commit on my changes

This commit is contained in:
Stoyan Zlatev 2025-09-18 09:27:15 +02:00
parent 6a84c594bd
commit 2e293b30c9
10 changed files with 182 additions and 69 deletions

View File

@ -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,    //<! Extended Alarm Status
public const byte LOG_ALARM_STATE = 0; // 0x00000001, //!< AlarmState (16 bits)
public const byte LOG_BILLING_COUNTER = 1; // 0x00000002, //!< BillingCounter
public const byte LOG_REVERSE_COUNTER = 2; // 0x00000004, //!< Backward or ReverseCounter
public const byte LOG_MAX_FLOW_VAL = 3; // 0x00000008, //!< Value of MaxFlow
public const byte LOG_MAX_FLOW_TIME = 4; // 0x00000010, //!< Date/Time of MaxFlow
public const byte LOG_PEAK_FLOW_VAL = 5; // 0x00000020, //!< Value of PeakFlow
public const byte LOG_PEAK_FLOW_TIME = 6; // 0x00000040, //!< Date/Time of PeakFlow
public const byte LOG_CUR_FLOW_VAL = 7; // 0x00000080, //!< Current Flow Value (Average of Period)
public const byte LOG_BROKEN_PIPE_FLOW_VAL = 8; // 0x00000100, //!< Value of BrokenPipe
public const byte LOG_BROKEN_PIPE_FLOW_TIME = 9; // 0x00000200, //!< Date/Time of BrokenPipe
public const byte LOG_MIN_FLOW_VAL = 10; // 0x00000400, //!< Value of FlowMin
public const byte LOG_MIN_FLOW_TIME = 11; // 0x00000800, //!< Date/Time of FlowMin
public const byte LOG_FORWARD_COUNTER = 12; // 0x00001000, //!< ForwardCounter
public const byte LOG_MIN_PRESS_VAL = 13; // 0x00010000, //!< Pressure Minimum
public const byte LOG_MIN_PRESS_TIME = 14; // 0x00020000, //!< Pressure Minimum Time
public const byte LOG_MAX_PRESS_VAL = 15; // 0x00040000, //!< Pressure Maximum
public const byte LOG_MAX_PRESS_TIME = 16; // 0x00080000, //!< Pressure Maximum Time
public const byte LOG_MIN_TEMP_VAL = 17; // 0x00100000, //!< Temperature Minimum
public const byte LOG_MIN_TEMP_TIME = 18; // 0x00200000, //!< Temperature Minimum
public const byte LOG_MAX_TEMP_VAL = 19; // 0x00400000, //!< Temperature Maximum
public const byte LOG_MAX_TEMP_TIME = 20; // 0x00800000, //!< Temperature Maximum
public const byte LOG_CUR_PRESS_VAL = 21; // 0x01000000, //!< Pressure Current Value
public const byte LOG_CUR_TEMP_VAL = 22; // 0x02000000, //!< Temperature Current Value
public const byte LOG_EXT_ALARM_STATE = 23; // 0x04000000,    //<! Extended Alarm Status
};
internal enum AlarmMask
class AlarmMask
{
ALARM_REBOOT = 1 << 0, // immer An
ALARM_LOW_BATTERY = 1 << 1,
ALARM_VERY_LOW_BATTERY = 1 << 2, /* For consistency with st_alarm_bit_t only */
ALARM_CONFIG_ERROR = 1 << 3,
ALARM_EMPTY_PIPE = 1 << 4,
ALARM_MAGNETIC_TAMPER = 1 << 5, /* For consistency with st_alarm_bit_t only */
ALARM_REVERSE_FLOW = 1 << 6,
ALARM_SUSPECT_LEAK = 1 << 7,
ALARM_BROKEN_PIPE = 1 << 8,
ALARM_LOW_PRESSURE = 1 << 9,
ALARM_HIGH_PRESSURE = 1 << 10,
ALARM_LOW_TEMPERATURE = 1 << 11,
ALARM_HIGH_TEMPERATURE = 1 << 12,
ALARM_RADIO_ERROR = 1 << 13,
ALARM_METROLOGY_PARAMS = 1 << 14,
ALARM_METROLOGY_MEASURE = 1 << 15,
ALARM_MAX = 1 << 16
public const byte ALARM_REBOOT = 0; // immer An
public const byte ALARM_LOW_BATTERY = 1;
public const byte ALARM_VERY_LOW_BATTERY = 2; /* For consistency with st_alarm_bit_t only */
public const byte ALARM_CONFIG_ERROR = 3;
public const byte ALARM_EMPTY_PIPE = 4;
public const byte ALARM_MAGNETIC_TAMPER = 5; /* For consistency with st_alarm_bit_t only */
public const byte ALARM_REVERSE_FLOW = 6;
public const byte ALARM_SUSPECT_LEAK = 7;
public const byte ALARM_BROKEN_PIPE = 8;
public const byte ALARM_LOW_PRESSURE = 9;
public const byte ALARM_HIGH_PRESSURE = 10;
public const byte ALARM_LOW_TEMPERATURE = 11;
public const byte ALARM_HIGH_TEMPERATURE = 12;
public const byte ALARM_RADIO_ERROR = 13;
public const byte ALARM_METROLOGY_PARAMS = 14;
public const byte ALARM_METROLOGY_MEASURE = 15;
public const byte ALARM_MAX = 16;
};
public static void Main()
{
var alarmEnableMask = 0xD39F0000;
var ix = 0;
//var alarmMask = 1 << AlarmMask.ALARM_REBOOT
// | 1 << AlarmMask.ALARM_LOW_BATTERY
// | 0 << AlarmMask.ALARM_VERY_LOW_BATTERY
// | 0 << AlarmMask.ALARM_CONFIG_ERROR
// | 1 << AlarmMask.ALARM_EMPTY_PIPE
// | 0 << AlarmMask.ALARM_MAGNETIC_TAMPER
// | 1 << AlarmMask.ALARM_REVERSE_FLOW
// | 1 << AlarmMask.ALARM_SUSPECT_LEAK
// | 1 << AlarmMask.ALARM_BROKEN_PIPE
// | 0 << AlarmMask.ALARM_LOW_PRESSURE
// | 0 << AlarmMask.ALARM_HIGH_PRESSURE
// | 0 << AlarmMask.ALARM_LOW_TEMPERATURE
// | 0 << AlarmMask.ALARM_HIGH_TEMPERATURE
// | 0 << AlarmMask.ALARM_RADIO_ERROR
// | 0 << AlarmMask.ALARM_METROLOGY_PARAMS
// | 0 << AlarmMask.ALARM_METROLOGY_MEASURE
// | 0 << AlarmMask.ALARM_MAX;
//var alarmBytes = BitConverter.GetBytes(alarmMask);
//Array.Reverse(alarmBytes);
//Console.WriteLine($"ALARM_MASK: {alarmMask} - {BitConverter.ToString(alarmBytes).Replace("-", "")}");
foreach (var item in Enum.GetValues(typeof(AlarmMask)).Cast<AlarmMask>().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<AlarmMask>().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<FDRMask>().OrderBy(x => x).ToArray())
//{

View File

@ -1,6 +1,5 @@
namespace Common.Hardware.SIRT
{
using Common.Hardware.SIRT.Parameters;
using Common.Hardware.SIRT.Tasks;
using System;

View File

@ -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,

View File

@ -250,7 +250,7 @@
public bool IsValid { get; set; } = true;
public bool IsEncrypted { get; set; }
public bool IsEncrypted { get; set; }
internal EregisterFeatures LoadInspectionFinalizationFeatures()
{

View File

@ -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; }
}
}

@ -1 +1 @@
Subproject commit 41c1163d102dbb63572e60c6ffd501e1765d848c
Subproject commit ffa0abaa0448ba22350982cd3d3560ce1eaab42a

View File

@ -9,6 +9,8 @@
<add key="EncryptionKeisUrl" value="http://sla12iis01.emea.sensus.net/LaaProductionWeb/api/eregister/radiokey/byserialno/{0}" />
<add key="SIRTComPorts" value="COM6,COM8" />
<add key="PSNR" value="2015" />
<add key="SIRT_433" value=""/>
<add key="SIRT_868" value=""/>
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

View File

@ -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">
</NavigationWindow>

View File

@ -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<MessurementUnits>($"{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
{

@ -1 +1 @@
Subproject commit 3a9b1c5d5ef1f05b68ff2c0f849f79b56bd44945
Subproject commit ffa0abaa0448ba22350982cd3d3560ce1eaab42a