- MessageBoxOp, MesssageBoxForm

- Configuration error handling in MainSeq
- Paths selection inside MainSeq
This commit is contained in:
Milan Hanajik 2014-08-12 22:21:26 +02:00
parent f4e7c7e88d
commit c56848958e
11 changed files with 138 additions and 134 deletions

View File

@ -24,77 +24,78 @@
/// <summary>
/// StateMachine events (issued by operations, IOperation derived classes)
/// </summary>
public enum Event
{
None = 0,
Done,
ModelessFormClosed,
ValvesSet,
AmbientDone,
BalanceDone,
BalanceOverload,
PressureDone,
PressureInDone,
PressureOutDone,
TempDone,
TempInDone,
TempOutDone,
TempDivDone,
FlowMeasurementDone,
FlowReached,
PositionReached,
RegulValveTimeOut, /// Maximum allowed flow setting time has elapsed
ReadRegisterDone,
ReadReferenceDone,
public enum Event
{
None = 0,
Done,
ModelessFormClosed,
ValvesSet,
AmbientDone,
BalanceDone,
BalanceOverload,
PressureDone,
PressureInDone,
PressureOutDone,
TempDone,
TempInDone,
TempOutDone,
TempDivDone,
FlowMeasurementDone,
FlowReached,
PositionReached,
RegulValveTimeOut, /// Maximum allowed flow setting time has elapsed
ReadRegisterDone,
ReadReferenceDone,
AllPositionsReached, /// Used in SetAllRegulValvesOp
TurnPumpOnOffDone,
/// CheckUi events
UiCmdStartTest,
UiCmdStartQ1,
UiCmdStartQ2,
UiCmdStartQ3,
UiCmdStartCycle,
UiCmdStop,
UiCmdPurgeBegin,
UiCmdPurgeEnd,
UiCmdEmptyTank1,
UiCmdEmptyTank2,
/// CheckUi events
UiCmdStartTest,
UiCmdStartQ1,
UiCmdStartQ2,
UiCmdStartQ3,
UiCmdStartCycle,
UiCmdStop,
UiCmdPurgeBegin,
UiCmdPurgeEnd,
UiCmdEmptyTank1,
UiCmdEmptyTank2,
UiCmdEmptyTank3,
UiCmdTestOpticalHeads,
UiCmdResetResults,
UiCmdAcceptResults,
UiCmdCalibration,
UiCmdCameraTest,
UiCmdSensitivityTest,
UiCmdB1,
UiCmdB2,
UiCmdB3,
UiCmdResetResults,
UiCmdAcceptResults,
UiCmdCalibration,
UiCmdCameraTest,
UiCmdSensitivityTest,
UiCmdB1,
UiCmdB2,
UiCmdB3,
/// Process/Test oriented
PreviousStopped,
Wait,
ProcedureLoaded,
MeasurementStarted,
ReadAllRegistersDone,
MeasurementCompleted,
ResultsPrinted,
ResultsWritten,
/// Process/Test oriented
PreviousStopped,
Wait,
ProcedureLoaded,
MeasurementStarted,
ReadAllRegistersDone,
MeasurementCompleted,
ResultsPrinted,
ResultsWritten,
/// Timer events
TimerExpired,
/// Timer events
TimerExpired,
/// IDC camera events
CameraBusy,
CameraOpCompleted,
CameraOpFailed,
/// IDC camera events
CameraBusy,
CameraOpCompleted,
CameraOpFailed,
/// Generic
Error, /// Many ops.: Fatal error occurred
OpArgumentError,
OpArgumentError,
ConfigurationError,
Yes,
No,
Next, /// To move to the next state when debugging
}
No,
Next, /// To move to the next state when debugging
OK,
}
}

View File

@ -18,7 +18,7 @@ namespace TBF.BenchControl.Operations
private void AskYesNoForm_Load(object sender, EventArgs e)
{
Text = Strings.Question;
questionLabel.Text = Strings.Fill_with_water;
questionLabel.Text = Question;
yesButton.Text = Strings.YesBtn;
noButton.Text = Strings.NoBtn;
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using TBF.BenchControl;
using TBF.Resources;
namespace TBF.BenchControl.Operations
{
@ -12,6 +13,7 @@ namespace TBF.BenchControl.Operations
/// <returns>Reference to the operation</returns>
public AskYesNoOp()
: this(Strings.Question)
{
}

View File

@ -28,44 +28,31 @@
/// </summary>
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.okButton = new System.Windows.Forms.Button();
this.messageLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// yesButton
// okButton
//
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);
this.okButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.okButton.ForeColor = System.Drawing.Color.Black;
this.okButton.Location = new System.Drawing.Point(177, 99);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(98, 63);
this.okButton.TabIndex = 1;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// noButton
// messageLabel
//
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?";
this.messageLabel.AutoSize = true;
this.messageLabel.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.messageLabel.Location = new System.Drawing.Point(34, 39);
this.messageLabel.Name = "messageLabel";
this.messageLabel.Size = new System.Drawing.Size(91, 23);
this.messageLabel.TabIndex = 4;
this.messageLabel.Text = "Message";
//
// MessageBoxForm
//
@ -73,13 +60,12 @@
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.Controls.Add(this.messageLabel);
this.Controls.Add(this.okButton);
this.Name = "MessageBoxForm";
this.Text = "Question";
this.Text = "Message";
this.TopMost = true;
this.Load += new System.EventHandler(this.AskYesNoForm_Load);
this.Load += new System.EventHandler(this.MessageBoxForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
@ -87,8 +73,7 @@
#endregion
private System.Windows.Forms.Button yesButton;
private System.Windows.Forms.Button noButton;
private System.Windows.Forms.Label questionLabel;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Label messageLabel;
}
}

