From 0c3e28b8bd147af418a14e2ca56c3a0215356777 Mon Sep 17 00:00:00 2001 From: Roland Drabesch Date: Wed, 10 Aug 2022 17:06:09 +0200 Subject: [PATCH] Mostly EOL and LUT Management --- Common/.shared/SharedAssemblyInfo.cs | 4 +- Common/.vs/config/applicationhost.config | 2 +- .../StreamingProtocol/StreamingDecoder.cs | 47 +- .../WaterMeter/WaterMeterCore/MeterBatch.cs | 2 + ...erRegisters.csproj.CoreCompileInputs.cache | 2 +- .../Cordonel/CordonelMetrologyLut.cs | 21 + .../Files/Lut/CordonelMetrologyLut.cs | 22 - .../Logic.ProductionToProductMapper.csproj | 6 +- .../KitronTestResults/JsonObject.cs | 435 ++++++++++++++++++ .../KitronTestResults/RadioTest.cs | 151 ++++++ .../OrderData/OrderProgrammingParameters.cs | 2 +- .../OrderData/OrderRadioParameter.cs | 4 +- .../Actions/ProductionProcessConnect.cs | 3 +- ...tionProcessFinalParameterizationVakoCsd.cs | 34 +- .../Actions/ProductionProcessFullReadOut.cs | 14 +- .../Actions/ProductionProcessRadioCheck.cs | 2 +- .../Controllers/FileUpToDateController.cs | 143 +++++- .../FrmLutManagement.Designer.cs | 190 +++----- Common/Ui/GenesisToolBox/FrmLutManagement.cs | 193 +++++++- .../Ui/GenesisToolBox/FrmLutManagement.resx | 49 +- .../Ui/GenesisToolBox/GenesisToolBox.csproj | 6 + ...r.Cordonel.CordonelMetrologyLut.datasource | 10 + ....Files.Lut.CordonelMetrologyLut.datasource | 10 + Common/Ui/LegacyGenesisControl/ctlBatch.cs | 5 + 24 files changed, 1116 insertions(+), 241 deletions(-) create mode 100644 Common/Logic.PrdoctionToProductMapper/Cordonel/CordonelMetrologyLut.cs delete mode 100644 Common/Logic.PrdoctionToProductMapper/Files/Lut/CordonelMetrologyLut.cs create mode 100644 Common/Ui/GenesisToolBox/Properties/DataSources/Logic.ProductionToProductMapper.Cordonel.CordonelMetrologyLut.datasource create mode 100644 Common/Ui/GenesisToolBox/Properties/DataSources/Logic.ProductionToProductMapper.Files.Lut.CordonelMetrologyLut.datasource diff --git a/Common/.shared/SharedAssemblyInfo.cs b/Common/.shared/SharedAssemblyInfo.cs index fc3528f6..b92dfac5 100644 --- a/Common/.shared/SharedAssemblyInfo.cs +++ b/Common/.shared/SharedAssemblyInfo.cs @@ -14,5 +14,5 @@ using System.Reflection; //[assembly: AssemblyVersion("1.2.*.0")] -[assembly: AssemblyVersion("2.2.8.*")] -[assembly: AssemblyFileVersion("2.2.8.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.2.9.*")] +[assembly: AssemblyFileVersion("2.2.9.0")] \ No newline at end of file diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index 1b9332b4..40cde372 100644 --- a/Common/.vs/config/applicationhost.config +++ b/Common/.vs/config/applicationhost.config @@ -155,7 +155,7 @@ - + diff --git a/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingDecoder.cs b/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingDecoder.cs index a140da9e..233e191e 100644 --- a/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingDecoder.cs +++ b/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingDecoder.cs @@ -111,6 +111,21 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol // save the raw message for CRC calculation before separation to fields _rawMsgForCrc = rawMsg; // extract message and split it to fields + + + //Dn 50 + //2022-07-21 07:22:06.9871 | @f 8497D 062E4216 9B2A + //2022-07-21 07:22:06.9871 | @h 1 0 0A1F59C4 00017A43 00115C45 72E1596B 00000400 00001998 7D91B652 7D4F37E6 000191E6 0C 062E4A9C 5331 + //2022-07-21 07:22:07.0171 | @h 2 0 0A1B1FE8 00017B7F 00116B56 72B77427 00000400 0000199A 7DC09688 7B570006 000191E6 0C 062E5326 95BD + //rawMsg = "@h 3 0 0A1DF1D5 00017EA8 00118037 741F80F3 00000400 00001998 7E58A62E 7CC2C606 000191E6 0C 062E5BAE D40E"; + //DN80 + // 2022-04-28 15:19:54.9167 | @f AA754B 4D0CEE78 5D89 + //2022-04-28 15:19:54.9337 | @h 1 0 0EF4A130 0002AAB8 000DAC8C 02B98FBD 00000200 00000FFC 643BCF30 63C9CFF6 00015096 0C 4D0CF3CC 3E87 + //2022-04-28 15:19:54.9497 | @h 2 0 0EFA3000 000283E7 000CE580 E3D5EFFA 00000200 00001000 6DC0A84E 6CD462C2 00015096 0C 4D0CF922 1646 + //2022-04-28 15:19:54.9627 | @h 3 0 0EFF7F91 0002AC39 000DB43D FE1C0254 00000200 00000FFE 6C932DE6 6D20005D 00015096 0C 4D0CFE76 868A + //2022-04-28 15:19:54.9787 | @f AA7C01 4D0CFE76 B08F + // rawMsg = "@h 3 0 0EFF7F91 0002AC39 000DB43D FE1C0254 00000200 00000FFE 6C932DE6 6D20005D 00015096 0C 4D0CFE76 868A "; + rawMsg = rawMsg.Replace('\n', ' '); var field = rawMsg.Split(' '); @@ -119,20 +134,31 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol case "@f": isSuccessfulDecoded = DecodeProtocolF(field); if (isSuccessfulDecoded || !_ignoreCorruptedData) + { DataFlowTest = _dataFlowTestRec; + } + break; case "@g": { isSuccessfulDecoded = DecodeProtocolG(ref _dataCalibRec, field); if (isSuccessfulDecoded || !_ignoreCorruptedData) + { DataCalib = _dataCalibRec; + } + break; } case "@h": { + + isSuccessfulDecoded = DecodeProtocolH(ref _dataCalibRec, field); if (isSuccessfulDecoded || !_ignoreCorruptedData) + { DataCalib = _dataCalibRec; + } + break; } } @@ -157,7 +183,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol var byteArraySize = _rawMsgForCrc.Length - 4; var byteArray = new Byte[byteArraySize]; for (var i = 0; i < byteArraySize; i++) + { byteArray[i] = (Byte)_rawMsgForCrc[i]; + } + _rawMsgForCrc = null; var calculatedCrc = Crc16Ccitt.CalculateMsb1021(byteArray); @@ -197,7 +226,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol var byteArraySize = _rawMsgForCrc.Length - 4; var byteArray = new Byte[byteArraySize]; for (var i = 0; i < byteArraySize; i++) + { byteArray[i] = (Byte)_rawMsgForCrc[i]; + } + _rawMsgForCrc = null; var calculatedCrc = Crc16Ccitt.CalculateMsb1021(byteArray); @@ -212,7 +244,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol //compare received with calculated CRC if (calculatedCrc != dataProtGRec.Crc || IsValidProtG != dataProtGRec.Validation) + { return false; + } //decode rest of message only if CRC and mode are valid dataProtGRec.IsValid = true; @@ -292,7 +326,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol private Boolean DecodeProtocolH(ref CalibrationRecord dataProtHRec, IList field) { - + dataProtHRec.DecodedTime = DateTimeOffset.UtcNow; dataProtHRec.IsValid = false; @@ -300,7 +334,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol var byteArraySize = _rawMsgForCrc.Length - 4; var byteArray = new Byte[byteArraySize]; for (var i = 0; i < byteArraySize; i++) + { byteArray[i] = (Byte)_rawMsgForCrc[i]; + } + _rawMsgForCrc = null; var calculatedCrc = Crc16Ccitt.CalculateMsb1021(byteArray); @@ -322,7 +359,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol } // decode rest of message only if CRC and mode are valid dataProtHRec.IsValid = true; - + // Total time of flight dataProtHRec.TotalTimeOfFlightS = int.Parse(field[(Int32)ProtHsubString.Ttof], @@ -335,10 +372,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol dataProtHRec.RAWTotalTimeOfFlight = - int.Parse(field[(Int32) ProtHsubString.Ttof], NumberStyles.AllowHexSpecifier); - dataProtHRec.RAWDeltaTimeOfFlight = int.Parse(field[(Int32) ProtHsubString.Dtof], NumberStyles.AllowHexSpecifier); + int.Parse(field[(Int32)ProtHsubString.Ttof], NumberStyles.AllowHexSpecifier); + dataProtHRec.RAWDeltaTimeOfFlight = int.Parse(field[(Int32)ProtHsubString.Dtof], NumberStyles.AllowHexSpecifier); - //Delta raw volume between two samples + //Delta raw volume between two samples dataProtHRec.DeltaVolumeRaw = uint.Parse(field[(Int32)ProtHsubString.RawDVolume], NumberStyles.AllowHexSpecifier); diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs b/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs index 17526ac1..32cae414 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs +++ b/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs @@ -56,6 +56,7 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore } _listOfMeters.Add(meterToAdd); + meterToAdd.ConnectMeter(); } @@ -67,6 +68,7 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore meterToAdd.LoadConfiguration(!string.IsNullOrEmpty(_sourceLocation) ? _sourceLocation : Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))); + } } 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 d8b5c8f6..f22623aa 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 @@ -1a3d4919c9c702245832d925951f2b7cb72fc333 +5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3 diff --git a/Common/Logic.PrdoctionToProductMapper/Cordonel/CordonelMetrologyLut.cs b/Common/Logic.PrdoctionToProductMapper/Cordonel/CordonelMetrologyLut.cs new file mode 100644 index 00000000..17850db0 --- /dev/null +++ b/Common/Logic.PrdoctionToProductMapper/Cordonel/CordonelMetrologyLut.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace Logic.ProductionToProductMapper.Cordonel +{ + public class CordonelMetrologyLut + { + public int Id { get; set; } + public int FileId { get; set; } + public string FileName { get; set; } + public MeterSize MeterSize { get; set; } + public string Region { get; set; } + public int FileCrc { get; set; } + public bool CurrentVerionForProd { get; set; } + + public int DataLength { get; set; } + + public string Version { get; set; } + public byte[] FileContent { get; set; } + + } +} diff --git a/Common/Logic.PrdoctionToProductMapper/Files/Lut/CordonelMetrologyLut.cs b/Common/Logic.PrdoctionToProductMapper/Files/Lut/CordonelMetrologyLut.cs deleted file mode 100644 index e581fc0a..00000000 --- a/Common/Logic.PrdoctionToProductMapper/Files/Lut/CordonelMetrologyLut.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Logic.ProductionToProductMapper.Cordonel; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Logic.ProductionToProductMapper.Files.Lut -{ - public class CordonelMetrologyLut - { - - public int FileId { get; set; } - public string FileName { get; set; } - public MeterSize MeterSize { get; set; } - public string Region { get; set; } - public int CRC { get; set; } - public bool ForProduction { get; set; } - - public List Content { get; set; } - - } -} diff --git a/Common/Logic.PrdoctionToProductMapper/Logic.ProductionToProductMapper.csproj b/Common/Logic.PrdoctionToProductMapper/Logic.ProductionToProductMapper.csproj index 0cefbcc7..3bcfc753 100644 --- a/Common/Logic.PrdoctionToProductMapper/Logic.ProductionToProductMapper.csproj +++ b/Common/Logic.PrdoctionToProductMapper/Logic.ProductionToProductMapper.csproj @@ -80,7 +80,7 @@ - + @@ -97,6 +97,8 @@ ProductionOrderCore - + + + \ No newline at end of file diff --git a/Common/Logic/ProductionOrderCore/KitronTestResults/JsonObject.cs b/Common/Logic/ProductionOrderCore/KitronTestResults/JsonObject.cs index f16d5616..f6cf5b3c 100644 --- a/Common/Logic/ProductionOrderCore/KitronTestResults/JsonObject.cs +++ b/Common/Logic/ProductionOrderCore/KitronTestResults/JsonObject.cs @@ -784,6 +784,441 @@ namespace Xylem.Common.Logic.ProductionOrderCore.KitronTestResults [JsonProperty("RFRemeasurePower Loop_12")] public string RFRemeasurePowerLoop12 { get; set; } + + [JsonProperty("ResultCalibration Loop_13")] + public string ResultCalibrationLoop13 { get; set; } + + [JsonProperty("LengthCode Loop_13")] + public string LengthCodeLoop13 { get; set; } + + [JsonProperty("RunCalibrate Loop_13")] + public string RunCalibrateLoop13 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_13")] + public string RFCalibrationCurrentLoop13 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_13")] + public string RFCalibrationPowerLoop13 { get; set; } + + [JsonProperty("PowerlevelReference Loop_13")] + public string PowerlevelReferenceLoop13 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_13")] + public string PowerLevelCalculatedLoop13 { get; set; } + + [JsonProperty("AntennaMatching Loop_13")] + public string AntennaMatchingLoop13 { get; set; } + + [JsonProperty("LookupTableCSV Loop_13")] + public string LookupTableCSVLoop13 { get; set; } + + [JsonProperty("RunRemeasure Loop_13")] + public string RunRemeasureLoop13 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_13")] + public string ResultRFRemeasureLoop13 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_13")] + public string RFRemeasureCurrentLoop13 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_13")] + public string RFRemeasurePowerLoop13 { get; set; } + + [JsonProperty("ResultCalibration Loop_14")] + public string ResultCalibrationLoop14 { get; set; } + + [JsonProperty("LengthCode Loop_14")] + public string LengthCodeLoop14 { get; set; } + + [JsonProperty("RunCalibrate Loop_14")] + public string RunCalibrateLoop14 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_14")] + public string RFCalibrationCurrentLoop14 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_14")] + public string RFCalibrationPowerLoop14 { get; set; } + + [JsonProperty("PowerlevelReference Loop_14")] + public string PowerlevelReferenceLoop14 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_14")] + public string PowerLevelCalculatedLoop14 { get; set; } + + [JsonProperty("AntennaMatching Loop_14")] + public string AntennaMatchingLoop14 { get; set; } + + [JsonProperty("LookupTableCSV Loop_14")] + public string LookupTableCSVLoop14 { get; set; } + + [JsonProperty("RunRemeasure Loop_14")] + public string RunRemeasureLoop14 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_14")] + public string ResultRFRemeasureLoop14 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_14")] + public string RFRemeasureCurrentLoop14 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_14")] + public string RFRemeasurePowerLoop14 { get; set; } + + [JsonProperty("ResultCalibration Loop_15")] + public string ResultCalibrationLoop15 { get; set; } + + [JsonProperty("LengthCode Loop_15")] + public string LengthCodeLoop15 { get; set; } + + [JsonProperty("RunCalibrate Loop_15")] + public string RunCalibrateLoop15 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_15")] + public string RFCalibrationCurrentLoop15 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_15")] + public string RFCalibrationPowerLoop15 { get; set; } + + [JsonProperty("PowerlevelReference Loop_15")] + public string PowerlevelReferenceLoop15 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_15")] + public string PowerLevelCalculatedLoop15 { get; set; } + + [JsonProperty("AntennaMatching Loop_15")] + public string AntennaMatchingLoop15 { get; set; } + + [JsonProperty("LookupTableCSV Loop_15")] + public string LookupTableCSVLoop15 { get; set; } + + [JsonProperty("RunRemeasure Loop_15")] + public string RunRemeasureLoop15 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_15")] + public string ResultRFRemeasureLoop15 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_15")] + public string RFRemeasureCurrentLoop15 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_15")] + public string RFRemeasurePowerLoop15 { get; set; } + + [JsonProperty("ResultCalibration Loop_16")] + public string ResultCalibrationLoop16 { get; set; } + + [JsonProperty("LengthCode Loop_16")] + public string LengthCodeLoop16 { get; set; } + + [JsonProperty("RunCalibrate Loop_16")] + public string RunCalibrateLoop16 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_16")] + public string RFCalibrationCurrentLoop16 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_16")] + public string RFCalibrationPowerLoop16 { get; set; } + + [JsonProperty("PowerlevelReference Loop_16")] + public string PowerlevelReferenceLoop16 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_16")] + public string PowerLevelCalculatedLoop16 { get; set; } + + [JsonProperty("AntennaMatching Loop_16")] + public string AntennaMatchingLoop16 { get; set; } + + [JsonProperty("LookupTableCSV Loop_16")] + public string LookupTableCSVLoop16 { get; set; } + + [JsonProperty("RunRemeasure Loop_16")] + public string RunRemeasureLoop16 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_16")] + public string ResultRFRemeasureLoop16 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_16")] + public string RFRemeasureCurrentLoop16 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_16")] + public string RFRemeasurePowerLoop16 { get; set; } + + [JsonProperty("ResultCalibration Loop_17")] + public string ResultCalibrationLoop17 { get; set; } + + [JsonProperty("LengthCode Loop_17")] + public string LengthCodeLoop17 { get; set; } + + [JsonProperty("RunCalibrate Loop_17")] + public string RunCalibrateLoop17 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_17")] + public string RFCalibrationCurrentLoop17 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_17")] + public string RFCalibrationPowerLoop17 { get; set; } + + [JsonProperty("PowerlevelReference Loop_17")] + public string PowerlevelReferenceLoop17 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_17")] + public string PowerLevelCalculatedLoop17 { get; set; } + + [JsonProperty("AntennaMatching Loop_17")] + public string AntennaMatchingLoop17 { get; set; } + + [JsonProperty("LookupTableCSV Loop_17")] + public string LookupTableCSVLoop17 { get; set; } + + [JsonProperty("RunRemeasure Loop_17")] + public string RunRemeasureLoop17 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_17")] + public string ResultRFRemeasureLoop17 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_17")] + public string RFRemeasureCurrentLoop17 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_17")] + public string RFRemeasurePowerLoop17 { get; set; } + + + [JsonProperty("ResultCalibration Loop_18")] + public string ResultCalibrationLoop18 { get; set; } + + [JsonProperty("LengthCode Loop_18")] + public string LengthCodeLoop18 { get; set; } + + [JsonProperty("RunCalibrate Loop_18")] + public string RunCalibrateLoop18 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_18")] + public string RFCalibrationCurrentLoop18 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_18")] + public string RFCalibrationPowerLoop18 { get; set; } + + [JsonProperty("PowerlevelReference Loop_18")] + public string PowerlevelReferenceLoop18 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_18")] + public string PowerLevelCalculatedLoop18 { get; set; } + + [JsonProperty("AntennaMatching Loop_18")] + public string AntennaMatchingLoop18 { get; set; } + + [JsonProperty("LookupTableCSV Loop_18")] + public string LookupTableCSVLoop18 { get; set; } + + [JsonProperty("RunRemeasure Loop_18")] + public string RunRemeasureLoop18 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_18")] + public string ResultRFRemeasureLoop18 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_18")] + public string RFRemeasureCurrentLoop18 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_18")] + public string RFRemeasurePowerLoop18 { get; set; } + + [JsonProperty("ResultCalibration Loop_19")] + public string ResultCalibrationLoop19 { get; set; } + + [JsonProperty("LengthCode Loop_19")] + public string LengthCodeLoop19 { get; set; } + + [JsonProperty("RunCalibrate Loop_19")] + public string RunCalibrateLoop19 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_19")] + public string RFCalibrationCurrentLoop19 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_19")] + public string RFCalibrationPowerLoop19 { get; set; } + + [JsonProperty("PowerlevelReference Loop_19")] + public string PowerlevelReferenceLoop19 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_19")] + public string PowerLevelCalculatedLoop19 { get; set; } + + [JsonProperty("AntennaMatching Loop_19")] + public string AntennaMatchingLoop19 { get; set; } + + [JsonProperty("LookupTableCSV Loop_19")] + public string LookupTableCSVLoop19 { get; set; } + + [JsonProperty("RunRemeasure Loop_19")] + public string RunRemeasureLoop19 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_19")] + public string ResultRFRemeasureLoop19 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_19")] + public string RFRemeasureCurrentLoop19 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_19")] + public string RFRemeasurePowerLoop19 { get; set; } + + + [JsonProperty("ResultCalibration Loop_20")] + public string ResultCalibrationLoop20 { get; set; } + + [JsonProperty("LengthCode Loop_20")] + public string LengthCodeLoop20 { get; set; } + + [JsonProperty("RunCalibrate Loop_20")] + public string RunCalibrateLoop20 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_20")] + public string RFCalibrationCurrentLoop20 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_20")] + public string RFCalibrationPowerLoop20 { get; set; } + + [JsonProperty("PowerlevelReference Loop_20")] + public string PowerlevelReferenceLoop20 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_20")] + public string PowerLevelCalculatedLoop20 { get; set; } + + [JsonProperty("AntennaMatching Loop_20")] + public string AntennaMatchingLoop20 { get; set; } + + [JsonProperty("LookupTableCSV Loop_20")] + public string LookupTableCSVLoop20 { get; set; } + + [JsonProperty("RunRemeasure Loop_20")] + public string RunRemeasureLoop20 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_20")] + public string ResultRFRemeasureLoop20 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_20")] + public string RFRemeasureCurrentLoop20 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_20")] + public string RFRemeasurePowerLoop20 { get; set; } + + [JsonProperty("ResultCalibration Loop_21")] + public string ResultCalibrationLoop21 { get; set; } + + [JsonProperty("LengthCode Loop_21")] + public string LengthCodeLoop21 { get; set; } + + [JsonProperty("RunCalibrate Loop_21")] + public string RunCalibrateLoop21 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_21")] + public string RFCalibrationCurrentLoop21 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_21")] + public string RFCalibrationPowerLoop21 { get; set; } + + [JsonProperty("PowerlevelReference Loop_21")] + public string PowerlevelReferenceLoop21 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_21")] + public string PowerLevelCalculatedLoop21 { get; set; } + + [JsonProperty("AntennaMatching Loop_21")] + public string AntennaMatchingLoop21 { get; set; } + + [JsonProperty("LookupTableCSV Loop_21")] + public string LookupTableCSVLoop21 { get; set; } + + [JsonProperty("RunRemeasure Loop_21")] + public string RunRemeasureLoop21 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_21")] + public string ResultRFRemeasureLoop21 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_21")] + public string RFRemeasureCurrentLoop21 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_21")] + public string RFRemeasurePowerLoop21 { get; set; } + + + [JsonProperty("ResultCalibration Loop_22")] + public string ResultCalibrationLoop22 { get; set; } + + [JsonProperty("LengthCode Loop_22")] + public string LengthCodeLoop22 { get; set; } + + [JsonProperty("RunCalibrate Loop_22")] + public string RunCalibrateLoop22 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_22")] + public string RFCalibrationCurrentLoop22 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_22")] + public string RFCalibrationPowerLoop22 { get; set; } + + [JsonProperty("PowerlevelReference Loop_22")] + public string PowerlevelReferenceLoop22 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_22")] + public string PowerLevelCalculatedLoop22 { get; set; } + + [JsonProperty("AntennaMatching Loop_22")] + public string AntennaMatchingLoop22 { get; set; } + + [JsonProperty("LookupTableCSV Loop_22")] + public string LookupTableCSVLoop22 { get; set; } + + [JsonProperty("RunRemeasure Loop_22")] + public string RunRemeasureLoop22 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_22")] + public string ResultRFRemeasureLoop22 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_22")] + public string RFRemeasureCurrentLoop22 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_22")] + public string RFRemeasurePowerLoop22 { get; set; } + + [JsonProperty("ResultCalibration Loop_23")] + public string ResultCalibrationLoop23 { get; set; } + + [JsonProperty("LengthCode Loop_23")] + public string LengthCodeLoop23 { get; set; } + + [JsonProperty("RunCalibrate Loop_23")] + public string RunCalibrateLoop23 { get; set; } + + [JsonProperty("RFCalibrationCurrent Loop_23")] + public string RFCalibrationCurrentLoop23 { get; set; } + + [JsonProperty("RFCalibrationPower Loop_23")] + public string RFCalibrationPowerLoop23 { get; set; } + + [JsonProperty("PowerlevelReference Loop_23")] + public string PowerlevelReferenceLoop23 { get; set; } + + [JsonProperty("PowerLevelCalculated Loop_23")] + public string PowerLevelCalculatedLoop23 { get; set; } + + [JsonProperty("AntennaMatching Loop_23")] + public string AntennaMatchingLoop23 { get; set; } + + [JsonProperty("LookupTableCSV Loop_23")] + public string LookupTableCSVLoop23 { get; set; } + + [JsonProperty("RunRemeasure Loop_23")] + public string RunRemeasureLoop23 { get; set; } + + [JsonProperty("ResultRFRemeasure Loop_23")] + public string ResultRFRemeasureLoop23 { get; set; } + + [JsonProperty("RFRemeasureCurrent Loop_23")] + public string RFRemeasureCurrentLoop23 { get; set; } + + [JsonProperty("RFRemeasurePower Loop_23")] + public string RFRemeasurePowerLoop23 { get; set; } + + + } public class Root diff --git a/Common/Logic/ProductionOrderCore/KitronTestResults/RadioTest.cs b/Common/Logic/ProductionOrderCore/KitronTestResults/RadioTest.cs index f6ce352d..a4afc047 100644 --- a/Common/Logic/ProductionOrderCore/KitronTestResults/RadioTest.cs +++ b/Common/Logic/ProductionOrderCore/KitronTestResults/RadioTest.cs @@ -417,7 +417,158 @@ namespace Xylem.Common.Logic.ProductionOrderCore.KitronTestResults } alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add12, 11); + var add13 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add13.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop13; + add13.LengthCode = newFromat.JsonObject.LengthCodeLoop13; + add13.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + add13.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop13; + add13.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop13; + if (add13.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add13, 12); + + + var add14 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add14.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop14; + add14.LengthCode = newFromat.JsonObject.LengthCodeLoop14; + add14.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + + add14.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop14; + add14.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop14; + if (add14.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add14, 13); + + + var add15 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add15.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop15; + add15.LengthCode = newFromat.JsonObject.LengthCodeLoop15; + add15.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + + add15.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop15; + add15.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop15; + if (add15.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add15, 14); + + + var add16 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add16.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop16; + add16.LengthCode = newFromat.JsonObject.LengthCodeLoop16; + add16.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + + add16.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop16; + add16.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop16; + if (add16.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add16, 15); + + + var add17 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add17.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop17; + add17.LengthCode = newFromat.JsonObject.LengthCodeLoop17; + add17.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + + add17.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop17; + add17.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop17; + if (add17.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add17, 16); + + + var add18 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add18.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop18; + add18.LengthCode = newFromat.JsonObject.LengthCodeLoop18; + add18.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + + add18.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop18; + add18.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop18; + if (add18.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add18, 17); + + + var add19 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add19.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop19; + add19.LengthCode = newFromat.JsonObject.LengthCodeLoop19; + add19.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + + add19.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop19; + add19.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop19; + if (add19.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add19, 18); + + + var add20 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add20.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop20; + add20.LengthCode = newFromat.JsonObject.LengthCodeLoop20; + add20.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + + add20.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop20; + add20.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop20; + if (add20.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add20, 19); + + + var add21 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add21.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop21; + add21.LengthCode = newFromat.JsonObject.LengthCodeLoop21; + add21.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + + add21.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop21; + add21.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop21; + if (add21.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add21, 20); + + + var add22 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add22.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop22; + add22.LengthCode = newFromat.JsonObject.LengthCodeLoop22; + add22.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + + add22.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop22; + add22.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop22; + if (add22.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add22, 21); + + + var add23 = new Xylem.Common.Logic.ProductionOrderCore.KitronTestResults.Value(); + add23.ResultCalibration = newFromat.JsonObject.ResultCalibrationLoop23; + add23.LengthCode = newFromat.JsonObject.LengthCodeLoop23; + add23.SLookupTablePower = newFromat.JsonObject.AttachmentFile.ToLower(); + + add23.IPowerLevelCalculated = newFromat.JsonObject.PowerLevelCalculatedLoop23; + add23.IAntennaMatching = newFromat.JsonObject.AntennaMatchingLoop23; + if (add23.ResultCalibration == null) + { + return alternateReturnObj; + } + alternateReturnObj.TestStepLoopCalibrate.Values.SetValue(add23, 22); return alternateReturnObj; diff --git a/Common/Logic/ProductionOrderCore/OrderData/OrderProgrammingParameters.cs b/Common/Logic/ProductionOrderCore/OrderData/OrderProgrammingParameters.cs index e3ebdf9e..d48f33cf 100644 --- a/Common/Logic/ProductionOrderCore/OrderData/OrderProgrammingParameters.cs +++ b/Common/Logic/ProductionOrderCore/OrderData/OrderProgrammingParameters.cs @@ -54,7 +54,7 @@ namespace Xylem.Common.Logic.ProductionOrderCore.OrderData } - ret.Add(new ProgrammingParameters("SENSUSRADIO_EncryptionKey", radioParams.EncryptionKey.Reverse().ToArray())); + ret.Add(new ProgrammingParameters("SENSUSRADIO_EncryptionKey", radioParams.EncryptionKey.ToArray())); diff --git a/Common/Logic/ProductionOrderCore/OrderData/OrderRadioParameter.cs b/Common/Logic/ProductionOrderCore/OrderData/OrderRadioParameter.cs index 44612f23..dc71d8a6 100644 --- a/Common/Logic/ProductionOrderCore/OrderData/OrderRadioParameter.cs +++ b/Common/Logic/ProductionOrderCore/OrderData/OrderRadioParameter.cs @@ -99,8 +99,8 @@ namespace Xylem.Common.Logic.ProductionOrderCore.OrderData - var a = radioTestResult.TestStepLoopCalibrate.Values.Where(w => w != null && ( w.ResultCalibration.ToLower() == "ok" && w.LengthCode.StartsWith($"DN{dnString}") && w.LengthCode.Contains($"-{LengthString}{pressure}") && !w.LengthCode.Contains($"-{LengthString}{pressure}o"))).ToList(); - var ao = radioTestResult.TestStepLoopCalibrate.Values.Where(w => w != null && (w.ResultCalibration.ToLower() == "ok" && w.LengthCode.StartsWith($"DN{dnString}") && w.LengthCode.Contains($"-{LengthString}{pressure}o"))).ToList(); + var a = radioTestResult.TestStepLoopCalibrate.Values.Where(w => w != null && ( w.LengthCode != null && w.ResultCalibration.ToLower() == "ok" && w.LengthCode.StartsWith($"DN{dnString}") && w.LengthCode.Contains($"-{LengthString}{pressure}") && !w.LengthCode.Contains($"-{LengthString}{pressure}o"))).ToList(); + var ao = radioTestResult.TestStepLoopCalibrate.Values.Where(w => w != null && (w.LengthCode != null && (w.ResultCalibration.ToLower() == "ok" && w.LengthCode.StartsWith($"DN{dnString}") && w.LengthCode.Contains($"-{LengthString}{pressure}o")))).ToList(); var snb = new List(); foreach (var lengthItem in radioTestResult.TestStepLoopCalibrate.Values) diff --git a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessConnect.cs b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessConnect.cs index 1eac880b..9d4a6ebf 100644 --- a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessConnect.cs +++ b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessConnect.cs @@ -75,8 +75,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions } catch (Exception ex) { - - return new List() { }; + return new List() { }; } diff --git a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFinalParameterizationVakoCsd.cs b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFinalParameterizationVakoCsd.cs index 888aa14e..cc069989 100644 --- a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFinalParameterizationVakoCsd.cs +++ b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFinalParameterizationVakoCsd.cs @@ -117,13 +117,22 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions foreach (var item in myJsonResponse.Where(m => m.Source == ProgrammingSource.Vako)) { - overAllResult.Add(_currentGenesis_WriteRegister(item.RegisterName, item.RegisterValue.Reverse().ToArray(), true, true)); + + if (item.RegisterName == "CUSTOMER_LeakFlowThreshold") + { + } + //todo: find a better sln for SENSUSRADIO_EncryptionKey + //SENSUSRADIO_EncryptionKey dont reserve SENSUSRADIO_EncryptionKey! + if (item.RegisterName.ToLower().Contains("SENSUSRADIO_EncryptionKey".ToLower())) + { + overAllResult.Add(_currentGenesis_WriteRegister(item.RegisterName, item.RegisterValue.ToArray(), true, true)); + } + else + { + overAllResult.Add(_currentGenesis_WriteRegister(item.RegisterName, item.RegisterValue.Reverse().ToArray(), true, true)); - //if (item.RegisterName.ToLower().Contains("SENSUSRADIO_EncryptionKey".ToLower())) - //{ - // overAllResult.Add(_currentGenesis_WriteRegister(item.RegisterName, item.RegisterValue.ToArray(), true, true)); - //} + } //else if (!item.RegisterName.ToLower().Contains("apparrangement")) //{ // overAllResult.Add(_currentGenesis_WriteRegister(item.RegisterName, item.RegisterValue.Reverse().ToArray(), true, true)); @@ -137,6 +146,8 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions foreach (var item in myJsonResponse.Where(m => m.Source == ProgrammingSource.Csd)) { + //todo: find a better sln for SENSUSRADIO_EncryptionKey + //SENSUSRADIO_EncryptionKey dont reserve SENSUSRADIO_EncryptionKey! if (item.RegisterName.ToLower().Contains("SENSUSRADIO_EncryptionKey".ToLower())) { overAllResult.Add(_currentGenesis_WriteRegister(item.RegisterName, item.RegisterValue.ToArray(), true, true)); @@ -158,6 +169,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions overAllResult.Add(wirteRegisterInBetweenCheck("SYSTEM_CalendarSeconds", Convert.ToInt32(ts.TotalSeconds))); + overAllResult.Add(wirteRegisterInBetweenCheck("IRDA_MfgDate", Convert.ToInt32(ts.TotalSeconds))); overAllResult.Add(_currentGenesis_WriteRegister("LOGGER_TriggerLogFlush", (new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, false)); @@ -168,7 +180,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_ResetCounter", (new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, false)); - + @@ -191,7 +203,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions } else { - if (cTask.Result.Item1.ToLower().Contains("Metersize".ToLower()) || cTask.Result.Item1.ToLower() == "SENSUSRADIO_MetroRadioLifeTimeCounter".ToLower() || cTask.Result.Item1.ToLower() == "CUSTOMER_LeakFlowThreshold".ToLower() || cTask.Result.Item1.ToLower() == "CUSTOMER_ExcessFlowVolumeThreshold".ToLower()) + if (cTask.Result.Item1.ToLower().Contains("Metersize".ToLower()) || cTask.Result.Item1.ToLower().Contains("CUSTOMER_ExcessFlowVolumeThreshold".ToLower()) || cTask.Result.Item1.ToLower().Contains("NFC_EraseRMA".ToLower()) || cTask.Result.Item1.ToLower() == "SENSUSRADIO_MetroRadioLifeTimeCounter".ToLower() || cTask.Result.Item1.ToLower() == "CUSTOMER_LeakFlowThreshold".ToLower()) { base.NewStatus($"Warnung!Schreiben des Parameter {cTask.Result.Item1} war nicht erfolgreich"); } @@ -205,10 +217,12 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions } } - catch (Exception) + catch (Exception ex) { - - throw; + if (cTask.Result.Item1 != "GENESISFLOW_MaxDeltaToFRange") + { + throw; + } } diff --git a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFullReadOut.cs b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFullReadOut.cs index 8d85d1d1..5ee55acd 100644 --- a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFullReadOut.cs +++ b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFullReadOut.cs @@ -39,7 +39,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions { //clear } - + public override void StartProcess() { try @@ -62,13 +62,21 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send, new Action(() => { - UserControl.lblText.Content = $"Read {dic.GetIdent()}({done}/{total.Count})"; } )); if (dic.RegisterName.ToLower() != "password" && dic.RegisterDetail.Privilege.Lvl8 != Access.Wo) { - Meter.ReadRegister(dic.GetIdent()); + switch (dic.GetIdent().ToLower()) + { + case "sensusradio_encryptionkey": + Meter.ReadRegister(dic.GetIdent(), 32); + break; + default: + Meter.ReadRegister(dic.GetIdent()); + break; + } + } base.Progress = (Int32)Math.Round(((Double)done / (Double)total.Count) * 100, 0); } diff --git a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessRadioCheck.cs b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessRadioCheck.cs index 709987a3..d7b2a8eb 100644 --- a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessRadioCheck.cs +++ b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessRadioCheck.cs @@ -92,7 +92,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions System.Windows.Forms.MessageBox.Show("Funkschlüssel überprüfen!"); } - + EncyptionKey = BitConverter.ToString(enc.ToArray()).Replace("-", ""); //if (freq == 868) //{ diff --git a/Common/Service/MeterProcessState/Controllers/FileUpToDateController.cs b/Common/Service/MeterProcessState/Controllers/FileUpToDateController.cs index 6dbd3e12..b4584208 100644 --- a/Common/Service/MeterProcessState/Controllers/FileUpToDateController.cs +++ b/Common/Service/MeterProcessState/Controllers/FileUpToDateController.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using Logic.ProductionToProductMapper.Cordonel; +using Newtonsoft.Json; using Service.Core; using System; using System.Collections.Generic; @@ -10,10 +11,8 @@ using System.Text; using System.Threading.Tasks; using System.Web; using System.Web.Http; -using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts; using Xylem.Common.Logic.ProductionOrderCore.File; using Xylem.Common.Logic.ProductionOrderCore.FW; -using Logic.ProductionToProductMapper.Cordonel; namespace Xylem.Common.Service.MeterProcessState.Controllers { @@ -154,6 +153,89 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers } + + + + + /// + /// Set LUT JSON content + /// + /// + [Route("PostLutFile"), HttpPost] + public async Task PostLutFile(int DataLength, string version, int crc, int Metersize, string Region) + { + var httpFiles = HttpContext.Current.Request.Files; + var listOfFiles = new List>(); + foreach (var a in httpFiles) + { + try + { + if (HttpContext.Current.Request.Files[a.ToString()] is HttpPostedFile f) + { + + listOfFiles.Add(new Tuple(f.FileName, GetFileBytes(f))); + } + } + catch (Exception) + { + + + } + + + } + + + + var fileID = 0; + + return await Task.Run(() => + { + try + { + int? retId = null; + int FileCounter = StoreFiles(out retId, true, listOfFiles.First().Item1, FileCategoryID: 7, listOfFiles: listOfFiles); + + if (FileCounter == listOfFiles.Count && retId.HasValue) + { + fileID = retId.Value; + } + + if (fileID != 0) + { + using (var dataacces = new SqlDataAccess(GlobalConfig.connectionString.Value)) + { + var sb = new StringBuilder(); + sb.AppendLine($" insert into [Cordonel_Lut] "); + sb.AppendLine($" select "); + sb.AppendLine($" {fileID} "); + sb.AppendLine($" , {DataLength} "); + sb.AppendLine($" , '{version}' "); + sb.AppendLine($" , '{crc}' "); + sb.AppendLine($" , '{Metersize}' "); + sb.AppendLine($" , '{Region}' "); + sb.AppendLine($" , 0 "); // [CurrentVerionForProd] + + sb.AppendLine($" select @@IDENTITY "); + var retDT = dataacces.ExecuteQuery(sb.ToString()); + return Request.CreateResponse(HttpStatusCode.OK, retDT.Rows[0][0]); + } + } + else + { + throw new ApplicationException($"file was not uploaded. Without error"); + } + } + catch (Exception ex) + { + throw new ApplicationException($"file was not uploaded {ex.Message}"); + } + + throw new ApplicationException("file was not uploaded"); + }); + + } + public virtual byte[] GetFileBytes(HttpPostedFile uploadedFile) { var bytes = new byte[uploadedFile.ContentLength]; @@ -162,6 +244,54 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers } + /// + /// Set LUT JSON content + /// + /// + [Route("GetLutFiles"), HttpGet] + public async Task GetLutFiles(int? Metersize = null, string Region = null, bool? ForProd = null) + { + + + return await Task.Run(() => + { + try + { + + using (var dataacces = new SqlDataAccess(GlobalConfig.connectionString.Value)) + { + var sb = new StringBuilder(); + + sb.AppendLine($" SELECT [Id] "); + sb.AppendLine($" ,lut.[FileID] "); + sb.AppendLine($" ,[DataLength] "); + sb.AppendLine($" ,[Version] "); + sb.AppendLine($" ,[FileCrc] "); + sb.AppendLine($" ,[MeterSize] "); + sb.AppendLine($" ,[Region] "); + sb.AppendLine($" ,[CurrentVerionForProd] "); + sb.AppendLine($" ,files.[FileName] "); + sb.AppendLine($" ,files.FileContent "); + sb.AppendLine($" FROM [Auftrag].[dbo].[Cordonel_Lut] lut "); + sb.AppendLine($" inner join [Auftrag].[dbo].[FileClusterStore] fileMaster on fileMaster.FileId = lut.[FileID] "); + sb.AppendLine($" inner join [Auftrag].[dbo].[FileMapToCluster] map on fileMaster.FileIsDeleted = 0 and fileMaster.FileId = map.[FileMapToCluster_FileClusterId] "); + sb.AppendLine($" inner join [Auftrag].[dbo].[File] files on files.FileId = map.[FileMapToCluster_FileId] "); + + + var retDT = dataacces.ExecuteQuery(sb.ToString()); + return Request.CreateResponse(HttpStatusCode.OK, retDT); + } + + } + catch (Exception ex) + { + throw new ApplicationException($"file was not uploaded {ex.Message}"); + } + + throw new ApplicationException("file was not uploaded"); + }); + + } /// /// Set TextFile content PostFileJsonContent @@ -184,12 +314,12 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers catch (Exception) { - + } - + } - + return await Task.Run(() => { @@ -213,6 +343,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers //4 Cordonel Update Safe //5 Cordonel Update Sotware //6 Cordonel Release Config + //7 Cordonel Look up table FileClusterStoreId = null; diff --git a/Common/Ui/GenesisToolBox/FrmLutManagement.Designer.cs b/Common/Ui/GenesisToolBox/FrmLutManagement.Designer.cs index 4d6eea94..f2239937 100644 --- a/Common/Ui/GenesisToolBox/FrmLutManagement.Designer.cs +++ b/Common/Ui/GenesisToolBox/FrmLutManagement.Designer.cs @@ -38,27 +38,22 @@ this.tmrProgressUpdate = new System.Windows.Forms.Timer(this.components); this.tbxRegionRadio = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); - this.tbxMeterFw = new System.Windows.Forms.TextBox(); this.tbxMeterMeterSize = new System.Windows.Forms.TextBox(); this.tbxMeterLutCrc = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); - this.lblFwVersion = new System.Windows.Forms.Label(); - this.cbForProd = new System.Windows.Forms.CheckBox(); this.btnOpenLutFile = new System.Windows.Forms.Button(); this.btnStore = new System.Windows.Forms.Button(); this.dgvLuts = new System.Windows.Forms.DataGridView(); - this.FileId = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.FileName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.FW = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.LUTCRC = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.MeterSize = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Region = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ForProd = new System.Windows.Forms.DataGridViewCheckBoxColumn(); - this.Dele = new System.Windows.Forms.DataGridViewButtonColumn(); + this.cordonelMetrologyLutBindingSource = new System.Windows.Forms.BindingSource(this.components); this.btnLoad = new System.Windows.Forms.Button(); + this.tbxVersion = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.tbxDataLengt = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvLuts)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonelMetrologyLutBindingSource)).BeginInit(); this.SuspendLayout(); // // label7 @@ -108,7 +103,7 @@ // // tbxRegionRadio // - this.tbxRegionRadio.Location = new System.Drawing.Point(97, 151); + this.tbxRegionRadio.Location = new System.Drawing.Point(97, 128); this.tbxRegionRadio.Name = "tbxRegionRadio"; this.tbxRegionRadio.ReadOnly = true; this.tbxRegionRadio.Size = new System.Drawing.Size(144, 20); @@ -117,23 +112,15 @@ // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(17, 158); + this.label8.Location = new System.Drawing.Point(17, 135); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(44, 13); this.label8.TabIndex = 53; this.label8.Text = "Region:"; // - // tbxMeterFw - // - this.tbxMeterFw.Location = new System.Drawing.Point(97, 73); - this.tbxMeterFw.Name = "tbxMeterFw"; - this.tbxMeterFw.ReadOnly = true; - this.tbxMeterFw.Size = new System.Drawing.Size(144, 20); - this.tbxMeterFw.TabIndex = 51; - // // tbxMeterMeterSize // - this.tbxMeterMeterSize.Location = new System.Drawing.Point(97, 125); + this.tbxMeterMeterSize.Location = new System.Drawing.Point(97, 102); this.tbxMeterMeterSize.Name = "tbxMeterMeterSize"; this.tbxMeterMeterSize.ReadOnly = true; this.tbxMeterMeterSize.Size = new System.Drawing.Size(144, 20); @@ -141,7 +128,7 @@ // // tbxMeterLutCrc // - this.tbxMeterLutCrc.Location = new System.Drawing.Point(97, 99); + this.tbxMeterLutCrc.Location = new System.Drawing.Point(97, 76); this.tbxMeterLutCrc.Name = "tbxMeterLutCrc"; this.tbxMeterLutCrc.ReadOnly = true; this.tbxMeterLutCrc.Size = new System.Drawing.Size(144, 20); @@ -150,7 +137,7 @@ // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(17, 132); + this.label5.Location = new System.Drawing.Point(17, 109); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(60, 13); this.label5.TabIndex = 48; @@ -159,32 +146,13 @@ // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(17, 106); + this.label6.Location = new System.Drawing.Point(17, 83); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(56, 13); this.label6.TabIndex = 47; this.label6.Text = "LUT CRC:"; this.label6.Click += new System.EventHandler(this.label6_Click); // - // lblFwVersion - // - this.lblFwVersion.AutoSize = true; - this.lblFwVersion.Location = new System.Drawing.Point(17, 80); - this.lblFwVersion.Name = "lblFwVersion"; - this.lblFwVersion.Size = new System.Drawing.Size(27, 13); - this.lblFwVersion.TabIndex = 46; - this.lblFwVersion.Text = "FW:"; - // - // cbForProd - // - this.cbForProd.AutoSize = true; - this.cbForProd.Location = new System.Drawing.Point(97, 203); - this.cbForProd.Name = "cbForProd"; - this.cbForProd.Size = new System.Drawing.Size(95, 17); - this.cbForProd.TabIndex = 55; - this.cbForProd.Text = "For Production"; - this.cbForProd.UseVisualStyleBackColor = true; - // // btnOpenLutFile // this.btnOpenLutFile.Location = new System.Drawing.Point(260, 47); @@ -209,16 +177,9 @@ // this.dgvLuts.AllowUserToAddRows = false; this.dgvLuts.AllowUserToDeleteRows = false; + this.dgvLuts.AutoGenerateColumns = false; this.dgvLuts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dgvLuts.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.FileId, - this.FileName, - this.FW, - this.LUTCRC, - this.MeterSize, - this.Region, - this.ForProd, - this.Dele}); + this.dgvLuts.DataSource = this.cordonelMetrologyLutBindingSource; this.dgvLuts.Location = new System.Drawing.Point(3, 378); this.dgvLuts.Name = "dgvLuts"; this.dgvLuts.ReadOnly = true; @@ -226,54 +187,6 @@ this.dgvLuts.Size = new System.Drawing.Size(775, 149); this.dgvLuts.TabIndex = 58; // - // FileId - // - this.FileId.HeaderText = "FileId"; - this.FileId.Name = "FileId"; - this.FileId.ReadOnly = true; - // - // FileName - // - this.FileName.HeaderText = "FileName"; - this.FileName.Name = "FileName"; - this.FileName.ReadOnly = true; - // - // FW - // - this.FW.HeaderText = "Fw"; - this.FW.Name = "FW"; - this.FW.ReadOnly = true; - // - // LUTCRC - // - this.LUTCRC.HeaderText = "LUT CRC"; - this.LUTCRC.Name = "LUTCRC"; - this.LUTCRC.ReadOnly = true; - // - // MeterSize - // - this.MeterSize.HeaderText = "MeterSize"; - this.MeterSize.Name = "MeterSize"; - this.MeterSize.ReadOnly = true; - // - // Region - // - this.Region.HeaderText = "Region"; - this.Region.Name = "Region"; - this.Region.ReadOnly = true; - // - // ForProd - // - this.ForProd.HeaderText = "ForProd"; - this.ForProd.Name = "ForProd"; - this.ForProd.ReadOnly = true; - // - // Dele - // - this.Dele.HeaderText = "Delete"; - this.Dele.Name = "Dele"; - this.Dele.ReadOnly = true; - // // btnLoad // this.btnLoad.Location = new System.Drawing.Point(12, 344); @@ -282,6 +195,41 @@ this.btnLoad.TabIndex = 59; this.btnLoad.Text = "Load"; this.btnLoad.UseVisualStyleBackColor = true; + this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click); + // + // tbxVersion + // + this.tbxVersion.Location = new System.Drawing.Point(97, 154); + this.tbxVersion.Name = "tbxVersion"; + this.tbxVersion.ReadOnly = true; + this.tbxVersion.Size = new System.Drawing.Size(144, 20); + this.tbxVersion.TabIndex = 61; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(17, 161); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(45, 13); + this.label1.TabIndex = 60; + this.label1.Text = "Version:"; + // + // tbxDataLengt + // + this.tbxDataLengt.Location = new System.Drawing.Point(97, 180); + this.tbxDataLengt.Name = "tbxDataLengt"; + this.tbxDataLengt.ReadOnly = true; + this.tbxDataLengt.Size = new System.Drawing.Size(144, 20); + this.tbxDataLengt.TabIndex = 63; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(17, 187); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(66, 13); + this.label2.TabIndex = 62; + this.label2.Text = "Data Length"; // // FrmLutManagement // @@ -289,21 +237,22 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(784, 561); + this.Controls.Add(this.tbxDataLengt); + this.Controls.Add(this.label2); + this.Controls.Add(this.tbxVersion); + this.Controls.Add(this.label1); this.Controls.Add(this.btnLoad); this.Controls.Add(this.dgvLuts); this.Controls.Add(this.btnStore); this.Controls.Add(this.btnOpenLutFile); - this.Controls.Add(this.cbForProd); this.Controls.Add(this.tbxRegionRadio); this.Controls.Add(this.label8); - this.Controls.Add(this.tbxMeterFw); this.Controls.Add(this.tbxMeterMeterSize); this.Controls.Add(this.tbxLutFilePathName); this.Controls.Add(this.label4); this.Controls.Add(this.tbxMeterLutCrc); this.Controls.Add(this.label5); this.Controls.Add(this.label6); - this.Controls.Add(this.lblFwVersion); this.Controls.Add(this.label7); this.Controls.Add(this.pictureBox1); this.MaximizeBox = false; @@ -314,6 +263,7 @@ this.Text = "Metrology Lookup Table Managment"; ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvLuts)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cordonelMetrologyLutBindingSource)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -330,24 +280,34 @@ private System.Windows.Forms.Timer tmrProgressUpdate; private System.Windows.Forms.TextBox tbxRegionRadio; private System.Windows.Forms.Label label8; - private System.Windows.Forms.TextBox tbxMeterFw; private System.Windows.Forms.TextBox tbxMeterMeterSize; private System.Windows.Forms.TextBox tbxMeterLutCrc; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; - private System.Windows.Forms.Label lblFwVersion; - private System.Windows.Forms.CheckBox cbForProd; private System.Windows.Forms.Button btnOpenLutFile; private System.Windows.Forms.Button btnStore; private System.Windows.Forms.DataGridView dgvLuts; - private System.Windows.Forms.DataGridViewTextBoxColumn FileId; - private System.Windows.Forms.DataGridViewTextBoxColumn FileName; - private System.Windows.Forms.DataGridViewTextBoxColumn FW; - private System.Windows.Forms.DataGridViewTextBoxColumn LUTCRC; - private System.Windows.Forms.DataGridViewTextBoxColumn MeterSize; - private System.Windows.Forms.DataGridViewTextBoxColumn Region; - private System.Windows.Forms.DataGridViewCheckBoxColumn ForProd; - private System.Windows.Forms.DataGridViewButtonColumn Dele; private System.Windows.Forms.Button btnLoad; + private System.Windows.Forms.TextBox tbxVersion; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox tbxDataLengt; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.DataGridViewTextBoxColumn fileIdDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn fileNameDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn meterSizeDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn regionDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn cRCDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewCheckBoxColumn forProductionDataGridViewCheckBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4; + private System.Windows.Forms.DataGridViewTextBoxColumn fileCrcDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn dataLengthDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn versionDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewCheckBoxColumn currentVerionForProdDataGridViewCheckBoxColumn; + private System.Windows.Forms.DataGridViewImageColumn fileContentDataGridViewImageColumn; + private System.Windows.Forms.BindingSource cordonelMetrologyLutBindingSource; } } \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/FrmLutManagement.cs b/Common/Ui/GenesisToolBox/FrmLutManagement.cs index 756d7afc..bfc76ab3 100644 --- a/Common/Ui/GenesisToolBox/FrmLutManagement.cs +++ b/Common/Ui/GenesisToolBox/FrmLutManagement.cs @@ -1,16 +1,18 @@ -using System; +using Logic.ProductionToProductMapper.Cordonel; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; using System.Drawing; using System.Globalization; +using System.IO; using System.Reflection; +using System.Text; using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms; -using Logic.ProductionToProductMapper.Cordonel; -using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile; -using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; -using Xylem.Common.Utils.ProcessExec.EventArguments; - +using Xylem.Common.Logic.ProductionOrderCore.File; +using Xylem.Common.Logic.SoftwareAccessHelper; +using Xylem.Common.Utils.Crc16Ccitt; namespace Xylem.Common.Ui.GenesisToolBox { @@ -20,12 +22,6 @@ namespace Xylem.Common.Ui.GenesisToolBox public partial class FrmLutManagement : Form { #region Variables - private readonly MeterBatch _meterBatch = new MeterBatch(); - private GenesisMeter _currentGenesis; - private const String StrConnecting = "Connecting to PCB"; - private const String StrNotConnected = "NOT CONNECTED"; - private const String StrPartPcbConnected = "PCB ID: "; - private const String StrOverallProcess = "Overall Process"; private MeterLutUpdate _meterLutUpdate; @@ -43,6 +39,35 @@ namespace Xylem.Common.Ui.GenesisToolBox private const String StrLutFileInvalid = "LUT FILE INVALID"; private const String StrLutFileValid = "LUT file loaded"; + private const String StrLutFileId = "GEN_LUT\0"; + private const Int32 IndexLutFileId = 0; + private const Int32 LengthLutFileId = 8; + + // data length, calculated from version field to the end of the data section + private const Int32 IndexDataLength = 8; + private const Int32 LengthDataLength = 4; + + // CCITT-CRC-16 , calculated from version field to the end of the data section + private const Int32 IndexCrc = 12; + private const Int32 LengthCrc = 2; + + // version + private const Int32 IndexVersion = 14; + private const Int32 LengthVersion = 2; + + // meter size as enumeration + private const Int32 IndexMeterSize = 16; + + // header size of file + private const Int32 LutFileHeaderLength = LengthLutFileId + LengthDataLength + LengthCrc + LengthVersion; + + // data size of file + private const Int32 LutFileDataLength = 730; + + // LUT file entire file size + private const Int32 SizeLutFile = LutFileHeaderLength + LutFileDataLength; + + // external update remarks form private readonly FrmHistory _frmHistory = new FrmHistory(); @@ -65,37 +90,163 @@ namespace Xylem.Common.Ui.GenesisToolBox public FrmLutManagement() { InitializeComponent(); + // + // cordonelMetrologyLutBindingSource + // + this.cordonelMetrologyLutBindingSource.DataSource = typeof(CordonelMetrologyLut); + var cultureInfo = new CultureInfo("en-GB"); Thread.CurrentThread.CurrentUICulture = cultureInfo; Thread.CurrentThread.CurrentCulture = cultureInfo; _version = Assembly.GetExecutingAssembly().GetName().Version; } - private void btnOpenLutFile_Click(object sender, EventArgs e) + + string _StrLutRegion; + string _StrLutVersion; + MeterSize _MeterSize; + UInt16 _FileCrc; + UInt16 _Version; + UInt32 _DataLength; + string lutFilePathName; + string lutFileName; + private void btnOpenLutFile_Click(object sender, EventArgs e) { + if (dlgOpenLuFile.ShowDialog() != DialogResult.OK) + { + return; + } + var ErrorMessage = ""; + lutFilePathName = dlgOpenLuFile.FileName; + + + lutFileName = Path.GetFileNameWithoutExtension(lutFilePathName); + var BinData = new List(File.ReadAllBytes(lutFilePathName)); + // check if LUT file contains data + if (BinData == null) + { + ErrorMessage = "File size mismatch!"; + } + btnStore.Enabled = false; + var IsValid = false; + + var IndexLutFileId = 0; + var LengthLutFileId = 8; + var IndexDataLength = 8; + var LengthDataLength = 4; + // extract the identifier and check, if this is a LUT file + var StrLutFileId = Encoding.UTF8.GetString(BinData.ToArray(), IndexLutFileId, IndexDataLength); + _StrLutRegion = lutFileName.Split('_')[3]; + _StrLutVersion = lutFileName.Split('_')[2]; + _MeterSize = (MeterSize)BinData[IndexMeterSize]; + _FileCrc = (UInt16)(BinData[IndexCrc] + (BinData[IndexCrc + 1] << 8)); + _Version = (UInt16)(BinData[IndexVersion] + (BinData[IndexVersion + 1] << 8)); + _DataLength = (UInt32)(BinData[IndexDataLength] + + (BinData[IndexDataLength + 1] << 8) + + (BinData[IndexDataLength + 2] << 16) + + (BinData[IndexDataLength + 3] << 24)); + // calculate CRC and compare this with the file CRC + var entireFile = new List(); + entireFile.AddRange(BinData); + var payload = new List(); + payload.AddRange(entireFile.GetRange(IndexVersion, LutFileDataLength + LengthVersion)); + var calculatedCrc = Crc16Ccitt.CalculateMsb1021(payload.ToArray()); + if (calculatedCrc != _FileCrc) + { + ErrorMessage = "CRC mismatch!"; + + } + + var CalculatedCrc = calculatedCrc; + IsValid = true; + + btnStore.Enabled = IsValid; + tbxLutFilePathName.Text = lutFilePathName; + tbxMeterLutCrc.Text = _FileCrc.ToString("X4"); + tbxMeterMeterSize.Text = _MeterSize.ToString(); + tbxRegionRadio.Text = _StrLutRegion; + tbxVersion.Text = _StrLutVersion; + tbxDataLengt.Text = _DataLength.ToString(); + //lutFilePathName. + ////mettbl_202203101419_v0.04_EMEA_DN50_v1.00_0xC50F + + } + + + /// /// Clear data table and set genesis to not connected /// private void Init() - { + { - } + } - private void label6_Click(object sender, EventArgs e) - { + private void label6_Click(object sender, EventArgs e) + { - } + } - private void button1_Click(object sender, EventArgs e) - { + private void button1_Click(object sender, EventArgs e) + { + + + + var FileList = new Dictionary(); + + + + var fileConfig = new FileInfo(tbxLutFilePathName.Text); + FileList = new Dictionary(); + FileList.Add(fileConfig.Name, fileConfig.FullName); + + + + StringBuilder sbUrl = new StringBuilder(); + // sbUrl.Append("http://10.49.40.25/MeterProcessState/api/FileUpToDate/PostLutFile"); + sbUrl.Append("http://localhost:56011//api/FileUpToDate/PostLutFile"); + // + + + sbUrl.Append($"?DataLength={_DataLength}"); + sbUrl.Append($"&version={_Version}"); + sbUrl.Append($"&crc={_FileCrc}"); + sbUrl.Append($"&Metersize={_MeterSize.GetHashCode()}"); + sbUrl.Append($"&Region={_StrLutRegion}"); + + + + + var result = LocalWebRequest.PostBinaryFileRequestAsync(sbUrl.ToString(), lutFileName, File.ReadAllBytes(lutFilePathName), 2800); } private void label4_Click(object sender, EventArgs e) + { + + } + + private void btnLoad_Click(object sender, EventArgs e) { + StringBuilder sbUrl = new StringBuilder(); + // sbUrl.Append("http://10.49.40.25/MeterProcessState/api/FileUpToDate/GetLutFiles"); + sbUrl.Append("http://localhost:56011/api/FileUpToDate/GetLutFiles"); + //sbUrl.Append($"?DataLength={_DataLength}"); + //sbUrl.Append($"&version={_Version}"); + //sbUrl.Append($"&crc={_FileCrc}"); + //sbUrl.Append($"&Metersize={_MeterSize.GetHashCode()}"); + //sbUrl.Append($"&Region={_StrLutRegion}"); + + var ret = LocalWebRequest.GetRequest(sbUrl.ToString()); + + + + var a = JsonConvert.DeserializeObject>(ret); + dgvLuts.DataSource = a; + } } diff --git a/Common/Ui/GenesisToolBox/FrmLutManagement.resx b/Common/Ui/GenesisToolBox/FrmLutManagement.resx index 74f435b0..69ca6cdd 100644 --- a/Common/Ui/GenesisToolBox/FrmLutManagement.resx +++ b/Common/Ui/GenesisToolBox/FrmLutManagement.resx @@ -126,52 +126,7 @@ 274, 17 - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True + + 572, 17 \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/GenesisToolBox.csproj b/Common/Ui/GenesisToolBox/GenesisToolBox.csproj index 05ee4931..fffe802f 100644 --- a/Common/Ui/GenesisToolBox/GenesisToolBox.csproj +++ b/Common/Ui/GenesisToolBox/GenesisToolBox.csproj @@ -545,8 +545,10 @@ + + @@ -664,6 +666,10 @@ {8a619cd5-6c8d-420c-a132-7946c6f13e6e} ByteArrayStyle + + {91DEF0C0-AA4F-40AE-8F18-CB717FDE7E7F} + Crc16Ccitt + {4b88b0d3-e791-4774-9521-eabeacdc420e} Logging diff --git a/Common/Ui/GenesisToolBox/Properties/DataSources/Logic.ProductionToProductMapper.Cordonel.CordonelMetrologyLut.datasource b/Common/Ui/GenesisToolBox/Properties/DataSources/Logic.ProductionToProductMapper.Cordonel.CordonelMetrologyLut.datasource new file mode 100644 index 00000000..82d17d85 --- /dev/null +++ b/Common/Ui/GenesisToolBox/Properties/DataSources/Logic.ProductionToProductMapper.Cordonel.CordonelMetrologyLut.datasource @@ -0,0 +1,10 @@ + + + + Logic.ProductionToProductMapper.Cordonel.CordonelMetrologyLut, Logic.ProductionToProductMapper, Version=2.2.8.24795, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/Properties/DataSources/Logic.ProductionToProductMapper.Files.Lut.CordonelMetrologyLut.datasource b/Common/Ui/GenesisToolBox/Properties/DataSources/Logic.ProductionToProductMapper.Files.Lut.CordonelMetrologyLut.datasource new file mode 100644 index 00000000..db5858dc --- /dev/null +++ b/Common/Ui/GenesisToolBox/Properties/DataSources/Logic.ProductionToProductMapper.Files.Lut.CordonelMetrologyLut.datasource @@ -0,0 +1,10 @@ + + + + Logic.ProductionToProductMapper.Files.Lut.CordonelMetrologyLut, Logic.ProductionToProductMapper, Version=2.2.8.19216, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Common/Ui/LegacyGenesisControl/ctlBatch.cs b/Common/Ui/LegacyGenesisControl/ctlBatch.cs index 8e5c540b..c75518b3 100644 --- a/Common/Ui/LegacyGenesisControl/ctlBatch.cs +++ b/Common/Ui/LegacyGenesisControl/ctlBatch.cs @@ -632,6 +632,11 @@ namespace XylemCommonUiLegacyGenCtl setBusy(true, $"Füge {serialNumber} hinzu"); Task.Factory.StartNew(() => { + + if (batch.ListOfMeters.Any(f => f.Slot == slot)) + { + batch.RemoveMeter(batch.ListOfMeters.First(f => f.Slot == slot)); + } var meter = new GenesisMeter(); meter.SerialNumber = serialNumber; meter.CurrentActionText = "FlowTest";