Solves issue with an opened CycleBeginForm after abort and re-selection in Israel:
- CloseCycleBeginForm() -> WaitBeginFormClosed() - CloseBeginForm() added to SequenceBase(forced dialog close) - CloseModellFormHandler added to UiBridge.Bridge
This commit is contained in:
parent
fc30e160fc
commit
c005a5cb26
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.Resources;
|
||||
|
||||
#pragma warning disable 162 /// Disables 'Unreachable code detected' warning
|
||||
@ -8,6 +9,8 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
{
|
||||
public partial class CycleBeginningForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(CycleBeginningForm));
|
||||
|
||||
// To be retrieved after the form closes
|
||||
public string[] MainSNText;
|
||||
public string[] AuxSNText;
|
||||
@ -23,6 +26,7 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
MainSNText = new string[Program.WMsCount / 2];
|
||||
AuxSNText = new string[Program.WMsCount / 2];
|
||||
completed = false;
|
||||
StartForceCloseHandler();
|
||||
|
||||
if (Program.WMsCount / 2 < 2) Height = 200;
|
||||
else if (Program.WMsCount / 2 < 3) Height = 355;
|
||||
@ -65,5 +69,24 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
completed = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
#region Forced close handling
|
||||
|
||||
public void StartForceCloseHandler()
|
||||
{
|
||||
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
||||
else OnForceClose(sender, args);
|
||||
};
|
||||
}
|
||||
|
||||
void OnForceClose(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.Resources;
|
||||
|
||||
#pragma warning disable 162 /// Disables 'Unreachable code detected' warning
|
||||
@ -8,6 +9,8 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
{
|
||||
public partial class CycleEndForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(CycleEndForm));
|
||||
|
||||
// To be set before the form opens
|
||||
public string ProtocolName1;
|
||||
public string ProtocolName2;
|
||||
@ -33,6 +36,7 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
QRise = new float[Program.WMsCount / 2];
|
||||
QFall = new float[Program.WMsCount / 2];
|
||||
completed = false;
|
||||
StartForceCloseHandler();
|
||||
|
||||
Localize();
|
||||
}
|
||||
@ -127,5 +131,24 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Forced close handling
|
||||
|
||||
public void StartForceCloseHandler()
|
||||
{
|
||||
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
||||
else OnForceClose(sender, args);
|
||||
};
|
||||
}
|
||||
|
||||
void OnForceClose(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
public float WMState(int wmNr) { return 0; }
|
||||
|
||||
|
||||
System.Windows.Forms.Form mdlessDlg;
|
||||
System.Windows.Forms.Form modelessDlg;
|
||||
|
||||
bool resultSaved;
|
||||
|
||||
@ -84,8 +84,8 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
///
|
||||
void OpenBeginningDlg(EntryForm myRef)
|
||||
{
|
||||
myRef.mdlessDlg = new CycleBeginningForm();
|
||||
mdlessDlg.Show();
|
||||
myRef.modelessDlg = new CycleBeginningForm();
|
||||
modelessDlg.Show();
|
||||
}
|
||||
///
|
||||
void OpenEndDlg(EntryForm myRef)
|
||||
@ -94,8 +94,8 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
endForm.ProtocolName1 = entryFormCfg.ProtocolTitle1;
|
||||
endForm.ProtocolName2 = entryFormCfg.ProtocolTitle2;
|
||||
endForm.ProtocolName3 = entryFormCfg.ProtocolTitle3;
|
||||
myRef.mdlessDlg = endForm;
|
||||
mdlessDlg.Show();
|
||||
myRef.modelessDlg = endForm;
|
||||
modelessDlg.Show();
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
@ -117,33 +117,34 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
/// <returns>Event.ResultsPrinted</returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (!(mdlessDlg as IHasCompleted).Completed)
|
||||
if (!(modelessDlg as IHasCompleted).Completed)
|
||||
{
|
||||
return Event.None; /// Return 'None' when form was not closed yet
|
||||
return Event.ModelessFormIsOpen;
|
||||
}
|
||||
|
||||
if (!resultSaved) /// This is to save the result only once
|
||||
{
|
||||
if (mdlessDlg is CycleBeginningForm)
|
||||
if (modelessDlg is CycleBeginningForm)
|
||||
{
|
||||
if (wMeters.Count >= 2 && wMeters[0] != null) wMeters[0].SerialNr = (mdlessDlg as CycleBeginningForm).MainSNText[0];
|
||||
if (wMeters.Count >= 2 && wMeters[1] != null) wMeters[1].SerialNr = (mdlessDlg as CycleBeginningForm).AuxSNText[0];
|
||||
if (wMeters.Count >= 4 && wMeters[2] != null) wMeters[2].SerialNr = (mdlessDlg as CycleBeginningForm).MainSNText[1];
|
||||
if (wMeters.Count >= 4 && wMeters[3] != null) wMeters[3].SerialNr = (mdlessDlg as CycleBeginningForm).AuxSNText[1];
|
||||
if (wMeters.Count >= 6 && wMeters[4] != null) wMeters[4].SerialNr = (mdlessDlg as CycleBeginningForm).MainSNText[2];
|
||||
if (wMeters.Count >= 6 && wMeters[5] != null) wMeters[5].SerialNr = (mdlessDlg as CycleBeginningForm).AuxSNText[2];
|
||||
if (wMeters.Count >= 2 && wMeters[0] != null) wMeters[0].SerialNr = (modelessDlg as CycleBeginningForm).MainSNText[0];
|
||||
if (wMeters.Count >= 2 && wMeters[1] != null) wMeters[1].SerialNr = (modelessDlg as CycleBeginningForm).AuxSNText[0];
|
||||
if (wMeters.Count >= 4 && wMeters[2] != null) wMeters[2].SerialNr = (modelessDlg as CycleBeginningForm).MainSNText[1];
|
||||
if (wMeters.Count >= 4 && wMeters[3] != null) wMeters[3].SerialNr = (modelessDlg as CycleBeginningForm).AuxSNText[1];
|
||||
if (wMeters.Count >= 6 && wMeters[4] != null) wMeters[4].SerialNr = (modelessDlg as CycleBeginningForm).MainSNText[2];
|
||||
if (wMeters.Count >= 6 && wMeters[5] != null) wMeters[5].SerialNr = (modelessDlg as CycleBeginningForm).AuxSNText[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wMeters.Count >= 2 && wMeters[0] != null) wMeters[0].EndState = (mdlessDlg as CycleEndForm).MainStateText[0];
|
||||
if (wMeters.Count >= 2 && wMeters[1] != null) wMeters[1].EndState = (mdlessDlg as CycleEndForm).AuxStateText[0];
|
||||
if (wMeters.Count >= 4 && wMeters[2] != null) wMeters[2].EndState = (mdlessDlg as CycleEndForm).MainStateText[1];
|
||||
if (wMeters.Count >= 4 && wMeters[3] != null) wMeters[3].EndState = (mdlessDlg as CycleEndForm).AuxStateText[1];
|
||||
if (wMeters.Count >= 6 && wMeters[4] != null) wMeters[4].EndState = (mdlessDlg as CycleEndForm).MainStateText[2];
|
||||
if (wMeters.Count >= 6 && wMeters[5] != null) wMeters[5].EndState = (mdlessDlg as CycleEndForm).AuxStateText[2];
|
||||
protocolTitle = (mdlessDlg as CycleEndForm).ProtocolTitle;
|
||||
if (wMeters.Count >= 2 && wMeters[0] != null) wMeters[0].EndState = (modelessDlg as CycleEndForm).MainStateText[0];
|
||||
if (wMeters.Count >= 2 && wMeters[1] != null) wMeters[1].EndState = (modelessDlg as CycleEndForm).AuxStateText[0];
|
||||
if (wMeters.Count >= 4 && wMeters[2] != null) wMeters[2].EndState = (modelessDlg as CycleEndForm).MainStateText[1];
|
||||
if (wMeters.Count >= 4 && wMeters[3] != null) wMeters[3].EndState = (modelessDlg as CycleEndForm).AuxStateText[1];
|
||||
if (wMeters.Count >= 6 && wMeters[4] != null) wMeters[4].EndState = (modelessDlg as CycleEndForm).MainStateText[2];
|
||||
if (wMeters.Count >= 6 && wMeters[5] != null) wMeters[5].EndState = (modelessDlg as CycleEndForm).AuxStateText[2];
|
||||
protocolTitle = (modelessDlg as CycleEndForm).ProtocolTitle;
|
||||
}
|
||||
resultSaved = true;
|
||||
modelessDlg = null;
|
||||
}
|
||||
|
||||
return Event.ModelessFormClosed; /// Form closed
|
||||
@ -152,7 +153,11 @@ namespace TBF.BenchControl.DataEntry.Munich
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
mdlessDlg = null;
|
||||
if (modelessDlg is IHasCompleted)
|
||||
{
|
||||
UiBridge.Bridge.OnCloseModelessForm(this, null);
|
||||
modelessDlg = null;
|
||||
}
|
||||
currentOp = CurrentOp.None;
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.DataEntry.Munich3
|
||||
{
|
||||
public partial class CycleBeginningForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(CycleBeginningForm));
|
||||
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
public readonly int WaterMetersCount;
|
||||
|
||||
/// To be retrieved after the form is closed
|
||||
@ -26,6 +29,7 @@ namespace TBF.BenchControl.DataEntry.Munich3
|
||||
InitializeComponent();
|
||||
SNText = new string[WaterMetersCount];
|
||||
completed = false;
|
||||
StartForceCloseHandler();
|
||||
|
||||
//Height = 55 + WaterMetersCount * 105;
|
||||
}
|
||||
@ -78,5 +82,24 @@ namespace TBF.BenchControl.DataEntry.Munich3
|
||||
completed = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
#region Forced close handling
|
||||
|
||||
public void StartForceCloseHandler()
|
||||
{
|
||||
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
||||
else OnForceClose(sender, args);
|
||||
};
|
||||
}
|
||||
|
||||
private void OnForceClose(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.DataEntry.Munich3
|
||||
{
|
||||
public partial class CycleEndForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(CycleEndForm));
|
||||
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
public readonly int WaterMetersCount;
|
||||
|
||||
// To be set before the form opens
|
||||
@ -32,7 +35,8 @@ namespace TBF.BenchControl.DataEntry.Munich3
|
||||
InitializeComponent();
|
||||
EndStateText = new string[WaterMetersCount];
|
||||
completed = false;
|
||||
}
|
||||
StartForceCloseHandler();
|
||||
}
|
||||
|
||||
/// <summary> Parameterless constructor for 3 watermeters </summary>
|
||||
public CycleEndForm()
|
||||
@ -93,5 +97,24 @@ namespace TBF.BenchControl.DataEntry.Munich3
|
||||
completed = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
#region Forced close handling
|
||||
|
||||
public void StartForceCloseHandler()
|
||||
{
|
||||
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
||||
else OnForceClose(sender, args);
|
||||
};
|
||||
}
|
||||
|
||||
void OnForceClose(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ namespace TBF.BenchControl.DataEntry.Munich3
|
||||
{
|
||||
if (!(modelessDlg as IHasCompleted).Completed)
|
||||
{
|
||||
return Event.None; /// Return 'None' when form was not closed yet
|
||||
return Event.ModelessFormIsOpen;
|
||||
}
|
||||
|
||||
if (!resultSaved) /// This is to save the result only once
|
||||
@ -150,6 +150,7 @@ namespace TBF.BenchControl.DataEntry.Munich3
|
||||
if (count > 5 && waterMeters[5] != null) waterMeters[5].EndState = dlg.EndStateText[5];
|
||||
}
|
||||
resultSaved = true;
|
||||
modelessDlg = null;
|
||||
}
|
||||
|
||||
return Event.ModelessFormClosed; /// Form closed
|
||||
@ -158,7 +159,11 @@ namespace TBF.BenchControl.DataEntry.Munich3
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
modelessDlg = null;
|
||||
if (modelessDlg is IHasCompleted)
|
||||
{
|
||||
UiBridge.Bridge.OnCloseModelessForm(this, null);
|
||||
modelessDlg = null;
|
||||
}
|
||||
currentOp = CurrentOp.None;
|
||||
}
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ namespace TBF.BenchControl.DataEntry.WMStates
|
||||
{
|
||||
if (!(modelessDlg as IHasCompleted).Completed)
|
||||
{
|
||||
return Event.None; /// Return 'None' when form was not closed yet
|
||||
return Event.ModelessFormIsOpen;
|
||||
}
|
||||
|
||||
if (!resultSaved) /// This is to save the result only once
|
||||
@ -163,6 +163,7 @@ namespace TBF.BenchControl.DataEntry.WMStates
|
||||
if (dlg.WaterMetersCount > 5) wmState[5] = dlg.WMState[5];
|
||||
}
|
||||
resultSaved = true;
|
||||
modelessDlg = null;
|
||||
}
|
||||
|
||||
return Event.ModelessFormClosed; /// Form closed
|
||||
@ -171,7 +172,11 @@ namespace TBF.BenchControl.DataEntry.WMStates
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
modelessDlg = null;
|
||||
if (modelessDlg is IHasCompleted)
|
||||
{
|
||||
UiBridge.Bridge.OnCloseModelessForm(this, null);
|
||||
modelessDlg = null;
|
||||
}
|
||||
currentOp = CurrentOp.None;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.DataEntry.WMStates
|
||||
{
|
||||
public partial class WMSNsAndStatesForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(WMSNsAndStatesForm));
|
||||
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
public readonly int WaterMetersCount;
|
||||
|
||||
/// To be retrieved after the form is closed
|
||||
@ -30,6 +33,7 @@ namespace TBF.BenchControl.DataEntry.WMStates
|
||||
SNText = new string[WaterMetersCount];
|
||||
WMState = new float[WaterMetersCount];
|
||||
completed = false;
|
||||
StartForceCloseHandler();
|
||||
|
||||
//Height = 55 + WaterMetersCount * 105;
|
||||
}
|
||||
@ -102,5 +106,24 @@ namespace TBF.BenchControl.DataEntry.WMStates
|
||||
completed = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
#region Forced close handling
|
||||
|
||||
public void StartForceCloseHandler()
|
||||
{
|
||||
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
||||
else OnForceClose(sender, args);
|
||||
};
|
||||
}
|
||||
|
||||
void OnForceClose(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.DataEntry.WMStates
|
||||
{
|
||||
public partial class WMStatesForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(WMStatesForm));
|
||||
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
public readonly int WaterMetersCount;
|
||||
|
||||
// To be retrieved after the form closes
|
||||
@ -26,7 +29,8 @@ namespace TBF.BenchControl.DataEntry.WMStates
|
||||
InitializeComponent();
|
||||
WMState = new float[WaterMetersCount];
|
||||
completed = false;
|
||||
}
|
||||
StartForceCloseHandler();
|
||||
}
|
||||
|
||||
/// <summary> Parameterless constructor for 3 watermeters </summary>
|
||||
public WMStatesForm()
|
||||
@ -85,5 +89,24 @@ namespace TBF.BenchControl.DataEntry.WMStates
|
||||
completed = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
#region Forced close handling
|
||||
|
||||
public void StartForceCloseHandler()
|
||||
{
|
||||
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
||||
else OnForceClose(sender, args);
|
||||
};
|
||||
}
|
||||
|
||||
void OnForceClose(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,85 +53,86 @@
|
||||
/// <summary>
|
||||
/// StateMachine events (issued by operations, IOperation derived classes)
|
||||
/// </summary>
|
||||
public enum Event
|
||||
{
|
||||
None = 0,
|
||||
Busy, /// Useful when waiting in state until at least one is busy (all are done)
|
||||
Done, /// Useful when waiting in state until the first is done, the rest miht still be busy
|
||||
///
|
||||
ModelessFormClosed,
|
||||
public enum Event
|
||||
{
|
||||
None = 0,
|
||||
Busy, /// Useful when waiting in state until at least one is busy (all are done)
|
||||
Done, /// Useful when waiting in state until the first is done, the rest miht still be busy
|
||||
///
|
||||
ModelessFormIsOpen,
|
||||
ModelessFormClosed,
|
||||
|
||||
ValvesBusy,
|
||||
ValvesSet,
|
||||
ValvesBusy,
|
||||
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,
|
||||
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,
|
||||
UiCmdEmptyTank3,
|
||||
UiCmdTestOpticalHeads,
|
||||
UiCmdResetResults,
|
||||
UiCmdAcceptResults,
|
||||
UiCmdCalibration,
|
||||
UiCmdCameraTest,
|
||||
UiCmdSensitivityTest,
|
||||
UiCmdB1,
|
||||
UiCmdB2,
|
||||
UiCmdB3,
|
||||
/// CheckUi events
|
||||
UiCmdStartTest,
|
||||
UiCmdStartQ1,
|
||||
UiCmdStartQ2,
|
||||
UiCmdStartQ3,
|
||||
UiCmdStartCycle,
|
||||
UiCmdStop,
|
||||
UiCmdPurgeBegin,
|
||||
UiCmdPurgeEnd,
|
||||
UiCmdEmptyTank1,
|
||||
UiCmdEmptyTank2,
|
||||
UiCmdEmptyTank3,
|
||||
UiCmdTestOpticalHeads,
|
||||
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,
|
||||
DetectionFailed,
|
||||
/// IDC camera events
|
||||
CameraBusy,
|
||||
CameraOpCompleted,
|
||||
CameraOpFailed,
|
||||
DetectionFailed,
|
||||
|
||||
/// Generic
|
||||
Error, /// Many ops.: Fatal error occurred
|
||||
OpArgumentError,
|
||||
ConfigurationError,
|
||||
Yes,
|
||||
No,
|
||||
Next, /// To move to the next state when debugging
|
||||
OK,
|
||||
TimerBusy,
|
||||
}
|
||||
/// Generic
|
||||
Error, /// Many ops.: Fatal error occurred
|
||||
OpArgumentError,
|
||||
ConfigurationError,
|
||||
Yes,
|
||||
No,
|
||||
Next, /// To move to the next state when debugging
|
||||
OK,
|
||||
TimerBusy,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace TBF.BenchControl.GenericDevices
|
||||
{
|
||||
interface IHasCompleted
|
||||
{
|
||||
bool Completed { get; }
|
||||
void StartForceCloseHandler();
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,11 +159,8 @@ namespace TBF.BenchControl.Sequences
|
||||
select_procedure:
|
||||
|
||||
/// Make sure the CycleBeginForm is closed (aftrer an abnormal procedure/test end, etc.)
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stop;
|
||||
}
|
||||
CloseBeginForm();
|
||||
cycleBeginFormOpened = false;
|
||||
|
||||
selection = MakeSelection(MKSelContext.ProcedureNotSelected);
|
||||
|
||||
@ -285,7 +282,7 @@ namespace TBF.BenchControl.Sequences
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stop;
|
||||
if (WaitBeginFormClosed()) goto stop;
|
||||
}
|
||||
|
||||
if (e.Contains(Event.ConfigurationError)) goto select_cycle_or_test;
|
||||
@ -331,7 +328,7 @@ namespace TBF.BenchControl.Sequences
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stop;
|
||||
if (WaitBeginFormClosed()) goto stop;
|
||||
}
|
||||
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
@ -364,7 +361,7 @@ namespace TBF.BenchControl.Sequences
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stop;
|
||||
if (WaitBeginFormClosed()) goto stop;
|
||||
}
|
||||
Bridge.OnActivity(this, "Enter protocol data");
|
||||
|
||||
|
||||
@ -581,26 +581,25 @@ namespace TBF.BenchControl.Sequences
|
||||
/// This function is typically called at the end of the first test of the procedure.
|
||||
/// </summary>
|
||||
/// <returns>false = OK, true = stop pressed</returns>
|
||||
protected bool CloseCycleBeginForm()
|
||||
protected bool WaitBeginFormClosed()
|
||||
{
|
||||
IList<Event> e;
|
||||
GenericDevices.IDataEntry dataEntryCmpnt =
|
||||
TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry;
|
||||
if (dataEntryCmpnt as IHasCycleBeginForm != null)
|
||||
|
||||
if ((dataEntryCmpnt as IHasCycleBeginForm != null) && State.LastEvents.Contains(Event.ModelessFormIsOpen))
|
||||
{
|
||||
if (!State.LastEvents.Contains(Event.ModelessFormClosed))
|
||||
IList<Event> e;
|
||||
|
||||
/// Wait until modeless dialg is closed
|
||||
State.Create("MainSeq : Check whether the entry form is closed")
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
/// Wait until modeless dialg is closed
|
||||
State.Create("MainSeq : Check whether the entry form is closed")
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) return true;
|
||||
}
|
||||
while (!e.Contains(Event.ModelessFormClosed));
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) return true;
|
||||
}
|
||||
while (!e.Contains(Event.ModelessFormClosed));
|
||||
|
||||
/// A state without any dataEntryCmpnt operation so that Stop() when entering
|
||||
/// this state and Start() when entering the following state are executed.
|
||||
@ -609,12 +608,44 @@ namespace TBF.BenchControl.Sequences
|
||||
.RemovePermanentOperation(dataEntryCmpnt as IOperation)
|
||||
.EnterState();
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
if (e.Contains(Event.UiCmdStop)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Forces closing of a modeless dialog for entering data at the beginnig of a procedure.
|
||||
/// This function is typically called before starting a new cycle
|
||||
/// in case previous cycle was aborted.
|
||||
/// </summary>
|
||||
protected void CloseBeginForm()
|
||||
{
|
||||
if (StateMachine.Procedure == null || StateMachine.Procedure.DataEntry == null) return;
|
||||
|
||||
GenericDevices.IDataEntry dataEntryCmpnt =
|
||||
TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry;
|
||||
|
||||
if ((dataEntryCmpnt as IHasCycleBeginForm != null) && State.LastEvents.Contains(Event.ModelessFormIsOpen))
|
||||
{
|
||||
IList<Event> e;
|
||||
|
||||
/// A state without any dataEntryCmpnt operation so that Stop() when entering
|
||||
/// this state and Start() when entering the following state are executed.
|
||||
State.Create("MainSeq : Nothing")
|
||||
.RemovePermanentOperation(dataEntryCmpnt as IOperation)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
}
|
||||
while (e.Contains(Event.ModelessFormIsOpen));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Main loop where measurements are collected.
|
||||
/// </summary>
|
||||
|
||||
@ -240,7 +240,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stopTest;
|
||||
if (WaitBeginFormClosed()) goto stopTest;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.Adjustment
|
||||
{
|
||||
public partial class WMErrorsForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(WMErrorsForm));
|
||||
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
public readonly int WaterMetersCount;
|
||||
|
||||
Entities.TestResult tr;
|
||||
@ -167,5 +170,24 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
||||
g.FillPolygon(blackBrush, triangle);
|
||||
}
|
||||
}
|
||||
|
||||
#region Forced close handling
|
||||
|
||||
public void StartForceCloseHandler()
|
||||
{
|
||||
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
||||
else OnForceClose(sender, args);
|
||||
};
|
||||
}
|
||||
|
||||
void OnForceClose(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stopTest;
|
||||
if (WaitBeginFormClosed()) goto stopTest;
|
||||
}
|
||||
|
||||
/// Optionally supress pulses from the large water meter
|
||||
|
||||
@ -541,7 +541,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stop;
|
||||
if (WaitBeginFormClosed()) goto stop;
|
||||
}
|
||||
|
||||
/// Optionally supress pulses from the large water meter
|
||||
|
||||
@ -462,7 +462,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stopTest;
|
||||
if (WaitBeginFormClosed()) goto stopTest;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@ -209,7 +209,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stopTest;
|
||||
if (WaitBeginFormClosed()) goto stopTest;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@ -347,7 +347,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stopTest;
|
||||
if (WaitBeginFormClosed()) goto stopTest;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@ -253,7 +253,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stopTest;
|
||||
if (WaitBeginFormClosed()) goto stopTest;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@ -172,7 +172,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stopTest;
|
||||
if (WaitBeginFormClosed()) goto stopTest;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@ -326,7 +326,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
|
||||
if (cycleBeginFormOpened)
|
||||
{
|
||||
cycleBeginFormOpened = false;
|
||||
if (CloseCycleBeginForm()) goto stopTest;
|
||||
if (WaitBeginFormClosed()) goto stopTest;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@ -208,5 +208,17 @@ namespace TBF.UiBridge
|
||||
catch (Exception e) { log.Error("EmergencyStopHandler(...) failed", e); }
|
||||
}
|
||||
public static event EventHandler<EmergencyStopEventArgs> EmergencyStopChangedHandler;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called from the state machine when an operation forces a modeless dialog close.
|
||||
/// </summary>
|
||||
public static void OnCloseModelessForm(object sender, EventArgs args)
|
||||
{
|
||||
if (CloseModelessFormHandler == null) return;
|
||||
try { CloseModelessFormHandler(sender, null); }
|
||||
catch (Exception e) { log.Error("CloseModelessFormHandler(...) failed", e); }
|
||||
}
|
||||
public static event EventHandler<EventArgs> CloseModelessFormHandler;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user