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-09-05 07:06:23 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-07-27 16:02:19 +00:00
|
|
|
|
using System.IO;
|
2014-09-05 07:06:23 +00:00
|
|
|
|
using log4net;
|
|
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
using TBF.UiBridge;
|
2018-10-22 16:14:47 +00:00
|
|
|
|
using TBF.BenchControl.GenericDevices;
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
|
|
|
|
|
|
{
|
|
|
|
|
|
public class FixedStartMassCollectionSeq : Sequences.SequenceBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartMassCollectionSeq));
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-11-22 20:06:00 +00:00
|
|
|
|
/// Fixed start mass collection method sequence
|
2014-09-05 07:06:23 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="test">Test entity</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// Event.Done . . . . . . . OK
|
2017-11-22 11:12:04 +00:00
|
|
|
|
/// Event.MakeSecondPass . . OK, 2nd pass (=evaluation) required
|
2014-09-05 07:06:23 +00:00
|
|
|
|
/// 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,
|
2016-08-24 16:30:00 +00:00
|
|
|
|
bool compound,
|
2017-03-07 17:35:39 +00:00
|
|
|
|
HeatMeters.TestParams heatMetersTestParams,
|
|
|
|
|
|
Config.Entities.DebugMode debugLevel)
|
2016-08-22 14:00:48 +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
|
|
|
|
new List<Event> { Event.ConfigurationError };
|
|
|
|
|
|
}
|
2018-10-22 16:14:47 +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);
|
2019-05-10 14:26:58 +00:00
|
|
|
|
new List<Event> { Event.ConfigurationError };
|
|
|
|
|
|
}
|
2018-10-22 16:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (test.Volume >= scale.Capacity * Constants.TankFullFactor)
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity);
|
2019-05-10 14:26:58 +00:00
|
|
|
|
new List<Event> { Event.ConfigurationError };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2018-10-22 16:14:47 +00:00
|
|
|
|
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null);
|
2019-03-18 08:14:13 +00:00
|
|
|
|
|
2019-05-10 14:26:58 +00:00
|
|
|
|
|
|
|
|
|
|
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;
|
2019-11-13 15:27:18 +00:00
|
|
|
|
if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8))
|
2019-05-10 14:26:58 +00:00
|
|
|
|
{
|
|
|
|
|
|
filters[eldeRR.Position - 1] = eldeRR.Filter;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1);
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
|
|
Event retVal = Event.Done;
|
2014-09-05 07:06:23 +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
|
|
|
|
|
2016-02-10 18:24:10 +00:00
|
|
|
|
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
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));
|
2016-08-22 14:00:48 +00:00
|
|
|
|
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
//====================================
|
2014-09-05 07:06:23 +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)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.Busy));
|
|
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
/// Start the test, initialize test results
|
2019-03-18 08:14:13 +00:00
|
|
|
|
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses));
|
2016-08-22 14:00:48 +00:00
|
|
|
|
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
|
|
|
|
|
|
2016-10-13 13:02:33 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test
|
|
|
|
|
|
///
|
|
|
|
|
|
IOperation heatMetersPromptOp = null;
|
|
|
|
|
|
if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt))
|
|
|
|
|
|
{
|
2017-03-28 21:47:32 +00:00
|
|
|
|
/// Make sure the CycleBeginForm is closed
|
|
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
|
|
|
|
|
|
|
|
|
|
|
heatMetersPromptOp = new Operations.MessageBoxOp(heatMetersTestParams.Prompt);
|
2016-10-13 13:02:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-03-28 21:47:32 +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(string.Format("{0}({1}) : Measuring 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))
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2017-03-28 21:47:32 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted));
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
///
|
2018-10-22 16:14:47 +00:00
|
|
|
|
if (test.DoDraining || (Mass.Val + test.Volume >= scale.Capacity * Constants.TankFullFactor))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Drain the water tank
|
|
|
|
|
|
///
|
2019-03-18 08:14:13 +00:00
|
|
|
|
IList<IOperation> ops = new List<IOperation>(readTempPressOps);
|
|
|
|
|
|
ops.Add(heatMetersPromptOp);
|
|
|
|
|
|
switch (DrainTheTank(scale, ops))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Make sure the drain valve is closed
|
|
|
|
|
|
///
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Make sure the drain valve is closed", test.Method, test.Name))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(scale.ReadMassOp(ref Mass))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
2018-10-22 16:14:47 +00:00
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, scale.DrainValve))
|
2017-03-28 21:47:32 +00:00
|
|
|
|
.EnterState();
|
2019-03-18 08:14:13 +00:00
|
|
|
|
do {
|
2017-03-28 21:47:32 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted));
|
|
|
|
|
|
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet) || !e.Contains(Event.BalanceDone));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
//------------------------------------------------
|
2016-10-13 13:02:33 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Starting_the_pump);
|
2016-08-22 14:00:48 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
|
|
|
|
|
int flowSetTime0 = StateMachine.Time;
|
2016-08-22 14:00:48 +00:00
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
|
2016-10-13 13:02:33 +00:00
|
|
|
|
///
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
//.AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-08-22 14:00:48 +00:00
|
|
|
|
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 (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2016-10-13 13:02:33 +00:00
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2016-08-22 14:00:48 +00:00
|
|
|
|
|
2016-10-13 13:02:33 +00:00
|
|
|
|
}
|
2017-04-24 09:58:57 +00:00
|
|
|
|
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
|
2015-02-01 18:30:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
2017-10-16 08:30:42 +00:00
|
|
|
|
if (test.TimePump2StartV > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
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)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(test.TimePump2StartV))
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2017-10-16 08:30:42 +00:00
|
|
|
|
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 (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.TimerExpired));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (benchPath.StopBFValve != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
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)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null))
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2017-10-16 08:30:42 +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));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (test.TimeBeforeFlow > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
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)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(test.TimeBeforeFlow))
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2017-10-16 08:30:42 +00:00
|
|
|
|
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 (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.TimerExpired));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
2017-10-16 08:30:42 +00:00
|
|
|
|
setting_flow:
|
2017-03-07 17:35:39 +00:00
|
|
|
|
|
2014-09-05 07:06:23 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Setting_the_flow);
|
|
|
|
|
|
//------------------------------------------------
|
2017-02-06 16:29:39 +00:00
|
|
|
|
if (inPath.Pump is GenericDevices.IPumpFM)
|
|
|
|
|
|
{
|
|
|
|
|
|
(inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
|
|
|
|
|
|
}
|
|
|
|
|
|
///
|
2018-04-24 11:24:36 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Pump on", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(inPath.Pump, null))
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-09-05 07:06:23 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-08-22 14:00:48 +00:00
|
|
|
|
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2014-09-05 07:06:23 +00:00
|
|
|
|
}
|
2017-02-06 16:29:39 +00:00
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
2018-04-24 11:24:36 +00:00
|
|
|
|
///
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Start valve open", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath))
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2018-04-24 11:24:36 +00:00
|
|
|
|
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 (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
2017-02-06 16:29:39 +00:00
|
|
|
|
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
|
|
|
|
|
//--------------------------------
|
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)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
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
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-08-22 14:00:48 +00:00
|
|
|
|
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.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
if (e.Contains(Event.RegulValveTimeOut))
|
|
|
|
|
|
{
|
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-08-22 14:00:48 +00:00
|
|
|
|
goto stopTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.Contains(Event.Next)) goto flow_set;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.FlowReached));
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
|
|
|
|
|
flow_set:
|
2016-08-17 16:11:34 +00:00
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
int flowSetTime = StateMachine.Time - flowSetTime0;
|
|
|
|
|
|
|
|
|
|
|
|
if (heatMetersTestParams != null && heatMetersPath != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
//---------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Setting_temperature);
|
|
|
|
|
|
//---------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
int lastTimeSec = StateMachine.Time;
|
2016-10-07 13:33:56 +00:00
|
|
|
|
double Tw_last = 0;
|
|
|
|
|
|
double Tc_last = 0;
|
2016-08-22 14:00:48 +00:00
|
|
|
|
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Checking if the temperature is stable", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(heatMetersPromptOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-08-21 20:07:20 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2016-08-22 14:00:48 +00:00
|
|
|
|
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-23 10:24:05 +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;
|
2019-03-18 08:14:13 +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) &&
|
|
|
|
|
|
(Math.Abs(TempRefHi1.Val - TempRefHi2.Val) <= heatMetersTestParams.DeltaTempWarm) &&
|
|
|
|
|
|
(Math.Abs(TempRefLo1.Val - TempRefLo2.Val) <= heatMetersTestParams.DeltaTempCold))
|
2016-08-23 10:24:05 +00:00
|
|
|
|
{
|
|
|
|
|
|
goto temperature_set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lastTimeSec = StateMachine.Time;
|
|
|
|
|
|
Tw_last = Tw;
|
|
|
|
|
|
Tc_last = Tc;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-08-22 14:00:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
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)
|
2017-06-08 14:55:24 +00:00
|
|
|
|
.EnterState();
|
2019-03-18 08:14:13 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
if (TempUp.Val >= test.TempLimLo && TempUp.Val <= test.TempLimHi &&
|
|
|
|
|
|
TempDown.Val >= test.TempLimLo && TempDown.Val <= test.TempLimHi)
|
|
|
|
|
|
{
|
|
|
|
|
|
goto temperature_set;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
while (true);
|
|
|
|
|
|
}
|
2016-08-22 14:00:48 +00:00
|
|
|
|
|
|
|
|
|
|
temperature_set:
|
2014-09-16 10:04:08 +00:00
|
|
|
|
|
2017-07-27 07:59:55 +00:00
|
|
|
|
//-----------------------------------------------------------------
|
2014-09-16 14:09:07 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Stopping_flow_for_the_fixed_start);
|
2017-07-27 07:59:55 +00:00
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Closing the start/stop valve before the fixed start test", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-08-22 14:00:48 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2014-09-16 14:09:07 +00:00
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2016-08-22 14:00:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
2014-09-16 14:09:07 +00:00
|
|
|
|
|
2014-09-16 10:04:08 +00:00
|
|
|
|
|
2014-09-05 07:06:23 +00:00
|
|
|
|
int time = StateMachine.Time;
|
2016-10-07 14:22:36 +00:00
|
|
|
|
double currentFlow = RefFlow.Val;
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
2014-09-16 14:09:07 +00:00
|
|
|
|
|
2017-11-22 09:43:37 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
if (test.TimeFlow2Mass > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Waiting before 1st mass measurement", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(test.TimeFlow2Mass))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2017-11-22 09:43:37 +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.TimerExpired));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TestStartTime = DateTime.Now;
|
|
|
|
|
|
LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name);
|
|
|
|
|
|
|
|
|
|
|
|
if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "Start mass");
|
|
|
|
|
|
else LogProcessDataHeaderHeatMeters(processDataLogger, "Start mass");
|
|
|
|
|
|
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Measuring the start mass", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec))
|
|
|
|
|
|
.AddOperation(processDataLoggingOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2017-11-22 09:43:37 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2019-03-08 13:52:02 +00:00
|
|
|
|
if (e.Contains(Event.TimerExpired))
|
|
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
2017-11-22 09:43:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.BalanceDone));
|
2019-05-14 14:59:20 +00:00
|
|
|
|
///
|
2017-11-22 09:43:37 +00:00
|
|
|
|
Mass.Val = StartMass.Val;
|
2019-05-14 14:59:20 +00:00
|
|
|
|
tMass1 = StateMachine.Time;
|
2017-11-22 09:43:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Enter watermeter begin states here
|
|
|
|
|
|
///
|
2017-07-27 16:02:19 +00:00
|
|
|
|
GenericDevices.IHasWMStatesForm dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm;
|
2017-07-27 12:31:15 +00:00
|
|
|
|
|
2017-07-27 16:02:19 +00:00
|
|
|
|
if (dataEntryCmpnt != null)
|
2017-11-22 09:43:37 +00:00
|
|
|
|
{
|
2017-07-27 16:02:19 +00:00
|
|
|
|
string fileName = string.Format("{0}-start.bmp", test.Name);
|
|
|
|
|
|
|
|
|
|
|
|
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera)
|
2017-07-27 12:31:15 +00:00
|
|
|
|
{
|
2017-07-27 16:02:19 +00:00
|
|
|
|
string[] startImages = new string[sensPath.RegisterReaders.Length];
|
2017-07-27 12:31:15 +00:00
|
|
|
|
|
2017-07-27 16:02:19 +00:00
|
|
|
|
State state2 = State.Create(string.Format("{0}({1}) : Grabbing images", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps);
|
|
|
|
|
|
|
2017-07-27 16:02:19 +00:00
|
|
|
|
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
GenericDevices.IRoiForFixedStart roi = sensPath.RegisterReaders[i] as GenericDevices.IRoiForFixedStart;
|
|
|
|
|
|
if (roi != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
string directory = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
|
|
|
|
|
Directory.CreateDirectory(directory);
|
|
|
|
|
|
startImages[i] = Path.Combine(directory, fileName);
|
|
|
|
|
|
state2.AddOperation(roi.GrabImageOp(startImages[i]));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
state2.EnterState();
|
2019-03-18 08:14:13 +00:00
|
|
|
|
do {
|
2017-07-27 16:02:19 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
|
2017-12-08 10:45:37 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
|
2017-07-27 16:02:19 +00:00
|
|
|
|
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; break; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.CameraBusy));
|
|
|
|
|
|
|
|
|
|
|
|
(dataEntryCmpnt as GenericDevices.IDataEntryForCamera).StartImages = startImages;
|
2017-07-27 12:31:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-11-22 09:43:37 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Entering begin-state", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp(sensPath.RegisterReaders))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2017-11-22 09:43:37 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ModelessFormClosed));
|
2014-09-23 11:16:59 +00:00
|
|
|
|
|
2017-11-22 09:43:37 +00:00
|
|
|
|
if (heatMetersTestParams != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < Config.Data.HeatMetersCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
BenchControl.Elde.FixedStartRegisterReader.RegisterReader volumeRegisterReader =
|
|
|
|
|
|
sensPath.RegisterReaders[2 * i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
|
|
|
|
|
|
|
|
|
|
|
|
BenchControl.Elde.FixedStartRegisterReader.RegisterReader energyRegisterReader =
|
|
|
|
|
|
sensPath.RegisterReaders[2 * i + 1] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
|
|
|
|
|
|
|
|
|
|
|
|
if (volumeRegisterReader != null) volumeRegisterReader.BeginWMState = dataEntryCmpnt.WMStartState(i);
|
|
|
|
|
|
if (energyRegisterReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
energyRegisterReader.BeginWMState = (float)(dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyStartState(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < Config.Data.WMsCount; i++)
|
|
|
|
|
|
{
|
2017-07-28 14:21:30 +00:00
|
|
|
|
GenericDevices.IRegisterReader rr = sensPath.RegisterReaders[i];
|
2015-06-02 15:58:42 +00:00
|
|
|
|
|
2017-07-28 14:21:30 +00:00
|
|
|
|
if (rr is BenchControl.Elde.FixedStartRegisterReader.RegisterReader)
|
|
|
|
|
|
(rr as BenchControl.Elde.FixedStartRegisterReader.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i);
|
|
|
|
|
|
|
|
|
|
|
|
if (rr is BenchControl.Network.Camera.RoiForFixedStart.Roi)
|
|
|
|
|
|
(rr as BenchControl.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
|
2019-04-29 08:33:19 +00:00
|
|
|
|
}
|
2017-11-22 09:43:37 +00:00
|
|
|
|
}
|
2017-07-27 16:02:19 +00:00
|
|
|
|
|
|
|
|
|
|
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera && (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).SaveImages)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// SaveImages==true ... copy images to the directory that will be archived at the end of the cycle
|
|
|
|
|
|
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
GenericDevices.IRoiForFixedStart roi = sensPath.RegisterReaders[i] as GenericDevices.IRoiForFixedStart;
|
|
|
|
|
|
if (roi != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
string srcDir = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
|
|
|
|
|
string destDir = Path.Combine(Program.ImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
2018-03-28 11:21:28 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (File.Exists(Path.Combine(srcDir, fileName)))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(destDir);
|
|
|
|
|
|
File.Copy(Path.Combine(srcDir, fileName), Path.Combine(destDir, fileName), true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.ErrorFormat("Failed to copy image {0} to {1}: {2}", fileName, destDir, exc.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-07-27 16:02:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-11-22 09:43:37 +00:00
|
|
|
|
}
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
2017-05-10 11:32:49 +00:00
|
|
|
|
|
|
|
|
|
|
if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "Measurement");
|
|
|
|
|
|
else LogProcessDataHeaderHeatMeters(processDataLogger, "Measurement");
|
|
|
|
|
|
|
2014-09-05 07:06:23 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Test_in_progress);
|
|
|
|
|
|
//------------------------------------------------
|
2017-06-07 14:22:18 +00:00
|
|
|
|
StartTime = (double)StateMachine.Time;
|
2020-08-07 10:12:57 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
2020-08-07 10:12:57 +00:00
|
|
|
|
.AddOperation(cBrd.StartMeasurementOp(outPath, (Elde.TestMethods.Diverter | Elde.TestMethods.FixedStart),
|
|
|
|
|
|
test.Qfrom, test.Qto, 2 * totalPulses, 10))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-09-16 14:09:07 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2020-08-07 10:12:57 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2014-09-16 14:09:07 +00:00
|
|
|
|
}
|
2020-08-07 10:12:57 +00:00
|
|
|
|
while (!e.Contains(Event.MeasurementStarted) || !e.Contains(Event.ValvesSet));
|
2014-09-16 14:09:07 +00:00
|
|
|
|
|
2017-09-28 15:11:41 +00:00
|
|
|
|
switchTimeStart = 0.001f * cBrd.ValveOpenCloseTime;
|
|
|
|
|
|
log.WarnFormat("Start valve switch time on test start = {0} ms", cBrd.ValveOpenCloseTime);
|
2014-09-16 14:09:07 +00:00
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
/// Measurement loop - preparation
|
2016-02-13 15:47:15 +00:00
|
|
|
|
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
|
2015-08-19 11:04:47 +00:00
|
|
|
|
queryEnd1 = cBrd.QueryMeasurementEndOp();
|
2016-08-22 14:00:48 +00:00
|
|
|
|
queryEnd2 = cBrd.QueryMeasurementEndOp();
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
2018-10-11 08:20:44 +00:00
|
|
|
|
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, Math.Max((int)(test.TstTime / 10), 5));
|
2018-02-11 15:31:25 +00:00
|
|
|
|
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
|
|
|
|
|
/// Measurement loop - begin
|
2014-09-23 11:16:59 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
2014-09-05 07:06:23 +00:00
|
|
|
|
//--------------------------------
|
2017-07-27 16:02:19 +00:00
|
|
|
|
switch (ReadRegistersTempPressAmbient(null, true))
|
2014-09-23 11:16:59 +00:00
|
|
|
|
{
|
2016-06-15 15:04:25 +00:00
|
|
|
|
case Event.Error:
|
|
|
|
|
|
retVal = Event.Error;
|
|
|
|
|
|
goto stopTest;
|
|
|
|
|
|
|
|
|
|
|
|
case Event.UiCmdStop:
|
|
|
|
|
|
retVal = Event.UiCmdStop;
|
|
|
|
|
|
goto stopTest;
|
|
|
|
|
|
|
|
|
|
|
|
case Event.MeasurementCompleted:
|
|
|
|
|
|
goto test_completed;
|
2014-09-23 11:16:59 +00:00
|
|
|
|
}
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
|
|
|
|
|
|
if (remainingTime > 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));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RefFreq.Val = cBrd.ReferenceFreq;
|
|
|
|
|
|
RefFlow.Val = cBrd.ReferenceFlow;
|
|
|
|
|
|
|
2017-05-18 11:22:11 +00:00
|
|
|
|
UpdateAllStatistics(StateMachine.Time);
|
2016-08-24 16:30:00 +00:00
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
if (heatMetersTestParams != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (lastEnergyUpdateTime == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastEnergyUpdateTime = StateMachine.Time;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//double deltaTime = (double)(StateMachine.Time - lastEnergyUpdateTime);
|
2016-10-18 16:48:20 +00:00
|
|
|
|
double T_in = (TempRefHi1.Val + TempRefHi2.Val) / 2; /// [°C]
|
|
|
|
|
|
double T_out = (TempRefLo1.Val + TempRefLo2.Val) / 2; /// [°C]
|
2016-08-22 14:00:48 +00:00
|
|
|
|
double deltaVolume = LtrPerRefPulse * RefPulsesDelta; /// [l]
|
2018-04-10 14:10:44 +00:00
|
|
|
|
double deltaEnergy = (0.001 * deltaVolume) * (T_in - T_out) * Config.Formulas.HeatCoefficientWater(16, T_in, T_out, heatMetersTestParams.FlowMeasuredAtHiTempPipe); /// [J] = [m3] * [K] * [J/(m3 K)]
|
2016-08-22 14:00:48 +00:00
|
|
|
|
Energy.Update(deltaEnergy);
|
|
|
|
|
|
VolumeForEnergy.Update(deltaVolume);
|
|
|
|
|
|
lastEnergyUpdateTime = StateMachine.Time;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (compound)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// TODO: Reimplement for combined meters
|
|
|
|
|
|
//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);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
|
|
|
|
|
|
}
|
2014-09-23 11:16:59 +00:00
|
|
|
|
while (cBrd.EtPulses(0) < totalPulses);
|
2016-08-22 14:00:48 +00:00
|
|
|
|
/// Measurement loop - end
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
|
|
|
|
|
test_completed:
|
|
|
|
|
|
|
2018-02-11 15:31:25 +00:00
|
|
|
|
StopRecordingStatistics();
|
|
|
|
|
|
|
2017-06-07 14:22:18 +00:00
|
|
|
|
EndTime = (double)StateMachine.Time;
|
|
|
|
|
|
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-09-16 14:09:07 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
}
|
2015-04-28 15:09:42 +00:00
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
2014-09-16 14:09:07 +00:00
|
|
|
|
|
2019-05-16 08:28:22 +00:00
|
|
|
|
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(cBrd.StopFlowRegulationOp(outPath))
|
|
|
|
|
|
.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.FlowRegulationStopped));
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-09-28 15:11:41 +00:00
|
|
|
|
switchTimeEnd = 0.001f * cBrd.ValveOpenCloseTime;
|
|
|
|
|
|
log.WarnFormat("Start valve switch time on test end = {0} ms", cBrd.ValveOpenCloseTime);
|
2014-09-16 14:09:07 +00:00
|
|
|
|
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Waiting before 2nd mass measurement", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(scale.ReadMassOp(ref Mass))
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
|
|
|
|
|
|
.AddOperation(processDataLoggingOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-08-22 14:00:48 +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.TimerExpired));
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-05-10 11:32:49 +00:00
|
|
|
|
if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "End mass");
|
|
|
|
|
|
else LogProcessDataHeaderHeatMeters(processDataLogger, "End mass");
|
|
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
|
|
|
|
|
//------------------------------------------------
|
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)
|
|
|
|
|
|
.AddOperation(scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec))
|
|
|
|
|
|
.AddOperation(processDataLoggingOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2016-08-22 14:00:48 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2019-03-08 13:52:02 +00:00
|
|
|
|
if (e.Contains(Event.TimerExpired))
|
|
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
2016-08-22 14:00:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.BalanceDone));
|
|
|
|
|
|
///
|
2019-05-14 14:59:20 +00:00
|
|
|
|
tMass2 = StateMachine.Time;
|
2016-08-22 14:00:48 +00:00
|
|
|
|
TestEndTime = DateTime.Now;
|
|
|
|
|
|
|
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)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
|
2019-03-18 08:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.AddOperation(cBrd.StopPreviousOp())
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2015-04-28 15:09:42 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-08-22 14:00:48 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-04-28 15:09:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.PreviousStopped));
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
2014-09-16 14:09:07 +00:00
|
|
|
|
|
2018-10-22 16:14:47 +00:00
|
|
|
|
double massStart = Config.Formulas.CorrectedValue(StartMass.Val, scale.Corrections);
|
|
|
|
|
|
double massEnd = Config.Formulas.CorrectedValue(EndMass.Val, scale.Corrections);
|
2018-11-08 09:54:26 +00:00
|
|
|
|
double densityOut = Config.Formulas.WaterDensityFromTempPress((TempUpStat.Average + TempDownStat.Average) / 2,
|
2019-09-18 07:09:00 +00:00
|
|
|
|
(PressUpStat.Average + PressDownStat.Average) / 2);
|
2018-04-10 14:10:44 +00:00
|
|
|
|
double buoyancy = Config.Formulas.Buoyancy();
|
2019-05-15 12:04:40 +00:00
|
|
|
|
double massOfEvaporatedWater = (double)(tMass2 - tMass1) * outPath.Scale.EvaporationRate(TempDivStat.Average);
|
|
|
|
|
|
double volumeCTV = 1000.0 * buoyancy * (massEnd - massStart + massOfEvaporatedWater) / densityOut;
|
2017-11-22 00:22:59 +00:00
|
|
|
|
if (debugLevel == Config.Entities.DebugMode.Simulate) volumeCTV = test.Volume;
|
|
|
|
|
|
|
2017-06-29 10:48:14 +00:00
|
|
|
|
double refEnergy = Energy.Sum * volumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l]
|
2015-04-29 17:03:00 +00:00
|
|
|
|
|
2014-09-16 14:09:07 +00:00
|
|
|
|
///
|
2014-09-16 19:05:54 +00:00
|
|
|
|
/// Enter watermeter end states here
|
2014-09-16 14:09:07 +00:00
|
|
|
|
///
|
2015-04-14 05:14:45 +00:00
|
|
|
|
if (dataEntryCmpnt != null)
|
2014-09-16 19:05:54 +00:00
|
|
|
|
{
|
2017-07-27 16:02:19 +00:00
|
|
|
|
string fileName = string.Format("{0}-end.bmp", test.Name);
|
|
|
|
|
|
|
|
|
|
|
|
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera)
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] endImages = new string[sensPath.RegisterReaders.Length];
|
|
|
|
|
|
|
|
|
|
|
|
State state2 = State.Create(string.Format("{0}({1}) : Grabbing images", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp);
|
|
|
|
|
|
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
GenericDevices.IRoiForFixedStart roi = sensPath.RegisterReaders[i] as GenericDevices.IRoiForFixedStart;
|
|
|
|
|
|
if (roi != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
string directory = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
|
|
|
|
|
Directory.CreateDirectory(directory);
|
|
|
|
|
|
endImages[i] = Path.Combine(directory, fileName);
|
|
|
|
|
|
state2.AddOperation(roi.GrabImageOp(endImages[i]));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
state2.EnterState();
|
2019-11-13 15:27:18 +00:00
|
|
|
|
do {
|
2017-07-27 16:02:19 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
|
2017-12-08 10:45:37 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
|
2017-07-27 16:02:19 +00:00
|
|
|
|
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; break; }
|
|
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.CameraBusy));
|
|
|
|
|
|
|
|
|
|
|
|
(dataEntryCmpnt as GenericDevices.IDataEntryForCamera).EndImages = endImages;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
|
2017-04-24 07:44:11 +00:00
|
|
|
|
State state = State.Create(string.Format("{0}({1}) : Entering the end-state", test.Method, test.Name));
|
2016-08-22 11:55:28 +00:00
|
|
|
|
if (heatMetersTestParams != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
state.AddOperation((dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).
|
2017-11-22 22:53:41 +00:00
|
|
|
|
ShowTestEndFormOp(sensPath.RegisterReaders,
|
|
|
|
|
|
volumeCTV, test.ErrLimLo + test.Uncertainty, test.ErrLimHi - test.Uncertainty,
|
2016-08-22 11:55:28 +00:00
|
|
|
|
refEnergy, test.ErrLimLo + test.Uncertainty, test.ErrLimHi - test.Uncertainty));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-11-22 22:53:41 +00:00
|
|
|
|
state.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(sensPath.RegisterReaders,
|
|
|
|
|
|
volumeCTV, test.ErrLimLo + test.Uncertainty, test.ErrLimHi - test.Uncertainty));
|
2016-08-22 11:55:28 +00:00
|
|
|
|
}
|
2019-03-18 08:14:13 +00:00
|
|
|
|
state.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
2014-09-23 11:16:59 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-08-22 14:00:48 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2014-09-23 11:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ModelessFormClosed));
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-28 16:45:43 +00:00
|
|
|
|
if (heatMetersTestParams != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < Config.Data.HeatMetersCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
BenchControl.Elde.FixedStartRegisterReader.RegisterReader volumeRegisterReader =
|
|
|
|
|
|
sensPath.RegisterReaders[2 * i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
|
|
|
|
|
|
|
|
|
|
|
|
BenchControl.Elde.FixedStartRegisterReader.RegisterReader energyRegisterReader =
|
|
|
|
|
|
sensPath.RegisterReaders[2 * i + 1] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
|
|
|
|
|
|
|
|
|
|
|
|
if (volumeRegisterReader != null) volumeRegisterReader.EndWMState = dataEntryCmpnt.WMEndState(i);
|
|
|
|
|
|
if (energyRegisterReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
energyRegisterReader.EndWMState = (float)(dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyEndState(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2014-09-16 19:05:54 +00:00
|
|
|
|
{
|
2016-10-28 16:45:43 +00:00
|
|
|
|
for (int i = 0; i < Config.Data.WMsCount; i++)
|
|
|
|
|
|
{
|
2017-07-28 14:21:30 +00:00
|
|
|
|
GenericDevices.IRegisterReader rr = sensPath.RegisterReaders[i];
|
2015-06-02 15:58:42 +00:00
|
|
|
|
|
2017-07-28 14:21:30 +00:00
|
|
|
|
if (rr is BenchControl.Elde.FixedStartRegisterReader.RegisterReader)
|
|
|
|
|
|
(rr as BenchControl.Elde.FixedStartRegisterReader.RegisterReader).EndWMState = dataEntryCmpnt.WMEndState(i);
|
|
|
|
|
|
|
|
|
|
|
|
if (rr is BenchControl.Network.Camera.RoiForFixedStart.Roi)
|
|
|
|
|
|
(rr as BenchControl.Network.Camera.RoiForFixedStart.Roi).EndWMState = dataEntryCmpnt.WMEndState(i);
|
|
|
|
|
|
}
|
2014-09-16 19:05:54 +00:00
|
|
|
|
}
|
2017-07-27 16:02:19 +00:00
|
|
|
|
|
|
|
|
|
|
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera && (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).SaveImages)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// SaveImages==true ... copy images to the directory that will be archived at the end of the cycle
|
|
|
|
|
|
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
GenericDevices.IRoiForFixedStart roi = sensPath.RegisterReaders[i] as GenericDevices.IRoiForFixedStart;
|
|
|
|
|
|
if (roi != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
string srcDir = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
|
|
|
|
|
string destDir = Path.Combine(Program.ImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
2018-03-28 11:21:28 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (File.Exists(Path.Combine(srcDir, fileName)))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(destDir);
|
|
|
|
|
|
File.Copy(Path.Combine(srcDir, fileName), Path.Combine(destDir, fileName), true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.ErrorFormat("Failed to copy image {0} to {1}: {2}", fileName, destDir, exc.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-07-27 16:02:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-09-16 14:09:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Test_completed);
|
|
|
|
|
|
//------------------------------------------------
|
2014-09-05 07:06:23 +00:00
|
|
|
|
|
2015-04-28 13:27:47 +00:00
|
|
|
|
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
|
2016-08-22 14:00:48 +00:00
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Populate TestResult data entity with data
|
|
|
|
|
|
///
|
|
|
|
|
|
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
|
|
|
|
|
|
|
|
|
|
|
|
if (tstRslt != null)
|
|
|
|
|
|
{
|
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-08-22 14:00:48 +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;
|
2019-05-14 14:59:20 +00:00
|
|
|
|
tstRslt.TestTime = Math.Max(1.0, EndTime - StartTime); /// [s] measurement time, at least 1 to prevent division by zero
|
2019-05-15 12:04:40 +00:00
|
|
|
|
tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1;
|
|
|
|
|
|
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
|
2016-08-22 14:00:48 +00:00
|
|
|
|
tstRslt.MassStartRaw = StartMass.Val;
|
2018-02-26 11:18:04 +00:00
|
|
|
|
tstRslt.MassStart = massStart;
|
|
|
|
|
|
tstRslt.MassEndRaw = EndMass.Val;
|
|
|
|
|
|
tstRslt.MassEnd = massEnd;
|
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 * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
|
|
|
|
|
|
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
2018-02-26 11:18:04 +00:00
|
|
|
|
tstRslt.Buoyancy = buoyancy;
|
2018-07-13 11:00:03 +00:00
|
|
|
|
tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3]
|
2018-07-19 11:19:47 +00:00
|
|
|
|
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);
|
|
|
|
|
|
/// Calculated master pulses per liter
|
|
|
|
|
|
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, false, true, switchTimeStart, switchTimeEnd, out infoFlags) : 0;
|
|
|
|
|
|
tstRslt.InfoFlags = infoFlags;
|
2017-08-19 10:07:57 +00:00
|
|
|
|
|
2016-08-22 14:00:48 +00:00
|
|
|
|
if (compound)
|
|
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// 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-22 14:00:48 +00:00
|
|
|
|
|
|
|
|
|
|
Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain);
|
|
|
|
|
|
Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux);
|
|
|
|
|
|
|
|
|
|
|
|
for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux
|
|
|
|
|
|
{
|
|
|
|
|
|
Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt;
|
2017-03-10 13:31:08 +00:00
|
|
|
|
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux];
|
2016-08-22 14:00:48 +00:00
|
|
|
|
|
|
|
|
|
|
if (meterRslt != null && regReader != null)
|
|
|
|
|
|
{
|
2018-04-10 14:10:44 +00:00
|
|
|
|
meterRslt.RegReaderType = (int)regReader.RegisterReaderType;
|
2017-11-22 20:06:00 +00:00
|
|
|
|
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
|
2016-08-22 14:00:48 +00:00
|
|
|
|
meterRslt.VolumeStart = regReader.BeginWMState; /// [l]
|
|
|
|
|
|
meterRslt.VolumeEnd = regReader.EndWMState; /// [l]
|
|
|
|
|
|
meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart; /// [l]
|
|
|
|
|
|
meterRslt.VolumeRef = tstRslt.VolumeCTV; /// [l]
|
|
|
|
|
|
meterRslt.PulsesMeter = meterRslt.VolumeMeter;
|
|
|
|
|
|
meterRslt.PulsesMaster = tstRslt.PulsesMaster;
|
|
|
|
|
|
meterRslt.TestTime = tstRslt.TestTime;
|
2018-04-10 14:10:44 +00:00
|
|
|
|
meterRslt.Error = Config.Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); /// Not used for evaluation
|
2016-08-22 14:00:48 +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; /// [l] must be calculated before main & aux. meter error
|
|
|
|
|
|
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);
|
|
|
|
|
|
mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed;
|
2016-08-22 14:00:48 +00:00
|
|
|
|
mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true;
|
2017-07-04 09:19:05 +00:00
|
|
|
|
tstRslt.TestDone = true;
|
2016-08-22 14:00:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (heatMetersTestParams != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Heat meters
|
|
|
|
|
|
///
|
2016-10-05 11:35:29 +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-22 14:00:48 +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-22 14:00:48 +00:00
|
|
|
|
|
2016-10-05 11:35:29 +00:00
|
|
|
|
Results.Entities.MeterTestRslt volumeRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.HeatMeterVolume);
|
|
|
|
|
|
Results.Entities.MeterTestRslt energyRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.HeatMeterEnergy);
|
2016-08-22 14:00:48 +00:00
|
|
|
|
|
2017-03-10 13:31:08 +00:00
|
|
|
|
GenericDevices.IRegisterReader volumeRegReader =
|
|
|
|
|
|
(sensPath.RegisterReaders.Length > 2 * i) ? sensPath.RegisterReaders[2 * i] : null;
|
2016-10-05 11:35:29 +00:00
|
|
|
|
|
2017-03-10 13:31:08 +00:00
|
|
|
|
GenericDevices.IRegisterReader energyRegReader =
|
|
|
|
|
|
(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)
|
2016-08-22 14:00:48 +00:00
|
|
|
|
{
|
2017-11-22 20:06:00 +00:00
|
|
|
|
volumeRslt.PulsesPerLiter = volumeRegReader.PulsesPerLtr;
|
2016-10-05 11:35:29 +00:00
|
|
|
|
volumeRslt.VolumeStart = volumeRegReader.BeginWMState;
|
|
|
|
|
|
volumeRslt.VolumeEnd = volumeRegReader.EndWMState;
|
|
|
|
|
|
volumeRslt.VolumeMeter = volumeRslt.VolumeEnd - volumeRslt.VolumeStart;
|
|
|
|
|
|
volumeRslt.VolumeRef = tstRslt.VolumeCTV;
|
|
|
|
|
|
volumeRslt.PulsesMeter = volumeRslt.VolumeMeter;
|
|
|
|
|
|
volumeRslt.PulsesMaster = tstRslt.PulsesMaster; /// <----------------- ???
|
|
|
|
|
|
volumeRslt.TestTime = tstRslt.TestTime;
|
|
|
|
|
|
|
2018-04-10 14:10:44 +00:00
|
|
|
|
volumeRslt.Error = Config.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-08-22 14:00:48 +00:00
|
|
|
|
|
2016-10-05 11:35:29 +00:00
|
|
|
|
if (energyRslt != null && energyRegReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm)
|
|
|
|
|
|
{
|
2017-11-22 20:06:00 +00:00
|
|
|
|
volumeRslt.PulsesPerLiter = energyRegReader.PulsesPerLtr;
|
2016-10-05 11:35:29 +00:00
|
|
|
|
energyRslt.VolumeStart = (dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyStartState(i);
|
|
|
|
|
|
energyRslt.VolumeEnd = (dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyEndState(i);
|
|
|
|
|
|
energyRslt.VolumeMeter = energyRslt.VolumeEnd - energyRslt.VolumeStart;
|
|
|
|
|
|
energyRslt.VolumeRef = tstRslt.RefEnergy;
|
|
|
|
|
|
energyRslt.PulsesMeter = energyRslt.VolumeMeter;
|
|
|
|
|
|
energyRslt.PulsesMaster = tstRslt.PulsesMaster; /// <----------------- ???
|
|
|
|
|
|
|
2018-04-10 14:10:44 +00:00
|
|
|
|
energyRslt.Error = Config.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);
|
|
|
|
|
|
energyRslt.TestDone = true;
|
2017-07-04 09:19:05 +00:00
|
|
|
|
tstRslt.TestDone = true;
|
2016-08-22 14:00:48 +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-22 14:00:48 +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-08-22 14:00:48 +00:00
|
|
|
|
|
|
|
|
|
|
if (meterRslt != null && regReader != null)
|
|
|
|
|
|
{
|
2018-04-10 14:10:44 +00:00
|
|
|
|
meterRslt.RegReaderType = (int)regReader.RegisterReaderType;
|
2017-11-22 20:06:00 +00:00
|
|
|
|
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
|
2016-08-22 14:00:48 +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;
|
|
|
|
|
|
meterRslt.PulsesMaster = tstRslt.PulsesMaster;
|
|
|
|
|
|
meterRslt.TestTime = tstRslt.TestTime;
|
2018-04-10 14:10:44 +00:00
|
|
|
|
meterRslt.Error = Config.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;
|
2016-08-22 14:00:48 +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,
|
2018-10-22 16:14:47 +00:00
|
|
|
|
scale != null ? scale.Name : string.Empty,
|
2016-08-22 14:00:48 +00:00
|
|
|
|
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
|
|
|
|
|
|
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
|
|
|
|
|
|
|
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-08-22 14:00:48 +00:00
|
|
|
|
/// Update results
|
|
|
|
|
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter));
|
|
|
|
|
|
|
|
|
|
|
|
/// Append the results to the CSV-file
|
|
|
|
|
|
allResults.Info(TestResult2CsvLine(testName, test.Part));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(cBrd.StopPreviousOp())
|
|
|
|
|
|
.EnterState();
|
2019-03-18 08:14:13 +00:00
|
|
|
|
do {
|
2017-12-02 16:54:38 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2020-05-21 14:37:09 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; }
|
2017-12-02 16:54:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.PreviousStopped));
|
2016-08-22 14:00:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-03-28 21:47:32 +00:00
|
|
|
|
stopTestWOTransitionAfter:
|
|
|
|
|
|
|
2019-03-18 08:14:13 +00:00
|
|
|
|
return new List<Event> { retVal };
|
2016-08-22 14:00:48 +00:00
|
|
|
|
}
|
2014-09-05 07:06:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|