2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using log4net;
|
2015-12-04 16:17:20 +00:00
|
|
|
|
using Config.Entities;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using TBF.UiBridge;
|
2015-09-04 11:49:04 +00:00
|
|
|
|
using TBF.BenchControl;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using TBF.BenchControl.Operations;
|
|
|
|
|
|
using TBF.BenchControl.GenericDevices;
|
2014-07-31 15:04:09 +00:00
|
|
|
|
using TBF.Boxes;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.Sequences
|
|
|
|
|
|
{
|
2015-02-01 15:20:27 +00:00
|
|
|
|
public class MainSeq : SequenceBase
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(MainSeq));
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString() { return "Sequences.MainSeq"; }
|
|
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
|
|
|
|
|
System.Windows.Forms.Form modelessDlg;
|
|
|
|
|
|
///
|
2016-01-19 16:38:09 +00:00
|
|
|
|
delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList<Test> tests, IList<Generic.ITestParams> multiTestParams);
|
2015-09-04 11:49:04 +00:00
|
|
|
|
///
|
2016-01-19 16:38:09 +00:00
|
|
|
|
void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, IList<Test> tests, IList<Generic.ITestParams> multiTestParams)
|
2015-09-04 11:49:04 +00:00
|
|
|
|
{
|
2015-11-23 19:31:01 +00:00
|
|
|
|
try
|
2015-09-04 11:49:04 +00:00
|
|
|
|
{
|
2016-01-19 16:38:09 +00:00
|
|
|
|
/// 1nd argument
|
2015-11-23 19:31:01 +00:00
|
|
|
|
TestMethods.iPerlCommunication.TestMethodCfg iPerlCfg = cfg as TestMethods.iPerlCommunication.TestMethodCfg;
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
2016-01-19 16:38:09 +00:00
|
|
|
|
/// 2rd argument: as is
|
2016-01-03 01:05:35 +00:00
|
|
|
|
|
2016-01-19 16:38:09 +00:00
|
|
|
|
/// 3th argument
|
2015-11-23 19:31:01 +00:00
|
|
|
|
IList<TestMethods.iPerlCommunication.iPerlCommunicationParams> iPerlCommParams = new List<TestMethods.iPerlCommunication.iPerlCommunicationParams>();
|
|
|
|
|
|
foreach (var tp in multiTestParams) iPerlCommParams.Add(tp as TestMethods.iPerlCommunication.iPerlCommunicationParams);
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
2016-01-19 16:38:09 +00:00
|
|
|
|
myRef.modelessDlg = new TestMethods.iPerlCommunication.iPerlCommunicationForm(iPerlCfg, tests, iPerlCommParams);
|
2015-11-23 19:31:01 +00:00
|
|
|
|
myRef.modelessDlg.Show();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.FatalFormat("---------------( MainSeq : OpenIperlCommForm crashed !!! )---------------");
|
|
|
|
|
|
log.FatalFormat("Message : {0}", e.Message);
|
|
|
|
|
|
if (e.InnerException != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
|
|
|
|
|
|
log.Fatal("--------------------------------------");
|
|
|
|
|
|
}
|
2015-09-04 11:49:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CloseIPerlCommForm()
|
|
|
|
|
|
{
|
|
|
|
|
|
UiBridge.Bridge.OnCloseModelessForm(this, null);
|
|
|
|
|
|
modelessDlg = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
/// <summary> Constructor </summary>
|
|
|
|
|
|
public MainSeq()
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2014-08-11 19:19:28 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Main sequence
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dummyArg"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2015-12-04 16:17:20 +00:00
|
|
|
|
public IList<Event> Execute(Test dummyArg)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2015-01-15 02:51:33 +00:00
|
|
|
|
/// Operations running in more then one state
|
2014-08-12 16:22:32 +00:00
|
|
|
|
checkUiOp = new CheckUIOp(true);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
IList<Event> e;
|
|
|
|
|
|
Selection selection;
|
|
|
|
|
|
bool benchFilled = false;
|
|
|
|
|
|
|
2015-09-04 11:49:04 +00:00
|
|
|
|
int simultWithPurgingCount = 0;
|
2015-09-10 18:07:06 +00:00
|
|
|
|
Generic.IComponentCfg simultWithPurgingCfg = null;
|
2016-01-19 16:38:09 +00:00
|
|
|
|
IList<Config.Entities.Test> simultWithPurgingTests = new List<Config.Entities.Test>();
|
2015-09-10 18:07:06 +00:00
|
|
|
|
IList<Generic.ITestParams> simultWithPurgingParams = new List<Generic.ITestParams>();
|
|
|
|
|
|
|
|
|
|
|
|
int simultWithEvacuationCount = 0;
|
|
|
|
|
|
Generic.IComponentCfg simultWithEvacuationCfg = null;
|
2016-01-19 16:38:09 +00:00
|
|
|
|
IList<Config.Entities.Test> simultWithEvacuationTests = new List<Config.Entities.Test>();
|
2015-09-10 18:07:06 +00:00
|
|
|
|
IList<Generic.ITestParams> simultWithEvacuationParams = new List<Generic.ITestParams>();
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
2014-08-08 14:25:51 +00:00
|
|
|
|
StateMachine.LoadProcedure(true); // TODO: Implement as an operation so that the worker thread is not blocked
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
|
|
|
|
|
|
|
2014-12-10 11:36:57 +00:00
|
|
|
|
//--------------------------------------------------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Starting_system);
|
|
|
|
|
|
State.Create("MainSeq : Setting valves to default positions")
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
|
|
|
|
|
.EnterState();
|
2014-07-28 07:54:35 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
}
|
2014-12-10 11:36:57 +00:00
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-12-10 11:36:57 +00:00
|
|
|
|
//--------------------------------------------------------------------------------------------
|
2014-12-10 21:39:53 +00:00
|
|
|
|
IntBox remainingTime = new IntBox();
|
|
|
|
|
|
State startNew = State.Create("MainSeq : Emptying tanks, Starting cameras")
|
2014-07-28 07:54:35 +00:00
|
|
|
|
.AddOperation(checkUiOp);
|
|
|
|
|
|
foreach (var cmpnt in StateMachine.Components)
|
|
|
|
|
|
{
|
|
|
|
|
|
Cameras.IdcCamera.IdcCamera camera = cmpnt as Cameras.IdcCamera.IdcCamera;
|
2015-12-04 16:17:20 +00:00
|
|
|
|
if ((camera != null) && (camera.Cfg.DebugLevel != DebugMode.DetectedOff))
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
startNew.AddOperation(camera.StartNewOp());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-12-10 11:36:57 +00:00
|
|
|
|
|
|
|
|
|
|
IList<IValve> allEmptyingValves = new List<IValve>();
|
|
|
|
|
|
if (StateMachine.EmptyTankValve1 != null) allEmptyingValves.Add(StateMachine.EmptyTankValve1);
|
|
|
|
|
|
if (StateMachine.EmptyTankValve2 != null) allEmptyingValves.Add(StateMachine.EmptyTankValve2);
|
|
|
|
|
|
if (StateMachine.EmptyTankValve3 != null) allEmptyingValves.Add(StateMachine.EmptyTankValve3);
|
|
|
|
|
|
|
|
|
|
|
|
// Determine the tank emptying time (the maximum for all balances)
|
|
|
|
|
|
int balanceEmptyTime = 0;
|
|
|
|
|
|
if (StateMachine.Balance1 != null && StateMachine.Balance1.EmptyTimeSec > balanceEmptyTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
balanceEmptyTime = StateMachine.Balance1.EmptyTimeSec;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StateMachine.Balance2 != null && StateMachine.Balance2.EmptyTimeSec > balanceEmptyTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
balanceEmptyTime = StateMachine.Balance2.EmptyTimeSec;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StateMachine.Balance3 != null && StateMachine.Balance3.EmptyTimeSec > balanceEmptyTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
balanceEmptyTime = StateMachine.Balance3.EmptyTimeSec;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (balanceEmptyTime > 0)
|
|
|
|
|
|
{
|
2014-12-10 21:39:53 +00:00
|
|
|
|
startNew.AddOperation(new TimerOp(balanceEmptyTime, remainingTime))
|
2014-12-10 11:36:57 +00:00
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(allEmptyingValves, null));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
startNew.EnterState();
|
2014-07-28 07:54:35 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
2015-10-14 13:45:51 +00:00
|
|
|
|
Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Emptying_tank, remainingTime.Val / 60, "min", remainingTime.Val % 60, Strings.sec));
|
2014-12-10 21:39:53 +00:00
|
|
|
|
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2014-07-28 07:54:35 +00:00
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
2014-12-10 11:36:57 +00:00
|
|
|
|
if (e.Contains(Event.UiCmdStop) &&
|
|
|
|
|
|
!e.Contains(Event.ValvesBusy) &&
|
|
|
|
|
|
!e.Contains(Event.CameraBusy))
|
|
|
|
|
|
{
|
|
|
|
|
|
goto stop_emptying;
|
|
|
|
|
|
}
|
2014-12-10 21:39:53 +00:00
|
|
|
|
}
|
2014-12-10 11:36:57 +00:00
|
|
|
|
while (e.Contains(Event.TimerBusy) ||
|
|
|
|
|
|
e.Contains(Event.CameraBusy) ||
|
|
|
|
|
|
e.Contains(Event.ValvesBusy));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
if (e.Contains(Event.CameraOpFailed)) goto error; /// TODO: resolve in some other way
|
|
|
|
|
|
|
2014-12-10 21:39:53 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Emptying_tank);
|
|
|
|
|
|
|
2014-12-10 11:36:57 +00:00
|
|
|
|
stop_emptying:
|
2014-12-10 13:34:47 +00:00
|
|
|
|
//--------------------------------------------------------------------------------------------
|
2014-12-10 11:36:57 +00:00
|
|
|
|
State stopEmptying = State.Create("MainSeq : Stop emptying of water tanks")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, allEmptyingValves))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.ValvesBusy));
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------
|
|
|
|
|
|
State taraAll = State.Create("MainSeq : Reset all balances").AddOperation(checkUiOp);
|
|
|
|
|
|
FloatBox tara = new FloatBox(0);
|
|
|
|
|
|
if (StateMachine.Balance1 != null) taraAll.AddOperation(StateMachine.Balance1.TaringOp(ref tara));
|
|
|
|
|
|
if (StateMachine.Balance2 != null) taraAll.AddOperation(StateMachine.Balance2.TaringOp(ref tara));
|
|
|
|
|
|
if (StateMachine.Balance3 != null) taraAll.AddOperation(StateMachine.Balance3.TaringOp(ref tara));
|
|
|
|
|
|
taraAll.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.Busy));
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
|
|
|
|
|
State.Create("MainSeq : Mesuring the weight for the 1st time")
|
2015-05-07 16:31:46 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(new MettlerToledo.ReadMassesOp())
|
2014-12-10 11:36:57 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.BalanceDone));
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------
|
2014-08-12 16:22:32 +00:00
|
|
|
|
select_procedure:
|
2015-01-15 05:34:36 +00:00
|
|
|
|
|
|
|
|
|
|
/// Make sure the CycleBeginForm is closed (aftrer an abnormal procedure/test end, etc.)
|
2015-03-01 09:19:00 +00:00
|
|
|
|
CloseBeginForm();
|
2015-01-15 05:34:36 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
selection = MakeSelection(MKSelContext.ProcedureNotSelected);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
//--------------------------------
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
|
|
|
|
|
|
StateMachine.LoadProcedure(false);
|
2014-08-12 16:22:32 +00:00
|
|
|
|
if (StateMachine.Procedure == null) goto select_procedure;
|
|
|
|
|
|
|
2015-12-04 11:24:55 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Procedure selected at this point, a new batch was started
|
|
|
|
|
|
///
|
2016-01-10 12:15:14 +00:00
|
|
|
|
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
2016-01-02 16:53:57 +00:00
|
|
|
|
|
|
|
|
|
|
/// Prepare new water meters
|
2016-01-10 12:15:14 +00:00
|
|
|
|
foreach (var wm in WaterMeters) wm.ClearData(); /// Clean water meter data
|
|
|
|
|
|
|
|
|
|
|
|
bool compound = (StateMachine.Procedure.MetersKind == MetersKind.Combined);
|
2016-01-02 16:53:57 +00:00
|
|
|
|
int nrWMs = Math.Min(WaterMeters.Count, compound ? Config.Data.CompoundWMsCount : Config.Data.WMsCount);
|
|
|
|
|
|
///
|
|
|
|
|
|
Results.Entities.WaterMeterData[] waterMeterData = new Results.Entities.WaterMeterData[nrWMs];
|
|
|
|
|
|
///
|
|
|
|
|
|
int[] waterMeterParts = new int[nrWMs];
|
|
|
|
|
|
for (int i = 0; i < nrWMs; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
waterMeterParts[i] = Utils.PartNr(i + 1, compound);
|
|
|
|
|
|
waterMeterData[i] = new Results.Entities.WaterMeterData()
|
|
|
|
|
|
{
|
|
|
|
|
|
ProductName = StateMachine.Procedure.Name,
|
|
|
|
|
|
Producer = WaterMeters[i].Producer,
|
|
|
|
|
|
MetrologicalClass = WaterMeters[i].MetrologicalClass,
|
|
|
|
|
|
ApprovalInfo = WaterMeters[i].ApprovalInfo,
|
|
|
|
|
|
Qn = WaterMeters[i].Qn,
|
|
|
|
|
|
Compound = compound,
|
|
|
|
|
|
};
|
2016-01-10 12:02:26 +00:00
|
|
|
|
#if IPERLST
|
|
|
|
|
|
BenchControl.WaterMeters.iPerl.WaterMeter iPerl = WaterMeters[i] as BenchControl.WaterMeters.iPerl.WaterMeter;
|
|
|
|
|
|
if (iPerl != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
waterMeterData[i].WMTypeId = iPerl.WMType_ID;
|
|
|
|
|
|
waterMeterData[i].WMTypeRev = iPerl.WMType_Rev;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
2016-01-02 16:53:57 +00:00
|
|
|
|
|
|
|
|
|
|
/// Prepare empty results
|
|
|
|
|
|
BatchRslts = Results.BatchResults.NewFromProcedure(Program.LocalSettings.BatchNr, BenchInfo.TestBenchId,
|
|
|
|
|
|
User.CurrentUser.Name, Program.Version,
|
|
|
|
|
|
StateMachine.Procedure, waterMeterData, waterMeterParts);
|
|
|
|
|
|
|
2016-01-10 12:15:14 +00:00
|
|
|
|
StateMachine.CycleStartTimeStamp = BatchRslts.Batch.StartTime;
|
2015-12-04 11:24:55 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
Bridge.OnProcedureSelected(this, new ProcedureSelectedEventArgs(StateMachine.Procedure));
|
|
|
|
|
|
|
2015-01-16 02:05:16 +00:00
|
|
|
|
/// Display 'Cycle Begin Form'
|
|
|
|
|
|
if (OpenCycleBeginForm()) goto stop;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-08-13 14:20:00 +00:00
|
|
|
|
/// Find purge suquences
|
2015-12-04 16:17:20 +00:00
|
|
|
|
TransitionSequence purgeBegin = null;
|
|
|
|
|
|
TransitionSequence purgeEnd = null;
|
2014-08-12 12:52:42 +00:00
|
|
|
|
foreach (var transition in StateMachine.TransitionSequences)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (transition.Name == StateMachine.Procedure.TransitionStart) purgeBegin = transition;
|
|
|
|
|
|
if (transition.Name == StateMachine.Procedure.TransitionEnd) purgeEnd = transition;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (selection == Selection.Q1 || selection == Selection.Q2 ||
|
|
|
|
|
|
selection == Selection.Q3 || selection == Selection.Test)
|
|
|
|
|
|
{
|
|
|
|
|
|
goto assume_bench_filled;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (selection == Selection.Cycle && benchFilled)
|
|
|
|
|
|
{
|
|
|
|
|
|
//--------------------------------
|
|
|
|
|
|
State.Create("MainSeq : Answer a question")
|
2014-08-12 20:21:26 +00:00
|
|
|
|
.AddOperation(new Operations.AskYesNoOp(Strings.Fill_with_water))
|
2014-07-28 07:54:35 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.No)) goto assume_bench_filled;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto select_procedure;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.Yes));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fill_the_bench:
|
|
|
|
|
|
|
2015-09-04 11:49:04 +00:00
|
|
|
|
///
|
2015-09-10 18:07:06 +00:00
|
|
|
|
/// Collect steps (e.g. iPerl communication) to be done simultaneously with purging
|
2015-09-04 11:49:04 +00:00
|
|
|
|
///
|
|
|
|
|
|
simultWithPurgingCount = 0;
|
|
|
|
|
|
simultWithPurgingCfg = null;
|
2016-01-19 16:38:09 +00:00
|
|
|
|
simultWithPurgingTests.Clear();
|
2015-09-10 18:07:06 +00:00
|
|
|
|
simultWithPurgingParams.Clear();
|
2015-09-05 22:09:52 +00:00
|
|
|
|
///
|
2015-09-04 11:49:04 +00:00
|
|
|
|
foreach (var test in StateMachine.Tests)
|
|
|
|
|
|
{
|
|
|
|
|
|
Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
|
2015-09-05 10:19:11 +00:00
|
|
|
|
if (testMethodComp == null) break;
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
|
|
|
|
|
testMethodComp.Cfg.UpdateTestParams(test);
|
|
|
|
|
|
|
2015-09-05 10:19:11 +00:00
|
|
|
|
ISimultTestMethod simultTest = testMethodComp as ISimultTestMethod;
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
2015-09-05 10:19:11 +00:00
|
|
|
|
if (simultTest == null || !simultTest.SimultWithPrevious) break;
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
2015-09-05 10:19:11 +00:00
|
|
|
|
if (simultWithPurgingCount == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
simultWithPurgingCfg = simultTest.Cfg;
|
|
|
|
|
|
sensPath = StateMachine.GetMetersPath(test);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (simultTest.Cfg != simultWithPurgingCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-19 16:38:09 +00:00
|
|
|
|
simultWithPurgingTests.Add(test);
|
2015-09-05 22:09:52 +00:00
|
|
|
|
simultWithPurgingParams.Add(testMethodComp.Cfg.GetTestParams().Clone() as Generic.ITestParams);
|
2015-09-04 11:49:04 +00:00
|
|
|
|
simultWithPurgingCount++;
|
|
|
|
|
|
}
|
2015-09-10 18:07:06 +00:00
|
|
|
|
|
2015-09-05 22:09:52 +00:00
|
|
|
|
///
|
2015-09-10 18:07:06 +00:00
|
|
|
|
/// Collect steps (e.g. iPerl communication) to be done simultaneously with evacuation
|
|
|
|
|
|
///
|
|
|
|
|
|
simultWithEvacuationCount = 0;
|
|
|
|
|
|
simultWithEvacuationCfg = null;
|
2016-01-19 16:38:09 +00:00
|
|
|
|
simultWithEvacuationTests.Clear();
|
2015-09-10 18:07:06 +00:00
|
|
|
|
simultWithEvacuationParams.Clear();
|
|
|
|
|
|
///
|
|
|
|
|
|
for (int i = StateMachine.Tests.Count - 1; i >= simultWithPurgingCount; i--)
|
|
|
|
|
|
{
|
|
|
|
|
|
var test = StateMachine.Tests[i];
|
|
|
|
|
|
|
|
|
|
|
|
Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
|
|
|
|
|
|
if (testMethodComp == null) break;
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
2015-09-10 18:07:06 +00:00
|
|
|
|
testMethodComp.Cfg.UpdateTestParams(test);
|
|
|
|
|
|
|
|
|
|
|
|
ISimultTestMethod simultTest = testMethodComp as ISimultTestMethod;
|
|
|
|
|
|
|
|
|
|
|
|
if (simultTest == null || !simultTest.SimultWithNext) break;
|
|
|
|
|
|
|
|
|
|
|
|
if (simultWithEvacuationCount == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
simultWithEvacuationCfg = simultTest.Cfg;
|
|
|
|
|
|
sensPath = StateMachine.GetMetersPath(test);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (simultTest.Cfg != simultWithEvacuationCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-19 16:38:09 +00:00
|
|
|
|
simultWithEvacuationTests.Insert(0, test);
|
2015-09-10 18:07:06 +00:00
|
|
|
|
simultWithEvacuationParams.Insert(0, testMethodComp.Cfg.GetTestParams().Clone() as Generic.ITestParams);
|
|
|
|
|
|
simultWithEvacuationCount++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
if (simultWithPurgingCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Make sure the entry form is closed
|
|
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stop;
|
|
|
|
|
|
|
|
|
|
|
|
/// Open iPerlCommunicationForm
|
2016-01-19 16:38:09 +00:00
|
|
|
|
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingTests, simultWithPurgingParams });
|
2015-09-05 22:09:52 +00:00
|
|
|
|
}
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Purging @ cycle start
|
|
|
|
|
|
///
|
|
|
|
|
|
Event evt = Transition(purgeBegin, TransitionContext.PurgeBegin);
|
|
|
|
|
|
///
|
|
|
|
|
|
switch (evt)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2015-09-04 11:49:04 +00:00
|
|
|
|
case Event.Error:
|
|
|
|
|
|
if (simultWithPurgingCount > 0) CloseIPerlCommForm();
|
|
|
|
|
|
goto error;
|
|
|
|
|
|
case Event.UiCmdStop:
|
|
|
|
|
|
if (simultWithPurgingCount > 0) CloseIPerlCommForm();
|
|
|
|
|
|
goto stop;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
2015-09-05 10:19:11 +00:00
|
|
|
|
|
|
|
|
|
|
if (simultWithPurgingCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Wait until iPerl communications are completed
|
|
|
|
|
|
///
|
|
|
|
|
|
bool completed = !(modelessDlg is GenericDevices.IHasCompleted)
|
|
|
|
|
|
|| (modelessDlg as GenericDevices.IHasCompleted).Completed;
|
|
|
|
|
|
if (!completed)
|
|
|
|
|
|
{
|
|
|
|
|
|
State.Create("MainSeq : Wait until the entry form is closed")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop))
|
|
|
|
|
|
{
|
|
|
|
|
|
CloseIPerlCommForm();
|
|
|
|
|
|
goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
completed = (modelessDlg as GenericDevices.IHasCompleted).Completed;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!completed);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
modelessDlg = null;
|
|
|
|
|
|
}
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
assume_bench_filled:
|
|
|
|
|
|
|
|
|
|
|
|
benchFilled = true;
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.ShowBenchFilled);
|
|
|
|
|
|
|
2014-08-12 12:52:42 +00:00
|
|
|
|
if (selection != Selection.PurgeBegin)
|
|
|
|
|
|
{
|
2014-08-12 16:22:32 +00:00
|
|
|
|
goto cycle_or_test_selected;
|
2014-08-12 12:52:42 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
select_cycle_or_test:
|
2015-04-28 13:27:47 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
|
selection = MakeSelection(MKSelContext.InsideProcedure);
|
|
|
|
|
|
///
|
|
|
|
|
|
if (selection == Selection.PurgeBegin) goto fill_the_bench;
|
2015-09-10 18:07:06 +00:00
|
|
|
|
if (selection == Selection.PurgeEnd) goto evacuation;
|
2015-05-22 14:43:17 +00:00
|
|
|
|
if (selection == Selection.Break)
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.ShowBenchEmpty);
|
|
|
|
|
|
goto select_procedure;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (selection == Selection.SaveResults) goto save_results;
|
2014-07-30 22:03:19 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
cycle_or_test_selected:
|
2014-07-30 22:03:19 +00:00
|
|
|
|
|
2015-06-25 02:45:04 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
|
|
|
|
|
|
|
|
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stop_within_cycle; /// Make sure the entry form is closed
|
2015-04-28 13:27:47 +00:00
|
|
|
|
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Hide buttons
|
2014-07-30 22:03:19 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
if (selection == Selection.Cycle)
|
|
|
|
|
|
{
|
|
|
|
|
|
TimeEstimateTotal = 0;
|
2015-09-10 18:07:06 +00:00
|
|
|
|
for (int i = simultWithPurgingCount; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
|
2015-09-04 11:49:04 +00:00
|
|
|
|
{
|
2015-12-04 16:17:20 +00:00
|
|
|
|
Test test = StateMachine.Tests[i];
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
|
|
|
|
|
TimeEstimateTotal += (test.Repeats * (test.TstTime + 10.0f));
|
2014-07-30 22:03:19 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
/// Try to fetch all test paths and transitions
|
|
|
|
|
|
/// to detect configuration errors as early as possible.
|
2015-05-20 14:18:54 +00:00
|
|
|
|
string errorMsg;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
if (!StateMachine.GetPaths(test, out inPath, out benchPath,
|
|
|
|
|
|
out outPath, out sensPath,
|
2015-05-22 08:29:56 +00:00
|
|
|
|
out transitionBefore, out transitionAfter,
|
2015-05-20 14:18:54 +00:00
|
|
|
|
out errorMsg))
|
2014-07-30 22:03:19 +00:00
|
|
|
|
{
|
2015-05-20 14:18:54 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, errorMsg);
|
2015-02-02 22:18:28 +00:00
|
|
|
|
goto select_cycle_or_test;
|
2014-07-30 22:03:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
TimeEstimateBeginRpts = 0;
|
2015-09-14 08:25:41 +00:00
|
|
|
|
for (int i = simultWithPurgingCount; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
|
2015-09-04 11:49:04 +00:00
|
|
|
|
{
|
2015-12-04 16:17:20 +00:00
|
|
|
|
Test test = StateMachine.Tests[i];
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
|
|
|
|
|
/// Fetch the test paths and transitions
|
|
|
|
|
|
string errorMsg;
|
|
|
|
|
|
if (!StateMachine.GetPaths(test, out inPath, out benchPath,
|
|
|
|
|
|
out outPath, out sensPath,
|
|
|
|
|
|
out transitionBefore, out transitionAfter,
|
|
|
|
|
|
out errorMsg))
|
|
|
|
|
|
{
|
|
|
|
|
|
UiBridge.Bridge.OnError(this, errorMsg);
|
2015-02-02 22:18:28 +00:00
|
|
|
|
goto select_cycle_or_test;
|
2015-09-04 11:49:04 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-03-25 09:01:37 +00:00
|
|
|
|
/// Update format for the water mass
|
2015-12-20 19:48:50 +00:00
|
|
|
|
Mass.Format = outPath.Balance.Format;
|
2016-02-10 18:24:10 +00:00
|
|
|
|
StartMass.Format = outPath.Balance.Format;
|
|
|
|
|
|
EndMass.Format = outPath.Balance.Format;
|
2015-03-25 09:01:37 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
TimeEstimateOneTest = test.TstTime + 10.0f;
|
2015-09-04 11:49:04 +00:00
|
|
|
|
//--------------------------------------------------------------
|
2015-02-01 15:20:27 +00:00
|
|
|
|
ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod;
|
2015-02-02 22:18:28 +00:00
|
|
|
|
if (testMethodSequence != null && testMethodSequence.CanTest(StateMachine.Procedure.MetersKind))
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2015-02-02 22:18:28 +00:00
|
|
|
|
StateMachine.LoadTestParams(test);
|
2016-02-13 07:18:49 +00:00
|
|
|
|
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
2014-09-08 11:16:31 +00:00
|
|
|
|
|
2016-02-13 07:18:49 +00:00
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
2015-09-04 11:49:04 +00:00
|
|
|
|
{
|
2016-02-13 07:18:49 +00:00
|
|
|
|
if ((rr is WaterMeters.iPerl.WaterMeter) && (BenchInfo != null))
|
|
|
|
|
|
{
|
|
|
|
|
|
(rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchName;
|
|
|
|
|
|
}
|
2015-09-04 11:49:04 +00:00
|
|
|
|
}
|
2015-08-22 11:34:10 +00:00
|
|
|
|
|
2015-09-04 11:49:04 +00:00
|
|
|
|
e = testMethodSequence.Execute(test);
|
2015-01-15 02:51:33 +00:00
|
|
|
|
|
2015-02-02 22:18:28 +00:00
|
|
|
|
if (e.Contains(Event.ConfigurationError)) goto select_cycle_or_test;
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
2014-08-15 12:31:45 +00:00
|
|
|
|
if (e.Contains(Event.OpArgumentError)) goto config_error;
|
2015-04-29 11:51:24 +00:00
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop_within_cycle;
|
2015-02-02 22:18:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
UiBridge.Bridge.OnError(this, string.Format("{0} cannot be used", test.Method));
|
|
|
|
|
|
goto select_cycle_or_test;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TimeEstimateBeginRpts += (test.Repeats * TimeEstimateOneTest);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2015-12-04 16:17:20 +00:00
|
|
|
|
Test test = TBF.BenchControl.StateMachine.GetTest(selection);
|
2015-05-20 14:18:54 +00:00
|
|
|
|
if (test == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UiBridge.Bridge.OnError(this, string.Format("No test specified"));
|
|
|
|
|
|
goto select_cycle_or_test;
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
/// Fetch the test paths and transitions
|
2015-05-20 14:18:54 +00:00
|
|
|
|
string errorMsg;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
if (!StateMachine.GetPaths(test, out inPath, out benchPath,
|
|
|
|
|
|
out outPath, out sensPath,
|
2015-05-22 08:29:56 +00:00
|
|
|
|
out transitionBefore, out transitionAfter,
|
2015-05-20 14:18:54 +00:00
|
|
|
|
out errorMsg))
|
2014-08-12 16:22:32 +00:00
|
|
|
|
{
|
2015-05-20 14:18:54 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, errorMsg);
|
2015-02-02 22:18:28 +00:00
|
|
|
|
goto select_cycle_or_test;
|
|
|
|
|
|
}
|
2014-08-12 16:22:32 +00:00
|
|
|
|
|
2015-03-25 09:01:37 +00:00
|
|
|
|
/// Update format for the water mass
|
2015-12-20 19:48:50 +00:00
|
|
|
|
Mass.Format = outPath.Balance.Format;
|
2016-02-10 18:24:10 +00:00
|
|
|
|
StartMass.Format = outPath.Balance.Format;
|
|
|
|
|
|
EndMass.Format = outPath.Balance.Format;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
TimeEstimateTotal = test.Repeats * (test.TstTime + 10.0f);
|
|
|
|
|
|
TimeEstimateOneTest = test.TstTime + 10.0f;
|
|
|
|
|
|
TimeEstimateBeginRpts = 0;
|
|
|
|
|
|
|
2015-02-01 15:20:27 +00:00
|
|
|
|
ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod;
|
2015-02-02 22:18:28 +00:00
|
|
|
|
if (testMethodSequence != null && testMethodSequence.CanTest(StateMachine.Procedure.MetersKind))
|
|
|
|
|
|
{
|
|
|
|
|
|
StateMachine.LoadTestParams(test);
|
2016-02-13 07:18:49 +00:00
|
|
|
|
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
2015-08-22 11:34:10 +00:00
|
|
|
|
|
2016-02-13 07:18:49 +00:00
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((rr is WaterMeters.iPerl.WaterMeter) && (BenchInfo != null))
|
|
|
|
|
|
{
|
|
|
|
|
|
(rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-08-22 11:34:10 +00:00
|
|
|
|
|
2015-04-28 13:27:47 +00:00
|
|
|
|
e = testMethodSequence.Execute(test);
|
2015-01-15 02:51:33 +00:00
|
|
|
|
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.OpArgumentError)) goto config_error;
|
2015-04-29 11:51:24 +00:00
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop_within_cycle;
|
2015-02-02 22:18:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
UiBridge.Bridge.OnError(this, string.Format("{0} cannot be used", test.Method));
|
|
|
|
|
|
goto select_cycle_or_test;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-03 01:05:35 +00:00
|
|
|
|
if (BatchRslts.AllTestsDone())
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.AcceptResultsBtnEn | ButtonsEtc.ResetResultsBtnEn);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.ResetResultsBtnEn);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
goto select_cycle_or_test;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-09-10 18:07:06 +00:00
|
|
|
|
evacuation:
|
2014-07-28 07:54:35 +00:00
|
|
|
|
save_results:
|
|
|
|
|
|
|
2015-06-25 02:45:04 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Hide the most of buttons
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-03-08 14:13:50 +00:00
|
|
|
|
if (State.LastEvents.Contains(Event.ModelessFormIsOpen))
|
2015-02-21 19:00:35 +00:00
|
|
|
|
{
|
2015-06-25 02:45:04 +00:00
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stop;
|
2015-02-21 19:00:35 +00:00
|
|
|
|
}
|
2015-03-08 14:13:50 +00:00
|
|
|
|
else if (State.LastEvents.Contains(Event.ModelessFormClosed))
|
|
|
|
|
|
{
|
|
|
|
|
|
CloseBeginForm();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-02-21 19:00:35 +00:00
|
|
|
|
Bridge.OnActivity(this, "Enter protocol data");
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------
|
2014-07-28 07:54:35 +00:00
|
|
|
|
string protocolTitle = string.Empty;
|
2015-01-15 02:51:33 +00:00
|
|
|
|
GenericDevices.IDataEntry dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry;
|
2014-07-28 21:12:43 +00:00
|
|
|
|
if (dataEntryCmpnt != null)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2014-09-23 11:16:59 +00:00
|
|
|
|
if (dataEntryCmpnt is IHasCycleEndForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Open the modeless form for the end of the cycle
|
|
|
|
|
|
State.Create("MainSeq : Enter end data")
|
2016-01-06 21:37:19 +00:00
|
|
|
|
.AddOperation((dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp())
|
2014-09-23 11:16:59 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ModelessFormClosed));
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
if (dataEntryCmpnt is IHasProtocolTitle)
|
|
|
|
|
|
{
|
|
|
|
|
|
protocolTitle = (dataEntryCmpnt as IHasProtocolTitle).ProtocolTitle;
|
|
|
|
|
|
}
|
2016-01-08 09:23:36 +00:00
|
|
|
|
|
2016-01-04 16:55:39 +00:00
|
|
|
|
dataEntryCmpnt.UpdateTestResults(BatchRslts);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
2016-01-06 20:39:52 +00:00
|
|
|
|
|
2016-01-06 21:37:19 +00:00
|
|
|
|
ProcessData.BatchRslts.Batch.EndTime = DateTime.Now;
|
2016-01-06 20:39:52 +00:00
|
|
|
|
ProcessData.BatchRslts.AddWaterMetersToBatch();
|
|
|
|
|
|
|
2015-01-25 07:11:40 +00:00
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
|
Bridge.OnActivity(this, "Saving and printing results");
|
|
|
|
|
|
State savingAndPrintingRslts = State.Create("MainSeq : Saving and printing results");
|
2016-01-08 18:18:45 +00:00
|
|
|
|
|
|
|
|
|
|
IResultsWriter writer = TbfComponents.FindComponent(StateMachine.Procedure.ResultsWriter) as IResultsWriter;
|
2015-04-19 14:48:46 +00:00
|
|
|
|
if (writer != null)
|
|
|
|
|
|
{
|
2016-01-06 20:39:52 +00:00
|
|
|
|
savingAndPrintingRslts.AddOperation(writer.WriteResultsOp(ProcessData.BatchRslts.Batch));
|
2015-04-19 14:48:46 +00:00
|
|
|
|
}
|
2016-01-08 18:18:45 +00:00
|
|
|
|
|
|
|
|
|
|
IResultsPrinter printer = TbfComponents.FindComponent(StateMachine.Procedure.ResultsPrinter) as IResultsPrinter;
|
2015-04-19 14:48:46 +00:00
|
|
|
|
if (printer != null && !printer.SupressPrinting)
|
2015-12-29 18:02:28 +00:00
|
|
|
|
{
|
2016-01-06 20:39:52 +00:00
|
|
|
|
savingAndPrintingRslts.AddOperation(printer.PrintResultsOp(ProcessData.BatchRslts.Batch, protocolTitle));
|
2015-04-19 14:48:46 +00:00
|
|
|
|
}
|
2016-01-08 18:18:45 +00:00
|
|
|
|
|
2015-01-25 07:11:40 +00:00
|
|
|
|
savingAndPrintingRslts.AddOperation(checkUiOp).EnterState();
|
|
|
|
|
|
do
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2015-01-25 07:11:40 +00:00
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
2015-01-25 07:11:40 +00:00
|
|
|
|
while (e.Contains(Event.Busy));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2016-01-08 18:18:45 +00:00
|
|
|
|
bool resultsSent = !e.Contains(Event.ResultsNotWritten);
|
2016-01-08 12:51:54 +00:00
|
|
|
|
ProcessData.BatchRslts.Batch.RsltsSent = resultsSent;
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Save results to the built in 'Results' database
|
|
|
|
|
|
///
|
|
|
|
|
|
Results.DB.SaveNewBatch(ProcessData.BatchRslts.Batch);
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Save results to 'summary results' logger
|
|
|
|
|
|
///
|
|
|
|
|
|
foreach (var tr in ProcessData.BatchRslts.Batch.TestRslts)
|
|
|
|
|
|
{
|
|
|
|
|
|
summaryResults.Info(TestResult2CsvLine(tr));
|
|
|
|
|
|
}
|
2015-02-01 23:07:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
2015-02-02 17:09:05 +00:00
|
|
|
|
Program.LocalSettings.BatchNr++;
|
2015-01-25 07:11:40 +00:00
|
|
|
|
Program.LocalSettings.Save();
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-09-10 18:07:06 +00:00
|
|
|
|
if (simultWithEvacuationCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Open iPerlCommunicationForm
|
2016-01-19 16:38:09 +00:00
|
|
|
|
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithEvacuationCfg, simultWithEvacuationTests, simultWithEvacuationParams });
|
2015-09-10 18:07:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-01-25 07:11:40 +00:00
|
|
|
|
//--------------------------------------------------------
|
2014-08-14 07:05:40 +00:00
|
|
|
|
switch (Transition(purgeEnd, TransitionContext.PurgeEnd))
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2015-09-10 18:07:06 +00:00
|
|
|
|
case Event.Error:
|
|
|
|
|
|
if (simultWithEvacuationCount > 0) CloseIPerlCommForm();
|
|
|
|
|
|
goto error;
|
|
|
|
|
|
case Event.UiCmdStop:
|
|
|
|
|
|
if (simultWithEvacuationCount > 0) CloseIPerlCommForm();
|
|
|
|
|
|
goto stop;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-09-10 18:07:06 +00:00
|
|
|
|
if (simultWithEvacuationCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Wait until iPerl communications are completed
|
|
|
|
|
|
///
|
|
|
|
|
|
bool completed = !(modelessDlg is GenericDevices.IHasCompleted)
|
|
|
|
|
|
|| (modelessDlg as GenericDevices.IHasCompleted).Completed;
|
|
|
|
|
|
if (!completed)
|
|
|
|
|
|
{
|
|
|
|
|
|
State.Create("MainSeq : Wait until the entry form is closed")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop))
|
|
|
|
|
|
{
|
|
|
|
|
|
CloseIPerlCommForm();
|
|
|
|
|
|
goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
completed = (modelessDlg as GenericDevices.IHasCompleted).Completed;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!completed);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
modelessDlg = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
benchFilled = false;
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.ShowBenchEmpty);
|
|
|
|
|
|
|
2015-09-10 18:07:06 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
goto select_procedure;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-04-29 11:51:24 +00:00
|
|
|
|
stop_within_cycle:
|
|
|
|
|
|
//--------------------------------
|
|
|
|
|
|
State.Create("MainSeq : Turning IDLE -> Closing the valves")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen,
|
|
|
|
|
|
StateMachine.DefaultValvesClose))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
|
|
|
|
|
|
goto select_cycle_or_test;
|
|
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
stop:
|
|
|
|
|
|
//--------------------------------
|
|
|
|
|
|
State.Create("MainSeq : Turning IDLE -> Closing the valves")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen,
|
|
|
|
|
|
StateMachine.DefaultValvesClose))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
|
|
|
|
|
|
goto select_procedure;
|
|
|
|
|
|
|
|
|
|
|
|
config_error:
|
|
|
|
|
|
//--------------------------------
|
|
|
|
|
|
State.Create("MainSeq : Procedure configuration error")
|
2014-08-12 20:21:26 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation(new Operations.MessageBoxOp("Test configration error"))
|
2014-08-12 16:22:32 +00:00
|
|
|
|
.EnterState();
|
2014-08-12 20:21:26 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.OK));
|
|
|
|
|
|
|
|
|
|
|
|
goto select_cycle_or_test;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
error:
|
|
|
|
|
|
//--------------------------------
|
|
|
|
|
|
State.Create("MainSeq : ERROR -> Closing the valves")
|
2014-07-28 07:54:35 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2014-08-12 16:22:32 +00:00
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen,
|
|
|
|
|
|
StateMachine.DefaultValvesClose))
|
2014-07-28 07:54:35 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
2014-08-12 16:22:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet) && !e.Contains(Event.Error));
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------
|
|
|
|
|
|
State.Create("MainSeq : ERROR state")
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
while (true) StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MakeSelection() call context
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
enum MKSelContext
|
|
|
|
|
|
{
|
|
|
|
|
|
ProcedureNotSelected,
|
|
|
|
|
|
InsideProcedure,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Selection done in MakeSelection()
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public enum Selection
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Handled inside MakeSelection()
|
|
|
|
|
|
None,
|
|
|
|
|
|
EmptyTank1,
|
|
|
|
|
|
EmptyTank2,
|
|
|
|
|
|
EmptyTank3,
|
|
|
|
|
|
CloseTank1,
|
|
|
|
|
|
CloseTank2,
|
|
|
|
|
|
CloseTank3,
|
|
|
|
|
|
CameraTest,
|
|
|
|
|
|
|
|
|
|
|
|
/// Used as return values
|
|
|
|
|
|
Cycle,
|
|
|
|
|
|
Test,
|
|
|
|
|
|
Q1,
|
|
|
|
|
|
Q2,
|
|
|
|
|
|
Q3,
|
|
|
|
|
|
Stop,
|
|
|
|
|
|
PurgeBegin,
|
|
|
|
|
|
PurgeEnd,
|
2015-05-22 14:43:17 +00:00
|
|
|
|
Break,
|
2014-08-12 16:22:32 +00:00
|
|
|
|
SaveResults,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Idle loop to make a procedure or test selection.
|
|
|
|
|
|
/// Handles tank emptying, camera test.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="context">Context where MakeSelection() is called</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// Selection.Cycle
|
|
|
|
|
|
/// Selection.Test
|
|
|
|
|
|
/// Selection.Q1
|
|
|
|
|
|
/// Selection.Q2
|
|
|
|
|
|
/// Selection.Q3
|
|
|
|
|
|
/// Selection.Stop
|
|
|
|
|
|
/// Selection.PurgeBegin
|
|
|
|
|
|
/// Selection.PurgeEnd
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
private Selection MakeSelection(MKSelContext context)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Tank emptying valves states
|
|
|
|
|
|
bool emptying1 = false;
|
|
|
|
|
|
bool emptying2 = false;
|
|
|
|
|
|
bool emptying3 = false;
|
|
|
|
|
|
|
|
|
|
|
|
/// Measured masses to control emptying
|
|
|
|
|
|
FloatBox mass1 = new FloatBox();
|
|
|
|
|
|
FloatBox mass2 = new FloatBox();
|
|
|
|
|
|
FloatBox mass3 = new FloatBox();
|
|
|
|
|
|
|
|
|
|
|
|
IList<Event> e;
|
|
|
|
|
|
Selection selection;
|
|
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Display an appropriate activity message
|
|
|
|
|
|
if (emptying1 || emptying2 || emptying3)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2014-08-12 16:22:32 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Emptying_tank);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (context == MKSelContext.ProcedureNotSelected)
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Please_select_a_procedure);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (context == MKSelContext.InsideProcedure)
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Please_select_a_cycle_a_test_or_empty);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
/// Enable appropriate UI controls and buttons
|
|
|
|
|
|
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
|
|
|
|
|
|
ButtonsEtc.TestCmbBoxEn |
|
|
|
|
|
|
ButtonsEtc.StopBtnEn |
|
|
|
|
|
|
((emptying1 || emptying2 || emptying3) ? 0 :
|
|
|
|
|
|
(ButtonsEtc.StartCycleBtnEn |
|
|
|
|
|
|
ButtonsEtc.StartTestBtnsEn |
|
|
|
|
|
|
ButtonsEtc.PurgeBeginBtnEn |
|
|
|
|
|
|
((context == MKSelContext.InsideProcedure) ? ButtonsEtc.PurgeEndBtnEn : 0) |
|
|
|
|
|
|
ButtonsEtc.SensitivityTestBtnEn |
|
|
|
|
|
|
((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0) |
|
2015-05-22 14:43:17 +00:00
|
|
|
|
ButtonsEtc.Break)) |
|
2014-09-06 09:35:10 +00:00
|
|
|
|
(((StateMachine.Balance1 != null) && (StateMachine.EmptyTankValve1 != null) && !emptying1) ? ButtonsEtc.EmptyTankBtn1En : 0) |
|
|
|
|
|
|
(((StateMachine.Balance2 != null) && (StateMachine.EmptyTankValve2 != null) && !emptying2) ? ButtonsEtc.EmptyTankBtn2En : 0) |
|
|
|
|
|
|
(((StateMachine.Balance3 != null) && (StateMachine.EmptyTankValve3 != null) && !emptying3) ? ButtonsEtc.EmptyTankBtn3En : 0));
|
2014-08-12 16:22:32 +00:00
|
|
|
|
|
|
|
|
|
|
selection = Selection.None;
|
|
|
|
|
|
State.Create("MainSeq : Select an activity")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.AddOperation((StateMachine.Balance1 != null) ? StateMachine.Balance1.ReadMassOp(ref mass1) : null)
|
|
|
|
|
|
.AddOperation((StateMachine.Balance2 != null) ? StateMachine.Balance2.ReadMassOp(ref mass2) : null)
|
|
|
|
|
|
.AddOperation((StateMachine.Balance3 != null) ? StateMachine.Balance3.ReadMassOp(ref mass3) : null)
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdCameraTest)) selection = Selection.CameraTest;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdEmptyTank3)) selection = Selection.EmptyTank3;
|
2014-09-08 13:39:33 +00:00
|
|
|
|
else if (emptying1 && StateMachine.Balance1.IsEmpty(mass1.Val)) selection = Selection.CloseTank1;
|
|
|
|
|
|
else if (emptying2 && StateMachine.Balance2.IsEmpty(mass2.Val)) selection = Selection.CloseTank2;
|
|
|
|
|
|
else if (emptying3 && StateMachine.Balance3.IsEmpty(mass3.Val)) selection = Selection.CloseTank3;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
else if (e.Contains(Event.UiCmdPurgeBegin)) return Selection.PurgeBegin; /// Value used to branch the code later on
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdPurgeEnd)) return Selection.PurgeEnd;
|
2015-05-22 14:43:17 +00:00
|
|
|
|
else if (e.Contains(Event.UiCmdBreak) && context == MKSelContext.InsideProcedure) return Selection.Break;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
else if (e.Contains(Event.UiCmdStartTest)) return Selection.Test;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdStartQ1)) return Selection.Q1;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdStartQ2)) return Selection.Q2;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdStartQ3)) return Selection.Q3;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdStartCycle)) return Selection.Cycle;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdAcceptResults)) return Selection.SaveResults;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (selection == Selection.None);
|
|
|
|
|
|
|
|
|
|
|
|
if (selection == Selection.CameraTest)
|
|
|
|
|
|
{
|
|
|
|
|
|
CameraTest();
|
|
|
|
|
|
}
|
2015-02-02 22:18:28 +00:00
|
|
|
|
else if (selection == Selection.Stop)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (emptying1 || emptying2 || emptying3)
|
|
|
|
|
|
{
|
|
|
|
|
|
IList<IValve> valvesClose = new List<IValve>();
|
|
|
|
|
|
if (emptying1) valvesClose.Add(StateMachine.EmptyTankValve1);
|
|
|
|
|
|
if (emptying2) valvesClose.Add(StateMachine.EmptyTankValve2);
|
|
|
|
|
|
if (emptying3) valvesClose.Add(StateMachine.EmptyTankValve3);
|
|
|
|
|
|
|
|
|
|
|
|
State.Create("MainSeq : Close emptying valve(s)")
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, valvesClose))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do { e = StateMachine.WaitRunDevsRunOps(); }
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
emptying1 = emptying2 = emptying3 = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
selection = Selection.None;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ((selection == Selection.EmptyTank1) && !emptying1)
|
|
|
|
|
|
{
|
|
|
|
|
|
emptying1 = true;
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Emptying_tank);
|
|
|
|
|
|
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
|
|
|
|
|
|
ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
|
|
|
|
|
|
(emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En) |
|
|
|
|
|
|
(emptying3 ? 0 : ButtonsEtc.EmptyTankBtn3En));
|
|
|
|
|
|
State.Create("MainSeq : Open tank 1")
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve1, null))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do { e = StateMachine.WaitRunDevsRunOps(); }
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ((selection == Selection.EmptyTank2) && !emptying2)
|
|
|
|
|
|
{
|
|
|
|
|
|
emptying2 = true;
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Emptying_tank);
|
|
|
|
|
|
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
|
|
|
|
|
|
ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
|
|
|
|
|
|
(emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) |
|
|
|
|
|
|
(emptying3 ? 0 : ButtonsEtc.EmptyTankBtn3En));
|
|
|
|
|
|
State.Create("MainSeq : Open tank 2")
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve2, null))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do { e = StateMachine.WaitRunDevsRunOps(); }
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ((selection == Selection.EmptyTank3) && !emptying3)
|
|
|
|
|
|
{
|
|
|
|
|
|
emptying3 = true;
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Emptying_tank);
|
|
|
|
|
|
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
|
|
|
|
|
|
ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
|
|
|
|
|
|
(emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) |
|
|
|
|
|
|
(emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En));
|
|
|
|
|
|
State.Create("MainSeq : Open tank 3")
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve3, null))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do { e = StateMachine.WaitRunDevsRunOps(); }
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (selection == Selection.CloseTank1)
|
|
|
|
|
|
{
|
|
|
|
|
|
State.Create("MainSeq : Close tank 1")
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve1))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do { e = StateMachine.WaitRunDevsRunOps(); }
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
emptying1 = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (selection == Selection.CloseTank2)
|
|
|
|
|
|
{
|
|
|
|
|
|
State.Create("MainSeq : Close tank 2")
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve2))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do { e = StateMachine.WaitRunDevsRunOps(); }
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
emptying2 = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (selection == Selection.CloseTank3)
|
|
|
|
|
|
{
|
|
|
|
|
|
State.Create("MainSeq : Close tank 3")
|
|
|
|
|
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve3))
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do { e = StateMachine.WaitRunDevsRunOps(); }
|
|
|
|
|
|
while (!e.Contains(Event.ValvesSet));
|
|
|
|
|
|
emptying3 = false;
|
|
|
|
|
|
}
|
2014-08-12 16:22:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Error);
|
|
|
|
|
|
State.Create("MainSeq : ERROR state")
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
while (true) StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Perform a camera test
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void CameraTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
IList<Event> e;
|
|
|
|
|
|
|
|
|
|
|
|
camera_test:
|
|
|
|
|
|
Bridge.OnActivity(this, "Camera test");
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StartTestBtnsEn | ButtonsEtc.StopBtnEn);
|
|
|
|
|
|
State.Create("MainSeq : 1 = Grab, 2 = Live, 3 = Focus, Stop = Quit camera test")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) return;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStartQ1)) goto grab;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStartQ2)) goto live;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStartQ3)) goto focus;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (true);
|
|
|
|
|
|
|
|
|
|
|
|
grab:
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
|
|
|
|
|
|
State.Create("MainSeq : Press 'Stop' to continue")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2015-12-04 16:17:20 +00:00
|
|
|
|
.AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[0].GrabOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[1].GrabOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[2].GrabOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[3].GrabOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[4].GrabOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[5].GrabOp() : null)
|
2014-08-12 16:22:32 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto camera_test;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (true);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
live:
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
|
|
|
|
|
|
State.Create("MainSeq : Press 'Stop' to stop.")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2015-12-04 16:17:20 +00:00
|
|
|
|
.AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[0].LiveOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[1].LiveOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[2].LiveOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[3].LiveOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[4].LiveOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[5].LiveOp() : null)
|
2014-08-12 16:22:32 +00:00
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto camera_test;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (true);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
focus:
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
|
|
|
|
|
|
State.Create("MainSeq : Press 'Stop' to stop.")
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
2015-12-04 16:17:20 +00:00
|
|
|
|
.AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[0].FocusOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[1].FocusOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[2].FocusOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[3].FocusOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[4].FocusOp() : null)
|
|
|
|
|
|
.AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[5].FocusOp() : null)
|
2014-08-12 16:22:32 +00:00
|
|
|
|
.EnterState();
|
2014-07-28 07:54:35 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto camera_test;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
2014-08-12 16:22:32 +00:00
|
|
|
|
while (true);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
error:
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Error);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
State.Create("MainSeq : ERROR state")
|
2014-08-12 16:22:32 +00:00
|
|
|
|
.EnterState();
|
2014-07-28 07:54:35 +00:00
|
|
|
|
while (true) StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
}
|
2014-08-12 16:22:32 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|