411 lines
14 KiB
C#
411 lines
14 KiB
C#
namespace Common.Hardware.WaterMeter.eRegister.Models
|
|
{
|
|
using Common.Hardware.SIRT;
|
|
using Common.Hardware.WaterMeter.eRegister.Attributes;
|
|
using Common.Hardware.WaterMeter.eRegister.Features;
|
|
|
|
using System;
|
|
using System.Xml.Serialization;
|
|
|
|
[XmlRoot(nameof(EregisterProgrammingParameters))]
|
|
public class EregisterProgrammingParameters
|
|
{
|
|
public int SharedId { get; set; }
|
|
|
|
public int SlotNr { 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; }
|
|
|
|
private long tempAdresse;
|
|
public long TempAdresse
|
|
{
|
|
get => this.tempAdresse;
|
|
set => this.tempAdresse = value % 10_000_000_000L;
|
|
}
|
|
|
|
private long adresse;
|
|
[CompareProperty]
|
|
public long Adresse
|
|
{
|
|
get => this.adresse;
|
|
set => this.adresse = value % 10_000_000_000L;
|
|
}
|
|
|
|
public string CSD { get; set; }
|
|
|
|
public int Frequency { get; set; }
|
|
|
|
[CompareProperty]
|
|
public uint MeterId { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte MeterSize { get; set; }
|
|
|
|
[CompareProperty]
|
|
public uint VolumePerPulse { get; set; }
|
|
|
|
[CompareProperty]
|
|
public uint VolumePerLedPulse { get; set; }
|
|
|
|
public byte UnitsOfMessure { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte UnitsOfMessureSEMI { get; set; }
|
|
|
|
public byte DecimalPoint { get; set; }
|
|
|
|
public bool DisallowReverseVolume { 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; }
|
|
|
|
[CompareProperty]
|
|
public byte Transmission_Intervall { get; set; }
|
|
|
|
[CompareProperty]
|
|
public byte LAT_Interval { get; set; }
|
|
|
|
public float UTC_Offset { get; set; }
|
|
|
|
public byte Wake_Up_Interval { 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 MBusStatus { get; set; }
|
|
|
|
public byte LatWindowsInitialization { get; set; }
|
|
|
|
public byte? PowerLevelHex { get; set; }
|
|
|
|
public byte DisableOTA { get; set; }
|
|
|
|
public byte ActivationByThreshold { get; set; }
|
|
|
|
[CompareProperty]
|
|
public ushort OMS_Interval { get; set; }
|
|
|
|
public uint DisplayVolume { get; set; }
|
|
|
|
public string EncryptionKey { get; set; }
|
|
|
|
public string MinMetrologyFWVersion { get; set; }
|
|
|
|
public string FWVersionsList { get; set; }
|
|
|
|
public double MinBatteryRemainingYears { get; set; }
|
|
|
|
public double MinBatteryVoltage { get; set; }
|
|
|
|
public byte MaxRebootCount { get; set; }
|
|
|
|
public byte LED_ON_Minutes { get; set; }
|
|
|
|
public string CustomerSpecificText { 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 bool IsEncrypted { get; set; }
|
|
|
|
internal EregisterFeatures LoadInspectionFinalizationFeatures()
|
|
{
|
|
var features = new EregisterFeatures
|
|
{
|
|
SlotNr = this.SlotNr,
|
|
SerialNr = this.SerienNr,
|
|
PoNr = this.FertigungsauftragNr,
|
|
RequestAddress = (uint)(this.IsEncrypted ? this.Adresse : this.TempAdresse),
|
|
ResponseAddress = (uint)(this.IsEncrypted ? this.TempAdresse : this.Adresse),
|
|
Frequency = this.Frequency,
|
|
EncryptionKey = this.EncryptionKey.GetEncryptionKey(),
|
|
};
|
|
|
|
//if (this.Completed)
|
|
//{
|
|
// return features;
|
|
//}
|
|
|
|
features.Debug = new EregisterDebugFeatures();
|
|
features.ChangeMeterReading = this.DisplayVolume;
|
|
|
|
if (!this.IsEbeling && !this.IsFuhzoe)
|
|
{
|
|
features.Debug.DisableOTAFirmwareUpdate = this.DisableOTA;
|
|
features.Debug.SetActivationByThreshold = this.ActivationByThreshold;
|
|
}
|
|
|
|
if (this.StatusFertigung != 30)
|
|
{
|
|
features.ChangeMeterReading = 333_333_333;
|
|
features.Debug = new EregisterDebugFeatures
|
|
{
|
|
OpticalTelegram = 0
|
|
};
|
|
|
|
return features;
|
|
}
|
|
|
|
if (!this.IsEbeling)
|
|
{
|
|
features.WirelessMBusMode = this.MBusStatus;
|
|
|
|
if (!string.IsNullOrWhiteSpace(this.EncryptionKey))
|
|
{
|
|
features.ChangeSensusRFEncryptionKey = this.EncryptionKey;
|
|
}
|
|
|
|
features.Debug.ChangeState = FactoryState.Shipment;
|
|
}
|
|
|
|
// features.ChangeWakeUp = (WakeUpMode)this.Wake_Up_Interval;
|
|
// features.ChangeNumberOfLatWindows = this.LAT_Interval;
|
|
// features.ChangeTransmissionInterval = this.Transmission_Intervall;
|
|
features.OpenMeteringTransmitionIntervalWMBus = this.OMS_Interval;
|
|
features.ChangeRadioId = (uint)this.Adresse;
|
|
features.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 = 0xFF;
|
|
features.SetDateAndTime = this.UTC_Offset;
|
|
features.ChangeCustomerText = this.CustomerSpecificText;
|
|
features.ParameterizeLeakageDetection = (byte)(this.LeakagePeriod | (this.LeakageThreshold * (byte)Math.Pow(2, 3)));
|
|
features.ParameterizeBrokenPipeDetection = (byte)(this.BrokenPipePeriod | (this.BrokenPipeThreshold * (byte)Math.Pow(2, 3)));
|
|
features.SetHistoricalErrorLimit = 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,
|
|
};
|
|
|
|
if (this.PowerLevelHex != null)
|
|
{
|
|
features.SetPowerLevelSensusRF = (byte)(this.PowerLevelHex & 127);
|
|
features.SetPowerLevelFlexNet = (byte)(this.PowerLevelHex | 128);
|
|
}
|
|
|
|
return features;
|
|
}
|
|
|
|
internal EregisterFeatures LoadInspectionInitializationFeatures()
|
|
{
|
|
var features = new EregisterFeatures
|
|
{
|
|
SlotNr = this.SlotNr,
|
|
SerialNr = this.SerienNr,
|
|
PoNr = this.FertigungsauftragNr,
|
|
RequestAddress = (uint)(this.IsEncrypted ? this.Adresse : this.TempAdresse),
|
|
ResponseAddress = (uint)(this.IsEncrypted ? this.TempAdresse : this.Adresse),
|
|
Frequency = this.Frequency,
|
|
EncryptionKey = this.EncryptionKey.GetEncryptionKey(),
|
|
/////////////////////////////////////////////////////
|
|
ChangeWakeUp = WakeUpMode.StayAwake,
|
|
ChangeTransmissionInterval = this.TransmissionIntervalInitialization,
|
|
ChangeNumberOfLatWindows = this.LatWindowsInitialization,
|
|
ChangeMeterReading = 111_111_111,
|
|
WirelessMBusMode = this.MBusStatus,
|
|
SetMetrologyParameters = new SetMetrologyParameters
|
|
{
|
|
UseCandIRules = this.DisallowReverseVolume,
|
|
DecimalPoint = (DecimalPointLocations)this.DecimalPoint,
|
|
FactoryCalibration = this.FactoryCalibration,
|
|
MeterSize = this.MeterSize,
|
|
OffsetFactor = this.OffsetFactor,
|
|
OffsetTime = this.OffsetTime,
|
|
Units = (MessurementUnits)this.UnitsOfMessure,
|
|
Vpp = (int)this.VolumePerPulse,
|
|
VppLED = this.VolumePerLedPulse
|
|
},
|
|
Debug = new EregisterDebugFeatures
|
|
{
|
|
OpticalTelegram = this.LED_ON_Minutes
|
|
}
|
|
};
|
|
|
|
return features;
|
|
}
|
|
}
|
|
}
|