Many changes, new results used, all test sequences modified, simulated tests rewritten.
This commit is contained in:
+193
-224
@@ -30,39 +30,41 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
|
||||
{
|
||||
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
|
||||
|
||||
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
||||
Event retVal = Event.Done;
|
||||
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
|
||||
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
||||
Event retVal = Event.Done;
|
||||
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
|
||||
|
||||
ltrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
|
||||
ltrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
|
||||
|
||||
/// Notes:
|
||||
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
|
||||
/// float timeSec = 3600.0f * timeHr;
|
||||
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
|
||||
int totalPulses = (int)(test.Volume / ltrPerRefPulse + 0.5f);
|
||||
/// Notes:
|
||||
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
|
||||
/// float timeSec = 3600.0f * timeHr;
|
||||
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
|
||||
int totalPulses = (int)(test.Volume / ltrPerRefPulse + 0.5f);
|
||||
|
||||
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this);
|
||||
|
||||
int repetitionNr = 1; /// First test: repetitionNr=1
|
||||
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this);
|
||||
|
||||
int repetitionNr = 1; /// First test: repetitionNr=1
|
||||
|
||||
//====================================
|
||||
// Transition or SetRoute - Start
|
||||
//====================================
|
||||
switch (Transition(transitionBefore, TransitionContext.BeforeTest))
|
||||
{
|
||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
|
||||
//====================================
|
||||
loop:
|
||||
loop:
|
||||
/// Start the test, initialize test results
|
||||
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
|
||||
Config.Entities.TestResult tstRslt = new Config.Entities.TestResult(test, repetitionNr, Config.Entities.MetersKind.Single);
|
||||
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
||||
TestStartTime = DateTime.Now;
|
||||
|
||||
|
||||
int flowSetTime0 = StateMachine.Time;
|
||||
int flowSetTime = 0;
|
||||
float estFlowSetTime = 10.0f;
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -78,9 +80,9 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
int flowSetTime = StateMachine.Time - flowSetTime0;
|
||||
flowSetTime = StateMachine.Time - flowSetTime0;
|
||||
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
|
||||
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
@@ -95,51 +97,51 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
int flowSetTime = StateMachine.Time - flowSetTime0;
|
||||
flowSetTime = StateMachine.Time - flowSetTime0;
|
||||
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
|
||||
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
|
||||
|
||||
if (!test.Emptying) /// If condition met => skip measuring and force emptying
|
||||
{
|
||||
if (!test.Emptying) /// If condition met => skip measuring and force emptying
|
||||
{
|
||||
///
|
||||
/// Measure the weight and skip emptying if there is enough room in the tank
|
||||
/// Measure the weight and skip emptying if there is enough room in the tank
|
||||
///
|
||||
State.Create("ReferenceFlowmeterCalibration : Measuring the mass of water in the tank")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.BalanceDone));
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.BalanceDone));
|
||||
|
||||
float estimatedEndMass = Mass.Val + test.Volume;
|
||||
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
|
||||
{
|
||||
goto set_flow; /// Enough room in the tank -> skip emptying
|
||||
}
|
||||
}
|
||||
float estimatedEndMass = Mass.Val + test.Volume;
|
||||
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
|
||||
{
|
||||
goto set_flow; /// Enough room in the tank -> skip emptying
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Empty the water tank
|
||||
///
|
||||
switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance))
|
||||
{
|
||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
|
||||
set_flow:
|
||||
set_flow:
|
||||
|
||||
//--------------------------------
|
||||
//--------------------------------
|
||||
State.Create("ReferenceFlowmeterCalibration : Setting the flow")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min.
|
||||
@@ -148,12 +150,12 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
int flowSetTime = StateMachine.Time - flowSetTime0;
|
||||
flowSetTime = StateMachine.Time - flowSetTime0;
|
||||
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
|
||||
|
||||
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
if (e.Contains(Event.RegulValveTimeOut))
|
||||
{
|
||||
Bridge.OnError(this, Strings.Timeout);
|
||||
@@ -164,97 +166,75 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
|
||||
}
|
||||
while (!e.Contains(Event.FlowReached));
|
||||
|
||||
flow_set:
|
||||
int time = StateMachine.Time;
|
||||
float currentFlow = RefFlow.Val;
|
||||
flow_set:
|
||||
int time = StateMachine.Time;
|
||||
float currentFlow = RefFlow.Val;
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
||||
//------------------------------------------------
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
||||
//------------------------------------------------
|
||||
State.Create("ReferenceFlowmeterCalibration : Measuring the start mass")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
|
||||
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
|
||||
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
|
||||
.AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp))
|
||||
.AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown))
|
||||
.AddOperation((StateMachine.Ambient != null)
|
||||
? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null)
|
||||
.AddOperation(outPath.Balance.ReadStableMassOp(ref startMass, 5))
|
||||
.AddOperation(cBrd.UpdateTankWeightOp())
|
||||
.AddOperation(processDataLoggingOp)
|
||||
.EnterState();
|
||||
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
|
||||
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
|
||||
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
|
||||
.AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp))
|
||||
.AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown))
|
||||
.AddOperation((StateMachine.Ambient != null)
|
||||
? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null)
|
||||
.AddOperation(outPath.Balance.ReadStableMassOp(ref startMass, 5))
|
||||
.AddOperation(cBrd.UpdateTankWeightOp())
|
||||
.AddOperation(processDataLoggingOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.BalanceDone));
|
||||
|
||||
tstRslt.TimeStart = DateTime.Now;
|
||||
tstRslt.MassStartRaw = startMass.Val;
|
||||
Mass.Val = startMass.Val;
|
||||
StartMassRaw = startMass.Val;
|
||||
Mass.Val = startMass.Val;
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Test_in_progress);
|
||||
//------------------------------------------------
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Test_in_progress);
|
||||
//------------------------------------------------
|
||||
State.Create("ReferenceFlowmeterCalibration : Starting the test")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
|
||||
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
|
||||
test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.MeasurementStarted));
|
||||
|
||||
/// Measurement loop - preparation
|
||||
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses);
|
||||
queryEnd1 = cBrd.QueryMeasurementEndOp();
|
||||
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses);
|
||||
queryEnd1 = cBrd.QueryMeasurementEndOp();
|
||||
queryEnd2 = cBrd.QueryMeasurementEndOp();
|
||||
|
||||
bool firstTime = true; /// To reset sums for averaging
|
||||
ResetAveragedData();
|
||||
ClearAllStatistics();
|
||||
|
||||
/// Measurement loop - begin
|
||||
/// Measurement loop - begin
|
||||
while (true)
|
||||
{
|
||||
//--------------------------------
|
||||
switch (ReadRegistersTempPressAmbient(null, true))
|
||||
//--------------------------------
|
||||
switch (ReadRegistersTempPressAmbient(null, true))
|
||||
{
|
||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
case Event.MeasurementCompleted: goto test_completed;
|
||||
}
|
||||
|
||||
if (firstTime)
|
||||
{
|
||||
firstTime = false; /// Do the following only once
|
||||
tstRslt.TempInStart = TempIn.Val;
|
||||
tstRslt.TempOutStart = TempOut.Val;
|
||||
tstRslt.TempDivStart = TempDiv.Val;
|
||||
tstRslt.PressInStart = PressureUp.Val;
|
||||
tstRslt.PressOutStart = PressureDown.Val;
|
||||
}
|
||||
|
||||
tstRslt.TempInEnd = TempIn.Val;
|
||||
tstRslt.TempOutEnd = TempOut.Val;
|
||||
tstRslt.TempDivEnd = TempDiv.Val;
|
||||
tstRslt.PressInEnd = PressureUp.Val;
|
||||
tstRslt.PressOutEnd = PressureDown.Val;
|
||||
tstRslt.MassEndRaw = Mass.Val;
|
||||
|
||||
AccumulateAveragedData();
|
||||
|
||||
RefFreq.Val = cBrd.ReferenceFreq;
|
||||
RefFlow.Val = cBrd.ReferenceFlow;
|
||||
tstRslt.AmbientTempAve = AmbientTemp.Val;
|
||||
tstRslt.AmbientPressAve = AmbientPressure.Val;
|
||||
tstRslt.AmbientHumiAve = AmbientHumidity.Val;
|
||||
UpdateAllStatistics();
|
||||
CurrentMassRaw = Mass.Val;
|
||||
RefFreq.Val = cBrd.ReferenceFreq;
|
||||
RefFlow.Val = cBrd.ReferenceFlow;
|
||||
|
||||
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
|
||||
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
|
||||
@@ -265,151 +245,140 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
|
||||
log.Debug(logstr);
|
||||
|
||||
|
||||
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress));
|
||||
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, true, cBrd, cBrd.TTime, progress));
|
||||
}
|
||||
/// Measurement loop - end
|
||||
/// Measurement loop - end
|
||||
|
||||
test_completed:
|
||||
State.Create("FlyingStartCollectionMethod : Waiting before mass measurement")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
|
||||
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
|
||||
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
|
||||
.AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp))
|
||||
.AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown))
|
||||
.AddOperation(readRegistersOp)
|
||||
.AddOperation((StateMachine.Ambient != null)
|
||||
? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null)
|
||||
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
|
||||
.AddOperation(cBrd.UpdateTankWeightOp())
|
||||
.AddOperation(processDataLoggingOp)
|
||||
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.TimerExpired));
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
||||
//------------------------------------------------
|
||||
State.Create("ReferenceFlowmeterCalibration : Measuring the end mass")
|
||||
test_completed:
|
||||
State.Create("ReferenceFlowmeterCalibration : Waiting before mass measurement")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
|
||||
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
|
||||
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
|
||||
.AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp))
|
||||
.AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown))
|
||||
.AddOperation((StateMachine.Ambient != null)
|
||||
? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null)
|
||||
.AddOperation(outPath.Balance.ReadStableMassOp(ref endMass, 5))
|
||||
.AddOperation(cBrd.UpdateTankWeightOp())
|
||||
.AddOperation(processDataLoggingOp)
|
||||
.EnterState();
|
||||
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
|
||||
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
|
||||
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
|
||||
.AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp))
|
||||
.AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown))
|
||||
.AddOperation(readRegistersOp)
|
||||
.AddOperation((StateMachine.Ambient != null)
|
||||
? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null)
|
||||
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
|
||||
.AddOperation(cBrd.UpdateTankWeightOp())
|
||||
.AddOperation(processDataLoggingOp)
|
||||
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.TimerExpired));
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
||||
//------------------------------------------------
|
||||
State.Create("ReferenceFlowmeterCalibration : Measuring the end mass")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
|
||||
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
|
||||
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
|
||||
.AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp))
|
||||
.AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown))
|
||||
.AddOperation((StateMachine.Ambient != null)
|
||||
? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null)
|
||||
.AddOperation(outPath.Balance.ReadStableMassOp(ref endMass, 5))
|
||||
.AddOperation(cBrd.UpdateTankWeightOp())
|
||||
.AddOperation(processDataLoggingOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.BalanceDone));
|
||||
///
|
||||
tstRslt.MassEndRaw = endMass.Val;
|
||||
tstRslt.TimeEnd = DateTime.Now;
|
||||
///
|
||||
EndMassRaw = endMass.Val;
|
||||
TestEndTime = DateTime.Now;
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Test_completed);
|
||||
//------------------------------------------------
|
||||
|
||||
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
|
||||
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
|
||||
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
||||
|
||||
///
|
||||
/// Populate TestResult data entity with data
|
||||
///
|
||||
UpdateTestRsltWithAveragedData(tstRslt);
|
||||
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
|
||||
|
||||
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
|
||||
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
|
||||
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
|
||||
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
|
||||
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
|
||||
tstRslt.Time = cBrd.TTime; /// [s] measurement time
|
||||
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
|
||||
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
|
||||
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
|
||||
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
|
||||
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
|
||||
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
|
||||
|
||||
if (tstRslt.VolumeCTV <= float.Epsilon)
|
||||
if (tstRslt != null)
|
||||
{
|
||||
tstRslt.ErrorMaster = 0.1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
|
||||
/// Auxiliary results
|
||||
tstRslt.AmbientTempAve = AmbientTempStat.Average;
|
||||
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
|
||||
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
|
||||
tstRslt.PressUpAvrg = PressureUpStat.Average;
|
||||
tstRslt.PressUpStart = PressureUpStat.First;
|
||||
tstRslt.PressUpEnd = PressureUpStat.Last;
|
||||
tstRslt.PressUpMin = PressureUpStat.Min;
|
||||
tstRslt.PressUpMax = PressureUpStat.Max;
|
||||
tstRslt.PressDownAvrg = PressureDownStat.Average;
|
||||
tstRslt.PressDownStart = PressureDownStat.First;
|
||||
tstRslt.PressDownEnd = PressureDownStat.Last;
|
||||
tstRslt.PressDownMin = PressureDownStat.Min;
|
||||
tstRslt.PressDownMax = PressureDownStat.Max;
|
||||
tstRslt.TempInAvrg = TempInStat.Average;
|
||||
tstRslt.TempInStart = TempInStat.First;
|
||||
tstRslt.TempInEnd = TempInStat.Last;
|
||||
tstRslt.TempInMin = TempInStat.Min;
|
||||
tstRslt.TempInMax = TempInStat.Max;
|
||||
tstRslt.TempOutAvrg = TempOutStat.Average;
|
||||
tstRslt.TempOutStart = TempOutStat.First;
|
||||
tstRslt.TempOutEnd = TempOutStat.Last;
|
||||
tstRslt.TempOutMin = TempOutStat.Min;
|
||||
tstRslt.TempOutMax = TempOutStat.Max;
|
||||
tstRslt.TempDivAvrg = TempDivStat.Average;
|
||||
tstRslt.TempDivStart = TempDivStat.First;
|
||||
tstRslt.TempDivEnd = TempDivStat.Last;
|
||||
tstRslt.TempDivMin = TempDivStat.Min;
|
||||
tstRslt.TempDivMax = TempDivStat.Max;
|
||||
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
|
||||
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
|
||||
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
|
||||
|
||||
/// Update flowmeter constant with the measured one
|
||||
if (outPath.FlowMeter.Idx1 > 0 && outPath.FlowMeter.Idx1 <= ReferenceFlowmetersCount)
|
||||
{
|
||||
LtrPerRefPulse[outPath.FlowMeter.Idx1 - 1] = tstRslt.ConstMaster;
|
||||
log.InfoFormat("Updating LtrPerRefPulse[{0}] = {1}", outPath.FlowMeter.Idx1 - 1, tstRslt.ConstMaster);
|
||||
}
|
||||
/// Main results
|
||||
tstRslt.StartTime = TestStartTime;
|
||||
tstRslt.EndTime = TestEndTime;
|
||||
tstRslt.FlowSetTime = flowSetTime;
|
||||
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
|
||||
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
|
||||
tstRslt.MassStartRaw = startMass.Val;
|
||||
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassEndRaw = endMass.Val;
|
||||
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
|
||||
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
|
||||
tstRslt.FlowVolume = 3.6 * ltrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
|
||||
tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
|
||||
tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
||||
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
|
||||
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
|
||||
|
||||
/// Update flowmeter constant with the measured one
|
||||
if (outPath.FlowMeter.Idx1 > 0 && outPath.FlowMeter.Idx1 <= ReferenceFlowmetersCount)
|
||||
{
|
||||
LtrPerRefPulse[outPath.FlowMeter.Idx1 - 1] = Convert.ToSingle(tstRslt.ConstMaster);
|
||||
log.InfoFormat("Updating LtrPerRefPulse[{0}] = {1}", outPath.FlowMeter.Idx1 - 1, tstRslt.ConstMaster);
|
||||
}
|
||||
}
|
||||
tstRslt.TimeDivStart0 = 0;
|
||||
tstRslt.TimeDivStart1 = 0;
|
||||
tstRslt.TimeDivStart2 = 0;
|
||||
tstRslt.TimeDivStart3 = 0;
|
||||
tstRslt.TimeDivStart4 = 0;
|
||||
tstRslt.TimeDivStart5 = 0;
|
||||
tstRslt.TimeDivEnd0 = 0;
|
||||
tstRslt.TimeDivEnd1 = 0;
|
||||
tstRslt.TimeDivEnd2 = 0;
|
||||
tstRslt.TimeDivEnd3 = 0;
|
||||
tstRslt.TimeDivEnd4 = 0;
|
||||
tstRslt.TimeDivEnd5 = 0;
|
||||
//for (int i = 0; i < Config.Data.WMsCount; i++)
|
||||
//{
|
||||
// if (sensPath.RegisterReaders[i] != null)
|
||||
// {
|
||||
// tstRslt.Meters[i].SerialNr = "wm" + (i + 1).ToString();
|
||||
// tstRslt.Meters[i].VolumeStart = 0; /// liter
|
||||
// tstRslt.Meters[i].VolumeEnd = 0; /// liter
|
||||
// if (sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) tstRslt.Meters[i].VolumeMeter = 0;
|
||||
// else tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr;
|
||||
// tstRslt.Meters[i].VolumeRef = tstRslt.ConstMaster * WMRefPulses[i]; /// liter
|
||||
// tstRslt.Meters[i].PulsesMeter = WMPulses[i];
|
||||
// tstRslt.Meters[i].PulsesMaster = WMRefPulses[i];
|
||||
// tstRslt.Meters[i].Time = cBrd.TTime;
|
||||
// if (WMPulses[i] > 0 && tstRslt.Meters[i].VolumeRef > 0)
|
||||
// {
|
||||
// tstRslt.Meters[i].VolumeErrorPct =
|
||||
// 100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef;
|
||||
// /// %
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// tstRslt.Meters[i].VolumeErrorPct = -100;
|
||||
// }
|
||||
// tstRslt.Meters[i].Passed = (tstRslt.Meters[i].VolumeErrorPct >= tstRslt.ErrLimLo + tstRslt.Uncertainty)
|
||||
// && (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi - tstRslt.Uncertainty);
|
||||
// }
|
||||
//}
|
||||
/// Add data - end
|
||||
|
||||
AddOrOverwriteResult(tstRslt);
|
||||
|
||||
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
|
||||
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
|
||||
|
||||
/// Append the results to the CSV-file
|
||||
allResults.Info(TestResult2CsvLine(tstRslt));
|
||||
allResults.Info(TestResult2CsvLine(testName, test.Part));
|
||||
|
||||
|
||||
if (++repetitionNr <= test.Repeats)
|
||||
@@ -439,7 +408,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
|
||||
/// Prevent overwriting 'retVal' in case it was set to non-default value earlier
|
||||
switch (Transition(transitionAfter, TransitionContext.AfterTest))
|
||||
{
|
||||
case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
|
||||
case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
|
||||
case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user