From 94e7a04d7b97ce3276d3acb5ea9d584c7ea0c8cc Mon Sep 17 00:00:00 2001 From: Roland Drabesch Date: Wed, 24 Aug 2022 17:23:11 +0200 Subject: [PATCH 1/3] change UI1236 Comamds --- Common/.vs/config/applicationhost.config | 2 +- .../TransmitProtocol/BaseTransmitProtocol.cs | 2 + .../TransmitProtocol/ITransmitProtocol.cs | 2 + .../TransmitProtocol/IrdaTransmitProtocol.cs | 20 +++++++++ .../TransmitProtocol/LedTransmitProtocol.cs | 2 + .../TransmitProtocol/UartTransmitProtocol.cs | 17 ++++++- .../Genesis/GenesisCore/GenesisMeter.cs | 10 +++++ .../RequestProtocol/RequestProtocol.cs | 23 ++++++++++ ...erRegisters.csproj.CoreCompileInputs.cache | 2 +- ...ToXlsHelper.csproj.CoreCompileInputs.cache | 2 +- Common/Ui/LegacyGenesisControl/ICtlBatch.cs | 4 +- Common/Ui/LegacyGenesisControl/ctlBatch.cs | 44 +++++++++++++++++-- 12 files changed, 121 insertions(+), 9 deletions(-) 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 { From f2bff1d39c1562fdb19aa8260fd3adadef61abc2 Mon Sep 17 00:00:00 2001 From: Roland Drabesch Date: Fri, 26 Aug 2022 16:14:40 +0200 Subject: [PATCH 2/3] FinalCheck is ready for fai --- .../Exceptions/DB/PcbIdNotException.cs | 2 +- Common/ProductionUiCordonel/FinalTest.xaml | 31 +++-- Common/ProductionUiCordonel/FinalTest.xaml.cs | 113 ++++++++++++++---- .../ProductionUiCordonel/MainWindow.xaml.cs | 2 +- .../ProductionProcessCheckOrderNumber.cs | 5 +- .../ProductionProcessCheckSerialNumber.cs | 7 +- .../Actions/ProductionProcessDone.cs | 34 +++++- .../Actions/ProductionProcessShippingMode.cs | 41 ++++++- .../MultiProcessController.cs | 4 + .../FinalTest/UcBarcodeInput.xaml | 8 +- .../FinalTest/UcBarcodeInput.xaml.cs | 51 ++++---- .../UserControls/FinalTest/UcRadioCheck.xaml | 2 +- .../Controllers/RadioCheckController.cs | 2 +- .../SoftwareAccessHelper/LocalWebRequest.cs | 9 +- 14 files changed, 224 insertions(+), 87 deletions(-) diff --git a/Common/CommonCore/Exceptions/DB/PcbIdNotException.cs b/Common/CommonCore/Exceptions/DB/PcbIdNotException.cs index 87edfeee..d32d1a33 100644 --- a/Common/CommonCore/Exceptions/DB/PcbIdNotException.cs +++ b/Common/CommonCore/Exceptions/DB/PcbIdNotException.cs @@ -28,7 +28,7 @@ namespace Xylem.Common.CommonCore.Exceptions.Db sb.AppendLine("1. Retry your request."); sb.AppendLine("2. Check if your pcb was produced by LAA Operations."); - sb.AppendLine("3. Ask the source of your pcb for the password and the pcbid and let it regiuser at LAA Operations."); + sb.AppendLine("3. Ask the source of your pcb for the password and the pcbid and let it register at LAA Operations."); if (_lCode.HasValue) { diff --git a/Common/ProductionUiCordonel/FinalTest.xaml b/Common/ProductionUiCordonel/FinalTest.xaml index b3ca4e68..9c644d0e 100644 --- a/Common/ProductionUiCordonel/FinalTest.xaml +++ b/Common/ProductionUiCordonel/FinalTest.xaml @@ -6,8 +6,8 @@ xmlns:local="clr-namespace:ProductionUiCordonel" xmlns:uc="clr-namespace:ProductionUiCordonel" mc:Ignorable="d" - Title="FinalTest" MinHeight="500" MinWidth="400" Height="603" Width="646" Initialized="Window_Initialized" Closing="Window_Closing"> - + Title="FinalTest" MinHeight="500" MinWidth="600" Height="638" Width="800" Initialized="Window_Initialized" Closing="Window_Closing" PreviewKeyDown="Window_PreviewKeyDown"> + @@ -75,18 +75,19 @@ - - - + + + - + + - public partial class UcBarcodeInput : UserControl { - - public event EventHandler BarcodeInput; - + + public event EventHandler BarcodeInput; + public UcBarcodeInput() { InitializeComponent(); @@ -85,18 +74,28 @@ namespace ProductionUiCordonel.UserControls.FinalTest )); } + public void inputKey(string input) + { + this.Dispatcher.Invoke(DispatcherPriority.Send, + new Action(() => + { + BarcodeInput?.Invoke(this,input); + } + )); + } + private void txtHiddenInput_KeyDown(object sender, KeyEventArgs e) { - if (e.Key == Key.Enter) - { - - BarcodeInput?.Invoke(sender, e); - } - else - { - lblInput.Content = txtHiddenInput.Text; - } - + //if (e.Key == Key.Enter) + //{ + + // BarcodeInput?.Invoke(sender, e); + //} + //else + //{ + // lblInput.Content = txtHiddenInput.Text; + //} + } @@ -105,7 +104,7 @@ namespace ProductionUiCordonel.UserControls.FinalTest this.Dispatcher.Invoke(DispatcherPriority.Send, new Action(() => { - txtHiddenInput.Focus(); + //txtHiddenInput.Focus(); } )); } @@ -115,7 +114,7 @@ namespace ProductionUiCordonel.UserControls.FinalTest this.Dispatcher.Invoke(DispatcherPriority.Send, new Action(() => { - txtHiddenInput.Focus(); + //txtHiddenInput.Focus(); } )); } diff --git a/Common/ProductionUiCordonel/UserControls/FinalTest/UcRadioCheck.xaml b/Common/ProductionUiCordonel/UserControls/FinalTest/UcRadioCheck.xaml index 7324a689..42c90743 100644 --- a/Common/ProductionUiCordonel/UserControls/FinalTest/UcRadioCheck.xaml +++ b/Common/ProductionUiCordonel/UserControls/FinalTest/UcRadioCheck.xaml @@ -43,7 +43,7 @@