From b8bc03240b7657bb8681b0f718ca2fe35ccfb59e Mon Sep 17 00:00:00 2001 From: Thomas Wiedebusch Date: Wed, 10 Sep 2025 17:08:00 +0200 Subject: [PATCH] SIRT setup to SirtConfig file --- .../GenesisConfig/CommunicationConfig.cs | 2 +- .../GenesisConfig/GenesisConfig.csproj | 5 + .../Genesis/GenesisConfig/ProcessConfig.cs | 40 ++--- .../Genesis/GenesisConfig/SirtConfig.cs | 81 ++++++++++ .../Genesis/GenesisCore/GenesisMeter.cs | 5 +- .../Genesis/GenesisCore/RegisterRestorer.cs | 2 - ...erRegisters.csproj.CoreCompileInputs.cache | 2 +- .../ProductionUiCordonel/App.config | 9 +- .../EolProcesses/CheckRadio.cs | 137 ++++------------ .../EolProcesses/ExecFinalParametrization.cs | 13 +- .../EolProcesses/ExecRebootCordonel.cs | 1 + .../RFTelegrams/AppCode.cs | 2 +- .../ProductionProcesses/RFTelegrams/SEMI.cs | 21 +-- .../Ui/GenesisToolBox/GenesisToolBox.csproj | 1 - Common/Ui/GenesisToolBox/ProccessConfig.cs | 12 -- Common/Ui/GenesisToolBox/frmSetup.Designer.cs | 147 +++++++++++++++--- Common/Ui/GenesisToolBox/frmSetup.cs | 59 +++++-- Common/Ui/GenesisToolBox/frmSetup.resx | 24 +++ 18 files changed, 366 insertions(+), 197 deletions(-) create mode 100644 Common/Hardware/WaterMeter/Genesis/GenesisConfig/SirtConfig.cs delete mode 100644 Common/Ui/GenesisToolBox/ProccessConfig.cs diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisConfig/CommunicationConfig.cs b/Common/Hardware/WaterMeter/Genesis/GenesisConfig/CommunicationConfig.cs index 9af01cc6..46fadc70 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisConfig/CommunicationConfig.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisConfig/CommunicationConfig.cs @@ -49,7 +49,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig /// /// Send delay between records in milliseconds before - /// new record is going to be send or between retries, + /// new record is going to be sent or between retries, /// this time is independent of the timeout, it is /// used to delay the next send record after successful /// response from meter. diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisConfig/GenesisConfig.csproj b/Common/Hardware/WaterMeter/Genesis/GenesisConfig/GenesisConfig.csproj index aaa32536..05b22dad 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisConfig/GenesisConfig.csproj +++ b/Common/Hardware/WaterMeter/Genesis/GenesisConfig/GenesisConfig.csproj @@ -100,10 +100,15 @@ + + + {1B02C79E-0B19-43E2-8F6B-71EF0C786C97} + CommonCore + {2E139F63-B6FE-4EA9-A098-85364FE9B26C} PortCore diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisConfig/ProcessConfig.cs b/Common/Hardware/WaterMeter/Genesis/GenesisConfig/ProcessConfig.cs index ddf3bb89..901a775b 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisConfig/ProcessConfig.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisConfig/ProcessConfig.cs @@ -2,6 +2,7 @@ using System.ComponentModel; using System.IO; using Newtonsoft.Json; +using Xylem.Common.CommonCore.Consts; namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig { @@ -10,35 +11,26 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig /// public class ProcessConfig { - /// - /// ctor - /// - public ProcessConfig() - { - UseRegisterWatchService = false; - UseErrorLogger = false; - AutoUpdateFiles = false; - ProductionMode = true; - } - /// /// Load configuration file from AppRoaming or working directory /// - /// - public ProcessConfig(String file) + public Boolean ReadProcessConfig() { - // check for AppRoaming - var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(Genesis), file); + // Check for AppRoaming + var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + nameof(Genesis), ProgramConfig.MeterConfigFileName); if (!File.Exists(configFile)) { - // take actual working directory - configFile = Path.Combine(file); + // Take actual working directory + configFile = Path.Combine(ProgramConfig.MeterConfigFileName); if (!File.Exists(configFile)) { UseRegisterWatchService = false; UseErrorLogger = false; - return; + AutoUpdateFiles = false; + ProductionMode = true; + return false; } } @@ -54,21 +46,21 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig CalibrationLoggerServiceUrl = meterConfig.CalibrationLoggerServiceUrl; AutoUpdateFiles = meterConfig.AutoUpdateFiles; ProductionMode = meterConfig.ProductionMode; - } + return true; } /// /// Write file to AppRoaming and backup it to actual working directory /// - /// - public void Update(String file) + public void Update() { - var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(Genesis), file); + var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + nameof(Genesis), ProgramConfig.MeterConfigFileName); File.WriteAllText(configFile, JsonConvert.SerializeObject(this)); - File.WriteAllText(file, JsonConvert.SerializeObject(this)); + File.WriteAllText(ProgramConfig.MeterConfigFileName, JsonConvert.SerializeObject(this)); } /// @@ -114,6 +106,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig [DefaultValue(true)] [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public Boolean ProductionMode { get; set; } = true; + public Boolean ProductionMode { get; set; } } } diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisConfig/SirtConfig.cs b/Common/Hardware/WaterMeter/Genesis/GenesisConfig/SirtConfig.cs new file mode 100644 index 00000000..83bd9804 --- /dev/null +++ b/Common/Hardware/WaterMeter/Genesis/GenesisConfig/SirtConfig.cs @@ -0,0 +1,81 @@ +using System; +using System.IO; +using Newtonsoft.Json; +using Xylem.Common.CommonCore.Consts; + +namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig +{ + /// + /// Configuration of SIRT + /// + public class SirtConfig + { + /// + /// Load SIRT configuration file from AppRoaming or working directory + /// + public Boolean ReadSirtConfig() + { + // Check for AppRoaming + var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + nameof(Genesis), ProgramConfig.SirtConfigFileName); + + if (!File.Exists(configFile)) + { + // Take actual working directory + configFile = Path.Combine(ProgramConfig.SirtConfigFileName); + if (!File.Exists(configFile)) + { + SirtComport433MHz = null; + SirtComport868MHz = null; + SirtBoxNo = null; + StationId = null; + return false; + } + } + + using (var tr = new StreamReader(configFile)) + { + var sirtConfig = JsonConvert.DeserializeObject(tr.ReadToEnd()); + SirtComport433MHz = sirtConfig.SirtComport433MHz; + SirtComport868MHz = sirtConfig.SirtComport868MHz; + SirtBoxNo = sirtConfig.SirtBoxNo; + StationId = sirtConfig.StationId; + } + + return true; + } + + /// + /// Write file to AppRoaming and backup it to actual working directory + /// + public void Update() + { + var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + nameof(Genesis), ProgramConfig.SirtConfigFileName); + + File.WriteAllText(configFile, JsonConvert.SerializeObject(this)); + File.WriteAllText(ProgramConfig.SirtConfigFileName, JsonConvert.SerializeObject(this)); + } + + /// + /// Comport for SIRT interface with 433MHz radio frequency + /// + public String SirtComport433MHz { get; set; } + + /// + /// Comport for SIRT interface with 868MHz radio frequency + /// + public String SirtComport868MHz { get; set; } + + /// + /// Box number for calibration settings + /// + public Int32? SirtBoxNo { get; set; } + + /// + /// Station ID where the SIRT is used + /// + public Int32? StationId { get; set; } + + } +} diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs index 3ee9ee24..b1a62e98 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs @@ -142,7 +142,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore /// /// Process configuration /// - public ProcessConfig Configuration { internal set; get; } = new ProcessConfig(); + public ProcessConfig Configuration { internal set; get; } //= new ProcessConfig(); /// /// Transmit protocol access for underlie objects to change response timeout @@ -798,7 +798,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore ledTransmit.GetTransmitPortSettings()); StreamingProtocol = new StreamingProtocol(streamingIdent, ignoreCorruptedData); } - Configuration = new ProcessConfig(ProgramConfig.MeterConfigFileName); + Configuration = new ProcessConfig(); + Configuration.ReadProcessConfig(); Logger.Debug($"Slot:{Slot} - Setup done"); } diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/RegisterRestorer.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/RegisterRestorer.cs index 6f644526..d7e5a6de 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/RegisterRestorer.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/RegisterRestorer.cs @@ -95,7 +95,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore private static readonly List _excludedFromCompareParameters = new List { "CUSTOMER_AlarmVisualMask", // Fully hard coded, cannot be overwritten - //"CUSTOMER_AlarmEnableMask", //Depending on FW version Will be overwritten by SENSUSRADIO if set System state to 0xFF "CUSTOMER_AppArrangement", // Is read only, makes no sense to compare anything "SENSUSRADIO_UpgFWVersion" // After a FW-Update the FW version has changed }; @@ -111,7 +110,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore /// private static readonly List _fieldUpdateBlacklist = new List { - //TODO THW "CUSTOMER_AlarmEnableMask", // Under discussion "CUSTOMER_AlarmVisualMask", "CUSTOMER_BackupCalendarSeconds", "CUSTOMER_InstallationTime", diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache index 8865d283..4163759b 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache +++ b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -89102b0142e574de38a9f47d370f3334e5e6c268 +8cb55c312de586b683d72cf58c13e2801d10e14b767777d98338d3e1473a1213 diff --git a/Common/Production/ProductionUiCordonel/App.config b/Common/Production/ProductionUiCordonel/App.config index 2f670969..45ce790e 100644 --- a/Common/Production/ProductionUiCordonel/App.config +++ b/Common/Production/ProductionUiCordonel/App.config @@ -35,11 +35,10 @@ - - - - - + + + + diff --git a/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs b/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs index a1c31908..fc1bb98c 100644 --- a/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs +++ b/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs @@ -2,7 +2,6 @@ using Newtonsoft.Json.Linq; using SIRTCOM; using System; -using System.Configuration; using System.Linq; using System.Net; using System.Threading; @@ -10,6 +9,7 @@ using System.Windows.Threading; using System.Xml.Linq; using Xylem.Common.CommonCore.Configuration; using Xylem.Common.CommonCore.Consts; +using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig; using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; using Xylem.Common.Logic.ProductionOrderCore; using Xylem.Common.Logic.SoftwareAccessHelper; @@ -18,6 +18,7 @@ using Xylem.Common.Production.ProductionUiCordonel.Properties; using Xylem.Common.Production.ProductionUiCordonel.UserControls; using Xylem.Common.Utils.Logging; using Button = System.Windows.Controls.Button; + // ReSharper disable UnusedAutoPropertyAccessor.Local namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolProcesses @@ -104,7 +105,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr /// /// Comport number of SIRT /// - private Byte _sirtComport; + private Int32 _sirtComport; /// /// Radio address Cordonel @@ -127,10 +128,6 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr { Retry(); }; - //_checkRadioUserControl.OnDoneRequested += delegate - //{ - // SaveRssiLevelsToDb(); - //}; } /// @@ -181,6 +178,9 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr /// /// - Removed change and read back of MainAlarmMask and ExtendedAlarmMask. /// + /// + /// - Load settings from SIRT config file instead from AppConfig. + /// public override StatusReturn ExecuteProcess() { // This will force to reset all values, Sentinel and Prepare shipping will fail based on EOL Progress @@ -269,9 +269,22 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr SuccessMsgDispatcher(Resources.StrSuccessMsgDbToMeterEncryptionKey); ActualProcessProgress++; - _sirtComport = Convert.ToByte(ConfigurationManager.AppSettings[$"SirtComport{freq}"]); - //_sirtSecondComport = Convert.ToByte(ConfigurationManager.AppSettings[$"SirtComportAlarm{freq}"]); - _sirtBoxNr = Convert.ToByte(ConfigurationManager.AppSettings["SirtBoxNr"]); + // Load settings from SIRT config file + var sirtConfig = new SirtConfig(); + sirtConfig.ReadSirtConfig(); + + if (freq == 433 && sirtConfig.SirtComport433MHz != null) + { + int.TryParse(sirtConfig.SirtComport433MHz.Replace("COM", ""), out _sirtComport); + } + + if (freq == 868 && sirtConfig.SirtComport433MHz != null) + { + int.TryParse(sirtConfig.SirtComport868MHz.Replace("COM", ""), out _sirtComport); + } + + if (sirtConfig.SirtBoxNo != null) + _sirtBoxNr = (Byte)sirtConfig.SirtBoxNo; var ucRadio = (UcRadioCheck)UserControl; ucRadio.SetHeadline($"{Resources.StrStateRadioCheck} BOX: {_sirtBoxNr}"); @@ -329,100 +342,6 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr SuccessMsgDispatcher(Resources.StrSuccessMsgRadioInCustomerMode); - //// Initialize the SIRT - //if (!SirtInit()) - //{ - // return SetTestFailed(Resources.StrErrorMsgSirt); - //} - - ////Radio rest alarms - ////readout wakeup, interval - ////start process - ////wait for process exit code - //var WakUpRestore = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_WakeupInterval")); - //var TxIntervalRestore = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_TxInterval")); - //var LatRestore = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_LatInterval")); - //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_WakeupInterval", - //new Byte[] { 0x00 }, ProgrammingSource.ProgramInternal)); - //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_TxInterval", - //new Byte[] { 0x01 }, ProgrammingSource.ProgramInternal)); - - //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_LatInterval", RegisterConverter.ValueToByteArray(3), ProgrammingSource.ProgramInternal)); - - - //Meter.Logout(); - - //var process = new Process - //{ - // EnableRaisingEvents = true, - // StartInfo = new ProcessStartInfo - // { - // Arguments = $"COM{_sirtSecondComport} {_radioAddressCordonel} {_radioEncryptionKey}", - // FileName = @"\\sla12file\auftrag\ProductionUiCordonel\CommonConsoleV2\CommonConsole.exe", - // CreateNoWindow = true, - // UseShellExecute = false, - // RedirectStandardError = true, - // RedirectStandardOutput = true - // } - //}; - - //void logData(string data, bool error) - //{ - // if (!string.IsNullOrWhiteSpace(data)) - // { - // if (error) - // { - // ErrorMsgDispatcher(data.Trim()); - // } - // else - // { - // SuccessMsgDispatcher(data.Trim()); - // } - - // } - //} - - //process.ErrorDataReceived += (_, args) => logData(args.Data, true); - //process.OutputDataReceived += (_, args) => logData(args.Data, false); - - //process.Start(); - //process.BeginOutputReadLine(); - //process.BeginErrorReadLine(); - //process.WaitForExit(80_000); - //if (process.ExitCode != 0) - //{ - // ErrorMsgDispatcher($"AlarmReset failed ExitCode{process.ExitCode}"); - // return SetTestFailed($"AlarmReset failed ExitCode{process.ExitCode}"); - //} - ////restore - - //// reset system state back to shipping mode - - //Meter.Login(); - //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_WakeupInterval", RegisterConverter.ValueToByteArray(WakupRestore) , ProgrammingSource.ProgramInternal)); - //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_TxInterval", RegisterConverter.ValueToByteArray(TxIntervalRestore), ProgrammingSource.ProgramInternal)); - //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_LatInterval", RegisterConverter.ValueToByteArray(LatRestore), ProgrammingSource.ProgramInternal)); - - - - - //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_SystemState", - // new Byte[] { 0xFF }, ProgrammingSource.ProgramInternal)); - //ActualProcessProgress++; - - //_finalRadioSystemState = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_SystemState")); - //ActualProcessProgress++; - - //if (// radio system state 0x02 shipping mode, 0x01 production mode, 0x0C transmission and data logger active - // _finalRadioSystemState != 0x02 - // // If radio check is enabled the signal level has to be in range and the test has to be finished - // || (!skipRadioCheck && (!_successSignalLevel || !_sirtComOkay || !_testFinished))) - //{ - // return SetTestFailed(!_sirtComOkay ? Resources.StrErrorMsgSirt : Resources.StrErrorMsgRadioCheck); - //} - - - // Skip radio check by requirement if (skipRadioCheck) { @@ -945,14 +864,19 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr /// /// - Initial. /// - /// + /// /// - Multilingual. /// + /// + /// - Reworked. + /// private void CheckAlarmStateFromRF(params Byte[] telegram) { + if (telegram == null) return; + try { - var telegramLength = telegram?.Length ?? 0; + var telegramLength = telegram.Length; if (telegramLength <= 8) { @@ -960,8 +884,6 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr return; } - if (telegram == null) return; - var semiLength = Math.Min(telegram[7], (Byte)RFTelegrams.SEMI.MIN_LENGTH); if (telegramLength < semiLength) @@ -969,6 +891,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr ErrorMsgDispatcher(Resources.StrErrorMsgSemiTelegramLength); return; } + var mhz = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_FrequencyIndicator")); var semiBytes = new Byte[semiLength]; Array.Copy(telegram, 8, semiBytes, 0, semiLength); diff --git a/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/ExecFinalParametrization.cs b/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/ExecFinalParametrization.cs index 5ed18ce5..d9bd00df 100644 --- a/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/ExecFinalParametrization.cs +++ b/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/ExecFinalParametrization.cs @@ -101,6 +101,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr return StatusReturn.Failed; } } + // ReSharper disable once UnusedVariable used for DEBUG var readBackScaledBilling = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("GENESISFLOW_ScaledBilling")); @@ -120,7 +121,17 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr CancellationToken); RegisterRestorer.OnProcessUpdate -= ProcessUpdate_Handler; - + + // ReSharper disable once UnusedVariable used for DEBUG + readBackScaledBilling = + RegisterConverter.ByteArrayToValue(Meter.ReadRegister("GENESISFLOW_ScaledBilling")); + // ReSharper disable once UnusedVariable used for DEBUG + readBackUnscaledFwd = + RegisterConverter.ByteArrayToValue(Meter.ReadRegister("GENESISFLOW_UnscaledFwd")); + // ReSharper disable once UnusedVariable used for DEBUG + readBackUnscaledRev = + RegisterConverter.ByteArrayToValue(Meter.ReadRegister("GENESISFLOW_UnscaledRev")); + EolProgress.ParametrizationDoneChecked = retVal == StatusReturn.Okay ? EOLStatus.OK : EOLStatus.FAIL; return retVal; } diff --git a/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/ExecRebootCordonel.cs b/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/ExecRebootCordonel.cs index b4ba38c6..ad650b1e 100644 --- a/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/ExecRebootCordonel.cs +++ b/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/ExecRebootCordonel.cs @@ -162,6 +162,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr } } + // Check all values for 0 after reset and followed reboot which may use the var readBackScaledBilling = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("GENESISFLOW_ScaledBilling")); var readBackUnscaledFwd = diff --git a/Common/Production/ProductionUiCordonel/ProductionProcesses/RFTelegrams/AppCode.cs b/Common/Production/ProductionUiCordonel/ProductionProcesses/RFTelegrams/AppCode.cs index 8ed5ef38..4ce6d158 100644 --- a/Common/Production/ProductionUiCordonel/ProductionProcesses/RFTelegrams/AppCode.cs +++ b/Common/Production/ProductionUiCordonel/ProductionProcesses/RFTelegrams/AppCode.cs @@ -1,6 +1,6 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.RFTelegrams { - public enum AppCode + public enum AppCode { BUP = 0x00, LAT = 0x01, diff --git a/Common/Production/ProductionUiCordonel/ProductionProcesses/RFTelegrams/SEMI.cs b/Common/Production/ProductionUiCordonel/ProductionProcesses/RFTelegrams/SEMI.cs index 8ea57993..f84c7040 100644 --- a/Common/Production/ProductionUiCordonel/ProductionProcesses/RFTelegrams/SEMI.cs +++ b/Common/Production/ProductionUiCordonel/ProductionProcesses/RFTelegrams/SEMI.cs @@ -7,7 +7,8 @@ public class SEMI { - public const int MIN_LENGTH = 120; + //public const int MIN_LENGTH = 120; + public const int MIN_LENGTH = 97; public SEMI(byte[] payload, int mhz) { @@ -54,15 +55,15 @@ this.PulseOutParameter = payload[94]; this.AlarmByteExtended = payload[95]; this.AlarmMaskExtended = payload[96]; - this.AlarmMaxPressureTime = payload.ToUInt32BE(97); - this.AlarmMinPressureTime = payload.ToUInt32BE(101); - this.AlarmMaxTemperatureTime = payload.ToUInt32BE(105); - this.AlarmMinTemperatureTime = payload.ToUInt32BE(109); - this.LogContentPressureTemperature = payload.ToUInt16BE(113); - this.FDRContentPressureTemperature = payload.ToUInt16BE(115); - this.UnitExtraFlags = payload[117]; - this.MeterSize = payload[118]; - this.PressureCalibrationOffset = payload[119]; + //this.AlarmMaxPressureTime = payload.ToUInt32BE(97); + //this.AlarmMinPressureTime = payload.ToUInt32BE(101); + //this.AlarmMaxTemperatureTime = payload.ToUInt32BE(105); + //this.AlarmMinTemperatureTime = payload.ToUInt32BE(109); + //this.LogContentPressureTemperature = payload.ToUInt16BE(113); + //this.FDRContentPressureTemperature = payload.ToUInt16BE(115); + //this.UnitExtraFlags = payload[117]; + //this.MeterSize = payload[118]; + //this.PressureCalibrationOffset = payload[119]; } public AppCode AppCode { get; } diff --git a/Common/Ui/GenesisToolBox/GenesisToolBox.csproj b/Common/Ui/GenesisToolBox/GenesisToolBox.csproj index 2588e772..75dc23fe 100644 --- a/Common/Ui/GenesisToolBox/GenesisToolBox.csproj +++ b/Common/Ui/GenesisToolBox/GenesisToolBox.csproj @@ -471,7 +471,6 @@ - diff --git a/Common/Ui/GenesisToolBox/ProccessConfig.cs b/Common/Ui/GenesisToolBox/ProccessConfig.cs deleted file mode 100644 index 19a46a64..00000000 --- a/Common/Ui/GenesisToolBox/ProccessConfig.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig; - -namespace Xylem.Common.Ui.GenesisToolBox -{ - internal class ProccessConfig : ProcessConfig - { - public ProccessConfig(String file) : base(file) - { - } - } -} \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/frmSetup.Designer.cs b/Common/Ui/GenesisToolBox/frmSetup.Designer.cs index 5d9ee225..8d46fd80 100644 --- a/Common/Ui/GenesisToolBox/frmSetup.Designer.cs +++ b/Common/Ui/GenesisToolBox/frmSetup.Designer.cs @@ -53,9 +53,6 @@ this.tabPage3 = new System.Windows.Forms.TabPage(); this.cmdAddOffline = new System.Windows.Forms.Button(); this.dgvofflinePw = new System.Windows.Forms.DataGridView(); - this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.offlinePaswordItemBindingSource = new System.Windows.Forms.BindingSource(this.components); this.tabPage4 = new System.Windows.Forms.TabPage(); this.lblGlobalCurrentPath = new System.Windows.Forms.Label(); this.btnGlobalSearch = new System.Windows.Forms.Button(); @@ -70,14 +67,27 @@ this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); + this.tabPage5 = new System.Windows.Forms.TabPage(); + this.lblSirtStation = new System.Windows.Forms.Label(); + this.lblSirtBoxNo = new System.Windows.Forms.Label(); + this.lblSirtComport433MHz = new System.Windows.Forms.Label(); + this.lblSirtComport868MHz = new System.Windows.Forms.Label(); + this.tbxSirtStationId = new System.Windows.Forms.TextBox(); + this.tbxSirtBoxNo = new System.Windows.Forms.TextBox(); + this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.offlinePaswordItemBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.cbxSirtComport433MHz = new System.Windows.Forms.ComboBox(); + this.cbxSirtComport868MHz = new System.Windows.Forms.ComboBox(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgvConfig)).BeginInit(); this.tabPage2.SuspendLayout(); this.tabPage3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgvofflinePw)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.offlinePaswordItemBindingSource)).BeginInit(); this.tabPage4.SuspendLayout(); + this.tabPage5.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.offlinePaswordItemBindingSource)).BeginInit(); this.SuspendLayout(); // // btnReload @@ -106,6 +116,7 @@ this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Controls.Add(this.tabPage4); + this.tabControl1.Controls.Add(this.tabPage5); this.tabControl1.Location = new System.Drawing.Point(12, 74); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; @@ -320,22 +331,6 @@ this.dgvofflinePw.Size = new System.Drawing.Size(345, 170); this.dgvofflinePw.TabIndex = 16; // - // dataGridViewTextBoxColumn1 - // - this.dataGridViewTextBoxColumn1.DataPropertyName = "PcbID"; - this.dataGridViewTextBoxColumn1.HeaderText = "PcbID"; - this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; - // - // dataGridViewTextBoxColumn2 - // - this.dataGridViewTextBoxColumn2.DataPropertyName = "Password"; - this.dataGridViewTextBoxColumn2.HeaderText = "Password"; - this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; - // - // offlinePaswordItemBindingSource - // - this.offlinePaswordItemBindingSource.DataSource = typeof(Xylem.Common.Ui.GenesisToolBox.OfflinePasswordItem); - // // tabPage4 // this.tabPage4.Controls.Add(this.lblGlobalCurrentPath); @@ -481,6 +476,105 @@ this.label2.TabIndex = 0; this.label2.Text = "Local (only ToolBox)"; // + // tabPage5 + // + this.tabPage5.Controls.Add(this.cbxSirtComport868MHz); + this.tabPage5.Controls.Add(this.cbxSirtComport433MHz); + this.tabPage5.Controls.Add(this.tbxSirtBoxNo); + this.tabPage5.Controls.Add(this.tbxSirtStationId); + this.tabPage5.Controls.Add(this.lblSirtComport868MHz); + this.tabPage5.Controls.Add(this.lblSirtComport433MHz); + this.tabPage5.Controls.Add(this.lblSirtBoxNo); + this.tabPage5.Controls.Add(this.lblSirtStation); + this.tabPage5.Location = new System.Drawing.Point(4, 22); + this.tabPage5.Name = "tabPage5"; + this.tabPage5.Size = new System.Drawing.Size(760, 361); + this.tabPage5.TabIndex = 4; + this.tabPage5.Text = "SIRT"; + this.tabPage5.UseVisualStyleBackColor = true; + // + // lblSirtStation + // + this.lblSirtStation.AutoSize = true; + this.lblSirtStation.Location = new System.Drawing.Point(22, 24); + this.lblSirtStation.Name = "lblSirtStation"; + this.lblSirtStation.Size = new System.Drawing.Size(57, 13); + this.lblSirtStation.TabIndex = 2; + this.lblSirtStation.Text = "Station ID:"; + // + // lblSirtBoxNo + // + this.lblSirtBoxNo.AutoSize = true; + this.lblSirtBoxNo.Location = new System.Drawing.Point(22, 51); + this.lblSirtBoxNo.Name = "lblSirtBoxNo"; + this.lblSirtBoxNo.Size = new System.Drawing.Size(45, 13); + this.lblSirtBoxNo.TabIndex = 3; + this.lblSirtBoxNo.Text = "Box No:"; + // + // lblSirtComport433MHz + // + this.lblSirtComport433MHz.AutoSize = true; + this.lblSirtComport433MHz.Location = new System.Drawing.Point(22, 78); + this.lblSirtComport433MHz.Name = "lblSirtComport433MHz"; + this.lblSirtComport433MHz.Size = new System.Drawing.Size(95, 13); + this.lblSirtComport433MHz.TabIndex = 4; + this.lblSirtComport433MHz.Text = "Comport 433 MHz:"; + // + // lblSirtComport868MHz + // + this.lblSirtComport868MHz.AutoSize = true; + this.lblSirtComport868MHz.Location = new System.Drawing.Point(22, 106); + this.lblSirtComport868MHz.Name = "lblSirtComport868MHz"; + this.lblSirtComport868MHz.Size = new System.Drawing.Size(95, 13); + this.lblSirtComport868MHz.TabIndex = 5; + this.lblSirtComport868MHz.Text = "Comport 868 MHz:"; + // + // tbxSirtStationId + // + this.tbxSirtStationId.Location = new System.Drawing.Point(142, 17); + this.tbxSirtStationId.Name = "tbxSirtStationId"; + this.tbxSirtStationId.Size = new System.Drawing.Size(100, 20); + this.tbxSirtStationId.TabIndex = 6; + // + // tbxSirtBoxNo + // + this.tbxSirtBoxNo.Location = new System.Drawing.Point(142, 44); + this.tbxSirtBoxNo.Name = "tbxSirtBoxNo"; + this.tbxSirtBoxNo.Size = new System.Drawing.Size(100, 20); + this.tbxSirtBoxNo.TabIndex = 7; + // + // dataGridViewTextBoxColumn1 + // + this.dataGridViewTextBoxColumn1.DataPropertyName = "PcbID"; + this.dataGridViewTextBoxColumn1.HeaderText = "PcbID"; + this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; + // + // dataGridViewTextBoxColumn2 + // + this.dataGridViewTextBoxColumn2.DataPropertyName = "Password"; + this.dataGridViewTextBoxColumn2.HeaderText = "Password"; + this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; + // + // offlinePaswordItemBindingSource + // + this.offlinePaswordItemBindingSource.DataSource = typeof(Xylem.Common.Ui.GenesisToolBox.OfflinePasswordItem); + // + // cbxSirtComport433MHz + // + this.cbxSirtComport433MHz.FormattingEnabled = true; + this.cbxSirtComport433MHz.Location = new System.Drawing.Point(142, 75); + this.cbxSirtComport433MHz.Name = "cbxSirtComport433MHz"; + this.cbxSirtComport433MHz.Size = new System.Drawing.Size(121, 21); + this.cbxSirtComport433MHz.TabIndex = 8; + // + // cbxSirtComport868MHz + // + this.cbxSirtComport868MHz.FormattingEnabled = true; + this.cbxSirtComport868MHz.Location = new System.Drawing.Point(142, 102); + this.cbxSirtComport868MHz.Name = "cbxSirtComport868MHz"; + this.cbxSirtComport868MHz.Size = new System.Drawing.Size(121, 21); + this.cbxSirtComport868MHz.TabIndex = 9; + // // FrmSetup // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -500,9 +594,11 @@ this.tabPage2.PerformLayout(); this.tabPage3.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dgvofflinePw)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.offlinePaswordItemBindingSource)).EndInit(); this.tabPage4.ResumeLayout(false); this.tabPage4.PerformLayout(); + this.tabPage5.ResumeLayout(false); + this.tabPage5.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.offlinePaswordItemBindingSource)).EndInit(); this.ResumeLayout(false); } @@ -550,5 +646,14 @@ private System.Windows.Forms.Button btnGlobalDefaultLan; private System.Windows.Forms.Button btnGlobalDefaultLocal; private System.Windows.Forms.Label label6; + private System.Windows.Forms.TabPage tabPage5; + private System.Windows.Forms.Label lblSirtComport868MHz; + private System.Windows.Forms.Label lblSirtComport433MHz; + private System.Windows.Forms.Label lblSirtBoxNo; + private System.Windows.Forms.Label lblSirtStation; + private System.Windows.Forms.TextBox tbxSirtBoxNo; + private System.Windows.Forms.TextBox tbxSirtStationId; + private System.Windows.Forms.ComboBox cbxSirtComport868MHz; + private System.Windows.Forms.ComboBox cbxSirtComport433MHz; } } \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/frmSetup.cs b/Common/Ui/GenesisToolBox/frmSetup.cs index df9b83f4..fa7a64a2 100644 --- a/Common/Ui/GenesisToolBox/frmSetup.cs +++ b/Common/Ui/GenesisToolBox/frmSetup.cs @@ -39,9 +39,10 @@ namespace Xylem.Common.Ui.GenesisToolBox private readonly String _serialConfigFilePathName; private readonly String _offlinePwdPathName; private readonly DataTable _slotConfigDataTable = new DataTable(); - - - private readonly ProcessConfig _configuration; + //private readonly List _sirt433MhzComports = new List(); + //private readonly List _sirt868MHzComports = new List(); + private readonly SirtConfig _sirtConfig = new SirtConfig(); + private readonly ProcessConfig _configuration = new ProcessConfig(); /// /// Ctor @@ -78,12 +79,33 @@ namespace Xylem.Common.Ui.GenesisToolBox cbcSlotType.HeaderText = SlotTypeString; LoadFromFile(); - _configuration = new ProcessConfig(ProgramConfig.MeterConfigFileName); + _configuration.ReadProcessConfig(); cbUseMinMaxCheck.Checked = _configuration.UseMinMaxCheck; cbUseRegisterWatch.Checked = _configuration.UseRegisterWatchService; txtWachSeriveUrl.Text = _configuration.RegisterWatchServiceUrl; cbUpdateFiles.Checked = _configuration.AutoUpdateFiles; cbxProductionMode.Checked = _configuration.ProductionMode; + + _sirtConfig.ReadSirtConfig(); + tbxSirtStationId.Text = _sirtConfig.StationId?.ToString(); + tbxSirtBoxNo.Text = _sirtConfig.SirtBoxNo?.ToString(); + + if (_sirtConfig.SirtComport433MHz != null) + cbxSirtComport433MHz.Items.Add(_sirtConfig.SirtComport433MHz); + if (_sirtConfig.SirtComport868MHz != null) + cbxSirtComport868MHz.Items.Add(_sirtConfig.SirtComport868MHz); + var comPorts = SerialPort.GetPortNames().ToList(); + foreach (var comPort in comPorts.Where(comPort => !cbxSirtComport433MHz.Items.Contains(comPort))) + { + cbxSirtComport433MHz.Items.Add(comPort); + } + foreach (var comPort in comPorts.Where(comPort => !cbxSirtComport868MHz.Items.Contains(comPort))) + { + cbxSirtComport868MHz.Items.Add(comPort); + } + + cbxSirtComport433MHz.Text = cbxSirtComport433MHz.Items[0].ToString(); + cbxSirtComport868MHz.Text = cbxSirtComport868MHz.Items[0].ToString(); } private void BtnReload_Click(Object sender, EventArgs e) @@ -96,6 +118,25 @@ namespace Xylem.Common.Ui.GenesisToolBox { StoreToPc(); StoreOfflineFile(); + StoreSirtSettings(); + } + + private void StoreSirtSettings() + { + // Get the SIRT settings from the GUI + if (int.TryParse(tbxSirtStationId.Text, out var intNo)) + { + _sirtConfig.StationId = intNo; + } + + if (int.TryParse(tbxSirtBoxNo.Text, out intNo)) + { + _sirtConfig.SirtBoxNo = intNo; + } + + _sirtConfig.SirtComport433MHz = cbxSirtComport433MHz.Text; + _sirtConfig.SirtComport868MHz = cbxSirtComport868MHz.Text; + _sirtConfig.Update(); } private void StoreToPc() @@ -401,28 +442,28 @@ namespace Xylem.Common.Ui.GenesisToolBox private void cbUseRegisterWatch_CheckedChanged(Object sender, EventArgs e) { _configuration.UseRegisterWatchService = cbUseRegisterWatch.Checked; - _configuration.Update(ProgramConfig.MeterConfigFileName); + _configuration.Update(); StoreToPc(); } private void cbUseMinMaxCheck_CheckedChanged(Object sender, EventArgs e) { _configuration.UseMinMaxCheck = cbUseMinMaxCheck.Checked; - _configuration.Update(ProgramConfig.MeterConfigFileName); + _configuration.Update(); StoreToPc(); } private void textBox1_TextChanged(Object sender, EventArgs e) { _configuration.RegisterWatchServiceUrl = txtWachSeriveUrl.Text; - _configuration.Update(ProgramConfig.MeterConfigFileName); + _configuration.Update(); StoreToPc(); } private void cbUpdateFiles_CheckedChanged(Object sender, EventArgs e) { _configuration.AutoUpdateFiles = cbUpdateFiles.Checked; - _configuration.Update(ProgramConfig.MeterConfigFileName); + _configuration.Update(); StoreToPc(); } @@ -511,7 +552,7 @@ namespace Xylem.Common.Ui.GenesisToolBox } _configuration.ProductionMode = cbxProductionMode.Checked; - _configuration.Update(ProgramConfig.MeterConfigFileName); + _configuration.Update(); StoreToPc(); } diff --git a/Common/Ui/GenesisToolBox/frmSetup.resx b/Common/Ui/GenesisToolBox/frmSetup.resx index 8a662b3c..fd796a2b 100644 --- a/Common/Ui/GenesisToolBox/frmSetup.resx +++ b/Common/Ui/GenesisToolBox/frmSetup.resx @@ -138,6 +138,30 @@ True + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + 17, 17 + 17, 17