2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
2017-01-24 17:55:36 +00:00
|
|
|
|
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2015-01-28 17:17:50 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using log4net;
|
2015-12-04 16:17:20 +00:00
|
|
|
|
using Config.Entities;
|
2015-01-28 17:17:50 +00:00
|
|
|
|
using TBF.BenchControl;
|
|
|
|
|
|
using TBF.Boxes;
|
|
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
using TBF.UiBridge;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.TestMethods.Adjustment
|
|
|
|
|
|
{
|
2015-01-28 18:33:02 +00:00
|
|
|
|
public class AdjustmentSeq : Sequences.SequenceBase
|
2015-01-28 17:17:50 +00:00
|
|
|
|
{
|
2015-01-28 18:33:02 +00:00
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(AdjustmentSeq));
|
|
|
|
|
|
|
|
|
|
|
|
System.Windows.Forms.Form modelessDlg;
|
|
|
|
|
|
///
|
2015-09-28 20:07:58 +00:00
|
|
|
|
delegate void ErrorsFormDlgt(AdjustmentSeq myRef, IList<GenericDevices.IWaterMeter> waterMeters);
|
2015-01-28 18:33:02 +00:00
|
|
|
|
///
|
2015-09-28 20:07:58 +00:00
|
|
|
|
void OpenWMErrorsForm(AdjustmentSeq myRef, IList<GenericDevices.IWaterMeter> waterMeters)
|
2015-01-28 18:33:02 +00:00
|
|
|
|
{
|
2015-09-17 18:58:56 +00:00
|
|
|
|
#pragma warning disable 162 /// Disables 'Unreachable code detected' warning
|
|
|
|
|
|
|
2015-12-04 16:17:20 +00:00
|
|
|
|
if (Config.Data.WMsCount > 12)
|
2015-09-17 18:58:56 +00:00
|
|
|
|
{
|
2015-09-28 20:07:58 +00:00
|
|
|
|
myRef.modelessDlg = new WMErrorsForm24(waterMeters);
|
2015-09-17 18:58:56 +00:00
|
|
|
|
}
|
2015-12-04 16:17:20 +00:00
|
|
|
|
else if (Config.Data.WMsCount > 6)
|
2015-10-05 07:59:27 +00:00
|
|
|
|
{
|
|
|
|
|
|
myRef.modelessDlg = new WMErrorsForm12(waterMeters);
|
|
|
|
|
|
}
|
2015-09-17 18:58:56 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2015-09-28 20:07:58 +00:00
|
|
|
|
myRef.modelessDlg = new WMErrorsForm(waterMeters);
|
2015-09-17 18:58:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma warning restore 162 /// Disables 'Unreachable code detected' warning
|
|
|
|
|
|
|
2015-01-28 18:33:02 +00:00
|
|
|
|
modelessDlg.Show();
|
|
|
|
|
|
}
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-09-21 12:04:31 +00:00
|
|
|
|
/// Adjustment method sequence
|
2015-01-28 17:17:50 +00:00
|
|
|
|
/// </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>
|
2016-12-10 11:40:35 +00:00
|
|
|
|
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter, DebugMode mode)
|
2015-01-28 17:17:50 +00:00
|
|
|
|
{
|
2015-09-28 20:07:58 +00:00
|
|
|
|
float simulatedError = 4.5f; /// %
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
|
|
|
|
|
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
|
|
|
|
|
|
|
|
|
|
|
|
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
|
|
|
|
|
Event retVal = Event.Done;
|
|
|
|
|
|
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
|
|
|
|
|
|
|
2016-02-10 18:24:10 +00:00
|
|
|
|
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
|
2015-01-28 17:17:50 +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-02-10 18:24:10 +00:00
|
|
|
|
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
2016-10-18 09:49:32 +00:00
|
|
|
|
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false);
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
2016-12-10 11:40:35 +00:00
|
|
|
|
int repetitionNr = outerLoopMode ? outerLoopCounter : 1; /// First test: repetitionNr=1
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
|
|
|
|
|
//====================================
|
|
|
|
|
|
// Transition or SetRoute - Start
|
|
|
|
|
|
//====================================
|
2015-05-22 08:29:56 +00:00
|
|
|
|
switch (Transition(transitionBefore, TransitionContext.BeforeTest))
|
2015-01-28 17:17:50 +00:00
|
|
|
|
{
|
|
|
|
|
|
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 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;
|
2017-05-05 10:41:15 +00:00
|
|
|
|
TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, 1, 1, 30, 0, Convert.ToInt32(test.TstTime) + 15, 0, 0 });
|
2016-01-08 18:18:45 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted));
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
2016-01-08 18:18:45 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
2015-01-28 17:17:50 +00:00
|
|
|
|
int flowSetTime0 = StateMachine.Time;
|
|
|
|
|
|
|
2015-02-01 18:30:00 +00:00
|
|
|
|
//------------------------------------------------
|
2016-10-13 13:02:33 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Starting_the_pump);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
|
|
|
|
|
|
///
|
|
|
|
|
|
State.Create("Adjustment : Starting the pump")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
2017-04-24 09:58:57 +00:00
|
|
|
|
// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
|
2016-10-13 13:02:33 +00:00
|
|
|
|
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
|
|
|
|
|
|
.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 (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2017-04-24 09:58:57 +00:00
|
|
|
|
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
|
2016-10-13 13:02:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (test.TimeBeforeFlow > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
State.Create("Adjustment : Waiting before flow setting process starts")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(test.TimeBeforeFlow))
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
|
|
|
|
|
.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 (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.TimerExpired));
|
|
|
|
|
|
}
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
2016-10-13 13:02:33 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Setting_the_flow);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
State.Create("Adjustment : Setting the flow")
|
2015-01-28 17:17:50 +00:00
|
|
|
|
.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-01-28 17:17:50 +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-01-28 17:17:50 +00:00
|
|
|
|
|
2016-01-08 18:18:45 +00:00
|
|
|
|
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-01-28 17:17:50 +00:00
|
|
|
|
if (e.Contains(Event.RegulValveTimeOut))
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, Strings.Timeout);
|
|
|
|
|
|
retVal = Event.Done;
|
|
|
|
|
|
goto stopTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.Contains(Event.Next)) goto flow_set;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.FlowReached));
|
|
|
|
|
|
|
2015-09-28 20:07:58 +00:00
|
|
|
|
flow_set:
|
2017-06-08 14:55:24 +00:00
|
|
|
|
|
2016-01-08 18:18:45 +00:00
|
|
|
|
int flowSetTime = StateMachine.Time - flowSetTime0;
|
2017-06-08 14:55:24 +00:00
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
|
|
|
|
|
|
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
temperature_set:
|
|
|
|
|
|
|
2015-01-28 17:17:50 +00:00
|
|
|
|
/// Show the modeless dialog with error indication
|
2015-09-28 20:07:58 +00:00
|
|
|
|
Program.MainWnd.Invoke(new ErrorsFormDlgt(OpenWMErrorsForm), new object[] { this, WaterMeters });
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
|
|
|
|
|
loop:
|
|
|
|
|
|
int time = StateMachine.Time;
|
2016-10-07 14:22:36 +00:00
|
|
|
|
double currentFlow = RefFlow.Val;
|
2015-01-28 17:17:50 +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
|
|
|
|
|
2017-01-22 19:39:14 +00:00
|
|
|
|
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
2015-09-28 20:07:58 +00:00
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Test_in_progress);
|
|
|
|
|
|
//------------------------------------------------
|
2015-12-04 16:17:20 +00:00
|
|
|
|
if (mode == Config.Entities.DebugMode.Simulate)
|
2015-01-28 17:17:50 +00:00
|
|
|
|
{
|
2016-01-03 01:05:35 +00:00
|
|
|
|
/// TODO: Reimplement
|
|
|
|
|
|
//tstRslt = MakeSimulated(test, 1, simulatedError);
|
2015-09-28 20:07:58 +00:00
|
|
|
|
simulatedError *= 0.6f;
|
|
|
|
|
|
|
|
|
|
|
|
State.Create("Adjustment : Simulating the test")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(new Operations.TimerOp(5))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-09-28 20:07:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.TimerExpired));
|
2015-01-28 17:17:50 +00:00
|
|
|
|
}
|
2015-09-28 20:07:58 +00:00
|
|
|
|
else
|
2015-01-28 17:17:50 +00:00
|
|
|
|
{
|
2015-09-28 20:07:58 +00:00
|
|
|
|
State.Create("Adjustment : Starting the test")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperations(measureOperations)
|
|
|
|
|
|
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro,
|
|
|
|
|
|
test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
2015-01-28 17:17:50 +00:00
|
|
|
|
{
|
2015-09-28 20:07:58 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-01-28 17:17:50 +00:00
|
|
|
|
}
|
2015-09-28 20:07:58 +00:00
|
|
|
|
while (!e.Contains(Event.MeasurementStarted));
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
2015-09-28 20:07:58 +00:00
|
|
|
|
/// Measurement loop - preparation
|
2016-02-13 15:47:15 +00:00
|
|
|
|
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
|
2015-09-28 20:07:58 +00:00
|
|
|
|
queryEnd1 = cBrd.QueryMeasurementEndOp();
|
|
|
|
|
|
queryEnd2 = cBrd.QueryMeasurementEndOp();
|
|
|
|
|
|
|
2017-05-18 11:22:11 +00:00
|
|
|
|
ClearAllStatistics(StateMachine.Time);
|
2015-09-28 20:07:58 +00:00
|
|
|
|
|
|
|
|
|
|
/// Measurement loop - begin
|
|
|
|
|
|
while (true)
|
2015-01-28 17:17:50 +00:00
|
|
|
|
{
|
2015-09-28 20:07:58 +00:00
|
|
|
|
//--------------------------------
|
|
|
|
|
|
switch (ReadRegistersTempPressAmbient(measureOperations, true))
|
|
|
|
|
|
{
|
2016-06-15 15:04:25 +00:00
|
|
|
|
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
|
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-09-28 20:07:58 +00:00
|
|
|
|
case Event.MeasurementCompleted: goto one_test_completed;
|
|
|
|
|
|
}
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
2015-12-20 19:48:50 +00:00
|
|
|
|
RefFreq.Val = cBrd.ReferenceFreq;
|
|
|
|
|
|
RefFlow.Val = cBrd.ReferenceFlow;
|
2017-05-18 11:22:11 +00:00
|
|
|
|
UpdateAllStatistics(StateMachine.Time);
|
2015-01-28 17:17:50 +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));
|
2015-09-28 20:07:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
/// Measurement loop - end
|
|
|
|
|
|
|
|
|
|
|
|
one_test_completed:
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Adjustment_in_progress);
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
|
2016-01-03 01:05:35 +00:00
|
|
|
|
TestEndTime = DateTime.Now;
|
|
|
|
|
|
|
2015-09-28 20:07:58 +00:00
|
|
|
|
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
|
|
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Populate TestResult data entity with data
|
|
|
|
|
|
///
|
2016-01-03 01:05:35 +00:00
|
|
|
|
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
|
|
|
|
|
|
|
|
|
|
|
|
if (tstRslt != null)
|
2015-01-28 17:17:50 +00:00
|
|
|
|
{
|
2017-05-10 08:43:33 +00:00
|
|
|
|
UpdateTempPressDensAmb(tstRslt);
|
2016-01-03 01:05:35 +00:00
|
|
|
|
|
|
|
|
|
|
/// Main results
|
|
|
|
|
|
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.MassStart = 0;
|
2016-01-03 01:05:35 +00:00
|
|
|
|
tstRslt.MassEnd = 0;
|
|
|
|
|
|
tstRslt.FlowMass = 0; /// [kg/h]
|
2016-02-10 18:24:10 +00:00
|
|
|
|
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * cBrd.EtPulses(0) / tstRslt.TestTime; /// [m3/h]
|
2017-07-20 13:16:55 +00:00
|
|
|
|
tstRslt.Buoyancy = Formulas.Buoyancy();
|
2016-02-10 18:24:10 +00:00
|
|
|
|
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
2016-01-03 01:05:35 +00:00
|
|
|
|
tstRslt.ConstMaster = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume); /// Calculate master flowmeter coefficient
|
|
|
|
|
|
tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
|
|
|
|
|
|
tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement
|
|
|
|
|
|
|
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 = 0;
|
|
|
|
|
|
tstRslt.DiverterEnd = 0;
|
|
|
|
|
|
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, false, 0, 0) : 0;
|
2017-08-19 10:07:57 +00:00
|
|
|
|
|
2016-06-30 12:02:25 +00:00
|
|
|
|
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
2016-06-30 10:54:34 +00:00
|
|
|
|
{
|
2016-06-30 12:02:25 +00:00
|
|
|
|
if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue;
|
|
|
|
|
|
|
|
|
|
|
|
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single);
|
2016-02-13 15:47:15 +00:00
|
|
|
|
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
|
2016-01-03 01:05:35 +00:00
|
|
|
|
|
|
|
|
|
|
if (meterRslt != null && regReader != null)
|
2015-09-28 20:07:58 +00:00
|
|
|
|
{
|
2016-01-03 01:05:35 +00:00
|
|
|
|
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
|
2016-02-13 15:47:15 +00:00
|
|
|
|
meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses);
|
|
|
|
|
|
meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses);
|
2016-02-13 07:18:49 +00:00
|
|
|
|
meterRslt.VolumeStart = 0; /// liter
|
|
|
|
|
|
meterRslt.VolumeEnd = 0; /// liter
|
|
|
|
|
|
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter
|
|
|
|
|
|
meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter
|
|
|
|
|
|
meterRslt.TestTime = tstRslt.TestTime;
|
|
|
|
|
|
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
|
|
|
|
|
|
meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty)
|
|
|
|
|
|
&& (meterRslt.Error <= test.ErrLimHi - test.Uncertainty);
|
2017-07-04 09:19:05 +00:00
|
|
|
|
meterRslt.TestDone = true;
|
|
|
|
|
|
tstRslt.TestDone = true;
|
|
|
|
|
|
}
|
2015-01-28 17:17:50 +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));
|
2016-02-13 18:25:43 +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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-13 18:25:43 +00:00
|
|
|
|
/// Update results
|
|
|
|
|
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt));
|
2015-01-28 17:17:50 +00:00
|
|
|
|
}
|
2015-09-28 20:07:58 +00:00
|
|
|
|
/// Add data - end
|
2015-01-28 17:17:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-03 01:05:35 +00:00
|
|
|
|
|
2015-01-28 17:17:50 +00:00
|
|
|
|
/// Update modeless dialog error information
|
2016-01-04 14:24:16 +00:00
|
|
|
|
Bridge.OnAdjustmentInProgress(this, new AdjustmentInProgressEventArgs(testName));
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
|
|
|
|
|
/// Test 'Quit'
|
|
|
|
|
|
if ((modelessDlg is GenericDevices.IHasCompleted) && !(modelessDlg as GenericDevices.IHasCompleted).Completed)
|
|
|
|
|
|
{
|
|
|
|
|
|
goto loop; /// Modeless dilaog not closed, keep looping
|
|
|
|
|
|
}
|
|
|
|
|
|
modelessDlg = null; /// Modeless dialog is closed now
|
|
|
|
|
|
|
|
|
|
|
|
/// Append the results to the CSV-file
|
2016-01-03 01:05:35 +00:00
|
|
|
|
allResults.Info(TestResult2CsvLine(testName, test.Part));
|
2015-01-28 17:17:50 +00:00
|
|
|
|
|
|
|
|
|
|
stopTest:
|
|
|
|
|
|
|
|
|
|
|
|
///----------------------///
|
|
|
|
|
|
/// Quit this sequence ///
|
|
|
|
|
|
///----------------------///
|
|
|
|
|
|
|
|
|
|
|
|
State.Create("Adjustment : Stopping diverter, gate, etc.")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(cBrd.StopPreviousOp())
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2016-04-14 07:16:20 +00:00
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
2015-01-28 17:17:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.PreviousStopped));
|
|
|
|
|
|
|
|
|
|
|
|
/// Transition sequence at the end of test
|
|
|
|
|
|
/// Prevent overwriting 'retVal' in case it was set to non-default value earlier
|
2016-02-07 21:27:32 +00:00
|
|
|
|
switch (Transition(transitionAfter, (retVal == Event.Done) ? TransitionContext.AfterTest : TransitionContext.Stop))
|
2015-01-28 17:17:50 +00:00
|
|
|
|
{
|
|
|
|
|
|
case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
|
|
|
|
|
|
case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-05 10:41:15 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr,
|
|
|
|
|
|
(retVal == Event.Done) ? Config.Entities.Progress.Completed : Config.Entities.Progress.Aborted));
|
2016-01-08 18:18:45 +00:00
|
|
|
|
|
2015-01-28 17:17:50 +00:00
|
|
|
|
/// Create a list with one item 'retVal' (default is Event.Done) and return it
|
2015-02-02 22:18:28 +00:00
|
|
|
|
IList<Event> retList = new List<Event>(1);
|
2015-01-28 17:17:50 +00:00
|
|
|
|
retList.Add(retVal);
|
|
|
|
|
|
return retList;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|