@ -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())
//{