View File

@ -6,32 +6,24 @@ namespace TBF.BenchControl.Operations
{
public partial class MessageBoxForm : Form
{
public string Question;
public bool CompletedYes;
public bool CompletedNo;
public string Message;
public bool CompletedOK;
public MessageBoxForm()
{
InitializeComponent();
}
private void AskYesNoForm_Load(object sender, EventArgs e)
private void MessageBoxForm_Load(object sender, EventArgs e)
{
Text = Strings.Question;
questionLabel.Text = Strings.Fill_with_water;
yesButton.Text = Strings.YesBtn;
noButton.Text = Strings.NoBtn;
Text = Strings.Message;
messageLabel.Text = Message;
okButton.Text = Strings.OkBtnText;
}
private void yesButton_Click(object sender, EventArgs e)
private void okButton_Click(object sender, EventArgs e)
{
CompletedYes = true;
Close();
}
private void noButton_Click(object sender, EventArgs e)
{
CompletedNo = true;
CompletedOK = true;
Close();
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using TBF.BenchControl;
using TBF.Resources;
namespace TBF.BenchControl.Operations
{
@ -8,39 +9,39 @@ namespace TBF.BenchControl.Operations
{
MessageBoxForm modelessDlg;
string question;
string message;
/// <returns>Reference to the operation</returns>
public MessageBoxOp()
: this(Strings.Message)
{
}
public MessageBoxOp(string question)
public MessageBoxOp(string message)
{
this.question = question;
this.message = message;
}
delegate void AskYesNoFormDlgt(MessageBoxOp myRef);
delegate void MessageBoxFormDlgt(MessageBoxOp myRef);
///
void OpenFormDlg(MessageBoxOp myRef)
{
myRef.modelessDlg = new MessageBoxForm();
myRef.modelessDlg.Question = this.question;
myRef.modelessDlg.Message = this.message;
modelessDlg.Show();
}
/// <summary>Start this operation</summary>
public void Start()
{
Program.MainWnd.Invoke(new AskYesNoFormDlgt(OpenFormDlg), this);
Program.MainWnd.Invoke(new MessageBoxFormDlgt(OpenFormDlg), this);
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
if (modelessDlg.CompletedYes) return Event.Yes;
if (modelessDlg.CompletedNo) return Event.No;
if (modelessDlg.CompletedOK) return Event.OK;
return Event.None;
}

View File

@ -115,7 +115,7 @@ namespace TBF.BenchControl.Sequences
{
//--------------------------------
State.Create("MainSeq : Answer a question")
.AddOperation(new Operations.AskYesNoOp(Strings.Purge_bench_qm))
.AddOperation(new Operations.AskYesNoOp(Strings.Fill_with_water))
.AddOperation(checkUiOp)
.EnterState();
do
@ -370,8 +370,16 @@ namespace TBF.BenchControl.Sequences
config_error:
//--------------------------------
State.Create("MainSeq : Procedure configuration error")
.AddOperation(checkUiOp)
.AddOperation(new Operations.MessageBoxOp("Test configration error"))
.EnterState();
while (true) StateMachine.WaitRunDevsRunOps();
do
{
e = StateMachine.WaitRunDevsRunOps();
}
while (!e.Contains(Event.OK));
goto select_cycle_or_test;
error:
//--------------------------------

View File

@ -113,12 +113,12 @@ namespace TBF.BenchControl.Sequences
/// Created when test sequence is open.
/// They persist during all repetitions of the same test
///------------------------------------------------------------
protected BenchControl.FeedingPath inPath;
protected BenchControl.BenchPath benchPath;
protected BenchControl.OutputPath outPath;
protected BenchControl.MetersPath sensPath;
protected Entities.TransitionSequence transitionStart;
protected Entities.TransitionSequence transitionStop;
protected static BenchControl.FeedingPath inPath;
protected static BenchControl.BenchPath benchPath;
protected static BenchControl.OutputPath outPath;
protected static BenchControl.MetersPath sensPath;
protected static Entities.TransitionSequence transitionStart;
protected static Entities.TransitionSequence transitionStop;
#region Temperature_Pressure_Humidity

View File

@ -843,6 +843,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Message.
/// </summary>
internal static string Message {
get {
return ResourceManager.GetString("Message", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Test method.
/// </summary>

View File

@ -756,4 +756,7 @@
<data name="Purge_bench_qm" xml:space="preserve">
<value>Prüfstand befüllen?</value>
</data>
<data name="Message" xml:space="preserve">
<value>Meldung</value>
</data>
</root>

View File

@ -817,4 +817,7 @@
<data name="Purge_bench_qm" xml:space="preserve">
<value>Fill the test bench with water?</value>
</data>
<data name="Message" xml:space="preserve">
<value>Message</value>
</data>
</root>