diff --git a/RateAppSource/RateController/Classes/clsRelays.cs b/RateAppSource/RateController/Classes/clsRelays.cs index ba692e40..e23ff333 100644 --- a/RateAppSource/RateController/Classes/clsRelays.cs +++ b/RateAppSource/RateController/Classes/clsRelays.cs @@ -62,38 +62,45 @@ public int PowerRelays(int ModuleID) public void Renumber(int StartRelay, int StartModule, int StartSection) { - int CurrentSection = StartSection; - int FirstRelay; - for (int j = StartModule; j < 8; j++) + try { - if (j == StartModule) + int CurrentSection = StartSection; + int FirstRelay; + for (int j = StartModule; j < 8; j++) { - FirstRelay = StartRelay; - } - else - { - FirstRelay = 0; - } - for (int i = FirstRelay; i < 16; i++) - { - clsRelay Rly = Item(i, j); - int tmp = Rly.SectionID; - //if (Rly.Type == RelayTypes.None && CurrentSection < mf.MaxSections) Rly.Type = RelayTypes.Section; - if (Rly.Type == RelayTypes.Section || Rly.Type == RelayTypes.Invert_Section - || ((Rly.Type == RelayTypes.TramRight || Rly.Type == RelayTypes.TramLeft) && tmp > 0)) + if (j == StartModule) { - if (CurrentSection < mf.MaxSections) - { - Rly.SectionID = CurrentSection; - CurrentSection++; - } - else + FirstRelay = StartRelay; + } + else + { + FirstRelay = 0; + } + for (int i = FirstRelay; i < 16; i++) + { + clsRelay Rly = Item(i, j); + int tmp = Rly.SectionID; + //if (Rly.Type == RelayTypes.None && CurrentSection < mf.MaxSections) Rly.Type = RelayTypes.Section; + if (Rly.Type == RelayTypes.Section || Rly.Type == RelayTypes.Invert_Section + || ((Rly.Type == RelayTypes.TramRight || Rly.Type == RelayTypes.TramLeft) && tmp > 0)) { - Rly.Type = RelayTypes.None; + if (CurrentSection < mf.MaxSections) + { + Rly.SectionID = CurrentSection; + CurrentSection++; + } + else + { + Rly.Type = RelayTypes.None; + } } } } } + catch (Exception ex) + { + mf.Tls.WriteErrorLog("clsRelays/Renumber: " + ex.Message); + } } public void Reset() @@ -128,108 +135,115 @@ public void Save(int RelayID = 0, int ModuleID = 0) public int SetRelays(int ModuleID) { - // based on sections status and relay type set relays - // return int value for relayLo, relayHi + int Result = 0; + try + { + // based on sections status and relay type set relays + // return int value for relayLo, relayHi - bool SectionsOn = false; // whether at least on section is on - bool MasterOn = false; // whether at least one master relay is on - bool MasterFound = false; + bool SectionsOn = false; // whether at least on section is on + bool MasterOn = false; // whether at least one master relay is on + bool MasterFound = false; - // check if at least one section on - for (int i = 0; i < mf.MaxSections; i++) - { - if (mf.Sections.Item(i).IsON) + // check if at least one section on + for (int i = 0; i < mf.MaxSections; i++) { - SectionsOn = true; - break; + if (mf.Sections.Item(i).IsON) + { + SectionsOn = true; + break; + } } - } - // set master relay - for (int i = 0; i < cRelays.Count; i++) - { - clsRelay Rly = cRelays[i]; - - if (Rly.Type == RelayTypes.Master) + // set master relay + for (int i = 0; i < cRelays.Count; i++) { - Rly.IsON = SectionsOn; - MasterOn = SectionsOn; - MasterFound = true; + clsRelay Rly = cRelays[i]; + + if (Rly.Type == RelayTypes.Master) + { + Rly.IsON = SectionsOn; + MasterOn = SectionsOn; + MasterFound = true; + } } - } - // set hydraulic relays - HydUPDown(ModuleID); + // set hydraulic relays + HydUPDown(ModuleID); - // set tram lines, geo stop - for (int i = 0; i < cRelays.Count; i++) - { - clsRelay Rly = cRelays[i]; - if (Rly.ModuleID == ModuleID) + // set tram lines, geo stop + for (int i = 0; i < cRelays.Count; i++) { - if (Rly.Type == RelayTypes.TramLeft) Rly.IsON = mf.MachineData.TramLeft; - if (Rly.Type == RelayTypes.TramRight) Rly.IsON = mf.MachineData.TramRight; - if (Rly.Type == RelayTypes.GeoStop) Rly.IsON = mf.MachineData.GeoStop; + clsRelay Rly = cRelays[i]; + if (Rly.ModuleID == ModuleID) + { + if (Rly.Type == RelayTypes.TramLeft) Rly.IsON = mf.MachineData.TramLeft; + if (Rly.Type == RelayTypes.TramRight) Rly.IsON = mf.MachineData.TramRight; + if (Rly.Type == RelayTypes.GeoStop) Rly.IsON = mf.MachineData.GeoStop; + } } - } - // set section, slave, power relays - int Result = 0; - for (int i = 0; i < cRelays.Count; i++) - { - clsRelay Rly = cRelays[i]; - if (Rly.ModuleID == ModuleID) + // set section, slave, power relays + for (int i = 0; i < cRelays.Count; i++) { - switch (Rly.Type) + clsRelay Rly = cRelays[i]; + if (Rly.ModuleID == ModuleID) { - case RelayTypes.Section: - if (MasterFound && !MasterOn) - { - // leave relay to previous value, master relay is off - // do nothing - } - else - { - // set relay by section - Rly.IsON = mf.Sections.Items[Rly.SectionID].IsON; - } - break; - - case RelayTypes.Slave: - if (MasterFound && !MasterOn) - { - // leave relay to previous value, master relay is off - // do nothing - } - else - { - // set relay if at lease one section on - Rly.IsON = SectionsOn; - } - break; - - case RelayTypes.Power: - cRelays[i].IsON = true; - break; + switch (Rly.Type) + { + case RelayTypes.Section: + if (MasterFound && !MasterOn) + { + // leave relay to previous value, master relay is off + // do nothing + } + else + { + // set relay by section + Rly.IsON = mf.Sections.Items[Rly.SectionID].IsON; + } + break; + + case RelayTypes.Slave: + if (MasterFound && !MasterOn) + { + // leave relay to previous value, master relay is off + // do nothing + } + else + { + // set relay if at lease one section on + Rly.IsON = SectionsOn; + } + break; + + case RelayTypes.Power: + cRelays[i].IsON = true; + break; + + case RelayTypes.Invert_Section: + if (MasterFound && !MasterOn) + { + // leave relay to previous value, master relay is off + // do nothing + } + else + { + // set relay by section + Rly.IsON = !mf.Sections.Items[Rly.SectionID].IsON; + } + break; + } - case RelayTypes.Invert_Section: - if (MasterFound && !MasterOn) - { - // leave relay to previous value, master relay is off - // do nothing - } - else - { - // set relay by section - Rly.IsON = !mf.Sections.Items[Rly.SectionID].IsON; - } - break; + // build return int + if (Rly.IsON) Result |= (int)Math.Pow(2, i); } - - // build return int - if (Rly.IsON) Result |= (int)Math.Pow(2, i); } } + catch (Exception ex) + { + mf.Tls.WriteErrorLog("clsRelays/SetRelays: " + ex.Message); + } return Result; } diff --git a/RateAppSource/RateController/obj/Debug/RateController.csproj.GenerateResource.cache b/RateAppSource/RateController/obj/Debug/RateController.csproj.GenerateResource.cache index fe3fe440..064bba1a 100644 Binary files a/RateAppSource/RateController/obj/Debug/RateController.csproj.GenerateResource.cache and b/RateAppSource/RateController/obj/Debug/RateController.csproj.GenerateResource.cache differ diff --git a/RateAppSource/RateController/obj/Debug/RateController.exe b/RateAppSource/RateController/obj/Debug/RateController.exe index fd0a9607..a70db2b9 100644 Binary files a/RateAppSource/RateController/obj/Debug/RateController.exe and b/RateAppSource/RateController/obj/Debug/RateController.exe differ diff --git a/RateAppSource/RateController/obj/Debug/RateController.pdb b/RateAppSource/RateController/obj/Debug/RateController.pdb index 7b4834b3..a2bb5284 100644 Binary files a/RateAppSource/RateController/obj/Debug/RateController.pdb and b/RateAppSource/RateController/obj/Debug/RateController.pdb differ diff --git a/RateAppSource/RateController/obj/Debug/de/RateController.resources.dll b/RateAppSource/RateController/obj/Debug/de/RateController.resources.dll index 543264b6..0ed26806 100644 Binary files a/RateAppSource/RateController/obj/Debug/de/RateController.resources.dll and b/RateAppSource/RateController/obj/Debug/de/RateController.resources.dll differ diff --git a/RateAppSource/RateController/obj/Debug/nl/RateController.resources.dll b/RateAppSource/RateController/obj/Debug/nl/RateController.resources.dll index 200f800f..74dcaf00 100644 Binary files a/RateAppSource/RateController/obj/Debug/nl/RateController.resources.dll and b/RateAppSource/RateController/obj/Debug/nl/RateController.resources.dll differ diff --git a/RateControllerApp/RateController.exe b/RateControllerApp/RateController.exe index fd0a9607..a70db2b9 100644 Binary files a/RateControllerApp/RateController.exe and b/RateControllerApp/RateController.exe differ diff --git a/RateControllerApp/de/RateController.resources.dll b/RateControllerApp/de/RateController.resources.dll index 543264b6..0ed26806 100644 Binary files a/RateControllerApp/de/RateController.resources.dll and b/RateControllerApp/de/RateController.resources.dll differ diff --git a/RateControllerApp/fr/RateController.resources.dll b/RateControllerApp/fr/RateController.resources.dll index a63a92ff..2d255645 100644 Binary files a/RateControllerApp/fr/RateController.resources.dll and b/RateControllerApp/fr/RateController.resources.dll differ diff --git a/RateControllerApp/hu/RateController.resources.dll b/RateControllerApp/hu/RateController.resources.dll index 369e809c..fdc7d6cc 100644 Binary files a/RateControllerApp/hu/RateController.resources.dll and b/RateControllerApp/hu/RateController.resources.dll differ diff --git a/RateControllerApp/nl/RateController.resources.dll b/RateControllerApp/nl/RateController.resources.dll index 200f800f..74dcaf00 100644 Binary files a/RateControllerApp/nl/RateController.resources.dll and b/RateControllerApp/nl/RateController.resources.dll differ diff --git a/RateControllerApp/pl/RateController.resources.dll b/RateControllerApp/pl/RateController.resources.dll index fe44f345..1d071ce1 100644 Binary files a/RateControllerApp/pl/RateController.resources.dll and b/RateControllerApp/pl/RateController.resources.dll differ diff --git a/RateControllerApp/ru/RateController.resources.dll b/RateControllerApp/ru/RateController.resources.dll index 18e23ab8..e623aa96 100644 Binary files a/RateControllerApp/ru/RateController.resources.dll and b/RateControllerApp/ru/RateController.resources.dll differ