diff --git a/src/BRS.Process.A020/A020Process_Operation.cs b/src/BRS.Process.A020/A020Process_Operation.cs index 42af1ac..36846f5 100644 --- a/src/BRS.Process.A020/A020Process_Operation.cs +++ b/src/BRS.Process.A020/A020Process_Operation.cs @@ -1983,12 +1983,17 @@ namespace BRS.Process.A020 else { ProcessWriteInt(MelsecPLC, "D3", "int", "0");//D3置0 - ProcessWriteInt(MelsecPLC, "D171", "int", "3000");//最大扭矩3000 + //ProcessWriteInt(MelsecPLC, "D171", "int", "3000");//最大扭矩3000 ProcessWriteInt(MelsecPLC, "D51", "int", "1");//手动拧紧螺丝D51置1 machineState = MachineState.Waiting;//设备启动完成后保持状态 LogAsync(DateTime.Now, LogLevel.Detail, "设备已启动,请勿其他操作!!"); } } + else + { + LogAsync(DateTime.Now, LogLevel.Warning, "通讯故障!"); + return; + } } }); Task.Run(() => @@ -2034,12 +2039,17 @@ namespace BRS.Process.A020 else { ProcessWriteInt(MelsecPLC, "D3", "int", "0");//D3置0 - ProcessWriteInt(MelsecPLC, "D171", "int", "3000");//最大扭矩3000 + //ProcessWriteInt(MelsecPLC, "D171", "int", "3000");//最大扭矩3000 ProcessWriteInt(MelsecPLC, "D53", "int", "1");//手动拧紧螺丝D51置1 machineState = MachineState.Waiting;//设备启动完成后保持状态 LogAsync(DateTime.Now, LogLevel.Detail, "设备已启动,请勿其他操作!!"); } } + else + { + LogAsync(DateTime.Now, LogLevel.Warning, "通讯故障!"); + return; + } } }); Task.Run(() => @@ -2107,9 +2117,6 @@ namespace BRS.Process.A020 } else { - - - ShaftOperateKeep(MelsecPLC, addD3, "0"); Thread.Sleep(500); ShaftOperateOnce(MelsecPLC, addD1, 500); @@ -2124,21 +2131,15 @@ namespace BRS.Process.A020 LogAsync(DateTime.Now, LogLevel.Warning, "通讯故障!"); return; } - - } - - }); - - LogAsync(DateTime.Now, LogLevel.Action, "流程启动完成!"); PubSubCenter.GetInstance().Publish(PubSubCenterMessageType.IsProcessOpened.ToString(), true, null); return new ProcessResponse(true); } /// - /// 根据PLC地址操作一次硫化机 + /// 根据PLC地址操作一次扭矩轴 /// /// PLC驱动 /// PLC地址 @@ -2589,7 +2590,6 @@ namespace BRS.Process.A020 } - [ProcessMethod("", "CloseProcess", "主流程停止", InvokeType.TestInvoke)] public BRS.Common.Model.ProcessResponse CloseProcess(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) { diff --git a/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs b/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs index f6b4296..608a3c5 100644 --- a/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs +++ b/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs @@ -46,21 +46,17 @@ namespace BRS.Process.A020.UI this.StopStateLabel = new Sunny.UI.UILabel(); this.chart2 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.uiPanel1 = new Sunny.UI.UIPanel(); - this.ManualBtn1 = new BRS.Process.A020.UI.CircleButton(); - this.AutoBtn1 = new BRS.Process.A020.UI.CircleButton(); - this.LoosenLight1 = new BRS.Process.A020.UI.CircleButton(); - this.ToughLight1 = new BRS.Process.A020.UI.CircleButton(); - this.StopStateLight1 = new BRS.Process.A020.UI.CircleButton(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); this.TestBtn = new Sunny.UI.UIButton(); - this.Setting = new Sunny.UI.UIButton(); this.AutoLoosenBtn1 = new Sunny.UI.UIButton(); this.AutoToughBtn1 = new Sunny.UI.UIButton(); this.ManualLoosenBtn = new Sunny.UI.UIButton(); this.ManualToughBtn = new Sunny.UI.UIButton(); this.StopBtn2 = new Sunny.UI.UIButton(); this.StartBtn1 = new Sunny.UI.UIButton(); - this.MoveStateLight1 = new BRS.Process.A020.UI.CircleButton(); - this.ESBtn = new BRS.Process.A020.UI.CircleButton(); this.AutoLoosenBtn = new Sunny.UI.UIButton(); this.AutoToughBtn = new Sunny.UI.UIButton(); this.uiLabel2 = new Sunny.UI.UILabel(); @@ -69,10 +65,16 @@ namespace BRS.Process.A020.UI this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.uiButton1 = new Sunny.UI.UIButton(); this.timer2 = new System.Windows.Forms.Timer(this.components); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.OKBtn = new Sunny.UI.UIButton(); + this.ManualBtn1 = new BRS.Process.A020.UI.CircleButton(); + this.AutoBtn1 = new BRS.Process.A020.UI.CircleButton(); + this.LoosenLight1 = new BRS.Process.A020.UI.CircleButton(); + this.ToughLight1 = new BRS.Process.A020.UI.CircleButton(); + this.StopStateLight1 = new BRS.Process.A020.UI.CircleButton(); + this.MoveStateLight1 = new BRS.Process.A020.UI.CircleButton(); + this.ESBtn = new BRS.Process.A020.UI.CircleButton(); ((System.ComponentModel.ISupportInitialize)(this.chart2)).BeginInit(); this.uiPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); @@ -204,6 +206,9 @@ namespace BRS.Process.A020.UI // // uiPanel1 // + this.uiPanel1.Controls.Add(this.OKBtn); + this.uiPanel1.Controls.Add(this.label5); + this.uiPanel1.Controls.Add(this.textBox1); this.uiPanel1.Controls.Add(this.label4); this.uiPanel1.Controls.Add(this.label3); this.uiPanel1.Controls.Add(this.label2); @@ -214,7 +219,6 @@ namespace BRS.Process.A020.UI this.uiPanel1.Controls.Add(this.ToughLight1); this.uiPanel1.Controls.Add(this.StopStateLight1); this.uiPanel1.Controls.Add(this.TestBtn); - this.uiPanel1.Controls.Add(this.Setting); this.uiPanel1.Controls.Add(this.AutoLoosenBtn1); this.uiPanel1.Controls.Add(this.AutoToughBtn1); this.uiPanel1.Controls.Add(this.ManualLoosenBtn); @@ -235,56 +239,49 @@ namespace BRS.Process.A020.UI this.uiPanel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; this.uiPanel1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); // - // ManualBtn1 + // label4 // - this.ManualBtn1.BackColor = System.Drawing.Color.Gray; - this.ManualBtn1.Cursor = System.Windows.Forms.Cursors.Hand; - this.ManualBtn1.Location = new System.Drawing.Point(484, 323); - this.ManualBtn1.Name = "ManualBtn1"; - this.ManualBtn1.Size = new System.Drawing.Size(58, 50); - this.ManualBtn1.TabIndex = 19; - this.ManualBtn1.Text = "手动按钮"; - this.ManualBtn1.UseVisualStyleBackColor = false; - this.ManualBtn1.Click += new System.EventHandler(this.ManualBtn1_Click); + this.label4.AutoSize = true; + this.label4.BackColor = System.Drawing.Color.Silver; + this.label4.Location = new System.Drawing.Point(480, 106); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(106, 42); + this.label4.TabIndex = 23; + this.label4.Text = "手动拧松状态\r\n指示灯"; + this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // AutoBtn1 + // label3 // - this.AutoBtn1.BackColor = System.Drawing.Color.Gray; - this.AutoBtn1.Cursor = System.Windows.Forms.Cursors.Hand; - this.AutoBtn1.Location = new System.Drawing.Point(420, 323); - this.AutoBtn1.Name = "AutoBtn1"; - this.AutoBtn1.Size = new System.Drawing.Size(58, 50); - this.AutoBtn1.TabIndex = 18; - this.AutoBtn1.Text = "自动按钮"; - this.AutoBtn1.UseVisualStyleBackColor = false; - this.AutoBtn1.Click += new System.EventHandler(this.AutoBtn1_Click); + this.label3.AutoSize = true; + this.label3.BackColor = System.Drawing.Color.Silver; + this.label3.Location = new System.Drawing.Point(326, 106); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(106, 42); + this.label3.TabIndex = 22; + this.label3.Text = "手动拧紧状态\r\n指示灯"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // LoosenLight1 + // label2 // - this.LoosenLight1.BackColor = System.Drawing.Color.Gray; - this.LoosenLight1.Location = new System.Drawing.Point(491, 39); - this.LoosenLight1.Name = "LoosenLight1"; - this.LoosenLight1.Size = new System.Drawing.Size(75, 64); - this.LoosenLight1.TabIndex = 17; - this.LoosenLight1.UseVisualStyleBackColor = false; + this.label2.AutoSize = true; + this.label2.BackColor = System.Drawing.Color.Silver; + this.label2.Location = new System.Drawing.Point(207, 106); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(74, 42); + this.label2.TabIndex = 21; + this.label2.Text = "停止状态\r\n指示灯"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // ToughLight1 + // label1 // - this.ToughLight1.BackColor = System.Drawing.Color.Gray; - this.ToughLight1.Location = new System.Drawing.Point(341, 39); - this.ToughLight1.Name = "ToughLight1"; - this.ToughLight1.Size = new System.Drawing.Size(75, 64); - this.ToughLight1.TabIndex = 16; - this.ToughLight1.UseVisualStyleBackColor = false; - // - // StopStateLight1 - // - this.StopStateLight1.BackColor = System.Drawing.Color.Gray; - this.StopStateLight1.Location = new System.Drawing.Point(211, 39); - this.StopStateLight1.Name = "StopStateLight1"; - this.StopStateLight1.Size = new System.Drawing.Size(75, 64); - this.StopStateLight1.TabIndex = 15; - this.StopStateLight1.UseVisualStyleBackColor = false; + this.label1.AutoSize = true; + this.label1.BackColor = System.Drawing.Color.Silver; + this.label1.Location = new System.Drawing.Point(63, 106); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(74, 42); + this.label1.TabIndex = 20; + this.label1.Text = "启动状态\r\n指示灯"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // TestBtn // @@ -299,19 +296,6 @@ namespace BRS.Process.A020.UI this.TestBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.TestBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); // - // Setting - // - this.Setting.Cursor = System.Windows.Forms.Cursors.Hand; - this.Setting.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.Setting.Location = new System.Drawing.Point(17, 380); - this.Setting.MinimumSize = new System.Drawing.Size(1, 1); - this.Setting.Name = "Setting"; - this.Setting.Size = new System.Drawing.Size(120, 45); - this.Setting.TabIndex = 13; - this.Setting.Text = "扭矩设置"; - this.Setting.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.Setting.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - // // AutoLoosenBtn1 // this.AutoLoosenBtn1.Cursor = System.Windows.Forms.Cursors.Hand; @@ -398,25 +382,6 @@ namespace BRS.Process.A020.UI this.StartBtn1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); this.StartBtn1.Click += new System.EventHandler(this.StartBtn1_Click); // - // MoveStateLight1 - // - this.MoveStateLight1.BackColor = System.Drawing.Color.Gray; - this.MoveStateLight1.Location = new System.Drawing.Point(67, 39); - this.MoveStateLight1.Name = "MoveStateLight1"; - this.MoveStateLight1.Size = new System.Drawing.Size(75, 64); - this.MoveStateLight1.TabIndex = 3; - this.MoveStateLight1.UseVisualStyleBackColor = false; - // - // ESBtn - // - this.ESBtn.BackColor = System.Drawing.Color.Red; - this.ESBtn.Location = new System.Drawing.Point(45, 185); - this.ESBtn.Name = "ESBtn"; - this.ESBtn.Size = new System.Drawing.Size(111, 102); - this.ESBtn.TabIndex = 0; - this.ESBtn.Text = "急停"; - this.ESBtn.UseVisualStyleBackColor = false; - // // AutoLoosenBtn // this.AutoLoosenBtn.Cursor = System.Windows.Forms.Cursors.Hand; @@ -508,49 +473,110 @@ namespace BRS.Process.A020.UI this.timer2.Interval = 1000; this.timer2.Tick += new System.EventHandler(this.timer2_Tick); // - // label1 + // textBox1 // - this.label1.AutoSize = true; - this.label1.BackColor = System.Drawing.Color.Silver; - this.label1.Location = new System.Drawing.Point(63, 106); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(74, 42); - this.label1.TabIndex = 20; - this.label1.Text = "启动状态\r\n指示灯"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.textBox1.Location = new System.Drawing.Point(132, 383); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(141, 45); + this.textBox1.TabIndex = 24; + this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // - // label2 + // label5 // - this.label2.AutoSize = true; - this.label2.BackColor = System.Drawing.Color.Silver; - this.label2.Location = new System.Drawing.Point(207, 106); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(74, 42); - this.label2.TabIndex = 21; - this.label2.Text = "停止状态\r\n指示灯"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.label5.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(12, 383); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(114, 45); + this.label5.TabIndex = 25; + this.label5.Text = "扭矩设置:"; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // label3 + // OKBtn // - this.label3.AutoSize = true; - this.label3.BackColor = System.Drawing.Color.Silver; - this.label3.Location = new System.Drawing.Point(326, 106); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(106, 42); - this.label3.TabIndex = 22; - this.label3.Text = "手动拧紧状态\r\n指示灯"; - this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.OKBtn.Cursor = System.Windows.Forms.Cursors.Hand; + this.OKBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.OKBtn.Location = new System.Drawing.Point(279, 383); + this.OKBtn.MinimumSize = new System.Drawing.Size(1, 1); + this.OKBtn.Name = "OKBtn"; + this.OKBtn.Size = new System.Drawing.Size(100, 45); + this.OKBtn.TabIndex = 26; + this.OKBtn.Text = "确定"; + this.OKBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.OKBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.OKBtn.Click += new System.EventHandler(this.OKBtn_Click); // - // label4 + // ManualBtn1 // - this.label4.AutoSize = true; - this.label4.BackColor = System.Drawing.Color.Silver; - this.label4.Location = new System.Drawing.Point(480, 106); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(106, 42); - this.label4.TabIndex = 23; - this.label4.Text = "手动拧松状态\r\n指示灯"; - this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.ManualBtn1.BackColor = System.Drawing.Color.Gray; + this.ManualBtn1.Cursor = System.Windows.Forms.Cursors.Hand; + this.ManualBtn1.Location = new System.Drawing.Point(484, 323); + this.ManualBtn1.Name = "ManualBtn1"; + this.ManualBtn1.Size = new System.Drawing.Size(58, 50); + this.ManualBtn1.TabIndex = 19; + this.ManualBtn1.Text = "手动按钮"; + this.ManualBtn1.UseVisualStyleBackColor = false; + this.ManualBtn1.Click += new System.EventHandler(this.ManualBtn1_Click); + // + // AutoBtn1 + // + this.AutoBtn1.BackColor = System.Drawing.Color.Gray; + this.AutoBtn1.Cursor = System.Windows.Forms.Cursors.Hand; + this.AutoBtn1.Location = new System.Drawing.Point(420, 323); + this.AutoBtn1.Name = "AutoBtn1"; + this.AutoBtn1.Size = new System.Drawing.Size(58, 50); + this.AutoBtn1.TabIndex = 18; + this.AutoBtn1.Text = "自动按钮"; + this.AutoBtn1.UseVisualStyleBackColor = false; + this.AutoBtn1.Click += new System.EventHandler(this.AutoBtn1_Click); + // + // LoosenLight1 + // + this.LoosenLight1.BackColor = System.Drawing.Color.Gray; + this.LoosenLight1.Location = new System.Drawing.Point(491, 39); + this.LoosenLight1.Name = "LoosenLight1"; + this.LoosenLight1.Size = new System.Drawing.Size(75, 64); + this.LoosenLight1.TabIndex = 17; + this.LoosenLight1.UseVisualStyleBackColor = false; + // + // ToughLight1 + // + this.ToughLight1.BackColor = System.Drawing.Color.Gray; + this.ToughLight1.Location = new System.Drawing.Point(341, 39); + this.ToughLight1.Name = "ToughLight1"; + this.ToughLight1.Size = new System.Drawing.Size(75, 64); + this.ToughLight1.TabIndex = 16; + this.ToughLight1.UseVisualStyleBackColor = false; + // + // StopStateLight1 + // + this.StopStateLight1.BackColor = System.Drawing.Color.Gray; + this.StopStateLight1.Location = new System.Drawing.Point(211, 39); + this.StopStateLight1.Name = "StopStateLight1"; + this.StopStateLight1.Size = new System.Drawing.Size(75, 64); + this.StopStateLight1.TabIndex = 15; + this.StopStateLight1.UseVisualStyleBackColor = false; + // + // MoveStateLight1 + // + this.MoveStateLight1.BackColor = System.Drawing.Color.Gray; + this.MoveStateLight1.Location = new System.Drawing.Point(67, 39); + this.MoveStateLight1.Name = "MoveStateLight1"; + this.MoveStateLight1.Size = new System.Drawing.Size(75, 64); + this.MoveStateLight1.TabIndex = 3; + this.MoveStateLight1.UseVisualStyleBackColor = false; + // + // ESBtn + // + this.ESBtn.BackColor = System.Drawing.Color.Red; + this.ESBtn.Cursor = System.Windows.Forms.Cursors.Hand; + this.ESBtn.Location = new System.Drawing.Point(45, 185); + this.ESBtn.Name = "ESBtn"; + this.ESBtn.Size = new System.Drawing.Size(111, 102); + this.ESBtn.TabIndex = 0; + this.ESBtn.Text = "急停"; + this.ESBtn.UseVisualStyleBackColor = false; + this.ESBtn.Click += new System.EventHandler(this.ESBtn_Click); // // 扭矩轴控制 // @@ -602,7 +628,6 @@ namespace BRS.Process.A020.UI private CircleButton ToughLight1; private CircleButton StopStateLight1; private Sunny.UI.UIButton TestBtn; - private Sunny.UI.UIButton Setting; private Sunny.UI.UIButton AutoLoosenBtn1; private Sunny.UI.UIButton AutoToughBtn1; private Sunny.UI.UIButton ManualLoosenBtn; @@ -616,5 +641,8 @@ namespace BRS.Process.A020.UI private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Label label5; + private Sunny.UI.UIButton OKBtn; } } \ No newline at end of file diff --git a/src/BRS.Process.A020/UI/ContorlShaft.cs b/src/BRS.Process.A020/UI/ContorlShaft.cs index e62f12c..4897000 100644 --- a/src/BRS.Process.A020/UI/ContorlShaft.cs +++ b/src/BRS.Process.A020/UI/ContorlShaft.cs @@ -28,7 +28,7 @@ namespace BRS.Process.A020.UI private bool is_btn_manual { get; set; } = false;//是否手动 private bool isOpenAuto { get; set; } = false;//是否正在自动操作 int resValue1; - int resValue2; + int resValue2; A020Process ProcessA020 => Process as A020Process; A020Config Config => Process?.IConfig as A020Config; @@ -38,7 +38,6 @@ namespace BRS.Process.A020.UI public 扭矩轴控制() { InitializeComponent(); - } public IDevice Device { get; set; } protected PLCBase PLC @@ -192,7 +191,7 @@ namespace BRS.Process.A020.UI this.chart2.Series[0].Points.AddXY(DateTime.Now.ToOADate(), ProcessReadInt(MelsecPlc, "D251", "int")); this.chart2.ChartAreas[0].AxisX.Maximum = DateTime.Now.AddSeconds(1).ToOADate();//X坐标后移1秒 this.chart2.ChartAreas[0].AxisX.Minimum = DateTime.Now.AddSeconds(-5).ToOADate();//此刻后十秒钟作为最初X轴 - + this.chart1.Series[0].Points.AddXY(DateTime.Now.ToOADate(), ProcessReadInt(MelsecPlc, "D351", "int")); this.chart1.ChartAreas[0].AxisX.Maximum = DateTime.Now.AddSeconds(1).ToOADate();//X坐标后移1秒 this.chart1.ChartAreas[0].AxisX.Minimum = DateTime.Now.AddSeconds(-5).ToOADate();//此刻后十秒钟作为最初X轴 @@ -533,41 +532,12 @@ namespace BRS.Process.A020.UI { var MelsecPLC = ProcessA020.DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; ProcessWriteInt(MelsecPLC, "D3", "int", "1"); - ProcessWriteInt(MelsecPLC, "D7", "int", "0"); - if (Process == null) - { - MessageBox.Show("无法操作空流程"); - return; - } - StopBtn2.Enabled = false; - try - { - ProcessOperation(false); - //if (isStart) - //{ - // await ProcessOperation(false); - //} - } - catch (Exception ex) - { - //MessageBox.Show(ex.GetExceptionMessage()); - } - finally - { - this.StopStateLight1.BackColor = Color.Red; - this.MoveStateLight1.BackColor = Color.Gray; - this.ToughLight1.BackColor = Color.Gray; - this.LoosenLight1.BackColor = Color.Gray; - //将自动手动按钮颜色恢复为灰色 - this.AutoBtn1.BackColor = Color.Gray; - this.ManualBtn1.BackColor = Color.Gray; - //点击停止后初始化图表 - InitChart(); - timer1.Stop(); - timer2.Stop(); - StopBtn2.Enabled = true; - isOpenAuto = false; - } + //ProcessWriteInt(MelsecPLC, "D7", "int", "0"); + this.StopStateLight1.BackColor = Color.Red; + this.MoveStateLight1.BackColor = Color.Gray; + timer1.Stop(); + timer2.Stop(); + isOpenAuto = false; } /// /// 手动拧紧鼠标按下 @@ -727,7 +697,6 @@ namespace BRS.Process.A020.UI { LogAsync(DateTime.Now, LogLevel.Error, "当前流程未启动,无法选择操作模式"); } - } private void ManualBtn1_Click(object sender, EventArgs e) { @@ -745,16 +714,13 @@ namespace BRS.Process.A020.UI AutoBtn1.BackColor = Color.Gray; ManualBtn1.BackColor = Color.GreenYellow; } - } else if (StopStateLight1.BackColor == Color.Red) { LogAsync(DateTime.Now, LogLevel.Error, "当前流程未启动,无法选择操作模式"); } is_btn_manual = true; - } - /// /// 自动拧紧 /// @@ -786,7 +752,6 @@ namespace BRS.Process.A020.UI } else { - LogAsync(DateTime.Now, LogLevel.Error, $"未打到自动状态"); } } @@ -794,7 +759,6 @@ namespace BRS.Process.A020.UI { LogAsync(DateTime.Now, LogLevel.Error, $"当前流程未启动"); } - } /// /// 自动拧松 @@ -851,5 +815,54 @@ namespace BRS.Process.A020.UI return; } } + /// + /// 急停按钮,结束PLC连接,停止流程 + /// + /// + /// + private void ESBtn_Click(object sender, EventArgs e) + { + var MelsecPLC = ProcessA020.DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + ProcessWriteInt(MelsecPLC, "D3", "int", "1");//D3写入1,使上位机停止 + ProcessWriteInt(MelsecPLC, "D7", "int", "0"); + if (Process == null) + { + MessageBox.Show("无法操作空流程"); + return; + } + try + { + ProcessOperation(false); + //if (isStart) + //{ + // await ProcessOperation(false); + //} + } + catch (Exception ex) + { + //MessageBox.Show(ex.GetExceptionMessage()); + } + finally + { + this.StopStateLight1.BackColor = Color.Gray; + this.MoveStateLight1.BackColor = Color.Gray; + this.ToughLight1.BackColor = Color.Gray; + this.LoosenLight1.BackColor = Color.Gray; + //将自动手动按钮颜色恢复为灰色 + this.AutoBtn1.BackColor = Color.Gray; + this.ManualBtn1.BackColor = Color.Gray; + //点击停止后初始化图表 + InitChart(); + timer1.Stop(); + timer2.Stop(); + isOpenAuto = false; + } + } + + private void OKBtn_Click(object sender, EventArgs e) + { + var MelsecPLC = ProcessA020.DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + ProcessWriteInt(MelsecPLC, "D171", "int", textBox1.Text); + } } }