diff --git a/TestBenchFramework/BenchControl/Operations/AskYesNoForm.Designer.cs b/TestBenchFramework/BenchControl/Operations/AskYesNoForm.Designer.cs
index 4517e6cd7..63c4dd4b8 100644
--- a/TestBenchFramework/BenchControl/Operations/AskYesNoForm.Designer.cs
+++ b/TestBenchFramework/BenchControl/Operations/AskYesNoForm.Designer.cs
@@ -28,60 +28,60 @@
///
private void InitializeComponent()
{
- this.yesButton = new System.Windows.Forms.Button();
- this.noButton = new System.Windows.Forms.Button();
- this.questionLabel = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // yesButton
- //
- this.yesButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
- this.yesButton.ForeColor = System.Drawing.Color.Black;
- this.yesButton.Location = new System.Drawing.Point(200, 96);
- this.yesButton.Name = "yesButton";
- this.yesButton.Size = new System.Drawing.Size(98, 63);
- this.yesButton.TabIndex = 1;
- this.yesButton.Text = "Yes";
- this.yesButton.UseVisualStyleBackColor = true;
- this.yesButton.Click += new System.EventHandler(this.yesButton_Click);
- //
- // noButton
- //
- this.noButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
- this.noButton.ForeColor = System.Drawing.Color.Black;
- this.noButton.Location = new System.Drawing.Point(65, 96);
- this.noButton.Name = "noButton";
- this.noButton.Size = new System.Drawing.Size(98, 63);
- this.noButton.TabIndex = 2;
- this.noButton.Text = "No";
- this.noButton.UseVisualStyleBackColor = true;
- this.noButton.Click += new System.EventHandler(this.noButton_Click);
- //
- // questionLabel
- //
- this.questionLabel.AutoSize = true;
- this.questionLabel.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
- this.questionLabel.Location = new System.Drawing.Point(34, 38);
- this.questionLabel.Name = "questionLabel";
- this.questionLabel.Size = new System.Drawing.Size(300, 23);
- this.questionLabel.TabIndex = 4;
- this.questionLabel.Text = "Fill the test bench with water?";
- //
- // AskYesNoForm
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.BackColor = System.Drawing.Color.Goldenrod;
- this.ClientSize = new System.Drawing.Size(363, 201);
- this.Controls.Add(this.questionLabel);
- this.Controls.Add(this.noButton);
- this.Controls.Add(this.yesButton);
- this.Name = "AskYesNoForm";
- this.Text = "Question";
- this.TopMost = true;
- this.Load += new System.EventHandler(this.AskYesNoForm_Load);
- this.ResumeLayout(false);
- this.PerformLayout();
+ this.yesButton = new System.Windows.Forms.Button();
+ this.noButton = new System.Windows.Forms.Button();
+ this.questionLabel = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // yesButton
+ //
+ this.yesButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
+ this.yesButton.ForeColor = System.Drawing.Color.Black;
+ this.yesButton.Location = new System.Drawing.Point(244, 99);
+ this.yesButton.Name = "yesButton";
+ this.yesButton.Size = new System.Drawing.Size(98, 63);
+ this.yesButton.TabIndex = 1;
+ this.yesButton.Text = "Yes";
+ this.yesButton.UseVisualStyleBackColor = true;
+ this.yesButton.Click += new System.EventHandler(this.yesButton_Click);
+ //
+ // noButton
+ //
+ this.noButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
+ this.noButton.ForeColor = System.Drawing.Color.Black;
+ this.noButton.Location = new System.Drawing.Point(109, 99);
+ this.noButton.Name = "noButton";
+ this.noButton.Size = new System.Drawing.Size(98, 63);
+ this.noButton.TabIndex = 2;
+ this.noButton.Text = "No";
+ this.noButton.UseVisualStyleBackColor = true;
+ this.noButton.Click += new System.EventHandler(this.noButton_Click);
+ //
+ // questionLabel
+ //
+ this.questionLabel.AutoSize = true;
+ this.questionLabel.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
+ this.questionLabel.Location = new System.Drawing.Point(34, 39);
+ this.questionLabel.Name = "questionLabel";
+ this.questionLabel.Size = new System.Drawing.Size(105, 23);
+ this.questionLabel.TabIndex = 4;
+ this.questionLabel.Text = "Question?";
+ //
+ // AskYesNoForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.BackColor = System.Drawing.Color.Goldenrod;
+ this.ClientSize = new System.Drawing.Size(454, 201);
+ this.Controls.Add(this.questionLabel);
+ this.Controls.Add(this.noButton);
+ this.Controls.Add(this.yesButton);
+ this.Name = "AskYesNoForm";
+ this.Text = "Question";
+ this.TopMost = true;
+ this.Load += new System.EventHandler(this.AskYesNoForm_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
}
diff --git a/TestBenchFramework/BenchControl/Operations/MessageBoxForm.Designer.cs b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.Designer.cs
new file mode 100644
index 000000000..96f0f4988
--- /dev/null
+++ b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.Designer.cs
@@ -0,0 +1,94 @@
+namespace TBF.BenchControl.Operations
+{
+ partial class MessageBoxForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.yesButton = new System.Windows.Forms.Button();
+ this.noButton = new System.Windows.Forms.Button();
+ this.questionLabel = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // yesButton
+ //
+ this.yesButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
+ this.yesButton.ForeColor = System.Drawing.Color.Black;
+ this.yesButton.Location = new System.Drawing.Point(244, 99);
+ this.yesButton.Name = "yesButton";
+ this.yesButton.Size = new System.Drawing.Size(98, 63);
+ this.yesButton.TabIndex = 1;
+ this.yesButton.Text = "Yes";
+ this.yesButton.UseVisualStyleBackColor = true;
+ this.yesButton.Click += new System.EventHandler(this.yesButton_Click);
+ //
+ // noButton
+ //
+ this.noButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
+ this.noButton.ForeColor = System.Drawing.Color.Black;
+ this.noButton.Location = new System.Drawing.Point(109, 99);
+ this.noButton.Name = "noButton";
+ this.noButton.Size = new System.Drawing.Size(98, 63);
+ this.noButton.TabIndex = 2;
+ this.noButton.Text = "No";
+ this.noButton.UseVisualStyleBackColor = true;
+ this.noButton.Click += new System.EventHandler(this.noButton_Click);
+ //
+ // questionLabel
+ //
+ this.questionLabel.AutoSize = true;
+ this.questionLabel.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
+ this.questionLabel.Location = new System.Drawing.Point(34, 39);
+ this.questionLabel.Name = "questionLabel";
+ this.questionLabel.Size = new System.Drawing.Size(105, 23);
+ this.questionLabel.TabIndex = 4;
+ this.questionLabel.Text = "Question?";
+ //
+ // MessageBoxForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.BackColor = System.Drawing.Color.Goldenrod;
+ this.ClientSize = new System.Drawing.Size(454, 201);
+ this.Controls.Add(this.questionLabel);
+ this.Controls.Add(this.noButton);
+ this.Controls.Add(this.yesButton);
+ this.Name = "MessageBoxForm";
+ this.Text = "Question";
+ this.TopMost = true;
+ this.Load += new System.EventHandler(this.AskYesNoForm_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button yesButton;
+ private System.Windows.Forms.Button noButton;
+ private System.Windows.Forms.Label questionLabel;
+ }
+}
\ No newline at end of file
diff --git a/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs
new file mode 100644
index 000000000..fdebfe4f0
--- /dev/null
+++ b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Windows.Forms;
+using TBF.Resources;
+
+namespace TBF.BenchControl.Operations
+{
+ public partial class MessageBoxForm : Form
+ {
+ public string Question;
+ public bool CompletedYes;
+ public bool CompletedNo;
+
+ public MessageBoxForm()
+ {
+ InitializeComponent();
+ }
+
+ private void AskYesNoForm_Load(object sender, EventArgs e)
+ {
+ Text = Strings.Question;
+ questionLabel.Text = Strings.Fill_with_water;
+ yesButton.Text = Strings.YesBtn;
+ noButton.Text = Strings.NoBtn;
+ }
+
+ private void yesButton_Click(object sender, EventArgs e)
+ {
+ CompletedYes = true;
+ Close();
+ }
+
+ private void noButton_Click(object sender, EventArgs e)
+ {
+ CompletedNo = true;
+ Close();
+ }
+ }
+}
diff --git a/TestBenchFramework/BenchControl/Operations/MessageBoxForm.resx b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.resx
new file mode 100644
index 000000000..1af7de150
--- /dev/null
+++ b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TestBenchFramework/BenchControl/Operations/MessageBoxOp.cs b/TestBenchFramework/BenchControl/Operations/MessageBoxOp.cs
new file mode 100644
index 000000000..67a74588b
--- /dev/null
+++ b/TestBenchFramework/BenchControl/Operations/MessageBoxOp.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using TBF.BenchControl;
+
+namespace TBF.BenchControl.Operations
+{
+ public class MessageBoxOp : IOperation
+ {
+ MessageBoxForm modelessDlg;
+
+ string question;
+
+ /// Reference to the operation
+ public MessageBoxOp()
+ {
+ }
+
+ public MessageBoxOp(string question)
+ {
+ this.question = question;
+ }
+
+ delegate void AskYesNoFormDlgt(MessageBoxOp myRef);
+ ///
+ void OpenFormDlg(MessageBoxOp myRef)
+ {
+ myRef.modelessDlg = new MessageBoxForm();
+ myRef.modelessDlg.Question = this.question;
+ modelessDlg.Show();
+ }
+
+ /// Start this operation
+ public void Start()
+ {
+ Program.MainWnd.Invoke(new AskYesNoFormDlgt(OpenFormDlg), this);
+ }
+
+ /// Run this operation
+ /// Event.ResultsPrinted
+ public Event Run()
+ {
+ if (modelessDlg.CompletedYes) return Event.Yes;
+ if (modelessDlg.CompletedNo) return Event.No;
+ return Event.None;
+ }
+
+ /// Stop this operation
+ public void Stop()
+ {
+ modelessDlg = null;
+ }
+ }
+}
diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs
index 52f6124a7..8a29a4802 100644
--- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs
+++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs
@@ -17,38 +17,22 @@ namespace TBF.BenchControl.Sequences
public override string ToString() { return "Sequences.MainSeq"; }
- ///
- /// Specifies the selection done in the main sequence
- ///
- public enum Selection
+
+ /// Constructor
+ public MainSeq()
{
- None,
- Cycle,
- Test,
- Q1,
- Q2,
- Q3,
- Stop,
- PurgeBegin,
- PurgeEnd,
- EmptyTank1,
- EmptyTank2,
- EmptyTank3,
- CloseTank1,
- CloseTank2,
- CloseTank3,
}
- public MainSeq()
- {
- }
+ ///
+ /// Main sequence
+ ///
+ ///
+ ///
public IList Execute(Entities.Test dummyArg)
{
- Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
-
/// Operations running in more then one state
- IOperation checkUiOp = new CheckUIOp(true);
+ checkUiOp = new CheckUIOp(true);
IList e;
Selection selection;
@@ -63,7 +47,8 @@ namespace TBF.BenchControl.Sequences
//------------------------------------------------
State.Create("MainSeq : Setting valves to the default state")
.AddOperation(new MettlerToledo.ReadMassesOp())
- .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
+ .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen,
+ StateMachine.DefaultValvesClose))
.EnterState();
do
{
@@ -97,158 +82,15 @@ namespace TBF.BenchControl.Sequences
if (e.Contains(Event.CameraOpFailed)) goto error; /// TODO: resolve in some other way
- idle:
-
- bool emptying1 = false;
- bool emptying2 = false;
- bool emptying3 = false;
- do
- {
- /// Used for emptying
- FloatBox mass1 = new FloatBox();
- FloatBox mass2 = new FloatBox();
- FloatBox mass3 = new FloatBox();
-
- //---------------------------------------------------------
- if (emptying1 || emptying2 || emptying3)
- Bridge.OnActivity(this, Strings.Emptying_tank);
- else
- Bridge.OnActivity(this, Strings.Please_select_a_procedure);
- //---------------------------------------------------------
-
- /// Start something buttons are hidden when emptyign is in progress
- Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
- ((emptying1 || emptying2 || emptying3) ? 0 :
- (ButtonsEtc.StartCycleBtnEn | ButtonsEtc.StartTestBtnsEn |
- ButtonsEtc.PurgeBeginBtnEn | ButtonsEtc.SensitivityTestBtnEn |
- ((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0) |
- ButtonsEtc.TryOpticalHeadsBtnEn)) |
- (((StateMachine.Balance1 != null) && !emptying1) ? ButtonsEtc.EmptyTankBtn1En : 0) |
- (((StateMachine.Balance2 != null) && !emptying2) ? ButtonsEtc.EmptyTankBtn2En : 0) |
- (((StateMachine.Balance3 != null) && !emptying3) ? ButtonsEtc.EmptyTankBtn3En : 0));
-
- selection = Selection.None;
- State.Create("MainSeq : Select a procedure")
- .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(cBrd.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.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
- else if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
- else if (e.Contains(Event.UiCmdEmptyTank3)) selection = Selection.EmptyTank3;
- else if (emptying1 && (mass1.Val < (StateMachine.Balance1.Capacity / 100.0f + 20.0f))) selection = Selection.CloseTank1;
- else if (emptying2 && (mass2.Val < (StateMachine.Balance2.Capacity / 100.0f + 20.0f))) selection = Selection.CloseTank2;
- else if (emptying3 && (mass3.Val < (StateMachine.Balance3.Capacity / 100.0f + 20.0f))) selection = Selection.CloseTank3;
- else if (e.Contains(Event.UiCmdPurgeBegin)) selection = Selection.PurgeBegin;
- else if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test;
- else if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1;
- else if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
- else if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
- else if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
- else if (e.Contains(Event.UiCmdCameraTest)) goto camera_test;
- }
- while (selection == Selection.None);
-
- if (selection == Selection.Stop)
- {
- if (emptying1 || emptying2 || emptying3)
- {
- IList valvesClose = new List();
- 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 == false))
- {
- emptying1 = true;
- Bridge.OnActivity(this, Strings.Emptying_tank);
- Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
- (emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En));
- 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 == false))
- {
- emptying2 = true;
- Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
- (emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En));
- Bridge.OnActivity(this, Strings.Emptying_tank);
- 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 == false))
- {
- emptying3 = true;
- Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
- (emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En));
- Bridge.OnActivity(this, Strings.Emptying_tank);
- 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;
- }
- }
- while ((selection != Selection.Cycle) && (selection != Selection.Test)
- && (selection != Selection.Q1) && (selection != Selection.Q2) && (selection != Selection.Q3)
- || emptying1 || emptying2 || emptying3);
+ select_procedure:
+ //----------------------------------------------------------
+ selection = MakeSelection(MKSelContext.ProcedureNotSelected);
//--------------------------------
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
StateMachine.LoadProcedure(false);
- if (StateMachine.Procedure == null)
- {
- goto idle;
- }
+ if (StateMachine.Procedure == null) goto select_procedure;
+
StateMachine.LoadProcedureParams(StateMachine.Procedure);
ResetResults();
Bridge.OnProcedureSelected(this, new ProcedureSelectedEventArgs(StateMachine.Procedure));
@@ -273,14 +115,14 @@ namespace TBF.BenchControl.Sequences
{
//--------------------------------
State.Create("MainSeq : Answer a question")
- .AddOperation(new Operations.AskYesNoOp())
+ .AddOperation(new Operations.AskYesNoOp(Strings.Purge_bench_qm))
.AddOperation(checkUiOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.No)) goto assume_bench_filled;
- if (e.Contains(Event.UiCmdStop)) goto idle;
+ if (e.Contains(Event.UiCmdStop)) goto select_procedure;
}
while (!e.Contains(Event.Yes));
}
@@ -315,177 +157,48 @@ namespace TBF.BenchControl.Sequences
if (selection != Selection.PurgeBegin)
{
- goto cycle_or_test;
+ goto cycle_or_test_selected;
}
- ready:
+ select_cycle_or_test:
+ //----------------------------------------------------------
+ selection = MakeSelection(MKSelContext.InsideProcedure);
+ ///
+ if (selection == Selection.PurgeBegin) goto fill_the_bench;
+ if (selection == Selection.PurgeEnd) goto purge_end;
+ if (selection == Selection.SaveResults) goto save_results;
- emptying1 = false;
- emptying2 = false;
- emptying3 = false;
- do
- {
- /// Used for emptying
- FloatBox mass1 = new FloatBox();
- FloatBox mass2 = new FloatBox();
- FloatBox mass3 = new FloatBox();
-
- //------------------------------------------------
- if (emptying1 || emptying2 || emptying3)
- Bridge.OnActivity(this, Strings.Emptying_tank);
- else
- Bridge.OnActivity(this, Strings.Please_select_a_cycle_a_test_or_empty);
- //------------------------------------------------
-
- Bridge.Bench2UI(ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
- ((emptying1 || emptying2 || emptying3) ? 0 :
- (ButtonsEtc.StartCycleBtnEn | ButtonsEtc.StartTestBtnsEn |
- ButtonsEtc.PurgeBeginBtnEn | ButtonsEtc.SensitivityTestBtnEn |
- ((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0) |
- ButtonsEtc.TryOpticalHeadsBtnEn)) |
- (((StateMachine.Balance1 != null) && !emptying1) ? ButtonsEtc.EmptyTankBtn1En : 0) |
- (((StateMachine.Balance2 != null) && !emptying2) ? ButtonsEtc.EmptyTankBtn2En : 0) |
- (((StateMachine.Balance3 != null) && !emptying3) ? ButtonsEtc.EmptyTankBtn3En : 0));
-
- selection = Selection.None;
- State.Create("MainSeq : Select an activity for the selected procedure")
- .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(cBrd.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.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
- else if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
- else if (e.Contains(Event.UiCmdEmptyTank3)) selection = Selection.EmptyTank3;
- else if (emptying1 && (mass1.Val < (StateMachine.Balance1.Capacity / 100.0f + 20.0f))) selection = Selection.CloseTank1;
- else if (emptying2 && (mass2.Val < (StateMachine.Balance2.Capacity / 100.0f + 20.0f))) selection = Selection.CloseTank2;
- else if (emptying3 && (mass3.Val < (StateMachine.Balance3.Capacity / 100.0f + 20.0f))) selection = Selection.CloseTank3;
- else if (e.Contains(Event.UiCmdPurgeBegin))
- {
- selection = Selection.PurgeBegin; /// Value used to branch the code later on
- goto fill_the_bench;
- }
- else if (e.Contains(Event.UiCmdPurgeEnd)) goto purge_end;
- else if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test;
- else if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1;
- else if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
- else if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
- else if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
- else if (e.Contains(Event.UiCmdAcceptResults)) goto save_results;
- }
- while (selection == Selection.None);
-
- if (selection == Selection.Stop)
- {
- if (emptying1 || emptying2 || emptying3)
- {
- IList valvesClose = new List();
- 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 == false))
- {
- emptying1 = true;
- Bridge.OnActivity(this, Strings.Emptying_tank);
- Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
- (emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En));
- State.Create("MainSeq : Open emptying valve 1")
- .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve1, null))
- .EnterState();
- do { e = StateMachine.WaitRunDevsRunOps(); }
- while (!e.Contains(Event.ValvesSet));
- }
- else if ((selection == Selection.EmptyTank2) && (emptying2 == false))
- {
- emptying2 = true;
- Bridge.OnActivity(this, Strings.Emptying_tank);
- Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
- (emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En));
- State.Create("MainSeq : Open emptying valve 2")
- .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve2, null))
- .EnterState();
- do { e = StateMachine.WaitRunDevsRunOps(); }
- while (!e.Contains(Event.ValvesSet));
- }
- else if ((selection == Selection.EmptyTank3) && (emptying3 == false))
- {
- emptying3 = true;
- Bridge.OnActivity(this, Strings.Emptying_tank);
- Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
- (emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En));
- State.Create("MainSeq : Open emptying valve 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;
- }
- }
- while ((selection != Selection.Cycle) && (selection != Selection.Test)
- && (selection != Selection.Q1) && (selection != Selection.Q2) && (selection != Selection.Q3)
- || emptying1 || emptying2 || emptying3);
-
- cycle_or_test:
+ cycle_or_test_selected:
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Hide buttons
if (selection == Selection.Cycle)
{
TimeEstimateTotal = 0;
- foreach (var test in StateMachine.Tests) TimeEstimateTotal += (test.Repeats * (test.TstTime + 10.0f));
+ foreach (var test in StateMachine.Tests)
+ {
+ TimeEstimateTotal += (test.Repeats * (test.TstTime + 10.0f));
+
+ /// Try to fetch all test paths and transitions
+ /// to detect configuration errors as early as possible.
+ if (!StateMachine.GetPaths(test, out inPath, out benchPath,
+ out outPath, out sensPath,
+ out transitionStart, out transitionStop))
+ {
+ goto config_error;
+ }
+ }
TimeEstimateBeginRpts = 0;
foreach (var test in StateMachine.Tests)
{
- transitionStart = null;
- transitionStop = null;
- foreach (var transition in StateMachine.TransitionSequences)
- {
- if (transition.Name == test.TransitionStart) transitionStart = transition;
- if (transition.Name == test.TransitionEnd) transitionStop = transition;
- }
+ /// Fetch the test paths and transitions
+ if (!StateMachine.GetPaths(test, out inPath, out benchPath,
+ out outPath, out sensPath,
+ out transitionStart, out transitionStop))
+ {
+ goto config_error;
+ }
TimeEstimateOneTest = test.TstTime + 10.0f;
//--------------------------------------------------------------
@@ -506,18 +219,19 @@ namespace TBF.BenchControl.Sequences
{
Entities.Test test = StateMachine.GetTest(selection);
+ /// Fetch the test paths and transitions
+ if (!StateMachine.GetPaths(test, out inPath, out benchPath,
+ out outPath, out sensPath,
+ out transitionStart, out transitionStop))
+ {
+ goto config_error;
+ }
+
+
TimeEstimateTotal = test.Repeats * (test.TstTime + 10.0f);
TimeEstimateOneTest = test.TstTime + 10.0f;
TimeEstimateBeginRpts = 0;
- transitionStart = null;
- transitionStop = null;
- foreach (var transition in StateMachine.TransitionSequences)
- {
- if (transition.Name == test.TransitionStart) transitionStart = transition;
- if (transition.Name == test.TransitionEnd) transitionStop = transition;
- }
-
ISequence testMethodSequence = TbfComponents.FindComponent(test.Method) as ISequence;
if (testMethodSequence != null)
{
@@ -538,7 +252,7 @@ namespace TBF.BenchControl.Sequences
Bridge.Bench2UI(ButtonsEtc.ResetResultsBtnEn);
}
- goto ready;
+ goto select_cycle_or_test;
purge_end:
save_results:
@@ -635,96 +349,14 @@ namespace TBF.BenchControl.Sequences
benchFilled = false;
Bridge.Bench2UI(ButtonsEtc.ShowBenchEmpty);
- goto idle;
-
- camera_test:
-
- Bridge.OnActivity(this, "Camera test");
- //---------------------------------------------------------
- Bridge.Bench2UI(ButtonsEtc.StartTestBtnsEn | ButtonsEtc.StopBtnEn);
- selection = Selection.None;
- 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))
- {
- goto idle;
- }
- 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);
- selection = Selection.None;
- State.Create("MainSeq : Press 'Stop' to continue")
- .AddOperation(checkUiOp)
- .AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[0].GrabOp() : null)
- .AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[1].GrabOp() : null)
- .AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[2].GrabOp() : null)
- .AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[3].GrabOp() : null)
- .AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[4].GrabOp() : null)
- .AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[5].GrabOp() : null)
- .EnterState();
- do
- {
- e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto camera_test;
- }
- while (true);
-
- live:
- Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
- selection = Selection.None;
- State.Create("MainSeq : Press 'Stop' to stop.")
- .AddOperation(checkUiOp)
- .AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[0].LiveOp() : null)
- .AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[1].LiveOp() : null)
- .AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[2].LiveOp() : null)
- .AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[3].LiveOp() : null)
- .AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[4].LiveOp() : null)
- .AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[5].LiveOp() : null)
- .EnterState();
- do
- {
- e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto camera_test;
- }
- while (true);
-
- focus:
- Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
- selection = Selection.None;
- State.Create("MainSeq : Press 'Stop' to stop.")
- .AddOperation(checkUiOp)
- .AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[0].FocusOp() : null)
- .AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[1].FocusOp() : null)
- .AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[2].FocusOp() : null)
- .AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[3].FocusOp() : null)
- .AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[4].FocusOp() : null)
- .AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[5].FocusOp() : null)
- .EnterState();
- do
- {
- e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto camera_test;
- }
- while (true);
+ goto select_procedure;
stop:
//--------------------------------
State.Create("MainSeq : Turning IDLE -> Closing the valves")
.AddOperation(checkUiOp)
- .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
+ .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen,
+ StateMachine.DefaultValvesClose))
.EnterState();
do
{
@@ -733,7 +365,7 @@ namespace TBF.BenchControl.Sequences
}
while (!e.Contains(Event.ValvesSet));
- goto idle;
+ goto select_procedure;
config_error:
//--------------------------------
@@ -745,7 +377,8 @@ namespace TBF.BenchControl.Sequences
//--------------------------------
State.Create("MainSeq : ERROR -> Closing the valves")
.AddOperation(checkUiOp)
- .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
+ .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen,
+ StateMachine.DefaultValvesClose))
.EnterState();
do
{
@@ -755,8 +388,328 @@ namespace TBF.BenchControl.Sequences
//--------------------------------
State.Create("MainSeq : ERROR state")
- .EnterState();
+ .EnterState();
while (true) StateMachine.WaitRunDevsRunOps();
}
- }
+
+
+ ///
+ /// MakeSelection() call context
+ ///
+ enum MKSelContext
+ {
+ ProcedureNotSelected,
+ InsideProcedure,
+ }
+
+ ///
+ /// Selection done in MakeSelection()
+ ///
+ 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,
+ SaveResults,
+ }
+
+ ///
+ /// Idle loop to make a procedure or test selection.
+ /// Handles tank emptying, camera test.
+ ///
+ /// Context where MakeSelection() is called
+ ///
+ /// Selection.Cycle
+ /// Selection.Test
+ /// Selection.Q1
+ /// Selection.Q2
+ /// Selection.Q3
+ /// Selection.Stop
+ /// Selection.PurgeBegin
+ /// Selection.PurgeEnd
+ ///
+ 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 e;
+ Selection selection;
+
+ while (true)
+ {
+ /// Display an appropriate activity message
+ if (emptying1 || emptying2 || emptying3)
+ {
+ 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);
+ }
+
+ /// 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) |
+ ButtonsEtc.TryOpticalHeadsBtnEn)) |
+ (((StateMachine.Balance1 != null) && !emptying1) ? ButtonsEtc.EmptyTankBtn1En : 0) |
+ (((StateMachine.Balance2 != null) && !emptying2) ? ButtonsEtc.EmptyTankBtn2En : 0) |
+ (((StateMachine.Balance3 != null) && !emptying3) ? ButtonsEtc.EmptyTankBtn3En : 0));
+
+ 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;
+ else if (emptying1 && (mass1.Val < (StateMachine.Balance1.Capacity / 100.0f + 20.0f))) selection = Selection.CloseTank1;
+ else if (emptying2 && (mass2.Val < (StateMachine.Balance2.Capacity / 100.0f + 20.0f))) selection = Selection.CloseTank2;
+ else if (emptying3 && (mass3.Val < (StateMachine.Balance3.Capacity / 100.0f + 20.0f))) selection = Selection.CloseTank3;
+ 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;
+ 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();
+ }
+ else if (selection == Selection.Stop)
+ {
+ if (emptying1 || emptying2 || emptying3)
+ {
+ IList valvesClose = new List();
+ 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;
+ }
+ }
+
+ error:
+ Bridge.OnActivity(this, Strings.Error);
+ State.Create("MainSeq : ERROR state")
+ .EnterState();
+ while (true) StateMachine.WaitRunDevsRunOps();
+ }
+
+
+ ///
+ /// Perform a camera test
+ ///
+ void CameraTest()
+ {
+ IList 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)
+ .AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[0].GrabOp() : null)
+ .AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[1].GrabOp() : null)
+ .AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[2].GrabOp() : null)
+ .AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[3].GrabOp() : null)
+ .AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[4].GrabOp() : null)
+ .AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[5].GrabOp() : null)
+ .EnterState();
+ do
+ {
+ e = StateMachine.WaitRunDevsRunOps();
+ if (e.Contains(Event.Error)) goto error;
+ if (e.Contains(Event.UiCmdStop)) goto camera_test;
+ }
+ while (true);
+
+ live:
+ Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
+ State.Create("MainSeq : Press 'Stop' to stop.")
+ .AddOperation(checkUiOp)
+ .AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[0].LiveOp() : null)
+ .AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[1].LiveOp() : null)
+ .AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[2].LiveOp() : null)
+ .AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[3].LiveOp() : null)
+ .AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[4].LiveOp() : null)
+ .AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[5].LiveOp() : null)
+ .EnterState();
+ do
+ {
+ e = StateMachine.WaitRunDevsRunOps();
+ if (e.Contains(Event.Error)) goto error;
+ if (e.Contains(Event.UiCmdStop)) goto camera_test;
+ }
+ while (true);
+
+ focus:
+ Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
+ State.Create("MainSeq : Press 'Stop' to stop.")
+ .AddOperation(checkUiOp)
+ .AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[0].FocusOp() : null)
+ .AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[1].FocusOp() : null)
+ .AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[2].FocusOp() : null)
+ .AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[3].FocusOp() : null)
+ .AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[4].FocusOp() : null)
+ .AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != Entities.DebugMode.DetectedOff)) ? Cameras[5].FocusOp() : null)
+ .EnterState();
+ do
+ {
+ e = StateMachine.WaitRunDevsRunOps();
+ if (e.Contains(Event.Error)) goto error;
+ if (e.Contains(Event.UiCmdStop)) goto camera_test;
+ }
+ while (true);
+
+ error:
+ Bridge.OnActivity(this, Strings.Error);
+ State.Create("MainSeq : ERROR state")
+ .EnterState();
+ while (true) StateMachine.WaitRunDevsRunOps();
+ }
+ }
}
diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs
index 0a287f766..a17499d27 100644
--- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs
+++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs
@@ -117,7 +117,6 @@ namespace TBF.BenchControl.Sequences
protected BenchControl.BenchPath benchPath;
protected BenchControl.OutputPath outPath;
protected BenchControl.MetersPath sensPath;
-
protected Entities.TransitionSequence transitionStart;
protected Entities.TransitionSequence transitionStop;
diff --git a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs
index 96352c865..8a0802ce1 100644
--- a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs
@@ -18,16 +18,13 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection
{
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
- /// Operations running in more then one state
- checkUiOp = new Operations.CheckUIOp(true);
-
IList e; /// Events from currently running operations
//--------------------------------
State.Create("RoiDetection : Starting the detection sequence")
- .AddOperation(checkUiOp)
- .AddOperation(cBrd.StopPreviousOp())
- .EnterState();
+ .AddOperation(checkUiOp)
+ .AddOperation(cBrd.StopPreviousOp())
+ .EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
@@ -35,10 +32,6 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection
}
while (!e.Contains(Event.PreviousStopped));
- /// Fetch the test, the paths
- bool success = StateMachine.GetPaths(test, out inPath, out benchPath, out outPath, out sensPath,
- out transitionStart, out transitionStop);
- if (!success) goto error;
//====================================
/// Start the test, initialize test results
diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs
index db95eec2d..3d0ef70b0 100644
--- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs
@@ -23,9 +23,6 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
/// Specific for combined meters
int[] lastWMPulses = new int[Program.WMsCount];
- /// Operations running in more then one state
- checkUiOp = new Operations.CheckUIOp(true);
-
IList e; /// Events from currently running operations
//--------------------------------
@@ -40,10 +37,6 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
}
while (!e.Contains(Event.PreviousStopped));
- /// Fetch the test, the paths
- bool success = StateMachine.GetPaths(test, out inPath, out benchPath, out outPath, out sensPath,
- out transitionStart, out transitionStop);
- if (!success) goto error;
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs
index 43dada310..ba4f44269 100644
--- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs
@@ -24,9 +24,6 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
/// Specific for combined meters
int[] lastWMPulses = new int[Program.WMsCount];
- /// Operations running in more then one state
- checkUiOp = new Operations.CheckUIOp(true);
-
IList e; /// Events from currently running operations
//--------------------------------
@@ -41,10 +38,6 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
}
while (!e.Contains(Event.PreviousStopped));
- /// Fetch the test, the paths
- bool success = StateMachine.GetPaths(test, out inPath, out benchPath, out outPath, out sensPath,
- out transitionStart, out transitionStop);
- if (!success) goto error;
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs
index d84edc872..c206b2683 100644
--- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs
@@ -35,10 +35,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
}
while (!e.Contains(Event.PreviousStopped));
- /// Fetch the test, the paths
- bool success = StateMachine.GetPaths(test, out inPath, out benchPath, out outPath, out sensPath,
- out transitionStart, out transitionStop);
- if (!success) goto error;
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs
index 03079fe94..78336192d 100644
--- a/TestBenchFramework/Resources/Strings.Designer.cs
+++ b/TestBenchFramework/Resources/Strings.Designer.cs
@@ -1284,6 +1284,15 @@ namespace TBF.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Fill the test bench with water?.
+ ///
+ internal static string Purge_bench_qm {
+ get {
+ return ResourceManager.GetString("Purge_bench_qm", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Purging.
///
diff --git a/TestBenchFramework/Resources/Strings.de.resx b/TestBenchFramework/Resources/Strings.de.resx
index 5b28f10cb..ffcbec743 100644
--- a/TestBenchFramework/Resources/Strings.de.resx
+++ b/TestBenchFramework/Resources/Strings.de.resx
@@ -753,4 +753,7 @@
Supress trills
+
+ Prüfstand befüllen?
+
\ No newline at end of file
diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx
index 4c9e2d43d..52750290d 100644
--- a/TestBenchFramework/Resources/Strings.resx
+++ b/TestBenchFramework/Resources/Strings.resx
@@ -814,4 +814,7 @@
Supress WM trills
+
+ Fill the test bench with water?
+
\ No newline at end of file
diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj
index c0ecf96d8..e1d1746b9 100644
--- a/TestBenchFramework/TBF.csproj
+++ b/TestBenchFramework/TBF.csproj
@@ -318,6 +318,13 @@
AskYesNoForm.cs
+
+ Form
+
+
+ MessageBoxForm.cs
+
+
@@ -903,6 +910,9 @@
AskYesNoForm.cs
+
+ MessageBoxForm.cs
+
PrinterCfgCtrl.cs