This commit is contained in:
GukSang.Jin
2026-05-05 18:19:32 +08:00
parent 6a57776f96
commit 69fb616ab9
3 changed files with 33 additions and 6 deletions

View File

@@ -14,6 +14,7 @@ public sealed class ExperimentDataService : IExperimentDataService
private double? _initialMass; private double? _initialMass;
private double _accumulatedTotalHeatRelease; private double _accumulatedTotalHeatRelease;
private double _accumulatedTotalSmoke; private double _accumulatedTotalSmoke;
private int? _lastAccumulationSeconds;
private bool _isTestRunning; private bool _isTestRunning;
public ExperimentDataService(IRealtimeDataService realtimeDataService) public ExperimentDataService(IRealtimeDataService realtimeDataService)
@@ -90,14 +91,39 @@ public sealed class ExperimentDataService : IExperimentDataService
}; };
} }
if (double.IsFinite(snapshot.HeatReleaseRate)) if (snapshot.TestSeconds < 0)
{ {
_accumulatedTotalHeatRelease += snapshot.HeatReleaseRate; return snapshot with
{
TotalHeatRelease = _accumulatedTotalHeatRelease,
TotalSmoke = _accumulatedTotalSmoke
};
} }
if (double.IsFinite(snapshot.SmokeProduction)) if (!_lastAccumulationSeconds.HasValue)
{ {
_accumulatedTotalSmoke += snapshot.SmokeProduction; _lastAccumulationSeconds = snapshot.TestSeconds;
return snapshot with
{
TotalHeatRelease = _accumulatedTotalHeatRelease,
TotalSmoke = _accumulatedTotalSmoke
};
}
var deltaSeconds = snapshot.TestSeconds - _lastAccumulationSeconds.Value;
if (deltaSeconds > 0)
{
if (double.IsFinite(snapshot.HeatReleaseRate))
{
_accumulatedTotalHeatRelease += snapshot.HeatReleaseRate * deltaSeconds;
}
if (double.IsFinite(snapshot.SmokeProduction))
{
_accumulatedTotalSmoke += snapshot.SmokeProduction * deltaSeconds;
}
_lastAccumulationSeconds = snapshot.TestSeconds;
} }
return snapshot with return snapshot with
@@ -137,5 +163,6 @@ public sealed class ExperimentDataService : IExperimentDataService
_initialMass = null; _initialMass = null;
_accumulatedTotalHeatRelease = 0; _accumulatedTotalHeatRelease = 0;
_accumulatedTotalSmoke = 0; _accumulatedTotalSmoke = 0;
_lastAccumulationSeconds = null;
} }
} }

View File

@@ -16,7 +16,7 @@ public sealed class ModbusRealtimeDataService : IRealtimeDataService
private const ushort HeatReleaseRateRegister = 354; private const ushort HeatReleaseRateRegister = 354;
private const ushort Qa180Register = 366; private const ushort Qa180Register = 366;
private const ushort Qa300Register = 370; private const ushort Qa300Register = 370;
private const ushort SmokeProductionRegister = 390; private const ushort SmokeProductionRegister = 392;
private const ushort IgnitionSecondsRegister = 1014; private const ushort IgnitionSecondsRegister = 1014;
private const ushort TestSecondsRegister = 1015; private const ushort TestSecondsRegister = 1015;
private const ushort FlameDetectedCoil = 3; private const ushort FlameDetectedCoil = 3;

View File

@@ -206,7 +206,7 @@ public sealed class TestPageViewModel : PageViewModel
HeatMetrics[1].SetValue(snapshot.Qa180); HeatMetrics[1].SetValue(snapshot.Qa180);
HeatMetrics[2].SetValue(snapshot.Qa300); HeatMetrics[2].SetValue(snapshot.Qa300);
HeatMetrics[3].SetValue(snapshot.TotalHeatRelease); HeatMetrics[3].SetValue(snapshot.TotalHeatRelease);
HeatMetrics[4].SetValue(snapshot.SmokeProduction); HeatMetrics[4].SetValue(snapshot.TotalSmoke);
HeatMetrics[5].SetValue(snapshot.CurrentMass); HeatMetrics[5].SetValue(snapshot.CurrentMass);
HeatMetrics[6].SetValue(snapshot.MassLoss); HeatMetrics[6].SetValue(snapshot.MassLoss);