Skip to content

Commit

Permalink
Store booster's RCSs in new format. #192
Browse files Browse the repository at this point in the history
  • Loading branch information
horacekj committed Jun 12, 2022
1 parent d93269d commit bfd6990
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions src/boosters/Booster.pas
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ interface
TBoosterChangeEvent = procedure(Sender: TObject; state: TBoosterSignal) of object;

TBoosterSettings = record
id: string;
name: string;

RCS: record
overload: TRCSAddr;
power: TRCSAddr;
DCC: TRCSAddr; // DCC input; DCC nemusi byt detekovano, to se pozna tak, ze .board = 0
end;

id: string;
end;

TBooster = class
Expand Down Expand Up @@ -76,7 +75,7 @@ TBooster = class

implementation

uses GetSystems, fMain, RCS, TechnologieTrakce, Trakce;
uses GetSystems, fMain, RCS, TechnologieTrakce, Trakce, FileSystem;

{
Format datoveho souboru: .ini soubor, kazdy SPAX ma svou sekci
Expand Down Expand Up @@ -146,20 +145,9 @@ procedure TBooster.LoadDataFromFile(var ini: TMemIniFile; const section: string)
Self.m_settings.id := section;
Self.m_settings.name := ini.ReadString(section, 'name', 'booster');

Self.m_settings.RCS.overload.board := ini.ReadInteger(section, 'zkr_module', 0);
if (Self.m_settings.RCS.overload.board = 0) then
Self.m_settings.RCS.overload.board := ini.ReadInteger(section, 'zkr_mtb', 0);
Self.m_settings.RCS.overload.port := ini.ReadInteger(section, 'zkr_port', 0);

Self.m_settings.RCS.power.board := ini.ReadInteger(section, 'nap_module', 0);
if (Self.m_settings.RCS.power.board = 0) then
Self.m_settings.RCS.power.board := ini.ReadInteger(section, 'nap_mtb', 0);
Self.m_settings.RCS.power.port := ini.ReadInteger(section, 'nap_port', 0);

Self.m_settings.RCS.DCC.board := ini.ReadInteger(section, 'dcc_module', 0);
if (Self.m_settings.RCS.DCC.board = 0) then
Self.m_settings.RCS.DCC.board := ini.ReadInteger(section, 'dcc_mtb', 0);
Self.m_settings.RCS.DCC.port := ini.ReadInteger(section, 'dcc_port', 0);
Self.m_settings.RCS.overload := RCSFromIni(ini, section, 'short', 'zkr_module', 'zkr_port');
Self.m_settings.RCS.power := RCSFromIni(ini, section, 'power', 'nap_module', 'nap_port');
Self.m_settings.RCS.DCC := RCSFromIni(ini, section, 'dcc', 'dcc_module', 'dcc_port');

if (Self.isPowerDetection) then
RCSi.SetNeeded(Self.m_settings.RCS.power.board);
Expand All @@ -172,22 +160,11 @@ procedure TBooster.SaveDataToFile(var ini: TMemIniFile; const section: string);
ini.WriteString(section, 'name', Self.m_settings.name);

if (Self.isOverloadDetection) then
begin
ini.WriteInteger(section, 'zkr_module', Self.m_settings.RCS.overload.board);
ini.WriteInteger(section, 'zkr_port', Self.m_settings.RCS.overload.port);
end;

ini.WriteString(section, 'short', Self.m_settings.RCS.overload.ToString());
if (Self.isPowerDetection) then
begin
ini.WriteInteger(section, 'nap_module', Self.m_settings.RCS.power.board);
ini.WriteInteger(section, 'nap_port', Self.m_settings.RCS.power.port);
end;

ini.WriteString(section, 'power', Self.m_settings.RCS.power.ToString());
if (Self.isDCCdetection) then
begin
ini.WriteInteger(section, 'dcc_module', Self.m_settings.RCS.DCC.board);
ini.WriteInteger(section, 'dcc_port', Self.m_settings.RCS.DCC.port);
end;
ini.WriteString(section, 'dcc', Self.m_settings.RCS.DCC.ToString());
end;

/// /////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit bfd6990

Please sign in to comment.