Emergency stop form reactivated

This commit is contained in:
Milan Hanajik 2014-07-29 00:39:43 +02:00
parent 805e66d537
commit 7261d44728
3 changed files with 49 additions and 27 deletions

View File

@ -70,8 +70,10 @@ namespace TBF.BenchControl.Elde
public float ReferenceVolume { get { return controlCom.ReferenceVolume; } } public float ReferenceVolume { get { return controlCom.ReferenceVolume; } }
public float VyslExt(int wmNr0, int what) { return controlCom.VyslExt(wmNr0, what); } public float VyslExt(int wmNr0, int what) { return controlCom.VyslExt(wmNr0, what); }
/// <summary> Extracted from the StatusP </summary> /// <summary> Extracted from the StatusP in RunDeviceBefore </summary>
public bool EmgcyStopActive { get { return (controlCom.StatusP & StatusP.EmgcyStopActive) != 0; } } public bool EmergencyStop { get { return emergencyStop; } }
bool emergencyStop;
bool previousEmergencyStop;
/// <summary> State of valves sent out - buffered by the last SendCommand() </summary> /// <summary> State of valves sent out - buffered by the last SendCommand() </summary>
public ulong Route { get { return route; } } public ulong Route { get { return route; } }
@ -134,6 +136,8 @@ namespace TBF.BenchControl.Elde
if (cfg == null) throw new ArgumentNullException("cfg"); if (cfg == null) throw new ArgumentNullException("cfg");
this.controlBoardCfg = cfg; this.controlBoardCfg = cfg;
FMFreq = new float[2] { 0, 0 }; FMFreq = new float[2] { 0, 0 };
emergencyStop = false;
previousEmergencyStop = false;
} }
/// <summary> /// <summary>
@ -179,7 +183,19 @@ namespace TBF.BenchControl.Elde
{ {
controlCom.RunDeviceBefore(); controlCom.RunDeviceBefore();
if (EmgcyStopActive) previousEmergencyStop = emergencyStop;
emergencyStop = (controlCom.StatusP & StatusP.EmgcyStopActive) != 0;
if (emergencyStop && !previousEmergencyStop)
{
Program.MainWnd.Invoke(new ShowEmergencyStopFormDlgt(ShowEmergencyStopForm));
}
else if (!emergencyStop && previousEmergencyStop)
{
UiBridge.Bridge.OnEmergencyStopChanged(this,UiBridge.EmergencyStopEventArgs.State.CloseForm);
}
if (emergencyStop)
{ {
/// SendCommand() arguments to clear the emergency stop state /// SendCommand() arguments to clear the emergency stop state
sendCommandFlag = true; sendCommandFlag = true;
@ -218,6 +234,15 @@ namespace TBF.BenchControl.Elde
{ {
} }
delegate void ShowEmergencyStopFormDlgt();
///
void ShowEmergencyStopForm()
{
(new TBF.Forms.EmergencyStopForm()).Show();
}
/// <summary> /// <summary>
/// Sends a command to the control board. /// Sends a command to the control board.
/// </summary> /// </summary>

View File

@ -7,22 +7,22 @@ namespace TBF.Forms
{ {
public partial class EmergencyStopForm : Form public partial class EmergencyStopForm : Form
{ {
public static bool ClosingForm = false; bool closingForm = false;
/// <summary> /// <summary>
/// Parameterless constructor (does the localization) /// Parameterless constructor (does the localization)
/// </summary> /// </summary>
public EmergencyStopForm() public EmergencyStopForm()
{ {
Visible = false; Visible = true;
InitializeComponent(); InitializeComponent();
emergencyStopMsgLabel.Text = Strings.Emergency_STOP; emergencyStopMsgLabel.Text = Strings.Emergency_STOP;
emergencyStopMsgLabel.Enabled = false; emergencyStopMsgLabel.Enabled = true;
emergencyStopMsgLabel.Visible = false; emergencyStopMsgLabel.Visible = true;
UiBridge.Bridge.EmergencyStopChangedHandler += delegate(object sender, UiBridge.EmergencyStopEventArgs args) UiBridge.Bridge.EmergencyStopChangedHandler += delegate(object sender, UiBridge.EmergencyStopEventArgs args)
{ {
if (ClosingForm) return; if (closingForm) return;
if (InvokeRequired) if (InvokeRequired)
{ {
@ -34,23 +34,23 @@ namespace TBF.Forms
void OnEmergencyStopStateChanged(Object sender, UiBridge.EmergencyStopEventArgs args) void OnEmergencyStopStateChanged(Object sender, UiBridge.EmergencyStopEventArgs args)
{ {
if (args.EmergencyStopState == UiBridge.EmergencyStopEventArgs.State.Active) if (args.EmergencyStopState == UiBridge.EmergencyStopEventArgs.State.CloseForm)
{ {
Visible = true; closingForm = true;
emergencyStopMsgLabel.Enabled = true;
emergencyStopMsgLabel.Visible = true;
}
else if (args.EmergencyStopState == UiBridge.EmergencyStopEventArgs.State.Inactive)
{
Visible = false;
emergencyStopMsgLabel.Enabled = false;
emergencyStopMsgLabel.Visible = false;
}
else if (args.EmergencyStopState == UiBridge.EmergencyStopEventArgs.State.CloseForm)
{
ClosingForm = true;
Close(); Close();
} }
//else if (args.EmergencyStopState == UiBridge.EmergencyStopEventArgs.State.Active)
//{
// Visible = true;
// emergencyStopMsgLabel.Enabled = true;
// emergencyStopMsgLabel.Visible = true;
//}
//else if (args.EmergencyStopState == UiBridge.EmergencyStopEventArgs.State.Inactive)
//{
// Visible = false;
// emergencyStopMsgLabel.Enabled = false;
// emergencyStopMsgLabel.Visible = false;
//}
} }
} }
} }

View File

@ -34,7 +34,6 @@
// emergencyStopMsgLabel // emergencyStopMsgLabel
// //
this.emergencyStopMsgLabel.AutoSize = true; this.emergencyStopMsgLabel.AutoSize = true;
this.emergencyStopMsgLabel.Enabled = false;
this.emergencyStopMsgLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.emergencyStopMsgLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.emergencyStopMsgLabel.ForeColor = System.Drawing.Color.Yellow; this.emergencyStopMsgLabel.ForeColor = System.Drawing.Color.Yellow;
this.emergencyStopMsgLabel.Location = new System.Drawing.Point(67, 86); this.emergencyStopMsgLabel.Location = new System.Drawing.Point(67, 86);
@ -42,7 +41,6 @@
this.emergencyStopMsgLabel.Size = new System.Drawing.Size(287, 37); this.emergencyStopMsgLabel.Size = new System.Drawing.Size(287, 37);
this.emergencyStopMsgLabel.TabIndex = 1; this.emergencyStopMsgLabel.TabIndex = 1;
this.emergencyStopMsgLabel.Text = "Emergency STOP"; this.emergencyStopMsgLabel.Text = "Emergency STOP";
this.emergencyStopMsgLabel.Visible = false;
// //
// EmergencyStopForm // EmergencyStopForm
// //
@ -52,13 +50,12 @@
this.BackColor = System.Drawing.Color.Red; this.BackColor = System.Drawing.Color.Red;
this.ClientSize = new System.Drawing.Size(412, 212); this.ClientSize = new System.Drawing.Size(412, 212);
this.Controls.Add(this.emergencyStopMsgLabel); this.Controls.Add(this.emergencyStopMsgLabel);
this.Enabled = false; this.ForeColor = System.Drawing.Color.Transparent;
this.ForeColor = System.Drawing.Color.Yellow;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "EmergencyStopForm"; this.Name = "EmergencyStopForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Emergency STOP"; this.Text = "Emergency STOP";
this.TopMost = true; this.TopMost = true;
this.ResumeLayout(false); this.ResumeLayout(false);