572 lines
37 KiB
C#
572 lines
37 KiB
C#
namespace CommonConsole
|
||
{
|
||
using Common.Hardware.SIRT;
|
||
using Common.Hardware.SIRT.Tasks;
|
||
using Common.Hardware.WaterMeter.eRegister.Features;
|
||
|
||
using System;
|
||
using System.Collections.Generic;
|
||
|
||
|
||
// { 4291923131, "6182ACF7E60266965951BBFB160C1707" },
|
||
// { 4291922821, "B9CC9CCD2CDCB285100B44995497071E" },
|
||
// { 4291868627, "4BC9FEBE927ADA57AE9EE699BBBAC4DC" },
|
||
// { 4291134308, "B9CC9CCD2CDCB285100B44995497071E" },
|
||
|
||
public static class Program
|
||
{
|
||
static int frequency = 868;
|
||
static int timeout = 15_000;
|
||
static string defaultEncryptionKey = "E6C88800DEB868C0D6A84880CE982840";
|
||
static Dictionary<uint, string> testAddresses868 = new Dictionary<uint, string>
|
||
{
|
||
{ 4291808024, "4BC9FEBE927ADA57AE9EE699BBBAC4DC" },
|
||
{ 4291759578, "4BC9FEBE927ADA57AE9EE699BBBAC4DC" },
|
||
{ 4291709169, "4BC9FEBE927ADA57AE9EE699BBBAC4DC" },
|
||
{ 4291657730, "B9CC9CCD2CDCB285100B44995497071E" },
|
||
{ 4291535650, "5DD3EF5233B4DAA6836721F2866182DA" },
|
||
{ 4291377834, "E6C88800DEB868C0D6A84880CE982840" },
|
||
{ 4291377829, "E6C88800DEB868C0D6A84880CE982840" },
|
||
{ 4291094212, "B9CC9CCD2CDCB285100B44995497071E" },
|
||
};
|
||
|
||
static void Main_ER()
|
||
{
|
||
var sirt868 = new SIRTBroadcaster("COM7");
|
||
SIRTLogger.Message += Console.WriteLine;
|
||
sirt868.Open();
|
||
|
||
var CSD_38102_BU_Key = "5DD3EF5233B4DAA6836721F2866182DA";
|
||
var task = new WritePamTask
|
||
{
|
||
Timeout = timeout,
|
||
DelPamSemi = true,
|
||
WakeUpCmd = true,
|
||
WakeUpModul = true,
|
||
RequireLAT = true,
|
||
RequireDEBUG = true,
|
||
Frequency = frequency,
|
||
RequestAddress = 4291535650,
|
||
ResponseAddress = 4291535650,
|
||
EncryptionKeyI = CSD_38102_BU_Key.GetEncryptionKey(),
|
||
Data = new OpticalTelegram(1).Append(new ProvidePin(AuthLevel.III))
|
||
};
|
||
|
||
for (var i = 0; i < 3 || task.State == SIRTTaskState.Completed || task.State == SIRTTaskState.Cancelled; i++)
|
||
{
|
||
sirt868.Start(task);
|
||
task.Wait();
|
||
}
|
||
|
||
Console.ReadKey();
|
||
sirt868.Close();
|
||
}
|
||
|
||
static void Main()
|
||
{
|
||
var alarmMask = 0 << 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($"{"ALARMS:",11} {alarmMask,11} - {BitConverter.ToString(alarmBytes).Replace("-", "")}");
|
||
|
||
|
||
|
||
uint content = // (uint)1 << LogContentBits.AlarmStatus // ALWAYS ON
|
||
//| (uint)1 << LogContentBits.BillingCounter // ALWAYS ON
|
||
(uint)0 << LogContentBits.ReverseCounter //
|
||
| (uint)0 << LogContentBits.MaxFlow //
|
||
| (uint)0 << LogContentBits.MaxFlowTime //
|
||
| (uint)0 << LogContentBits.PeakFlow //
|
||
| (uint)0 << LogContentBits.PeakFlowTime //
|
||
| (uint)0 << LogContentBits.AvgFlow //
|
||
| (uint)0 << LogContentBits.BrokenPipe //
|
||
| (uint)0 << LogContentBits.BrokenPipeTime //
|
||
| (uint)0 << LogContentBits.MinFlow //
|
||
| (uint)0 << LogContentBits.MinFlowTime //
|
||
| (uint)0 << LogContentBits.ForwardCounter //
|
||
| (uint)0 << LogContentBits._UTC32 // ALWAYS ON
|
||
//| (uint)0 << LogContentBits._MaskSelector_1_1 //
|
||
//| (uint)0 << LogContentBits._MaskSelector_1_2 //
|
||
| (uint)0 << LogContentBits.MinPress //
|
||
| (uint)0 << LogContentBits.MinPressTime //
|
||
| (uint)0 << LogContentBits.MaxPress //
|
||
| (uint)0 << LogContentBits.MaxPressTime //
|
||
| (uint)0 << LogContentBits.MinTemp //
|
||
| (uint)0 << LogContentBits.MinTempTime //
|
||
| (uint)0 << LogContentBits.MaxTemp //
|
||
| (uint)0 << LogContentBits.MaxTempTime //
|
||
| (uint)0 << LogContentBits.CurrentPress //
|
||
| (uint)0 << LogContentBits.CurrentTemp; //
|
||
//| (uint)1 << LogContentBits.ExtendedAlarm // ALWAYS ON
|
||
//| (uint)1 << LogContentBits._RecordCheckSum; // ALWAYS ON
|
||
|
||
var contentBytes = BitConverter.GetBytes(content);
|
||
Array.Reverse(contentBytes);
|
||
Console.WriteLine($"{"DATALOGGER:",11} {content,11} - {BitConverter.ToString(contentBytes).Replace("-", "")}");
|
||
|
||
uint fdr = // (uint)1 << LogContentBits.AlarmStatus // ALWAYS ON
|
||
//| (uint)1 << LogContentBits.BillingCounter // ALWAYS ON
|
||
(uint)0 << LogContentBits.ReverseCounter //
|
||
| (uint)0 << LogContentBits.MaxFlow //
|
||
| (uint)0 << LogContentBits.MaxFlowTime //
|
||
| (uint)0 << LogContentBits.PeakFlow //
|
||
| (uint)0 << LogContentBits.PeakFlowTime //
|
||
| (uint)0 << LogContentBits.AvgFlow //
|
||
| (uint)0 << LogContentBits.BrokenPipe //
|
||
| (uint)0 << LogContentBits.BrokenPipeTime //
|
||
| (uint)0 << LogContentBits.MinFlow //
|
||
| (uint)0 << LogContentBits.MinFlowTime //
|
||
| (uint)0 << LogContentBits.ForwardCounter //
|
||
| (uint)0 << LogContentBits._UTC32 // ALWAYS ON
|
||
//| (uint)0 << LogContentBits._MaskSelector_1_1 //
|
||
//| (uint)0 << LogContentBits._MaskSelector_1_2 //
|
||
| (uint)0 << LogContentBits.MinPress //
|
||
| (uint)0 << LogContentBits.MinPressTime //
|
||
| (uint)0 << LogContentBits.MaxPress //
|
||
| (uint)0 << LogContentBits.MaxPressTime //
|
||
| (uint)0 << LogContentBits.MinTemp //
|
||
| (uint)0 << LogContentBits.MinTempTime //
|
||
| (uint)0 << LogContentBits.MaxTemp //
|
||
| (uint)0 << LogContentBits.MaxTempTime //
|
||
| (uint)0 << LogContentBits.CurrentPress //
|
||
| (uint)0 << LogContentBits.CurrentTemp; //
|
||
//| (uint)1 << LogContentBits.ExtendedAlarm // ALWAYS ON
|
||
//| (uint)1 << LogContentBits._RecordCheckSum; // ALWAYS ON
|
||
|
||
var fdrBytes = BitConverter.GetBytes(fdr);
|
||
Array.Reverse(fdrBytes);
|
||
Console.WriteLine($"{"FDR:",11} {fdr,11} - {BitConverter.ToString(fdrBytes).Replace("-", "")}");
|
||
|
||
Console.WriteLine();
|
||
|
||
//uint min = 201344787;
|
||
//uint def = 206906379;
|
||
//uint max = 4294967295;
|
||
|
||
//for (byte i = 0; i < LogContentBits.BitMask.Length; i++)
|
||
//{
|
||
// Console.WriteLine($"Min: {(min >> i) % 2} - Def: {(def >> i) % 2} - Max: {(max >> i) % 2} - {LogContentBits.BitMask[i]}");
|
||
//}
|
||
|
||
} // CONTENT: 67110031 - 04-00-04-8F => 0400048F <-> 8F040004 04000C03
|
||
|
||
static void Main123()
|
||
{
|
||
// Console.WriteLine(BitConverter.ToInt32(new byte[] { 0xEC, 0xFF, 0xFF, 0xFF }, 0));
|
||
|
||
// SIRTServer.StartServer(Console.WriteLine, Console.WriteLine, 6, 8);
|
||
// SIRTServer.StartProgramming(433, 412013443, "0E9FACC6A0E1EF1C3B27A49BAC216535");
|
||
// SIRTServer.StartProgramming(433, 412013444, "0E9FACC6A0E1EF1C3B27A49BAC216535");
|
||
// SIRTServer.StartProgramming(433, 412013356, "80D46C00E1BED73FE0DA85D95CA4BEE3");
|
||
// SIRTServer.StartProgramming(433, 412013081, "7B5F2F606155C670BD9891231A598EF3");
|
||
// SIRTServer.StartProgramming(433, 412013082, "A10BB3C32B71894BD8BB17884973E616");
|
||
// SIRTServer.StartProgramming(433, 412013083, "15EEC94741740FB1EA736CF6468A4790");
|
||
// SIRTServer.StartProgramming(433, 412013084, "6E742330A56149E8CF94ABD70576573D");
|
||
// SIRTServer.StartProgramming(433, 412013087, "C4D1DC170D7E219C26FDE76F9B2DC89A");
|
||
// SIRTServer.StartProgramming(433, 412013078, "4E788CF5F57FF977C85F458049D00387");
|
||
// SIRTServer.StartProgramming(868, 402001154, "0E9FACC6A0E1EF1C3B27A49BAC216535");
|
||
// SIRTServer.StartProgramming(433, 412012695, "867DD2A34C382B7D1190DD563E6B52C4");
|
||
// SIRTServer.StartProgramming(433, 412013356, "80D46C00E1BED73FE0DA85D95CA4BEE3");
|
||
}
|
||
|
||
public static void MainRF(params string[] args)
|
||
{
|
||
//var pam03 = new PAM03();
|
||
|
||
//pam03.Run("COM6", "402010030", "E6C88800DEB868C0D6A84880CE982840");
|
||
//pam03.Run("COM6", "402010027", "D9C154DC274966AB71AD5D804A322178");
|
||
|
||
//return pam03.Run("COM7", "412004190", "0E9FACC6A0E1EF1C3B27A49BAC216535");
|
||
// 10402010030 E6C88800DEB868C0D6A84880CE982840
|
||
|
||
//try
|
||
//{
|
||
// return pam03.Run("COM10", "402009768", "3CB64CBCB71F8D0F9F69FF18DF5D24D3");
|
||
//}
|
||
//catch (System.Exception e)
|
||
//{
|
||
// return -1;
|
||
//}
|
||
}
|
||
|
||
class FDRMask
|
||
{
|
||
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_AVG_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_FORWARD_COUNTER = 12; // 0x00002000, //!< ForwardCounter
|
||
// public const byte LOG_FORWARD_COUNTER = 12; // 0x00004000, //!< ForwardCounter
|
||
// public const byte LOG_FORWARD_COUNTER = 12; // 0x00008000, //!< 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
|
||
};
|
||
|
||
class LogContentBits
|
||
{
|
||
public const byte AlarmStatus = 0; // 0x00000001 ;The active alarm information at UTC32
|
||
public const byte BillingCounter = 1; // 0x00000002 ;The billing counter at UTC32
|
||
public const byte ReverseCounter = 2; // 0x00000004 ;The reverse counter at UTC32
|
||
public const byte MaxFlow = 3; // 0x00000008 ;The maximum flow of the current FDR period UTC32n -… UTC32n-1
|
||
public const byte MaxFlowTime = 4; // 0x00000010 ;The Date/Time information when Qmax happened in the FDR period
|
||
public const byte PeakFlow = 5; // 0x00000020 ;The peak flow of the current FDR period
|
||
public const byte PeakFlowTime = 6; // 0x00000040 ;The Date/Time information when Qpeak happened in the FDR period
|
||
public const byte AvgFlow = 7; // 0x00000080 ;The average flow rate in the current FDR period
|
||
public const byte BrokenPipe = 8; // 0x00000100 ;The weak flow in the current FDR period
|
||
public const byte BrokenPipeTime = 9; // 0x00000200 ;The Date/Time information when Qweak happened in the FDR period
|
||
public const byte MinFlow = 10; // 0x00000400 ;The minimum flow in the current FDR period
|
||
public const byte MinFlowTime = 11; // 0x00000800 ;The Date/Time information when Qmin happened in the FDR period
|
||
public const byte ForwardCounter = 12; // 0x00001000 ;The forward counter at UTC32
|
||
public const byte _UTC32 = 13; // 0x00002000 ;Date/Time information when the record was stored.
|
||
public const byte _MaskSelector_1_1 = 14; // 0x00004000 ;Two selector bits to switch the bitmask of the RF-communication between the internal pages
|
||
public const byte _MaskSelector_1_2 = 15; // 0x00008000 ;Two selector bits to switch the bitmask of the RF-communication between the internal pages
|
||
public const byte MinPress = 16; // 0x00010000 ;The minimum pressure in the current LOG period
|
||
public const byte MinPressTime = 17; // 0x00020000 ;The number of 1-second intervals when Pmin happened in the LOG period
|
||
public const byte MaxPress = 18; // 0x00040000 ;The maximum pressure in the current LOG period
|
||
public const byte MaxPressTime = 19; // 0x00080000 ;The number of 1-second intervals when Pmax happened in the LOG period
|
||
public const byte MinTemp = 20; // 0x00100000 ;The minimum temperature in the current LOG period
|
||
public const byte MinTempTime = 21; // 0x00200000 ;The number of 1-second intervals when Tmin happened in the LOG period
|
||
public const byte MaxTemp = 22; // 0x00400000 ;The maximum temperature in the current LOG period
|
||
public const byte MaxTempTime = 23; // 0x00800000 ;The number of 1-second intervals when Tmax happened in the LOG period
|
||
public const byte CurrentPress = 24; // 0x01000000 ;The last measured instantaneous pressure at RTC32
|
||
public const byte CurrentTemp = 25; // 0x02000000 ;The last measured instantaneous temperature at RTC32
|
||
public const byte ExtendedAlarm = 26; // 0x04000000 ;Similar to the AlarmStatus; P and T related Alarms.
|
||
public const byte _RecordCheckSum = 27; // 0x08000000 ;A Checksum across the entire record
|
||
public const byte _Reserved_1 = 28; // 0x10000000 ;A reserved mask for a further item
|
||
public const byte _Reserved_2 = 29; // 0x20000000 ;A reserved mask for a further item
|
||
public const byte _MaskSelector_2_1 = 30; // 0x40000000 ;The mirror of the MaskSelector_1
|
||
public const byte _MaskSelector_2_2 = 31; // 0x80000000 ;The mirror of the MaskSelector_2
|
||
|
||
public static string[] BitMask = new string[]
|
||
{
|
||
"AlarmStatus",
|
||
"BillingCounter",
|
||
"ReverseCounter",
|
||
"MaxFlow",
|
||
"MaxFlowTime",
|
||
"PeakFlow",
|
||
"PeakFlowTime",
|
||
"AvgFlow",
|
||
"BrokenPipe",
|
||
"BrokenPipeTime",
|
||
"MinFlow",
|
||
"MinFlowTime",
|
||
"ForwardCounter",
|
||
"_UTC32",
|
||
"_MaskSelector_1_1",
|
||
"_MaskSelector_1_2",
|
||
"MinPress",
|
||
"MinPressTime",
|
||
"MaxPress",
|
||
"MaxPressTime",
|
||
"MinTemp",
|
||
"MinTempTime",
|
||
"MaxTemp",
|
||
"MaxTempTime",
|
||
"CurrentPress",
|
||
"CurrentTemp",
|
||
"ExtendedAlarm",
|
||
"_RecordCheckSum",
|
||
"_Reserved_1",
|
||
"_Reserved_2",
|
||
"_MaskSelector_2_1",
|
||
"_MaskSelector_2_2",
|
||
};
|
||
}
|
||
|
||
[Flags]
|
||
enum LogContentHex : uint
|
||
{
|
||
AlarmStatus = 0x00000001, // ;The active alarm information at UTC32
|
||
BillingCounter = 0x00000002, // ;The billing counter at UTC32
|
||
ReverseCounter = 0x00000004, // ;The reverse counter at UTC32
|
||
MaxFlow = 0x00000008, // ;The maximum flow of the current FDR period UTC32n -… UTC32n-1
|
||
MaxFlowTime = 0x00000010, // ;The Date/Time information when Qmax happened in the FDR period
|
||
PeakFlow = 0x00000020, // ;The peak flow of the current FDR period
|
||
PeakFlowTime = 0x00000040, // ;The Date/Time information when Qpeak happened in the FDR period
|
||
AvgFlow = 0x00000080, // ;The average flow rate in the current FDR period
|
||
BrokenPipe = 0x00000100, // ;The weak flow in the current FDR period
|
||
BrokenPipeTime = 0x00000200, // ;The Date/Time information when Qweak happened in the FDR period
|
||
MinFlow = 0x00000400, // ;The minimum flow in the current FDR period
|
||
MinFlowTime = 0x00000800, // ;The Date/Time information when Qmin happened in the FDR period
|
||
ForwardCounter = 0x00001000, // ;The forward counter at UTC32
|
||
_UTC32 = 0x00002000, // ;Date/Time information when the record was stored.
|
||
_MaskSelector_1_1 = 0x00004000, // ;Two selector bits to switch the bitmask of the RF-communication between the internal pages
|
||
_MaskSelector_1_2 = 0x00008000, // ;
|
||
MinPress = 0x00010000, // ;The minimum pressure in the current LOG period
|
||
MinPressTime = 0x00020000, // ;The number of 1-second intervals when Pmin happened in the LOG period
|
||
MaxPress = 0x00040000, // ;The maximum pressure in the current LOG period
|
||
MaxPressTime = 0x00080000, // ;The number of 1-second intervals when Pmax happened in the LOG period
|
||
MinTemp = 0x00100000, // ;The minimum temperature in the current LOG period
|
||
MinTempTime = 0x00200000, // ;The number of 1-second intervals when Tmin happened in the LOG period
|
||
MaxTemp = 0x00400000, // ;The maximum temperature in the current LOG period
|
||
MaxTempTime = 0x00800000, // ;The number of 1-second intervals when Tmax happened in the LOG period
|
||
CurrentPress = 0x01000000, // ;The last measured instantaneous pressure at RTC32
|
||
CurrentTemp = 0x02000000, // ;The last measured instantaneous temperature at RTC32
|
||
ExtendedAlarm = 0x04000000, // ;"Similar to the AlarmStatus; P and T related Alarms. "
|
||
_RecordCheckSum = 0x08000000, // ;A Checksum across the entire FDR record
|
||
_Reserved_1 = 0x10000000, // ;A reserved mask for a further item
|
||
_Reserved_2 = 0x20000000, // ;A reserved mask for a further item
|
||
_MaskSelector_2_1 = 0x40000000, // ;The mirror of the MaskSelector_1
|
||
_MaskSelector_2_2 = 0x80000000, // ;The mirror of the MaskSelector_2
|
||
}
|
||
|
||
class AlarmMask
|
||
{
|
||
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;
|
||
}; // ' CSD ', IIF(i.CSD_Wert IS NULL, i.CSD_Charcode, 'mit neue konfiguration')
|
||
|
||
public static void Main1()
|
||
{
|
||
Console.WriteLine(BitConverter.ToInt32(new byte[] { 0xE9, 0xFF, 0xFF, 0xFF }, 0));
|
||
Console.WriteLine(BitConverter.ToInt32(new byte[] { 0xAD, 0xFF, 0xFF, 0xFF }, 0));
|
||
Console.WriteLine(BitConverter.ToInt32(new byte[] { 0xE6, 0xFF, 0xFF, 0xFF }, 0));
|
||
Console.WriteLine(BitConverter.ToInt32(new byte[] { 0x03, 0x00, 0x00, 0x00 }, 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("-", "")}");
|
||
|
||
//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()*/ Main()
|
||
//{
|
||
// 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())
|
||
// {
|
||
// Console.WriteLine($"{item} = {item:X} = {(uint)item}");
|
||
// }
|
||
|
||
// ushort value = 3;
|
||
|
||
// Console.WriteLine($"0: {value >> 0 & 1}");
|
||
// Console.WriteLine($"0: {value >> 1 & 1}");
|
||
// Console.WriteLine($"0: {value >> 2 & 1}");
|
||
|
||
// Console.WriteLine("CSD CSD 772161_MW");
|
||
// Console.WriteLine("=============================================================================");
|
||
|
||
// var alarm = AlarmMask.ALARM_REBOOT
|
||
// | AlarmMask.ALARM_EMPTY_PIPE
|
||
// | AlarmMask.ALARM_LOW_BATTERY
|
||
// | AlarmMask.ALARM_REVERSE_FLOW;
|
||
|
||
// Console.WriteLine($"CUSTOMER_AlarmVisualMask: {BitConverter.ToString(BitConverter.GetBytes((int)alarm))}");
|
||
|
||
|
||
// var dlg = FDRMask.LOG_BILLING_COUNTER
|
||
// | FDRMask.LOG_MIN_FLOW_VAL
|
||
// | FDRMask.LOG_CUR_FLOW_VAL // ... AverageFlow !?
|
||
// | FDRMask.LOG_ALARM_STATE
|
||
// | FDRMask.LOG_EXT_ALARM_STATE;
|
||
|
||
// Console.WriteLine($"PERIODICLOG_DataLogContents: {BitConverter.ToString(BitConverter.GetBytes((int)dlg))}");
|
||
|
||
// var fdr = FDRMask.LOG_BILLING_COUNTER
|
||
// | FDRMask.LOG_MIN_FLOW_VAL
|
||
// | FDRMask.LOG_CUR_FLOW_VAL // ... AverageFlow !?
|
||
// | FDRMask.LOG_ALARM_STATE
|
||
// | FDRMask.LOG_EXT_ALARM_STATE;
|
||
|
||
// Console.WriteLine($"PERIODICLOG_FixedDateReadingContents: {BitConverter.ToString(BitConverter.GetBytes((int)fdr))}");
|
||
//}
|
||
|
||
/// <summary>
|
||
/// CSD 769400 Arqiva Thames Water
|
||
/// </summary>
|
||
public static void Main1231231()
|
||
{
|
||
Console.WriteLine("CSD 769400 Arqiva Thames Water");
|
||
Console.WriteLine("=============================================================================");
|
||
Console.WriteLine("--- DN50 --------------------------------------------------------------------");
|
||
Console.WriteLine($"CUSTOMER_ExcessFlowVolumeThreshold: {BitConverter.ToString(BitConverter.GetBytes((int)(37.5 * 1000) / 256))}");
|
||
|
||
var alarm = 1 << AlarmMask.ALARM_EMPTY_PIPE
|
||
| 1 << AlarmMask.ALARM_SUSPECT_LEAK
|
||
| 1 << AlarmMask.ALARM_LOW_BATTERY
|
||
| 1 << AlarmMask.ALARM_HIGH_TEMPERATURE
|
||
| 1 << AlarmMask.ALARM_LOW_TEMPERATURE
|
||
| 1 << AlarmMask.ALARM_HIGH_PRESSURE
|
||
| 1 << AlarmMask.ALARM_LOW_PRESSURE;
|
||
|
||
Console.WriteLine($"CUSTOMER_AlarmVisualMask: {BitConverter.ToString(BitConverter.GetBytes(alarm))}");
|
||
|
||
|
||
var dlg = 1 <<FDRMask.LOG_BILLING_COUNTER
|
||
| 1 <<FDRMask.LOG_REVERSE_COUNTER
|
||
| 1 <<FDRMask.LOG_MIN_FLOW_TIME
|
||
| 1 <<FDRMask.LOG_MIN_FLOW_VAL
|
||
| 1 <<FDRMask.LOG_AVG_FLOW_VAL
|
||
| 1 <<FDRMask.LOG_PEAK_FLOW_TIME
|
||
| 1 <<FDRMask.LOG_PEAK_FLOW_VAL
|
||
| 1 <<FDRMask.LOG_MAX_FLOW_TIME
|
||
| 1 <<FDRMask.LOG_MAX_FLOW_VAL
|
||
| 1 <<FDRMask.LOG_ALARM_STATE;
|
||
|
||
Console.WriteLine($"PERIODICLOG_DataLogContents: {BitConverter.ToString(BitConverter.GetBytes(dlg))}");
|
||
|
||
var fdr = 1 << FDRMask.LOG_BILLING_COUNTER
|
||
| 1 << FDRMask.LOG_ALARM_STATE;
|
||
|
||
Console.WriteLine($"PERIODICLOG_FixedDateReadingContents: {BitConverter.ToString(BitConverter.GetBytes(fdr))}");
|
||
}
|
||
}
|
||
} |