This commit is contained in:
GukSang.Jin
2026-05-27 18:46:19 +08:00
parent 0139c4475b
commit 73023e2b44
2 changed files with 12 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ namespace ConeCalorimeter.Services;
public sealed class ExperimentDataService : IExperimentDataService public sealed class ExperimentDataService : IExperimentDataService
{ {
private const int MaximumRows = 1200; private const int MaximumRows = 1200;
private const double TotalHeatReleaseDivisor = 1000;
private readonly IRealtimeDataService _realtimeDataService; private readonly IRealtimeDataService _realtimeDataService;
private readonly DispatcherTimer _timer; private readonly DispatcherTimer _timer;
@@ -167,7 +168,7 @@ public sealed class ExperimentDataService : IExperimentDataService
{ {
if (double.IsFinite(snapshot.HeatReleaseRate)) if (double.IsFinite(snapshot.HeatReleaseRate))
{ {
_accumulatedTotalHeatRelease += snapshot.HeatReleaseRate * deltaSeconds / 1000; _accumulatedTotalHeatRelease += snapshot.HeatReleaseRate * deltaSeconds / TotalHeatReleaseDivisor;
} }
if (double.IsFinite(snapshot.SmokeProduction)) if (double.IsFinite(snapshot.SmokeProduction))

View File

@@ -8,6 +8,7 @@ public sealed class ModbusRealtimeDataService : IRealtimeDataService
private const int ScaleCurrentMassStabilityKey = -1; private const int ScaleCurrentMassStabilityKey = -1;
private const double RealtimeZeroTolerance = 0.005; private const double RealtimeZeroTolerance = 0.005;
private const int ZeroValueStableReadCount = 2; private const int ZeroValueStableReadCount = 2;
private const double HeatReleaseRateDisplayScale = 1000;
private const ushort OxygenRegister = 10; private const ushort OxygenRegister = 10;
private const ushort OrificeFlowRegister = 14; private const ushort OrificeFlowRegister = 14;
private const ushort OrificePressureRegister = 16; private const ushort OrificePressureRegister = 16;
@@ -76,7 +77,7 @@ public sealed class ModbusRealtimeDataService : IRealtimeDataService
CarbonDioxide: ReadRangedFloatOrEmpty("CO2", CarbonDioxideRegister, 0, 20), CarbonDioxide: ReadRangedFloatOrEmpty("CO2", CarbonDioxideRegister, 0, 20),
CarbonMonoxide: ReadRangedFloatOrEmpty("CO", CarbonMonoxideRegister, 0, 10), CarbonMonoxide: ReadRangedFloatOrEmpty("CO", CarbonMonoxideRegister, 0, 10),
Absorbance: ReadAbsorbanceOrEmpty(), Absorbance: ReadAbsorbanceOrEmpty(),
HeatReleaseRate: ReadRangedFloatOrEmpty("HeatReleaseRate", HeatReleaseRateRegister, 0, 5000), HeatReleaseRate: ReadHeatReleaseRateOrEmpty(),
PeakHeatReleaseRate: ReadRangedFloatOrEmpty("PeakHeatReleaseRate", PeakHeatReleaseRateRegister, 0, 5000), PeakHeatReleaseRate: ReadRangedFloatOrEmpty("PeakHeatReleaseRate", PeakHeatReleaseRateRegister, 0, 5000),
CFactor: ReadRangedFloatOrEmpty("CFactor", CFactorRegister, 0, 1000), CFactor: ReadRangedFloatOrEmpty("CFactor", CFactorRegister, 0, 1000),
Qa180: ReadRangedFloatOrEmpty("Qa180", Qa180Register, 0, 1000), Qa180: ReadRangedFloatOrEmpty("Qa180", Qa180Register, 0, 1000),
@@ -117,6 +118,14 @@ public sealed class ModbusRealtimeDataService : IRealtimeDataService
: double.NaN; : double.NaN;
} }
private double ReadHeatReleaseRateOrEmpty()
{
var value = ReadRangedFloatOrEmpty("HeatReleaseRate", HeatReleaseRateRegister, 0, 5000);
return double.IsFinite(value)
? value * HeatReleaseRateDisplayScale
: double.NaN;
}
private bool TryUpdateStableAbsorbance(double value, out double stableValue) private bool TryUpdateStableAbsorbance(double value, out double stableValue)
{ {
stableValue = _stableAbsorbance ?? value; stableValue = _stableAbsorbance ?? value;