laatzen/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeDataLoggerSettings.cs
2025-01-24 12:10:40 +01:00

112 lines
2.9 KiB
C#

namespace Common.Hardware.WaterMeter.eRegister.Features
{
using Common.Hardware.Ports;
public class ChangeDataLoggerSettings : Pam
{
private readonly byte[] contentBits = new byte[16];
public ChangeDataLoggerSettings() : base(5, ChangeDataLoggerSettings)
{
}
public ushort TimeInterval { get; set; }
public ushort LogContent => this.contentBits.ToUIint16LEFromBits();
public bool ForwardCounter
{
get => this.contentBits[12] == 1;
set => this.contentBits[12] = (byte)(value ? 1 : 0);
}
public bool TimeOfMinimumFlow
{
get => this.contentBits[11] == 1;
set => this.contentBits[11] = (byte)(value ? 1 : 0);
}
public bool MinimumFlow
{
get => this.contentBits[10] == 1;
set => this.contentBits[10] = (byte)(value ? 1 : 0);
}
public bool TimeOfBrokenPipe
{
get => this.contentBits[9] == 1;
set => this.contentBits[9] = (byte)(value ? 1 : 0);
}
public bool BrokenPipeFlow
{
get => this.contentBits[8] == 1;
set => this.contentBits[8] = (byte)(value ? 1 : 0);
}
public bool CurrentFlow
{
get => this.contentBits[7] == 1;
set => this.contentBits[7] = (byte)(value ? 1 : 0);
}
public bool TimeOfPeakFlow
{
get => this.contentBits[6] == 1;
set => this.contentBits[6] = (byte)(value ? 1 : 0);
}
public bool PeakFlow
{
get => this.contentBits[5] == 1;
set => this.contentBits[5] = (byte)(value ? 1 : 0);
}
public bool TimeOfMaximumFlow
{
get => this.contentBits[4] == 1;
set => this.contentBits[4] = (byte)(value ? 1 : 0);
}
public bool MaximumFlow
{
get => this.contentBits[3] == 1;
set => this.contentBits[3] = (byte)(value ? 1 : 0);
}
public bool BackwardVolume
{
get => this.contentBits[2] == 1;
set => this.contentBits[2] = (byte)(value ? 1 : 0);
}
public bool Counter
{
get => this.contentBits[1] == 1;
set => this.contentBits[1] = (byte)(value ? 1 : 0);
}
public bool AlarmState
{
get => this.contentBits[0] == 1;
set => this.contentBits[0] = (byte)(value ? 1 : 0);
}
public void SetLogContent(ushort value)
=> value.GetBitsLE()
.CopyTo(this.contentBits, 0);
public override byte[] ToByteArray()
{
this.TimeInterval
.GetBytesBE()
.CopyTo(this.bytes, 1);
this.LogContent
.GetBytesBE()
.CopyTo(this.bytes, 3);
return base.ToByteArray();
}
}
}