2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
2021-01-21 14:00:55 +00:00
|
|
|
|
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
2018-06-15 07:38:18 +00:00
|
|
|
|
using System.Diagnostics;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using log4net;
|
2018-06-08 10:41:47 +00:00
|
|
|
|
using NHibernate;
|
2021-09-23 09:46:40 +00:00
|
|
|
|
using Common;
|
2015-12-04 16:17:20 +00:00
|
|
|
|
using Config.Entities;
|
2017-04-12 19:45:58 +00:00
|
|
|
|
using Results.Entities;
|
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;
|
2020-04-18 08:25:30 +00:00
|
|
|
|
using TBF.UiBridge;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.Sequences
|
|
|
|
|
|
{
|
2020-04-18 08:25:30 +00:00
|
|
|
|
public partial 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
|
|
|
|
|
2017-06-30 10:04:55 +00:00
|
|
|
|
bool benchFilled;
|
|
|
|
|
|
|
2016-04-07 11:52:57 +00:00
|
|
|
|
int simultWithPurgingCount;
|
|
|
|
|
|
Generic.IComponentCfg simultWithPurgingCfg;
|
|
|
|
|
|
IList<Config.Entities.Test> simultWithPurgingTests;
|
|
|
|
|
|
IList<Generic.ITestParams> simultWithPurgingParams;
|
|
|
|
|
|
|
|
|
|
|
|
int simultWithEvacuationCount;
|
|
|
|
|
|
Generic.IComponentCfg simultWithEvacuationCfg;
|
|
|
|
|
|
IList<Config.Entities.Test> simultWithEvacuationTests;
|
|
|
|
|
|
IList<Generic.ITestParams> simultWithEvacuationParams;
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2017-04-10 13:23:37 +00:00
|
|
|
|
///
|
2015-09-04 11:49:04 +00:00
|
|
|
|
void CloseIPerlCommForm()
|
|
|
|
|
|
{
|
|
|
|
|
|
UiBridge.Bridge.OnCloseModelessForm(this, null);
|
|
|
|
|
|
modelessDlg = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-18 08:25:30 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Constructor
|
|
|
|
|
|
/// </summary>
|
2014-08-12 16:22:32 +00:00
|
|
|
|
public MainSeq()
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2017-06-30 10:04:55 +00:00
|
|
|
|
benchFilled = false;
|
|
|
|
|
|
|
|
|
|
|
|
simultWithPurgingCount = 0;
|
|
|
|
|
|
simultWithPurgingCfg = null;
|
2016-04-07 11:52:57 +00:00
|
|
|
|
simultWithPurgingTests = new List<Config.Entities.Test>();
|
|
|
|
|
|
simultWithPurgingParams = new List<Generic.ITestParams>();
|
2017-06-30 10:04:55 +00:00
|
|
|
|
|
|
|
|
|
|
simultWithEvacuationCount = 0;
|
|
|
|
|
|
simultWithEvacuationCfg = null;
|
2016-04-07 11:52:57 +00:00
|
|
|
|
simultWithEvacuationTests = new List<Config.Entities.Test>();
|
|
|
|
|
|
simultWithEvacuationParams = new List<Generic.ITestParams>();
|
2019-01-23 07:34:31 +00:00
|
|
|
|
|
|
|
|
|
|
checkUiOp = new CheckUIOp(true); /// Running in almost all states
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
/// <summary>
|
2020-04-18 08:25:30 +00:00
|
|
|
|
/// Main sequence execution
|
2019-01-23 07:34:31 +00:00
|
|
|
|
/// </summary>
|
2019-03-16 09:08:15 +00:00
|
|
|
|
public void Execute()
|
|
|
|
|
|
{
|
2019-06-21 11:25:47 +00:00
|
|
|
|
IList<Event> e = new List<Event>();
|
2019-03-16 09:08:15 +00:00
|
|
|
|
Selection selection;
|
|
|
|
|
|
string selectedTestName;
|
|
|
|
|
|
|
|
|
|
|
|
Bridge.OnActivity(this, Strings.Starting_system);
|
|
|
|
|
|
WaitForOkButton();
|
|
|
|
|
|
SetValvesToDefaultState();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string scaleName;
|
|
|
|
|
|
string message;
|
|
|
|
|
|
if (TestCommunicationWithScales(out scaleName, out message) == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, string.Format("{0} : {1}", scaleName, message));
|
|
|
|
|
|
goto error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!DrainTanks())
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, "Error when draining tanks");
|
|
|
|
|
|
goto error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-10 11:36:57 +00:00
|
|
|
|
//--------------------------------------------------------------------------------------------
|
2017-06-26 11:22:36 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Resetting_scales);
|
2019-03-16 09:08:15 +00:00
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Resetting scales -> Enable STOP button
|
2017-07-19 08:32:20 +00:00
|
|
|
|
|
2017-06-26 13:27:26 +00:00
|
|
|
|
State.Create("MainSeq : Reset scales").AddOperation(checkUiOp)
|
2020-08-07 07:30:38 +00:00
|
|
|
|
.AddOperation((StateMachine.Tank1 is IScale) ? (StateMachine.Tank1 as IScale).ZeroOp() : null)
|
|
|
|
|
|
.AddOperation((StateMachine.Tank2 is IScale) ? (StateMachine.Tank2 as IScale).ZeroOp() : null)
|
|
|
|
|
|
.AddOperation((StateMachine.Tank3 is IScale) ? (StateMachine.Tank3 as IScale).ZeroOp() : null)
|
2017-06-26 13:27:26 +00:00
|
|
|
|
.EnterState();
|
2014-12-10 11:36:57 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.Busy));
|
|
|
|
|
|
|
2019-01-23 07:34:31 +00:00
|
|
|
|
|
2014-12-10 11:36:57 +00:00
|
|
|
|
//--------------------------------------------------------------------------------------------
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
2019-06-21 11:25:47 +00:00
|
|
|
|
select_procedure:
|
2015-01-15 05:34:36 +00:00
|
|
|
|
|
2017-04-10 13:23:37 +00:00
|
|
|
|
CloseBeginForm(); /// Make sure the CycleBeginForm is closed (after an abnormal end, etc.)
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
2019-03-04 12:14:13 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
selection = MakeSelection(MKSelContext.ProcedureNotSelected);
|
|
|
|
|
|
if (selection == Selection.Shutdown)
|
|
|
|
|
|
{
|
|
|
|
|
|
Shutdown();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
while (selection == Selection.Shutdown);
|
|
|
|
|
|
|
2020-02-06 14:39:38 +00:00
|
|
|
|
selectedTestName = (selection == Selection.Q1) ? "Q1"
|
|
|
|
|
|
: ((selection == Selection.Q2) ? "Q2"
|
|
|
|
|
|
: ((selection == Selection.Q3) ? "Q3" : Bridge.SelectedTestName));
|
|
|
|
|
|
|
2020-04-18 08:25:30 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Auto invocation actions
|
|
|
|
|
|
///
|
|
|
|
|
|
IList<string> procedureBefore = new List<string>();
|
|
|
|
|
|
IList<string> testsInside = new List<string>();
|
|
|
|
|
|
IList<string> procedureAfer = new List<string>();
|
2020-02-06 14:39:38 +00:00
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Collect information about the interrupted procedure (if applicable)
|
|
|
|
|
|
///
|
2020-04-18 08:25:30 +00:00
|
|
|
|
bool restoreInterruptedSession = false;
|
2020-02-06 14:39:38 +00:00
|
|
|
|
bool processDataHeaderOK = false;
|
|
|
|
|
|
string interruptedProcedureName = string.Empty;
|
|
|
|
|
|
bool isRemoteIntProc = false;
|
|
|
|
|
|
///
|
|
|
|
|
|
if (selection == Selection.RestoreInterruptedSession)
|
|
|
|
|
|
{
|
|
|
|
|
|
int batchNr;
|
|
|
|
|
|
string version;
|
|
|
|
|
|
processDataHeaderOK = ProcessData.LoadProcessDataHeader(out batchNr, out version, out interruptedProcedureName, out isRemoteIntProc);
|
|
|
|
|
|
|
|
|
|
|
|
if (!processDataHeaderOK)
|
|
|
|
|
|
{
|
|
|
|
|
|
UiBridge.Bridge.OnError(this, "Invalid process data");
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (version != Program.Version)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Program version does not match the one stored in process data
|
|
|
|
|
|
UiBridge.Bridge.OnError(this, Strings.Program_version_does_not_match);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (batchNr != Program.LocalSettings.BatchNr)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Program version does not match the one stored in process data
|
|
|
|
|
|
UiBridge.Bridge.OnError(this, Strings.Invalid_batch_number);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2020-04-18 08:25:30 +00:00
|
|
|
|
|
|
|
|
|
|
restoreInterruptedSession = true;
|
2020-02-06 14:39:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-08 09:34:02 +00:00
|
|
|
|
|
2018-06-15 07:38:18 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2021-09-23 09:46:40 +00:00
|
|
|
|
using (ISession localSession = TBF.DB.CreateSession(Common.DBKind.Config))
|
2018-06-15 07:38:18 +00:00
|
|
|
|
{
|
|
|
|
|
|
StateMachine.LoadPathsAndTransitions(localSession);
|
|
|
|
|
|
}
|
2018-06-19 07:25:24 +00:00
|
|
|
|
|
2018-06-20 12:38:32 +00:00
|
|
|
|
///
|
2020-02-06 14:39:38 +00:00
|
|
|
|
/// Try to load all parameters of selected or restored procedure from the respective database
|
2018-06-20 12:38:32 +00:00
|
|
|
|
///
|
2020-04-18 08:25:30 +00:00
|
|
|
|
if (restoreInterruptedSession)
|
2018-06-15 07:38:18 +00:00
|
|
|
|
{
|
2020-04-18 08:25:30 +00:00
|
|
|
|
/// User has chosen to restore an interrupted session and necessary conditions are met
|
|
|
|
|
|
|
2021-09-23 09:46:40 +00:00
|
|
|
|
/// TODO: Repeate twice for Common.DBKind.Config and Common.DBKind.RemoteConfig
|
2021-09-19 20:04:16 +00:00
|
|
|
|
using (ISession remoteOrLocalSession = TBF.DB.CreateSession(isRemoteIntProc ?
|
2021-09-23 09:46:40 +00:00
|
|
|
|
Common.DBKind.RemoteConfig :
|
|
|
|
|
|
Common.DBKind.Config))
|
2018-06-19 07:25:24 +00:00
|
|
|
|
{
|
2020-02-06 14:39:38 +00:00
|
|
|
|
StateMachine.LoadProcedure(remoteOrLocalSession, interruptedProcedureName, isRemoteIntProc);
|
|
|
|
|
|
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
|
|
|
|
|
|
2020-04-18 08:25:30 +00:00
|
|
|
|
/// This is to load Procedure.Tests and test.MoreParams for each test
|
2020-02-06 14:39:38 +00:00
|
|
|
|
int a = 0;
|
|
|
|
|
|
foreach (var test in StateMachine.Procedure.Tests) a += test.MoreParams.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ((Bridge.SelectedProcedure != null) && !string.IsNullOrEmpty(Bridge.SelectedProcedure.Name))
|
|
|
|
|
|
{
|
2020-04-18 08:25:30 +00:00
|
|
|
|
if (selection == Selection.Cycle)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// This is a regular complete cycle => check AutoAction==InvokeXY calendar events
|
|
|
|
|
|
procedureBefore = ServeCalendarEventsInvokeXY(Config.CalendarEvent.AutoAction.InvokeBeforeCycle, 1);
|
|
|
|
|
|
|
|
|
|
|
|
if (procedureBefore.Count == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// TODO: Invoke procedure before a cycle
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
testsInside = ServeCalendarEventsInvokeXY(Config.CalendarEvent.AutoAction.InvokeInsideCycle);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-23 09:46:40 +00:00
|
|
|
|
/// TODO: Repeate twice for Common.DBKind.Config and Common.DBKind.RemoteConfig
|
2021-09-19 20:04:16 +00:00
|
|
|
|
using (ISession remoteOrLocalSession = TBF.DB.CreateSession(Bridge.SelectedProcedure.IsRemote ?
|
2021-09-23 09:46:40 +00:00
|
|
|
|
Common.DBKind.RemoteConfig :
|
|
|
|
|
|
Common.DBKind.Config))
|
2020-02-06 14:39:38 +00:00
|
|
|
|
{
|
2020-04-18 08:25:30 +00:00
|
|
|
|
StateMachine.LoadProcedure(remoteOrLocalSession, Bridge.SelectedProcedure.Name, Bridge.SelectedProcedure.IsRemote, testsInside);
|
2018-06-19 07:25:24 +00:00
|
|
|
|
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
2018-06-08 10:41:47 +00:00
|
|
|
|
|
2020-04-18 08:25:30 +00:00
|
|
|
|
/// This is to load Procedure.Tests and test.MoreParams for each test
|
2018-06-19 07:25:24 +00:00
|
|
|
|
int a = 0;
|
|
|
|
|
|
foreach (var test in StateMachine.Procedure.Tests) a += test.MoreParams.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-20 12:38:32 +00:00
|
|
|
|
else
|
2018-06-19 07:25:24 +00:00
|
|
|
|
{
|
|
|
|
|
|
StateMachine.Procedure = null;
|
2018-06-08 10:41:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-20 12:38:32 +00:00
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
StateMachine.Procedure = null;
|
|
|
|
|
|
}
|
2018-06-08 10:41:47 +00:00
|
|
|
|
}
|
2017-04-10 13:23:37 +00:00
|
|
|
|
while (StateMachine.Procedure == null); /// Make sure a valid procedure is selected
|
2014-08-12 16:22:32 +00:00
|
|
|
|
|
2018-06-15 07:38:18 +00:00
|
|
|
|
Debug.WriteLine(string.Empty);
|
|
|
|
|
|
Debug.WriteLine(string.Format("TransitionSequences {0}", NHibernateUtil.IsInitialized(StateMachine.TransitionSequences) ? "initialized" : "NOT initialized"));
|
|
|
|
|
|
Debug.WriteLine(string.Format("TransitionSteps {0}", NHibernateUtil.IsInitialized(StateMachine.TransitionSteps) ? "initialized" : "NOT initialized"));
|
|
|
|
|
|
Debug.WriteLine(string.Format("Procedure {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure) ? "initialized" : "NOT initialized"));
|
|
|
|
|
|
Debug.WriteLine(string.Format("Procedure.MoreParams {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure.MoreParams) ? "initialized" : "NOT initialized"));
|
|
|
|
|
|
Debug.WriteLine(string.Format("Procedure.Tests {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure.Tests) ? "initialized" : "NOT initialized"));
|
2019-09-21 09:04:40 +00:00
|
|
|
|
if (StateMachine.Procedure.Tests.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.WriteLine(string.Format("Procedure.Tests[0].MoreParams {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure.Tests[0].MoreParams) ? "initialized" : "NOT initialized"));
|
|
|
|
|
|
}
|
2018-06-15 07:38:18 +00:00
|
|
|
|
|
2018-06-08 10:41:47 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
|
|
|
|
|
|
|
2016-01-10 12:15:14 +00:00
|
|
|
|
|
2020-02-04 07:11:11 +00:00
|
|
|
|
if (selection == Selection.RestoreInterruptedSession)
|
|
|
|
|
|
{
|
2020-02-06 14:39:38 +00:00
|
|
|
|
if (!LoadProcessData())
|
2020-02-04 07:11:11 +00:00
|
|
|
|
{
|
2020-02-06 14:39:38 +00:00
|
|
|
|
/// Restorig interrupted session failed
|
|
|
|
|
|
UiBridge.Bridge.OnError(this, "Restorig interrupted session failed");
|
2020-02-04 07:11:11 +00:00
|
|
|
|
goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-02-06 14:39:38 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Clear session data in case this is not an interrupted/restored session
|
|
|
|
|
|
ClearSessionData();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Procedure selected at this point, a new batch was started
|
|
|
|
|
|
///
|
|
|
|
|
|
int newBatchNr = Program.LocalSettings.BatchNr;
|
|
|
|
|
|
StateMachine.ControlBoard.ManualUIAllowed = !StateMachine.Procedure.ManualCtrlDisabled;
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// A new cycle started : Enable STOP button
|
|
|
|
|
|
log.FatalFormat("New measurement session started: batch = {0}, procedure = {1}", newBatchNr, StateMachine.Procedure.Name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (selection == Selection.RestoreBatch)
|
2016-01-02 16:53:57 +00:00
|
|
|
|
{
|
2017-04-20 11:45:38 +00:00
|
|
|
|
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
|
|
|
|
|
|
RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, ref BatchRslts); /// pass the original batch number of the batch to be restored
|
2017-04-10 13:23:37 +00:00
|
|
|
|
}
|
2019-04-30 09:43:37 +00:00
|
|
|
|
else if (selection == Selection.RestoreAndFixBatch)
|
|
|
|
|
|
{
|
2019-07-24 13:15:09 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Restore and fix a batch - part 1 (fix "Previous workstep is missing" error)
|
|
|
|
|
|
///
|
2019-04-30 09:43:37 +00:00
|
|
|
|
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
|
|
|
|
|
|
RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, ref BatchRslts); /// pass the original batch number of the batch to be restored
|
|
|
|
|
|
|
2020-01-31 14:45:30 +00:00
|
|
|
|
for (int i = 0; i < BatchRslts.Batch.WaterMeters.Count; i++)
|
2019-04-30 09:43:37 +00:00
|
|
|
|
{
|
2020-01-31 14:45:30 +00:00
|
|
|
|
WaterMeter wm = BatchRslts.Batch.WaterMeters[i];
|
|
|
|
|
|
if (wm != null && !wm.Disabled)
|
2019-04-30 09:43:37 +00:00
|
|
|
|
{
|
2019-10-10 11:41:31 +00:00
|
|
|
|
if (wm.Passed)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Water meter passed and was already saved to Oracle, do not reload & fix it now
|
|
|
|
|
|
wm.Disabled = true;
|
|
|
|
|
|
}
|
2019-12-18 16:52:46 +00:00
|
|
|
|
else if ((wm.ErrorFlags & (int)ErrorFlagMask.E28) == 0)
|
2019-10-10 11:41:31 +00:00
|
|
|
|
{
|
2019-12-18 16:52:46 +00:00
|
|
|
|
/// Water meter failed but the failure is not an assembly error
|
|
|
|
|
|
wm.Disabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (!wm.Disabled && (Users.GlobalData.GetCurrentUserName() == "milan" ||
|
|
|
|
|
|
Users.GlobalData.GetCurrentUserName() == "augustin" ||
|
|
|
|
|
|
Users.GlobalData.GetCurrentUserName() == "michal" ||
|
|
|
|
|
|
Users.GlobalData.GetCurrentUserName() == "michal2"))
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Water meter failed, is not disabled, there is an assembly error and user is one of above
|
|
|
|
|
|
/// ... => reset flag E28
|
2019-10-10 11:41:31 +00:00
|
|
|
|
wm.ErrorFlags = wm.ErrorFlags & (~(int)ErrorFlagMask.E28);
|
|
|
|
|
|
foreach (var mtr in wm.MeterTestRslts)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (mtr.TestData().Evaluate && (mtr.TestData().Name == "Kontrola montaze") && (mtr.TestData().Method == "iPerlCommunication"))
|
|
|
|
|
|
{
|
|
|
|
|
|
mtr.TestDone = true;
|
|
|
|
|
|
mtr.Passed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-04-30 09:43:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-02-06 14:39:38 +00:00
|
|
|
|
else if (selection != Selection.RestoreInterruptedSession)
|
2017-04-12 15:33:47 +00:00
|
|
|
|
{
|
2020-02-06 14:39:38 +00:00
|
|
|
|
/// This is a regular session => initialize BatchRslts
|
2017-04-20 09:00:41 +00:00
|
|
|
|
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
|
2017-04-12 15:33:47 +00:00
|
|
|
|
}
|
2016-01-02 16:53:57 +00:00
|
|
|
|
|
2020-02-06 14:39:38 +00:00
|
|
|
|
|
|
|
|
|
|
BatchRslts.Batch.IsRemoteProcedure = StateMachine.IsRemoteProcedure;
|
2016-01-10 12:15:14 +00:00
|
|
|
|
StateMachine.CycleStartTimeStamp = BatchRslts.Batch.StartTime;
|
2020-02-04 07:11:11 +00:00
|
|
|
|
Bridge.OnProcedureSelected(this, new ProcedureSelectedEventArgs(StateMachine.Procedure)); /// Select procedure in case of interrupted session
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2019-03-16 09:08:15 +00:00
|
|
|
|
|
2020-02-04 07:11:11 +00:00
|
|
|
|
if (selection != Selection.RestoreBatch && selection != Selection.RestoreAndFixBatch && selection != Selection.RestoreInterruptedSession)
|
2019-03-16 09:08:15 +00:00
|
|
|
|
{
|
2020-02-04 07:11:11 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// This is a normal batch (not a restored one) => Display 'Cycle Begin Form'
|
|
|
|
|
|
///
|
|
|
|
|
|
if (!OpenCycleBeginForm())
|
|
|
|
|
|
{
|
|
|
|
|
|
goto stop;
|
|
|
|
|
|
}
|
2017-04-10 13:23:37 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2019-03-16 09:08:15 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Prepare operations for reading start info @ cycle start
|
|
|
|
|
|
///
|
|
|
|
|
|
IList<IOperation> startInfoReadOps = new List<IOperation>();
|
|
|
|
|
|
string[] resultWriters = StateMachine.Procedure.ResultsWriter.Split(new char[] { '~' });
|
|
|
|
|
|
foreach (var writerName in resultWriters)
|
|
|
|
|
|
{
|
|
|
|
|
|
IStartInfoReader infoReader = TbfComponents.FindComponent(writerName) as IStartInfoReader;
|
|
|
|
|
|
if (infoReader != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2020-01-31 14:45:30 +00:00
|
|
|
|
IOperation op = infoReader.ReadStartInfoOp(ProcessData.BatchRslts.Batch.WaterMeters);
|
2019-03-16 09:08:15 +00:00
|
|
|
|
if (op != null) startInfoReadOps.Add(op);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
|
{
|
|
|
|
|
|
Bridge.OnError(this, string.Format(Strings.Component_0_crashed_Results_not_saved, writerName));
|
|
|
|
|
|
log.FatalFormat("StartInfoReader {0} crashed: {1}", writerName, exc.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///
|
2014-08-13 14:20:00 +00:00
|
|
|
|
/// Find purge suquences
|
2019-03-16 09:08:15 +00:00
|
|
|
|
///
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-04 07:11:11 +00:00
|
|
|
|
if (selection == Selection.Q1 ||
|
|
|
|
|
|
selection == Selection.Q2 ||
|
|
|
|
|
|
selection == Selection.Q3 ||
|
|
|
|
|
|
selection == Selection.Test ||
|
|
|
|
|
|
selection == Selection.RestoreInterruptedSession)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
goto assume_bench_filled;
|
|
|
|
|
|
}
|
2020-02-04 07:11:11 +00:00
|
|
|
|
else if ((selection == Selection.Cycle && benchFilled) || (selection == Selection.RestoreBatch) || (selection == Selection.RestoreAndFixBatch) || (selection == Selection.RestoreInterruptedSession))
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2017-04-10 13:23:37 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Always ask a question in case of a restored batch
|
|
|
|
|
|
///
|
2014-07-28 07:54:35 +00:00
|
|
|
|
State.Create("MainSeq : Answer a question")
|
2019-03-16 09:08:15 +00:00
|
|
|
|
.AddOperation(new Operations.AskYesNoOp(Strings.Fill_with_water))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
2014-07-28 07:54:35 +00:00
|
|
|
|
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:
|
|
|
|
|
|
|
2016-04-07 11:52:57 +00:00
|
|
|
|
CollectSimultSteps();
|
2015-09-10 18:07:06 +00:00
|
|
|
|
///
|
|
|
|
|
|
if (simultWithPurgingCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Make sure the entry form is closed
|
|
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stop;
|
|
|
|
|
|
|
|
|
|
|
|
/// Open iPerlCommunicationForm
|
2016-02-16 14:57:30 +00:00
|
|
|
|
ProcessData.RegisterReaders = StateMachine.GetMetersPath(simultWithPurgingTests[0]).RegisterReaders;
|
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
|
|
|
|
|
2019-02-06 09:34:43 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Wait until iPerl communications or S/N data entry are completed
|
|
|
|
|
|
///
|
2019-03-16 09:08:15 +00:00
|
|
|
|
if ((simultWithPurgingCount > 0) || (startInfoReadOps.Count > 0))
|
2015-09-05 10:19:11 +00:00
|
|
|
|
{
|
2019-03-06 12:11:01 +00:00
|
|
|
|
/// Get 'bool completed'
|
|
|
|
|
|
bool completed = !(modelessDlg is GenericDevices.IHasCompleted) || (modelessDlg as GenericDevices.IHasCompleted).Completed;
|
|
|
|
|
|
if (lastDataEntryCmpnt != null) completed = completed && lastDataEntryCmpnt.Completed;
|
|
|
|
|
|
|
2015-09-05 10:19:11 +00:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-03-06 12:11:01 +00:00
|
|
|
|
/// Update 'bool completed'
|
|
|
|
|
|
completed = !(modelessDlg is GenericDevices.IHasCompleted) || (modelessDlg as GenericDevices.IHasCompleted).Completed;
|
|
|
|
|
|
if (lastDataEntryCmpnt != null) completed = completed && lastDataEntryCmpnt.Completed;
|
2015-09-05 10:19:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
while (!completed);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
modelessDlg = null;
|
2019-01-09 12:48:51 +00:00
|
|
|
|
}
|
2017-04-12 15:33:47 +00:00
|
|
|
|
|
2019-03-16 09:08:15 +00:00
|
|
|
|
assume_bench_filled:
|
|
|
|
|
|
|
|
|
|
|
|
benchFilled = true;
|
|
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.ShowBenchFilled);
|
|
|
|
|
|
|
2019-04-30 09:43:37 +00:00
|
|
|
|
if ((selection == Selection.Cycle) || (selection == Selection.RestoreBatch) || (selection == Selection.RestoreAndFixBatch))
|
2019-01-09 12:48:51 +00:00
|
|
|
|
{
|
2019-03-16 09:08:15 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Read start info from the DB @ cycle start
|
|
|
|
|
|
///
|
|
|
|
|
|
if (startInfoReadOps.Count > 0)
|
2019-01-09 12:48:51 +00:00
|
|
|
|
{
|
2019-03-16 09:08:15 +00:00
|
|
|
|
State.Create("MainSeq : Reading start info from DB")
|
|
|
|
|
|
.AddOperations(startInfoReadOps)
|
|
|
|
|
|
.AddOperation(checkUiOp).EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.Busy));
|
2019-01-09 12:48:51 +00:00
|
|
|
|
|
2019-03-16 09:08:15 +00:00
|
|
|
|
if (e.Contains(Event.InfoNotRead))
|
|
|
|
|
|
{
|
|
|
|
|
|
log.ErrorFormat("StartInfoReader failed to read data from the database");
|
|
|
|
|
|
/// TODO: Message for an operator? Error?
|
|
|
|
|
|
}
|
2019-10-10 11:41:31 +00:00
|
|
|
|
else if ((selection == Selection.RestoreAndFixBatch) && (Users.GlobalData.GetCurrentUserName() != "milan"))
|
2019-07-24 13:15:09 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// Restore and fix a batch - part 2
|
2020-01-31 14:45:30 +00:00
|
|
|
|
for (int i = 0; i < BatchRslts.Batch.WaterMeters.Count; i++)
|
2019-07-24 13:15:09 +00:00
|
|
|
|
{
|
2020-01-31 14:45:30 +00:00
|
|
|
|
WaterMeter wm = BatchRslts.Batch.WaterMeters[i];
|
2019-07-24 13:15:09 +00:00
|
|
|
|
if (wm != null && !wm.Disabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Water meter did not pass
|
|
|
|
|
|
foreach (var mtr in wm.MeterTestRslts)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Find test entitled 'Kontrola montaze'
|
|
|
|
|
|
if (mtr.TestData().Evaluate && (mtr.TestData().Name == "Kontrola montaze") && (mtr.TestData().Method == "iPerlCommunication"))
|
|
|
|
|
|
{
|
|
|
|
|
|
/// This meter test result (mtr) is 'Kontrola montaze'
|
|
|
|
|
|
if (wm.LastRecordIsNok)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// There is still a production tracing error, last record is missing
|
2021-09-23 09:46:40 +00:00
|
|
|
|
wm.ErrorFlags |= (int)ErrorFlagMask.E28; /// Set E28
|
2019-07-24 13:15:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// No production tracing error, last record is OK
|
2021-09-23 09:46:40 +00:00
|
|
|
|
wm.ErrorFlags &= ~(int)ErrorFlagMask.E28; /// Clear E28
|
2019-07-24 13:15:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-23 09:46:40 +00:00
|
|
|
|
if ((wm.ErrorFlags & (int)ErrorFlagMask.E28) != 0)
|
2019-07-24 13:15:09 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// Previous workstep missing or NOK (production tracing error)
|
|
|
|
|
|
mtr.ErrorIndicators |= (int)ErrorFlagMask.E28;
|
|
|
|
|
|
mtr.Passed = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Previous step is OK
|
|
|
|
|
|
mtr.Passed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-02-06 09:34:43 +00:00
|
|
|
|
|
2019-03-16 09:08:15 +00:00
|
|
|
|
/// Redraw on-screen results
|
|
|
|
|
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(string.Empty, null));
|
|
|
|
|
|
}
|
2019-01-09 12:48:51 +00:00
|
|
|
|
}
|
2015-09-04 11:49:04 +00:00
|
|
|
|
|
2020-02-04 07:11:11 +00:00
|
|
|
|
if (selection == Selection.Cycle || selection == Selection.RestOfCycle ||
|
|
|
|
|
|
selection == Selection.Test || selection == Selection.Q1 || selection == Selection.Q2 || selection == Selection.Q3)
|
2014-08-12 12:52:42 +00:00
|
|
|
|
{
|
2014-08-12 16:22:32 +00:00
|
|
|
|
goto cycle_or_test_selected;
|
2014-08-12 12:52:42 +00:00
|
|
|
|
}
|
2020-02-04 07:11:11 +00:00
|
|
|
|
else if (selection == Selection.RestoreInterruptedSession)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Make progress bars of completed test green
|
|
|
|
|
|
foreach (var testRslt in BatchRslts.Batch.TestRslts)
|
|
|
|
|
|
{
|
2020-02-06 14:39:38 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(testRslt));
|
2020-02-04 07:11:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// TODO: Try to find out where the cycle stopped
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Do nothing
|
|
|
|
|
|
}
|
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);
|
2019-03-06 12:11:01 +00:00
|
|
|
|
if (selection == Selection.Shutdown)
|
|
|
|
|
|
{
|
|
|
|
|
|
Shutdown();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
switch (selection)
|
2017-12-08 09:34:02 +00:00
|
|
|
|
{
|
2018-02-06 14:26:50 +00:00
|
|
|
|
case Selection.Q1: selectedTestName = "Q1"; break;
|
|
|
|
|
|
case Selection.Q2: selectedTestName = "Q2"; break;
|
|
|
|
|
|
case Selection.Q3: selectedTestName = "Q3"; break;
|
|
|
|
|
|
default: selectedTestName = Bridge.SelectedTestName; break;
|
2017-12-08 09:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
///
|
2017-07-25 08:41:06 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
|
|
|
|
|
|
///
|
|
|
|
|
|
if (selection == Selection.PurgeBegin) goto fill_the_bench;
|
2017-06-30 10:04:55 +00:00
|
|
|
|
if (selection == Selection.PurgeEnd)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (DoEvacuation(purgeEnd))
|
|
|
|
|
|
{
|
|
|
|
|
|
case Event.Error: goto error;
|
|
|
|
|
|
case Event.UiCmdStop: goto stop;
|
|
|
|
|
|
default: goto select_cycle_or_test;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-05-22 14:43:17 +00:00
|
|
|
|
if (selection == Selection.Break)
|
|
|
|
|
|
{
|
2017-05-03 20:19:26 +00:00
|
|
|
|
StateMachine.ControlBoard.ManualUIAllowed = true;
|
2015-05-22 14:43:17 +00:00
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.ShowBenchEmpty);
|
2017-05-04 20:11:18 +00:00
|
|
|
|
Bridge.OnProcedureCompleted(this, new ProcedureCompletedEventArgs(StateMachine.Procedure));
|
|
|
|
|
|
goto select_procedure;
|
2015-05-22 14:43:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
2017-05-03 20:19:26 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
|
2015-06-25 02:45:04 +00:00
|
|
|
|
|
2017-05-03 20:19:26 +00:00
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed())
|
|
|
|
|
|
{
|
|
|
|
|
|
goto stop_within_cycle; /// Make sure the entry form is closed
|
|
|
|
|
|
}
|
2015-04-28 13:27:47 +00:00
|
|
|
|
|
2017-05-03 20:19:26 +00:00
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Hide buttons
|
2014-07-30 22:03:19 +00:00
|
|
|
|
|
2016-04-07 11:52:57 +00:00
|
|
|
|
if (selection != Selection.Cycle)
|
|
|
|
|
|
{
|
2016-04-07 12:53:34 +00:00
|
|
|
|
//--------------------------------
|
|
|
|
|
|
State.Create("MainSeq : Continue in the cycle?")
|
2019-10-15 08:03:28 +00:00
|
|
|
|
.AddOperation(new Operations.AskYesNoOp(Strings.Continue_in_the_cycle))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
2016-04-07 12:53:34 +00:00
|
|
|
|
while (true)
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.Yes))
|
|
|
|
|
|
{
|
|
|
|
|
|
selection = Selection.RestOfCycle;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.Contains(Event.No)) break;
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto select_procedure;
|
|
|
|
|
|
}
|
2016-04-07 11:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-11-22 13:56:22 +00:00
|
|
|
|
///------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
if (selection == Selection.Cycle || selection == Selection.RestOfCycle)
|
|
|
|
|
|
{
|
2019-06-27 09:14:26 +00:00
|
|
|
|
/// A sequence of tests will be executed
|
|
|
|
|
|
|
2017-11-22 13:56:22 +00:00
|
|
|
|
IList<DeferredTestEvaluationData> deferredData = new List<DeferredTestEvaluationData>();
|
2019-06-27 09:14:26 +00:00
|
|
|
|
bool veryFirstTestInTheRestOfCycle = true;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2021-01-21 14:00:55 +00:00
|
|
|
|
int selsctedTestIx = -1; ///= undefined
|
2017-11-22 13:56:22 +00:00
|
|
|
|
///
|
2021-01-21 14:00:55 +00:00
|
|
|
|
if (selection == Selection.RestOfCycle) /// ... otherwise
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < StateMachine.TestInstances.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (selectedTestName == StateMachine.TestInstances[i].Name)
|
|
|
|
|
|
{
|
|
|
|
|
|
selsctedTestIx = i;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((selsctedTestIx < simultWithPurgingCount) ||
|
|
|
|
|
|
(selsctedTestIx >= StateMachine.TestInstances.Length - simultWithEvacuationCount))
|
|
|
|
|
|
{
|
2019-10-15 08:03:28 +00:00
|
|
|
|
/// Invalid test selection
|
2021-01-21 14:00:55 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, string.Format("No test specified"));
|
|
|
|
|
|
goto select_cycle_or_test;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
selsctedTestIx = simultWithPurgingCount; /// Applies when selection == Selection.Cycle
|
|
|
|
|
|
}
|
2016-04-07 12:53:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
2018-01-24 12:59:20 +00:00
|
|
|
|
float TimeEstimateTotal = 0; /// Time estimate of the selected cycle or test
|
2016-04-07 12:53:34 +00:00
|
|
|
|
|
2021-01-21 14:00:55 +00:00
|
|
|
|
for (int i = selsctedTestIx; i < StateMachine.TestInstances.Length - simultWithEvacuationCount; i++)
|
2016-04-07 12:53:34 +00:00
|
|
|
|
{
|
2021-01-21 14:00:55 +00:00
|
|
|
|
Test test = StateMachine.TestInstances[i].Test;
|
2016-04-07 12:53:34 +00:00
|
|
|
|
|
2021-09-23 09:46:40 +00:00
|
|
|
|
TimeEstimateTotal += (test.TestTime + 10.0f);
|
2016-04-07 12:53:34 +00:00
|
|
|
|
|
|
|
|
|
|
/// Try to fetch all test paths and transitions
|
|
|
|
|
|
/// to detect configuration errors as early as possible.
|
2019-10-15 08:03:28 +00:00
|
|
|
|
TBF.BenchControl.Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
|
|
|
|
|
|
string errorMsg;
|
2017-11-22 13:56:22 +00:00
|
|
|
|
if (!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.Start.Component) &&
|
|
|
|
|
|
!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.End.Component) &&
|
2016-12-10 15:27:51 +00:00
|
|
|
|
!StateMachine.GetPaths(test, (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter),
|
2016-07-07 07:52:54 +00:00
|
|
|
|
out inPath, out benchPath, out outPath, out sensPath,
|
|
|
|
|
|
out heatMetersPath,
|
2018-11-14 07:23:01 +00:00
|
|
|
|
out transitionBefore, out transitionBetween, out transitionAfter,
|
2016-07-07 07:52:54 +00:00
|
|
|
|
out errorMsg))
|
|
|
|
|
|
{
|
2016-04-07 12:53:34 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, errorMsg);
|
|
|
|
|
|
goto select_cycle_or_test;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-10 10:30:57 +00:00
|
|
|
|
int currentTestIx = selsctedTestIx;
|
2021-01-21 14:00:55 +00:00
|
|
|
|
while (currentTestIx < StateMachine.TestInstances.Length - simultWithEvacuationCount)
|
2016-04-07 12:53:34 +00:00
|
|
|
|
{
|
2021-01-21 14:00:55 +00:00
|
|
|
|
TestInstance nextTest = (currentTestIx + 1 < StateMachine.TestInstances.Length - simultWithEvacuationCount)
|
|
|
|
|
|
? StateMachine.TestInstances[currentTestIx + 1]
|
|
|
|
|
|
: null;
|
2016-04-07 12:53:34 +00:00
|
|
|
|
|
2019-10-15 08:03:28 +00:00
|
|
|
|
Test nextHydroTest = null;
|
2021-01-21 14:00:55 +00:00
|
|
|
|
for (int i = currentTestIx + 1; i < StateMachine.TestInstances.Length - simultWithEvacuationCount; i++)
|
2019-10-15 08:03:28 +00:00
|
|
|
|
{
|
2021-01-21 14:00:55 +00:00
|
|
|
|
Test tst = StateMachine.TestInstances[i].Test;
|
2019-10-15 08:03:28 +00:00
|
|
|
|
if (tst != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
ITestMethod tm = TbfComponents.FindComponent(tst.Method) as ITestMethod;
|
|
|
|
|
|
if (tm != null && tm.DoTransitions())
|
|
|
|
|
|
{
|
|
|
|
|
|
nextHydroTest = tst;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (nextHydroTest != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Fetch paths and 'transition before' of the next test
|
|
|
|
|
|
TBF.BenchControl.Generic.IComponent nextTestMethodComp = TbfComponents.FindComponent(nextHydroTest.Method);
|
|
|
|
|
|
TransitionSequence dummy2, dummy3;
|
|
|
|
|
|
string errorMsg2;
|
|
|
|
|
|
if (!(nextTestMethodComp is TBF.BenchControl.TestMethods.OuterLoop.Start.Component) &&
|
|
|
|
|
|
!(nextTestMethodComp is TBF.BenchControl.TestMethods.OuterLoop.End.Component) &&
|
|
|
|
|
|
!StateMachine.GetPaths(nextHydroTest, (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter),
|
|
|
|
|
|
out nextInPath, out nextBenchPath, out nextOutPath, out nextSensPath,
|
|
|
|
|
|
out nextHeatMetersPath,
|
|
|
|
|
|
out nextTransitionBefore, out dummy2, out dummy3,
|
|
|
|
|
|
out errorMsg2))
|
|
|
|
|
|
{
|
|
|
|
|
|
UiBridge.Bridge.OnError(this, errorMsg2);
|
|
|
|
|
|
goto select_cycle_or_test;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nextQfrom = nextHydroTest.Qfrom;
|
|
|
|
|
|
nextQto = nextHydroTest.Qto;
|
|
|
|
|
|
nextPumpPower = nextHydroTest.PumpPower;
|
2021-09-23 09:46:40 +00:00
|
|
|
|
nextTolerRed = nextHydroTest.ShortPulses;
|
2019-10-15 08:03:28 +00:00
|
|
|
|
nextPidCoef = (nextOutPath != null) ? nextOutPath.PidCoef : 1.0F;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Clear paths and 'transition before' of the next test it does not exist
|
|
|
|
|
|
nextInPath = null;
|
|
|
|
|
|
nextBenchPath = null;
|
|
|
|
|
|
nextOutPath = null;
|
|
|
|
|
|
nextSensPath = null;
|
|
|
|
|
|
nextHeatMetersPath = null;
|
|
|
|
|
|
nextTransitionBefore = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Fetch paths and transitions of this test
|
2021-01-21 14:00:55 +00:00
|
|
|
|
TestInstance testInst = StateMachine.TestInstances[currentTestIx];
|
|
|
|
|
|
TBF.BenchControl.Generic.IComponent testMethodComp = TbfComponents.FindComponent(testInst.Test.Method);
|
2019-10-15 08:03:28 +00:00
|
|
|
|
string errorMsg;
|
2021-01-21 14:00:55 +00:00
|
|
|
|
if (!StateMachine.GetPaths(testInst.Test, (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter),
|
2016-07-07 07:52:54 +00:00
|
|
|
|
out inPath, out benchPath, out outPath, out sensPath,
|
|
|
|
|
|
out heatMetersPath,
|
2018-11-14 07:23:01 +00:00
|
|
|
|
out transitionBefore, out transitionBetween, out transitionAfter,
|
2016-07-07 07:52:54 +00:00
|
|
|
|
out errorMsg))
|
|
|
|
|
|
{
|
2016-04-07 12:53:34 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, errorMsg);
|
|
|
|
|
|
goto select_cycle_or_test;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Update format for the water mass
|
2019-10-15 08:03:28 +00:00
|
|
|
|
if (outPath != null && outPath.Scale != null && !string.IsNullOrEmpty(outPath.Scale.Format))
|
|
|
|
|
|
{
|
|
|
|
|
|
Mass.Format = outPath.Scale.Format;
|
|
|
|
|
|
StartMass.Format = outPath.Scale.Format;
|
|
|
|
|
|
EndMass.Format = outPath.Scale.Format;
|
|
|
|
|
|
}
|
2016-04-07 12:53:34 +00:00
|
|
|
|
|
2017-11-22 13:56:22 +00:00
|
|
|
|
|
|
|
|
|
|
ITestMethod testMethod = testMethodComp as ITestMethod;
|
|
|
|
|
|
if (testMethod != null && testMethod.CanTest(StateMachine.Procedure.MetersKind))
|
2016-04-07 12:53:34 +00:00
|
|
|
|
{
|
2021-01-21 14:00:55 +00:00
|
|
|
|
StateMachine.LoadTestParams(testInst.Test);
|
2019-12-05 12:06:47 +00:00
|
|
|
|
|
|
|
|
|
|
if ((sensPath != null) && (sensPath.RegisterReaders != null))
|
|
|
|
|
|
{
|
|
|
|
|
|
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
|
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((rr is TestMethods.iPerlCommunication.iPerlHead.IperlHead) && (BenchInfo != null))
|
|
|
|
|
|
{
|
|
|
|
|
|
(rr as TestMethods.iPerlCommunication.iPerlHead.IperlHead).BenchName = BenchInfo.TestBenchName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ProcessData.RegisterReaders = null;
|
|
|
|
|
|
}
|
2016-04-07 12:53:34 +00:00
|
|
|
|
|
2017-12-02 16:54:38 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Execute one test (single repetition of a repeated test)
|
|
|
|
|
|
/// Previously:
|
|
|
|
|
|
/// e = testMethod.Execute(test, outerLoopMode, (outerLoopMode ? outerLoopCounter: repetNr));
|
|
|
|
|
|
///
|
|
|
|
|
|
Event rsltTransBefore = Event.Done;
|
2018-11-14 07:23:01 +00:00
|
|
|
|
Event rsltTransBetween = Event.Done;
|
2017-12-02 16:54:38 +00:00
|
|
|
|
Event rsltTransAfter = Event.Done;
|
|
|
|
|
|
{
|
|
|
|
|
|
int timeEstTransBefore = testMethod.DoTransitions() ? GetTransitionTimeEst(transitionBefore) : 1;
|
2018-11-14 07:23:01 +00:00
|
|
|
|
int timeEstTransBetween = testMethod.DoTransitions() ? GetTransitionTimeEst(transitionBetween) : 1;
|
2017-12-02 16:54:38 +00:00
|
|
|
|
int timeEstTransAfter = testMethod.DoTransitions() ? GetTransitionTimeEst(transitionAfter) : 1;
|
2016-04-07 12:53:34 +00:00
|
|
|
|
|
2021-09-23 09:46:40 +00:00
|
|
|
|
TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, timeEstTransBefore, 1, 30, 0, Convert.ToInt32(testInst.Test.TestTime) + 15, timeEstTransAfter, 0 });
|
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(testInst.Test, testInst.Repetition, Progress.JustStarted));
|
2017-12-02 16:54:38 +00:00
|
|
|
|
|
2018-06-01 11:58:59 +00:00
|
|
|
|
bool currentTestFinished = true;
|
2018-11-14 15:41:58 +00:00
|
|
|
|
bool doOneMoreRepetition = false;
|
2017-12-02 16:54:38 +00:00
|
|
|
|
|
2021-01-21 14:00:55 +00:00
|
|
|
|
bool doExecuteTransitionBefore = (currentTestIx == simultWithPurgingCount) || (testInst.Test != StateMachine.TestInstances[currentTestIx - 1].Test) || veryFirstTestInTheRestOfCycle;
|
|
|
|
|
|
bool isLastRepetition = (currentTestIx == StateMachine.TestInstances.Length - simultWithEvacuationCount - 1) || (testInst.Test != StateMachine.TestInstances[currentTestIx + 1].Test);
|
|
|
|
|
|
veryFirstTestInTheRestOfCycle = false;
|
|
|
|
|
|
if (testMethod.DoTransitions())
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Make a transition before a test and before each test repetition
|
|
|
|
|
|
rsltTransBefore = Transition(doExecuteTransitionBefore ? transitionBefore : null, TransitionContext.BeforeTest); /// Transition or SetRoute - start of test
|
|
|
|
|
|
log.InfoFormat("Test {0}: Transition({1}, BeforeTest) returned {2}", testInst.Name, (transitionBefore == null ? "null" : transitionBefore.Name), rsltTransBefore);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (rsltTransBefore != Event.Done) break;
|
2017-12-02 16:54:38 +00:00
|
|
|
|
|
2021-01-21 14:00:55 +00:00
|
|
|
|
log.InfoFormat("Test {0}: Execute(., {1}, {2})", testInst.Name, testInst.Repetition, isLastRepetition);
|
|
|
|
|
|
e = testMethod.Execute(testInst.Test, testInst.Repetition, isLastRepetition);
|
2018-06-01 11:58:59 +00:00
|
|
|
|
|
2021-01-21 14:00:55 +00:00
|
|
|
|
if (e.Contains(Event.MakeSecondPass) && testMethod is ITestMethodWith2ndPass)
|
|
|
|
|
|
{
|
|
|
|
|
|
deferredData.Add(new DeferredTestEvaluationData(testInst.Test, testInst.Repetition, (testMethod as ITestMethodWith2ndPass).IntermediateData));
|
|
|
|
|
|
}
|
2018-11-14 07:23:01 +00:00
|
|
|
|
|
2021-01-21 14:00:55 +00:00
|
|
|
|
currentTestFinished = (rsltTransBefore == Event.Done && !e.Contains(Event.Error)
|
|
|
|
|
|
&& !e.Contains(Event.ConfigurationError)
|
|
|
|
|
|
&& !e.Contains(Event.OpArgumentError)
|
|
|
|
|
|
&& !e.Contains(Event.UiCmdStop));
|
2018-11-14 07:23:01 +00:00
|
|
|
|
|
2021-09-23 09:46:40 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(testInst.Test, testInst.Repetition, currentTestFinished ? Progress.Completed
|
|
|
|
|
|
: Progress.Aborted));
|
2017-12-02 16:54:38 +00:00
|
|
|
|
|
2021-01-21 14:00:55 +00:00
|
|
|
|
if (testMethod.DoTransitions() && !e.Contains(Event.RecoverableError))
|
|
|
|
|
|
{
|
2021-06-24 11:57:31 +00:00
|
|
|
|
if (currentTestFinished && !isLastRepetition && !e.Contains(Event.ErrorFlagsStop))
|
2018-11-14 15:41:58 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// Make a transition between two test repetitions
|
|
|
|
|
|
rsltTransBetween = Transition(transitionBetween, TransitionContext.BetweenTests); /// Transition or SetRoute - start of test
|
2021-01-21 14:00:55 +00:00
|
|
|
|
log.InfoFormat("Test {0}: Transition({1}, BetweenTests) returned {2}", testInst.Name, (transitionBetween == null ? "null" : transitionBetween.Name), rsltTransBetween);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Make a transition after the last test repetition
|
|
|
|
|
|
TransitionContext endContext =
|
|
|
|
|
|
!currentTestFinished ? TransitionContext.Stop
|
|
|
|
|
|
: ((nextTransitionBefore != null) && (nextTransitionBefore.Name.ToLower().Contains("fastflow"))) ? TransitionContext.AfterTestWithOverlap
|
|
|
|
|
|
: TransitionContext.AfterTest;
|
|
|
|
|
|
rsltTransAfter = Transition(transitionAfter, endContext); /// Transition or SetRoute - end of test
|
|
|
|
|
|
log.InfoFormat("Test {0}: Transition({1}, {2}) returned {3}", testInst.Name, (transitionAfter == null ? "null" : transitionAfter.Name), endContext, rsltTransAfter);
|
2018-11-14 15:41:58 +00:00
|
|
|
|
}
|
2017-12-02 16:54:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-14 07:23:01 +00:00
|
|
|
|
if (rsltTransBefore == Event.Error || rsltTransBetween == Event.Error|| e.Contains(Event.Error))
|
2017-12-02 16:54:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
goto error;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (e.Contains(Event.ConfigurationError))
|
2016-12-10 10:30:57 +00:00
|
|
|
|
{
|
2017-12-02 16:54:38 +00:00
|
|
|
|
goto select_cycle_or_test; /// OR goto config_error; ???
|
2016-12-10 10:30:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
else if (e.Contains(Event.OpArgumentError))
|
|
|
|
|
|
{
|
|
|
|
|
|
goto config_error;
|
|
|
|
|
|
}
|
2021-06-24 11:57:31 +00:00
|
|
|
|
else if (rsltTransBefore == Event.UiCmdStop || e.Contains(Event.UiCmdStop) || e.Contains(Event.RecoverableError) || e.Contains(Event.ErrorFlagsStop))
|
2016-12-10 10:30:57 +00:00
|
|
|
|
{
|
|
|
|
|
|
goto stop_within_cycle;
|
|
|
|
|
|
}
|
2016-04-07 12:53:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-01-21 14:00:55 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, string.Format(Strings.Method_0_cannot_be_used, testInst.Test.Method));
|
2016-04-07 12:53:34 +00:00
|
|
|
|
goto select_cycle_or_test;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-10 10:30:57 +00:00
|
|
|
|
currentTestIx++;
|
2016-04-07 12:53:34 +00:00
|
|
|
|
}
|
2017-11-22 13:56:22 +00:00
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Execute deferred evaluations of tests that returned 'Event.MakeSecondPass' here
|
|
|
|
|
|
///
|
|
|
|
|
|
foreach (var dfrrdData in deferredData)
|
|
|
|
|
|
{
|
|
|
|
|
|
string errorMsg;
|
|
|
|
|
|
StateMachine.GetPaths(dfrrdData.Test, (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter),
|
|
|
|
|
|
out inPath, out benchPath, out outPath, out sensPath,
|
|
|
|
|
|
out heatMetersPath,
|
2018-11-14 07:23:01 +00:00
|
|
|
|
out transitionBefore, out transitionBetween, out transitionAfter,
|
|
|
|
|
|
out errorMsg);
|
2017-11-22 13:56:22 +00:00
|
|
|
|
|
|
|
|
|
|
ITestMethodWith2ndPass testMethod = TbfComponents.FindComponent(dfrrdData.Test.Method) as ITestMethodWith2ndPass;
|
|
|
|
|
|
|
|
|
|
|
|
if (testMethod != null && testMethod.CanTest(StateMachine.Procedure.MetersKind))
|
|
|
|
|
|
{
|
2018-06-19 07:25:24 +00:00
|
|
|
|
StateMachine.LoadTestParams(dfrrdData.Test);
|
2017-11-22 13:56:22 +00:00
|
|
|
|
|
2019-12-05 12:06:47 +00:00
|
|
|
|
if ((sensPath != null) && (sensPath.RegisterReaders != null))
|
|
|
|
|
|
{
|
|
|
|
|
|
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
|
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((rr is TestMethods.iPerlCommunication.iPerlHead.IperlHead) && (BenchInfo != null))
|
|
|
|
|
|
{
|
|
|
|
|
|
(rr as TestMethods.iPerlCommunication.iPerlHead.IperlHead).BenchName = BenchInfo.TestBenchName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ProcessData.RegisterReaders = null;
|
|
|
|
|
|
}
|
2017-11-22 13:56:22 +00:00
|
|
|
|
|
|
|
|
|
|
e = testMethod.Execute2ndPass(dfrrdData.Test, dfrrdData.RepetNr, dfrrdData.IntermediateData);
|
|
|
|
|
|
|
|
|
|
|
|
if (e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
else if (e.Contains(Event.OpArgumentError)) goto config_error;
|
|
|
|
|
|
else if (e.Contains(Event.UiCmdStop)) goto stop_within_cycle;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
deferredData.Clear();
|
2016-04-07 12:53:34 +00:00
|
|
|
|
}
|
2017-11-22 13:56:22 +00:00
|
|
|
|
///------------------------------------------------------------------------------------------------------------
|
2019-06-27 09:14:26 +00:00
|
|
|
|
else
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2019-06-27 09:14:26 +00:00
|
|
|
|
/// selection == Selection.Test or Selection.Q1 or Selection.Q2 or Selection.Q3
|
|
|
|
|
|
/// Single test will be executed
|
|
|
|
|
|
|
2021-01-21 14:00:55 +00:00
|
|
|
|
int testIx = -1; ///= undefined
|
|
|
|
|
|
///
|
|
|
|
|
|
for (int i = 0; i < StateMachine.TestInstances.Length; i++)
|
2015-05-20 14:18:54 +00:00
|
|
|
|
{
|
2021-01-21 14:00:55 +00:00
|
|
|
|
if (selectedTestName == StateMachine.TestInstances[i].Name)
|
|
|
|
|
|
{
|
|
|
|
|
|
testIx = i;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (testIx < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Invalid test selection
|
2015-05-20 14:18:54 +00:00
|
|
|
|
UiBridge.Bridge.OnError(this, string.Format("No test specified"));
|
|
|
|
|
|
goto select_cycle_or_test;
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2021-01-21 14:00:55 +00:00
|
|
|
|
Test test = StateMachine.TestInstances[testIx].Test;
|
|
|
|
|
|
int repetNr = StateMachine.TestInstances[testIx].Repetition;
|
|
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
/// Fetch the test paths and transitions
|
2015-05-20 14:18:54 +00:00
|
|
|
|
string errorMsg;
|
2017-11-22 13:56:22 +00:00
|
|
|
|
TBF.BenchControl.Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
|
|
|
|
|
|
if (!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.Start.Component) &&
|
|
|
|
|
|
!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.End.Component) &&
|
2016-12-10 15:27:51 +00:00
|
|
|
|
!StateMachine.GetPaths(test, (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter),
|
2016-07-07 07:52:54 +00:00
|
|
|
|
out inPath, out benchPath, out outPath, out sensPath,
|
|
|
|
|
|
out heatMetersPath,
|
2018-11-14 07:23:01 +00:00
|
|
|
|
out transitionBefore, out transitionBetween, out transitionAfter,
|
2016-07-07 07:52: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
|
2018-08-22 15:51:31 +00:00
|
|
|
|
Mass.Format = (outPath != null && outPath.Scale != null) ? outPath.Scale.Format : "F3";
|
|
|
|
|
|
StartMass.Format = (outPath != null && outPath.Scale != null) ? outPath.Scale.Format : "F3";
|
|
|
|
|
|
EndMass.Format = (outPath != null && outPath.Scale != null) ? outPath.Scale.Format : "F3";
|
2014-08-12 16:22:32 +00:00
|
|
|
|
|
2017-11-23 08:15:25 +00:00
|
|
|
|
ITestMethod testMethod = TbfComponents.FindComponent(test.Method) as ITestMethod;
|
|
|
|
|
|
if (testMethod != null && testMethod.CanTest(StateMachine.Procedure.MetersKind))
|
2015-02-02 22:18:28 +00:00
|
|
|
|
{
|
2018-06-19 07:25:24 +00:00
|
|
|
|
StateMachine.LoadTestParams(test);
|
2015-08-22 11:34:10 +00:00
|
|
|
|
|
2019-12-05 12:06:47 +00:00
|
|
|
|
if ((sensPath != null) && (sensPath.RegisterReaders != null))
|
|
|
|
|
|
{
|
|
|
|
|
|
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
|
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((rr is TestMethods.iPerlCommunication.iPerlHead.IperlHead) && (BenchInfo != null))
|
|
|
|
|
|
{
|
|
|
|
|
|
(rr as TestMethods.iPerlCommunication.iPerlHead.IperlHead).BenchName = BenchInfo.TestBenchName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ProcessData.RegisterReaders = null;
|
|
|
|
|
|
}
|
2015-08-22 11:34:10 +00:00
|
|
|
|
|
2017-12-02 16:54:38 +00:00
|
|
|
|
Event rsltTransBefore = Event.Done;
|
|
|
|
|
|
Event rsltTransAfter = Event.Done;
|
|
|
|
|
|
{
|
|
|
|
|
|
int timeEstTransBefore = testMethod.DoTransitions() ? GetTransitionTimeEst(transitionBefore) : 1;
|
2018-11-14 07:23:01 +00:00
|
|
|
|
int timeEstTransBetween = testMethod.DoTransitions() ? GetTransitionTimeEst(transitionBetween) : 1;
|
2017-12-02 16:54:38 +00:00
|
|
|
|
int timeEstTransAfter = testMethod.DoTransitions() ? GetTransitionTimeEst(transitionAfter) : 1;
|
2017-11-23 08:15:25 +00:00
|
|
|
|
|
2021-09-23 09:46:40 +00:00
|
|
|
|
TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, timeEstTransBefore, 1, 30, 0, Convert.ToInt32(test.TestTime) + 15, timeEstTransAfter, 0 });
|
2017-12-02 16:54:38 +00:00
|
|
|
|
/// start, transition, flow detection, flow setting, aborted, test, transition, end
|
2021-09-23 09:46:40 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, Progress.JustStarted));
|
2017-12-02 16:54:38 +00:00
|
|
|
|
|
|
|
|
|
|
if (testMethod.DoTransitions())
|
|
|
|
|
|
{
|
|
|
|
|
|
rsltTransBefore = Transition(transitionBefore, TransitionContext.BeforeTest); /// Transition or SetRoute - start of test
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (rsltTransBefore == Event.Done)
|
|
|
|
|
|
{
|
|
|
|
|
|
e = testMethod.Execute(test, repetNr, true);
|
|
|
|
|
|
|
|
|
|
|
|
if (e.Contains(Event.MakeSecondPass) && testMethod is ITestMethodWith2ndPass)
|
|
|
|
|
|
{
|
|
|
|
|
|
ITestMethodWith2ndPass tm2 = testMethod as ITestMethodWith2ndPass;
|
|
|
|
|
|
e = tm2.Execute2ndPass(test, repetNr, tm2.IntermediateData);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-05 09:16:13 +00:00
|
|
|
|
bool testFinished = (rsltTransBefore == Event.Done && !e.Contains(Event.Error)
|
|
|
|
|
|
&& !e.Contains(Event.ConfigurationError)
|
|
|
|
|
|
&& !e.Contains(Event.OpArgumentError)
|
|
|
|
|
|
&& !e.Contains(Event.UiCmdStop));
|
2017-12-02 16:54:38 +00:00
|
|
|
|
|
2021-09-23 09:46:40 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, testFinished ? Progress.Completed
|
|
|
|
|
|
: Progress.Aborted));
|
2018-06-01 11:58:59 +00:00
|
|
|
|
|
2018-06-06 07:50:52 +00:00
|
|
|
|
if (testMethod.DoTransitions())
|
2017-12-02 16:54:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
TransitionContext endContext = testFinished ? TransitionContext.AfterTest : TransitionContext.Stop;
|
|
|
|
|
|
rsltTransAfter = Transition(transitionAfter, endContext); /// Transition or SetRoute - end of test
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-23 09:46:40 +00:00
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, testFinished ? Progress.Completed
|
|
|
|
|
|
: Progress.Aborted));
|
2017-12-02 16:54:38 +00:00
|
|
|
|
}
|
2015-01-15 02:51:33 +00:00
|
|
|
|
|
2017-12-02 16:54:38 +00:00
|
|
|
|
if (rsltTransBefore == Event.Error || e.Contains(Event.Error)) goto error;
|
|
|
|
|
|
if (e.Contains(Event.ConfigurationError)) goto config_error;
|
|
|
|
|
|
if (e.Contains(Event.OpArgumentError)) goto config_error;
|
|
|
|
|
|
if (rsltTransBefore == Event.UiCmdStop || 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
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-11-22 13:56:22 +00:00
|
|
|
|
///------------------------------------------------------------------------------------------------------------
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
goto select_cycle_or_test;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-11-22 13:56:22 +00:00
|
|
|
|
|
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)
|
2017-11-07 10:05:22 +00:00
|
|
|
|
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Hide 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();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-28 11:40:58 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Enter_protocol_data);
|
2015-02-21 19:00:35 +00:00
|
|
|
|
|
|
|
|
|
|
//--------------------------------
|
2015-01-15 02:51:33 +00:00
|
|
|
|
GenericDevices.IDataEntry dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry;
|
2020-02-06 14:39:38 +00:00
|
|
|
|
if (dataEntryCmpnt is IHasCycleEndForm)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2021-07-16 15:57:55 +00:00
|
|
|
|
IOperation showCycleEndFormOp = (dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp();
|
|
|
|
|
|
|
|
|
|
|
|
if (showCycleEndFormOp != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Open the modeless form for the end of the cycle
|
|
|
|
|
|
State.Create("MainSeq : Enter end data")
|
|
|
|
|
|
.AddOperation(showCycleEndFormOp)
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.ModelessFormClosed));
|
|
|
|
|
|
}
|
2020-02-06 14:39:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Update batch results, determine whether watermeters passed all required tests
|
|
|
|
|
|
///
|
|
|
|
|
|
BatchRslts.Batch.EndTime = DateTime.Now; /// Set cycle end time
|
|
|
|
|
|
Results.Utils.GetCounterStates(BatchRslts.Batch, Program.LocalSettings.Counters); /// Update counters
|
|
|
|
|
|
/// Remove results of internal tests
|
|
|
|
|
|
for (int i = BatchRslts.Batch.TestRslts.Count - 1; i >= 0; i--)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var wm in BatchRslts.Batch.WaterMeters)
|
2014-09-23 11:16:59 +00:00
|
|
|
|
{
|
2020-02-06 14:39:38 +00:00
|
|
|
|
for (int j = wm.MeterTestRslts.Count - 1; j >= 0; j--)
|
2014-09-23 11:16:59 +00:00
|
|
|
|
{
|
2020-02-06 14:39:38 +00:00
|
|
|
|
MeterTestRslt mtr = wm.MeterTestRslts[j];
|
|
|
|
|
|
if ((mtr.Publish() == Publish.Never || mtr.Publish() == Publish.Internal) && !mtr.Evaluate())
|
|
|
|
|
|
{
|
|
|
|
|
|
wm.MeterTestRslts.RemoveAt(j);
|
|
|
|
|
|
}
|
2014-09-23 11:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-01-06 20:39:52 +00:00
|
|
|
|
|
2020-02-06 14:39:38 +00:00
|
|
|
|
TestRslt tr = BatchRslts.Batch.TestRslts[i];
|
|
|
|
|
|
if ((tr.Publish() == Publish.Never || tr.Publish() == Publish.Internal) && !tr.Evaluate())
|
|
|
|
|
|
{
|
|
|
|
|
|
BatchRslts.Batch.TestRslts.RemoveAt(i);
|
|
|
|
|
|
}
|
2019-05-06 14:16:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-06 14:39:38 +00:00
|
|
|
|
/// (1) Set boolean WaterMeter.Passed variable, (2) Remove disabled water meters
|
2020-01-31 14:45:30 +00:00
|
|
|
|
for (int wmNr0 = ProcessData.BatchRslts.Batch.WaterMeters.Count - 1; wmNr0 >= 0; wmNr0--)
|
|
|
|
|
|
{
|
|
|
|
|
|
WaterMeter wm = ProcessData.BatchRslts.Batch.WaterMeters[wmNr0];
|
|
|
|
|
|
if (wm.Disabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Do not save disabled watermeters to DB, remove them from the list
|
|
|
|
|
|
ProcessData.BatchRslts.Batch.WaterMeters.RemoveAt(wmNr0);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Determine whether the watermeter passed all required tests
|
|
|
|
|
|
wm.Passed = wm.PassedFromTests();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-06 20:39:52 +00:00
|
|
|
|
|
2015-01-25 07:11:40 +00:00
|
|
|
|
//------------------------------------------------------
|
2016-05-28 11:40:58 +00:00
|
|
|
|
Bridge.OnActivity(this, Strings.Saving_and_printing_results);
|
2020-03-05 12:59:43 +00:00
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
string[] writers = (StateMachine.Procedure.ResultsWriter != null) ? StateMachine.Procedure.ResultsWriter.Split(new char[] { '~' }) : new string[0];
|
|
|
|
|
|
string[] printers = (StateMachine.Procedure.ResultsPrinter != null) ? StateMachine.Procedure.ResultsPrinter.Split(new char[] { '~' }) : new string[0];
|
|
|
|
|
|
string[] eventTriggers = (StateMachine.Procedure.EventTriggers != null) ? StateMachine.Procedure.EventTriggers.Split(new char[] { '~' }) : new string[0];
|
2020-05-05 13:42:15 +00:00
|
|
|
|
///
|
2020-03-05 12:59:43 +00:00
|
|
|
|
string[] rsltProcessors = new string[writers.Length + printers.Length + eventTriggers.Length];
|
|
|
|
|
|
writers.CopyTo(rsltProcessors, 0);
|
|
|
|
|
|
printers.CopyTo(rsltProcessors, writers.Length);
|
|
|
|
|
|
eventTriggers.CopyTo(rsltProcessors, writers.Length + printers.Length);
|
|
|
|
|
|
///
|
|
|
|
|
|
State savingAndPrintingRslts = State.Create("MainSeq : Saving and printing results");
|
|
|
|
|
|
foreach (var rpName in rsltProcessors)
|
2016-04-29 14:58:23 +00:00
|
|
|
|
{
|
2020-03-05 12:59:43 +00:00
|
|
|
|
IResultsProcessor rsltProcessor = TbfComponents.FindComponent(rpName) as IResultsProcessor;
|
|
|
|
|
|
if (rsltProcessor != null)
|
2016-04-29 14:58:23 +00:00
|
|
|
|
{
|
2016-08-24 13:42:24 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2020-03-05 12:59:43 +00:00
|
|
|
|
savingAndPrintingRslts.AddOperation(rsltProcessor.ProcessResultsOp(ProcessData.BatchRslts.Batch));
|
2016-08-24 13:42:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
|
{
|
2020-03-05 12:59:43 +00:00
|
|
|
|
Bridge.OnError(this, string.Format(Strings.Component_0_crashed_Results_not_saved, rpName));
|
|
|
|
|
|
log.FatalFormat("FileWriter {0} crashed: {1}", rpName, exc.Message);
|
2016-08-24 13:42:24 +00:00
|
|
|
|
}
|
2016-04-29 14:58:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-03-05 12:59:43 +00:00
|
|
|
|
savingAndPrintingRslts.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
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));
|
2020-03-05 12:59:43 +00:00
|
|
|
|
///
|
|
|
|
|
|
bool resultsSent = !e.Contains(Event.ErrorProcessingResults);
|
2016-01-08 12:51:54 +00:00
|
|
|
|
ProcessData.BatchRslts.Batch.RsltsSent = resultsSent;
|
|
|
|
|
|
|
2020-03-05 12:59:43 +00:00
|
|
|
|
|
2016-01-08 12:51:54 +00:00
|
|
|
|
///
|
2019-05-02 12:19:01 +00:00
|
|
|
|
/// Save results to 'Results' MySQL database
|
2016-01-08 12:51:54 +00:00
|
|
|
|
///
|
|
|
|
|
|
Results.DB.SaveNewBatch(ProcessData.BatchRslts.Batch);
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Save results to 'summary results' logger
|
|
|
|
|
|
///
|
2020-10-08 07:00:50 +00:00
|
|
|
|
log.WarnFormat("Saving SummaryResults of batch {0}", ProcessData.BatchRslts.Batch.BatchNr);
|
|
|
|
|
|
foreach (var tr in ProcessData.BatchRslts.Batch.TestRslts)
|
2016-01-08 12:51:54 +00:00
|
|
|
|
{
|
|
|
|
|
|
summaryResults.Info(TestResult2CsvLine(tr));
|
|
|
|
|
|
}
|
2015-02-01 23:07:39 +00:00
|
|
|
|
|
2020-02-04 07:11:11 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Clear a file with interim test results
|
|
|
|
|
|
///
|
|
|
|
|
|
ClearProcessData();
|
|
|
|
|
|
|
2015-02-02 17:09:05 +00:00
|
|
|
|
Program.LocalSettings.BatchNr++;
|
2015-01-25 07:11:40 +00:00
|
|
|
|
Program.LocalSettings.Save();
|
|
|
|
|
|
|
2017-04-20 09:00:41 +00:00
|
|
|
|
log.FatalFormat("Measurement session saved: batch = {0}, procedure = {1}, next batch nr. = {2}",
|
|
|
|
|
|
ProcessData.BatchRslts.Batch.BatchNr,
|
|
|
|
|
|
ProcessData.BatchRslts.Batch.ProcedureName,
|
|
|
|
|
|
Program.LocalSettings.BatchNr);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-05-03 20:19:26 +00:00
|
|
|
|
StateMachine.ControlBoard.ManualUIAllowed = true;
|
2019-05-02 12:19:01 +00:00
|
|
|
|
Event evacRetv = DoEvacuation(purgeEnd);
|
2017-05-03 20:17:20 +00:00
|
|
|
|
|
2020-05-05 13:42:15 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Process statistics (in each regular cycle after evacuation when ProcessData.StatisticsMonitoringComp is defined)
|
|
|
|
|
|
///
|
|
|
|
|
|
if (ProcessData.StatisticsMonitoringComp is IStatisticsMonitoring)
|
|
|
|
|
|
{
|
|
|
|
|
|
State.Create("MainSeq : Processing statistics")
|
|
|
|
|
|
.AddOperation((ProcessData.StatisticsMonitoringComp as IStatisticsMonitoring).ProcessStatisticsOp(ProcessData.BatchRslts.Batch.BatchNr))
|
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
|
.EnterState();
|
|
|
|
|
|
do {
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
if (e.Contains(Event.UiCmdStop)) goto stop;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (e.Contains(Event.Busy));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Procedure completed, branch depending on the result of evacuation
|
|
|
|
|
|
///
|
|
|
|
|
|
Bridge.OnProcedureCompleted(this, new ProcedureCompletedEventArgs(StateMachine.Procedure));
|
2019-05-02 12:19:01 +00:00
|
|
|
|
switch (evacRetv)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2019-05-02 12:19:01 +00:00
|
|
|
|
case Event.Error: goto error;
|
|
|
|
|
|
case Event.UiCmdStop: goto stop;
|
|
|
|
|
|
default: goto select_procedure;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-06-30 10:04:55 +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)
|
2019-02-12 08:00:02 +00:00
|
|
|
|
.AddOperation(StateMachine.BenchErrorOp)
|
2020-12-03 12:25:15 +00:00
|
|
|
|
.AddOperation(new Operations.MessageBoxOp("Test configuration 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)
|
2019-02-12 08:00:02 +00:00
|
|
|
|
.AddOperation(StateMachine.BenchErrorOp)
|
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")
|
2019-03-04 12:14:13 +00:00
|
|
|
|
.AddOperation(checkUiOp)
|
2019-02-12 08:00:02 +00:00
|
|
|
|
.AddOperation(StateMachine.BenchErrorOp)
|
2014-08-12 16:22:32 +00:00
|
|
|
|
.EnterState();
|
2019-03-04 12:14:13 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
|
}
|
|
|
|
|
|
while (!e.Contains(Event.UiCmdShutdown));
|
|
|
|
|
|
|
|
|
|
|
|
Shutdown(true);
|
|
|
|
|
|
return;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MakeSelection() call context
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
enum MKSelContext
|
|
|
|
|
|
{
|
|
|
|
|
|
ProcedureNotSelected,
|
|
|
|
|
|
InsideProcedure,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-04-10 13:23:37 +00:00
|
|
|
|
/// Return values of MakeSelection()
|
2014-08-12 16:22:32 +00:00
|
|
|
|
/// </summary>
|
2019-04-30 09:43:37 +00:00
|
|
|
|
public enum Selection
|
|
|
|
|
|
{
|
|
|
|
|
|
PurgeBegin,
|
|
|
|
|
|
PurgeEnd,
|
|
|
|
|
|
Break,
|
|
|
|
|
|
Cycle,
|
|
|
|
|
|
RestOfCycle,
|
|
|
|
|
|
Test,
|
|
|
|
|
|
Q1,
|
|
|
|
|
|
Q2,
|
|
|
|
|
|
Q3,
|
|
|
|
|
|
SaveResults,
|
|
|
|
|
|
RestoreBatch,
|
|
|
|
|
|
RestoreAndFixBatch,
|
2018-02-06 14:26:50 +00:00
|
|
|
|
Shutdown,
|
2020-02-04 07:11:11 +00:00
|
|
|
|
RestoreInterruptedSession,
|
2019-04-30 09:43:37 +00:00
|
|
|
|
}
|
2016-04-07 11:52:57 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|