48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using OmniPlus.Features.Enums;
|
|
|
|
using System;
|
|
|
|
namespace OmniPlus.Features.DeviceSpecific
|
|
{
|
|
public struct CalibrationResults
|
|
{
|
|
private const byte FAILED = 0x01;
|
|
private const byte COMPLETED = 0x02;
|
|
|
|
private CalibrationResults(byte[] bytes)
|
|
{
|
|
this.Status = Status.UnknownCommand;
|
|
this.Completed = default(bool);
|
|
this.Rotations = default(ushort);
|
|
this.Dauer = default(uint);
|
|
|
|
if (bytes?.Length == 8)
|
|
{
|
|
this.Status = (Status)bytes[0];
|
|
this.Completed = bytes[1] == COMPLETED;
|
|
this.Rotations = BitConverter.ToUInt16(bytes, 2);
|
|
this.Dauer = BitConverter.ToUInt16(bytes, 4);
|
|
}
|
|
}
|
|
|
|
public Status Status { get; }
|
|
|
|
public bool Completed { get; }
|
|
|
|
public ushort Rotations { get; }
|
|
|
|
public uint Dauer { get; }
|
|
|
|
|
|
public static byte[] RequestResults => new byte[]
|
|
{
|
|
FactoryMeterChamberCalibrationTest.BASE,
|
|
FactoryMeterChamberCalibrationTest.SET,
|
|
FactoryMeterChamberCalibrationTest.VIEW,
|
|
};
|
|
|
|
public static implicit operator CalibrationResults(byte[] bytes)
|
|
=> new CalibrationResults(bytes);
|
|
}
|
|
}
|