Refactor iPerl communication system: - Consolidate redundant OptoHead methods. - Introduce new utilities for diagnostic LED state handling and volume unit conversions. - Improve FIFO logic in flow direction detection with enhanced regression calculation. - Add enhanced debugging and logging within communication layers (`SerialDriver` and `RadioService`). - Update communication protocols for improved response handling and configuration management. - Replace raw volume with meaningful unit-based values (`RawVolume1to4`).
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.diagnosticLed.parserer;
|
|
using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead;
|
|
|
|
namespace TBF.Rig.TestMethods.iPerlCommunication.communication.C4.diagnosticLed.utils
|
|
{
|
|
public class DiagnostigLedDataByUnit
|
|
{
|
|
private readonly Common.Unit _unitFlow;
|
|
private readonly Common.Unit _unitVolume;
|
|
private readonly DiagnosticLedState4Data _data;
|
|
|
|
public DiagnostigLedDataByUnit(Common.Unit unitFlow, Common.Unit unitVolume, DiagnosticLedState4Data data)
|
|
{
|
|
this._unitFlow = unitFlow;
|
|
this._unitVolume = unitVolume;
|
|
this._data = data;
|
|
}
|
|
|
|
public Common.Unit Unit => _unitVolume;
|
|
public DiagnosticLedState4Data Data => _data;
|
|
|
|
public double RawFlow {
|
|
get { return UnitVolume(_unitFlow, _data.RawFlow); }
|
|
}
|
|
|
|
public double RawVolume
|
|
{
|
|
get { return Common.Units.ConvertFrom(_unitVolume, _data.RawVolume); }
|
|
}
|
|
|
|
public double AsicTimestamp
|
|
{
|
|
get { return _data.AsicTimestamp; }
|
|
}
|
|
|
|
public static double UnitVolume(Common.Unit unit, double volume)
|
|
{
|
|
return Common.Units.ConvertFrom(unit, volume); /// 1 liter
|
|
}
|
|
|
|
public static uint DeltaTicks(uint oldTicks, uint newTicks)
|
|
{
|
|
return newTicks >= oldTicks
|
|
? newTicks - oldTicks
|
|
: uint.MaxValue - oldTicks + newTicks + 1;
|
|
}
|
|
|
|
}
|
|
} |