2015-10-05 08:11:59 +00:00
|
|
|
|
///
|
2017-01-24 17:55:36 +00:00
|
|
|
|
/// Copyright (c) 2016-2017 Sensus Metering Systems
|
2015-10-05 08:11:59 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using log4net;
|
|
|
|
|
|
using TBF.BenchControl;
|
|
|
|
|
|
using TBF.Boxes;
|
|
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
using TBF.UiBridge;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
|
|
|
|
|
|
{
|
|
|
|
|
|
public class FixedStartAdvancedSeq : Sequences.SequenceBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartAdvancedSeq));
|
|
|
|
|
|
|
|
|
|
|
|
/// <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-08 10:45:37 +00:00
|
|
|
|
public IList<Event> Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition)
|
2015-10-05 08:11:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
|
|
|
|
|
Event retVal = Event.Done;
|
|
|
|
|
|
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-09-28 10:51:41 +00:00
|
|
|
|
float switchTimeStart = 0.001f; /// in seconds, original vale is 1 ms
|
|
|
|
|
|
float switchTimeEnd = 0.001f; /// in seconds, original vale is 1 ms
|
2017-09-21 12:04:31 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
/// Notes:
|
|
|
|
|
|
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
|
|
|
|
|
|
/// float timeSec = 3600.0f * timeHr;
|
|
|
|
|
|
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
|
|
|
|
|
|
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2018-07-13 11:00:03 +00:00
|
|
|
|
int rangeIx = 0; /// Default range, used for non-Elde flowmeters
|
|
|
|
|
|
if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter)
|
|
|
|
|
|
{
|
|
|
|
|
|
Elde.FlowMeter.FlowMeter eldeFM = outPath.FlowMeter as Elde.FlowMeter.FlowMeter;
|
|
|
|
|
|
rangeIx = -1; /// Indicates invalid range
|
|
|
|
|
|
for (int r = 0; r <= 5; r++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (eldeFM.RangeEnabled(r) && eldeFM.GetTempLo(r) <= test.TempLimLo
|
|
|
|
|
|
&& eldeFM.GetTempHi(r) >= test.TempLimHi)
|
|
|
|
|
|
{
|
|
|
|
|
|
rangeIx = r;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (rangeIx == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions);
|
|
|
|
|
|
retVal = Event.UiCmdStop;
|
|
|
|
|
|
goto stopTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false);
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
//====================================
|
2017-03-28 21:47:32 +00:00
|
|
|
|
loop:
|
2015-10-05 08:11:59 +00:00
|
|
|
|
/// Start the test, initialize test results
|
|
|
|
|
|
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
|
2016-01-03 01:05:35 +00:00
|
|
|
|
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
|
|
|
|
|
TestStartTime = DateTime.Now;
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
2017-06-08 13:42:47 +00:00
|
|
|
|
if (!test.DoDraining)
|
2017-03-28 21:47:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Measure the weight in case there is no unconditional draining
|
|
|
|
|
|
///
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create("FixedStartAdvanced : Measuring mass of water in the tank")
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
|
|
|
|
|
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.BalanceDone));
|
|
|
|
|
|
}
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Skip draining in case there is enough room in the tank
|
|
|
|
|
|
///
|
2017-06-08 13:42:47 +00:00
|
|
|
|
if (test.DoDraining || (Mass.Val + test.Volume >= outPath.Scale.Capacity * Constants.TankFullFactor))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Drain the water tank
|
|
|
|
|
|
///
|
2017-03-29 07:22:39 +00:00
|
|
|
|
switch (DrainTheTank(outPath.Scale.DrainValve, outPath.Scale))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Setting_the_flow);
|
|
|
|
|
|
//------------------------------------------------
|
2017-03-28 21:47:32 +00:00
|
|
|
|
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
|
|
|
|
|
int flowSetTime0 = StateMachine.Time;
|
|
|
|
|
|
|
2015-10-05 08:11:59 +00:00
|
|
|
|
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
|
|
|
|
|
|
|
2016-01-08 18:18:45 +00:00
|
|
|
|
State.Create("FixedStartAdvanced : Waiting 5 sec")
|
2015-10-05 08:11:59 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(5))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
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));
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-10-05 08:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.TimerExpired));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
State.Create("FixedStartAdvanced : Starting the pump")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(cBrd.SetValvesOp(inPath.Pump, null))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
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));
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-10-05 08:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
set_flow:
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Setting_the_flow);
|
|
|
|
|
|
//------------------------------------------------
|
2015-10-05 08:11:59 +00:00
|
|
|
|
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
|
|
|
|
|
|
State.Create("FixedStartAdvanced : Starting the pump")
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2015-10-05 08:11:59 +00:00
|
|
|
|
.AddOperation(cBrd.SetValvesOp(inPath.Pump, null))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
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));
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
//--------------------------------
|
2015-10-05 08:11:59 +00:00
|
|
|
|
State.Create("FixedStartAdvanced : Setting the flow")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2015-12-20 19:48:50 +00:00
|
|
|
|
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min.
|
2015-10-05 08:11:59 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
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));
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-10-05 08:11:59 +00:00
|
|
|
|
if (e.Contains(Event.RegulValveTimeOut))
|
|
|
|
|
|
{
|
2018-06-05 09:16:13 +00:00
|
|
|
|
Bridge.OnError(this, Strings.Flow_adjustment_failed);
|
|
|
|
|
|
retVal = Event.UiCmdStop;
|
2015-10-05 08:11:59 +00:00
|
|
|
|
goto stopTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.Contains(Event.Next)) goto flow_set;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.FlowReached));
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
flow_set:
|
2016-01-08 18:18:45 +00:00
|
|
|
|
int flowSetTime = StateMachine.Time - flowSetTime0;
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Stopping_flow_for_the_fixed_start);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
State.Create("FixedStartAdvanced : Closing the start/stop valve before the fixed start test")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2018-04-24 11:24:36 +00:00
|
|
|
|
.AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath))
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
2015-10-05 08:11:59 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2015-10-05 08:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
int time = StateMachine.Time;
|
|
|
|
|
|
double currentFlow = RefFlow.Val;
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
2017-01-22 19:39:14 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Prepare cameras, ROI-s and measurementOperations
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
|
|
/// Find ROI-s
|
|
|
|
|
|
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
|
|
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
|
|
|
|
{
|
2017-04-06 16:55:01 +00:00
|
|
|
|
GenericDevices.IRoi roi = rr as GenericDevices.IRoi;
|
|
|
|
|
|
if (roi != null && roi.Detected)
|
|
|
|
|
|
{
|
|
|
|
|
|
rois.Add(roi);
|
|
|
|
|
|
}
|
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
|
|
|
|
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Enter watermeter begin states here
|
|
|
|
|
|
///
|
2015-10-05 08:11:59 +00:00
|
|
|
|
GenericDevices.IHasWMStatesForm dataEntryCmpnt =
|
|
|
|
|
|
TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm;
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (dataEntryCmpnt != null)
|
|
|
|
|
|
{
|
2016-05-28 11:40:58 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
|
2017-03-28 21:47:32 +00:00
|
|
|
|
State.Create("FixedStartAdvanced : Enter begin-state")
|
2017-11-21 20:51:22 +00:00
|
|
|
|
.AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp(sensPath.RegisterReaders))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ModelessFormClosed));
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < Config.Data.WMsCount; i++)
|
|
|
|
|
|
{
|
2015-10-05 08:11:59 +00:00
|
|
|
|
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
|
2017-03-28 21:47:32 +00:00
|
|
|
|
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
if (registerReader != null) registerReader.BeginWMState = dataEntryCmpnt.WMStartState(i);
|
2017-03-28 21:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
|
|
|
|
|
//------------------------------------------------
|
2015-10-05 08:11:59 +00:00
|
|
|
|
State.Create("FixedStartAdvanced : Measuring the start mass")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2017-01-24 17:55:36 +00:00
|
|
|
|
.AddOperations(measureOperations)
|
|
|
|
|
|
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
|
|
|
|
|
|
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
|
|
|
|
|
|
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
|
|
|
|
|
|
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
|
2016-11-17 07:48:52 +00:00
|
|
|
|
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
|
2016-10-18 16:48:20 +00:00
|
|
|
|
.AddOperation((StateMachine.Ambient != null)
|
2017-03-28 21:47:32 +00:00
|
|
|
|
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
|
|
|
|
|
|
.AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
|
|
|
|
|
|
.AddOperation(cBrd.UpdateTankWeightOp())
|
|
|
|
|
|
.AddOperation(processDataLoggingOp)
|
|
|
|
|
|
.EnterState();
|
2015-10-05 08:11:59 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-10-05 08:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.BalanceDone));
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
TestStartTime = DateTime.Now;
|
|
|
|
|
|
Mass.Val = StartMass.Val;
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Test_in_progress);
|
|
|
|
|
|
//------------------------------------------------
|
2015-10-05 08:11:59 +00:00
|
|
|
|
State.Create("FixedStartAdvanced : Starting the test")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperations(measureOperations)
|
|
|
|
|
|
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
|
2015-10-05 08:11:59 +00:00
|
|
|
|
test.Qfrom, test.Qto, 2 * totalPulses, (float)test.TolerRed))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-10-05 08:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.MeasurementStarted));
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
State.Create("FixedStartAdvanced : Opening the start/stop valve at the beginning of the fixed start test")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2018-04-24 11:24:36 +00:00
|
|
|
|
.AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath))
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Measurement loop - preparation
|
2017-03-28 21:47:32 +00:00
|
|
|
|
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
|
|
|
|
|
|
queryEnd1 = cBrd.QueryMeasurementEndOp();
|
2015-10-05 08:11:59 +00:00
|
|
|
|
queryEnd2 = cBrd.QueryMeasurementEndOp();
|
|
|
|
|
|
|
2018-02-11 15:31:25 +00:00
|
|
|
|
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
|
2015-10-05 08:11:59 +00:00
|
|
|
|
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
/// Measurement loop - begin
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
//--------------------------------
|
|
|
|
|
|
switch (ReadRegistersTempPressAmbient(measureOperations, true))
|
|
|
|
|
|
{
|
|
|
|
|
|
case Event.Error:
|
|
|
|
|
|
retVal = Event.Error;
|
|
|
|
|
|
goto stopTest;
|
2016-06-15 15:04:25 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
case Event.UiCmdStop:
|
|
|
|
|
|
retVal = Event.UiCmdStop;
|
|
|
|
|
|
goto stopTest;
|
2016-06-15 15:04:25 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
case Event.MeasurementCompleted:
|
|
|
|
|
|
goto test_completed;
|
|
|
|
|
|
}
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
|
|
|
|
|
|
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-10-05 08:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-10 18:24:10 +00:00
|
|
|
|
RefFreq.Val = cBrd.ReferenceFreq;
|
2017-03-28 21:47:32 +00:00
|
|
|
|
RefFlow.Val = cBrd.ReferenceFlow;
|
2017-05-18 11:22:11 +00:00
|
|
|
|
UpdateAllStatistics(StateMachine.Time);
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
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));
|
|
|
|
|
|
}
|
2017-03-28 21:47:32 +00:00
|
|
|
|
while (cBrd.EtPulses(0) < totalPulses);
|
|
|
|
|
|
/// Measurement loop - end
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
test_completed:
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2018-02-11 15:31:25 +00:00
|
|
|
|
StopRecordingStatistics();
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
State.Create("FixedStartAdvanced : Closing the start/stop valve at the end of the fixed start test")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2018-04-24 11:24:36 +00:00
|
|
|
|
.AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath))
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
State.Create("FixedStartAdvanced : Waiting before 2nd mass measurement")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2016-10-18 16:48:20 +00:00
|
|
|
|
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
|
|
|
|
|
|
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
|
2015-12-20 19:48:50 +00:00
|
|
|
|
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
|
2016-10-18 16:48:20 +00:00
|
|
|
|
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
|
|
|
|
|
|
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
|
2016-11-17 07:48:52 +00:00
|
|
|
|
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
|
2015-10-05 08:11:59 +00:00
|
|
|
|
.AddOperation((StateMachine.Ambient != null)
|
2016-10-18 16:48:20 +00:00
|
|
|
|
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
|
2015-10-05 08:11:59 +00:00
|
|
|
|
.AddOperation(cBrd.UpdateTankWeightOp())
|
|
|
|
|
|
.AddOperation(processDataLoggingOp)
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-10-05 08:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.TimerExpired));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
State.Create("FixedStartAdvanced : Measuring the end mass")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2016-10-18 16:48:20 +00:00
|
|
|
|
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
|
|
|
|
|
|
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
|
2015-12-20 19:48:50 +00:00
|
|
|
|
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
|
2016-10-18 16:48:20 +00:00
|
|
|
|
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
|
|
|
|
|
|
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
|
2016-11-17 07:48:52 +00:00
|
|
|
|
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
|
2015-10-05 08:11:59 +00:00
|
|
|
|
.AddOperation((StateMachine.Ambient != null)
|
2016-10-18 16:48:20 +00:00
|
|
|
|
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
|
2015-10-05 08:11:59 +00:00
|
|
|
|
.AddOperation(cBrd.UpdateTankWeightOp())
|
|
|
|
|
|
.AddOperation(processDataLoggingOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-10-05 08:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.BalanceDone));
|
|
|
|
|
|
///
|
2016-01-03 01:05:35 +00:00
|
|
|
|
TestEndTime = DateTime.Now;
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
State.Create("FixedStartAdvanced : Stopping diverter, gate, etc.")
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(cBrd.StopPreviousOp())
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.PreviousStopped));
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-04-10 14:10:44 +00:00
|
|
|
|
double massStart = Config.Formulas.CorrectedValue(StartMass.Val, outPath.Scale.Corrections);
|
|
|
|
|
|
double massEnd = Config.Formulas.CorrectedValue(EndMass.Val, outPath.Scale.Corrections);
|
|
|
|
|
|
double densityOut = Config.Formulas.WaterDensityFromTemp(TempDownStat.Average, Program.LocalSettings.RealDensity, Program.LocalSettings.AtTemperature);
|
|
|
|
|
|
double buoyancy = Config.Formulas.Buoyancy();
|
2017-07-20 13:16:55 +00:00
|
|
|
|
double volumeCTV = 1000.0 * buoyancy * (massEnd - massStart) / densityOut;
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Enter watermeter end states here
|
|
|
|
|
|
///
|
|
|
|
|
|
if (dataEntryCmpnt != null)
|
|
|
|
|
|
{
|
2016-05-28 11:40:58 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
|
2017-03-28 21:47:32 +00:00
|
|
|
|
State.Create("FixedStartAdvanced : Enter end-state")
|
2017-11-22 22:53:41 +00:00
|
|
|
|
.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(sensPath.RegisterReaders,
|
|
|
|
|
|
volumeCTV,
|
|
|
|
|
|
test.ErrLimLo + test.Uncertainty,
|
|
|
|
|
|
test.ErrLimHi - test.Uncertainty))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ModelessFormClosed));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < Config.Data.WMsCount; i++)
|
|
|
|
|
|
{
|
2015-10-05 08:11:59 +00:00
|
|
|
|
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
|
2017-03-28 21:47:32 +00:00
|
|
|
|
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
if (registerReader != null) registerReader.EndWMState = dataEntryCmpnt.WMEndState(i);
|
2017-03-28 21:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Test_completed);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
|
2015-10-05 08:11:59 +00:00
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Populate TestResult data entity with data
|
|
|
|
|
|
///
|
2016-01-03 01:05:35 +00:00
|
|
|
|
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
|
|
|
|
|
|
|
|
|
|
|
|
if (tstRslt != null)
|
2015-10-05 08:11:59 +00:00
|
|
|
|
{
|
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;
|
|
|
|
|
|
tstRslt.EndTime = TestEndTime;
|
|
|
|
|
|
tstRslt.FlowSetTime = flowSetTime;
|
|
|
|
|
|
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
|
2016-12-16 12:07:54 +00:00
|
|
|
|
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
|
|
|
|
|
|
tstRslt.MassStartRaw = StartMass.Val;
|
2018-02-26 11:18:04 +00:00
|
|
|
|
tstRslt.MassStart = massStart; /// [kg] calculated before displaying 'End state' dialog
|
|
|
|
|
|
tstRslt.MassEndRaw = EndMass.Val;
|
|
|
|
|
|
tstRslt.MassEnd = massEnd; /// [kg] calculated before displaying 'End state' dialog
|
|
|
|
|
|
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
|
|
|
|
|
|
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime;
|
|
|
|
|
|
tstRslt.Buoyancy = buoyancy;
|
2018-07-13 11:00:03 +00:00
|
|
|
|
tstRslt.VolumeCTV = volumeCTV; /// [kg] calculated before displaying 'End state' dialog
|
|
|
|
|
|
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
2018-07-19 11:19:47 +00:00
|
|
|
|
tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient
|
2018-07-13 11:00:03 +00:00
|
|
|
|
tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume, 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);
|
|
|
|
|
|
/// Calculated master pulses per liter
|
|
|
|
|
|
tstRslt.ErrorMaster = Config.Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
|
2016-01-03 01:05:35 +00:00
|
|
|
|
|
2017-05-18 11:22:11 +00:00
|
|
|
|
tstRslt.FlowMean = (float)RefFlowStat.Average;
|
2017-09-13 13:48:31 +00:00
|
|
|
|
tstRslt.FlowStart = (float)RefFlowStat.First;
|
|
|
|
|
|
tstRslt.FlowEnd = (float)RefFlowStat.Last;
|
|
|
|
|
|
tstRslt.FlowMin = (float)RefFlowStat.Min;
|
2017-05-25 12:06:05 +00:00
|
|
|
|
tstRslt.FlowMax = (float)RefFlowStat.Max;
|
2016-08-02 12:48:18 +00:00
|
|
|
|
|
2017-09-27 21:04:30 +00:00
|
|
|
|
tstRslt.DiverterStart = switchTimeStart;
|
|
|
|
|
|
tstRslt.DiverterEnd = switchTimeEnd;
|
|
|
|
|
|
tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0;
|
2017-09-21 12:04:31 +00:00
|
|
|
|
tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, true, switchTimeStart, switchTimeEnd) : 0;
|
2017-08-19 10:07:57 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue;
|
2016-06-30 12:02:25 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
|
2017-03-10 13:31:08 +00:00
|
|
|
|
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
|
2016-01-03 01:05:35 +00:00
|
|
|
|
|
|
|
|
|
|
if (meterRslt != null && regReader != null)
|
2015-10-05 08:11:59 +00:00
|
|
|
|
{
|
2018-04-10 14:10:44 +00:00
|
|
|
|
meterRslt.RegReaderType = (int)regReader.RegisterReaderType;
|
2018-02-26 11:18:04 +00:00
|
|
|
|
meterRslt.PulsesPerLiter = 1.0f;
|
2017-03-28 21:47:32 +00:00
|
|
|
|
meterRslt.VolumeStart = regReader.BeginWMState;
|
|
|
|
|
|
meterRslt.VolumeEnd = regReader.EndWMState;
|
|
|
|
|
|
meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart;
|
|
|
|
|
|
meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter
|
|
|
|
|
|
meterRslt.PulsesMeter = meterRslt.VolumeMeter;
|
2016-01-03 01:05:35 +00:00
|
|
|
|
meterRslt.PulsesMaster = tstRslt.PulsesMaster;
|
2017-03-28 21:47:32 +00:00
|
|
|
|
meterRslt.TestTime = tstRslt.TestTime;
|
2018-04-10 14:10:44 +00:00
|
|
|
|
meterRslt.Error = Config.Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
|
2017-10-17 22:30:26 +00:00
|
|
|
|
meterRslt.Passed = (meterRslt.Error >= test.GetErrLimLo(tstRslt.FlowMean) + test.Uncertainty)
|
|
|
|
|
|
&& (meterRslt.Error <= test.GetErrLimHi(tstRslt.FlowMean) - test.Uncertainty)
|
2017-08-19 10:07:57 +00:00
|
|
|
|
&& (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On);
|
2016-01-03 01:05:35 +00:00
|
|
|
|
meterRslt.TestDone = true;
|
2017-07-04 09:19:05 +00:00
|
|
|
|
tstRslt.TestDone = true;
|
|
|
|
|
|
}
|
2015-10-05 08:11:59 +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,
|
2017-03-28 21:47:32 +00:00
|
|
|
|
outPath.Scale != null ? outPath.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));
|
2015-10-05 08:11:59 +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
|
|
|
|
{
|
2017-10-04 11:07:56 +00:00
|
|
|
|
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
2017-09-27 21:04:30 +00:00
|
|
|
|
{
|
2017-10-04 11:07:56 +00:00
|
|
|
|
if (BatchRslts.WaterMeters[i] != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
BatchRslts.WaterMeters[i].ErrorFlags = ErrorFlagsComp.GetWMtrErrorFlags(BatchRslts.WaterMeters[i].MeterTestRslts);
|
|
|
|
|
|
}
|
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));
|
|
|
|
|
|
}
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
2016-01-08 18:18:45 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter));
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
/// Append the results to the CSV-file
|
2016-01-03 01:05:35 +00:00
|
|
|
|
allResults.Info(TestResult2CsvLine(testName, test.Part));
|
2015-10-05 08:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stopTest:
|
|
|
|
|
|
|
2018-02-11 15:31:25 +00:00
|
|
|
|
StopRecordingStatistics();
|
|
|
|
|
|
|
2017-12-08 10:45:37 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Quit this sequence
|
|
|
|
|
|
///
|
|
|
|
|
|
if (isLastRepetition || retVal == Event.UiCmdStop || retVal == Event.OpArgumentError
|
|
|
|
|
|
|| retVal == Event.Error || retVal == Event.ConfigurationError)
|
|
|
|
|
|
{
|
2017-12-02 16:54:38 +00:00
|
|
|
|
State.Create("FixedStartAdvanced : Stopping diverter, gate, etc.")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(cBrd.StopPreviousOp())
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.PreviousStopped));
|
|
|
|
|
|
}
|
2016-01-08 18:18:45 +00:00
|
|
|
|
|
2015-10-05 08:11:59 +00:00
|
|
|
|
/// Create a list with one item 'retVal' (default is Event.Done) and return it
|
|
|
|
|
|
IList<Event> retList = new List<Event>(1);
|
|
|
|
|
|
retList.Add(retVal);
|
|
|
|
|
|
return retList;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|