From 3cd488fc76dda1888393654c896e439da5c98e78 Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Wed, 27 May 2026 14:00:40 +0200 Subject: [PATCH] Increment assembly version to `3.9.3121.1`, add `FailedPrepare` error constant and handling in `iPerlCommunicationForm`, enhance `PrepareSlotQ3Calibration` and `WriteSlotQ3Calibration` with exception handling and logging, introduce `IsCalibFactorValid` property and mappings for calibration logic, and extend debug logging across Genesis operations. --- Results/DB.cs | 57 ++- Results/Entities/TestRsltCalibFactor.cs | 3 + .../helpers/DatabaseMigrationHelper.cs | 3 +- .../helpers/TestRsltCalibFactorHelper.cs | 8 + Results/Mappings/MeterTestRsltMap.cs | 2 +- Results/Mappings/TestRsltCalibFactorMap.cs | 1 + Results/Mappings/WaterMeterDataMap.cs | 2 +- TBF/Properties/AssemblyInfo.cs | 4 +- .../communication/OptoHeadTest.cs | 468 ++++++++++++++---- .../implementations/GenesisSmartReader.cs | 116 ++--- .../communication/RadioService.cs | 1 + .../iPerlCommunicationForm.cs | 150 ++++-- TBFTests/DBTest.cs | 2 + .../OptoHeadTestImpelementations.cs | 67 ++- .../GenesisSmartReader_Q3Test.cs | 53 +- .../Logic.ProductionToProductMapper.dll | Bin 15360 -> 15360 bytes .../Logic.ProductionToProductMapper.pdb | Bin 56832 -> 56832 bytes .../Xylem.Common.CommonCore.Configuration.dll | Bin 28160 -> 28160 bytes .../Xylem.Common.CommonCore.Configuration.pdb | Bin 36352 -> 36352 bytes .../Xylem.Common.CommonCore.ThreadWatcher.dll | Bin 6144 -> 6144 bytes .../Xylem.Common.CommonCore.ThreadWatcher.pdb | Bin 19968 -> 19968 bytes packages/Common/Xylem.Common.CommonCore.dll | Bin 7680 -> 7680 bytes packages/Common/Xylem.Common.CommonCore.pdb | Bin 30208 -> 30208 bytes ...mon.Hardware.Interfaces.Ports.PortCore.dll | Bin 7680 -> 7680 bytes ...mon.Hardware.Interfaces.Ports.PortCore.pdb | Bin 34304 -> 34304 bytes ....Hardware.Interfaces.Ports.SerialPorts.dll | Bin 17920 -> 17920 bytes ....Hardware.Interfaces.Ports.SerialPorts.pdb | Bin 38400 -> 38400 bytes ....Interfaces.Protocols.TransmitProtocol.dll | Bin 11264 -> 11264 bytes ....Interfaces.Protocols.TransmitProtocol.pdb | Bin 36352 -> 36352 bytes ...rdware.WaterMeter.Genesis.Applications.dll | Bin 12288 -> 12288 bytes ...rdware.WaterMeter.Genesis.Applications.pdb | Bin 36352 -> 36352 bytes ...rdware.WaterMeter.Genesis.DataPackages.dll | Bin 10752 -> 10752 bytes ...rdware.WaterMeter.Genesis.DataPackages.pdb | Bin 36352 -> 36352 bytes ...dware.WaterMeter.Genesis.GenesisConfig.dll | Bin 9728 -> 9728 bytes ...dware.WaterMeter.Genesis.GenesisConfig.pdb | Bin 30208 -> 30208 bytes ...ardware.WaterMeter.Genesis.GenesisCore.dll | Bin 158720 -> 158720 bytes ...ardware.WaterMeter.Genesis.GenesisCore.pdb | Bin 243200 -> 243200 bytes ...ardware.WaterMeter.Genesis.GenesisFile.dll | Bin 73216 -> 73216 bytes ...ardware.WaterMeter.Genesis.GenesisFile.pdb | Bin 167424 -> 167424 bytes ...Hardware.WaterMeter.Genesis.GenesisPwd.dll | Bin 7168 -> 7168 bytes ...eter.Genesis.Protocols.RequestProtocol.dll | Bin 20480 -> 20480 bytes ...eter.Genesis.Protocols.RequestProtocol.pdb | Bin 40448 -> 40448 bytes ...er.Genesis.Protocols.StreamingProtocol.dll | Bin 13312 -> 13312 bytes ...er.Genesis.Protocols.StreamingProtocol.pdb | Bin 24064 -> 24064 bytes ....Hardware.WaterMeter.Genesis.Registers.dll | Bin 34816 -> 34816 bytes ....Hardware.WaterMeter.Genesis.Registers.pdb | Bin 101888 -> 101888 bytes ...mon.Hardware.WaterMeter.WaterMeterCore.dll | Bin 16896 -> 16896 bytes ...mon.Hardware.WaterMeter.WaterMeterCore.pdb | Bin 58880 -> 58880 bytes ...ardware.WaterMeter.WaterMeterRegisters.dll | Bin 5120 -> 5120 bytes ...ardware.WaterMeter.WaterMeterRegisters.pdb | Bin 19968 -> 19968 bytes ...Xylem.Common.Logic.ProductionOrderCore.dll | Bin 192512 -> 192512 bytes ...Xylem.Common.Logic.ProductionOrderCore.pdb | Bin 429568 -> 429568 bytes .../Common/Xylem.Common.Logic.RelatePcb.dll | Bin 5120 -> 5120 bytes .../Common/Xylem.Common.Logic.RelatePcb.pdb | Bin 17920 -> 17920 bytes .../Common/Xylem.Common.Logic.ServiceCore.dll | Bin 8192 -> 8192 bytes .../Common/Xylem.Common.Logic.ServiceCore.pdb | Bin 22016 -> 22016 bytes ...ylem.Common.Logic.SoftwareAccessHelper.dll | Bin 13312 -> 13312 bytes ...ylem.Common.Logic.SoftwareAccessHelper.pdb | Bin 36352 -> 36352 bytes .../Xylem.Common.Metrology.Measurements.dll | Bin 15360 -> 15360 bytes .../Xylem.Common.Metrology.Measurements.pdb | Bin 42496 -> 42496 bytes ...ylem.Common.Ui.CordonelPreadjustmentUi.pdb | Bin 396800 -> 396800 bytes .../Common/Xylem.Common.Ui.GenesisToolBox.exe | Bin 526336 -> 526336 bytes .../Common/Xylem.Common.Ui.GenesisToolBox.pdb | Bin 851456 -> 851456 bytes .../Xylem.Common.Utils.ByteArrayStyle.dll | Bin 5120 -> 5120 bytes .../Xylem.Common.Utils.ByteArrayStyle.pdb | Bin 17920 -> 17920 bytes .../Common/Xylem.Common.Utils.Crc16Ccitt.dll | Bin 4608 -> 4608 bytes .../Common/Xylem.Common.Utils.Crc16Ccitt.pdb | Bin 19968 -> 19968 bytes .../Common/Xylem.Common.Utils.Logging.dll | Bin 11776 -> 11776 bytes .../Common/Xylem.Common.Utils.Logging.pdb | Bin 30208 -> 30208 bytes .../Common/Xylem.Common.Utils.ProcessExec.dll | Bin 7168 -> 7168 bytes .../Common/Xylem.Common.Utils.ProcessExec.pdb | Bin 19968 -> 19968 bytes packages/Common/XylemCommonUiLegacyGenCtl.dll | Bin 179712 -> 179712 bytes packages/Common/XylemCommonUiLegacyGenCtl.pdb | Bin 329216 -> 329216 bytes 73 files changed, 680 insertions(+), 257 deletions(-) diff --git a/Results/DB.cs b/Results/DB.cs index c81fec55b..ff2e5819a 100644 --- a/Results/DB.cs +++ b/Results/DB.cs @@ -307,38 +307,45 @@ namespace Results { bool hasCalibrationFactors = false; - foreach (var tstRslt in batch.TestRslts) + try { - if (tstRslt.CalibFactorResultsToSave != null && - tstRslt.CalibFactorResultsToSave.Count > 0) - { - hasCalibrationFactors = true; - break; - } - } - - if (hasCalibrationFactors) - { - TestRsltCalibFactorHelper.CreateTableIfNotExists(session); foreach (var tstRslt in batch.TestRslts) { - if (tstRslt.CalibFactorResultsToSave == null || - tstRslt.CalibFactorResultsToSave.Count == 0) + if (tstRslt.CalibFactorResultsToSave != null && + tstRslt.CalibFactorResultsToSave.Count > 0) { - continue; - } - - TestRsltCalibFactorHelper.DeleteByTestRsltIdNoTransaction(session, tstRslt.Id); - - foreach (var calib in tstRslt.CalibFactorResultsToSave) - { - calib.TestRslt = tstRslt; - calib.ErrorStr = TestRsltCalibFactorHelper.Truncate(calib.ErrorStr, 240); - - session.SaveOrUpdate(calib); + hasCalibrationFactors = true; + break; } } + + if (hasCalibrationFactors) + { + TestRsltCalibFactorHelper.CreateTableIfNotExists(session); + + foreach (var tstRslt in batch.TestRslts) + { + if (tstRslt.CalibFactorResultsToSave == null || + tstRslt.CalibFactorResultsToSave.Count == 0) + { + continue; + } + + TestRsltCalibFactorHelper.DeleteByTestRsltIdNoTransaction(session, tstRslt.Id); + + foreach (var calib in tstRslt.CalibFactorResultsToSave) + { + calib.TestRslt = tstRslt; + calib.ErrorStr = TestRsltCalibFactorHelper.Truncate(calib.ErrorStr, 240); + + session.SaveOrUpdate(calib); + } + } + } + }catch(Exception exc) + { + log.ErrorFormat("DB - Cannot save calibration factors: {0}", exc.Message); } } diff --git a/Results/Entities/TestRsltCalibFactor.cs b/Results/Entities/TestRsltCalibFactor.cs index 36c771422..2c762e755 100644 --- a/Results/Entities/TestRsltCalibFactor.cs +++ b/Results/Entities/TestRsltCalibFactor.cs @@ -8,6 +8,8 @@ namespace Results.Entities public virtual int CalibFactorIndex { get; set; } // 1, 2, 3 + public virtual bool IsCalibFactorValid { get; set; } + public virtual int BaseCalibFactor { get; set; } public virtual int CalculatedCalibFactor { get; set; } @@ -29,6 +31,7 @@ namespace Results.Entities { Stored = false; ErrorStr = string.Empty; + IsCalibFactorValid = false; } } } \ No newline at end of file diff --git a/Results/Entities/helpers/DatabaseMigrationHelper.cs b/Results/Entities/helpers/DatabaseMigrationHelper.cs index cd4af3082..ec0cfaaef 100644 --- a/Results/Entities/helpers/DatabaseMigrationHelper.cs +++ b/Results/Entities/helpers/DatabaseMigrationHelper.cs @@ -66,8 +66,7 @@ namespace Results.Entities.helpers { alter.Transaction = transaction; - alter.CommandText = - "ALTER TABLE `" + tableName + "` ADD COLUMN `" + columnName + "` " + columnDefinition; + alter.CommandText = "ALTER TABLE `" + tableName + "` ADD COLUMN `" + columnName + "` " + columnDefinition; alter.ExecuteNonQuery(); } diff --git a/Results/Entities/helpers/TestRsltCalibFactorHelper.cs b/Results/Entities/helpers/TestRsltCalibFactorHelper.cs index b0c6befa4..81a04bb8b 100644 --- a/Results/Entities/helpers/TestRsltCalibFactorHelper.cs +++ b/Results/Entities/helpers/TestRsltCalibFactorHelper.cs @@ -1,10 +1,14 @@ using System.Collections.Generic; +using log4net; using NHibernate; namespace Results.Entities.helpers { public static class TestRsltCalibFactorHelper { + + private static readonly ILog log = LogManager.GetLogger(typeof(TestRsltCalibFactorHelper)); + public static bool TableExists(ISession session) { try @@ -24,6 +28,7 @@ namespace Results.Entities.helpers ISession session, int testRsltId) { + log.DebugFormat("Deleting TestRsltCalibFactor records for TestRsltId: {0}", testRsltId); session.CreateSQLQuery(@" DELETE FROM TestRsltCalibFactor WHERE TestRsltId = :testRsltId") .SetParameter("testRsltId", testRsltId) .ExecuteUpdate(); @@ -65,6 +70,7 @@ CREATE TABLE IF NOT EXISTS TestRsltCalibFactor ( CalibFactorIndex INT NOT NULL, BaseCalibFactor INT NOT NULL, CalculatedCalibFactor INT NOT NULL, + IsCalibFactorValid BIT NOT NULL, Stored BIT NOT NULL, ErrorStr VARCHAR(240) NULL, TimeStart DOUBLE NOT NULL, @@ -90,6 +96,7 @@ CREATE TABLE IF NOT EXISTS TestRsltCalibFactor ( CalibFactorIndex INTEGER NOT NULL, BaseCalibFactor INTEGER NOT NULL, CalculatedCalibFactor INTEGER NOT NULL, + IsCalibFactorValid INTEGER NOT NULL, Stored INTEGER NOT NULL, ErrorStr VARCHAR(240) NULL, TimeStart DOUBLE NOT NULL, @@ -103,6 +110,7 @@ CREATE TABLE IF NOT EXISTS TestRsltCalibFactor ( );"; } + log.InfoFormat("Creating TestRsltCalibFactor table: {0}", sql); session.CreateSQLQuery(sql).ExecuteUpdate(); } } diff --git a/Results/Mappings/MeterTestRsltMap.cs b/Results/Mappings/MeterTestRsltMap.cs index 35a57abf3..5b9cce0ec 100644 --- a/Results/Mappings/MeterTestRsltMap.cs +++ b/Results/Mappings/MeterTestRsltMap.cs @@ -49,7 +49,7 @@ namespace Results.Mappings #endif References(x => x.WaterMeter); References(x => x.TestRslt); - Map(x => x.Q3Channel).Not.Nullable() .Default("0"); + Map(x => x.Q3Channel); } } } diff --git a/Results/Mappings/TestRsltCalibFactorMap.cs b/Results/Mappings/TestRsltCalibFactorMap.cs index 5a0764afc..618e7c132 100644 --- a/Results/Mappings/TestRsltCalibFactorMap.cs +++ b/Results/Mappings/TestRsltCalibFactorMap.cs @@ -14,6 +14,7 @@ namespace Results.Mappings .Not.Nullable(); Map(x => x.CalibFactorIndex).Not.Nullable(); + Map(x => x.IsCalibFactorValid).Not.Nullable(); Map(x => x.BaseCalibFactor).Not.Nullable(); Map(x => x.CalculatedCalibFactor).Not.Nullable(); diff --git a/Results/Mappings/WaterMeterDataMap.cs b/Results/Mappings/WaterMeterDataMap.cs index 622e43739..0dfe40ba2 100644 --- a/Results/Mappings/WaterMeterDataMap.cs +++ b/Results/Mappings/WaterMeterDataMap.cs @@ -58,7 +58,7 @@ namespace Results.Mappings #if ORACLE_DB Map(x => x.WMTypeId); #endif - Map(x => x.Q3Channel) .Not.Nullable() .Default("0"); + Map(x => x.Q3Channel); } } diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 50b62ac3b..e247b9f11 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.9.3110.1")] -[assembly: AssemblyFileVersion("3.9.3110.1")] +[assembly: AssemblyVersion("3.9.3121.1")] +[assembly: AssemblyFileVersion("3.9.3121.1")] diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs index 22ec77c38..c46d6942c 100644 --- a/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs @@ -380,6 +380,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication if (pcbResult.IsValidPcb) { + log.Debug($"Setting PCB: {pcbResult.PcbId} for Head: {genesisHead.Name}"); genesisHead.SerialNr = pcbResult.PcbId; if (genesisHead.ConfigStruct != null) { @@ -474,6 +475,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication if (pbcReadBuildAsync.Success && !string.IsNullOrEmpty(pbcReadBuildAsync.PcbId)) { + log.Debug($"Setting PCB: {pbcReadBuildAsync.PcbId} for Head: {genesisHead.Name}"); genesisHead.SerialNr = pbcReadBuildAsync.PcbId; } @@ -1330,6 +1332,16 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication BridgeComponents.GciBridge.Interfaces.PublicModels.GciFullLoginResult connectFullPassLoginWithRetryAsync = await genesisSmartReader.CommInterfaceBridge.ConnectFullPassLoginWithRetryAsync(genesisSmartReader.GetSlotNr, token); log.Debug($"GroupedLoginSlot_Async( Slot: {genesisSmartReader.GetSlotNr}) - Result: " + connectFullPassLoginWithRetryAsync); + if (connectFullPassLoginWithRetryAsync?.PcbResult?.Success == true) + { + log.Debug($"Setting PCB: {connectFullPassLoginWithRetryAsync?.PcbResult?.Result?.PcbId} for Head: {genesisSmartReader.Name}"); + genesisSmartReader.SerialNr = connectFullPassLoginWithRetryAsync?.PcbResult?.Result?.PcbId; + if (genesisSmartReader.ConfigStruct != null) + { + genesisSmartReader.ConfigStruct.PCBNumberString = genesisSmartReader.SerialNr; + } + } + return connectFullPassLoginWithRetryAsync; } catch (Exception ex) @@ -1447,30 +1459,78 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication } } - public string WriteQ3Calibration() + public string WriteQ3Calibration(TestMethodCfg cfg, Test test, WaterMeter wm) { if (genesisHead != null && genesisHead.DebugLevel == DebugMode.Simulate) { log.Debug("Connect() - Simulated response"); return ResultOk; //"Simulated Connect"; } - return Task.Run(() => WriteQ3Calibration_Async(genesisHead)) + + if (cfg == null) + { + log.Error("WriteQ3Calibration() - Missing TestMethodCfg"); + return "Missing TestMethodCfg"; + } + if (test == null) + { + log.Error("WriteQ3Calibration() - Missing Test"); + return "Missing Test"; + } + + + return Task.Run(() => WriteQ3Calibration_Async(genesisHead, cfg, test, wm)) .GetAwaiter() .GetResult(); } - private async Task WriteQ3Calibration_Async(GenesisSmartReader genesisSmartReader) + private async Task WriteQ3Calibration_Async(GenesisSmartReader genesisSmartReader, + TestMethodCfg cfg, + Test test, WaterMeter wm) { try { - log.Debug("WriteQ3Calibration_Async called for iHead: " + genesisHead); + log.Debug("WriteQ3Calibration_Async called for iHead: " + genesisHead?.Name + " , cfg: " + cfg?.Name + " , test: " + test?.Name); - if (genesisHead == null) return string.Empty; - if (string.IsNullOrEmpty(genesisHead.CommInterface)) return string.Empty; + if (genesisHead == null) + { + log.Error("WriteQ3Calibration_Async() - Missing GenesisSmartReader"); + return string.Empty; + } + if (string.IsNullOrEmpty(genesisHead.CommInterface)) + { + log.Error("WriteQ3Calibration_Async() - Missing CommInterface"); + return string.Empty; + } GciBridge gciBridge = genesisHead.CommInterfaceBridge; - if (gciBridge == null) return string.Empty; + if (gciBridge == null) + { + log.Error("WriteQ3Calibration_Async() - Missing GciBridge"); + return string.Empty; + } + Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(test.Name, test.Part); + log.Debug($"WriteQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Test: {test.Name} - Part: {test.Part} - IsTestRslt: {(tstRslt==null?true:false)}"); + + try + { + if (tstRslt.CalibFactorResultsToSave.Count == 0) + { + for (int i = 0; i < genesisSmartReader.ChannelsCount; i++) + { + tstRslt.CalibFactorResultsToSave.Add(new TestRsltCalibFactor() + { + Stored = false, + CalibFactorIndex = i + } + ); + } + } + }catch(Exception ex) + { + log.Error($"WriteQ3Calibration_Async() - DB Exception: {ex.Message}"); + } CancellationToken token = default; @@ -1481,6 +1541,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication return "CalculateQ3Calibration Initialised Data not valid"; } + StoreCalibrationValuesResults(tstRslt, genesisSmartReader); + if (!genesisSmartReader.Q3CalibValid) { log.Error("WriteQ3Calibration_Async() - Q3Channel not valid"); @@ -1490,36 +1552,112 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication //Get Activity Status LedState ledMode = LedState.inactive; // swich on LED byte valueLed = (ledMode == LedState.active) ? (byte)6 : (byte)0; + UInt16 calibFactor1 = Convert.ToUInt16(genesisSmartReader.Q3Calib_Ch1Value); UInt16 calibFactor2 = Convert.ToUInt16(genesisSmartReader.Q3Calib_Ch2Value); UInt16 calibFactor3 = Convert.ToUInt16(genesisSmartReader.Q3Calib_Ch3Value); + UInt16 valueSampleRate = 2; UInt16 ResetAccumulatorsValue = 0; UInt16 ForwardArrowValue = 0; UInt16 StoreCalibrationValue = 1; - log.Debug( $"WriteQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start - Set Led Mode: {valueLed}"); + + + + log.Debug( $"WriteQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start"); + + log.Debug( $"WriteQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start - Set CalFactor1: {calibFactor1}"); var CalFactor1AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor1, calibFactor1, false, false, token); if (CalFactor1AsyncResult == null || !CalFactor1AsyncResult.Success) { log.Error( $"WriteQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - CalFactor1AsyncResult failed. Result: {CalFactor1AsyncResult}"); return "Failed to set CalFactor1"; } + wm.OrigCalibFactor = calibFactor1; + if (genesisSmartReader.Q3CalibDiffPercentageValue.Length == 3) + wm.Q2ErrWOCorrection = genesisSmartReader.Q3CalibDiffPercentageValue[0]; + //CH3 to DB + try + { + if (tstRslt != null && + tstRslt?.CalibFactorResultsToSave?.Count == 3 && + tstRslt?.CalibFactorResultsToSave?[0] != null) + { + tstRslt.CalibFactorResultsToSave[0].CalculatedCalibFactor = Convert.ToInt32(calibFactor1); + tstRslt.CalibFactorResultsToSave[0].Stored = true; + tstRslt.CalibFactorResultsToSave[0].IsCalibFactorValid = true; + tstRslt.CalibFactorResultsToSave[0].Error = genesisSmartReader.Q3CalibDiffPercentageValue[0]; + } + log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB Stored tstRslt:{tstRslt.Name()} - CalFactor3: {calibFactor1}"); + } + catch (Exception ex) + { + log.Error($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB CH1 Exception:", ex); + } + + log.Debug( $"WriteQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start - Set CalFactor2: {calibFactor2}"); var CalFactor2AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor2, calibFactor2, false, false, token); if (CalFactor2AsyncResult == null || !CalFactor2AsyncResult.Success) { log.Error( $"WriteQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - CalFactor2AsyncResult failed. Result: {CalFactor2AsyncResult}"); return "Failed to set CalFactor2"; } + wm.CalibFactorLNA = calibFactor2; + if (genesisSmartReader.Q3CalibDiffPercentageValue.Length == 3) + wm.OrigCalibFactorLNA = genesisSmartReader.Q3CalibDiffPercentageValue[1]; + //CH3 to DB + try + { + if (tstRslt != null && + tstRslt?.CalibFactorResultsToSave?.Count == 3 && + tstRslt?.CalibFactorResultsToSave?[1] != null) + { + tstRslt.CalibFactorResultsToSave[1].CalculatedCalibFactor = Convert.ToInt32(calibFactor2); + tstRslt.CalibFactorResultsToSave[1].Stored = true; + tstRslt.CalibFactorResultsToSave[1].IsCalibFactorValid = true; + tstRslt.CalibFactorResultsToSave[1].Error = genesisSmartReader.Q3CalibDiffPercentageValue[1]; + } + log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB Stored tstRslt:{tstRslt.Name()} - CalFactor3: {calibFactor2}"); + } + catch (Exception ex) + { + log.Error($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB CH2 Exception:", ex); + } + + + log.Debug( $"WriteQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start - Set CalFactor3: {calibFactor3}"); var CalFactor3AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor3, calibFactor3, false, false, token); if (CalFactor3AsyncResult == null || !CalFactor3AsyncResult.Success) { log.Error( $"WriteQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - CalFactor3AsyncResult failed. Result: {CalFactor3AsyncResult}"); return "Failed to set CalFactor3"; } + wm.CalibFactor = calibFactor3; + if (genesisSmartReader.Q3CalibDiffPercentageValue.Length == 3) + wm.Diff2Hz8Hz = genesisSmartReader.Q3CalibDiffPercentageValue[2]; + //CH3 to DB + try + { + if (tstRslt != null && + tstRslt?.CalibFactorResultsToSave?.Count == 3 && + tstRslt?.CalibFactorResultsToSave?[2] != null) + { + tstRslt.CalibFactorResultsToSave[2].CalculatedCalibFactor = Convert.ToInt32(calibFactor3); + tstRslt.CalibFactorResultsToSave[2].Stored = true; + tstRslt.CalibFactorResultsToSave[2].IsCalibFactorValid = true; + tstRslt.CalibFactorResultsToSave[2].Error = genesisSmartReader.Q3CalibDiffPercentageValue[2]; + } + log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB Stored tstRslt:{tstRslt.Name()} - CalFactor3: {calibFactor3}"); + } + catch (Exception ex) + { + log.Error($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB CH3 Exception:", ex); + } + log.Info( $"WriteQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Set DONE CalFactor1: {calibFactor1}, CalFactor2: {calibFactor2}, CalFactor2: {calibFactor3}"); @@ -1569,46 +1707,133 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication } } - - public string PrepareQ3Calibration(TestMethodCfg cfg, Test test) + private void StoreCalibrationValuesResults(TestRslt tstRslt, GenesisSmartReader genesisSmartReader) { + try + { + if (tstRslt == null || tstRslt.CalibFactorResultsToSave == null) + { + log.Error("StoreCalibrationValuesResults() - Missing TestRslt OR CalibFactorResultsToSave"); + return; + } + + for (int i = 0; i < tstRslt.CalibFactorResultsToSave.Count; i++) + { + ushort calibFactor = 0; + switch (i) + { + case 0: + calibFactor = Convert.ToUInt16(genesisSmartReader.Q3Calib_Ch1Value); + break; + case 1: + calibFactor = Convert.ToUInt16(genesisSmartReader.Q3Calib_Ch2Value); + break; + case 2: + calibFactor = Convert.ToUInt16(genesisSmartReader.Q3Calib_Ch3Value); + break; + } + + tstRslt.CalibFactorResultsToSave[i].CalculatedCalibFactor = calibFactor; + tstRslt.CalibFactorResultsToSave[i].IsCalibFactorValid = genesisSmartReader.Q3CalibValid; + tstRslt.CalibFactorResultsToSave[i].Error = genesisSmartReader.Q3CalibDiffPercentageValue[i]; + log.Debug($"StoreCalibrationValuesResults() - CalibFactor: {i} - CalibFactor: {calibFactor} - Q3CalibValid: {genesisSmartReader.Q3CalibValid} - Q3CalibDiffPercentageValue: {genesisSmartReader.Q3CalibDiffPercentageValue[i]}"); + } + } + catch (Exception ex) + { + log.Error("StoreCalibrationValuesResults() - Exception:", ex); + } + } + + + public string PrepareQ3Calibration(TestMethodCfg cfg, Test test, WaterMeter wm) + { + log.Debug("PrepareQ3Calibration() - Start, Head: " + genesisHead?.Name); if (genesisHead != null && genesisHead.DebugLevel == DebugMode.Simulate) { - log.Debug("Connect() - Simulated response"); + log.Debug("PrepareQ3Calibration() - Simulated response"); return ResultOk;//"Simulated Connect"; } - return Task.Run(() => PrepareQ3Calibration_Async(genesisHead, cfg, test)) + + + if (cfg == null) + { + log.Error($"PrepareQ3Calibration({genesisHead?.Name}) - Missing TestMethodCfg"); + return "PrepareQ3Calibration - Missing TestMethodCfg"; + } + + if (test == null) + { + log.Error($"PrepareQ3Calibration({genesisHead?.Name}) - Missing Test"); + return "PrepareQ3Calibration - Missing Test"; + } + + return Task.Run(() => PrepareQ3Calibration_Async(genesisHead, cfg, test, wm)) .GetAwaiter() .GetResult(); } - private async Task PrepareQ3Calibration_Async( - GenesisSmartReader genesisSmartReader, + private async Task PrepareQ3Calibration_Async(GenesisSmartReader genesisSmartReader, TestMethodCfg cfg, - Test test) + Test test, WaterMeter wm) { try { - log.Debug("PrepareQ3Calibration_Async called for iHead: " + genesisHead); + log.Debug("PrepareQ3Calibration_Async called for iHead: " + genesisHead?.Name + ", cfg: " + cfg?.Name + ", test: " + test?.Name); - if (genesisHead == null) return string.Empty; - if (string.IsNullOrEmpty(genesisHead.CommInterface)) return string.Empty; - GciBridge gciBridge = genesisHead.CommInterfaceBridge; - if (gciBridge == null) return string.Empty; - - if (test == null) return "Valid Test Missing!"; - Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(test.Name, test.Part); - log.Debug($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Test: {test.Name} - Part: {test.Part} - IsTestRslt: {(tstRslt==null?true:false)}"); - - if (tstRslt.CalibFactorResultsToSave.Count == 0) + if (genesisHead == null) { - for (int i = 0; i < genesisSmartReader.ChannelsCount; i++) - { - tstRslt.CalibFactorResultsToSave.Add(new TestRsltCalibFactor()); - } + log.Error("PrepareQ3Calibration_Async() - Missing GenesisSmartReader"); + return string.Empty; + } + if (string.IsNullOrEmpty(genesisHead.CommInterface)) + { + log.Error("PrepareQ3Calibration_Async() - Missing CommInterface"); + return string.Empty; + } + GciBridge gciBridge = genesisHead.CommInterfaceBridge; + if (gciBridge == null) + { + log.Error("PrepareQ3Calibration_Async() - Missing GciBridge"); + return string.Empty; } + Results.Entities.TestRslt tstRslt = null; + + try + { + if (test == null) + { + log.Error($"PrepareQ3Calibration_Async({genesisHead?.Name}) - Missing Test"); + return "Valid Test Missing!"; + } + tstRslt = ProcessData.BatchRslts.GetTestRslt(test.Name, test.Part); + log.Debug($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Test: {test.Name} - Part: {test.Part} - IsTestRslt: {(tstRslt==null?true:false)}"); + if (tstRslt?.CalibFactorResultsToSave?.Count > 0) + { + tstRslt?.CalibFactorResultsToSave.Clear(); + } + if (tstRslt?.CalibFactorResultsToSave?.Count == 0) + { + for (int i = 0; i < genesisSmartReader.ChannelsCount; i++) + { + tstRslt.CalibFactorResultsToSave.Add(new TestRsltCalibFactor() + { + Stored = false, + CalibFactorIndex = i + } + ); + } + } + } + catch (Exception ex) + { + log.Error($"PrepareQ3Calibration_Async({genesisSmartReader.GetSlotNr}) - DB TestRslt Exception:", ex); + return ex.Message; + } + + CancellationToken token = default; //Get Activity Status @@ -1618,34 +1843,95 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication UInt16 valueSampleRate = 10; //TODO BUMI - implement variable values for Q3Channel - be shure is implemented in Head - string prepareMeterSizeAndCalibration = await PrepareMeterSizeAndCalibration(genesisSmartReader, cfg, gciBridge, token); + string prepareMeterSizeAndCalibration = await PrepareMeterSizeAndCalibration(genesisSmartReader, cfg, gciBridge, tstRslt, token); if (prepareMeterSizeAndCalibration != ResultOk) { log.Error($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - prepareMeterSizeAndCalibration failed. Result: {prepareMeterSizeAndCalibration}"); return prepareMeterSizeAndCalibration; } - log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start - Set Led Mode: {valueLed}"); - var CalFactor1AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor1, genesisSmartReader.Q3CalibValue[0], false, false, token); + ushort calibrationFactor1 = Convert.ToUInt16(genesisSmartReader?.Q3CalibValue[0]); + log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start - Set CalFactor1: {calibrationFactor1}"); + var CalFactor1AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor1, calibrationFactor1, false, false, token); if (CalFactor1AsyncResult == null || !CalFactor1AsyncResult.Success) { log.Error( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - CalFactor1AsyncResult failed. Result: {CalFactor1AsyncResult}"); return "Failed to disable Led Mode"; } - - var CalFactor2AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor2, genesisSmartReader.Q3CalibValue[1], false, false, token); + + //CH1 to DB + try + { + if (tstRslt != null && + tstRslt?.CalibFactorResultsToSave?.Count == 3 && + tstRslt?.CalibFactorResultsToSave?[0] != null) + { + tstRslt.CalibFactorResultsToSave[0].BaseCalibFactor = Convert.ToInt32(calibrationFactor1); + tstRslt.CalibFactorResultsToSave[0].Stored = false; + } + //wm.OrigCalibFactor = calibrationFactor1; // now dosabled + log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB Stored tstRslt:{tstRslt.Name()} - CalFactor1: {calibrationFactor1}"); + } + catch (Exception ex) + { + log.Error($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB CH1 Exception:", ex); + } + + + ushort calibrationFactor2 = Convert.ToUInt16(genesisSmartReader?.Q3CalibValue[1]); + log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start - Set CalFactor2: {calibrationFactor2}"); + var CalFactor2AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor2, calibrationFactor2, false, false, token); if (CalFactor2AsyncResult == null || !CalFactor2AsyncResult.Success) { log.Error( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - CalFactor2AsyncResult failed. Result: {CalFactor2AsyncResult}"); return "Failed to disable Led Mode"; } + //CH2 to DB + try + { + if (tstRslt != null && + tstRslt?.CalibFactorResultsToSave?.Count == 3 && + tstRslt?.CalibFactorResultsToSave?[1] != null) + { + tstRslt.CalibFactorResultsToSave[1].BaseCalibFactor = Convert.ToInt32(calibrationFactor2); + tstRslt.CalibFactorResultsToSave[1].Stored = false; + } + //wm.CalibFactorLNA = calibrationFactor2; // now dosabled + log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB Stored tstRslt:{tstRslt.Name()} - CalFactor2: {calibrationFactor2}"); + } + catch (Exception ex) + { + log.Error($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB CH2 Exception:", ex); + } - var CalFactor3AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor3, genesisSmartReader.Q3CalibValue[2], false, false, token); + + ushort calibrationFactor3 = Convert.ToUInt16(genesisSmartReader?.Q3CalibValue[2]); + log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start - Set CalFactor1: {calibrationFactor3}"); + var CalFactor3AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor3, calibrationFactor3, false, false, token); if (CalFactor3AsyncResult == null || !CalFactor3AsyncResult.Success) { log.Error( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - CalFactor3AsyncResult failed. Result: {CalFactor3AsyncResult}"); return "Failed to disable Led Mode"; } + //CH3 to DB + try + { + if (tstRslt != null && + tstRslt?.CalibFactorResultsToSave?.Count == 3 && + tstRslt?.CalibFactorResultsToSave?[2] != null) + { + tstRslt.CalibFactorResultsToSave[2].BaseCalibFactor = Convert.ToInt32(calibrationFactor3); + tstRslt.CalibFactorResultsToSave[2].Stored = false; + } + //wm.CalibFactor = calibrationFactor3; // now dosabled + log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB Stored tstRslt:{tstRslt.Name()} - CalFactor3: {calibrationFactor3}"); + } + catch (Exception ex) + { + log.Error($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - DB CH3 Exception:", ex); + } + + var SampleRateAsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.SampleRate, valueSampleRate, false, false, token); if (SampleRateAsyncResult == null || !SampleRateAsyncResult.Success) @@ -1673,66 +1959,82 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication } private static async Task PrepareMeterSizeAndCalibration(GenesisSmartReader genesisSmartReader, TestMethodCfg cfg, - GciBridge gciBridge, CancellationToken token) + GciBridge gciBridge, Results.Entities.TestRslt tstRslt, CancellationToken token) { UInt16 valueCalibrate = 15625; //Predefined Calibration Value + log.Debug( $"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader?.GetSlotNr}) - Start - predefined {valueCalibrate}"); try { - if (cfg != null) - { - var MeterSizeAsyncResult = await gciBridge.ReadRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, - RadioService.MeterSize, token); - - if (MeterSizeAsyncResult == null || !MeterSizeAsyncResult.Success) - { - log.Error($"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Error reading MeterSize register. Result: {MeterSizeAsyncResult}"); - return "Error reading MeterSize register"; - } - - string rawHex = MeterSizeAsyncResult.Result?.RawHex; - if (string.IsNullOrWhiteSpace(rawHex)) - { - log.Error( - $"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - MeterSize RawHex is empty"); - return "MeterSize RawHex is empty"; - } - - uint meterSizeRaw = ParseRawHexToUInt32(rawHex); - - // If register returns 4 bytes like "00 00 00 02", this gives 2. - // If it returns "02", this also gives 2. - if (meterSizeRaw > ushort.MaxValue) - { - log.Error( - $"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - MeterSize too large. RawHex='{rawHex}', Value={meterSizeRaw}"); - return "MeterSize value too large"; - } - - ushort int16MeterSize = (ushort)meterSizeRaw; - - double[] dSize = cfg.GetQ3CalibrationBySizeDoubles(int16MeterSize); - if (dSize == null || dSize.Length != 3) - { - log.Info( - $"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Problem with Q3Channel calculation. Size: {int16MeterSize}"); - return ResultNok; - } - - genesisSmartReader - .SetQ3Calibration(dSize); // new double[]{valueCalibrate,valueCalibrate,valueCalibrate} - log.Info( - $"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Based MeterSize: {int16MeterSize} Set Q3Channel: CH1({dSize[0]}), CH2({dSize[1]}), CH3({dSize[2]})"); - } - else + // if (cfg != null) + // { + // var MeterSizeAsyncResult = await gciBridge.ReadRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, + // RadioService.MeterSize, token); + // + // if (MeterSizeAsyncResult == null || !MeterSizeAsyncResult.Success) + // { + // log.Error($"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Error reading MeterSize register. Result: {MeterSizeAsyncResult}"); + // return "Error reading MeterSize register"; + // } + // + // string rawHex = MeterSizeAsyncResult.Result?.RawHex; + // if (string.IsNullOrWhiteSpace(rawHex)) + // { + // log.Error( + // $"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - MeterSize RawHex is empty"); + // return "MeterSize RawHex is empty"; + // } + // + // uint meterSizeRaw = ParseRawHexToUInt32(rawHex); + // + // // If register returns 4 bytes like "00 00 00 02", this gives 2. + // // If it returns "02", this also gives 2. + // if (meterSizeRaw > ushort.MaxValue) + // { + // log.Error( + // $"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - MeterSize too large. RawHex='{rawHex}', Value={meterSizeRaw}"); + // return "MeterSize value too large"; + // } + // + // ushort int16MeterSize = (ushort)meterSizeRaw; + // + // double[] dSize = cfg.GetQ3CalibrationBySizeDoubles(int16MeterSize); + // if (dSize == null || dSize.Length != 3) + // { + // log.Info( + // $"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Problem with Q3Channel calculation. Size: {int16MeterSize}"); + // return ResultNok; + // } + // + // genesisSmartReader .SetQ3Calibration(dSize); // new double[]{valueCalibrate,valueCalibrate,valueCalibrate} + // for (int i = 0; i < genesisSmartReader.ChannelsCount; i++) + // { + // tstRslt.CalibFactorResultsToSave[i].BaseCalibFactor = Convert.ToInt32(dSize[i]); + // } + // + // log.Info( + // $"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Based MeterSize: {int16MeterSize} Set Q3Channel: CH1({dSize[0]}), CH2({dSize[1]}), CH3({dSize[2]})"); + // } + // else { genesisSmartReader.SetQ3Calibration(new double[] { valueCalibrate, valueCalibrate, valueCalibrate }); + for (int i = 0; i < genesisSmartReader.ChannelsCount; i++) + { + if(tstRslt != null && tstRslt?.CalibFactorResultsToSave[i] != null) + tstRslt.CalibFactorResultsToSave[i].BaseCalibFactor = Convert.ToInt32(valueCalibrate); + } + + log.Info( $"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Hard Set Q3Channel: CH1({valueCalibrate}), CH2({valueCalibrate}), CH3({valueCalibrate})"); } }catch(Exception ex) { log.Error($"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Error during Q3Channel calculation: {ex.Message}"); genesisSmartReader.SetQ3Calibration(new double[] { valueCalibrate, valueCalibrate, valueCalibrate }); + for (int i = 0; i < genesisSmartReader.ChannelsCount; i++) + { + tstRslt.CalibFactorResultsToSave[i].BaseCalibFactor = Convert.ToInt32(valueCalibrate); + } return ResultNok; } diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader.cs index 75a9078fb..613d1f1c6 100644 --- a/TBF/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader.cs +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader.cs @@ -1340,16 +1340,6 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations void DataStreamPostProcessing() { PrepareCalculatedChannelData(); - try - { - log.DebugFormat("DataStreamPostProcessing() - harcoded call GetQ3Calibration(200.0, 120.0, 17969.0);"); - SetQ3Calibration(new double[]{17969.0,17969.0,17969.0 }); - CalculateQ3Calibration(200.0, 120.0); - } - catch (Exception ex) - { - log.Error($"DataStreamPostProcessing -- Q3 CALIBRATION -- failed: {ex}"); - } } /// @@ -1883,7 +1873,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations _readLoopTask = Task.Run(() => { - log.Debug($"OPTHO {OptoComPortNr} background read loop started."); + logStream.Debug($"OPTHO {OptoComPortNr} background read loop started."); while (!token.IsCancellationRequested) { @@ -1939,12 +1929,12 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } catch (Exception ex) { - log.Error($"OPTHO {OptoComPortNr} background read error: {ex.Message}"); + logStream.Error($"OPTHO {OptoComPortNr} background read error: {ex.Message}"); Thread.Sleep(100); } } - log.Debug($"OPTHO {OptoComPortNr} background read loop stopped."); + logStream.Debug($"OPTHO {OptoComPortNr} background read loop stopped."); }, token); } @@ -2025,7 +2015,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations { try { - log.Debug($"OPTHO {OptoComPortNr} processing loop started."); + logStream.Debug($"OPTHO {OptoComPortNr} processing loop started."); while (!token.IsCancellationRequested) { @@ -2055,14 +2045,14 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations if (blockCompleted) { - log.Debug("Processing loop completed flow block detected."); + logStream.Debug("Processing loop completed flow block detected."); if (resetSerialBuffersOnCompletedFlowBlock) ResetDataBuffer(); } } catch (Exception ex) { - log.Error($"Processing loop failed: {ex}"); + logStream.Error($"Processing loop failed: {ex}"); } continue; @@ -2076,16 +2066,16 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } catch (Exception ex) { - log.Error($"OPTHO {OptoComPortNr} processing loop error: {ex}"); + logStream.Error($"OPTHO {OptoComPortNr} processing loop error: {ex}"); Thread.Sleep(50); } } - log.Debug($"OPTHO {OptoComPortNr} processing loop stopped."); + logStream.Debug($"OPTHO {OptoComPortNr} processing loop stopped."); } catch (Exception ex) { - log.Error($"StartProcessingLoop fatal error: {ex}"); + logStream.Error($"StartProcessingLoop fatal error: {ex}"); } }, token); } @@ -2114,13 +2104,13 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations // 🔴 STEP 1: Check if we should start processing if (startDataProcessing && optoState == DataStreamState.ProcessAndSave) { - log.DebugFormat("Read Opto Data Line timestamp:{0} to process from queue: {1}",timestamp.ToString("HH:mm:ss.fff") , line); + logStream.DebugFormat("Read Opto Data Line timestamp:{0} to process from queue: {1}",timestamp.ToString("HH:mm:ss.fff") , line); bool blockCompleted; ProcessOptoLine(line, optoState, out blockCompleted); if (blockCompleted) { - log.Debug("ReadOptoData() completed flow block detected."); + logStream.Debug("ReadOptoData() completed flow block detected."); if (resetSerialBuffersOnCompletedFlowBlock) // DO NOT call ResetDataBuffer() here ResetDataBuffer(); } @@ -2128,7 +2118,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } catch (Exception ex) { - log.Error($"OPTHO {OptoComPortNr} processing queued line failed: {ex.Message}"); + logStream.Error($"OPTHO {OptoComPortNr} processing queued line failed: {ex.Message}"); } } } @@ -2144,7 +2134,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations var encoding = optoSerialPort?.Encoding ?? Encoding.ASCII; byte[] bytes = encoding.GetBytes(line); - log.Debug("ComPort: " + OptoComPortNr + " OPTHO RX ← " + HexFormatter.ToSerialHex(bytes)); + logStream.Debug("ComPort: " + OptoComPortNr + " OPTHO RX ← " + HexFormatter.ToSerialHex(bytes)); var streamingDecode = new StreamingDecoder(true); streamingDecode.DecodeMsg(line); @@ -2154,14 +2144,14 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations if (streamingDecode.DataFlowTest != null && streamingDecode.DataFlowTest.IsValid) { blockCompleted = HandleFlowMarker(); - log.Debug("ComPort: " + OptoComPortNr + " Decoded Flow data: " + streamingDecode.DataFlowTest + - " OPTHO RX ← " + HexFormatter.ToSerialHex(bytes)); + logStream.Debug("ComPort: " + OptoComPortNr + " Decoded Flow data: " + streamingDecode.DataFlowTest + + " OPTHO RX ← " + HexFormatter.ToSerialHex(bytes)); } if (calibData != null && calibData.IsValid) { - log.Debug("ComPort: " + OptoComPortNr + " Decoded Calib: " + calibData + " OPTHO RX ← " + - HexFormatter.ToSerialHex(bytes)); + logStream.Debug("ComPort: " + OptoComPortNr + " Decoded Calib: " + calibData + " OPTHO RX ← " + + HexFormatter.ToSerialHex(bytes)); MarkCalibrationChannelSeen(calibData.Channel); } @@ -2181,7 +2171,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations if (optoData[bufferIx] == null) { - log.ErrorFormat("{0}: optoData[{1}] was null, recreating.", Name, bufferIx); + logStream.ErrorFormat("{0}: optoData[{1}] was null, recreating.", Name, bufferIx); optoData[bufferIx] = new OptoTelegramRaw(); } @@ -2194,7 +2184,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations int iChanel = calibData.Channel - 1; if (iChanel >= 0 && iChanel < iChanelsCount) { - log.Debug( + logStream.Debug( $"Before UpdateFromSmart ch={iChanel + 1}: " + $"volumeRawExtLast={volumeRawExtLast[iChanel]}, " + $"timestampExtLast={timestampExtLast[iChanel]}, " + @@ -2262,7 +2252,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations var encoding = optoSerialPort?.Encoding ?? Encoding.ASCII; byte[] bytes = encoding.GetBytes(line); received = HexFormatter.ToSerialHex(bytes); - log.Debug("RX ← " + received); + logStream.Debug("RX ← " + received); try { @@ -2271,19 +2261,19 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations CalibrationRecord data = _streamingDecode.DataCalib; if (data != null && data.IsValid) { - log.Info($"OPTHO {OptoComPortNr} DataCalib Parsed opto data: " + data + " RX ← " + - received); + logStream.Info($"OPTHO {OptoComPortNr} DataCalib Parsed opto data: " + data + " RX ← " + + received); MarkCalibrationChannelSeen(data.Channel); } FlowTestRecord dataFlow = _streamingDecode.DataFlowTest; if (dataFlow != null && dataFlow.IsValid) { - log.Info($"OPTHO {OptoComPortNr} FLOW Parsed opto data: " + dataFlow + " RX ← " + received); + logStream.Info($"OPTHO {OptoComPortNr} FLOW Parsed opto data: " + dataFlow + " RX ← " + received); if (HandleFlowMarker()) { - log.Debug("ReadOptoData() completed flow block detected."); + logStream.Debug("ReadOptoData() completed flow block detected."); if (resetSerialBuffersOnCompletedFlowBlock) ResetDataBuffer(); // no ResetDataBuffer() here } @@ -2292,7 +2282,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } catch (Exception ex) { - log.Error($"OPTHO {OptoComPortNr} Read error: {ex.Message}"); + logStream.Error($"OPTHO {OptoComPortNr} Read error: {ex.Message}"); } // string line = optoSerialPort.ReadExisting(); @@ -2337,11 +2327,11 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } catch (TimeoutException) { - log.Debug($"ReadOptoData() OPTHO {OptoComPortNr} timeout - continuing."); + logStream.Debug($"ReadOptoData() OPTHO {OptoComPortNr} timeout - continuing."); } catch (Exception ex) { - log.Error($"ReadOptoData() OPTHO {OptoComPortNr} Read error: {ex.Message}"); + logStream.Error($"ReadOptoData() OPTHO {OptoComPortNr} Read error: {ex.Message}"); } } @@ -2357,11 +2347,11 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations { optoSerialPort.DiscardInBuffer(); optoSerialPort.DiscardOutBuffer(); - log.Debug("-- Reaset Data Buffer --"); + logStream.Debug("-- Reaset Data Buffer --"); return; } } - log.Debug("-- Reaset Data Buffer - no serial port --"); + logStream.Debug("-- Reaset Data Buffer - no serial port --"); } void ISmartReader.SetNfcInterface() @@ -2387,17 +2377,17 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations byte[] bytes = optoSerialPort.Encoding.GetBytes(line); string received = HexFormatter.ToSerialHex(bytes); - log.Debug("RX ← " + received); + logStream.Debug("RX ← " + received); return line; } } catch (TimeoutException) { - log.Debug($"ReadOptoData() OPTHO {OptoComPortNr} ReadLine timeout (3s) - continuing."); + logStream.Debug($"ReadOptoData() OPTHO {OptoComPortNr} ReadLine timeout (3s) - continuing."); } catch (Exception ex) { - log.Error($"ReadOptoData() OPTHO {OptoComPortNr} Read error: {ex.Message}"); + logStream.Error($"ReadOptoData() OPTHO {OptoComPortNr} Read error: {ex.Message}"); } return string.Empty; @@ -2408,7 +2398,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations if (completedTask == readTask) return await readTask; - log.Debug("ReadOptoData timeout after " + timeoutMs + " ms"); + logStream.Debug("ReadOptoData timeout after " + timeoutMs + " ms"); return string.Empty; } @@ -2957,7 +2947,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations if (data == null || !data.IsValid) continue; - log.Info($"OPTHO {OptoComPortNr} Parsed optho data:" + data); + logStream.Info($"OPTHO {OptoComPortNr} Parsed optho data:" + data); int dch = data.Channel - 1; if (dch >= 0 && dch < iChanelsCount) @@ -2970,7 +2960,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } catch (Exception ex) { - log.Warn($"Parsing DiagnosticLedState4Data: {ex.Message}"); + logStream.Warn($"Parsing DiagnosticLedState4Data: {ex.Message}"); } } } @@ -2981,7 +2971,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } - log.Debug($"Try get End Volume! COM: {this.OptoComPortNr}, Volume: {volumeLtr}"); + logStream.Debug($"Try get End Volume! COM: {this.OptoComPortNr}, Volume: {volumeLtr}"); if (optoSerialPort != null && optoSerialPort.IsOpen) CloseOptoSerialPort(); if (!Double.IsNaN(volumeLtr[channel0])) @@ -2992,12 +2982,12 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations //Solve roll over if (endWMState < beginWMState) { - log.Debug($"Solve roll over! endWMState: {endWMState} < beginWMState: {beginWMState}"); + logStream.Debug($"Solve roll over! endWMState: {endWMState} < beginWMState: {beginWMState}"); const double VOL_RANGE_LITERS = 16777216.0 * 0.00025; // 4,194.304 l endWMState += VOL_RANGE_LITERS; volumeLtr[channel0] = endWMState; ReadPulses(); - log.Debug( + logStream.Debug( $"Solve roll over! Upgraded endWMState: {endWMState}, beginWMState: {beginWMState}"); } } @@ -3006,7 +2996,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } //} - log.Warn("Default NaN value returned! Data Opto stream reading failed!"); + logStream.Warn("Default NaN value returned! Data Opto stream reading failed!"); return Double.NaN; }).ConfigureAwait(false); } @@ -3016,14 +3006,14 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations { if (ConfigStruct == null) { - log.Debug("ConfigStruct is null - created new in ReadSerialNr()"); + logStream.Debug("ConfigStruct is null - created new in ReadSerialNr()"); ConfigStruct = new ConfigStruct(); } return await Task.Run(() => { - log.Debug($"Try get Start Volume! COM: {this.OptoComPortNr}"); + logStream.Debug($"Try get Start Volume! COM: {this.OptoComPortNr}"); Start(); @@ -3044,7 +3034,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations StreamingDecoder _streamingDecode = new StreamingDecoder(true); _streamingDecode.DecodeMsg(readOptoDataWithTimeout); CalibrationRecord data = _streamingDecode.DataCalib; - log.Info($"OPTHO {OptoComPortNr} Parsed optho data:" + data); + logStream.Info($"OPTHO {OptoComPortNr} Parsed optho data:" + data); if (data == null || !data.IsValid) continue; @@ -3060,7 +3050,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } catch (Exception ex) { - log.Warn($"Parsing DiagnosticLedState4Data: {ex.Message}"); + logStream.Warn($"Parsing DiagnosticLedState4Data: {ex.Message}"); } } } @@ -3070,7 +3060,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } } - log.Debug($"Try get Start Volume! COM: {this.OptoComPortNr}, Volume: {volumeLtr0}"); + logStream.Debug($"Try get Start Volume! COM: {this.OptoComPortNr}, Volume: {volumeLtr0}"); if (optoSerialPort != null && optoSerialPort.IsOpen) CloseOptoSerialPort(); if (!Double.IsNaN(volumeLtr0[ch])) @@ -3081,7 +3071,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } //} - log.Warn("Default NaN value returned! Data Opto stream reading failed!"); + logStream.Warn("Default NaN value returned! Data Opto stream reading failed!"); return Double.NaN; }).ConfigureAwait(false); } @@ -3093,7 +3083,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations if (ConfigStruct == null) { - log.Debug("ConfigStruct is null - created new in ReadSerialNr()"); + logStream.Debug("ConfigStruct is null - created new in ReadSerialNr()"); ConfigStruct = new ConfigStruct(); } @@ -3103,11 +3093,11 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations return await Task.Run(() => { - log.Debug($"Try get ReadSerialNr! COM: {this.RfidComPortNr}"); + logStream.Debug($"Try get ReadSerialNr! COM: {this.RfidComPortNr}"); SerialNr = OptoHeadTest.ReadRequest_PCB(); if (string.IsNullOrEmpty(SerialNr)) { - log.Debug("ReadSerialNr successful"); + logStream.Debug("ReadSerialNr successful"); } //optoHeadTest.CloseConnection(); @@ -3933,6 +3923,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations private double[] q3CalibInitial = {Double.NaN,Double.NaN,Double.NaN}; private bool[] isChQ3CalibValid = { false,false,false}; private double[] q3CalibCh = {Double.NaN,Double.NaN,Double.NaN}; + private double[] q3DiffPercentageCalibCh = {Double.NaN,Double.NaN,Double.NaN}; public bool Q3CalibValid @@ -3950,6 +3941,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations } public double[] Q3CalibValue { get => q3CalibInitial; } + public double[] Q3CalibDiffPercentageValue { get => q3DiffPercentageCalibCh; } public bool Q3Calib_Ch1Valid { get => isChQ3CalibValid[0]; } public bool Q3Calib_Ch2Valid { get => isChQ3CalibValid[1]; } @@ -3983,10 +3975,10 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations public void CalculateQ3Calibration(double refVolume, double refTime) { - GetQ3Calibration(refVolume, refTime, q3CalibInitial, ref isChQ3CalibValid, ref q3CalibCh); + GetQ3Calibration(refVolume, refTime, q3CalibInitial, ref isChQ3CalibValid,ref q3DiffPercentageCalibCh, ref q3CalibCh); } - public void GetQ3Calibration(double refVolume, double refTime, double[] initCalibFactor, ref bool[] isChQ3CalibValid, ref double[] q3CalibCh) + public void GetQ3Calibration(double refVolume, double refTime, double[] initCalibFactor, ref bool[] isChQ3CalibValid, ref double[] calibDiffPercent, ref double[] q3CalibCh) { log.Debug("=== Q3 CALIBRATION START ==="); @@ -4096,9 +4088,9 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations q3CalibCh[iChannel] = (refVolume / recalculatedDeltaVolume) * initCalibFactor[iChannel]; double diffPercent = Math.Abs((initCalibFactor[iChannel] - q3CalibCh[iChannel] ) / initCalibFactor[iChannel]) * 100.0; - isChQ3CalibValid[iChannel] = diffPercent <= 5.0; + isChQ3CalibValid[iChannel] = diffPercent <= 5.0 && diffPercent >= -5.0; + calibDiffPercent[iChannel] = diffPercent; log.Debug($"Calculated Q3Calib Ch[{iChannel}] ={q3CalibCh[iChannel]} DiffPercent={diffPercent}% isValid[{isChQ3CalibValid[iChannel]}] IninitCalibFactor={initCalibFactor}"); - } log.Debug("=== Q3 CALIBRATION END ==="); diff --git a/TBF/Rig/TestMethods/iPerlCommunication/communication/RadioService.cs b/TBF/Rig/TestMethods/iPerlCommunication/communication/RadioService.cs index 7a17fbf16..7e5c50734 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/communication/RadioService.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/communication/RadioService.cs @@ -50,6 +50,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.communication if (decoded.IsOk) { string asciiPayload = decoded.GetAsciiPayload(); + iHead.SerialNr = asciiPayload; if (iHead.ConfigStruct != null) // store mechanism { iHead.ConfigStruct.PCBNumberString = asciiPayload; diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs index ecf9ed721..638c1a2eb 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs @@ -65,6 +65,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication FailedSetActiveMode, /// 1AH = 26 FailedWriteCalibrationFactor,/// 1BH = 27 FailedWriteRegister,/// 1CH = 28 + FailedPrepare, /// 1DH = 29 } @@ -818,7 +819,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication else if (currentActivity.ToLower().Equals(SlotSetActiveModeStr.ToLower()))error = SlotSetActiveMode(threadID, ihead, ref resultStr); else if (currentActivity.ToLower().Equals(SlotDisconnectStr.ToLower())) error = SlotDisconnect(threadID, ihead, ref resultStr); else if (currentActivity.ToLower().Equals(PrepareSlotQ3CalibrationStr.ToLower())) error = PrepareSlotQ3Calibration(threadID, ihead,wm, currentTest, tests , ref resultStr); - else if (currentActivity.ToLower().Equals(WriteSlotQ3CalibrationStr.ToLower())) error = WriteSlotQ3Calibration(threadID, ihead, ref resultStr); + else if (currentActivity.ToLower().Equals(WriteSlotQ3CalibrationStr.ToLower())) error = WriteSlotQ3Calibration(threadID, ihead, wm, currentTest, tests, ref resultStr); else if (currentActivity.ToLower().Equals(CheckMeterPrepareStr.ToLower())) error = CheckMeterPrepare(threadID, ihead, ref resultStr); else if (currentActivity.ToLower().Contains(ReadSerialNrStr.ToLower())) error = ReadSerialNr(threadID, ihead, ref resultStr); @@ -876,9 +877,11 @@ namespace TBF.Rig.TestMethods.iPerlCommunication (error == CommErr.FailedSetTestMode)|| (error == CommErr.FailedSetActiveMode)|| (error == CommErr.FailedWriteRegister)|| - (error == CommErr.FailedWriteCalibrationFactor)) + (error == CommErr.FailedWriteCalibrationFactor) || + (error == CommErr.FailedPrepare) + ) { - OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr0, ihead, wm, resultStr, CommErr.FailedInit)); + OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr0, ihead, wm, resultStr, error)); } else if (ihead.CommFailed || (error == CommErr.CommFailed)) { @@ -1024,57 +1027,104 @@ namespace TBF.Rig.TestMethods.iPerlCommunication private CommErr PrepareSlotQ3Calibration(int threadId, GenesisSmartReader iHead, WaterMeter wm, Test currentTest, IList tests, ref string resultStr) { - CommErr error = CommErr.FailedLogin; + CommErr error = CommErr.FailedPrepare; //TODO BUMI get Next test method - Test NextTest = null; - bool bNextChatch = false; - foreach (Test test in tests) + log.InfoFormat("PrepareSlotQ3Calibration() threadId={0}", threadId); + + try { - if (test.Equals(currentTest)) + Test NextTest = null; + bool bNextChatch = false; + foreach (Test test in tests) { - bNextChatch = true; - continue; + if (test.Equals(currentTest)) + { + bNextChatch = true; + continue; + } + + if (bNextChatch) + { + NextTest = test; + break; + } } - if (bNextChatch) + if (NextTest == null) { - NextTest = test; - break; + log.Error("No next test method found, we use the current test method"); + NextTest = currentTest; } - } - - var gciFullLoginResult = iHead.OptoHeadTest.PrepareQ3Calibration(cfg,NextTest); - if (!string.IsNullOrEmpty(resultStr) && resultStr.Equals(TBF.Rig.RegisterReaders.GenesisRegReader.communication.OptoHeadTest.ResultOk)) + + var gciFullLoginResult = iHead.OptoHeadTest.PrepareQ3Calibration(cfg, NextTest, wm); + if (!string.IsNullOrEmpty(resultStr) && + resultStr.Equals(TBF.Rig.RegisterReaders.GenesisRegReader.communication.OptoHeadTest.ResultOk)) + { + log.DebugFormat("PrepareQ3Calibration successfull threadId={0}", threadId); + resultStr = string.Format($"Write Q3 Calibration: OK"); + // note Q3 calibration is done + error = CommErr.None; + } + else + { + resultStr = "Write Q3 Calibration: Failed"; + } + + return error; + }catch (Exception ex) { - log.Debug("SlotLogin successful"); - resultStr = string.Format($"Write Q3 Calibration: OK"); - // note Q3 calibration is done - error = CommErr.None; + log.ErrorFormat("PrepareSlotQ3Calibration() threadId={0}, Error: {1}", threadId, ex.Message); + return CommErr.FailedPrepare; } - else - { - resultStr = "Write Q3 Calibration: Failed"; - } - return error; } - private CommErr WriteSlotQ3Calibration(int threadId, GenesisSmartReader iHead, ref string resultStr) + private CommErr WriteSlotQ3Calibration(int threadId, GenesisSmartReader iHead, WaterMeter wm, + Test currentTest, IList tests, ref string resultStr) { CommErr error = CommErr.FailedWriteCalibrationFactor; - var gciFullLoginResult = iHead.OptoHeadTest.WriteQ3Calibration(); - if (!string.IsNullOrEmpty(resultStr) && resultStr.Equals(TBF.Rig.RegisterReaders.GenesisRegReader.communication.OptoHeadTest.ResultOk)) + log.DebugFormat("WriteSlotQ3Calibration() threadId={0}, iHead: {1}, wm: {2}, currentTest: {3}, tests: {4}", threadId, iHead?.Name, wm?.Id, currentTest?.Name, tests?.Count); + //TODO BUMI get Before test method + try { - log.Debug("SlotLogin successful"); - resultStr = string.Format($"Write Q3 Calibration: OK"); - // note Q3 calibration is done - error = CommErr.None; + Test BeforeTest = null; + + foreach (Test test in tests) + { + if (test.Equals(currentTest)) + { + break; + } + + BeforeTest = test; + } + + if (BeforeTest == null) + { + BeforeTest = currentTest; + } + + var gciFullLoginResult = iHead.OptoHeadTest.WriteQ3Calibration(cfg, BeforeTest, wm); + if (!string.IsNullOrEmpty(resultStr) && + resultStr.Equals(TBF.Rig.RegisterReaders.GenesisRegReader.communication.OptoHeadTest.ResultOk)) + { + log.Debug("SlotLogin successful"); + resultStr = string.Format($"Write Q3 Calibration: OK"); + // note Q3 calibration is done + error = CommErr.None; + } + else + { + resultStr = "Write Q3 Calibration: Failed"; + } + + return error; } - else + catch (Exception ex) { - resultStr = "Write Q3 Calibration: Failed"; + log.ErrorFormat("WriteSlotQ3Calibration() threadId={0}, Error: {1}", threadId, ex.Message); + return CommErr.FailedWriteCalibrationFactor; } - return error; } private CommErr SlotGroupedLogin(int threadId, GenesisSmartReader iHead, ref string resultStr) @@ -1083,8 +1133,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication var gciFullLoginResult = iHead.OptoHeadTest.GroupedLoginSlot(); if (gciFullLoginResult.Success) { - log.Debug("SlotLogin successful"); + log.Debug($"SlotLogin Head:{iHead.Name} successful, PCB: {gciFullLoginResult?.PcbResult?.Result?.PcbId}"); resultStr = string.Format($"Login OK - Serial No: {gciFullLoginResult?.PcbResult?.Result?.PcbId}"); + log.Debug($"Setting PCB: {gciFullLoginResult?.PcbResult?.Result?.PcbId} for Head: {iHead.Name}"); iHead.SerialNr = gciFullLoginResult?.PcbResult?.Result?.PcbId; if (iHead.ConfigStruct != null) { @@ -1190,8 +1241,16 @@ namespace TBF.Rig.TestMethods.iPerlCommunication PcbReadResult pcbReadSlot = iHead.OptoHeadTest.PCB_ReadSlot(); if (pcbReadSlot.Success) { - log.Debug("SlotPCBSlot successful"); - resultStr = string.Format($"SlotPCBSlot: {pcbReadSlot.PcbId}"); + var pcbId = pcbReadSlot?.PcbId; + log.Debug($"SlotPCBSlot Head:{iHead.Name} successful, PCB:{pcbId}"); + resultStr = string.Format($"SlotPCBSlot: {pcbId}"); + if (!string.IsNullOrWhiteSpace(pcbId)) + { + log.Debug($"Setting PCB: {pcbId} for Head: {iHead.Name}"); + iHead.SerialNr = pcbId; + if (iHead.ConfigStruct != null) iHead.ConfigStruct.PCBNumberString = pcbId; + } + error = CommErr.None; } else @@ -1256,7 +1315,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication CommErr error = CommErr.Read; var result = ihead.OptoHeadTest.ReadRequest_PCB(); - if (string.IsNullOrEmpty(result)) + if (!string.IsNullOrEmpty(result)) { log.Debug("ReadSerialNr successful"); resultStr = string.Format($"Serial No: {result}"); @@ -1612,6 +1671,17 @@ namespace TBF.Rig.TestMethods.iPerlCommunication checkBoxes[data.WMNr0].Checked = true; checkBoxes[data.WMNr0].Enabled = false; } + // else if (data.WMNr0 >= 0 && data.CommErr != CommErr.None) + // { + // //disable if error + // ckbState[data.WMNr0] = false; + // checkBoxes[data.WMNr0].Checked = false; + // checkBoxes[data.WMNr0].Enabled = false; + // if (data.Ihead != null) data.Ihead.Disabled = true; + // if (data.Wm != null) data.Wm.Disabled = true; + // //color + // if (counters.Length > data.WMNr0) counters[data.WMNr0].BackColor = OptoNokColor; + // } /// /// Update opto-communication indication diff --git a/TBFTests/DBTest.cs b/TBFTests/DBTest.cs index fe17d476e..1c74c06d6 100644 --- a/TBFTests/DBTest.cs +++ b/TBFTests/DBTest.cs @@ -107,6 +107,7 @@ namespace TBFTests CalibFactorIndex = 1, BaseCalibFactor = 15625, CalculatedCalibFactor = 17969, + IsCalibFactorValid = true, Stored = true, ErrorStr = "OK", TimeStart = 1.1, @@ -142,6 +143,7 @@ namespace TBFTests Assert.AreEqual(1, loadedCalib.CalibFactorIndex); Assert.AreEqual(15625, loadedCalib.BaseCalibFactor); Assert.AreEqual(17969, loadedCalib.CalculatedCalibFactor); + Assert.IsTrue(loadedCalib.IsCalibFactorValid); Assert.IsTrue(loadedCalib.Stored); Assert.AreEqual("OK", loadedCalib.ErrorStr); } diff --git a/TBFTests/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTestImpelementations.cs b/TBFTests/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTestImpelementations.cs index 117ffa184..73fc738e2 100644 --- a/TBFTests/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTestImpelementations.cs +++ b/TBFTests/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTestImpelementations.cs @@ -1,14 +1,11 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; -using Config.Entities; -using GenesisCordonelInterface.API; using JetBrains.Annotations; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TBF.Rig.BridgeComponents.GciBridge; +using Results.Entities; using TBF.Rig.RegisterReaders.GenesisRegReader.communication; using TBF.Rig.RegisterReaders.GenesisRegReader.implementations; -using TBF.Rig.Sequences; using TBF.Rig.TestMethods.GenesisCommunication; namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.communication @@ -91,34 +88,50 @@ namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.communication [TestMethod] public void PrepareQ3Calibration_SimulateMode_ReturnsOk() { - // ARRANGE - GenesisSmartReader reader = new GenesisSmartReader - { - DebugLevel = Common.DebugMode.Simulate - }; + Factory factory = new Factory(); + GenesisSmartReader reader = new GenesisSmartReader(factory.DefaultConfig()); + reader.DebugLevel = Common.DebugMode.Simulate; OptoHeadTest optoHeadTest = new OptoHeadTest(reader); - TestMethodCfg cfg = new TestMethodCfg(null) - { - CalibFactor6InchCh1 = 17969, - CalibFactor6InchCh2 = 17969, - CalibFactor6InchCh3 = 17969 - }; + string result = optoHeadTest.PrepareQ3Calibration(null, null, null); - Test test = new Test - { - Name = "Q3Channel", - Part = 1 - }; - - // ACT - string result = optoHeadTest.PrepareQ3Calibration(cfg, test); - - // ASSERT - Assert.AreEqual(OptoHeadTest.ResultOk, result); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual( + OptoHeadTest.ResultOk, + result); } - + [TestMethod] + public void PrepareQ3Calibration_TestStoreDB() + { + GenesisSmartReader reader = new GenesisSmartReader(); + + Results.Entities.TestRslt tstRslt = new Results.Entities.TestRslt(); + + Assert.IsNotNull(tstRslt.CalibFactorResultsToSave); + tstRslt.CalibFactorResultsToSave.Clear(); + + Assert.AreEqual(0, tstRslt.CalibFactorResultsToSave.Count); + + if (tstRslt?.CalibFactorResultsToSave?.Count == 0) + { + for (int i = 0; i < reader.ChannelsCount; i++) + { + tstRslt.CalibFactorResultsToSave.Add(new TestRsltCalibFactor() + { + Stored = false, + CalibFactorIndex = i + }); + } + } + + Assert.AreEqual(reader.ChannelsCount, tstRslt.CalibFactorResultsToSave.Count); + + for (int i = 0; i < reader.ChannelsCount; i++) + { + Assert.IsFalse(tstRslt.CalibFactorResultsToSave[i].Stored); + Assert.AreEqual(i, tstRslt.CalibFactorResultsToSave[i].CalibFactorIndex); + } + } } } \ No newline at end of file diff --git a/TBFTests/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader_Q3Test.cs b/TBFTests/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader_Q3Test.cs index 71830e2be..b9c998d24 100644 --- a/TBFTests/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader_Q3Test.cs +++ b/TBFTests/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader_Q3Test.cs @@ -22,12 +22,15 @@ namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.implementations var valid = new bool[3]; var calib = new double[3]; + var calibDiff = new double[3]; + sut.SetQ3Calibration(ValidInitFactors); sut.GetQ3Calibration( - refVolume: 1000.0, - refTime: 120.0, - initCalibFactor: ValidInitFactors, + 200.0, + 120.0, + ValidInitFactors, ref valid, + ref calibDiff, ref calib); Assert.IsFalse(sut.Q3CalibValid); @@ -47,12 +50,15 @@ namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.implementations var valid = new bool[3]; var calib = new double[3]; + var calibDiff = new double[3]; + sut.SetQ3Calibration(ValidInitFactors); sut.GetQ3Calibration( - refVolume: 1000.0, - refTime: 120.0, - initCalibFactor: ValidInitFactors, + 200.0, + 120.0, + ValidInitFactors, ref valid, + ref calibDiff, ref calib); Assert.IsFalse(sut.Q3CalibValid); @@ -70,13 +76,16 @@ namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.implementations var valid = new bool[3]; var calib = new double[3]; + var calibDiff = new double[3]; sut.GetQ3Calibration( refVolume: 0.0, refTime: 120.0, initCalibFactor: ValidInitFactors, ref valid, - ref calib); + ref calibDiff, + ref calib + ); Assert.IsFalse(sut.Q3CalibValid); CollectionAssert.AreEqual(new[] { false, false, false }, valid); @@ -93,13 +102,17 @@ namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.implementations var valid = new bool[3]; var calib = new double[3]; + var calibDiff = new double[3]; + sut.SetQ3Calibration(ValidInitFactors); sut.GetQ3Calibration( refVolume: 1000.0, refTime: 0.0, initCalibFactor: ValidInitFactors, ref valid, - ref calib); + ref calibDiff, + ref calib + ); Assert.IsFalse(sut.Q3CalibValid); CollectionAssert.AreEqual(new[] { false, false, false }, valid); @@ -117,13 +130,17 @@ namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.implementations var init = new[] { 0.0, 0.0, 0.0 }; var valid = new bool[3]; var calib = new double[3]; + var calibDiff = new double[3]; + sut.SetQ3Calibration(ValidInitFactors); sut.GetQ3Calibration( refVolume: 1000.0, refTime: 120.0, initCalibFactor: init, ref valid, - ref calib); + ref calibDiff, + ref calib + ); Assert.IsFalse(sut.Q3CalibValid); CollectionAssert.AreEqual(new[] { false, false, false }, valid); @@ -173,14 +190,19 @@ namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.implementations var init = new[] { 15625.0, 15625.0, 15625.0 }; var valid = new bool[3]; var calib = new double[3]; + var calibDiff = new double[3]; + sut.SetQ3Calibration(init); + sut.GetQ3Calibration( refVolume: 200.0, refTime: 120.0, initCalibFactor: init, ref valid, - ref calib); - + ref calibDiff, + ref calib + ); + double expectedCh1 = (200.0 / 600.0) * 15625.0; double expectedCh2 = (200.0 / 600.0) * 15625.0; double expectedCh3 = (200.0 / 560.0) * 15625.0; @@ -220,12 +242,15 @@ namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.implementations var init = new[] { 15625.0, 15625.0, 15625.0 }; var valid = new bool[3]; var calib = new double[3]; + var calibDiff = new double[3]; + sut.SetQ3Calibration(init); sut.GetQ3Calibration( - refVolume: 200.0, - refTime: 120.0, - initCalibFactor: init, + 200.0, + 120.0, + init, ref valid, + ref calibDiff, ref calib); Assert.IsTrue(valid[0], $"Ch1 invalid, value={calib[0]}"); diff --git a/packages/Common/Logic.ProductionToProductMapper.dll b/packages/Common/Logic.ProductionToProductMapper.dll index 88c2003821b2d3fe084cbc967d4323fd55dc0d14..699a1e30977dea6f302b68d04ded2c5e83036850 100644 GIT binary patch delta 145 zcmZpuXsDRb!Q3Y+y0QDWEYo!D$sKYkKx*?kIV&N7YgU~6D}P(LOn2D$zNdFZ`sN=7 zEKDH9lm8n@3S3*gN@ zEKDH9lm8n@3LIzoYX1FLt8-uY+VU9;e)~3S7^g6E-AWW<;9y{40Gct)%!HBCh{2S> c0E9PRHaAD&P8PPbMo3PcXtHWEqt$;#0Kx|_i2wiq diff --git a/packages/Common/Logic.ProductionToProductMapper.pdb b/packages/Common/Logic.ProductionToProductMapper.pdb index ec93fbf6cc852eab3621b408685923a56d6e9943..26ff63747755c3d7b68229b4b141360749faac62 100644 GIT binary patch delta 51 zcmV-30L=e@yaRx|1F#4>21HP@%f;-o4m$Re7>*qkY5@QM0M(>lqNJZJPq&&)v?h$D JbF&=I22~%|(c$T{4m$Re7!^biY5@QM0LKLNH}}ScLylLicbEW9 JzOx+8o+2F#ye&mX^WDX~ba4V8CF) cV7Zw+<2@30^8ZY0BuT-XeTpeiY5@QM09#YHLaoHPPO}^49Ed1S Jkh2_ws%)`JC6zmfGqS%+Q_`8!=Bm0acS8V=#-Moj#g&P3Z1RU-F diff --git a/packages/Common/Xylem.Common.CommonCore.ThreadWatcher.pdb b/packages/Common/Xylem.Common.CommonCore.ThreadWatcher.pdb index 28b96a70d7aaf7c26564a0cdcabb55632a69f2a4..4544419c69c3d4c14fa50c3b9a050f5f1b8ce69a 100644 GIT binary patch delta 51 zcmV-30L=e@oB@EG0k8-l2B9*H%Ej!n4j}d)7>peiY5@QM01Ur(6y*?FLX>b;M%^v7 JH delta 51 zcmV-30L=e@oB@EG0k8-l2Ju;B(BbK`4j}d)7!pJfY5@QM0O)f~0dx04N`VKMq|`k8 J^|Ks6p4udDa&M;*Bif?MR);|4p3DV z0}wC)u?!;v!yaQG7G+=v3U&!zt#s&4L2a2wkJN7Wn8&-EH(wCl!^HI>RfvHDs2*tU oGzkYrP9p|01_K5Q28+%2CB>1rlmAOuBP1sqitpRZDD$5Y0PX)R4gdfE diff --git a/packages/Common/Xylem.Common.CommonCore.pdb b/packages/Common/Xylem.Common.CommonCore.pdb index a0e848b8d1b44e74980af036396bba212442ee0c..dc4c54ec9fe0eafe7c9de269bf7a92d6624ee09e 100644 GIT binary patch delta 57 zcmV-90LK4->;Zu60k8-<2ur0e%Ej#50h2*TFtb29#48w!9TjQ;0000VT}wq#@mxif P!mDa_-Gc_R9A@MXjZhX+ delta 57 zcmV-90LK4->;Zu60k8-<2m&Hgr{?M00h2*TFtb29#48vvOb}`T00021BEsBoeRfEU P8oNhat>=5 u0|!t&(A;SfA&i_x45kbQ3?>Ygn?FmIBXK7eOIsr(CvOz<+RP~PpAi7SjW7fN diff --git a/packages/Common/Xylem.Common.Hardware.Interfaces.Ports.PortCore.pdb b/packages/Common/Xylem.Common.Hardware.Interfaces.Ports.PortCore.pdb index 3fa669f9059175b130fe9e79966ed4a927387b6f..c52e6de6e6966136321f68bc586311997674ad10 100644 GIT binary patch delta 57 zcmV-90LK4-i~@j+0Cj_gIV9D3vnRO}Uk diff --git a/packages/Common/Xylem.Common.Hardware.Interfaces.Ports.SerialPorts.dll b/packages/Common/Xylem.Common.Hardware.Interfaces.Ports.SerialPorts.dll index 7ee0cca57605705e77f4723af9362e4e1d97cb0c..f1809fa434521d7e328341358e51f44a4eab4d18 100644 GIT binary patch delta 181 zcmZqZVQlDOoY2ACBP+VGd#V!CH0{Ys$|@krL)l7fsx|`{Y-0gYObi?hLJUBu8Ol~b z6`QXpZxIzJpSZei*XI_W%?H#L{BOMfZu1OF0~U~RlTX`93dF2Eo#(XA!l%Q%%EWAf zPU+?^wlkQxrfCZSjbZ{CwRxID3?ru@0|=TjSZx07*p9@V-0f_Qkes~H&S*2E%YQ}y DAj~%1 delta 181 zcmZqZVQlDOoY286>>{wSd#V!C&BVz{$|@krL)l8~W+DR^Y-0gYObi?hLJUBu8Ol~b z6`QXpZxI!^bh9gaLuiQ8=Cy03Pw;D4Zk}OjzydOE@@ZR1fx}5(*8Oa7aGlpE#yIQ# zd8W-@Y-ccW-Aoh$8pQ-OYV$OQ7)DMb22%zD1``I$&A%Pnk+_q)ovjg)lQ-HKZDw@& G&jL%Ej!n4lwpx7>peiY5@QM09>uhZbH5|Oo&H%G&Ybd Jb+a6d J0<#>9W73%;1 diff --git a/packages/Common/Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol.dll b/packages/Common/Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol.dll index 9f3cf8c9ae97a4bc55c9506c123d2be6e1b818f6..d5d3a399bbc18f5c91695557e90bc09765962ac2 100644 GIT binary patch delta 171 zcmZpOXo#55!7O%7Y-6{-Ad__b&s7=##rQd&Z4Oj7ZigM{XB z3rvdQ)vtFBc3HOW-v^DX?{$$-?cKhuv2_iI9ACT*+_q6NMGb xT+;DEK$Dn&CT*UklEcVp#9+c;48-P}xz&~?CrE_?t0 delta 171 zcmZpOXo#55!QA~tcw@J}Ak$U*$#(=T#ID*ifI&ASh+<;kU=U&eN@)qH0aa`c5}L;? z@GrQn*CW!@amj*hf|9Fl-P$C#g9&8Jh7#7wRY5@QM0JXL>p|@$nN2=sl8S2L( JPO}_*h7>o21Y5@QM0Gufk69+vTN}zj97Pno& JShE~_}$Hl5wo87gznGoE`(K^-$-ey6)B*x8*djA;#*842` delta 159 zcmZojXh@jQ!7St=u(3OwpXp}e<|q6CyaGzs;%A(7oafsW#L&u>pSNYRi|hps9iXZ# z1|VPpVi`sT1|1h5R%2iY3U&$J6ZD%g!0n;KWOb{iva9kQn;q1An7D2x3Ndg1)dS6) prm=#N(}=;8!GOVp!E&>^7B>@uJ2_g%8o}EvsF%dJnNjaQBLJ7`Dg*!k diff --git a/packages/Common/Xylem.Common.Hardware.WaterMeter.Genesis.Applications.pdb b/packages/Common/Xylem.Common.Hardware.WaterMeter.Genesis.Applications.pdb index 22b667603f6a91ad16fb1601bbafe5df5c653a90..c7111d8ce01a345c73210a53728c950c5311de68 100644 GIT binary patch delta 51 zcmV-30L=e@oC1KH0peiY5@QM01KuucfRt2MzYPbMVamE Jd9xgVNaK$9mrf_Bv( JNV6P(&s7=##LVxO5X#m=xJ#H8Xk zALDQ06WDg`Y4;!c)U Rvqq8>)L6v0nNj0EBLL0mGUxyR delta 226 zcmZn&X$YCn!91l`U}N`nKBif1lT-Lr>}IwxfB_E&h+<;kU=U)M1r__ugei809U(Te zZSyhyCO(0l>pgWV6xKQK%UmNMb=IhUbA;RtMjfC~vj}cZ01$T_HgIu7wcZG=I<~!0Gn7F2C3o&p2)dS6) lCbxu<(~toKO&KgUJ1hK0;!gHfvPO~=R4HQI%&7985daeDDCz(J delta 159 zcmZqhY4DlQ!7Sn;u(5k9FVn5W%}#vVxC8>?S2XffPjs96aQ4(0(&s!jb4adW(gCW< zVgLdrAeLcdU^rn3#L^55LBTG;HcQou#bzhCH=KFoIWs{~Ve=j74NP3O5``Ezfa-zf mPLo^0$Z5o2%3uJ(o1GQ@BXK8tD_J8+3aS(_Ze~>Z&jL1#Bj4r H))Q_312z&Z delta 51 zcmV-30L=e@>;Zu60k8-x25?y^(c$T{4lMRP7!*VhY5@QM06e89a~7LmM}W-YNts|F JAhR55!c o7&(m?Oc;!T*kXHf8dEV!7QdjjN2KrnEo>Y01x9-i~s-t delta 530 zcmZp;!P#(wb3zAm?-$|5?ycR7OZAwp*-tmpXH-eMX3qcyM~p!f69Wf>5W`id7=t6G zSaS@f*nTTau~sDWfOhTCXH*k|nOmKJP!E**0hFtU$!VG(%YoPo3}2Ak0dsGv14std zy<$lSF_^l!NbZ2y;fpE8&#)mGS@ZNY28@1MFb(^y5ppoG$sWjJ(^U)^t>7M15kZz~ zFEM1?USi0U!zNJI{>=1TYqZzy9ItS#V8utK((-T4&H*8k< z5-tT1+up#(_}vvQkEC)tP^CC8c9~?x)6Ljqz@~3M@`AB>21I%~(D6U$;`U|?Xhv9$Y}TjRIY<7Y(c)dlt2Wu`DcQ3L>o4om+4 delta 204 zcmZp8!`JYJZv#ghM^ewuBO-6^FivJRs8XC4yG%0U>1J#)VAHoBdBNB`10p>gXnaoljz*^KI~tjN mgd}>u2xl=eFfho!tIRRpBkR!r>W09&Ki)3eWu`DcQ3L={gG@UB diff --git a/packages/Common/Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.dll b/packages/Common/Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.dll index a480b765f62ea55d3fa17c84694962dbdd3378f2..5d998840f22a6bdddfdef9770f838c853d5f6a3c 100644 GIT binary patch delta 301 zcmZqJ!_u&aWkLtD#2^zteVPR04^ATn69!`-w%9&hlChr=!Jn=#&1j9peJIA* Lx1CXj@joK~`g1}) delta 301 zcmZqJ!_u&aWkLsY-xuMH-Qx3^uG>#uGG9gPnmq#;u!w>vCI$`$A%?5=lkd$}V**la z3)J8$d{q!CuGvp^TA&tm6{^|B7+DI$W?;A?0wQ4sg4hfU-LfDORcx9fve@KZ3qTfc zezf3OkU;<8Lzi^_oN-;mxM=UIiTb{qZ+vD^1bJZkeGx`UfsD>G_ohsYcHAYrx_^X+~=#?n5!g LzU_=MjQ<${V_8g5 diff --git a/packages/Common/Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.pdb b/packages/Common/Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.pdb index fe2cfeae7306695d774128c760a618a54ce6446b..64055834c2b009ac358174514e7aee9e6b19cc70 100644 GIT binary patch delta 67 zcmV-J0KETzoC<)P3a|)f2$$dcV9f2@0hhsn0x*L>W`{s#0k=SA0>ld#8P*nR0RR91 Zz9G%(XoHALsYuq3+!hF1w;XZ;W`{s#0k=SA0>ld#j`S010RR91 ZXo<|;l#yFOx)Y@KI23htw;XZ;j!D5<~Fmq$i2X-;3cm^<#WdTu43>*wX4ASwNCvj|I6L9?KY%0&Mj!E$=btfL!yKCp{jwPyeWSr!n*#K6HI#BkMq^CXT(*A^dB20Lq#cJ^%m! diff --git a/packages/Common/Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol.dll b/packages/Common/Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol.dll index 426fd7cf5851e92cf463f0ef2c44afc90cd2bad4..1b7b771d99609e5645d03c3b647ec65e8b545366 100644 GIT binary patch delta 295 zcmZozz}T>WaY6^P_%*SO-OCl3q~j->D5=;<$1{MzWj+wa#K6HI!~hdZXT=oTjv_XB znvxpa2!0NPaw({>^HG$8p0W9yLbQHj}CJAo8Q>a zVATP-H4CDafkB3mfniQE5W6xk1O>YUKXP7^>Lz93w&>ZCqnl+_LN;%3y~D&M9WMm* s0u#^+o2PmFVdOMoFkvtTV)MV!Z delta 295 zcmZozz}T>WaY6@k?-${X-OCl3uGvpEQBtwHX3qcym-#>x69Wf>5W`idSUM}F*mfi_ zpb^uQ)a+o&`8hC^&qq=YQ+J#lS>5JeN{?g&_W68Ue9H8-LyvZf`AkNM8JpkO&tTO7 zx-|=;mVrTrk%3`OG7!5mFa!m=1b3Z!(s1dSfY-dqoGU*vb_H(U;ChFN>zcg~&^Z3KaX~)E3Y5@QM0E)`wfYRm=N}iJmsqq1d JQL`M7i z;_#)0x><#rS7<(A;*yRR0=kI_=%&rnbXb@;jTlTAjDgsE^J2a8j0o=JY6EKoZ?mA0 L6XRw^qyLNmjm$E& delta 246 zcmZq3Xvmn*!QA^rcw@J^1k*M9$y+2;(yrPwfWcN~5XHp6!63u{6JupTh+TuKGv!2x z!PLFQqW3L|y3KZyuXqGrgv)?>ThlPpLkim?>n8Ad>X!Byd^Na}Y)E3Y5@QM0Gv}9Td9L%N12EDlo_?H J6|)>vOUKw6kHeNQnhE$biZI^^yWU3$uG&-sn5Ehl#V~RjGJv2dgT?0G&Fx6s$=$8i2+7HY4Mv+8+x{~G04&fjD*ylh delta 167 zcmZpez|=5-X+j6Hh>O6+?o=nHTZxlDIjM-m>zNtxa8d*~`&?nsJC<>jjIin=9%?n7M8x u3IWYvVz`yKd0JBpBc~CADT4tBZ~oofj>MhZ-D-`HoNU-&w3)H(KO+DoPcp6m diff --git a/packages/Common/Xylem.Common.Hardware.WaterMeter.Genesis.Registers.pdb b/packages/Common/Xylem.Common.Hardware.WaterMeter.Genesis.Registers.pdb index 8cef354c9ccf8184d9eb9d8e69612c9db8075bed..0c2930a508074d62380a13063c44790020273c6a 100644 GIT binary patch delta 61 zcmV-D0K)%(oCbiL2CxWv2upc1%f;;60h0j&7m-jIvp{;p_ZW>G6>0$h002y(YmG$g TFG7SDN_!}fxuv%paslKU(TW!$ delta 61 zcmV-D0K)%(oCbiL2CxWv2%?WX(c$Ub0h0j&7m-jIvp{;p_ZSpJ5NZJc00643WvSCj TK~I)5R8ED^IQ6$2aslKU^z;~F diff --git a/packages/Common/Xylem.Common.Hardware.WaterMeter.WaterMeterCore.dll b/packages/Common/Xylem.Common.Hardware.WaterMeter.WaterMeterCore.dll index 7b09f4020e83f7756f60c71f2edf190c92f9dbcb..b6bc3f1f0a757ca4f62fd54971d78a9fda97a196 100644 GIT binary patch delta 194 zcmZo@VQgq&oY2ACD=WIOd#()AH0{Y+vML}dKvqp`nl=L%9N_~|Obi?hLJZTiH}}Xo zhzoe%J$ZC$%PRLxuVv=`MhCAUvY{|e76zmc_S15EY zPqDGfa>G@YPycY2Z~kC8hly*Nwh+)>{wSd#()A&BV!CvML}dKvqrcW+DR^9N_~|Obi?hLJT((H}}Xo zhzm>)+kav64s)-09DV|8D_UGP-!XZ?q60K13!;{RL57im;Z8UZTQV>N1-k^l)<3N3 zvBSu3rE$ZZdsRV;Hh-|3!^CwnQ3z-*6Uf|YHU*5FMhvD51`H+)mYezQ%8|H}`|Yg} Pl9Lsg^fog({AUCJqoOt? diff --git a/packages/Common/Xylem.Common.Hardware.WaterMeter.WaterMeterCore.pdb b/packages/Common/Xylem.Common.Hardware.WaterMeter.WaterMeterCore.pdb index d32b4e9bef6852c7adc21bdf1d1a439736854cd8..97d0e8e2d2ad37d725c649623ed656e75344fd4c 100644 GIT binary patch delta 51 zcmV-30L=e@%maYT1F#5K2Db(S%f;-o4p{bc7>ykjY5@QM0G$$5oeXm`M5i&TIpzEd Jce5PKn}72v YGa)dj2(yv>3_(-=213jJpU0Aq+Jp#T5? delta 139 zcmZqBXwaC@!7St=u(8{ih3RJE<^wDt%mNFPtP1lq86CFn4D@oZbNsSdg+qlAq-wG^ zr=-9SttrA)nIg^;i(i~Hn-%wMa|x#eGuO>TAqEZxCI+Ax(|BSSIgJ=h84MUq7%Vsc a=2d1wa3`w^SR;6w1%;+DZe|qv&jpeiY5@QM0JV2Ocpx8~O{A_sC+?#; J;jdn$u^o^ J_Ol#5E1Q_SKnvRJ!8BI9<0M5Yz$0(=}_6<(y8IxVVIW422_F=P9S4knQ} zkQ1i=f5s#!P;I%{%0~Z{^NgDuUzcBvtlqBioGFEwYr3`&&`u_X>Dt?;y<&1<JjD_ttL4lkrTq5~qhHFsd-!Oq^bmz~~3!pGja;v%8td00trF zK@<}M2ZIm;OicM2LhKe)oyA>**v-UtgG9#d28m27)CIUd9e#bzcfEhl{JORkGA;Jo zUvw~u#DSbJ{r@v2NrB|bbJly$=DF4{{&eTJOx6hL=^I}#Rc~i{$Mla80JXbFt^fc4 diff --git a/packages/Common/Xylem.Common.Logic.ProductionOrderCore.pdb b/packages/Common/Xylem.Common.Logic.ProductionOrderCore.pdb index d04412073f1da11026d8c411941a7e6f7aad9e3c..7a96d83db77d2a5ffbe3cafd25fb4586ff191025 100644 GIT binary patch delta 78 zcmZpeBh@fRY6Hgv4n>vP(?{RjVVum!WYFv|q1|BuBM>tIF*6XeY;t+Y?Oyko6t@ delta 78 zcmZpeBh@fRY6Hgv4h^^M7azX7!#J6d$)MR`Lc7BRMj&PaVrC#_+3qlb^~hxj5f_0h gMg|6kBbSW!8JX+sAir7U0rg1gV;A z%`GYL&wg*&|38*K?GM@nk4=kH-<-m&!OV5lUWkE%fr$ZV#xy0h19NFtb1+#1|M9))s030001gD~b~F)U`;r PV;TohQ&&&396IC+b2t?R delta 57 zcmV-90LK4-i~)d*0k8-n2r?_r!W8V>0h19NFtb1+#1|Nf^b=|U0002~KfQMU{5edA P;D!;#mR={b96IC+Xp$C# diff --git a/packages/Common/Xylem.Common.Logic.ServiceCore.dll b/packages/Common/Xylem.Common.Logic.ServiceCore.dll index e45eae2c7e7b40bc727698a36b95d03bcc44b2d3..d1ac66c31ff9c8feaed98507efcb7460ebbd08a9 100644 GIT binary patch delta 138 zcmZp0XmFU&!7O@BY-2YgFOyXK=04ta>;mi|1>668_~_Bw=zccd_7U&Oq0@Kpl9L}wY}(8y_n#2}N+&Bb delta 138 zcmZp0XmFU&!91x~U}HBUFVoDn&3(M<*aa;9E!MjBMb3BL@=b~rAOHGp_7VNV2vRlK zTU=5gU&@iiUUH4cthHAr?w-8IV{?hP1T)vnHX#NM1||le8PlY67&(m@On}go!F=;+ YX>%m*WNuk&gyiIh5}P(N%Kc{q0Heh$82|tP diff --git a/packages/Common/Xylem.Common.Logic.ServiceCore.pdb b/packages/Common/Xylem.Common.Logic.ServiceCore.pdb index de4d9e75896210c87dd74927cf0c647a4a362cae..b44511224c78b68f2193074ec214f4b11fe7f096 100644 GIT binary patch delta 51 zcmV-30L=e@tO04kY#?7?O<;Y5@QM0B;&W1V0(9NSdwGk-L+; JNV6PBinADifC-3Y7#SFRyntATfgvc^CHP;`da1B!%^u6d)^%mi`Eq-6f{qRo*EDS* s1`eQlpt;lZ6c{-T89>mK!D91%{ct4iWO+ktgydvFqj{Sdjs7zN0OX`D{r~^~ delta 165 zcmZq3Xvmn*!7S_|u(7*Tis@$JWG3kZAhkI~T8BqqU+Jyf;~S3nE_Ddmwx#T1inADifC-3Y7#SFRyntATfgvc^C0M@QI#e~~lJAZUN3>G9?p)rSprgaYbu&?j ufdi->XznyU1x8LI22%zD1``I$&HMGkk+_rP4XqK9lLd|DZDut3&jykjY5@QM0RCdH8djErNTwF9iff$o J+p`>k J)3Y3cKf6wCks diff --git a/packages/Common/Xylem.Common.Metrology.Measurements.dll b/packages/Common/Xylem.Common.Metrology.Measurements.dll index 394ad4b8278c5422fcbcf68e868e0993d737b7e9..6eb5448e3af7aa8ac4c358d74f6679d1bd8196e8 100644 GIT binary patch delta 165 zcmZpuXsDRb!E7KVwy|4UhUvxf$tz@h#GWr_0E0a&Ac~2BgF%Sl#q!Nuva5sz5^qIb z*Jl!STsA?q^h8VV+RaA{Oqf9iO#W>wDX{FpexWbdoBXC&0>* tpczacGp3o@FmjqO7%^BfSTLAuzHRP~#GR~dX^oJaENC@pGo#giMgRx}F+l(T delta 165 zcmZpuXsDRb!92NFU}Lwm4AacE$tz@h#AdcJfWaOX5XHp6!63vivu!h%>?&aao$zme z4(fC|ZsD=HFKsoifAbLo6K0SBlYbja3OKs-r%N$?ciH7}XHM?gj`N#UOfs0bX0{0d r&0qqVG0n_|k<*yL1PDzT%s1aQcSqt**0!`pNKO{CnzWhG>OUg@_jfSu diff --git a/packages/Common/Xylem.Common.Metrology.Measurements.pdb b/packages/Common/Xylem.Common.Metrology.Measurements.pdb index 03d01d0fc4ce0687016148f967a6cd907fcf8ce6..71e6fb6314d74822bb91d3181e58ac4370004b5e 100644 GIT binary patch delta 60 zcmV-C0K@-)%mRSS0(>N3PZCTnB)!71{Zq( delta 60 zcmV-C0K@-)%mRSS0tIF*6XeYtIF*6XeY+tWS&qrd=M# diff --git a/packages/Common/Xylem.Common.Ui.GenesisToolBox.exe b/packages/Common/Xylem.Common.Ui.GenesisToolBox.exe index d829df7def4c749da9eefa0c6fb0fcff7db213f9..01da14bffc8f5375d0028f1ee926f6123cf3a9bf 100644 GIT binary patch delta 583 zcmZpepwKWuVL}J9^fj@@?$&O`)^4WOZsyi*maW~a*4a$5@zYOav-&W}#7`H?VO3+2 zj-PG^rPF|Py>vVS7)U39C?*CD1|bHRnCwx6m<&|i=gpX6hp_04y@*gJ1=YLuEJ6%w z$8_#oRz;BG^m1AKv|tubnt)IU(>xE!K%gg<<+7@3_=~uyue2wF-8U!24)Zg2tG`IoyW>622&7>5-#n0`K&<9 zww*7Zy-G&lXvzYWyW+bXrmQabvsZD7()JnM>=gw%z-Y_@8N~#|GK>ri8d4k#8h_Xs zf`VOwZ~QzrWhG0A*976B?_aWuFK@T`!ydrGB^xgUj5a0)+4!x~I7%2fjTlTAjDgs4 eyD$^SeI)+$-^?7=NYa9A9ETXUGqQ2~X9NIA4Qglr delta 583 zcmZpepwKWuVL}Jt=&wm-OR1sEL*!-t+SbK*iS!^&FaH+-F~`Q4yzi| zHT&syAo{BP^fVw{f7PA=45X7l6cYmngAl_tsF>_gOtH_KF~tsH(Hnaap$=xp+Or5T zs2$U}b6FKZj?>F!_0xh`JZS<#Ax!f;6a%L(%VkwzS*Z%tc`g^?oo~6UWpM9IL2@R{ zgpNg6Of5o)!EC>d#rB{WggTgcfsa69j0`Lc%pe93e3&eD*3C0o%8)4(463bn4^!XMHtiR_*o~-Ru2bm0vW{w#4?Nw3>s1#3>tsf z8G?dcf(x`e*JV9-_ugFYnzmQv72|fBKkNZ4TsQ26fYHXpaKnD#HRPD2JW24e;j g29xc=OdR)-_|tzgb66uu3$k$>V%*Ni#_^vK0PzZXZU6uP diff --git a/packages/Common/Xylem.Common.Ui.GenesisToolBox.pdb b/packages/Common/Xylem.Common.Ui.GenesisToolBox.pdb index c41ce5b0efa86b00ecfd71851beb650314f24693..474596d0e3e3e3aaafa839fb305e8ed81b9f1475 100644 GIT binary patch delta 311 zcmZqpW845lTNpXwIHsuPB%OJChjB6^lfia}I7a#9tVSlrCg#&8m@sXJFt;nPF=gvv z2u}wJXS8oIW!k>QlzH!6u)GCGP-FW%VU~}{Pz?@^tQp(?l(STSgbILFEXib@E)Egc z4ped494d*h6>R)=lU=NukzhH9(bIuOJ8eHB%qA#^F52#+$_B*j+kI3y>X{+twO`QS z*nUBS^S3U9zx_fOr?fUy?n5JI`-es@Am-lwp^-;KMnd|USQaA#1H+A<=ccS=De;;h ST=e}*cJbxyGV^$z!~+2IRAM*) delta 311 zcmZqpW845lTNpXwIJ{eWkBPjw!#J6d$zZ!f9HablRzovm6Qk)9OqjMqnA;WDn6mXS zgr@_AGupS9GHu^t%Dne3R30d(v3;H}%g1D>fI}l|#`ZtuEY%;8RV>M5oh}X$*bY>2 z+8ip0uoZ0lc9UJKnvqBvrvr_4+I~iuO;8YBwB1LQ4T#yd`>1l%GeczCFKBRVzo5bS zTNlFLej$ugS{o|&p^>xwLn9Xub8r99$Ri>nG2x4F79#@#LxFbZx~%8!-kZx^)Ap*o MV%#n>kLO7|0Gu^oasU7T diff --git a/packages/Common/Xylem.Common.Utils.ByteArrayStyle.dll b/packages/Common/Xylem.Common.Utils.ByteArrayStyle.dll index 781af629700e1512304077dc57fa564c7e508066..6c7c24e9f8b8341002f7c2b8d5383bbe84da55e9 100644 GIT binary patch delta 142 zcmZqBXwaC@!Q3M&y0N>Jg=w1hW+7HBW`UYjiM#joX}az%3cMq+=(^@+9}XWzkgCbE zIVA;FDsJfAmGaSX|CE9j@%Q(wHy`0V!NfI9TZn;!fr$ZV#x$M~MovQp5Hw}5*!-FI aG!l36aeiwgNkM@Rj1vvmHZuzSX9NJ4`79;? delta 142 zcmZqBXwaC@!7St=u(7+9h3RJEW+7HBW`Qa4{f7f~v%5^6yV-@A`@-wZJ{&%bAXSrR zb4m(K*_iWcmyfo`g!#Ig49^Nr-+YAg1QXZIL?H$a1||le8Pj+|7&(m?Oc@LqOc*RT cf95@n#GQPc-x^6$P~ZdOL<6?Xj6(kz0U>uQIsgCw diff --git a/packages/Common/Xylem.Common.Utils.ByteArrayStyle.pdb b/packages/Common/Xylem.Common.Utils.ByteArrayStyle.pdb index 521955454a2e4d0ec0ff65a73c90f2ae44fefec1..230852745bad836ad69f2ed03c582f422bf04355 100644 GIT binary patch delta 51 zcmV-30L=e@i~)d*0k8-p28cPQ%Ej!n4kY#!7>peiY5@QM0I4Ccjk;v1`6vqGn delta 51 zcmV-30L=e@i~)d*0k8-p2HnbguTNRXc`vN6pQ Jm$Mu?p?6j=ZO diff --git a/packages/Common/Xylem.Common.Utils.Crc16Ccitt.dll b/packages/Common/Xylem.Common.Utils.Crc16Ccitt.dll index f5a0be2bc04ce4f40aac47d0aa874f5e68d6ccf3..a97e259cb994ead5141e6ef862d81de16922f335 100644 GIT binary patch delta 138 zcmZorX;7Ka!Q3M&y0QBsE7LUX&2?;TOae=@uQ<#OQ}x<^C+e^EqNh_gi*QOXf>ce` z=aLlod?uQug?E!{*TtlJALg@t*c`!S!o)RATZn;!fr$ZV#x$N5MovQp5Hw}5*sRQ_ WkHnoE&2Np6ocxh1X)~k1e?|cOuqp5W delta 138 zcmZorX;7Ka!7St=u(A6iE7Q%y&2?;TOac#E=bL=^#O5+Va7O3dOE0f&7U7g&1gV;= z&m}1!-#JZi>x9pKQ`z4dvZdv2+8n`U!o+nmQHX(qfr$ZV#x$N5MouFJQw9SD69&u8 Z%6$4r+{w}W)(FYTAGwk?GYb4?1OWY=DdPYD diff --git a/packages/Common/Xylem.Common.Utils.Crc16Ccitt.pdb b/packages/Common/Xylem.Common.Utils.Crc16Ccitt.pdb index e4dbe2ca7a7c4ceb9c10684f38880f7d23d708c0..0359508da70cf9ea267158746dca9152674ee7f2 100644 GIT binary patch delta 57 zcmV-90LK4-oB@EG0k8-p2vt%=%Ej#50h19NFtb1;#2pxn9TjQ;0002<%v%J64YEaw P(PG~4p9b)=975y^VsaKz delta 57 zcmV-90LK4-oB@EG0k8-p2v30?(BbLa0h19NFtb1;#2pwCL=b8L0000ViIx$ykn>KJ P2kkKiW^J;w975y^N-7j@ diff --git a/packages/Common/Xylem.Common.Utils.Logging.dll b/packages/Common/Xylem.Common.Utils.Logging.dll index 3dfdf0851e53a5209501d4e1f216e26c3a35994d..2750d77bfffdb429c0e094e792c0ef90a6579756 100644 GIT binary patch delta 134 zcmZpOX^5H7!Q3M&y0QDEAk#GM&1FJG`~v$AiHALUb;)PN@daB=#7;GB{-L;m8Ki3R zYE?;r9a~~rGS9E}m?jo~UHrjc*3DN`cQA2H(-vajU|?bZnlVkIhLPQn0R&AqOKNGt YIg>rLZ8@P53>K3U)rvMV>ilN}0LQp38UO$Q delta 134 zcmZpOX^5H7!EERwu(A84Ak&M~&1FJG`~q*CR`8ztd)Rl?tFP`$opxGp{-L;m8Ki3R zYE?-AJ5}lXg7rbZD}NkY@cSUg%*|I+cQA3iNEKq>U|?bZnlVkIhLPQf!HmIx!D6$d amL{At*;Ct=6Dq-AF*#AKXfvbEe?|Zb|1L@Z diff --git a/packages/Common/Xylem.Common.Utils.Logging.pdb b/packages/Common/Xylem.Common.Utils.Logging.pdb index d02503b0bfaa4a185c25ab8ac7395ae2ebff3484..bd634de0b64c55452fe2ee9bf2a28c4ef9088a93 100644 GIT binary patch delta 51 zcmV-30L=e@>;Zu60k8-%24LKr%Ej!n4l?#N7>peiY5@QM0JyYVglW&KNR}2~*B9XZ J1+yGz;Zu60k8-%274#9r{?Li4l?#N7%@x`Y5@QM06rxf-w}UOO{w_Cp!>lH JnX?>dj!Q3M&y0QB>7t>Vj%^}=7*aTFS=N$56kaO90G4=micBeU;WrR*J>Ht+` uF#rJ*5X&$!F#ItDVqpe`pkSBaT@#Fcuf1~3ccMQxgOb;8oy`IwAJ_rDgC5HO delta 94 zcmZp$Xt0>j!7S_|u(A6%7t_te%^}=7*aX-MuGTkZZt~a@>0vRcXsX?28KD!5IzUxf u3_!pH#4?Nw41WxPSeSt!DA*-fpeiY5@QM0J@Me`>oX0O_5Iv03u5J JEVCR&G|;NR33JI!CG? Jr?VVJ>ODy-@{O6T#pTK^mzj^zPElgLKxn$ynfc|1)kcr;6O1Z4D^;)CGk}4<4Txf5 z;9wA9xCRxw6M`%@{oDygHIUA4Ao{BPbh(od+6_wQLFs8wdLNLsy9zZc+6~z(5SxL) zHVQ diff --git a/packages/Common/XylemCommonUiLegacyGenCtl.pdb b/packages/Common/XylemCommonUiLegacyGenCtl.pdb index bdad89171254b4eb4eebfc723775038c4f9a9475..5dd6c53c47db4f4cdbc9d14fadd6fd7cbd9d6cd3 100644 GIT binary patch delta 101 zcmZqZ5ozcV*}&1j@h7t+@yy#hjFTCe3^qG7%y4Hn)-y6OHnC{Ff4u$vamMZUk2A?u z!vrVaKc3p2;mo`}!r@8&