452 lines
16 KiB
C#
452 lines
16 KiB
C#
namespace Common.Hardware.WaterMeter.eRegister.Models
|
|
{
|
|
using Common.Hardware.Ports;
|
|
using Common.Hardware.WaterMeter.eRegister.Attributes;
|
|
using Common.Hardware.WaterMeter.eRegister.Features;
|
|
using Common.Hardware.WaterMeter.eRegister.Telegrams;
|
|
|
|
using System;
|
|
using System.Xml.Serialization;
|
|
|
|
[XmlRoot(nameof(EregisterProgrammingParameters))]
|
|
public class EregisterProgrammingParameters
|
|
{
|
|
[XmlAttribute("P2000_Shared_Id")]
|
|
public int SharedId { get; set; }
|
|
|
|
public int Slotno { get; set; }
|
|
|
|
public int FertigungsauftragNr { get; set; }
|
|
|
|
public int AuftragNr { get; set; }
|
|
|
|
public int PositionNr { get; set; }
|
|
|
|
public int SerienNr { get; set; }
|
|
|
|
public string KundeneigeneSerienNr { get; set; }
|
|
|
|
public int StatusFertigung { get; set; }
|
|
|
|
public long TempAdresse { get; set; }
|
|
|
|
[CompareProperty]
|
|
public long Adresse { get; set; }
|
|
|
|
public int Frequency { get; set; }
|
|
|
|
public string CSD { get; set; }
|
|
|
|
[CompareProperty]
|
|
public uint MeterId { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte MeterSize { get; set; }
|
|
|
|
[CompareProperty]
|
|
public int VolumePerPulse { get; set; }
|
|
|
|
[CompareProperty]
|
|
public int VolumePerLedPulse { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte OffsetFactor { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte OffsetTime { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte FactoryCalibration { get; set; }
|
|
|
|
public byte TransmissionIntervalInitialization { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte TransmissionIntervalFinal { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte MBusStatus { get; set; }
|
|
|
|
public byte LatWindowsInitialization { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte LATWindowsFinal { get; set; }
|
|
|
|
public byte UnitsOfMessure { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte UnitsOfMessureSEMI { get; set; }
|
|
|
|
public byte DecimalPoint { get; set; }
|
|
|
|
public byte CandIType { get; set; }
|
|
|
|
public bool Ruecklaufsperre { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Alarm_Low_Battery { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Alarm_Leakage { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Alarm_Magnetic_Tamper { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Alarm_Metrology_Unavailable { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Alarm_Backflow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Alarm_Broken_Pipe { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Alarm_Medium_Absent { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Alarm_Specific_Error { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte LeakagePeriod { get; set; }
|
|
|
|
public byte LeakageThreshold { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte BrokenPipePeriod { get; set; }
|
|
|
|
public byte BrokenPipeThreshold { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte History_Error_Limits_Days { get; set; }
|
|
|
|
[CompareProperty]
|
|
public ushort Data_Logging_Period { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Forward_Counter { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Time_Of_Minimum_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Minimum_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Time_Of_Broken_Pipe { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Broken_Pipe_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Current_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Time_Of_Peak_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Peak_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Time_Of_Maximum_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Maximum_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Backward_Volume { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Counter { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool Data_Logging_Alarm_State { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte FDR_Day_Of_Data_Reading { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Forward_Counter { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Time_Of_Minimum_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Minimum_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Time_Of_Broken_Pipe { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Broken_Pipe_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Current_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Time_Of_Peak_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Peak_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Time_Of_Maximum_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Maximum_Flow { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Backward_Volume { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Counter { get; set; }
|
|
|
|
[CompareProperty]
|
|
public bool FDR_Alarm_State { get; set; }
|
|
|
|
public byte PowerLevelHex { get; set; }
|
|
|
|
public byte DisableOTA { get; set; }
|
|
|
|
public byte ActivationByThreshold { get; set; }
|
|
|
|
public ushort OpenMeteringTransmissionIntervalSeconds { get; set; }
|
|
|
|
public float UTC_Offset { get; set; }
|
|
|
|
public byte Wake_Up_Interval { get; set; }
|
|
|
|
public uint DisplayVolume { get; set; }
|
|
|
|
public bool Encrypted { get; set; }
|
|
|
|
public byte LED_On_Minutes { get; set; }
|
|
|
|
public string EncryptionKey { get; set; }
|
|
|
|
public string MinMetrologyFWVersion { get; set; }
|
|
|
|
public string FWVersionsList { get; set; }
|
|
|
|
public byte MaxRebootCount { get; set; }
|
|
|
|
public double MinBatteryRemainingYears { get; set; }
|
|
|
|
public double MinBatteryVoltage { get; set; }
|
|
|
|
[CompareProperty]
|
|
public string CustomerSpecificText { get; set; }
|
|
|
|
public bool Sealed { get; set; }
|
|
|
|
public bool IsEbeling { get; set; }
|
|
|
|
public bool IsFuhzoe { get; set; }
|
|
|
|
public bool SkipChecks { get; set; }
|
|
|
|
public bool Completed { get; set; }
|
|
|
|
public bool IsValid { get; set; } = true;
|
|
|
|
public uint RequestAddress => (uint)(this.TempAdresse % 10_000_000_000);
|
|
|
|
public uint ResponseAddress => (uint)(this.Adresse % 10_000_000_000);
|
|
|
|
internal EregisterFeatures LoadInspectionFinalizationFeatures()
|
|
{
|
|
var features = new EregisterFeatures
|
|
{
|
|
SlotNr = this.Slotno,
|
|
SerialNr = this.SerienNr,
|
|
PoNr = this.FertigungsauftragNr,
|
|
RequestAddress = this.RequestAddress,
|
|
ResponseAddress = this.ResponseAddress,
|
|
Frequency = this.Frequency,
|
|
EncryptionKey = this.EncryptionKey.GetEncryptionKey(),
|
|
};
|
|
|
|
if (this.IsValid)
|
|
{
|
|
if (this.StatusFertigung != 30)
|
|
{
|
|
features.ChangeMeterReading = new ChangeMeterReading(333_333_333);
|
|
|
|
return features;
|
|
}
|
|
|
|
features.Debug = new EregisterDebugFeatures();
|
|
features.ChangeMeterReading = new ChangeMeterReading(this.DisplayVolume);
|
|
features.ChangeRadioId = new ChangeRadioId(this.ResponseAddress);
|
|
features.ChangeMeterId = new ChangeMeterId(this.MeterId);
|
|
features.DeactivateAlarms = new DeactivateAlarms
|
|
{
|
|
Backflow = this.Alarm_Backflow,
|
|
BrokenPipe = this.Alarm_Broken_Pipe,
|
|
Leak = this.Alarm_Leakage,
|
|
LowBattery = this.Alarm_Low_Battery,
|
|
MagneticTamper = this.Alarm_Magnetic_Tamper,
|
|
MediumAbsent = this.Alarm_Medium_Absent,
|
|
MetrologyUnavailable = this.Alarm_Metrology_Unavailable,
|
|
SpecificError = this.Alarm_Specific_Error,
|
|
};
|
|
features.ResetAlarms = new ResetAlarms(0xFF);
|
|
features.SetDateAndTime = new SetDateAndTime
|
|
{
|
|
SecondsSince20000101 = new Epoch20000101
|
|
{
|
|
DateTime = DateTime.UtcNow.AddHours(this.UTC_Offset)
|
|
}
|
|
};
|
|
features.ChangeCustomerText = new ChangeCustomerText
|
|
{
|
|
Text = this.CustomerSpecificText
|
|
};
|
|
features.ParameterizeLeakageDetection = new ParameterizeLeakageDetection
|
|
{
|
|
Value = (byte)(this.LeakagePeriod | (this.LeakageThreshold * (byte)Math.Pow(2, 3)))
|
|
};
|
|
features.ParameterizeBrokenPipeDetection = new ParameterizeBrokenPipeDetection
|
|
{
|
|
Value = (byte)(this.BrokenPipePeriod | (this.BrokenPipeThreshold * (byte)Math.Pow(2, 3)))
|
|
};
|
|
features.SetHistoricalErrorLimit = new SetHistoricalErrorLimit
|
|
{
|
|
Value = this.History_Error_Limits_Days
|
|
};
|
|
features.ChangeDataLoggerSettings = new ChangeDataLoggerSettings
|
|
{
|
|
TimeInterval = this.Data_Logging_Period,
|
|
ForwardCounter = this.Data_Logging_Forward_Counter,
|
|
TimeOfMinimumFlow = this.Data_Logging_Time_Of_Minimum_Flow,
|
|
MinimumFlow = this.Data_Logging_Minimum_Flow,
|
|
TimeOfBrokenPipe = this.Data_Logging_Time_Of_Broken_Pipe,
|
|
BrokenPipeFlow = this.Data_Logging_Broken_Pipe_Flow,
|
|
CurrentFlow = this.Data_Logging_Current_Flow,
|
|
TimeOfPeakFlow = this.Data_Logging_Time_Of_Peak_Flow,
|
|
PeakFlow = this.Data_Logging_Peak_Flow,
|
|
TimeOfMaximumFlow = this.Data_Logging_Time_Of_Maximum_Flow,
|
|
MaximumFlow = this.Data_Logging_Maximum_Flow,
|
|
BackwardVolume = this.Data_Logging_Backward_Volume,
|
|
Counter = this.Data_Logging_Counter,
|
|
AlarmState = this.Data_Logging_Alarm_State,
|
|
};
|
|
features.ChangeFixedDateReadingSettings = new ChangeFixedDateReadingSettings
|
|
{
|
|
DayOfMonth = this.FDR_Day_Of_Data_Reading,
|
|
ForwardCounter = this.FDR_Forward_Counter,
|
|
TimeOfMinimumFlow = this.FDR_Time_Of_Minimum_Flow,
|
|
MinimumFlow = this.FDR_Minimum_Flow,
|
|
TimeOfBrokenPipe = this.FDR_Time_Of_Broken_Pipe,
|
|
BrokenPipeFlow = this.FDR_Broken_Pipe_Flow,
|
|
CurrentFlow = this.FDR_Current_Flow,
|
|
TimeOfPeakFlow = this.FDR_Time_Of_Peak_Flow,
|
|
PeakFlow = this.FDR_Peak_Flow,
|
|
TimeOfMaximumFlow = this.FDR_Time_Of_Maximum_Flow,
|
|
MaximumFlow = this.FDR_Maximum_Flow,
|
|
BackwardVolume = this.FDR_Backward_Volume,
|
|
Counter = this.FDR_Counter,
|
|
AlarmState = this.FDR_Alarm_State,
|
|
};
|
|
features.WirelessMBusMode = new WirelessMBusMode(this.MBusStatus);
|
|
features.SetPowerLevelSensusRF = new SetPowerLevel
|
|
{
|
|
Value = (byte)(this.PowerLevelHex & 127)
|
|
};
|
|
features.SetPowerLevelFlexNet = new SetPowerLevel
|
|
{
|
|
Value = (byte)(this.PowerLevelHex | 128)
|
|
};
|
|
|
|
if (!this.IsEbeling && !this.IsFuhzoe)
|
|
{
|
|
features.Debug.DisableOTAFirmwareUpdate = new DisableOTAFirmwareUpdate
|
|
{
|
|
Mode = (OTAMode)this.DisableOTA
|
|
};
|
|
features.Debug.SetActivationByThreshold = new SetActivationByThreshold
|
|
{
|
|
Rotations = this.ActivationByThreshold
|
|
};
|
|
features.OpenMeteringTransmitionIntervalWMBus = new OpenMeteringTransmitionIntervalWMBus
|
|
{
|
|
Seconds = this.OpenMeteringTransmissionIntervalSeconds
|
|
};
|
|
|
|
features.ChangeWakeUp = new ChangeWakeUp
|
|
{
|
|
Mode = this.Wake_Up_Interval
|
|
};
|
|
}
|
|
|
|
if (!this.IsEbeling)
|
|
{
|
|
features.ChangeTransmissionInterval = new ChangeTransmissionInterval
|
|
{
|
|
Seconds = this.TransmissionIntervalFinal,
|
|
};
|
|
features.ChangeNumberOfLatWindows = new ChangeNumberOfLatWindows
|
|
{
|
|
N = this.LATWindowsFinal
|
|
};
|
|
features.ChangeSensusRFEncryptionKey = new ChangeSensusRFEncryptionKey
|
|
{
|
|
HexKey = this.EncryptionKey
|
|
};
|
|
//features.Debug.ChangeState = new ChangeState
|
|
//{
|
|
// Mode = FactoryState.Shipment
|
|
//};
|
|
}
|
|
}
|
|
|
|
return features;
|
|
}
|
|
|
|
internal EregisterFeatures LoadInspectionInitializationFeatures()
|
|
{
|
|
var features = new EregisterFeatures
|
|
{
|
|
SlotNr = this.Slotno,
|
|
SerialNr = this.SerienNr,
|
|
PoNr = this.FertigungsauftragNr,
|
|
RequestAddress = this.RequestAddress,
|
|
ResponseAddress = this.ResponseAddress,
|
|
Frequency = this.Frequency,
|
|
EncryptionKey = this.EncryptionKey.GetEncryptionKey(),
|
|
};
|
|
|
|
if (this.IsValid)
|
|
{
|
|
features.ChangeWakeUp = new ChangeWakeUp(WakeUpMode.StayAwake);
|
|
features.ChangeTransmissionInterval = new ChangeTransmissionInterval(this.TransmissionIntervalInitialization);
|
|
features.ChangeNumberOfLatWindows = new ChangeNumberOfLatWindows(this.LatWindowsInitialization);
|
|
features.ChangeMeterReading = new ChangeMeterReading(000_000_010);
|
|
features.WirelessMBusMode = new WirelessMBusMode(this.MBusStatus);
|
|
features.SetMetrologyParameters = new SetMetrologyParameters
|
|
{
|
|
UseCandIRules = this.Ruecklaufsperre,
|
|
DecimalPoint = (DecimalPointLocations)this.DecimalPoint,
|
|
FactoryCalibration = this.FactoryCalibration,
|
|
MeterSize = this.MeterSize,
|
|
OffsetFactor = this.OffsetFactor,
|
|
OffsetTime = this.OffsetTime,
|
|
Units = (MessurementUnits)this.UnitsOfMessure,
|
|
Vpp = this.VolumePerPulse,
|
|
VppLED = (uint)this.VolumePerLedPulse
|
|
};
|
|
|
|
features.Debug = new EregisterDebugFeatures
|
|
{
|
|
SetMeterType = new SetMeterType
|
|
{
|
|
Type = (MeterTypes)this.CandIType
|
|
},
|
|
|
|
};
|
|
}
|
|
|
|
return features;
|
|
}
|
|
}
|
|
}
|