2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
2021-03-11 16:57:19 +00:00
|
|
|
|
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using log4net;
|
2021-05-27 15:30:04 +00:00
|
|
|
|
using Common;
|
|
|
|
|
|
using Config.Entities;
|
2021-03-05 13:47:21 +00:00
|
|
|
|
using TBF.Rig;
|
2014-08-15 12:31:45 +00:00
|
|
|
|
using TBF.Boxes;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
using TBF.UiBridge;
|
2021-03-05 13:47:21 +00:00
|
|
|
|
using TBF.Rig.GenericDevices;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2021-03-05 13:47:21 +00:00
|
|
|
|
namespace TBF.Rig.TestMethods.FlyingStartMassCollection
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2016-08-17 10:24:24 +00:00
|
|
|
|
public class FlyingStartMassCollectionSeq : Sequences.SequenceBase
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2016-08-17 10:24:24 +00:00
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartMassCollectionSeq));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2020-05-14 08:44:36 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Check capabilities of devces in the output path required for this test method
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="devices">Devices</param>
|
|
|
|
|
|
/// <returns>true when capabilities of devices are OK</returns>
|
|
|
|
|
|
public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message)
|
|
|
|
|
|
{
|
2021-03-11 16:57:19 +00:00
|
|
|
|
if (!(StateMachine.ControlBoard is ControlBoard.Uni.UniCB))
|
2020-05-14 08:44:36 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// Control board does not support this method
|
|
|
|
|
|
message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!(devices.Scale is IScale))
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Scale is missing
|
|
|
|
|
|
message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_scale);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (test.Volume > devices.Scale.Capacity * Constants.TankFullFactor)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Scale capacity is not sufficient
|
|
|
|
|
|
message = string.Format("{0}: {1}", test.Name, Strings.Test_volume_exceeds_the_scale_capacity);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!(devices.Diverter is IDiverter))
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Scale is missing
|
|
|
|
|
|
message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_diverter);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!(devices.FlowMeter is IFlowMeter))
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Flow meter is missing
|
|
|
|
|
|
message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-04 12:16:21 +00:00
|
|
|
|
if (!(devices.RegValve is GenericDevices.IRegValve))
|
2020-05-14 08:44:36 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// Regulation valve is missing
|
|
|
|
|
|
message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
message = string.Empty;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-15 12:31:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Flying start mass collection method sequence
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="test">Test entity</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// Event.Done . . . . . . . OK
|
|
|
|
|
|
/// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP
|
|
|
|
|
|
/// Event.OpArgumentError . Target flow is out of range
|
|
|
|
|
|
/// Event.Error . . . . . . Unspecified error
|
|
|
|
|
|
/// </returns>
|
2017-12-02 16:54:38 +00:00
|
|
|
|
public IList<Event> Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition,
|
2016-08-17 10:24:24 +00:00
|
|
|
|
Compound.CombinedTestParams compoundTestParams,
|
2016-10-11 07:59:59 +00:00
|
|
|
|
HeatMeters.TestParams heatMetersTestParams,
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Common.DebugMode debugLevel)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2021-05-27 15:30:04 +00:00
|
|
|
|
if (debugLevel == Common.DebugMode.Simulate)
|
2016-10-11 07:59:59 +00:00
|
|
|
|
{
|
2018-11-12 13:16:03 +00:00
|
|
|
|
return Simulate1(test, repetitionNr, isLastRepetition, compoundTestParams, heatMetersTestParams);
|
2016-10-11 07:59:59 +00:00
|
|
|
|
}
|
2021-05-27 15:30:04 +00:00
|
|
|
|
else if (debugLevel == Common.DebugMode.Inherit)
|
2018-02-11 15:31:25 +00:00
|
|
|
|
{
|
2018-11-12 13:16:03 +00:00
|
|
|
|
return Simulate2(test, repetitionNr, isLastRepetition, compoundTestParams, heatMetersTestParams);
|
2018-10-22 16:14:47 +00:00
|
|
|
|
}
|
2018-02-11 15:31:25 +00:00
|
|
|
|
|
2021-03-11 16:57:19 +00:00
|
|
|
|
ControlBoard.Uni.UniCB cBrd = StateMachine.ControlBoard as ControlBoard.Uni.UniCB;
|
2020-05-14 08:44:36 +00:00
|
|
|
|
IScale scale = cBrd.Devices.Scale as IScale;
|
2018-02-11 15:31:25 +00:00
|
|
|
|
|
2022-05-02 07:28:16 +00:00
|
|
|
|
if ((outPath.FlowMeter is IFlowMeterSingle) &&
|
|
|
|
|
|
(outPath.FlowMeter as IFlowMeterSingle).GetRange(test.TempLimLo, test.TempLimHi) == -1)
|
2021-03-11 13:55:21 +00:00
|
|
|
|
{
|
2022-05-02 07:28:16 +00:00
|
|
|
|
Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions);
|
|
|
|
|
|
return new List<Event> { Event.ConfigurationError }; /// or Event.UiCmdStop ???
|
|
|
|
|
|
}
|
2018-02-11 15:31:25 +00:00
|
|
|
|
|
2019-05-10 14:26:58 +00:00
|
|
|
|
IList<Event> e; /// Events from currently running operations
|
|
|
|
|
|
Event retVal = Event.Done;
|
2019-05-14 14:59:20 +00:00
|
|
|
|
int tMass1 = 0;
|
|
|
|
|
|
int tMass2 = 0;
|
|
|
|
|
|
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
|
2021-03-05 13:47:21 +00:00
|
|
|
|
processDataLoggingOp = new TBF.Rig.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null);
|
2019-05-10 14:26:58 +00:00
|
|
|
|
|
2021-03-12 15:03:21 +00:00
|
|
|
|
if (cBrd is ControlBoard.Uni.UniCB)
|
2019-05-02 07:36:33 +00:00
|
|
|
|
{
|
2021-03-12 15:03:21 +00:00
|
|
|
|
int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
|
|
|
|
if (sensPath != null && sensPath.RegisterReaders != null)
|
2019-05-02 07:36:33 +00:00
|
|
|
|
{
|
2021-03-12 15:03:21 +00:00
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
2019-05-02 07:36:33 +00:00
|
|
|
|
{
|
2021-03-12 15:03:21 +00:00
|
|
|
|
IRegReaderPulses rrPls = rr as IRegReaderPulses;
|
|
|
|
|
|
if (rrPls != null && rrPls.Position >= 1 && rrPls.Position <= 8)
|
|
|
|
|
|
{
|
|
|
|
|
|
filters[rrPls.Position - 1] = rrPls.Filter;
|
|
|
|
|
|
}
|
2019-05-02 07:36:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-12 15:03:21 +00:00
|
|
|
|
(cBrd as ControlBoard.Uni.UniCB).SetFiltersPidShortPulses(filters, outPath.PidCoef, test.ShortPulses);
|
2020-05-14 08:44:36 +00:00
|
|
|
|
}
|
2019-03-18 08:14:13 +00:00
|
|
|
|
|
|
|
|
|
|
IList<IOperation> readTempPressOps = new List<IOperation>();
|
|
|
|
|
|
if(benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp));
|
|
|
|
|
|
if(benchPath.TempMtrDown != null) readTempPressOps.Add(benchPath.TempMtrDown.ReadTempOp(ref TempDown));
|
2021-02-25 12:38:24 +00:00
|
|
|
|
if(outPath.TempMtrDiv != null) readTempPressOps.Add(outPath.TempMtrDiv.ReadTempOp(ref TempDiv));
|
2019-03-18 08:14:13 +00:00
|
|
|
|
if(benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
|
|
|
|
|
|
if(benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
|
|
|
|
|
|
if(benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
|
|
|
|
|
|
if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
|
|
|
|
|
|
if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
|
|
|
|
|
|
if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
|
|
|
|
|
|
if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2));
|
|
|
|
|
|
|
2022-05-02 07:28:16 +00:00
|
|
|
|
int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse);
|
2016-06-28 16:04:52 +00:00
|
|
|
|
|
2021-04-02 21:41:49 +00:00
|
|
|
|
///============================================================================================
|
2021-03-12 15:03:21 +00:00
|
|
|
|
|
2019-03-18 08:14:13 +00:00
|
|
|
|
/// Read pressure and temperature once before calling Bridge.OnTestSelected(...)
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Measuring process data", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.Busy));
|
|
|
|
|
|
|
|
|
|
|
|
/// Start the test, initialize test results
|
2020-05-14 08:44:36 +00:00
|
|
|
|
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath));
|
2016-01-03 01:05:35 +00:00
|
|
|
|
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
|
|
|
|
|
TestStartTime = DateTime.Now;
|
2017-03-28 21:47:32 +00:00
|
|
|
|
|
2016-06-28 16:04:52 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Checking_tank_capacity);
|
|
|
|
|
|
//------------------------------------------------
|
2017-06-08 13:42:47 +00:00
|
|
|
|
bool drainTheTank = test.DoDraining;
|
2016-03-17 04:05:30 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (!drainTheTank) /// If condition met => skip measuring and force emptying
|
2016-06-28 16:04:52 +00:00
|
|
|
|
{
|
2021-04-15 09:58:31 +00:00
|
|
|
|
double estimatedEndMass = scale.Mass + test.Volume;
|
2018-10-22 16:14:47 +00:00
|
|
|
|
if (estimatedEndMass >= scale.Capacity * Constants.TankFullFactor)
|
2016-06-28 16:04:52 +00:00
|
|
|
|
{
|
2017-03-28 21:47:32 +00:00
|
|
|
|
drainTheTank = true;
|
2016-06-28 16:04:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
///
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (drainTheTank)
|
2016-06-28 16:04:52 +00:00
|
|
|
|
{
|
2018-09-28 12:16:12 +00:00
|
|
|
|
#if BERLIN || SENTEC
|
2020-05-14 08:44:36 +00:00
|
|
|
|
switch (DrainTheTank(scale, readTempPressOps))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
drainTheTank = false;
|
|
|
|
|
|
#else
|
2019-03-18 08:14:13 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Open the drain valve", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2020-05-14 08:44:36 +00:00
|
|
|
|
.AddOperation(cBrd.SetValvesOp(scale.DrainValve, null))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-06-28 16:04:52 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2016-06-28 16:04:52 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
2017-07-25 08:41:06 +00:00
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
2017-03-28 21:47:32 +00:00
|
|
|
|
#endif
|
2016-06-28 16:04:52 +00:00
|
|
|
|
}
|
2015-02-01 16:42:14 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
|
2016-10-10 12:23:20 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test
|
|
|
|
|
|
///
|
2016-10-11 07:10:33 +00:00
|
|
|
|
IOperation heatMetersPromptOp = null;
|
2016-10-10 12:23:20 +00:00
|
|
|
|
if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt))
|
|
|
|
|
|
{
|
2016-10-11 07:10:33 +00:00
|
|
|
|
/// Make sure the CycleBeginForm is closed
|
|
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
|
|
|
|
|
|
|
|
|
|
|
heatMetersPromptOp = new Operations.MessageBoxOp(heatMetersTestParams.Prompt);
|
2016-10-10 12:23:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
|
2016-10-13 13:02:33 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Starting_the_pump);
|
|
|
|
|
|
//------------------------------------------------
|
2017-03-28 21:47:32 +00:00
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.FlowSetting));
|
2017-03-28 21:47:32 +00:00
|
|
|
|
int flowSetTime0 = StateMachine.Time;
|
|
|
|
|
|
|
2021-05-11 12:28:27 +00:00
|
|
|
|
|
|
|
|
|
|
if (inPath.Pump is GenericDevices.IPumpFM)
|
|
|
|
|
|
{
|
|
|
|
|
|
(inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
|
|
|
|
|
|
}
|
2016-10-13 11:41:00 +00:00
|
|
|
|
///
|
2021-05-11 12:28:27 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Starting pump {2}", test.Method, test.Name, (inPath.Pump != null) ? inPath.Pump.Name : "?"))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2017-04-24 09:58:57 +00:00
|
|
|
|
// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-10-13 13:02:33 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.FlowSetting));
|
2015-02-01 16:42:14 +00:00
|
|
|
|
|
2016-10-13 13:02:33 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2016-06-28 16:04:52 +00:00
|
|
|
|
}
|
2017-04-24 09:58:57 +00:00
|
|
|
|
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
|
2015-02-01 16:42:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
2016-06-28 16:04:52 +00:00
|
|
|
|
if (test.TimePump2StartV > 0)
|
|
|
|
|
|
{
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Waiting after the pump started", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(test.TimePump2StartV))
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-06-28 16:04:52 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.FlowSetting));
|
2016-03-17 04:05:30 +00:00
|
|
|
|
|
2016-06-28 16:04:52 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.TimerExpired));
|
|
|
|
|
|
}
|
2016-03-17 04:05:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
2016-06-28 16:04:52 +00:00
|
|
|
|
if (benchPath.StopBFValve != null)
|
|
|
|
|
|
{
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2020-05-14 08:44:36 +00:00
|
|
|
|
.AddOperation(cBrd.SetValvesOp(benchPath.StopBFValve, null))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-06-28 16:04:52 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
2016-06-28 16:04:52 +00:00
|
|
|
|
if (test.TimeBeforeFlow > 0)
|
|
|
|
|
|
{
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Waiting before flow setting process starts", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(test.TimeBeforeFlow))
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-06-28 16:04:52 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.FlowSetting));
|
2016-03-17 04:05:30 +00:00
|
|
|
|
|
2016-06-28 16:04:52 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.TimerExpired));
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-05-19 13:38:58 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Setting_the_flow);
|
|
|
|
|
|
//------------------------------------------------
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2020-05-14 08:44:36 +00:00
|
|
|
|
.AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-06-28 16:04:52 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.FlowSetting));
|
2014-08-01 06:36:17 +00:00
|
|
|
|
|
2016-06-28 16:04:52 +00:00
|
|
|
|
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-01-12 04:56:19 +00:00
|
|
|
|
if (e.Contains(Event.RegulValveTimeOut))
|
2016-06-28 16:04:52 +00:00
|
|
|
|
{
|
2018-06-05 09:16:13 +00:00
|
|
|
|
Bridge.OnError(this, Strings.Flow_adjustment_failed);
|
2019-04-08 08:33:58 +00:00
|
|
|
|
retVal = Event.RecoverableError;
|
2016-06-28 16:04:52 +00:00
|
|
|
|
goto stopTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.Contains(Event.Next)) goto flow_set;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.FlowReached));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
flow_set:
|
|
|
|
|
|
|
2016-06-28 16:04:52 +00:00
|
|
|
|
int flowSetTime = StateMachine.Time - flowSetTime0;
|
2016-10-07 14:22:36 +00:00
|
|
|
|
double currentFlow = RefFlow.Val;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2016-08-24 16:30:00 +00:00
|
|
|
|
if (heatMetersTestParams != null && heatMetersPath != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
//---------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Setting_temperature);
|
|
|
|
|
|
//---------------------------------------------------
|
2016-08-17 16:11:34 +00:00
|
|
|
|
|
2016-08-24 16:30:00 +00:00
|
|
|
|
int lastTimeSec = StateMachine.Time;
|
2016-10-07 13:33:56 +00:00
|
|
|
|
double Tw_last = 0;
|
|
|
|
|
|
double Tc_last = 0;
|
2016-08-17 16:11:34 +00:00
|
|
|
|
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Check temperature stabilized.", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-08-24 16:30:00 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
if (e.Contains(Event.Next)) goto temperature_set;
|
|
|
|
|
|
|
2016-10-18 16:48:20 +00:00
|
|
|
|
if (TempRefHi1.Val != 0 && TempRefHi2.Val != 0 && TempRefLo1.Val != 0 && TempRefLo2.Val != 0)
|
2016-08-24 16:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (StateMachine.Time - lastTimeSec > 10 || StateMachine.Time - lastTimeSec < 0)
|
|
|
|
|
|
{
|
2016-10-18 16:48:20 +00:00
|
|
|
|
double Tw = (TempRefHi1.Val + TempRefHi2.Val) / 2;
|
|
|
|
|
|
double Tc = (TempRefLo1.Val + TempRefLo2.Val) / 2;
|
2016-08-24 16:30:00 +00:00
|
|
|
|
if (heatMetersTestParams.TempWarmLo <= Tw && Tw <= heatMetersTestParams.TempWarmHi &&
|
|
|
|
|
|
heatMetersTestParams.TempColdLo <= Tc && Tc <= heatMetersTestParams.TempColdHi &&
|
|
|
|
|
|
Math.Abs(Tw - Tw_last) <= heatMetersTestParams.ChangeInTimeWarm &&
|
|
|
|
|
|
Math.Abs(Tc - Tc_last) <= heatMetersTestParams.ChangeInTimeCold &&
|
2016-10-18 16:48:20 +00:00
|
|
|
|
Math.Abs(TempRefHi1.Val - TempRefHi2.Val) <= heatMetersTestParams.DeltaTempWarm &&
|
|
|
|
|
|
Math.Abs(TempRefLo1.Val - TempRefLo2.Val) <= heatMetersTestParams.DeltaTempCold)
|
2016-08-24 16:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
|
goto temperature_set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lastTimeSec = StateMachine.Time;
|
|
|
|
|
|
Tw_last = Tw;
|
|
|
|
|
|
Tc_last = Tc;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
while (true);
|
|
|
|
|
|
}
|
2017-06-08 14:55:24 +00:00
|
|
|
|
else if (test.DoControlWaterTemp && benchPath.TempMtrUp != null && benchPath.TempMtrDown != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
//---------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Setting_temperature);
|
|
|
|
|
|
//---------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Wait until the water temperature is within limits", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2017-06-08 14:55:24 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
if (e.Contains(Event.Next)) goto temperature_set;
|
|
|
|
|
|
|
2019-03-18 08:14:13 +00:00
|
|
|
|
if ((test.TempLimLo <= TempUp.Val) && (TempUp.Val <= test.TempLimHi) &&
|
|
|
|
|
|
(test.TempLimLo <= TempDown.Val) && (TempDown.Val <= test.TempLimHi))
|
|
|
|
|
|
{
|
2017-06-08 14:55:24 +00:00
|
|
|
|
goto temperature_set;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
while (true);
|
|
|
|
|
|
}
|
2016-08-17 16:11:34 +00:00
|
|
|
|
|
2016-08-24 16:30:00 +00:00
|
|
|
|
temperature_set:
|
2016-08-17 16:11:34 +00:00
|
|
|
|
|
2017-01-22 19:39:14 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Prepare cameras, ROI-s and measurementOperations
|
|
|
|
|
|
///
|
|
|
|
|
|
|
2017-04-06 16:55:01 +00:00
|
|
|
|
/// Find successfully detected ROI-s
|
2020-11-13 10:33:33 +00:00
|
|
|
|
IList<GenericDevices.IRegReaderLiveCamera> rois = new List<GenericDevices.IRegReaderLiveCamera>();
|
2017-01-22 19:39:14 +00:00
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
|
|
|
|
{
|
2020-11-13 10:33:33 +00:00
|
|
|
|
GenericDevices.IRegReaderLiveCamera cameraRoI = rr as GenericDevices.IRegReaderLiveCamera;
|
2019-05-02 07:36:33 +00:00
|
|
|
|
if ((cameraRoI != null) && cameraRoI.Detected)
|
2018-08-23 09:39:11 +00:00
|
|
|
|
{
|
2019-05-02 07:36:33 +00:00
|
|
|
|
rois.Add(cameraRoI);
|
2018-08-23 09:39:11 +00:00
|
|
|
|
}
|
2017-01-22 19:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Find cameras
|
|
|
|
|
|
IList<GenericDevices.ICamera> cameras = new List<GenericDevices.ICamera>();
|
|
|
|
|
|
foreach (var roi in rois)
|
2016-06-28 16:04:52 +00:00
|
|
|
|
{
|
2017-01-24 17:55:36 +00:00
|
|
|
|
if (roi.Camera != null && !cameras.Contains(roi.Camera))
|
2017-01-22 19:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
cameras.Add(roi.Camera);
|
2017-04-06 16:55:01 +00:00
|
|
|
|
roi.Camera.ClearRoiParams();
|
2017-01-22 19:39:14 +00:00
|
|
|
|
}
|
2016-06-28 16:04:52 +00:00
|
|
|
|
}
|
2016-03-17 04:05:30 +00:00
|
|
|
|
|
2017-01-22 19:39:14 +00:00
|
|
|
|
/// Register ROI-parameters to cameras
|
2017-01-24 09:50:53 +00:00
|
|
|
|
foreach (var roi in rois) roi.RegisterRoiToCamera();
|
2017-01-22 19:39:14 +00:00
|
|
|
|
|
|
|
|
|
|
/// Prepare measurementOperations
|
2021-03-12 15:03:21 +00:00
|
|
|
|
IList<IOperation> cameraMeasurementOps = new List<IOperation>();
|
2021-05-18 07:25:41 +00:00
|
|
|
|
foreach (var camera in cameras)
|
|
|
|
|
|
{
|
|
|
|
|
|
cameraMeasurementOps.Add(camera.MeasurementOp());
|
|
|
|
|
|
}
|
2017-01-24 17:55:36 +00:00
|
|
|
|
|
2022-01-25 15:16:12 +00:00
|
|
|
|
/// Prepare datastream read operations
|
|
|
|
|
|
IList<IOperation> readDatastreamOps = new List<IOperation>();
|
|
|
|
|
|
if (sensPath != null && sensPath.RegisterReaders != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
|
|
|
|
{
|
|
|
|
|
|
var datastreamRR = rr as GenericDevices.IRegReaderDatastream;
|
|
|
|
|
|
if (datastreamRR != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
datastreamRR.TestIsGoingToStartSoon(test, repetitionNr);
|
|
|
|
|
|
readDatastreamOps.Add(datastreamRR.ReadDatastreamOp());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-22 19:39:14 +00:00
|
|
|
|
|
2017-07-25 08:41:06 +00:00
|
|
|
|
if (drainTheTank)
|
|
|
|
|
|
{
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Closing_the_tank);
|
|
|
|
|
|
//------------------------------------------------
|
2016-03-17 04:05:30 +00:00
|
|
|
|
|
2017-07-25 08:41:06 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Make sure tank draining completed
|
|
|
|
|
|
///
|
2019-03-18 08:14:13 +00:00
|
|
|
|
switch (DrainTheTank(scale, readTempPressOps))
|
2017-07-25 08:41:06 +00:00
|
|
|
|
{
|
|
|
|
|
|
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
2015-04-19 11:07:49 +00:00
|
|
|
|
|
2017-07-25 08:41:06 +00:00
|
|
|
|
drainTheTank = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Close the drain valve anyway
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Close the drain valve", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
2020-05-14 08:44:36 +00:00
|
|
|
|
.AddOperation(cBrd.SetValvesOp(null, scale.DrainValve))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2017-07-25 08:41:06 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
|
|
|
|
|
}
|
2015-04-19 11:07:49 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
|
2017-11-22 09:43:37 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
|
2017-05-10 11:32:49 +00:00
|
|
|
|
LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name);
|
|
|
|
|
|
|
|
|
|
|
|
if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "Start mass");
|
|
|
|
|
|
else LogProcessDataHeaderHeatMeters(processDataLogger, "Start mass");
|
2014-09-09 14:18:23 +00:00
|
|
|
|
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Measuring the start mass", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2021-03-23 12:50:32 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
2021-03-12 15:03:21 +00:00
|
|
|
|
.AddOperations(cameraMeasurementOps)
|
2021-03-23 12:50:32 +00:00
|
|
|
|
.AddOperation(scale.ReadStableMassOp(ref StartMass, test.TimeFlow2Mass, test.MassMethod, test.MassRepeats, test.MassSpread))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(processDataLoggingOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2021-03-25 11:34:06 +00:00
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2019-03-08 13:52:02 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2021-03-23 12:50:32 +00:00
|
|
|
|
if (e.Contains(Event.ScaleTimeout))
|
2019-03-08 13:52:02 +00:00
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, Strings.Mass_measurement_timeout);
|
2019-04-08 08:33:58 +00:00
|
|
|
|
retVal = Event.RecoverableError;
|
2019-03-08 13:52:02 +00:00
|
|
|
|
goto stopTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-25 11:34:06 +00:00
|
|
|
|
while (!e.Contains(Event.ScaleDone) && !e.Contains(Event.Next));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2019-05-14 14:59:20 +00:00
|
|
|
|
tMass1 = StateMachine.Time;
|
|
|
|
|
|
log.WarnFormat("Start mass = {0}kg", StartMass);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-05-10 11:32:49 +00:00
|
|
|
|
|
2021-03-12 15:03:21 +00:00
|
|
|
|
if (heatMetersPath == null)
|
|
|
|
|
|
LogProcessDataHeader(processDataLogger, "Measurement");
|
|
|
|
|
|
else
|
|
|
|
|
|
LogProcessDataHeaderHeatMeters(processDataLogger, "Measurement");
|
2017-05-10 11:32:49 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Test_in_progress);
|
|
|
|
|
|
//------------------------------------------------
|
2022-05-02 07:28:16 +00:00
|
|
|
|
|
2021-03-12 15:03:21 +00:00
|
|
|
|
/// Measurement loop preparation
|
|
|
|
|
|
int estimtdEndTime = StateMachine.Time + (int)test.TestTime;
|
|
|
|
|
|
int remainingTime;
|
2022-05-02 07:28:16 +00:00
|
|
|
|
StartNewStatistics(outPath.FlowMeter, BatchRslts.Batch.BatchNr, test, repetitionNr, 0);
|
2021-03-25 11:34:06 +00:00
|
|
|
|
DiverterStart.Start(BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
|
|
|
|
|
|
DiverterEnd.Start(BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2021-03-12 15:03:21 +00:00
|
|
|
|
/// Measurement loop
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : FlyingStartStopTestWithDivOp is running", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
2021-05-18 07:25:41 +00:00
|
|
|
|
.AddOperations(readDatastreamOps)
|
2021-03-12 15:03:21 +00:00
|
|
|
|
.AddOperations(cameraMeasurementOps)
|
2021-03-25 11:34:06 +00:00
|
|
|
|
.AddOperation(cBrd.FlyingStartStopTestOp(test, test.Qfrom, test.Qto, totalPulses, true, false, 0, true, DiverterStart, DiverterEnd))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(processDataLoggingOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2015-08-19 11:04:47 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2021-03-12 15:03:21 +00:00
|
|
|
|
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2021-03-12 15:03:21 +00:00
|
|
|
|
/// Show remaining time
|
|
|
|
|
|
if ((remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0)) > 60)
|
|
|
|
|
|
Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec));
|
|
|
|
|
|
else
|
|
|
|
|
|
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
|
2015-02-20 12:38:07 +00:00
|
|
|
|
|
2021-03-12 15:03:21 +00:00
|
|
|
|
/// Update statistics
|
2020-05-14 08:44:36 +00:00
|
|
|
|
RefFrequency.Val = cBrd.RefFrequency;
|
2021-03-09 09:46:59 +00:00
|
|
|
|
RefFlow.Val = outPath.FlowMeter.ReadFlow();
|
2022-05-02 07:28:16 +00:00
|
|
|
|
UpdateAllStatistics();
|
2016-08-24 16:30:00 +00:00
|
|
|
|
|
2021-03-12 15:03:21 +00:00
|
|
|
|
#region Heat meters
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2016-08-24 16:30:00 +00:00
|
|
|
|
if (heatMetersTestParams != null)
|
|
|
|
|
|
{
|
2021-03-12 15:03:21 +00:00
|
|
|
|
/// Update heatmeter volume and energy values
|
2016-08-24 16:30:00 +00:00
|
|
|
|
if (lastEnergyUpdateTime == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastEnergyUpdateTime = StateMachine.Time;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//double deltaTime = (double)(StateMachine.Time - lastEnergyUpdateTime);
|
2021-03-12 15:03:21 +00:00
|
|
|
|
double T_in = (TempRefHi1.Val + TempRefHi2.Val) / 2; /// [°C]
|
|
|
|
|
|
double T_out = (TempRefLo1.Val + TempRefLo2.Val) / 2; /// [°C]
|
2022-05-02 07:28:16 +00:00
|
|
|
|
double deltaVolume = outPath.FlowMeter.LtrPerPulse * RefPulsesDelta; /// [l]
|
2021-05-27 15:30:04 +00:00
|
|
|
|
double deltaEnergy = (0.001 * deltaVolume) * (T_in - T_out) * Formulas.HeatCoefficientWater(16, T_in, T_out, heatMetersTestParams.FlowMeasuredAtHiTempPipe); /// [J] = [m3] * [K] * [J/(m3 K)]
|
2016-08-24 16:30:00 +00:00
|
|
|
|
Energy.Update(deltaEnergy);
|
|
|
|
|
|
VolumeForEnergy.Update(deltaVolume);
|
|
|
|
|
|
lastEnergyUpdateTime = StateMachine.Time;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-12 15:03:21 +00:00
|
|
|
|
#endregion
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test));
|
2021-03-12 15:03:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.TestCompleted) && !e.Contains(Event.Next)); /// 'Next' button is enabled in Debug version only
|
2017-02-17 09:51:30 +00:00
|
|
|
|
|
2021-03-12 15:03:21 +00:00
|
|
|
|
/// Measurement loop end
|
2018-02-11 15:31:25 +00:00
|
|
|
|
StopRecordingStatistics();
|
|
|
|
|
|
|
2017-12-02 16:54:38 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// (Berlin:) Water is stopped immediately after the test and before the 2nd mass measurement in case:
|
|
|
|
|
|
/// - no 'transition sequence after test' is used
|
|
|
|
|
|
/// - this is the last (or the only) test repetition or test is a part of an 'outer loop'
|
|
|
|
|
|
///
|
2018-11-27 06:49:17 +00:00
|
|
|
|
#if !CEVAK_200
|
2017-12-02 16:54:38 +00:00
|
|
|
|
if (isLastRepetition && transitionAfter == null)
|
2018-11-27 06:49:17 +00:00
|
|
|
|
#endif
|
2019-04-25 09:00:34 +00:00
|
|
|
|
{
|
2017-12-02 16:54:38 +00:00
|
|
|
|
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOff();
|
|
|
|
|
|
|
|
|
|
|
|
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
2020-05-14 08:44:36 +00:00
|
|
|
|
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
2017-12-02 16:54:38 +00:00
|
|
|
|
.EnterState();
|
2019-03-18 08:14:13 +00:00
|
|
|
|
do {
|
2017-12-02 16:54:38 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
}
|
2017-02-17 09:51:30 +00:00
|
|
|
|
|
2016-02-15 21:48:44 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
|
|
|
|
|
//------------------------------------------------
|
2017-05-10 11:32:49 +00:00
|
|
|
|
|
|
|
|
|
|
if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "End mass");
|
|
|
|
|
|
else LogProcessDataHeaderHeatMeters(processDataLogger, "End mass");
|
2014-09-09 14:18:23 +00:00
|
|
|
|
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Measuring the end mass", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
2021-03-23 12:50:32 +00:00
|
|
|
|
.AddOperation(scale.ReadStableMassOp(ref EndMass, test.TimeStop2Mass, test.MassMethod, test.MassRepeats, test.MassSpread))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec))
|
|
|
|
|
|
.AddOperation(processDataLoggingOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2014-08-15 12:31:45 +00:00
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2021-03-23 12:50:32 +00:00
|
|
|
|
if (e.Contains(Event.ScaleTimeout))
|
2019-03-08 13:52:02 +00:00
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, Strings.Mass_measurement_timeout);
|
2019-04-08 08:33:58 +00:00
|
|
|
|
retVal = Event.RecoverableError;
|
2019-03-08 13:52:02 +00:00
|
|
|
|
goto stopTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-25 11:34:06 +00:00
|
|
|
|
while (!e.Contains(Event.ScaleDone) && !e.Contains(Event.Next));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
///
|
2019-05-14 14:59:20 +00:00
|
|
|
|
tMass2 = StateMachine.Time;
|
|
|
|
|
|
log.WarnFormat("End mass = {0}kg", EndMass);
|
2016-02-10 18:24:10 +00:00
|
|
|
|
TestEndTime = DateTime.Now;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2019-10-24 12:38:36 +00:00
|
|
|
|
if (test.DoDrainingAfter)
|
|
|
|
|
|
{
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Open the drain valve", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2020-05-14 08:44:36 +00:00
|
|
|
|
.AddOperation(cBrd.SetValvesOp(scale.DrainValve, null))
|
2019-10-24 12:38:36 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-13 14:20:00 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Test_completed);
|
|
|
|
|
|
//------------------------------------------------
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-01-15 05:34:36 +00:00
|
|
|
|
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
|
2016-10-11 07:10:33 +00:00
|
|
|
|
if (heatMetersPromptOp == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
|
|
|
|
|
}
|
2015-01-15 05:34:36 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
///
|
2014-08-13 14:20:00 +00:00
|
|
|
|
/// Populate TestResult data entity with data
|
2014-07-28 07:54:35 +00:00
|
|
|
|
///
|
2016-01-03 01:05:35 +00:00
|
|
|
|
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
|
2015-08-22 04:32:55 +00:00
|
|
|
|
|
2021-06-27 14:07:21 +00:00
|
|
|
|
bool stopCycle = false;
|
|
|
|
|
|
if (tstRslt != null)
|
2020-01-22 12:51:47 +00:00
|
|
|
|
{
|
|
|
|
|
|
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
|
2016-01-03 01:05:35 +00:00
|
|
|
|
|
2022-05-02 07:28:16 +00:00
|
|
|
|
/// Raw data
|
|
|
|
|
|
UpdateTempPressDensAmb(tstRslt);
|
|
|
|
|
|
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
|
|
|
|
|
|
tstRslt.StartTime = TestStartTime;
|
|
|
|
|
|
tstRslt.EndTime = TestEndTime;
|
|
|
|
|
|
tstRslt.FlowSetTime = flowSetTime;
|
|
|
|
|
|
tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time
|
|
|
|
|
|
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total)
|
|
|
|
|
|
tstRslt.MassStartRaw = StartMass.Val;
|
|
|
|
|
|
tstRslt.MassEndRaw = EndMass.Val;
|
2019-05-15 12:04:40 +00:00
|
|
|
|
tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1;
|
2022-05-02 07:28:16 +00:00
|
|
|
|
tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse;
|
|
|
|
|
|
tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
|
|
|
|
|
double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] flow before correction from the master flow meter
|
|
|
|
|
|
|
|
|
|
|
|
/// Corrected data
|
|
|
|
|
|
tstRslt.MassStart = MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections);
|
|
|
|
|
|
tstRslt.MassEnd = MeasurementCorrection.CorrectedValue(tstRslt.MassEndRaw, scale.Corrections);
|
2021-04-04 12:36:43 +00:00
|
|
|
|
tstRslt.MassOfEvapWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean);
|
2022-05-02 07:28:16 +00:00
|
|
|
|
double mass = tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater;
|
|
|
|
|
|
tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean);
|
|
|
|
|
|
|
|
|
|
|
|
/// Main result calculation
|
|
|
|
|
|
tstRslt.VolumeCTV = 1000 * tstRslt.Batch.Buoyancy * mass / tstRslt.DensityLine;
|
2019-05-15 08:31:52 +00:00
|
|
|
|
if ((outPath.Diverter != null) && (tstRslt.TestTime > float.Epsilon))
|
|
|
|
|
|
{
|
2022-05-02 07:28:16 +00:00
|
|
|
|
tstRslt.TestTimeCorrection = outPath.Diverter.TestTimeCorrection(flowMID);
|
2019-05-15 08:31:52 +00:00
|
|
|
|
tstRslt.VolumeCTV *= tstRslt.TestTime + tstRslt.TestTimeCorrection;
|
|
|
|
|
|
tstRslt.VolumeCTV /= tstRslt.TestTime;
|
|
|
|
|
|
}
|
2022-05-02 07:28:16 +00:00
|
|
|
|
tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// Flow from VolumeCTV and time
|
|
|
|
|
|
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
|
|
|
|
|
|
tstRslt.ConstMaster = (tstRslt.PulsesMaster != 0) ? (tstRslt.VolumeCTV / tstRslt.PulsesMaster) : tstRslt.ConstMasterCorr;
|
|
|
|
|
|
/// Master pulses per liter from the measured mass
|
|
|
|
|
|
/// Flow statistics correction
|
|
|
|
|
|
tstRslt.FlowMean = Convert.ToSingle(tstRslt.ConstMaster * RefFlowStat.Average / tstRslt.ConstMasterRaw);
|
|
|
|
|
|
tstRslt.FlowStart = Convert.ToSingle(tstRslt.ConstMaster * RefFlowStat.First / tstRslt.ConstMasterRaw);
|
|
|
|
|
|
tstRslt.FlowEnd = Convert.ToSingle(tstRslt.ConstMaster * RefFlowStat.Last / tstRslt.ConstMasterRaw);
|
|
|
|
|
|
tstRslt.FlowMin = Convert.ToSingle(tstRslt.ConstMaster * RefFlowStat.Min / tstRslt.ConstMasterRaw);
|
|
|
|
|
|
tstRslt.FlowMax = Convert.ToSingle(tstRslt.ConstMaster * RefFlowStat.Max / tstRslt.ConstMasterRaw);
|
2016-08-02 12:48:18 +00:00
|
|
|
|
|
2019-09-04 10:28:30 +00:00
|
|
|
|
tstRslt.DiverterStart = outPath.Diverter.SwitchTimeStart.Val;
|
2018-06-08 12:52:34 +00:00
|
|
|
|
tstRslt.DivStart10 = 0;
|
|
|
|
|
|
tstRslt.DivStart50 = 0;
|
|
|
|
|
|
tstRslt.DivStart90 = 0;
|
2019-09-04 10:28:30 +00:00
|
|
|
|
tstRslt.DiverterEnd = outPath.Diverter.SwitchTimeEnd.Val;
|
2018-06-08 12:52:34 +00:00
|
|
|
|
tstRslt.DivEnd90 = 0;
|
|
|
|
|
|
tstRslt.DivEnd50 = 0;
|
|
|
|
|
|
tstRslt.DivEnd10 = 0;
|
|
|
|
|
|
log.DebugFormat("Diverter switch time [s]: Start: {0}ms ({1} {2} {3}) End: {4}ms ({5} {6} {7})",
|
|
|
|
|
|
(tstRslt.DiverterStart * 1000).ToString("F0"), tstRslt.DivStart10, tstRslt.DivStart50, tstRslt.DivStart90,
|
|
|
|
|
|
(tstRslt.DiverterEnd * 1000).ToString("F0"), tstRslt.DivEnd90, tstRslt.DivEnd50, tstRslt.DivEnd10);
|
2022-05-02 07:28:16 +00:00
|
|
|
|
|
2019-12-03 09:32:46 +00:00
|
|
|
|
long infoFlags = 0;
|
2022-05-02 07:28:16 +00:00
|
|
|
|
tstRslt.ErrorFlags = (ErrorFlagsComp != null)
|
|
|
|
|
|
? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, tstRslt.DiverterStart, tstRslt.DiverterEnd, out infoFlags, out stopCycle)
|
|
|
|
|
|
: 0;
|
2019-12-03 09:32:46 +00:00
|
|
|
|
tstRslt.InfoFlags = infoFlags;
|
2017-08-19 10:07:57 +00:00
|
|
|
|
|
2016-08-17 10:24:24 +00:00
|
|
|
|
if (compoundTestParams != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Compound meters
|
|
|
|
|
|
///
|
|
|
|
|
|
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
|
|
|
|
|
{
|
2019-01-14 13:32:26 +00:00
|
|
|
|
if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue;
|
2016-08-17 10:24:24 +00:00
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Common.CompoundMeterId.CompoundMain);
|
|
|
|
|
|
Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Common.CompoundMeterId.CompoundAux);
|
2016-08-17 10:24:24 +00:00
|
|
|
|
|
|
|
|
|
|
for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux
|
|
|
|
|
|
{
|
2020-11-13 10:33:33 +00:00
|
|
|
|
GenericDevices.IRegReader regReader = sensPath.RegisterReaders[2 * i + isAux];
|
2016-08-17 10:24:24 +00:00
|
|
|
|
Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt;
|
|
|
|
|
|
|
|
|
|
|
|
if (meterRslt != null && regReader != null)
|
|
|
|
|
|
{
|
2018-04-10 14:10:44 +00:00
|
|
|
|
meterRslt.RegReaderType = (int)regReader.RegisterReaderType;
|
2018-02-26 11:18:04 +00:00
|
|
|
|
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
|
2016-08-17 10:24:24 +00:00
|
|
|
|
|
|
|
|
|
|
/// Optionally supress pulses from the large water meter
|
|
|
|
|
|
meterRslt.PulsesMeter = (isAux == 0 && compoundTestParams.SupressTrills) ? 0 : Convert.ToDouble(regReader.WMPulses);
|
|
|
|
|
|
meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses);
|
|
|
|
|
|
|
2020-05-14 08:44:36 +00:00
|
|
|
|
meterRslt.TestTime = cBrd.TestTimeWM(regReader.Position);
|
2016-08-17 10:24:24 +00:00
|
|
|
|
meterRslt.VolumeStart = 0;
|
|
|
|
|
|
meterRslt.VolumeEnd = 0;
|
|
|
|
|
|
meterRslt.VolumeRef = tstRslt.VolumeCTV;
|
|
|
|
|
|
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter
|
|
|
|
|
|
|
|
|
|
|
|
if (meterRslt.PulsesMaster != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
meterRslt.VolumeMeter *= (tstRslt.PulsesMaster / meterRslt.PulsesMaster);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV); /// Main/Aux meter error is not usedfor evaluation
|
2016-08-17 10:24:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Common.CompoundMeterId.Compound);
|
2016-08-17 10:24:24 +00:00
|
|
|
|
|
|
|
|
|
|
if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV;
|
|
|
|
|
|
compoundMeterRslt.VolumeMeter = mainMeterRslt.VolumeMeter + auxMeterRslt.VolumeMeter;
|
|
|
|
|
|
compoundMeterRslt.PulsesMaster = tstRslt.PulsesMaster;
|
|
|
|
|
|
compoundMeterRslt.TestTime = tstRslt.TestTime;
|
2021-05-27 15:30:04 +00:00
|
|
|
|
compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef);
|
2019-01-25 15:31:26 +00:00
|
|
|
|
compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty)
|
|
|
|
|
|
&& (compoundMeterRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty)
|
2019-12-03 09:32:46 +00:00
|
|
|
|
&& (tstRslt.ErrorFlags == 0);
|
|
|
|
|
|
mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed;
|
2016-08-17 10:24:24 +00:00
|
|
|
|
mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true;
|
2017-07-04 09:19:05 +00:00
|
|
|
|
tstRslt.TestDone = true;
|
2016-08-17 10:24:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (heatMetersTestParams != null)
|
|
|
|
|
|
{
|
2016-08-24 16:30:00 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Heat meters
|
|
|
|
|
|
///
|
2016-10-07 08:09:38 +00:00
|
|
|
|
tstRslt.RefEnergy = Energy.Sum * tstRslt.VolumeCTV / VolumeForEnergy.Sum; /// [J] = [J] * [l] / [l]
|
2016-08-24 16:30:00 +00:00
|
|
|
|
|
2016-10-18 16:48:20 +00:00
|
|
|
|
tstRslt.Custom1 = (float)TempRefHiStat.Average;
|
|
|
|
|
|
tstRslt.Custom2 = (float)TempRefHiStat.First;
|
|
|
|
|
|
tstRslt.Custom3 = (float)TempRefHiStat.Last;
|
|
|
|
|
|
tstRslt.Custom4 = (float)TempRefHiStat.Min;
|
|
|
|
|
|
tstRslt.Custom5 = (float)TempRefHiStat.Max;
|
|
|
|
|
|
tstRslt.Custom6 = (float)TempRefLoStat.Average;
|
|
|
|
|
|
tstRslt.Custom7 = (float)TempRefLoStat.First;
|
|
|
|
|
|
tstRslt.Custom8 = (float)TempRefLoStat.Last;
|
|
|
|
|
|
tstRslt.Custom9 = (float)TempRefLoStat.Min;
|
|
|
|
|
|
tstRslt.Custom10 = (float)TempRefLoStat.Max;
|
2016-10-11 23:23:38 +00:00
|
|
|
|
|
2016-08-24 16:30:00 +00:00
|
|
|
|
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
|
|
|
|
|
{
|
2019-01-14 13:32:26 +00:00
|
|
|
|
if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue;
|
2016-08-24 16:30:00 +00:00
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Results.Entities.MeterTestRslt volumeRslt = BatchRslts.GetMeterTestRslt(testName, i, Common.CompoundMeterId.HeatMeterVolume);
|
|
|
|
|
|
Results.Entities.MeterTestRslt energyRslt = BatchRslts.GetMeterTestRslt(testName, i, Common.CompoundMeterId.HeatMeterEnergy);
|
2016-08-24 16:30:00 +00:00
|
|
|
|
|
2021-03-05 13:47:21 +00:00
|
|
|
|
Rig.GenericDevices.IRegReader volumeRegReader =
|
2016-10-10 09:35:09 +00:00
|
|
|
|
(sensPath.RegisterReaders.Length > 2 * i) ? sensPath.RegisterReaders[2 * i] : null;
|
2016-10-05 11:35:29 +00:00
|
|
|
|
|
2021-03-05 13:47:21 +00:00
|
|
|
|
Rig.GenericDevices.IRegReader energyRegReader =
|
2016-10-10 09:35:09 +00:00
|
|
|
|
(sensPath.RegisterReaders.Length > 2 * i + 1) ? sensPath.RegisterReaders[2 * i + 1] : null;
|
2016-10-05 11:35:29 +00:00
|
|
|
|
|
|
|
|
|
|
if (volumeRslt != null && volumeRegReader != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
volumeRslt.PulsesPerLiter = volumeRegReader.PulsesPerLtr; /// [l ^ -1]
|
|
|
|
|
|
volumeRslt.PulsesMeter = Convert.ToDouble(volumeRegReader.WMPulses);
|
|
|
|
|
|
volumeRslt.PulsesMaster = Convert.ToDouble(volumeRegReader.WMRefPulses);
|
|
|
|
|
|
volumeRslt.VolumeStart = 0;
|
|
|
|
|
|
volumeRslt.VolumeEnd = 0;
|
|
|
|
|
|
volumeRslt.VolumeMeter = volumeRslt.PulsesMeter * volumeRegReader.LtrsPerPulse; /// [l]
|
|
|
|
|
|
volumeRslt.VolumeRef = volumeRslt.PulsesMaster * tstRslt.ConstMaster; /// [l]
|
2020-05-14 08:44:36 +00:00
|
|
|
|
volumeRslt.TestTime = cBrd.TestTimeWM(i + 1); /// [s]
|
2016-10-05 11:35:29 +00:00
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
volumeRslt.Error = Formulas.ErrorFromVolumes(volumeRslt.VolumeMeter, volumeRslt.VolumeRef);
|
2016-10-10 12:29:26 +00:00
|
|
|
|
volumeRslt.Passed = !heatMetersTestParams.EvaluateVolume ||
|
2019-01-25 15:31:26 +00:00
|
|
|
|
((volumeRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty) &&
|
|
|
|
|
|
(volumeRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty) &&
|
2019-12-03 09:32:46 +00:00
|
|
|
|
(tstRslt.ErrorFlags == 0));
|
2016-10-05 11:35:29 +00:00
|
|
|
|
volumeRslt.TestDone = true;
|
2017-07-04 09:19:05 +00:00
|
|
|
|
tstRslt.TestDone = true;
|
2016-10-05 11:35:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (energyRslt != null && energyRegReader != null)
|
2016-08-24 16:30:00 +00:00
|
|
|
|
{
|
2016-10-05 11:35:29 +00:00
|
|
|
|
energyRslt.PulsesPerLiter = energyRegReader.PulsesPerLtr; /// [kWh ^ -1]
|
|
|
|
|
|
energyRslt.PulsesMeter = Convert.ToDouble(energyRegReader.WMPulses);
|
|
|
|
|
|
energyRslt.PulsesMaster = Convert.ToDouble(energyRegReader.WMRefPulses);
|
|
|
|
|
|
energyRslt.VolumeStart = 0;
|
|
|
|
|
|
energyRslt.VolumeEnd = 0;
|
2016-10-07 08:09:38 +00:00
|
|
|
|
energyRslt.VolumeRef = tstRslt.RefEnergy * (energyRslt.PulsesMaster / tstRslt.PulsesMaster); /// [J]
|
2021-05-27 15:30:04 +00:00
|
|
|
|
energyRslt.VolumeMeter = energyRslt.PulsesMeter * Common.Units.ConvertFrom(Common.Unit.kWh, energyRegReader.LtrsPerPulse); /// [J]
|
2020-05-14 08:44:36 +00:00
|
|
|
|
energyRslt.TestTime = cBrd.TestTimeWM(i + 1); /// [s]
|
2016-10-05 11:35:29 +00:00
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
energyRslt.Error = Formulas.ErrorFromVolumes(energyRslt.VolumeMeter, energyRslt.VolumeRef);
|
2016-10-10 12:29:26 +00:00
|
|
|
|
energyRslt.Passed = (energyRslt.Error >= heatMetersTestParams.ErrorLimitLo)
|
2017-08-19 10:07:57 +00:00
|
|
|
|
&& (energyRslt.Error <= heatMetersTestParams.ErrorLimitHi)
|
2019-12-03 09:32:46 +00:00
|
|
|
|
&& (tstRslt.ErrorFlags == 0);
|
2016-10-05 11:35:29 +00:00
|
|
|
|
energyRslt.TestDone = true;
|
2017-07-04 09:19:05 +00:00
|
|
|
|
tstRslt.TestDone = true;
|
2016-08-24 16:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-08-17 10:24:24 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Single meters
|
|
|
|
|
|
///
|
|
|
|
|
|
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
|
|
|
|
|
{
|
2019-01-14 13:32:26 +00:00
|
|
|
|
if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue;
|
2016-08-17 10:24:24 +00:00
|
|
|
|
|
2016-08-24 16:30:00 +00:00
|
|
|
|
/// MetersKind.Single meters
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Common.CompoundMeterId.Single);
|
2020-11-13 10:33:33 +00:00
|
|
|
|
GenericDevices.IRegReader regReader = sensPath.RegisterReaders[i];
|
|
|
|
|
|
GenericDevices.IRegReaderDatastream dstrReader = regReader as GenericDevices.IRegReaderDatastream;
|
2018-06-01 13:44:31 +00:00
|
|
|
|
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = regReader as TestMethods.iPerlCommunication.iPerlHead.IperlHead;
|
2020-11-13 10:33:33 +00:00
|
|
|
|
GenericDevices.IRegReaderLiveCamera cameraRoi = regReader as GenericDevices.IRegReaderLiveCamera;
|
2016-08-17 10:24:24 +00:00
|
|
|
|
|
2016-08-24 16:30:00 +00:00
|
|
|
|
if (meterRslt != null && regReader != null)
|
2016-08-17 10:24:24 +00:00
|
|
|
|
{
|
2018-04-10 14:10:44 +00:00
|
|
|
|
meterRslt.RegReaderType = (int)regReader.RegisterReaderType;
|
|
|
|
|
|
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
|
2016-08-24 16:30:00 +00:00
|
|
|
|
meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses);
|
2016-08-17 10:24:24 +00:00
|
|
|
|
|
2018-06-01 13:44:31 +00:00
|
|
|
|
if (dstrReader != null)
|
2016-08-17 10:24:24 +00:00
|
|
|
|
{
|
2017-08-21 13:43:23 +00:00
|
|
|
|
|
2018-06-01 13:44:31 +00:00
|
|
|
|
meterRslt.TimestampStart = dstrReader.TimestampSecStart;
|
2021-03-29 22:03:35 +00:00
|
|
|
|
meterRslt.TimestampEnd = !dstrReader.NoSamples ? dstrReader.TimestampSecEnd : (dstrReader.TimestampSecStart + tstRslt.TestTime);
|
2018-06-01 13:44:31 +00:00
|
|
|
|
meterRslt.TestTime = meterRslt.TimestampEnd - meterRslt.TimestampStart;
|
|
|
|
|
|
meterRslt.VolumeStart = dstrReader.VolumeLtrStart; /// liter
|
|
|
|
|
|
meterRslt.VolumeEnd = dstrReader.VolumeLtrEnd; /// liter
|
|
|
|
|
|
meterRslt.VolumeMeter = Math.Abs(dstrReader.VolumeLtrEnd - dstrReader.VolumeLtrStart);
|
2018-01-15 15:53:27 +00:00
|
|
|
|
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
|
2018-11-07 07:10:12 +00:00
|
|
|
|
meterRslt.PulsesMaster = tstRslt.PulsesMaster * meterRslt.TestTime / tstRslt.TestTime;
|
2018-06-01 13:44:31 +00:00
|
|
|
|
|
|
|
|
|
|
if (iPerl != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (iPerl.ResultCode != 0 && (meterRslt.WaterMeter.ResultCode & (int)Results.Entities.ResultCode.OptoErrorCodeMask) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
meterRslt.WaterMeter.ResultCode |= iPerl.ResultCode;
|
|
|
|
|
|
}
|
2017-07-14 14:31:35 +00:00
|
|
|
|
#if IPERL
|
2021-06-27 13:52:05 +00:00
|
|
|
|
meterRslt.WaterMeter.CalibFactor = iPerl.CalibFactor;
|
|
|
|
|
|
meterRslt.ExtraDataPath = iPerl.ExtraDataPath;
|
2021-07-02 14:22:46 +00:00
|
|
|
|
if (TestMethods.iPerlCommunication.iPerlHead.IperlHead.FeatureVectorSize >= 1) meterRslt.X1 = iPerl.X[0];
|
|
|
|
|
|
if (TestMethods.iPerlCommunication.iPerlHead.IperlHead.FeatureVectorSize >= 2) meterRslt.X2 = iPerl.X[1];
|
|
|
|
|
|
if (TestMethods.iPerlCommunication.iPerlHead.IperlHead.FeatureVectorSize >= 3) meterRslt.X3 = iPerl.X[2];
|
|
|
|
|
|
if (TestMethods.iPerlCommunication.iPerlHead.IperlHead.FeatureVectorSize >= 4) meterRslt.X4 = iPerl.X[3];
|
|
|
|
|
|
if (TestMethods.iPerlCommunication.iPerlHead.IperlHead.FeatureVectorSize >= 5) meterRslt.X5 = iPerl.X[4];
|
|
|
|
|
|
if (TestMethods.iPerlCommunication.iPerlHead.IperlHead.FeatureVectorSize >= 6) meterRslt.X6 = iPerl.X[5];
|
|
|
|
|
|
if (TestMethods.iPerlCommunication.iPerlHead.IperlHead.FeatureVectorSize >= 7) meterRslt.X7 = iPerl.X[6];
|
|
|
|
|
|
if (TestMethods.iPerlCommunication.iPerlHead.IperlHead.FeatureVectorSize >= 8) meterRslt.X8 = iPerl.X[7];
|
|
|
|
|
|
if (TestMethods.iPerlCommunication.iPerlHead.IperlHead.FeatureVectorSize >= 9) meterRslt.X9 = iPerl.X[8];
|
2017-07-14 14:31:35 +00:00
|
|
|
|
#endif
|
2021-06-27 13:52:05 +00:00
|
|
|
|
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
|
2018-06-01 13:44:31 +00:00
|
|
|
|
iPerl.LastTestResult = meterRslt; /// Save this test result
|
|
|
|
|
|
}
|
2021-03-29 22:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
log.DebugFormat("Datastream: Tst={0} Tend={1} Tmtr={2} Ttime={3} Vst={4} Vend={5} Vmtr={6} Vref={7}",
|
|
|
|
|
|
meterRslt.TimestampStart,
|
|
|
|
|
|
meterRslt.TimestampEnd,
|
|
|
|
|
|
meterRslt.TestTime,
|
|
|
|
|
|
tstRslt.TestTime,
|
|
|
|
|
|
meterRslt.VolumeStart,
|
|
|
|
|
|
meterRslt.VolumeEnd,
|
|
|
|
|
|
meterRslt.VolumeMeter,
|
|
|
|
|
|
meterRslt.VolumeRef);
|
2018-06-01 13:44:31 +00:00
|
|
|
|
}
|
2017-04-07 09:29:35 +00:00
|
|
|
|
else if (cameraRoi != null)
|
|
|
|
|
|
{
|
2021-03-29 22:03:35 +00:00
|
|
|
|
meterRslt.TimestampStart = cameraRoi.TimestampStart; /// [s]
|
|
|
|
|
|
meterRslt.TimestampEnd = cameraRoi.TimestampEnd; /// [s]
|
|
|
|
|
|
meterRslt.VolumeStart = cameraRoi.VolumeStart; /// [l]
|
|
|
|
|
|
meterRslt.VolumeEnd = cameraRoi.VolumeEnd; /// [l]
|
|
|
|
|
|
meterRslt.VolumeMeter = cameraRoi.VolumeEnd - cameraRoi.VolumeStart; /// [l]
|
2018-04-27 11:52:06 +00:00
|
|
|
|
|
|
|
|
|
|
if (meterRslt.VolumeMeter != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Normal measurement with camera
|
2021-03-29 22:03:35 +00:00
|
|
|
|
meterRslt.TestTime = cameraRoi.TimestampEnd - cameraRoi.TimestampStart; /// [s]
|
2018-04-27 11:52:06 +00:00
|
|
|
|
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
|
2018-11-07 07:10:12 +00:00
|
|
|
|
meterRslt.PulsesMaster = tstRslt.PulsesMaster * meterRslt.TestTime / tstRslt.TestTime;
|
2018-04-27 11:52:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// None or one pulse from the water meter using camera
|
|
|
|
|
|
meterRslt.TestTime = tstRslt.TestTime;
|
|
|
|
|
|
meterRslt.VolumeRef = tstRslt.VolumeCTV;
|
2018-11-07 07:10:12 +00:00
|
|
|
|
meterRslt.PulsesMaster = tstRslt.PulsesMaster;
|
2018-04-27 11:52:06 +00:00
|
|
|
|
}
|
2021-03-29 22:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
log.DebugFormat("Camera: Tst={0} Tend={1} Tmtr={2} Ttime={3} Vst={4} Vend={5} Vmtr={6} Vref={7}",
|
|
|
|
|
|
meterRslt.TimestampStart,
|
|
|
|
|
|
meterRslt.TimestampEnd,
|
|
|
|
|
|
meterRslt.TestTime,
|
|
|
|
|
|
tstRslt.TestTime,
|
|
|
|
|
|
meterRslt.VolumeStart,
|
|
|
|
|
|
meterRslt.VolumeEnd,
|
|
|
|
|
|
meterRslt.VolumeMeter,
|
|
|
|
|
|
meterRslt.VolumeRef);
|
|
|
|
|
|
}
|
2016-08-24 16:30:00 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2018-11-07 07:10:12 +00:00
|
|
|
|
meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses);
|
2021-03-29 22:03:35 +00:00
|
|
|
|
meterRslt.VolumeStart = 0;
|
|
|
|
|
|
meterRslt.VolumeEnd = 0;
|
|
|
|
|
|
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// [l]
|
|
|
|
|
|
|
2018-10-24 13:04:51 +00:00
|
|
|
|
if (regReader.WMPulses >= 1)
|
2018-04-27 11:52:06 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// Normal measurement
|
2020-05-14 08:44:36 +00:00
|
|
|
|
meterRslt.TestTime = cBrd.TestTimeWM(regReader.Position);
|
2021-03-29 22:03:35 +00:00
|
|
|
|
meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// [l]
|
2018-04-27 11:52:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// None or one pulse from the water meter
|
|
|
|
|
|
meterRslt.TestTime = tstRslt.TestTime;
|
2021-03-29 22:03:35 +00:00
|
|
|
|
meterRslt.VolumeRef = tstRslt.VolumeCTV; /// [l]
|
2018-04-27 11:52:06 +00:00
|
|
|
|
}
|
2021-03-29 22:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
log.DebugFormat("Pulses: Pref4meter={0} Vmeter={1} Vref4meter={2} Ttime4meter={3} Ttime={4}",
|
|
|
|
|
|
meterRslt.PulsesMaster,
|
|
|
|
|
|
meterRslt.VolumeMeter,
|
|
|
|
|
|
meterRslt.VolumeRef,
|
|
|
|
|
|
meterRslt.TestTime,
|
|
|
|
|
|
tstRslt.TestTime);
|
|
|
|
|
|
}
|
2016-08-24 16:30:00 +00:00
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
|
2019-01-25 15:31:26 +00:00
|
|
|
|
meterRslt.Passed = (meterRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty)
|
|
|
|
|
|
&& (meterRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty)
|
2019-12-03 09:32:46 +00:00
|
|
|
|
&& (tstRslt.ErrorFlags == 0);
|
|
|
|
|
|
meterRslt.TestDone = true;
|
2017-07-04 09:19:05 +00:00
|
|
|
|
tstRslt.TestDone = true;
|
2021-07-02 14:22:46 +00:00
|
|
|
|
#if ORACLE_DB
|
|
|
|
|
|
meterRslt.ErrorBC = meterRslt.Error;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
2016-08-17 10:24:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tstRslt.Components = Results.Entities.Components.UpdateList(BatchRslts.ComponentsList,
|
|
|
|
|
|
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
|
|
|
|
|
|
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
|
|
|
|
|
|
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
|
|
|
|
|
|
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
|
2020-05-14 08:44:36 +00:00
|
|
|
|
cBrd.Devices.Scale.Name,
|
2021-02-25 12:38:24 +00:00
|
|
|
|
outPath.RegValve != null ? outPath.RegValve.Name : string.Empty,
|
2016-08-17 10:24:24 +00:00
|
|
|
|
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-09-27 21:04:30 +00:00
|
|
|
|
/// Update water meter error flags
|
2017-10-04 11:07:56 +00:00
|
|
|
|
if (ErrorFlagsComp != null)
|
2017-09-27 21:04:30 +00:00
|
|
|
|
{
|
2020-01-31 14:45:30 +00:00
|
|
|
|
if (BatchRslts.Batch != null && BatchRslts.Batch.WaterMeters != null)
|
2017-09-27 21:04:30 +00:00
|
|
|
|
{
|
2020-01-31 14:45:30 +00:00
|
|
|
|
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
2017-10-04 11:07:56 +00:00
|
|
|
|
{
|
2020-01-31 14:45:30 +00:00
|
|
|
|
if (BatchRslts.Batch.WaterMeters[i] != null && !BatchRslts.Batch.WaterMeters[i].Disabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
long wmInfoFlags;
|
|
|
|
|
|
BatchRslts.Batch.WaterMeters[i].ErrorFlags = ErrorFlagsComp.GetWMtrErrorFlags(BatchRslts.Batch.WaterMeters[i].MeterTestRslts, out wmInfoFlags);
|
|
|
|
|
|
BatchRslts.Batch.WaterMeters[i].InfoFlags = wmInfoFlags;
|
|
|
|
|
|
}
|
2017-10-04 11:07:56 +00:00
|
|
|
|
}
|
2017-09-27 21:04:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-13 18:25:43 +00:00
|
|
|
|
/// Update results
|
|
|
|
|
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt));
|
|
|
|
|
|
}
|
2016-01-08 18:18:45 +00:00
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.TransitionAfter));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
/// Append the results to the CSV-file
|
2016-01-03 01:05:35 +00:00
|
|
|
|
allResults.Info(TestResult2CsvLine(testName, test.Part));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2021-06-27 14:07:21 +00:00
|
|
|
|
if (stopCycle) retVal = Event.ErrorFlagsStop;
|
|
|
|
|
|
|
2014-08-15 12:31:45 +00:00
|
|
|
|
stopTest:
|
|
|
|
|
|
|
2018-02-11 15:31:25 +00:00
|
|
|
|
StopRecordingStatistics(); /// Make sure graph files are closed
|
|
|
|
|
|
|
2017-12-08 10:45:37 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Quit this sequence
|
|
|
|
|
|
///
|
2021-03-23 08:47:07 +00:00
|
|
|
|
if (isLastRepetition || retVal == Event.UiCmdStop
|
|
|
|
|
|
|| retVal == Event.OpArgumentError
|
2021-06-27 14:07:21 +00:00
|
|
|
|
|| retVal == Event.RecoverableError
|
|
|
|
|
|
|| retVal == Event.ErrorFlagsStop
|
2021-03-23 08:47:07 +00:00
|
|
|
|
|| retVal == Event.Error
|
|
|
|
|
|
|| retVal == Event.ConfigurationError)
|
|
|
|
|
|
{
|
2021-05-21 13:47:22 +00:00
|
|
|
|
cBrd.StopAll(false);
|
2017-12-02 16:54:38 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2019-03-18 08:14:13 +00:00
|
|
|
|
return new List<Event> { retVal };
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
2018-10-22 16:14:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IList<Event> Simulate1(Config.Entities.Test test, int repetitionNr, bool isLastRepetition,
|
|
|
|
|
|
Compound.CombinedTestParams compoundTestParams,
|
|
|
|
|
|
HeatMeters.TestParams heatMetersTestParams)
|
|
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Test method simulation
|
|
|
|
|
|
///
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.FlowSetting));
|
2018-10-22 16:14:47 +00:00
|
|
|
|
|
2020-02-24 14:12:02 +00:00
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
|
|
|
|
{
|
2022-01-25 15:16:12 +00:00
|
|
|
|
if (rr is IRegReaderDatastream) (rr as IRegReaderDatastream).TestIsGoingToStartSoon(test, repetitionNr);
|
2020-02-24 14:12:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Reading watermeters", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-22 16:14:47 +00:00
|
|
|
|
if (compoundTestParams != null)
|
|
|
|
|
|
{
|
2020-02-07 09:03:42 +00:00
|
|
|
|
if (test.Name.ToLower().Contains("nok")) MakeSimulatedCompound(test, 1, test.Part, 4.7f, 0.9f);
|
|
|
|
|
|
else MakeSimulatedCompound(test, repetitionNr, test.Part, 0.7f, 1.0f);
|
2018-10-22 16:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
else if (heatMetersTestParams != null)
|
|
|
|
|
|
{
|
2020-02-07 09:03:42 +00:00
|
|
|
|
MakeSimulatedHeatMeters(test, repetitionNr, test.Part, 1.5f, 1000000, heatMetersTestParams.ErrorLimitLo, heatMetersTestParams.ErrorLimitHi, heatMetersTestParams.EvaluateVolume);
|
2018-10-22 16:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
float errorPctBase = -1.0f;
|
|
|
|
|
|
if (test.Name.ToLower().Contains("q3")) errorPctBase = -0.5f;
|
|
|
|
|
|
else if (test.Name.ToLower().Contains("q2")) errorPctBase = 0.5f;
|
|
|
|
|
|
else if (test.Name.ToLower().Contains("q1")) errorPctBase = -5.1f;
|
|
|
|
|
|
|
2020-02-07 09:03:42 +00:00
|
|
|
|
MakeSimulated(test, repetitionNr, test.Part, errorPctBase + repetitionNr * 0.1f);
|
2018-10-22 16:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Completed));
|
2018-10-22 16:14:47 +00:00
|
|
|
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, 1, 1), 0)));
|
|
|
|
|
|
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, string.Format("{0} Simulation", test.Name));
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Simulation", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
IList<Event> e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
|
2019-03-18 08:14:13 +00:00
|
|
|
|
return new List<Event> { TestAndLogUiCmdStop(test, e) ? Event.UiCmdStop : Event.Done };
|
2018-10-22 16:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IList<Event> Simulate2(Config.Entities.Test test, int repetitionNr, bool isLastRepetition,
|
|
|
|
|
|
Compound.CombinedTestParams compoundTestParams,
|
|
|
|
|
|
HeatMeters.TestParams heatMetersTestParams)
|
|
|
|
|
|
{
|
|
|
|
|
|
IList<Event> e;
|
|
|
|
|
|
Event retVal = Event.Done;
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Test method with flow chart simulation
|
|
|
|
|
|
///
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.FlowSetting));
|
2018-10-22 16:14:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Simulate flow
|
2022-05-02 07:28:16 +00:00
|
|
|
|
StartNewStatistics(null, BatchRslts.Batch.BatchNr, test, repetitionNr, 0);
|
2018-10-22 16:14:47 +00:00
|
|
|
|
|
2021-02-24 16:42:50 +00:00
|
|
|
|
IntBox remainingTime = new IntBox((int)test.TestTime);
|
2018-10-22 16:14:47 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Simulation", test.Method, test.Name))
|
2022-05-02 07:28:16 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp((int)test.TestTime, remainingTime))
|
|
|
|
|
|
.EnterState();
|
2018-10-22 16:14:47 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; }
|
|
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test));
|
2018-10-22 16:14:47 +00:00
|
|
|
|
|
|
|
|
|
|
if (remainingTime.Val > 60)
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime.Val / 60, "min", remainingTime.Val % 60, Strings.sec));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime.Val));
|
|
|
|
|
|
}
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
|
2021-02-24 16:42:50 +00:00
|
|
|
|
RefFlow.Val = (1.0 + 0.2 * Math.Sin(2 * Math.PI * (float)remainingTime.Val / test.TestTime)) * (test.Qfrom + test.Qto) / 2.0;
|
2018-10-22 16:14:47 +00:00
|
|
|
|
PressUp.Val = 2.7f;
|
|
|
|
|
|
PressDown.Val = 2.2f;
|
|
|
|
|
|
|
2022-05-02 07:28:16 +00:00
|
|
|
|
UpdateAllStatistics();
|
2018-10-22 16:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.TimerExpired));
|
|
|
|
|
|
|
|
|
|
|
|
StopRecordingStatistics();
|
|
|
|
|
|
|
|
|
|
|
|
if (retVal != Event.UiCmdStop)
|
|
|
|
|
|
{
|
|
|
|
|
|
float errorPctBase = -1.0f;
|
|
|
|
|
|
|
|
|
|
|
|
if (test.Name.ToLower().Contains("q3")) errorPctBase = -0.5f;
|
|
|
|
|
|
else if (test.Name.ToLower().Contains("q2")) errorPctBase = 0.5f;
|
|
|
|
|
|
else if (test.Name.ToLower().Contains("q1")) errorPctBase = -5.1f;
|
|
|
|
|
|
|
2020-02-07 09:03:42 +00:00
|
|
|
|
MakeSimulated(test, repetitionNr, test.Part, errorPctBase + repetitionNr * 0.1f);
|
2018-10-22 16:14:47 +00:00
|
|
|
|
|
2021-05-27 15:30:04 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Completed));
|
2018-10-22 16:14:47 +00:00
|
|
|
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, 1, 1), 0)));
|
|
|
|
|
|
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-03-18 08:14:13 +00:00
|
|
|
|
return new List<Event> { retVal }; /// default 'retVal' value is Event.Done
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|