2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
2019-03-18 08:14:13 +00:00
|
|
|
|
/// Copyright (c) 2013-2019 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;
|
|
|
|
|
|
using TBF.BenchControl;
|
|
|
|
|
|
using TBF.Resources;
|
2014-07-31 15:04:09 +00:00
|
|
|
|
using TBF.UiBridge;
|
2018-10-22 16:14:47 +00:00
|
|
|
|
using TBF.BenchControl.GenericDevices;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.TestMethods.CombinedWithDetection
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CombinedWithDetectionSeq : Sequences.SequenceBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(CombinedWithDetectionSeq));
|
|
|
|
|
|
|
|
|
|
|
|
const int DetectionBufferSize = 9;
|
|
|
|
|
|
const int DetectionKernelSize = 5;
|
|
|
|
|
|
|
2017-12-02 16:54:38 +00:00
|
|
|
|
public IList<Event> Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition,
|
2016-10-11 07:59:59 +00:00
|
|
|
|
CombinedWithDetTestParams testParams,
|
|
|
|
|
|
Config.Entities.DebugMode debugLevel)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2016-10-11 07:59:59 +00:00
|
|
|
|
if (debugLevel == Config.Entities.DebugMode.Simulate)
|
|
|
|
|
|
{
|
2018-11-12 13:16:03 +00:00
|
|
|
|
return Simulate(test, repetitionNr, isLastRepetition, testParams);
|
2018-10-22 16:14:47 +00:00
|
|
|
|
}
|
2016-10-11 07:59:59 +00:00
|
|
|
|
|
2019-05-10 14:26:58 +00:00
|
|
|
|
int rangeIx = 0; /// Default range, used for non-Elde flowmeters
|
|
|
|
|
|
if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter)
|
2019-05-02 07:36:33 +00:00
|
|
|
|
{
|
2019-05-10 14:26:58 +00:00
|
|
|
|
Elde.FlowMeter.FlowMeter eldeFM = outPath.FlowMeter as Elde.FlowMeter.FlowMeter;
|
|
|
|
|
|
rangeIx = -1; /// Indicates invalid range
|
|
|
|
|
|
for (int r = 0; r <= 5; r++)
|
2019-05-02 07:36:33 +00:00
|
|
|
|
{
|
2019-05-10 14:26:58 +00:00
|
|
|
|
if (eldeFM.RangeEnabled(r) && eldeFM.GetTempLo(r) <= test.TempLimLo
|
|
|
|
|
|
&& eldeFM.GetTempHi(r) >= test.TempLimHi)
|
2019-05-02 07:36:33 +00:00
|
|
|
|
{
|
2019-05-10 14:26:58 +00:00
|
|
|
|
rangeIx = r;
|
2019-05-02 07:36:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-05-10 14:26:58 +00:00
|
|
|
|
|
|
|
|
|
|
if (rangeIx == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions);
|
|
|
|
|
|
return new List<Event> { Event.ConfigurationError };
|
|
|
|
|
|
}
|
2019-05-02 07:36:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-22 16:14:47 +00:00
|
|
|
|
IScale scale = outPath.Scale as IScale;
|
|
|
|
|
|
if (scale == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, Strings.Missing_a_scale);
|
2019-05-10 14:26:58 +00:00
|
|
|
|
return new List<Event> { Event.ConfigurationError };
|
|
|
|
|
|
}
|
2016-10-11 07:59:59 +00:00
|
|
|
|
|
2018-10-22 16:14:47 +00:00
|
|
|
|
if (test.Part < 1 || test.Part > Config.Data.CompoundWMsCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
UiBridge.Bridge.OnError(this, string.Format("Test 'Part' should be 1 .. {0}", Config.Data.CompoundWMsCount));
|
2019-05-10 14:26:58 +00:00
|
|
|
|
return new List<Event> { Event.ConfigurationError };
|
|
|
|
|
|
}
|
2016-10-11 07:59:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
2019-05-10 14:26:58 +00:00
|
|
|
|
IList<Event> e; /// Events from currently running operations
|
|
|
|
|
|
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
|
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
|
2019-05-10 14:26:58 +00:00
|
|
|
|
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
|
|
|
|
if (sensPath != null && sensPath.RegisterReaders != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
|
|
|
|
{
|
|
|
|
|
|
TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader;
|
|
|
|
|
|
if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8))
|
|
|
|
|
|
{
|
|
|
|
|
|
filters[eldeRR.Position - 1] = eldeRR.Filter;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1);
|
2018-10-22 16:14:47 +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));
|
|
|
|
|
|
if (outPath.TempDiv != null) readTempPressOps.Add(outPath.TempDiv.ReadTempOp(ref TempDiv));
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
2018-10-22 16:14:47 +00:00
|
|
|
|
float switchTimeStart = 0.001f; /// in seconds, original vale is 1 ms
|
|
|
|
|
|
float switchTimeEnd = 0.001f; /// in seconds, original vale is 1 ms
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
/// Specific for combined meters
|
2015-12-04 16:17:20 +00:00
|
|
|
|
int[] lastWMPulses = new int[2 * Config.Data.CompoundWMsCount];
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
//--------------------------------
|
2018-07-17 07:15:43 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Stop diverter gate etc", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2019-07-04 13:20:10 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(cBrd.StopPreviousOp())
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.PreviousStopped));
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-10 18:24:10 +00:00
|
|
|
|
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
|
2014-09-12 05:17:30 +00:00
|
|
|
|
|
|
|
|
|
|
/// Notes:
|
|
|
|
|
|
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
|
|
|
|
|
|
/// float timeSec = 3600.0f * timeHr;
|
|
|
|
|
|
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
|
2018-07-13 11:00:03 +00:00
|
|
|
|
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
|
|
|
|
|
|
|
2014-09-09 14:18:23 +00:00
|
|
|
|
/// Meters path is required for the following:
|
2016-02-13 15:47:15 +00:00
|
|
|
|
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
//====================================
|
|
|
|
|
|
loop:
|
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)) { goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.Busy));
|
|
|
|
|
|
|
|
|
|
|
|
/// Start the test, initialize test results
|
|
|
|
|
|
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses));
|
2016-01-03 01:05:35 +00:00
|
|
|
|
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
|
|
|
|
|
TestStartTime = DateTime.Now;
|
2017-12-02 16:54:38 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2016-01-03 01:05:35 +00:00
|
|
|
|
Qrise = 0;
|
|
|
|
|
|
Qfall = 0;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-06-08 13:42:47 +00:00
|
|
|
|
if (!test.DoDraining) /// Do not skip emptying if test.Emptying==true
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
//--------------------------------
|
2018-07-13 11:00:03 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Mesuring mass of water in the tank", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(scale.ReadMassOp(ref Mass))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.BalanceDone));
|
|
|
|
|
|
|
2016-10-07 12:06:54 +00:00
|
|
|
|
double estimatedEndMass = Mass.Val + test.Volume;
|
2018-10-22 16:14:47 +00:00
|
|
|
|
if (estimatedEndMass < scale.Capacity * Constants.TankFullFactor)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
goto switching_flow_detection; /// Enough room in the tank -> skip emptying
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-17 07:15:43 +00:00
|
|
|
|
/// Empty the water tank
|
2019-03-18 08:14:13 +00:00
|
|
|
|
switch (DrainTheTank(scale, readTempPressOps))
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
case Event.Error: goto error;
|
2015-04-28 13:27:47 +00:00
|
|
|
|
case Event.UiCmdStop: goto stopTest;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switching_flow_detection:
|
|
|
|
|
|
|
2016-01-03 01:05:35 +00:00
|
|
|
|
int flowDetectTime0 = StateMachine.Time;
|
|
|
|
|
|
int flowDetectTime = 0;
|
2014-08-01 06:36:17 +00:00
|
|
|
|
float estFlowSetTime = 100.0f;
|
|
|
|
|
|
|
2017-01-22 19:39:14 +00:00
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Prepare cameras, ROI-s and measurementOperations
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
|
|
/// Find ROI-s
|
2018-08-23 09:39:11 +00:00
|
|
|
|
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
|
2017-01-22 19:39:14 +00:00
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
|
|
|
|
{
|
2019-05-02 07:36:33 +00:00
|
|
|
|
GenericDevices.IRoi cameraRoI = rr as GenericDevices.IRoi;
|
|
|
|
|
|
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
|
|
|
|
}
|
2019-05-02 07:36:33 +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)
|
|
|
|
|
|
{
|
2017-01-24 17:55:36 +00:00
|
|
|
|
if (roi.Camera != null && !cameras.Contains(roi.Camera))
|
2017-01-22 19:39:14 +00:00
|
|
|
|
{
|
2017-04-06 16:55:01 +00:00
|
|
|
|
roi.Camera.ClearRoiParams();
|
2017-01-22 19:39:14 +00:00
|
|
|
|
cameras.Add(roi.Camera);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 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
|
|
|
|
|
|
IList<IOperation> measureOperations = new List<IOperation>();
|
2017-01-24 09:50:53 +00:00
|
|
|
|
foreach (var camera in cameras) measureOperations.Add(camera.MeasurementOp());
|
2017-01-24 17:55:36 +00:00
|
|
|
|
|
2017-01-22 19:39:14 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Switching_flow_detection);
|
|
|
|
|
|
//------------------------------------------------
|
2018-07-13 11:00:03 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Start the pump", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperations(measureOperations)
|
|
|
|
|
|
.AddOperation((inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOnOp(test.PumpPower) : null)
|
|
|
|
|
|
.AddOperation(cBrd.SetValvesOp(inPath.Pump, null))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-01-08 18:18:45 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.SwitchingFlowDetection));
|
2014-08-01 06:36:17 +00:00
|
|
|
|
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
|
2018-07-17 07:15:43 +00:00
|
|
|
|
|
2018-07-13 11:00:03 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Set the initial flow", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperations(measureOperations)
|
2019-05-10 14:26:58 +00:00
|
|
|
|
.AddOperation(outPath.RegulValve.SetFlowAndMeasureOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec, (float)test.TolerRed))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-01-08 18:18:45 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.SwitchingFlowDetection));
|
2014-08-01 06:36:17 +00:00
|
|
|
|
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2015-01-12 04:56:19 +00:00
|
|
|
|
if (e.Contains(Event.RegulValveTimeOut))
|
|
|
|
|
|
{
|
2018-06-05 09:16:13 +00:00
|
|
|
|
Bridge.OnError(this, Strings.Flow_adjustment_failed);
|
2018-06-27 08:31:22 +00:00
|
|
|
|
goto stopTest;
|
2015-01-12 04:56:19 +00:00
|
|
|
|
}
|
2018-07-17 10:16:52 +00:00
|
|
|
|
if (e.Contains(Event.Next)) goto init_flow_set;
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
while (!e.Contains(Event.FlowReached));
|
|
|
|
|
|
|
2018-07-17 07:15:43 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
switch (ReadRegistersTempPressAmbient(measureOperations, false))
|
|
|
|
|
|
{
|
|
|
|
|
|
case Event.Error: goto error;
|
2015-04-28 13:27:47 +00:00
|
|
|
|
case Event.UiCmdStop: goto stopTest;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-17 10:16:52 +00:00
|
|
|
|
|
|
|
|
|
|
init_flow_set:
|
|
|
|
|
|
|
|
|
|
|
|
//====================================
|
|
|
|
|
|
// Find the switching flow
|
|
|
|
|
|
//====================================
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
/// Allocate detection buffers
|
2018-07-17 07:15:43 +00:00
|
|
|
|
double[] flowsForDetection = new double[DetectionBufferSize]; /// in [m3/h]
|
2016-10-07 14:22:36 +00:00
|
|
|
|
double[] pulseFreqsForDetection = new double[DetectionBufferSize];
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
/// Current values
|
2015-12-20 19:48:50 +00:00
|
|
|
|
flowsForDetection[0] = RefFlow.Val;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
pulseFreqsForDetection[0] = 0.0f;
|
2014-08-01 06:36:17 +00:00
|
|
|
|
int startTime = StateMachine.Time;
|
|
|
|
|
|
int lastTime = StateMachine.Time;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
/// Detection parameters
|
2018-07-17 07:15:43 +00:00
|
|
|
|
float rvPulse = (testParams.TargetQ > (test.Qfrom + test.Qto) / 2.0f) ? 0.05f : -0.05f; /// rise(+) or fall(-)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
rvPulse *= (100.0f * testParams.RateOfChange);
|
2018-07-17 07:15:43 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
bool detected = false;
|
|
|
|
|
|
bool targetReached = false;
|
2016-10-07 14:22:36 +00:00
|
|
|
|
double detectedFlow = 0;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-08-01 08:54:38 +00:00
|
|
|
|
int detectionStartTime = StateMachine.Time;
|
2016-01-08 18:18:45 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.SwitchingFlowDetection));
|
2014-08-01 08:54:38 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
do
|
2018-07-17 07:15:43 +00:00
|
|
|
|
{
|
2018-07-13 11:00:03 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Change the RV position", test.Method, test.Name))
|
2018-07-17 07:15:43 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
2018-07-17 07:15:43 +00:00
|
|
|
|
.AddOperations(measureOperations)
|
|
|
|
|
|
.AddOperation(outPath.RegulValve.ChangeRegulValvePositionOp(rvPulse))
|
|
|
|
|
|
.EnterState();
|
2019-03-18 08:14:13 +00:00
|
|
|
|
do {
|
2018-07-17 07:15:43 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.SwitchingFlowDetection));
|
2014-08-01 06:36:17 +00:00
|
|
|
|
|
2018-07-17 07:15:43 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) goto stopTest;
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
while (!e.Contains(Event.PositionReached));
|
|
|
|
|
|
|
|
|
|
|
|
{
|
2018-07-17 07:15:43 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Update FIFO buffers for the reference flow and the frequency of pulses
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
|
|
/// Last pulses are kept to calculate differences
|
|
|
|
|
|
for (int i = 0; i < 2 * Config.Data.CompoundWMsCount; i++) lastWMPulses[i] = RegisterReaders[i].WMPulses;
|
|
|
|
|
|
|
|
|
|
|
|
/// Shift data in the detection buffers
|
|
|
|
|
|
for (int i = DetectionBufferSize - 2; i >= 0; i--)
|
|
|
|
|
|
{
|
|
|
|
|
|
flowsForDetection[i + 1] = flowsForDetection[i];
|
|
|
|
|
|
pulseFreqsForDetection[i + 1] = pulseFreqsForDetection[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (ReadRegistersTempPressAmbient(measureOperations, false))
|
|
|
|
|
|
{
|
|
|
|
|
|
case Event.Error: goto error;
|
|
|
|
|
|
case Event.UiCmdStop: goto stopTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0;
|
2019-07-04 13:20:10 +00:00
|
|
|
|
double diff = RegisterReaders[(test.Part - 1) * 2 + 1].WMPulses - lastWMPulses[(test.Part - 1) * 2 + 1];
|
|
|
|
|
|
pulseFreqsForDetection[0] = diff / (double)(StateMachine.Time - lastTime);
|
2018-07-17 07:15:43 +00:00
|
|
|
|
lastTime = StateMachine.Time;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-17 07:15:43 +00:00
|
|
|
|
if ((StateMachine.Time - detectionStartTime > 15) && (flowsForDetection[0] > 0) && (flowsForDetection[DetectionBufferSize - 1] > 0))
|
|
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Evaluate ref. flow and WM pulses frequency data in FIFO buffers.
|
|
|
|
|
|
/// Updpate 'detected' and 'targetReached' flags.
|
|
|
|
|
|
///
|
|
|
|
|
|
double[] flowBefore = new double[DetectionKernelSize];
|
|
|
|
|
|
double[] flowAfter = new double[DetectionKernelSize];
|
|
|
|
|
|
double[] freqBefore = new double[DetectionKernelSize];
|
|
|
|
|
|
double[] freqAfter = new double[DetectionKernelSize];
|
|
|
|
|
|
for (int i = 0; i < DetectionKernelSize; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
flowBefore[i] = flowsForDetection[DetectionBufferSize - DetectionKernelSize + i]; /// The oldest DetectionKernelSize samples
|
|
|
|
|
|
freqBefore[i] = pulseFreqsForDetection[DetectionBufferSize - DetectionKernelSize + i];
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2018-07-17 07:15:43 +00:00
|
|
|
|
flowAfter[i] = flowsForDetection[i]; /// The newest DetectionKernelSize samples
|
|
|
|
|
|
freqAfter[i] = pulseFreqsForDetection[i];
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2018-07-17 07:15:43 +00:00
|
|
|
|
/// Skip the smallest and the largest flow
|
|
|
|
|
|
Array.Sort(flowBefore);
|
|
|
|
|
|
Array.Sort(flowAfter);
|
|
|
|
|
|
flowBefore[0] = 0;
|
|
|
|
|
|
flowAfter[0] = 0;
|
|
|
|
|
|
flowBefore[DetectionKernelSize - 1] = 0;
|
|
|
|
|
|
flowAfter[DetectionKernelSize - 1] = 0;
|
|
|
|
|
|
///
|
|
|
|
|
|
double aveFlowBefore = 0;
|
|
|
|
|
|
double aveFlowAfter = 0;
|
|
|
|
|
|
foreach (var f in flowBefore) aveFlowBefore += f;
|
|
|
|
|
|
foreach (var f in flowAfter) aveFlowAfter += f;
|
|
|
|
|
|
aveFlowBefore /= (double)(DetectionKernelSize - 2);
|
|
|
|
|
|
aveFlowAfter /= (double)(DetectionKernelSize - 2);
|
|
|
|
|
|
|
|
|
|
|
|
/// Do NOT skip the smallest and the largest flow
|
|
|
|
|
|
//Array.Sort(freqBefore);
|
|
|
|
|
|
//Array.Sort(freqAfter);
|
|
|
|
|
|
//freqBefore[0] = 0;
|
|
|
|
|
|
//freqAfter[0] = 0;
|
|
|
|
|
|
//freqBefore[DetectionKernelSize - 1] = 0;
|
|
|
|
|
|
//freqAfter[DetectionKernelSize - 1] = 0;
|
|
|
|
|
|
///
|
|
|
|
|
|
double aveFreqBefore = 0;
|
|
|
|
|
|
double aveFreqAfter = 0;
|
|
|
|
|
|
foreach (var f in freqBefore) aveFreqBefore += f;
|
|
|
|
|
|
foreach (var f in freqAfter) aveFreqAfter += f;
|
|
|
|
|
|
aveFreqBefore /= (double)DetectionKernelSize;
|
|
|
|
|
|
aveFreqAfter /= (double)DetectionKernelSize;
|
|
|
|
|
|
|
2020-03-05 12:59:43 +00:00
|
|
|
|
//UiBridge.Bridge.OnEvent(this, string.Format("time={0}, flow{1}, aveFlowB={2}, aveFlowA={3}, pulseFreq={4}, aveFreqB={5}, aveFreqA={6}\r\n",
|
|
|
|
|
|
// StateMachine.Time - startTime,
|
|
|
|
|
|
// flowsForDetection[0].ToString("F2"),
|
|
|
|
|
|
// aveFlowBefore.ToString("F2"),
|
|
|
|
|
|
// aveFlowAfter.ToString("F2"),
|
|
|
|
|
|
// pulseFreqsForDetection[0].ToString("F2"),
|
|
|
|
|
|
// aveFreqBefore.ToString("F2"),
|
|
|
|
|
|
// aveFreqAfter.ToString("F2")));
|
2018-07-17 07:15:43 +00:00
|
|
|
|
|
2019-07-04 13:20:10 +00:00
|
|
|
|
//detectedFlow = (aveFlowBefore + aveFlowAfter) / 2;
|
2018-07-17 07:15:43 +00:00
|
|
|
|
detectedFlow = aveFlowBefore;
|
|
|
|
|
|
|
|
|
|
|
|
if (rvPulse > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// rise
|
2019-07-04 13:20:10 +00:00
|
|
|
|
detected = (aveFreqAfter < aveFreqBefore * (1 - testParams.DetectionThreshold));
|
|
|
|
|
|
targetReached = ((aveFlowAfter + aveFlowBefore) / 2) > testParams.TargetQ;
|
2018-07-17 07:15:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// fall
|
2019-07-04 13:20:10 +00:00
|
|
|
|
detected = (aveFreqAfter > (aveFreqBefore + testParams.OffsetPulsesFreq) * (1 + testParams.DetectionThreshold));
|
|
|
|
|
|
targetReached = ((aveFlowAfter + aveFlowBefore) / 2) < testParams.TargetQ;
|
2018-07-17 07:15:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
while (!detected && !targetReached);
|
|
|
|
|
|
|
|
|
|
|
|
if (rvPulse > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Qrise = detectedFlow;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Qfall = detectedFlow;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-05 12:59:43 +00:00
|
|
|
|
//UiBridge.Bridge.OnEvent(this, string.Format("detected flow={0}\r\n", detectedFlow.ToString("F2")));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2016-10-07 14:22:36 +00:00
|
|
|
|
float qfrom_detected = (float)(detectedFlow + testParams.RelativeQfrom);
|
|
|
|
|
|
float qto_detected = (float)(detectedFlow + testParams.RelativeQto);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
/// Update test results with the test flow determined from the detected switching flow
|
2016-01-03 01:05:35 +00:00
|
|
|
|
float Qave_lps = (qfrom_detected + qto_detected) / 7.2f;
|
|
|
|
|
|
float testTimeFromDetectedFlow = test.Volume / Qave_lps; /// Test volume wont be changed
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-08-01 06:36:17 +00:00
|
|
|
|
float relativeQave = (testParams.RelativeQfrom + testParams.RelativeQto) / 2.0f;
|
|
|
|
|
|
bool goBackToInitFlow = ((rvPulse > 0) && (relativeQave < 0)) ||
|
|
|
|
|
|
((rvPulse < 0) && (relativeQave > 0));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2016-02-10 18:24:10 +00:00
|
|
|
|
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
2016-01-08 18:18:45 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
2016-01-03 01:05:35 +00:00
|
|
|
|
int flowSetTime0 = StateMachine.Time;
|
|
|
|
|
|
|
|
|
|
|
|
if (goBackToInitFlow)
|
2014-08-01 06:36:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
//--------------------------------
|
2018-07-13 11:00:03 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Switching flow detected, going back", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperations(measureOperations)
|
2019-05-10 14:26:58 +00:00
|
|
|
|
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-08-01 06:36:17 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-02-10 18:24:10 +00:00
|
|
|
|
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
2016-01-08 18:18:45 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
2014-08-01 06:36:17 +00:00
|
|
|
|
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2015-01-12 04:56:19 +00:00
|
|
|
|
if (e.Contains(Event.RegulValveTimeOut))
|
|
|
|
|
|
{
|
2018-06-05 09:16:13 +00:00
|
|
|
|
Bridge.OnError(this, Strings.Flow_adjustment_failed);
|
2018-06-27 08:31:22 +00:00
|
|
|
|
goto stopTest;
|
2015-01-12 04:56:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-08-01 06:36:17 +00:00
|
|
|
|
while (!e.Contains(Event.FlowReached));
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
//--------------------------------
|
2018-07-13 11:00:03 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Going to the test flow", test.Method, test.Name))
|
2018-10-11 08:20:44 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
2018-10-11 08:20:44 +00:00
|
|
|
|
.AddOperations(measureOperations)
|
2019-05-10 14:26:58 +00:00
|
|
|
|
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, qfrom_detected, qto_detected, RefFlow, FlowSettingTimeoutSec))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
//.AddOp(pOut.RegulValve.SetPositionOp(35.0f, 38.0f, uint.MaxValue))
|
2018-10-11 08:20:44 +00:00
|
|
|
|
.EnterState();
|
2019-03-18 08:14:13 +00:00
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-02-10 18:24:10 +00:00
|
|
|
|
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
2016-01-08 18:18:45 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
2014-08-01 06:36:17 +00:00
|
|
|
|
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
//if (e.Contains(Event.FlowTimeOut)) goto do_detection;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.FlowReached));
|
|
|
|
|
|
|
2016-01-08 18:18:45 +00:00
|
|
|
|
int flowSetTime = StateMachine.Time - flowDetectTime0;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-12-31 12:44:47 +00:00
|
|
|
|
//start_measurement:
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
State.Create(Strings.Measure_the_mass)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperations(measureOperations)
|
|
|
|
|
|
.AddOperation(scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2019-03-08 13:52:02 +00:00
|
|
|
|
if (e.Contains(Event.TimerExpired))
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, Strings.Mass_measurement_timeout);
|
|
|
|
|
|
goto stopTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
while (!e.Contains(Event.BalanceDone));
|
2019-05-14 14:59:20 +00:00
|
|
|
|
///
|
2016-02-10 18:24:10 +00:00
|
|
|
|
Mass.Val = StartMass.Val;
|
2019-05-14 14:59:20 +00:00
|
|
|
|
tMass1 = StateMachine.Time;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Test_in_progress);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
State.Create(Strings.Start_the_test)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperations(measureOperations)
|
2019-05-10 14:26:58 +00:00
|
|
|
|
.AddOperation(cBrd.StartMeasurementOp(outPath, (Elde.TestMethods.Diverter | Elde.TestMethods.Synchro), qfrom_detected, qto_detected, totalPulses))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.MeasurementStarted));
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Measurement loop - preparation
|
|
|
|
|
|
///
|
|
|
|
|
|
queryEnd1 = cBrd.QueryMeasurementEndOp();
|
|
|
|
|
|
queryEnd2 = cBrd.QueryMeasurementEndOp();
|
|
|
|
|
|
|
2018-10-11 08:20:44 +00:00
|
|
|
|
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0);
|
2016-01-03 01:05:35 +00:00
|
|
|
|
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-09-21 12:04:31 +00:00
|
|
|
|
/// Read the diverter switch time
|
2017-10-16 13:48:34 +00:00
|
|
|
|
switchTimeStart = 0.001f * (float)cBrd.DivTime(0);
|
|
|
|
|
|
log.WarnFormat("Diverter switch time on test start = {0} ms", cBrd.DivTime(0));
|
2017-09-21 12:04:31 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
/// Measurement loop - begin
|
|
|
|
|
|
while (true)
|
|
|
|
|
|
{
|
|
|
|
|
|
//--------------------------------
|
|
|
|
|
|
switch (ReadRegistersTempPressAmbient(measureOperations, true))
|
|
|
|
|
|
{
|
2016-06-15 15:04:25 +00:00
|
|
|
|
case Event.Error: goto error;
|
|
|
|
|
|
case Event.UiCmdStop: goto stopTest;
|
|
|
|
|
|
case Event.MeasurementCompleted: goto measurement_completed;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-02-20 12:38:07 +00:00
|
|
|
|
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
|
2015-09-22 09:29:20 +00:00
|
|
|
|
if (remainingTime > 60)
|
|
|
|
|
|
{
|
2015-10-14 13:45:51 +00:00
|
|
|
|
Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec));
|
2015-09-22 09:29:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
|
|
|
|
|
|
}
|
2015-02-20 12:38:07 +00:00
|
|
|
|
|
2017-05-18 11:22:11 +00:00
|
|
|
|
UpdateAllStatistics(StateMachine.Time);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2016-01-03 01:05:35 +00:00
|
|
|
|
/// TODO: Reimplement
|
|
|
|
|
|
//for (int i = 0; i < Config.Data.CompoundWMsCount; i++)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// data.TestResult.CombinedMeters[i].VolumeMeter = data.TestResult.Meters[2 * i].VolumeMeter
|
|
|
|
|
|
// + data.TestResult.Meters[2 * i + 1].VolumeMeter;
|
|
|
|
|
|
// if (data.Volume.Valid)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// data.TestResult.CombinedMeters[i].VolumeErrorPct =
|
|
|
|
|
|
// Formulas.ErrorFromVolumes(data.TestResult.CombinedMeters[i].VolumeMeter, data.Volume.Val);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
2016-02-10 18:24:10 +00:00
|
|
|
|
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
|
2016-01-08 18:18:45 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
/// Measurement loop - end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
measurement_completed:
|
2016-01-08 18:18:45 +00:00
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------
|
2014-07-28 07:54:35 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
|
|
|
|
|
//------------------------------------------------
|
2019-03-18 08:14:13 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Measuring the mass", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2019-03-08 13:52:02 +00:00
|
|
|
|
if (e.Contains(Event.TimerExpired))
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, Strings.Mass_measurement_timeout);
|
|
|
|
|
|
goto stopTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
while (!e.Contains(Event.BalanceDone));
|
|
|
|
|
|
///
|
2019-05-14 14:59:20 +00:00
|
|
|
|
tMass2 = StateMachine.Time;
|
2016-01-03 01:05:35 +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)
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(scale.DrainValve, null))
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { goto error; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-21 12:04:31 +00:00
|
|
|
|
/// Read the diverter switch time
|
2017-10-16 13:48:34 +00:00
|
|
|
|
switchTimeEnd = 0.001f * (float)cBrd.DivTime(0);
|
|
|
|
|
|
log.WarnFormat("Diverter switch time on test end = {0} ms", cBrd.DivTime(0));
|
2017-09-21 12:04:31 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Test_completed);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
State.Create(Strings.Stop_the_pump)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null)
|
|
|
|
|
|
.AddOperation(cBrd.SetValvesOp(null, inPath.Pump))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------
|
2019-03-18 08:14:13 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Stop_diverter_gate_etc", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(cBrd.StopPreviousOp())
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-07-28 07:54:35 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.PreviousStopped));
|
|
|
|
|
|
|
2016-01-03 01:05:35 +00:00
|
|
|
|
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
|
2015-06-25 02:45:04 +00:00
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
2015-01-15 05:34:36 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
///
|
2015-01-15 05:34:36 +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-02-02 17:09:05 +00:00
|
|
|
|
|
2016-01-03 01:05:35 +00:00
|
|
|
|
if (tstRslt != null)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2020-01-22 12:51:47 +00:00
|
|
|
|
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
|
2017-05-10 08:43:33 +00:00
|
|
|
|
UpdateTempPressDensAmb(tstRslt);
|
2016-01-03 01:05:35 +00:00
|
|
|
|
|
|
|
|
|
|
/// Main results
|
2018-02-26 11:18:04 +00:00
|
|
|
|
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
|
|
|
|
|
|
tstRslt.StartTime = TestStartTime;
|
2016-01-03 01:05:35 +00:00
|
|
|
|
tstRslt.EndTime = TestEndTime;
|
|
|
|
|
|
tstRslt.FlowSetTime = flowSetTime;
|
|
|
|
|
|
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
|
2019-05-15 12:04:40 +00:00
|
|
|
|
tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1;
|
|
|
|
|
|
double massOfEvaporatedWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean);
|
|
|
|
|
|
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
|
2016-12-16 12:07:54 +00:00
|
|
|
|
tstRslt.MassStartRaw = StartMass.Val;
|
2018-10-22 16:14:47 +00:00
|
|
|
|
tstRslt.MassStart = Config.Formulas.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections);
|
2016-02-10 18:24:10 +00:00
|
|
|
|
tstRslt.MassEndRaw = EndMass.Val;
|
2018-10-22 16:14:47 +00:00
|
|
|
|
tstRslt.MassEnd = Config.Formulas.CorrectedValue(tstRslt.MassEndRaw, scale.Corrections);
|
2019-05-15 12:04:40 +00:00
|
|
|
|
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart + massOfEvaporatedWater) / tstRslt.TestTime; /// [kg/h]
|
2020-06-25 07:35:10 +00:00
|
|
|
|
double flow = 3.6 * LtrPerRefPulse * cBrd.EtPulses(0) / tstRslt.TestTime; /// [m3/h]
|
2018-04-10 14:10:44 +00:00
|
|
|
|
tstRslt.Buoyancy = Config.Formulas.Buoyancy();
|
2019-05-15 12:04:40 +00:00
|
|
|
|
tstRslt.VolumeCTV = 1000 * tstRslt.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart + massOfEvaporatedWater) / tstRslt.DensityLine; /// [l] commercially true volume
|
2019-05-15 08:31:52 +00:00
|
|
|
|
if ((outPath.Diverter != null) && (tstRslt.TestTime > float.Epsilon))
|
|
|
|
|
|
{
|
2020-06-25 07:35:10 +00:00
|
|
|
|
tstRslt.TestTimeCorrection = outPath.Diverter.TestTimeCorrection(flow);
|
2019-05-15 08:31:52 +00:00
|
|
|
|
tstRslt.VolumeCTV *= tstRslt.TestTime + tstRslt.TestTimeCorrection;
|
|
|
|
|
|
tstRslt.VolumeCTV /= tstRslt.TestTime;
|
|
|
|
|
|
}
|
2018-11-08 09:54:26 +00:00
|
|
|
|
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
|
|
|
|
|
tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient
|
2020-06-25 07:35:10 +00:00
|
|
|
|
tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flow, rangeIx); /// Corrected master pulses per liter
|
2018-07-19 11:19:47 +00:00
|
|
|
|
tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster);
|
2018-11-08 09:54:26 +00:00
|
|
|
|
/// Calculated master pulses per liter
|
2018-07-19 11:19:47 +00:00
|
|
|
|
tstRslt.ErrorMaster = Config.Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
|
2016-01-03 01:05:35 +00:00
|
|
|
|
|
2020-06-25 07:35:10 +00:00
|
|
|
|
tstRslt.FlowVolume = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime;
|
|
|
|
|
|
tstRslt.FlowMean = Convert.ToSingle(RefFlowStat.Average);
|
|
|
|
|
|
tstRslt.FlowStart = Convert.ToSingle(RefFlowStat.First);
|
|
|
|
|
|
tstRslt.FlowEnd = Convert.ToSingle(RefFlowStat.Last);
|
|
|
|
|
|
tstRslt.FlowMin = Convert.ToSingle(RefFlowStat.Min);
|
|
|
|
|
|
tstRslt.FlowMax = Convert.ToSingle(RefFlowStat.Max);
|
2016-08-02 12:48:18 +00:00
|
|
|
|
|
2017-09-27 21:04:30 +00:00
|
|
|
|
tstRslt.DiverterStart = switchTimeStart;
|
|
|
|
|
|
tstRslt.DiverterEnd = switchTimeEnd;
|
2019-12-03 09:32:46 +00:00
|
|
|
|
long infoFlags = 0;
|
|
|
|
|
|
tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, switchTimeStart, switchTimeEnd, out infoFlags) : 0;
|
|
|
|
|
|
tstRslt.InfoFlags = infoFlags;
|
2017-08-19 10:07:57 +00:00
|
|
|
|
|
2016-06-30 12:02:25 +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-06-30 12:02:25 +00:00
|
|
|
|
|
|
|
|
|
|
Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain);
|
2016-01-03 01:05:35 +00:00
|
|
|
|
Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux);
|
|
|
|
|
|
|
|
|
|
|
|
for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2016-01-03 01:05:35 +00:00
|
|
|
|
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux];
|
|
|
|
|
|
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;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2016-01-03 01:05:35 +00:00
|
|
|
|
/// Optionally supress pulses from the large water meter
|
2016-02-13 15:47:15 +00:00
|
|
|
|
meterRslt.PulsesMeter = (isAux == 0 && testParams.SupressTrills) ? 0 : Convert.ToDouble(regReader.WMPulses);
|
|
|
|
|
|
meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses);
|
2016-02-13 07:18:49 +00:00
|
|
|
|
meterRslt.TestTime = cBrd.TTime;
|
|
|
|
|
|
meterRslt.VolumeStart = 0;
|
|
|
|
|
|
meterRslt.VolumeEnd = 0;
|
|
|
|
|
|
meterRslt.VolumeRef = tstRslt.VolumeCTV;
|
|
|
|
|
|
|
|
|
|
|
|
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter
|
|
|
|
|
|
///
|
2016-01-03 01:05:35 +00:00
|
|
|
|
if (meterRslt.PulsesMaster != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
meterRslt.VolumeMeter *= (tstRslt.PulsesMaster / meterRslt.PulsesMaster);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-10 14:10:44 +00:00
|
|
|
|
meterRslt.Error = Config.Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV); /// Main/Aux meter error is not usedfor evaluation
|
2016-01-03 01:05:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound);
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
2018-04-10 14:10:44 +00:00
|
|
|
|
compoundMeterRslt.Error = Config.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);
|
2016-01-03 01:05:35 +00:00
|
|
|
|
mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed;
|
|
|
|
|
|
mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true;
|
2017-07-04 09:19:05 +00:00
|
|
|
|
tstRslt.TestDone = true;
|
2016-01-03 01:05:35 +00:00
|
|
|
|
|
2020-01-31 14:45:30 +00:00
|
|
|
|
if (Qrise != 0) BatchRslts.Batch.WaterMeters[i].QRise = Qrise;
|
|
|
|
|
|
if (Qfall != 0) BatchRslts.Batch.WaterMeters[i].QFall = Qfall;
|
2016-01-03 01:05:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-01-08 18:18:45 +00:00
|
|
|
|
|
|
|
|
|
|
tstRslt.Components = Results.Entities.Components
|
|
|
|
|
|
.UpdateList(BatchRslts.ComponentsList,
|
2016-02-15 21:48:44 +00:00
|
|
|
|
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
|
|
|
|
|
|
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
|
2016-01-08 18:18:45 +00:00
|
|
|
|
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
|
|
|
|
|
|
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
|
2018-10-22 16:14:47 +00:00
|
|
|
|
scale != null ? scale.Name : string.Empty,
|
2016-01-08 18:18:45 +00:00
|
|
|
|
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Update results
|
2016-02-13 18:25:43 +00:00
|
|
|
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt));
|
|
|
|
|
|
}
|
2016-01-08 18:18:45 +00:00
|
|
|
|
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.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
|
|
|
|
|
|
|
|
|
|
///----------------------///
|
|
|
|
|
|
/// Quit this sequence ///
|
|
|
|
|
|
///----------------------///
|
|
|
|
|
|
|
2017-12-02 16:54:38 +00:00
|
|
|
|
if (isLastRepetition)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2017-12-02 16:54:38 +00:00
|
|
|
|
/// Stop the pump
|
2018-07-13 11:00:03 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Test(s) completed -> Stopping the pump", test.Method, test.Name))
|
2017-12-02 16:54:38 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(cBrd.SetValvesOp(null, inPath.Pump))
|
|
|
|
|
|
.AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null)
|
|
|
|
|
|
.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)) goto error;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone)));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-03-18 08:14:13 +00:00
|
|
|
|
return new List<Event> { Event.Done };
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
//====================================
|
2015-04-28 13:27:47 +00:00
|
|
|
|
stopTest:
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2018-07-13 11:00:03 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : User selected STOP -> Closing the valves", test.Method, test.Name))
|
2014-07-28 07:54:35 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2014-09-08 11:16:31 +00:00
|
|
|
|
.AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
|
2019-03-18 08:14:13 +00:00
|
|
|
|
return new List<Event> { Event.UiCmdStop };
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
//====================================
|
|
|
|
|
|
error:
|
|
|
|
|
|
State.Create("close_before_error")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2014-09-08 11:16:31 +00:00
|
|
|
|
.AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2017-12-02 16:54:38 +00:00
|
|
|
|
if (e.Contains(Event.Error)) break;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
|
2019-03-18 08:14:13 +00:00
|
|
|
|
return new List<Event> { Event.Error };
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
2018-10-22 16:14:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IList<Event> Simulate(Config.Entities.Test test, int repetitionNr, bool isLastRepetition,
|
|
|
|
|
|
CombinedWithDetTestParams testParams)
|
|
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Test method simulation
|
|
|
|
|
|
///
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
|
|
|
|
|
|
|
|
|
|
|
if (test.Name.ToLower().Contains("rise") || test.Name.ToLower().Contains("steig"))
|
|
|
|
|
|
{
|
|
|
|
|
|
MakeSimulatedCompound(test, 1, 0, 0.7f, 0.0f);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
MakeSimulatedCompound(test, 1, 0, 0.7f, 0.9f);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed));
|
|
|
|
|
|
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("Simulating {0}", test.Name));
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Simulating {1}", 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
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|