Volume rollOver Logic upgrade

Update AssemblyVersion to 3.9.2208.2 and refine OptoTelegramRaw volume unwrap logic:

- Simplify and correct `VOL_LITERS_PER_TICK` and `VOL_RANGE` calculations.
- Fix volume unwrap logic in `UpdateFromSmart` for improved accuracy.
This commit is contained in:
Michal Buzik 2026-02-27 14:49:03 +01:00
parent 5a254c9ebd
commit 4abe8509b8
2 changed files with 17 additions and 11 deletions

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.9.2208.1")]
[assembly: AssemblyFileVersion("3.9.2008.1")]
[assembly: AssemblyVersion("3.9.2208.2")]
[assembly: AssemblyFileVersion("3.9.2008.2")]

View File

@ -193,16 +193,15 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.common
// -------- TIMESTAMP (seconds) --------
private const double TS_TICKS_PER_SEC = 8192.0;
private const double TS_RANGE = 4294967296.0 / TS_TICKS_PER_SEC; // 2^32 / 8192 = 524288 sec
// 2^32 ticks converted to seconds => wraps every ~6.07 days
private const double TS_RANGE = 4294967296.0 / TS_TICKS_PER_SEC; // 524288.0
// -------- VOLUME (liters) --------
// vvvvvv is unsigned 24-bit, 1 tick = 1/4 ml = 0.00025 L
private const double VOL_LITERS_PER_TICK = 0.00025; // liters per tick
private const double VOL_RANGE = 16777216.0 * VOL_LITERS_PER_TICK; // 2^24 * 0.00025 = 4194.304 L
// -------- VOLUME (liters) --------
private const double GAL_TO_LITER = 3.785411784;
private const double VOL_LITERS_PER_TICK =
(4.0 / 1000.0) / GAL_TO_LITER / 2.0;
private const double VOL_RANGE = (1 << 24) * VOL_LITERS_PER_TICK;
public void UpdateFromSmart(
DiagnosticLedState4Data data,
@ -236,8 +235,15 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.common
else
{
// nearest-lap unwrap
double k = Math.Round((volumeRawExtLast - v) / VOL_RANGE);
VolumeRawExt = volumeRawExtLast = v + k * VOL_RANGE;
//double k = Math.Round(volumeRawExtLast - v) / VOL_RANGE);
if (v < volumeRawExtLast)
{
VolumeRawExt = volumeRawExtLast = v + VOL_RANGE;
}
else
{
VolumeRawExt = volumeRawExtLast = v;
}
}
// ---------- TIMESTAMP UNWRAP (seconds) ----------