Add initial MassMeter implementation

This commit is contained in:
2026-02-19 19:22:02 +01:00
parent b43657a4db
commit ead350eef3
70 changed files with 8013 additions and 4604 deletions
@@ -13,6 +13,8 @@ using TBF.Resources;
using TBF.Rig.GenericDevices;
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
using TBF.UiBridge;
using System.Xml.Serialization;
using TBF.Rig.RegisterReaders.PulsesFromUniCB;
namespace TBF.Rig.TestMethods.StandingStartMassCollection
{
@@ -844,7 +846,8 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
double buoyancy = Formulas.Buoyancy();
double massOfEvaporatedWater = (double)(tMass2 - tMass1) * outPath.Scale.EvaporationRate(TempDivStat.Average);
double volumeCTV = 1000.0 * buoyancy * (massEnd - massStart + massOfEvaporatedWater) / densityOut;
if (debugLevel == Common.DebugMode.Simulate) volumeCTV = test.Volume;
double massCTV = buoyancy * (massEnd - massStart + massOfEvaporatedWater);
if (debugLevel == Common.DebugMode.Simulate) volumeCTV = test.Volume;
double refEnergy = Energy.Sum * volumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l]
@@ -1077,6 +1080,8 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
/// Main results
tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.Flow = 3.6 * volumeCTV / tstRslt.TestTime; /// [m3/h]
tstRslt.MassCTV = massCTV; /// [kg] 1000.0f is because density is in [kg/m3]
tstRslt.MassFlow = 3.6 * massCTV / tstRslt.TestTime; /// [kg/h]
if (cBrd is ControlBoard.Uni.UniCB)
{
@@ -1085,6 +1090,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.Flow, tstRslt.TempDownMean);
tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = (tstRslt.VolumeMaster != 0) ? (tstRslt.ConstMasterRaw * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr;
tstRslt.MassConstMaster = (tstRslt.PulsesMaster != 0) ? (tstRslt.MassCTV / tstRslt.PulsesMaster) : tstRslt.ConstMasterCorr;
}
else
{
@@ -1095,6 +1101,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
tstRslt.ConstMaster = 1;
}
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
tstRslt.MassErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.MassCTV);
tstRslt.FlowMean = (float)RefFlowStat.Average;
tstRslt.FlowStart = (float)RefFlowStat.First;
@@ -1244,18 +1251,72 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
if (meterRslt != null && regReader != null)
{
meterRslt.RegReaderType = (int)regReader.RegisterReaderType;
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
ComponentProcedure procParamsEntity = test.Procedure.GetProcedureParamsEntity(regReader.Name);
try
{
if (regReader.RegisterReaderType == RegisterReaderType.Pulses || regReader.RegisterReaderType == RegisterReaderType.Manual)
{
XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RRProcParams) })[0];
RRProcParams tmp = Serializer.Deserialize(new StringReader(procParamsEntity.Parameters.ToString())) as RRProcParams;
regReader.PulsesPerLtr = tmp.PulsesPerLtr;
regReader.QuantityUnits = tmp.Units;
}
else
{
//MessageBox.Show("Cannot create or initialize a printer", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
catch (Exception ex)
{
/*log.DebugFormat(
"Error during Procedure parameters deserialization. CmpntName='{0}', Procedure='{1}', Parameters='{2}', Exception: {3}",
dbEntity?.CmpntName,
dbEntity?.Procedure,
dbEntity?.Parameters,
ex
);*/
}
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;//...MF 11.12.2025 toto chybalo, v .csv bol stlpec naplneny nulami
meterRslt.QuantityUnits = regReader.QuantityUnits;
meterRslt.VolumeStart = regReader.BeginWMState;
meterRslt.VolumeEnd = regReader.EndWMState;
meterRslt.VolumeMeter = Math.Abs(meterRslt.VolumeEnd - meterRslt.VolumeStart);
meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter
meterRslt.MassMeter = Math.Abs(meterRslt.VolumeEnd - meterRslt.VolumeStart);
meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter
meterRslt.MassRef = tstRslt.MassCTV; /// kg
meterRslt.PulsesMeter = meterRslt.VolumeMeter;
meterRslt.PulsesMaster = tstRslt.PulsesMaster;
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
meterRslt.Passed = (meterRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty)
//meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
double Error = 0;
if (meterRslt.GetQuantityFromUnits() == "Mass")
Error = Formulas.ErrorFromVolumes(meterRslt.MassMeter, meterRslt.MassRef);
else
Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
meterRslt.Error = Error;
/*meterRslt.Passed = (meterRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty)
&& (meterRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty)
&& (tstRslt.ErrorFlags == 0);
&& (tstRslt.ErrorFlags == 0);*/
var ErrLimLo_Volume = test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime);
var ErrLimHi_Volume = test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime);
var ErrLimLo_Mass = test.GetErrLimLo(tstRslt.MassCTV, tstRslt.TestTime);
var ErrLimHi_Mass = test.GetErrLimHi(tstRslt.MassCTV, tstRslt.TestTime);
bool Passed;
if (meterRslt.GetQuantityFromUnits() == "Mass")
Passed = (meterRslt.Error >= ErrLimLo_Volume + test.Uncertainty) &&
(meterRslt.Error <= ErrLimHi_Volume - test.Uncertainty) &&
(tstRslt.ErrorFlags == 0);
else
Passed = (meterRslt.Error >= ErrLimLo_Mass + test.Uncertainty) &&
(meterRslt.Error <= ErrLimHi_Mass - test.Uncertainty) &&
(tstRslt.ErrorFlags == 0);
meterRslt.Passed = Passed;
meterRslt.TestDone = true;
tstRslt.TestDone = true;
if (regReader is ICommonRegReader regReaderCommon)