diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index 40cde372..ebc79eca 100644 --- a/Common/.vs/config/applicationhost.config +++ b/Common/.vs/config/applicationhost.config @@ -155,7 +155,7 @@ - + diff --git a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/BaseTransmitProtocol.cs b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/BaseTransmitProtocol.cs index 8f738811..215edf0b 100644 --- a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/BaseTransmitProtocol.cs +++ b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/BaseTransmitProtocol.cs @@ -24,6 +24,8 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol public abstract List DecodeDataForLogicLayer(List rawData); + public abstract List DecodeDataForPhysicalLayerUI1236(byte[] payload); + } } diff --git a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/ITransmitProtocol.cs b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/ITransmitProtocol.cs index cea8b9a5..e9ed89e9 100644 --- a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/ITransmitProtocol.cs +++ b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/ITransmitProtocol.cs @@ -22,6 +22,8 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol /// void SetDefaultResponseTimeout(); + List DecodeDataForPhysicalLayerUI1236(byte[] payload); + /// /// Send out data (including transport protocol specific data like CRC) to physical port (like UART or IrDA) /// diff --git a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/IrdaTransmitProtocol.cs b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/IrdaTransmitProtocol.cs index a328f353..80b45342 100644 --- a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/IrdaTransmitProtocol.cs +++ b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/IrdaTransmitProtocol.cs @@ -169,5 +169,25 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol return irdaRecord; } + + public override List DecodeDataForPhysicalLayerUI1236(byte[] requestProtocolPayload) + { + List collection = new List() + { + (byte) 35, + (byte) (requestProtocolPayload.Length / 2) + }; + collection.AddRange((IEnumerable)requestProtocolPayload); + ushort reversedLsb8408 = Xylem.Common.Utils.Crc16Ccitt.Crc16Ccitt.CalculateReversedLsb8408(collection.ToArray()); + List byteList = new List() + { + (byte) 155 + }; + byteList.AddRange((IEnumerable)collection); + byteList.Add((byte)((uint)reversedLsb8408 & (uint)byte.MaxValue)); + byteList.Add((byte)((uint)reversedLsb8408 >> 8)); + this.Logger.Info("DecodeDataForPhysicalLayerUI1236 PC->Cordonel(" + BitConverter.ToString(byteList.ToArray()) + ")"); + return byteList; + } } } diff --git a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/LedTransmitProtocol.cs b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/LedTransmitProtocol.cs index 3c94127d..6bd149ed 100644 --- a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/LedTransmitProtocol.cs +++ b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/LedTransmitProtocol.cs @@ -47,5 +47,7 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol { return rawData; } + + public override List DecodeDataForPhysicalLayerUI1236(byte[] payload) => throw new ApplicationException("Streaming port cannot send data"); } } diff --git a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/UartTransmitProtocol.cs b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/UartTransmitProtocol.cs index a924a9b1..93d6df33 100644 --- a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/UartTransmitProtocol.cs +++ b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/UartTransmitProtocol.cs @@ -144,7 +144,22 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol return uartRecord; } - + public override List DecodeDataForPhysicalLayerUI1236(byte[] requestProtocolPayload) + { + List byteList1 = new List(); + List list = ((IEnumerable)requestProtocolPayload).ToList(); + List byteList2 = new List(); + byteList1.Add((byte)(requestProtocolPayload.Length + 4 + 2)); + byteList1.Add((byte)0); + byteList1.Add((byte)0); + ushort num = this.CrcCalc(byteList1, list); + byteList2.Add((byte)91); + byteList2.AddRange((IEnumerable)byteList1); + byteList2.Add((byte)((uint)num & (uint)byte.MaxValue)); + byteList2.Add((byte)((uint)num >> 8)); + byteList2.AddRange((IEnumerable)list); + return byteList2; + } } } diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs index 66c1c034..3bf7dcfc 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs @@ -1878,6 +1878,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore } } + + public byte[] SendUI1236Command(byte[] UI1236Frame,bool waitForResult = true,bool checkRegister = false,ushort skipRetryErrorCode = 4) + { + this._logger.Info(string.Format("Slot:{0} - Sending Ui-1236 frame: {1} ", (object)this.Slot, (object)UI1236Frame)); + RequestRecord sendFifoUi1236 = this.RequestProtocol.AddRecordToSendFifoUI1236(UI1236Frame); + this.RequestProtocolProcess(); + return sendFifoUi1236.ResponsePayload.ToArray(); + } + + #endregion #region Class handling diff --git a/Common/Hardware/WaterMeter/Genesis/Protocols/RequestProtocol/RequestProtocol.cs b/Common/Hardware/WaterMeter/Genesis/Protocols/RequestProtocol/RequestProtocol.cs index a18d45e2..68176943 100644 --- a/Common/Hardware/WaterMeter/Genesis/Protocols/RequestProtocol/RequestProtocol.cs +++ b/Common/Hardware/WaterMeter/Genesis/Protocols/RequestProtocol/RequestProtocol.cs @@ -11,6 +11,8 @@ using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig; using Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore; using Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol.Consts; using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; +using Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol; +using Xylem.Common.Hardware.Interfaces.Ports.PortCore; namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol { @@ -305,6 +307,27 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol return recordForSendFifo; } + + public RequestRecord AddRecordToSendFifoUI1236( + byte[] payload, + RegisterDefinition register = null, + bool hideDataInLog = false, + ushort skipRetryErrorCode = 4) + { + byte maxValue = byte.MaxValue; + List requestProtocolData = new List() + { + maxValue + }; + requestProtocolData.AddRange((IEnumerable)payload); + ITransmitProtocol transmitProtocol = this.GetTransmitProtocol(); + List encodedRequestData = transmitProtocol.DecodeDataForPhysicalLayerUI1236(payload); + TransmitPortSettings transmitPortSettings = transmitProtocol.GetTransmitPortSettings(); + RequestRecord sendFifoUi1236 = new RequestRecord(maxValue, requestProtocolData, encodedRequestData, transmitPortSettings.ResponseTimeoutMs, register, hideDataInLog, skipRetryErrorCode); + this._recordsSendFifo.Enqueue(sendFifoUi1236); + return sendFifoUi1236; + } + /// /// Called after successful response. /// Decode and check record, handle Errors and dispatch result. 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 f22623aa..b81d5f66 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 @@ -5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3 +46bd00889699f5a20a4981a22f62b66368323855 diff --git a/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache b/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache index 0028f628..2634cdb8 100644 --- a/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache +++ b/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -f64d563def603c89cafafa61a3219ba97e1e344c +81d60b90addc793525740e9993e19bf6665bd401 diff --git a/Common/Ui/LegacyGenesisControl/ICtlBatch.cs b/Common/Ui/LegacyGenesisControl/ICtlBatch.cs index e1d98280..c8187b3d 100644 --- a/Common/Ui/LegacyGenesisControl/ICtlBatch.cs +++ b/Common/Ui/LegacyGenesisControl/ICtlBatch.cs @@ -15,7 +15,8 @@ namespace XylemCommonUiLegacyGenCtl void AddMeter(string serialNumber, int slot); void AddAllMeters(); void MeterDone(int slot, bool Succeed); - + void MeterDoneWithDetails(int slot, bool Succeed, out string LutCrc, out bool MeterHasPreadjustment); + void SetErrorFrame(int slot, double errorFrame = 0.0); void PrepareMeters(string meterDn = "-", double refPulseValence = 0.0, double predictedQFlow = 0.0, double predictedTs = 0.0, double refError = 0.0, bool isAdjustment = false, bool IsFlyingStartStop = true); @@ -48,7 +49,6 @@ namespace XylemCommonUiLegacyGenCtl bool IsBusy(); - void Dispose(bool fromCode); void SetTestSetupContainer(dynamic container); diff --git a/Common/Ui/LegacyGenesisControl/ctlBatch.cs b/Common/Ui/LegacyGenesisControl/ctlBatch.cs index c75518b3..7b202b43 100644 --- a/Common/Ui/LegacyGenesisControl/ctlBatch.cs +++ b/Common/Ui/LegacyGenesisControl/ctlBatch.cs @@ -1,4 +1,5 @@ using ByteArrayStyle; +using Newtonsoft.Json; using NLog; using System; using System.Collections.Concurrent; @@ -14,9 +15,11 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using Xylem.Common.CommonCore.Configuration; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; +using Xylem.Common.Logic.SoftwareAccessHelper; using Xylem.Common.Metrology.Measurements; using Xylem.Common.Metrology.Measurements.Consts; using Xylem.Common.Utils.Logging; @@ -700,9 +703,39 @@ namespace XylemCommonUiLegacyGenCtl } } + public void MeterDoneWithDetails(int slot, bool Succeed, out string LutCrc, out bool MeterHasPreadjustment) + { + LutCrc = ""; + MeterHasPreadjustment = false; + MeterDone(slot, Succeed); + var meter = batch.ListOfMeters.First(f => f.Slot == slot); + if (meter != null && meter is GenesisMeter gen) + { + LutCrc = gen.LutCrc; + try + { + var responseJson = LocalWebRequest.GetRequest($"{ServiceUrls.MeterInfoForTestBench()}{gen.PcbId}"); + var a = JsonConvert.DeserializeObject(responseJson); + var SerialNumber = a[0]; + if (!String.IsNullOrEmpty(SerialNumber)) + { + int tmp; + MeterHasPreadjustment = int.TryParse(a[4], out tmp); + } + } + catch (Exception) + { + + throw; + } + + } + } - public void MeterDone(int slot, bool Succeed) + + + public void MeterDone(int slot, bool Succeed) { try { @@ -750,14 +783,19 @@ namespace XylemCommonUiLegacyGenCtl if (!genMeter.IsLoggedOn) { genMeter.Login(); + } genMeter.WriteRegister(Register.Genesisflow.SampleRate, 2); genMeter.WriteRegister(Register.Genesisflow.LedMode, 0,true); - + meter.WriteLog($"MeterIsDone {state} {genMeter.LutCrc }"); + } + else + { + meter.WriteLog($"MeterIsDone {state} "); } - meter.WriteLog($"MeterIsDone {state}"); + }).ContinueWith(delegate {