72 lines
3.3 KiB
C#
72 lines
3.3 KiB
C#
using TBF.Rig.RegisterReaders.iPerlASICReader.communication.C4.diagnosticLed.utils;
|
||
|
||
namespace TBF.Rig.RegisterReaders.iPerlASICReader.communication.C4.diagnosticLed.parserer
|
||
{
|
||
/// <summary>
|
||
/// Diagnostic LED State #3 data frame.
|
||
///
|
||
/// <para>
|
||
/// State #3 extends the common diagnostic LED fields with calibration
|
||
/// and timing information related to the field drive and ASIC operation.
|
||
/// </para>
|
||
///
|
||
/// <para>
|
||
/// Frame format: TAB-separated ASCII hexadecimal fields, terminated by CRLF.
|
||
/// The checksum is an 8-bit sum of all previous ASCII bytes including
|
||
/// the TAB character before the checksum field.
|
||
/// </para>
|
||
///
|
||
/// <list type="table">
|
||
/// <listheader>
|
||
/// <term>Pos</term>
|
||
/// <description>Field description</description>
|
||
/// </listheader>
|
||
/// <item><term>0 – xxxxxx</term><description>Signed 24-bit ADC value (two’s complement)</description></item>
|
||
/// <item><term>1 – aaaa</term><description>Unsigned 16-bit field strength (internal units)</description></item>
|
||
/// <item><term>2 – yyyy</term><description>Signed 16-bit raw flow rate (¼ ml per bit)</description></item>
|
||
/// <item><term>3 – vvvvvv</term><description>Unsigned 24-bit raw volume accumulation (¼ ml per bit)</description></item>
|
||
/// <item><term>4 – cccc</term><description>Unsigned 16-bit millivolt delta on the field drive capacitor</description></item>
|
||
/// <item><term>5 – tttt</term><description>Unsigned 16-bit field calibration value</description></item>
|
||
/// <item><term>6 – bbbbbbbb</term><description>Unsigned 32-bit ASIC timestamp (8192 ticks per second,
|
||
/// rolls over at 2^32)</description></item>
|
||
/// <item><term>7 – ff</term><description>Unsigned 8-bit field drive time in microseconds</description></item>
|
||
/// <item><term>8 – ss</term><description>Unsigned 8-bit checksum (sum of all previous ASCII bytes including
|
||
/// the TAB before the checksum field)</description></item>
|
||
/// </list>
|
||
/// </summary>
|
||
public sealed class DiagnosticLedState3Data : DiagnosticLedData
|
||
{
|
||
/// <summary>
|
||
/// Unsigned 16-bit field calibration value.
|
||
/// </summary>
|
||
public ushort FieldCalibration { get; }
|
||
|
||
/// <summary>
|
||
/// ASIC timestamp in units of 1 / 8192 seconds.
|
||
/// Rolls over at 2^32.
|
||
/// </summary>
|
||
public uint AsicTimestamp { get; }
|
||
|
||
/// <summary>
|
||
/// Field drive time in microseconds.
|
||
/// </summary>
|
||
public byte FieldDriveTimeUs { get; }
|
||
|
||
public DiagnosticLedState3Data(string rawLine, string[] fields)
|
||
: base(rawLine)
|
||
{
|
||
// ---- Common fields (0–4) ----
|
||
Adc24 = DiagnosticHex.ParseInt24(fields[0]);
|
||
FieldStrength = DiagnosticHex.ParseUInt16(fields[1]);
|
||
RawFlow = DiagnosticHex.ParseInt16(fields[2]);
|
||
RawVolume = DiagnosticHex.ParseUInt24(fields[3]);
|
||
CapacitorMv = DiagnosticHex.ParseUInt16(fields[4]);
|
||
|
||
// ---- State #3 specific fields ----
|
||
FieldCalibration = DiagnosticHex.ParseUInt16(fields[5]);
|
||
AsicTimestamp = DiagnosticHex.ParseUInt32(fields[6]);
|
||
FieldDriveTimeUs = DiagnosticHex.ParseByte(fields[7]);
|
||
}
|
||
}
|
||
}
|