diff --git a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs index 42bdecdf1..9bcc6a3e6 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs @@ -70,8 +70,10 @@ namespace TBF.BenchControl.Elde public float ReferenceVolume { get { return controlCom.ReferenceVolume; } } public float VyslExt(int wmNr0, int what) { return controlCom.VyslExt(wmNr0, what); } - /// Extracted from the StatusP - public bool EmgcyStopActive { get { return (controlCom.StatusP & StatusP.EmgcyStopActive) != 0; } } + /// Extracted from the StatusP in RunDeviceBefore + public bool EmergencyStop { get { return emergencyStop; } } + bool emergencyStop; + bool previousEmergencyStop; /// State of valves sent out - buffered by the last SendCommand() public ulong Route { get { return route; } } @@ -134,6 +136,8 @@ namespace TBF.BenchControl.Elde if (cfg == null) throw new ArgumentNullException("cfg"); this.controlBoardCfg = cfg; FMFreq = new float[2] { 0, 0 }; + emergencyStop = false; + previousEmergencyStop = false; } /// @@ -179,7 +183,19 @@ namespace TBF.BenchControl.Elde { 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 sendCommandFlag = true; @@ -218,6 +234,15 @@ namespace TBF.BenchControl.Elde { } + + delegate void ShowEmergencyStopFormDlgt(); + /// + void ShowEmergencyStopForm() + { + (new TBF.Forms.EmergencyStopForm()).Show(); + } + + /// /// Sends a command to the control board. /// diff --git a/TestBenchFramework/Forms/EmergencyStopForm.cs b/TestBenchFramework/Forms/EmergencyStopForm.cs index 83c996286..a9cafaea4 100644 --- a/TestBenchFramework/Forms/EmergencyStopForm.cs +++ b/TestBenchFramework/Forms/EmergencyStopForm.cs @@ -7,22 +7,22 @@ namespace TBF.Forms { public partial class EmergencyStopForm : Form { - public static bool ClosingForm = false; + bool closingForm = false; /// /// Parameterless constructor (does the localization) /// public EmergencyStopForm() { - Visible = false; + Visible = true; InitializeComponent(); emergencyStopMsgLabel.Text = Strings.Emergency_STOP; - emergencyStopMsgLabel.Enabled = false; - emergencyStopMsgLabel.Visible = false; + emergencyStopMsgLabel.Enabled = true; + emergencyStopMsgLabel.Visible = true; UiBridge.Bridge.EmergencyStopChangedHandler += delegate(object sender, UiBridge.EmergencyStopEventArgs args) { - if (ClosingForm) return; + if (closingForm) return; if (InvokeRequired) { @@ -34,23 +34,23 @@ namespace TBF.Forms void OnEmergencyStopStateChanged(Object sender, UiBridge.EmergencyStopEventArgs args) { - if (args.EmergencyStopState == UiBridge.EmergencyStopEventArgs.State.Active) + if (args.EmergencyStopState == UiBridge.EmergencyStopEventArgs.State.CloseForm) { - Visible = 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; + closingForm = true; 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; + //} } } } diff --git a/TestBenchFramework/Forms/EmergencyStopForm.designer.cs b/TestBenchFramework/Forms/EmergencyStopForm.designer.cs index d8d406f57..c56676849 100644 --- a/TestBenchFramework/Forms/EmergencyStopForm.designer.cs +++ b/TestBenchFramework/Forms/EmergencyStopForm.designer.cs @@ -34,7 +34,6 @@ // emergencyStopMsgLabel // 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.ForeColor = System.Drawing.Color.Yellow; this.emergencyStopMsgLabel.Location = new System.Drawing.Point(67, 86); @@ -42,7 +41,6 @@ this.emergencyStopMsgLabel.Size = new System.Drawing.Size(287, 37); this.emergencyStopMsgLabel.TabIndex = 1; this.emergencyStopMsgLabel.Text = "Emergency STOP"; - this.emergencyStopMsgLabel.Visible = false; // // EmergencyStopForm // @@ -52,13 +50,12 @@ this.BackColor = System.Drawing.Color.Red; this.ClientSize = new System.Drawing.Size(412, 212); this.Controls.Add(this.emergencyStopMsgLabel); - this.Enabled = false; - this.ForeColor = System.Drawing.Color.Yellow; + this.ForeColor = System.Drawing.Color.Transparent; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "EmergencyStopForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Emergency STOP"; this.TopMost = true; this.ResumeLayout(false);