Modeless form for S/N entry does not prevent test from starting
This commit is contained in:
@@ -29,6 +29,8 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
|
||||
System.Windows.Forms.Form modelessDlg;
|
||||
|
||||
bool resultSaved;
|
||||
|
||||
IList<GenericDevices.IWaterMeter> waterMeters;
|
||||
|
||||
public enum CurrentOp
|
||||
@@ -86,7 +88,8 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
switch (currentOp)
|
||||
resultSaved = false;
|
||||
switch (currentOp)
|
||||
{
|
||||
case CurrentOp.ShowFormAtCycleBeginning:
|
||||
Program.MainWnd.Invoke(new EntryFormDlgt(OpenBeginningDlg), this);
|
||||
@@ -101,34 +104,42 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
/// <returns>Event.ResultsPrinted</returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (!(modelessDlg as GenericDevices.IHasCompleted).Completed) return Event.None;
|
||||
if (!(modelessDlg as GenericDevices.IHasCompleted).Completed)
|
||||
{
|
||||
return Event.None; /// Return 'None' when form was not closed yet
|
||||
}
|
||||
|
||||
if (modelessDlg is CycleBeginningForm)
|
||||
if (!resultSaved) /// This is to save the result only once
|
||||
{
|
||||
if (waterMeters.Count >= 1 && waterMeters[0] != null)
|
||||
if (modelessDlg is CycleBeginningForm)
|
||||
{
|
||||
mainBeginStateText = (modelessDlg as CycleBeginningForm).MainStateText;
|
||||
waterMeters[0].SerialNr = (modelessDlg as CycleBeginningForm).MainSNText;
|
||||
if (waterMeters.Count >= 1 && waterMeters[0] != null)
|
||||
{
|
||||
mainBeginStateText = (modelessDlg as CycleBeginningForm).MainStateText;
|
||||
waterMeters[0].SerialNr = (modelessDlg as CycleBeginningForm).MainSNText;
|
||||
}
|
||||
if (waterMeters.Count >= 2 && waterMeters[1] != null)
|
||||
{
|
||||
auxBeginStateText = (modelessDlg as CycleBeginningForm).AuxStateText;
|
||||
waterMeters[1].SerialNr = (modelessDlg as CycleBeginningForm).AuxSNText;
|
||||
}
|
||||
}
|
||||
if (waterMeters.Count >= 2 && waterMeters[1] != null)
|
||||
else
|
||||
{
|
||||
auxBeginStateText = (modelessDlg as CycleBeginningForm).AuxStateText;
|
||||
waterMeters[1].SerialNr = (modelessDlg as CycleBeginningForm).AuxSNText;
|
||||
if (waterMeters.Count >= 1 && waterMeters[0] != null)
|
||||
{
|
||||
waterMeters[0].EndState = (modelessDlg as CycleEndForm).MainStateText;
|
||||
}
|
||||
if (waterMeters.Count >= 2 && waterMeters[1] != null)
|
||||
{
|
||||
waterMeters[1].EndState = (modelessDlg as CycleEndForm).AuxStateText;
|
||||
}
|
||||
protocolTitle = (modelessDlg as CycleEndForm).ProtocolTitle;
|
||||
}
|
||||
resultSaved = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (waterMeters.Count >= 1 && waterMeters[0] != null)
|
||||
{
|
||||
waterMeters[0].EndState = (modelessDlg as CycleEndForm).MainStateText;
|
||||
}
|
||||
if (waterMeters.Count >= 2 && waterMeters[1] != null)
|
||||
{
|
||||
waterMeters[1].EndState = (modelessDlg as CycleEndForm).AuxStateText;
|
||||
}
|
||||
protocolTitle = (modelessDlg as CycleEndForm).ProtocolTitle;
|
||||
}
|
||||
return Event.Done;
|
||||
|
||||
return Event.ModelessFormDone; /// Form closed
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace TBF.BenchControl.DataEntry.Munich3
|
||||
|
||||
System.Windows.Forms.Form modelessDlg;
|
||||
|
||||
bool resultSaved;
|
||||
|
||||
IList<GenericDevices.IWaterMeter> waterMeters;
|
||||
|
||||
public enum CurrentOp
|
||||
@@ -80,7 +82,8 @@ namespace TBF.BenchControl.DataEntry.Munich3
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
switch (currentOp)
|
||||
resultSaved = false;
|
||||
switch (currentOp)
|
||||
{
|
||||
case CurrentOp.ShowFormAtCycleBeginning:
|
||||
Program.MainWnd.Invoke(new EntryFormDlgt(OpenBeginningDlg), this);
|
||||
@@ -95,32 +98,40 @@ namespace TBF.BenchControl.DataEntry.Munich3
|
||||
/// <returns>Event.ResultsPrinted</returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (!(modelessDlg as GenericDevices.IHasCompleted).Completed) return Event.None;
|
||||
|
||||
if (modelessDlg is CycleBeginningForm)
|
||||
if (!(modelessDlg as GenericDevices.IHasCompleted).Completed)
|
||||
{
|
||||
CycleBeginningForm dlg = (modelessDlg as CycleBeginningForm);
|
||||
return Event.None; /// Return 'None' when form was not closed yet
|
||||
}
|
||||
|
||||
if (!resultSaved) /// This is to save the result only once
|
||||
{
|
||||
if (modelessDlg is CycleBeginningForm)
|
||||
{
|
||||
CycleBeginningForm dlg = (modelessDlg as CycleBeginningForm);
|
||||
|
||||
if (dlg.WaterMetersCount > 0 && waterMeters[0] != null) waterMeters[0].SerialNr = dlg.SNText[0];
|
||||
if (dlg.WaterMetersCount > 1 && waterMeters[1] != null) waterMeters[1].SerialNr = dlg.SNText[1];
|
||||
if (dlg.WaterMetersCount > 2 && waterMeters[2] != null) waterMeters[2].SerialNr = dlg.SNText[2];
|
||||
if (dlg.WaterMetersCount > 3 && waterMeters[3] != null) waterMeters[3].SerialNr = dlg.SNText[3];
|
||||
if (dlg.WaterMetersCount > 4 && waterMeters[4] != null) waterMeters[4].SerialNr = dlg.SNText[4];
|
||||
if (dlg.WaterMetersCount > 5 && waterMeters[5] != null) waterMeters[5].SerialNr = dlg.SNText[5];
|
||||
}
|
||||
else if (modelessDlg is CycleEndForm)
|
||||
{
|
||||
CycleEndForm dlg = (modelessDlg as CycleEndForm);
|
||||
if (dlg.WaterMetersCount > 0 && waterMeters[0] != null) waterMeters[0].SerialNr = dlg.SNText[0];
|
||||
if (dlg.WaterMetersCount > 1 && waterMeters[1] != null) waterMeters[1].SerialNr = dlg.SNText[1];
|
||||
if (dlg.WaterMetersCount > 2 && waterMeters[2] != null) waterMeters[2].SerialNr = dlg.SNText[2];
|
||||
if (dlg.WaterMetersCount > 3 && waterMeters[3] != null) waterMeters[3].SerialNr = dlg.SNText[3];
|
||||
if (dlg.WaterMetersCount > 4 && waterMeters[4] != null) waterMeters[4].SerialNr = dlg.SNText[4];
|
||||
if (dlg.WaterMetersCount > 5 && waterMeters[5] != null) waterMeters[5].SerialNr = dlg.SNText[5];
|
||||
}
|
||||
else if (modelessDlg is CycleEndForm)
|
||||
{
|
||||
CycleEndForm dlg = (modelessDlg as CycleEndForm);
|
||||
|
||||
protocolTitle = dlg.ProtocolTitle;
|
||||
if (dlg.WaterMetersCount > 0 && waterMeters[0] != null) waterMeters[0].EndState = dlg.EndStateText[0];
|
||||
if (dlg.WaterMetersCount > 1 && waterMeters[1] != null) waterMeters[1].EndState = dlg.EndStateText[1];
|
||||
if (dlg.WaterMetersCount > 2 && waterMeters[2] != null) waterMeters[2].EndState = dlg.EndStateText[2];
|
||||
if (dlg.WaterMetersCount > 3 && waterMeters[3] != null) waterMeters[3].EndState = dlg.EndStateText[3];
|
||||
if (dlg.WaterMetersCount > 4 && waterMeters[4] != null) waterMeters[4].EndState = dlg.EndStateText[4];
|
||||
if (dlg.WaterMetersCount > 5 && waterMeters[5] != null) waterMeters[5].EndState = dlg.EndStateText[5];
|
||||
}
|
||||
return Event.Done;
|
||||
protocolTitle = dlg.ProtocolTitle;
|
||||
if (dlg.WaterMetersCount > 0 && waterMeters[0] != null) waterMeters[0].EndState = dlg.EndStateText[0];
|
||||
if (dlg.WaterMetersCount > 1 && waterMeters[1] != null) waterMeters[1].EndState = dlg.EndStateText[1];
|
||||
if (dlg.WaterMetersCount > 2 && waterMeters[2] != null) waterMeters[2].EndState = dlg.EndStateText[2];
|
||||
if (dlg.WaterMetersCount > 3 && waterMeters[3] != null) waterMeters[3].EndState = dlg.EndStateText[3];
|
||||
if (dlg.WaterMetersCount > 4 && waterMeters[4] != null) waterMeters[4].EndState = dlg.EndStateText[4];
|
||||
if (dlg.WaterMetersCount > 5 && waterMeters[5] != null) waterMeters[5].EndState = dlg.EndStateText[5];
|
||||
}
|
||||
resultSaved = true;
|
||||
}
|
||||
|
||||
return Event.ModelessFormDone; /// Form closed
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
{
|
||||
None = 0,
|
||||
Done,
|
||||
ModelessFormDone,
|
||||
ValvesSet,
|
||||
AmbientDone,
|
||||
BalanceDone,
|
||||
|
||||
@@ -130,17 +130,17 @@ namespace TBF.BenchControl.Sequences
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdPurgeBegin)) selection = Selection.PurgeBegin;
|
||||
if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test;
|
||||
if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1;
|
||||
if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
|
||||
if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
|
||||
if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
|
||||
if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop;
|
||||
if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
|
||||
if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
|
||||
if (e.Contains(Event.UiCmdCameraTest)) goto camera_test;
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdPurgeBegin)) selection = Selection.PurgeBegin;
|
||||
if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test;
|
||||
if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1;
|
||||
if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
|
||||
if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
|
||||
if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
|
||||
if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop;
|
||||
if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
|
||||
if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
|
||||
if (e.Contains(Event.UiCmdCameraTest)) goto camera_test;
|
||||
}
|
||||
while (selection == Selection.None);
|
||||
|
||||
@@ -264,15 +264,11 @@ namespace TBF.BenchControl.Sequences
|
||||
{
|
||||
Bridge.OnActivity(this, "Enter the water meter data");
|
||||
State.Create("MainSeq : Enter begin data")
|
||||
.AddOperation(dataEntryCmpnt.ShowFormAtCycleBeginningOp(WaterMeters))
|
||||
.AddPermanentOperation(dataEntryCmpnt.ShowFormAtCycleBeginningOp(WaterMeters))
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
}
|
||||
while (!e.Contains(Event.Done));
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
}
|
||||
|
||||
assume_bench_filled:
|
||||
@@ -316,18 +312,22 @@ namespace TBF.BenchControl.Sequences
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop;
|
||||
if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test;
|
||||
if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1;
|
||||
if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
|
||||
if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
|
||||
if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
|
||||
if (e.Contains(Event.UiCmdPurgeBegin)) { selection = Selection.PurgeBegin; goto fill_the_bench; }
|
||||
if (e.Contains(Event.UiCmdPurgeEnd)) goto purge_end;
|
||||
if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
|
||||
if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
|
||||
if (e.Contains(Event.UiCmdAcceptResults)) goto save_results;
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop;
|
||||
if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test;
|
||||
if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1;
|
||||
if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
|
||||
if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
|
||||
if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
|
||||
if (e.Contains(Event.UiCmdPurgeBegin))
|
||||
{
|
||||
selection = Selection.PurgeBegin;
|
||||
goto fill_the_bench;
|
||||
}
|
||||
if (e.Contains(Event.UiCmdPurgeEnd)) goto purge_end;
|
||||
if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
|
||||
if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
|
||||
if (e.Contains(Event.UiCmdAcceptResults)) goto save_results;
|
||||
}
|
||||
while (selection == Selection.None);
|
||||
|
||||
@@ -476,7 +476,25 @@ namespace TBF.BenchControl.Sequences
|
||||
dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry;
|
||||
if (dataEntryCmpnt != null)
|
||||
{
|
||||
Bridge.OnActivity(this, "Enter the protokoll data");
|
||||
Bridge.OnActivity(this, "Enter the protocol data");
|
||||
|
||||
State.Create("MainSeq : Check whether the entry form is closed")
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
}
|
||||
while (!e.Contains(Event.ModelessFormDone));
|
||||
|
||||
State.Create("MainSeq : Nothing")
|
||||
.AddOperation(checkUiOp)
|
||||
.RemovePermanentOperation(dataEntryCmpnt as IOperation)
|
||||
.EnterState();
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
|
||||
State.Create("MainSeq : Enter end data")
|
||||
.AddOperation((dataEntryCmpnt as GenericDevices.IDataEntry).ShowFormAtCycleEndOp(WaterMeters))
|
||||
.AddOperation(checkUiOp)
|
||||
@@ -486,7 +504,7 @@ namespace TBF.BenchControl.Sequences
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
}
|
||||
while (!e.Contains(Event.Done));
|
||||
while (!e.Contains(Event.ModelessFormDone));
|
||||
|
||||
if (dataEntryCmpnt is IHasProtocolTitle)
|
||||
{
|
||||
|
||||
@@ -35,11 +35,13 @@ namespace TBF.BenchControl
|
||||
static State()
|
||||
{
|
||||
currentState = State.Empty;
|
||||
PermanentOperations = new List<IOperation>();
|
||||
}
|
||||
|
||||
///
|
||||
/// Instance fields set or initialized by the constructor
|
||||
///
|
||||
public static IList<IOperation> PermanentOperations;
|
||||
public readonly IList<IOperation> Operations;
|
||||
public readonly IList<Transition> Transitions;
|
||||
public readonly string Name;
|
||||
@@ -54,6 +56,7 @@ namespace TBF.BenchControl
|
||||
this.Name = name;
|
||||
this.Label = label;
|
||||
Operations = new List<IOperation>();
|
||||
foreach (var op in PermanentOperations) Operations.Add(op);
|
||||
Transitions = new List<Transition>();
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
@@ -83,6 +86,49 @@ namespace TBF.BenchControl
|
||||
return new State(name, label);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an operation to the list of permanent opertion (and to this state)
|
||||
/// </summary>
|
||||
/// <param name="obj">operation</param>
|
||||
public State AddPermanentOperation(IOperation operation)
|
||||
{
|
||||
if (operation != null)
|
||||
{
|
||||
Operations.Add(operation);
|
||||
PermanentOperations.Add(operation);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove an operation from the list of permanent opertion (and from this state)
|
||||
/// </summary>
|
||||
/// <param name="obj">operation</param>
|
||||
public State RemovePermanentOperation(IOperation operation)
|
||||
{
|
||||
if (operation != null)
|
||||
{
|
||||
Operations.Remove(operation);
|
||||
PermanentOperations.Remove(operation);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all permanent operations from this state and from the list
|
||||
/// (= clear the list of permanent operations)
|
||||
/// </summary>
|
||||
/// <param name="obj">operation</param>
|
||||
public State RemoveAllPermanentOperations()
|
||||
{
|
||||
if (PermanentOperations != null)
|
||||
{
|
||||
foreach (var op in PermanentOperations) Operations.Remove(op);
|
||||
PermanentOperations.Clear();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an operation to this state
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user