From 2e293b30c9db4cabac1c6df2177f319bfd20a9a2 Mon Sep 17 00:00:00 2001 From: Stoyan Zlatev Date: Thu, 18 Sep 2025 09:27:15 +0200 Subject: [PATCH] commit on my changes --- Common/CommonConsole/Program.cs | 219 +++++++++++++----- .../Common.Hardware.SIRT/SIRTExtensions.cs | 1 - .../EregisterCheckFinalizationTask.cs | 2 +- .../Models/EregisterProgrammingParameters.cs | 2 +- .../Telegrams/DEBUG.cs | 4 +- Common/LaaPackages | 2 +- Common/Ui/Common.UI/App.config | 2 + Common/Ui/Common.UI/MainWindow.xaml | 2 +- .../ViewModels/SetMetrologyParametersVM.cs | 15 +- LaaProductionWeb/LaaPackages | 2 +- 10 files changed, 182 insertions(+), 69 deletions(-) diff --git a/Common/CommonConsole/Program.cs b/Common/CommonConsole/Program.cs index 68e63744..8c7e648f 100644 --- a/Common/CommonConsole/Program.cs +++ b/Common/CommonConsole/Program.cs @@ -1,12 +1,18 @@ -using Common.Hardware.SIRT; -using System; +using System; using System.Linq; namespace CommonConsole { public static class Program { - public static void Main2(params string[] args) + //static void Main() + //{ + // var epoch20000101 = new DateTime(2000, 01, 01, 00, 00, 00, DateTimeKind.Utc).AddSeconds(50000); + + // Console.WriteLine(BitConverter.ToInt32(new byte[] { 0xF5, 0xFF, 0xFF, 0xFF }, 0)); + //} + + public static void MainRF(params string[] args) { var pam03 = new PAM03(); @@ -26,64 +32,173 @@ namespace CommonConsole //} } - internal enum FDRMask + class FDRMask { - LOG_ALARM_STATE = 1 << 0, // 0x00000001, //!< AlarmState (16 bits) - LOG_BILLING_COUNTER = 1 << 1, // 0x00000002, //!< BillingCounter - LOG_REVERSE_COUNTER = 1 << 2, // 0x00000004, //!< Backward or ReverseCounter - LOG_MAX_FLOW_VAL = 1 << 3, // 0x00000008, //!< Value of MaxFlow - LOG_MAX_FLOW_TIME = 1 << 4, // 0x00000010, //!< Date/Time of MaxFlow - LOG_PEAK_FLOW_VAL = 1 << 5, // 0x00000020, //!< Value of PeakFlow - LOG_PEAK_FLOW_TIME = 1 << 6, // 0x00000040, //!< Date/Time of PeakFlow - LOG_CUR_FLOW_VAL = 1 << 7, // 0x00000080, //!< Current Flow Value (Average of Period) - LOG_BROKEN_PIPE_FLOW_VAL = 1 << 8, // 0x00000100, //!< Value of BrokenPipe - LOG_BROKEN_PIPE_FLOW_TIME = 1 << 9, // 0x00000200, //!< Date/Time of BrokenPipe - LOG_MIN_FLOW_VAL = 1 << 10, // 0x00000400, //!< Value of FlowMin - LOG_MIN_FLOW_TIME = 1 << 11, // 0x00000800, //!< Date/Time of FlowMin - LOG_FORWARD_COUNTER = 1 << 12, // 0x00001000, //!< ForwardCounter - LOG_MIN_PRESS_VAL = 1 << 13, // 0x00010000, //!< Pressure Minimum - LOG_MIN_PRESS_TIME = 1 << 14, // 0x00020000, //!< Pressure Minimum Time - LOG_MAX_PRESS_VAL = 1 << 15, // 0x00040000, //!< Pressure Maximum - LOG_MAX_PRESS_TIME = 1 << 16, // 0x00080000, //!< Pressure Maximum Time - LOG_MIN_TEMP_VAL = 1 << 17, // 0x00100000, //!< Temperature Minimum - LOG_MIN_TEMP_TIME = 1 << 18, // 0x00200000, //!< Temperature Minimum - LOG_MAX_TEMP_VAL = 1 << 19, // 0x00400000, //!< Temperature Maximum - LOG_MAX_TEMP_TIME = 1 << 20, // 0x00800000, //!< Temperature Maximum - LOG_CUR_PRESS_VAL = 1 << 21, // 0x01000000, //!< Pressure Current Value - LOG_CUR_TEMP_VAL = 1 << 22, // 0x02000000, //!< Temperature Current Value - LOG_EXT_ALARM_STATE = 1 << 23, // 0x04000000,    //().OrderBy(x => (uint)x).ToArray()) - { - Console.WriteLine($"{item,23} = {item:X} = {(uint)item,5} = {(alarmEnableMask << ix++) & 1}"); - } + //var dataLogger = 1 << FDRMask.LOG_ALARM_STATE + // | 1 << FDRMask.LOG_BILLING_COUNTER + // | 0 << FDRMask.LOG_REVERSE_COUNTER + // | 0 << FDRMask.LOG_MAX_FLOW_VAL + // | 0 << FDRMask.LOG_MAX_FLOW_TIME + // | 0 << FDRMask.LOG_PEAK_FLOW_VAL + // | 0 << FDRMask.LOG_PEAK_FLOW_TIME + // | 1 << FDRMask.LOG_CUR_FLOW_VAL + // | 0 << FDRMask.LOG_BROKEN_PIPE_FLOW_VAL + // | 0 << FDRMask.LOG_BROKEN_PIPE_FLOW_TIME + // | 1 << FDRMask.LOG_MIN_FLOW_VAL + // | 0 << FDRMask.LOG_MIN_FLOW_TIME + // | 0 << FDRMask.LOG_FORWARD_COUNTER + // | 0 << FDRMask.LOG_MIN_PRESS_VAL + // | 0 << FDRMask.LOG_MIN_PRESS_TIME + // | 0 << FDRMask.LOG_MAX_PRESS_VAL + // | 0 << FDRMask.LOG_MAX_PRESS_TIME + // | 0 << FDRMask.LOG_MIN_TEMP_VAL + // | 0 << FDRMask.LOG_MIN_TEMP_TIME + // | 0 << FDRMask.LOG_MAX_TEMP_VAL + // | 0 << FDRMask.LOG_MAX_TEMP_TIME + // | 0 << FDRMask.LOG_CUR_PRESS_VAL + // | 0 << FDRMask.LOG_CUR_TEMP_VAL + // | 1 << FDRMask.LOG_EXT_ALARM_STATE; + + //var dataLoggerBytes = BitConverter.GetBytes(dataLogger); + //Array.Reverse(dataLoggerBytes); + //Console.WriteLine($"DATA_LOGGER: {dataLogger} - {BitConverter.ToString(dataLoggerBytes).Replace("-", "")}"); + + //var fixDateReading = 1 << FDRMask.LOG_ALARM_STATE + // | 1 << FDRMask.LOG_BILLING_COUNTER + // | 0 << FDRMask.LOG_REVERSE_COUNTER + // | 0 << FDRMask.LOG_MAX_FLOW_VAL + // | 0 << FDRMask.LOG_MAX_FLOW_TIME + // | 0 << FDRMask.LOG_PEAK_FLOW_VAL + // | 0 << FDRMask.LOG_PEAK_FLOW_TIME + // | 1 << FDRMask.LOG_CUR_FLOW_VAL + // | 0 << FDRMask.LOG_BROKEN_PIPE_FLOW_VAL + // | 0 << FDRMask.LOG_BROKEN_PIPE_FLOW_TIME + // | 1 << FDRMask.LOG_MIN_FLOW_VAL + // | 0 << FDRMask.LOG_MIN_FLOW_TIME + // | 0 << FDRMask.LOG_FORWARD_COUNTER + // | 0 << FDRMask.LOG_MIN_PRESS_VAL + // | 0 << FDRMask.LOG_MIN_PRESS_TIME + // | 0 << FDRMask.LOG_MAX_PRESS_VAL + // | 0 << FDRMask.LOG_MAX_PRESS_TIME + // | 0 << FDRMask.LOG_MIN_TEMP_VAL + // | 0 << FDRMask.LOG_MIN_TEMP_TIME + // | 0 << FDRMask.LOG_MAX_TEMP_VAL + // | 0 << FDRMask.LOG_MAX_TEMP_TIME + // | 0 << FDRMask.LOG_CUR_PRESS_VAL + // | 0 << FDRMask.LOG_CUR_TEMP_VAL + // | 1 << FDRMask.LOG_EXT_ALARM_STATE; + + //var fixDateReadingBytes = BitConverter.GetBytes(fixDateReading); + //Array.Reverse(fixDateReadingBytes); + //Console.WriteLine($"FDR_LOGGER: {fixDateReading} - {BitConverter.ToString(fixDateReadingBytes).Replace("-", "")}"); + + var x1 = 0xD29F; + var x2 = 0xD39F; + Console.WriteLine(new string('=', 50)); + Console.WriteLine($"ALARM_REBOOT: [{(int)AlarmMask.ALARM_REBOOT,2}] {(x1 >> AlarmMask.ALARM_REBOOT) % 2} {(x2 >> AlarmMask.ALARM_REBOOT) % 2} "); + Console.WriteLine($"ALARM_LOW_BATTERY: [{(int)AlarmMask.ALARM_LOW_BATTERY,2}] {(x1 >> AlarmMask.ALARM_LOW_BATTERY) % 2} {(x2 >> AlarmMask.ALARM_LOW_BATTERY) % 2} "); + Console.WriteLine($"ALARM_VERY_LOW_BATTERY: [{(int)AlarmMask.ALARM_VERY_LOW_BATTERY,2}] {(x1 >> AlarmMask.ALARM_VERY_LOW_BATTERY) % 2} {(x2 >> AlarmMask.ALARM_VERY_LOW_BATTERY) % 2} "); + Console.WriteLine($"ALARM_CONFIG_ERROR: [{(int)AlarmMask.ALARM_CONFIG_ERROR,2}] {(x1 >> AlarmMask.ALARM_CONFIG_ERROR) % 2} {(x2 >> AlarmMask.ALARM_CONFIG_ERROR) % 2} "); + Console.WriteLine($"ALARM_EMPTY_PIPE: [{(int)AlarmMask.ALARM_EMPTY_PIPE,2}] {(x1 >> AlarmMask.ALARM_EMPTY_PIPE) % 2} {(x2 >> AlarmMask.ALARM_EMPTY_PIPE) % 2} "); + Console.WriteLine($"ALARM_MAGNETIC_TAMPER: [{(int)AlarmMask.ALARM_MAGNETIC_TAMPER,2}] {(x1 >> AlarmMask.ALARM_MAGNETIC_TAMPER) % 2} {(x2 >> AlarmMask.ALARM_MAGNETIC_TAMPER) % 2} "); + Console.WriteLine($"ALARM_REVERSE_FLOW: [{(int)AlarmMask.ALARM_REVERSE_FLOW,2}] {(x1 >> AlarmMask.ALARM_REVERSE_FLOW) % 2} {(x2 >> AlarmMask.ALARM_REVERSE_FLOW) % 2} "); + Console.WriteLine($"ALARM_SUSPECT_LEAK: [{(int)AlarmMask.ALARM_SUSPECT_LEAK,2}] {(x1 >> AlarmMask.ALARM_SUSPECT_LEAK) % 2} {(x2 >> AlarmMask.ALARM_SUSPECT_LEAK) % 2} "); + Console.WriteLine($"ALARM_BROKEN_PIPE: [{(int)AlarmMask.ALARM_BROKEN_PIPE,2}] {(x1 >> AlarmMask.ALARM_BROKEN_PIPE) % 2} {(x2 >> AlarmMask.ALARM_BROKEN_PIPE) % 2} "); + Console.WriteLine($"ALARM_LOW_PRESSURE: [{(int)AlarmMask.ALARM_LOW_PRESSURE,2}] {(x1 >> AlarmMask.ALARM_LOW_PRESSURE) % 2} {(x2 >> AlarmMask.ALARM_LOW_PRESSURE) % 2} "); + Console.WriteLine($"ALARM_HIGH_PRESSURE: [{(int)AlarmMask.ALARM_HIGH_PRESSURE,2}] {(x1 >> AlarmMask.ALARM_HIGH_PRESSURE) % 2} {(x2 >> AlarmMask.ALARM_HIGH_PRESSURE) % 2} "); + Console.WriteLine($"ALARM_LOW_TEMPERATURE: [{(int)AlarmMask.ALARM_LOW_TEMPERATURE,2}] {(x1 >> AlarmMask.ALARM_LOW_TEMPERATURE) % 2} {(x2 >> AlarmMask.ALARM_LOW_TEMPERATURE) % 2} "); + Console.WriteLine($"ALARM_HIGH_TEMPERATURE: [{(int)AlarmMask.ALARM_HIGH_TEMPERATURE,2}] {(x1 >> AlarmMask.ALARM_HIGH_TEMPERATURE) % 2} {(x2 >> AlarmMask.ALARM_HIGH_TEMPERATURE) % 2} "); + Console.WriteLine($"ALARM_RADIO_ERROR: [{(int)AlarmMask.ALARM_RADIO_ERROR,2}] {(x1 >> AlarmMask.ALARM_RADIO_ERROR) % 2} {(x2 >> AlarmMask.ALARM_RADIO_ERROR) % 2} "); + Console.WriteLine($"ALARM_METROLOGY_PARAMS: [{(int)AlarmMask.ALARM_METROLOGY_PARAMS,2}] {(x1 >> AlarmMask.ALARM_METROLOGY_PARAMS) % 2} {(x2 >> AlarmMask.ALARM_METROLOGY_PARAMS) % 2} "); + Console.WriteLine($"ALARM_METROLOGY_MEASURE: [{(int)AlarmMask.ALARM_METROLOGY_MEASURE,2}] {(x1 >> AlarmMask.ALARM_METROLOGY_MEASURE) % 2} {(x2 >> AlarmMask.ALARM_METROLOGY_MEASURE) % 2}"); + Console.WriteLine($"ALARM_MAX: [{(int)AlarmMask.ALARM_MAX,2}] {(x1 >> AlarmMask.ALARM_MAX) % 2} {(x2 >> AlarmMask.ALARM_MAX) % 2} "); + + + Console.WriteLine(int.MaxValue); + Console.WriteLine(uint.MaxValue); + Console.WriteLine(long.MaxValue); + + } + + public static void MainCSD() + { + //var alarmEnableMask = 0xD39F0000; + //var ix = 0; + + //foreach (var item in Enum.GetValues(typeof(AlarmMask)).Cast().OrderBy(x => (uint)x).ToArray()) + //{ + // Console.WriteLine($"{item,23} = {item:X} = {(uint)item,5} = {(alarmEnableMask << ix++) & 1}"); + //} //foreach (var item in Enum.GetValues(typeof(FDRMask)).Cast().OrderBy(x => x).ToArray()) //{ diff --git a/Common/Hardware/Common.Hardware.SIRT/SIRTExtensions.cs b/Common/Hardware/Common.Hardware.SIRT/SIRTExtensions.cs index f0f987af..8229ff9f 100644 --- a/Common/Hardware/Common.Hardware.SIRT/SIRTExtensions.cs +++ b/Common/Hardware/Common.Hardware.SIRT/SIRTExtensions.cs @@ -1,6 +1,5 @@ namespace Common.Hardware.SIRT { - using Common.Hardware.SIRT.Parameters; using Common.Hardware.SIRT.Tasks; using System; diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckFinalizationTask.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckFinalizationTask.cs index 82b8893a..4dacb728 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckFinalizationTask.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckFinalizationTask.cs @@ -109,7 +109,7 @@ VolumePerLedPulse = this.DEBUGMessage.VolumePerLedPulse, VolumePerPulse = (uint)this.DEBUGMessage.VolumePerPulse, OffsetFactor = (byte)this.DEBUGMessage.OffsetFactor, - OffsetTime = this.DEBUGMessage.OffsetTime, + OffsetTime = (byte)this.DEBUGMessage.OffsetTime, FactoryCalibration = (byte)(this.DEBUGMessage.FactoryCalibration * 10), UnitsOfMessureSEMI = (byte)this.SEMIMessage.Units, MeterSize = (byte)this.SEMIMessage.MeterSize, diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs index 603d5cc7..7665c125 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs @@ -250,7 +250,7 @@ public bool IsValid { get; set; } = true; - public bool IsEncrypted { get; set; } + public bool IsEncrypted { get; set; } internal EregisterFeatures LoadInspectionFinalizationFeatures() { diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Telegrams/DEBUG.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Telegrams/DEBUG.cs index 1979ce16..ab98fe15 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Telegrams/DEBUG.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Telegrams/DEBUG.cs @@ -35,7 +35,7 @@ this.VolumePerLedPulse = payload.ToUInt32BE(38); this.VolumePerPulse = payload.ToInt32BE(42); this.OffsetFactor = payload.ToInt32BE(46); - this.OffsetTime = payload[50]; + this.OffsetTime = payload.ToSByteBE(50); this.Crc = 0; if (payload.Length > MIN_LENGTH) @@ -97,6 +97,6 @@ public int OffsetFactor { get; } - public byte OffsetTime { get; } + public sbyte OffsetTime { get; } } } diff --git a/Common/LaaPackages b/Common/LaaPackages index 41c1163d..ffa0abaa 160000 --- a/Common/LaaPackages +++ b/Common/LaaPackages @@ -1 +1 @@ -Subproject commit 41c1163d102dbb63572e60c6ffd501e1765d848c +Subproject commit ffa0abaa0448ba22350982cd3d3560ce1eaab42a diff --git a/Common/Ui/Common.UI/App.config b/Common/Ui/Common.UI/App.config index e767c4cc..1ef9828a 100644 --- a/Common/Ui/Common.UI/App.config +++ b/Common/Ui/Common.UI/App.config @@ -9,6 +9,8 @@ + + diff --git a/Common/Ui/Common.UI/MainWindow.xaml b/Common/Ui/Common.UI/MainWindow.xaml index 050ddd42..d9df9c04 100644 --- a/Common/Ui/Common.UI/MainWindow.xaml +++ b/Common/Ui/Common.UI/MainWindow.xaml @@ -2,6 +2,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ShowsNavigationUI="False" - Source="Pages/EregisterFinalize.xaml" + Source="Pages/SetMetrologyParameters.xaml" Title="PAM 146: Set metrology parameters"> diff --git a/Common/Ui/Common.UI/ViewModels/SetMetrologyParametersVM.cs b/Common/Ui/Common.UI/ViewModels/SetMetrologyParametersVM.cs index fa7ec535..7fa66821 100644 --- a/Common/Ui/Common.UI/ViewModels/SetMetrologyParametersVM.cs +++ b/Common/Ui/Common.UI/ViewModels/SetMetrologyParametersVM.cs @@ -200,15 +200,15 @@ }); } - private int vpp; - public int VPP + private float vpp; + public float VPP { get => this.vpp; set => this.SetValue(x => x.vpp = value); } - private uint vppLED; - public uint VPPLED + private float vppLED; + public float VPPLED { get => this.vppLED; set => this.SetValue(x => x.vppLED = value); @@ -482,9 +482,6 @@ return; } - var _vpp = (this.vpp * 65536) | 0x80_00_00_00; - var __vpp = (int)_vpp; // 625 = -2106523648 - var task = new EregisterTask(this.sirt.Frequency) { DelPamSemi = true, @@ -561,8 +558,8 @@ OffsetTime = this.OffsetTime, Units = Enum.TryParse($"{this.Units}", out var units) ? units : MessurementUnits.Cubic_Meters, UseCandIRules = this.UseCandIRules, - VppLED = this.vppLED * 65536, - Vpp = __vpp, + VppLED = (uint)(this.vppLED * 65536), + Vpp = (int)((uint)(this.vpp * 65536) | 0x80_00_00_00), } .Append(new ProvidePin { diff --git a/LaaProductionWeb/LaaPackages b/LaaProductionWeb/LaaPackages index 3a9b1c5d..ffa0abaa 160000 --- a/LaaProductionWeb/LaaPackages +++ b/LaaProductionWeb/LaaPackages @@ -1 +1 @@ -Subproject commit 3a9b1c5d5ef1f05b68ff2c0f849f79b56bd44945 +Subproject commit ffa0abaa0448ba22350982cd3d3560ce1eaab42a