From 1e5327bc4804f40adf589af880887654822e24c2 Mon Sep 17 00:00:00 2001 From: 17860779768 <3219079380@qq.com> Date: Tue, 14 Mar 2023 08:41:59 +0800 Subject: [PATCH] 20230314Change --- src/BRS.Process.A020/A020Process_Operation.cs | 187 ++++++-- .../UI/ContorlShaft.Designer.cs | 436 ++++++++++-------- src/BRS.Process.A020/UI/ContorlShaft.cs | 194 ++++++-- src/BRS.Process.A020/UI/ContorlShaft.resx | 3 + src/BRS.UI.Main/Properties/AssemblyInfo.cs | 3 +- 5 files changed, 569 insertions(+), 254 deletions(-) diff --git a/src/BRS.Process.A020/A020Process_Operation.cs b/src/BRS.Process.A020/A020Process_Operation.cs index ce5eae4..42af1ac 100644 --- a/src/BRS.Process.A020/A020Process_Operation.cs +++ b/src/BRS.Process.A020/A020Process_Operation.cs @@ -789,7 +789,6 @@ namespace BRS.Process.A020 } - public class DistanceRobot { public double testDs { get; set; } @@ -884,7 +883,6 @@ namespace BRS.Process.A020 return strRobotPoint; } - //private void Pause() //{ // while (MachineState == MachineState.Pause) @@ -893,8 +891,6 @@ namespace BRS.Process.A020 // continue; // } //} - - private bool isMachineRobotRunning() { //if(MachineState == MachineState.Running && RobotsStatus != RobotsStatus.Pweroff) @@ -1667,6 +1663,11 @@ namespace BRS.Process.A020 PubSubCenter.GetInstance().Publish(PubSubCenterMessageType.IsProcessOpened.ToString(), true, null); return new ProcessResponse(true); } + #region 手动操作流程 + /// + /// 手动拧紧鼠标按下 + /// + /// public void ShaftRightMouseDown(MachineState machineState) { if (machineState != MachineState.Ready) @@ -1726,19 +1727,18 @@ namespace BRS.Process.A020 LogAsync(DateTime.Now, LogLevel.Warning, "通讯故障!"); return; } - } - }); Task.Run(() => { - ShaftOperateOnce(MelsecPLC, addD1, 500);//D1置1延时500后置0 - }); - IsSingleStepOperating = false; } + /// + /// 手动拧松鼠标按下 + /// + /// public void ShaftLeftMouseDown(MachineState machineState) { if (machineState != MachineState.Ready) @@ -1749,7 +1749,6 @@ namespace BRS.Process.A020 LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候..."); var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; - string addD201 = "D201";//通讯故障检查地址 string addD19 = "D19";//急停状态检查地址 string addD1 = "D1";//上位机启动标志位 @@ -1812,16 +1811,18 @@ namespace BRS.Process.A020 IsSingleStepOperating = false; } - + /// + /// 手动拧紧鼠标抬起 + /// + /// public void ShaftRightMouseUp(MachineState machineState) { - - if (machineState != MachineState.Ready) - { - LogAsync(DateTime.Now, LogLevel.Error, "机台不在就绪状态,无法启动"); - return; - } - LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候..."); + //if (machineState != MachineState.Ready) + //{ + // LogAsync(DateTime.Now, LogLevel.Error, "机台不在就绪状态,无法启动"); + // return; + //} + //LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候..."); var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; @@ -1858,12 +1859,9 @@ namespace BRS.Process.A020 { ProcessWriteInt(MelsecPLC, addD3, "int", "1");//D3置0 - ProcessWriteInt(MelsecPLC, addD51, "int", "0");//手动拧紧螺丝D51置1 - machineState = MachineState.Pause;//设备暂停 LogAsync(DateTime.Now, LogLevel.Detail, "设备已关闭"); - } ShaftCommunication = ProcessReadInt(MelsecPLC, addD201, "int"); continue; @@ -1873,24 +1871,24 @@ namespace BRS.Process.A020 LogAsync(DateTime.Now, LogLevel.Warning, "通讯故障!"); return; } - } - }); IsSingleStepOperating = false; } + /// + /// 手动拧松鼠标抬起 + /// + /// public void ShaftLeftMouseUp(MachineState machineState) { - - if (machineState != MachineState.Ready) - { - LogAsync(DateTime.Now, LogLevel.Error, "机台不在就绪状态,无法启动"); - return; - } - LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候..."); - + //if (machineState != MachineState.Ready) + //{ + // LogAsync(DateTime.Now, LogLevel.Error, "机台不在就绪状态,无法启动"); + // return; + //} + //LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候..."); var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; string addD201 = "D201";//通讯故障检查地址 @@ -1926,13 +1924,9 @@ namespace BRS.Process.A020 else { ProcessWriteInt(MelsecPLC, addD3, "int", "1");//D3置0 - - - ProcessWriteInt(MelsecPLC, addD53, "int", "0");//手动拧紧螺丝D51置1 - + ProcessWriteInt(MelsecPLC, addD53, "int", "0");//手动拧紧螺丝D53置0 machineState = MachineState.Pause;//设备暂停 LogAsync(DateTime.Now, LogLevel.Detail, "设备已关闭"); - } ShaftCommunication = ProcessReadInt(MelsecPLC, addD201, "int"); continue; @@ -1950,6 +1944,123 @@ namespace BRS.Process.A020 IsSingleStepOperating = false; } + #endregion + + #region 自动操作流程 + /// + /// 自动拧紧 + /// + public void ShaftAutoTough(MachineState machineState) + { + if (machineState != MachineState.Ready) + { + LogAsync(DateTime.Now, LogLevel.Error, "机台不在就绪状态,无法启动"); + return; + } + LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候..."); + //设置PLC + var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + string addressD07 = ProcessReadInt(MelsecPLC, "D07", "int"); + //string ShaftCommunication = ProcessReadInt(MelsecPLC, "D201", "int");//通讯 + + machineState = MachineState.Running; + ProcessStatus = ProcessStatus.Init; + MachineStateStep = MachineStateStep.Ready; + Task.Run(()=> + { + while (machineState == MachineState.Running && MachineStateStep != MachineStateStep.Pause) + { + string ShaftCommunication = ProcessReadInt(MelsecPLC, "D201", "int");//通讯 + if (ShaftCommunication == "111")//如果等于111,流程启动 + { + string ShaftEmergencyStop = ProcessReadInt(MelsecPLC, "D19", "int");//急停 + if (ShaftEmergencyStop != "0")//判断是否急停,0不急停,1急停 + { + LogAsync(DateTime.Now, LogLevel.Warning, "设备急停!"); + //Thread.Sleep(2000); + return; + } + else + { + ProcessWriteInt(MelsecPLC, "D3", "int", "0");//D3置0 + ProcessWriteInt(MelsecPLC, "D171", "int", "3000");//最大扭矩3000 + ProcessWriteInt(MelsecPLC, "D51", "int", "1");//手动拧紧螺丝D51置1 + machineState = MachineState.Waiting;//设备启动完成后保持状态 + LogAsync(DateTime.Now, LogLevel.Detail, "设备已启动,请勿其他操作!!"); + } + } + } + }); + Task.Run(() => + { + ShaftOperateOnce(MelsecPLC, "D1", 500);//D1置1延时500后置0 + }); + IsSingleStepOperating = false; + } + /// + /// 自动拧松流程 + /// + /// + public void ShaftAutoLoosen(MachineState machineState) + { + if (machineState != MachineState.Ready) + { + LogAsync(DateTime.Now, LogLevel.Error, "机台不在就绪状态,无法启动"); + return; + } + LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候..."); + //设置PLC + var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + string addressD07 = ProcessReadInt(MelsecPLC, "D07", "int"); + //string ShaftCommunication = ProcessReadInt(MelsecPLC, "D201", "int");//通讯 + + machineState = MachineState.Running; + ProcessStatus = ProcessStatus.Init; + MachineStateStep = MachineStateStep.Ready; + Task.Run(() => + { + while (machineState == MachineState.Running && MachineStateStep != MachineStateStep.Pause) + { + string ShaftCommunication = ProcessReadInt(MelsecPLC, "D201", "int");//通讯 + if (ShaftCommunication == "111")//如果等于111,流程启动 + { + string ShaftEmergencyStop = ProcessReadInt(MelsecPLC, "D19", "int");//急停 + if (ShaftEmergencyStop != "0")//判断是否急停,0不急停,1急停 + { + LogAsync(DateTime.Now, LogLevel.Warning, "设备急停!"); + //Thread.Sleep(2000); + return; + } + else + { + ProcessWriteInt(MelsecPLC, "D3", "int", "0");//D3置0 + ProcessWriteInt(MelsecPLC, "D171", "int", "3000");//最大扭矩3000 + ProcessWriteInt(MelsecPLC, "D53", "int", "1");//手动拧紧螺丝D51置1 + machineState = MachineState.Waiting;//设备启动完成后保持状态 + LogAsync(DateTime.Now, LogLevel.Detail, "设备已启动,请勿其他操作!!"); + } + } + } + }); + Task.Run(() => + { + ShaftOperateOnce(MelsecPLC, "D1", 500);//D1置1延时500后置0 + }); + IsSingleStepOperating = false; + } + + /// + /// 到位或急停后停止 + /// + public void StopProcess() + { + var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + ProcessWriteInt(MelsecPLC, "D3", "int", "1");//D3置0 + ProcessWriteInt(MelsecPLC, "D53", "int", "0");//手动拧紧螺丝D53置0 + } + #endregion + + /// /// 进入自动化控制进程,完成系列动作 /// @@ -2341,13 +2452,10 @@ namespace BRS.Process.A020 default: break; } - sw.Stop(); - // lblElapsed.Text = sw.ElapsedMilliseconds.ToString(); } - private void ProcessStartTimer(object state) { //isMidFeedingProductFlag = true; @@ -2578,6 +2686,5 @@ namespace BRS.Process.A020 // MachineState = MachineState.Ready; return new ProcessResponse(true); } - } } diff --git a/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs b/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs index 039b34d..f6b4296 100644 --- a/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs +++ b/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs @@ -46,6 +46,21 @@ 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.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(); @@ -53,21 +68,11 @@ namespace BRS.Process.A020.UI this.timer1 = new System.Windows.Forms.Timer(this.components); this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.uiButton1 = new Sunny.UI.UIButton(); - this.StartBtn1 = new Sunny.UI.UIButton(); - this.StopBtn2 = new Sunny.UI.UIButton(); - this.ManualToughBtn = new Sunny.UI.UIButton(); - this.ManualLoosenBtn = new Sunny.UI.UIButton(); - this.AutoToughBtn1 = new Sunny.UI.UIButton(); - this.AutoLoosenBtn1 = new Sunny.UI.UIButton(); - this.Setting = new Sunny.UI.UIButton(); - this.TestBtn = 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(); + 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(); ((System.ComponentModel.ISupportInitialize)(this.chart2)).BeginInit(); this.uiPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); @@ -199,6 +204,10 @@ namespace BRS.Process.A020.UI // // uiPanel1 // + this.uiPanel1.Controls.Add(this.label4); + this.uiPanel1.Controls.Add(this.label3); + this.uiPanel1.Controls.Add(this.label2); + this.uiPanel1.Controls.Add(this.label1); this.uiPanel1.Controls.Add(this.ManualBtn1); this.uiPanel1.Controls.Add(this.AutoBtn1); this.uiPanel1.Controls.Add(this.LoosenLight1); @@ -226,6 +235,188 @@ namespace BRS.Process.A020.UI this.uiPanel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; this.uiPanel1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); // + // ManualBtn1 + // + 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; + // + // TestBtn + // + this.TestBtn.Cursor = System.Windows.Forms.Cursors.Hand; + this.TestBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.TestBtn.Location = new System.Drawing.Point(12, 508); + this.TestBtn.MinimumSize = new System.Drawing.Size(1, 1); + this.TestBtn.Name = "TestBtn"; + this.TestBtn.Size = new System.Drawing.Size(100, 35); + this.TestBtn.TabIndex = 14; + this.TestBtn.Text = "测试按钮"; + 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; + this.AutoLoosenBtn1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.AutoLoosenBtn1.Location = new System.Drawing.Point(420, 450); + this.AutoLoosenBtn1.MinimumSize = new System.Drawing.Size(1, 1); + this.AutoLoosenBtn1.Name = "AutoLoosenBtn1"; + this.AutoLoosenBtn1.Size = new System.Drawing.Size(120, 45); + this.AutoLoosenBtn1.TabIndex = 12; + this.AutoLoosenBtn1.Text = "自动拧松"; + this.AutoLoosenBtn1.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.AutoLoosenBtn1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.AutoLoosenBtn1.Click += new System.EventHandler(this.AutoLoosenBtn1_Click); + // + // AutoToughBtn1 + // + this.AutoToughBtn1.Cursor = System.Windows.Forms.Cursors.Hand; + this.AutoToughBtn1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.AutoToughBtn1.Location = new System.Drawing.Point(420, 393); + this.AutoToughBtn1.MinimumSize = new System.Drawing.Size(1, 1); + this.AutoToughBtn1.Name = "AutoToughBtn1"; + this.AutoToughBtn1.Size = new System.Drawing.Size(120, 45); + this.AutoToughBtn1.TabIndex = 11; + this.AutoToughBtn1.Text = "自动拧紧"; + this.AutoToughBtn1.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.AutoToughBtn1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.AutoToughBtn1.Click += new System.EventHandler(this.AutoToughBtn1_Click); + // + // ManualLoosenBtn + // + this.ManualLoosenBtn.Cursor = System.Windows.Forms.Cursors.Hand; + this.ManualLoosenBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.ManualLoosenBtn.Location = new System.Drawing.Point(420, 258); + this.ManualLoosenBtn.MinimumSize = new System.Drawing.Size(1, 1); + this.ManualLoosenBtn.Name = "ManualLoosenBtn"; + this.ManualLoosenBtn.Size = new System.Drawing.Size(120, 45); + this.ManualLoosenBtn.TabIndex = 10; + this.ManualLoosenBtn.Text = "手动拧松"; + this.ManualLoosenBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.ManualLoosenBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.ManualLoosenBtn.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ManualLoosenBtn_MouseDown); + this.ManualLoosenBtn.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ManualLoosenBtn_MouseUp); + // + // ManualToughBtn + // + this.ManualToughBtn.Cursor = System.Windows.Forms.Cursors.Hand; + this.ManualToughBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.ManualToughBtn.Location = new System.Drawing.Point(420, 185); + this.ManualToughBtn.MinimumSize = new System.Drawing.Size(1, 1); + this.ManualToughBtn.Name = "ManualToughBtn"; + this.ManualToughBtn.Size = new System.Drawing.Size(120, 45); + this.ManualToughBtn.TabIndex = 9; + this.ManualToughBtn.Text = "手动拧紧"; + this.ManualToughBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.ManualToughBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.ManualToughBtn.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ManualToughBtn_MouseDown); + this.ManualToughBtn.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ManualToughBtn_MouseUp); + // + // StopBtn2 + // + this.StopBtn2.Cursor = System.Windows.Forms.Cursors.Hand; + this.StopBtn2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.StopBtn2.Location = new System.Drawing.Point(215, 258); + this.StopBtn2.MinimumSize = new System.Drawing.Size(1, 1); + this.StopBtn2.Name = "StopBtn2"; + this.StopBtn2.Size = new System.Drawing.Size(120, 45); + this.StopBtn2.TabIndex = 8; + this.StopBtn2.Text = "停止"; + this.StopBtn2.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.StopBtn2.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.StopBtn2.Click += new System.EventHandler(this.StopBtn2_Click); + // + // StartBtn1 + // + this.StartBtn1.Cursor = System.Windows.Forms.Cursors.Hand; + this.StartBtn1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.StartBtn1.Location = new System.Drawing.Point(215, 185); + this.StartBtn1.MinimumSize = new System.Drawing.Size(1, 1); + this.StartBtn1.Name = "StartBtn1"; + this.StartBtn1.Size = new System.Drawing.Size(120, 45); + this.StartBtn1.TabIndex = 7; + this.StartBtn1.Text = "开始"; + this.StartBtn1.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + 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; @@ -312,185 +503,54 @@ namespace BRS.Process.A020.UI this.uiButton1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); this.uiButton1.Click += new System.EventHandler(this.uiButton1_Click); // - // StartBtn1 + // timer2 // - this.StartBtn1.Cursor = System.Windows.Forms.Cursors.Hand; - this.StartBtn1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.StartBtn1.Location = new System.Drawing.Point(199, 156); - this.StartBtn1.MinimumSize = new System.Drawing.Size(1, 1); - this.StartBtn1.Name = "StartBtn1"; - this.StartBtn1.Size = new System.Drawing.Size(100, 35); - this.StartBtn1.TabIndex = 7; - this.StartBtn1.Text = "开始"; - this.StartBtn1.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.StartBtn1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - this.StartBtn1.Click += new System.EventHandler(this.StartBtn1_Click); + this.timer2.Interval = 1000; + this.timer2.Tick += new System.EventHandler(this.timer2_Tick); // - // StopBtn2 + // label1 // - this.StopBtn2.Cursor = System.Windows.Forms.Cursors.Hand; - this.StopBtn2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.StopBtn2.Location = new System.Drawing.Point(199, 229); - this.StopBtn2.MinimumSize = new System.Drawing.Size(1, 1); - this.StopBtn2.Name = "StopBtn2"; - this.StopBtn2.Size = new System.Drawing.Size(100, 35); - this.StopBtn2.TabIndex = 8; - this.StopBtn2.Text = "停止"; - this.StopBtn2.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.StopBtn2.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - this.StopBtn2.Click += new System.EventHandler(this.StopBtn2_Click); + 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; // - // ManualToughBtn + // label2 // - this.ManualToughBtn.Cursor = System.Windows.Forms.Cursors.Hand; - this.ManualToughBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.ManualToughBtn.Location = new System.Drawing.Point(420, 156); - this.ManualToughBtn.MinimumSize = new System.Drawing.Size(1, 1); - this.ManualToughBtn.Name = "ManualToughBtn"; - this.ManualToughBtn.Size = new System.Drawing.Size(100, 35); - this.ManualToughBtn.TabIndex = 9; - this.ManualToughBtn.Text = "手动拧紧"; - this.ManualToughBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.ManualToughBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - this.ManualToughBtn.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ManualToughBtn_MouseDown); - this.ManualToughBtn.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ManualToughBtn_MouseUp); + 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; // - // ManualLoosenBtn + // label3 // - this.ManualLoosenBtn.Cursor = System.Windows.Forms.Cursors.Hand; - this.ManualLoosenBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.ManualLoosenBtn.Location = new System.Drawing.Point(420, 229); - this.ManualLoosenBtn.MinimumSize = new System.Drawing.Size(1, 1); - this.ManualLoosenBtn.Name = "ManualLoosenBtn"; - this.ManualLoosenBtn.Size = new System.Drawing.Size(100, 35); - this.ManualLoosenBtn.TabIndex = 10; - this.ManualLoosenBtn.Text = "手动拧松"; - this.ManualLoosenBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.ManualLoosenBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - this.ManualLoosenBtn.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ManualLoosenBtn_MouseDown); - this.ManualLoosenBtn.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ManualLoosenBtn_MouseUp); + 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; // - // AutoToughBtn1 + // label4 // - this.AutoToughBtn1.Cursor = System.Windows.Forms.Cursors.Hand; - this.AutoToughBtn1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.AutoToughBtn1.Location = new System.Drawing.Point(420, 364); - this.AutoToughBtn1.MinimumSize = new System.Drawing.Size(1, 1); - this.AutoToughBtn1.Name = "AutoToughBtn1"; - this.AutoToughBtn1.Size = new System.Drawing.Size(100, 35); - this.AutoToughBtn1.TabIndex = 11; - this.AutoToughBtn1.Text = "自动拧紧"; - this.AutoToughBtn1.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.AutoToughBtn1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - // - // AutoLoosenBtn1 - // - this.AutoLoosenBtn1.Cursor = System.Windows.Forms.Cursors.Hand; - this.AutoLoosenBtn1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.AutoLoosenBtn1.Location = new System.Drawing.Point(420, 421); - this.AutoLoosenBtn1.MinimumSize = new System.Drawing.Size(1, 1); - this.AutoLoosenBtn1.Name = "AutoLoosenBtn1"; - this.AutoLoosenBtn1.Size = new System.Drawing.Size(100, 35); - this.AutoLoosenBtn1.TabIndex = 12; - this.AutoLoosenBtn1.Text = "自动拧松"; - this.AutoLoosenBtn1.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.AutoLoosenBtn1.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(199, 299); - this.Setting.MinimumSize = new System.Drawing.Size(1, 1); - this.Setting.Name = "Setting"; - this.Setting.Size = new System.Drawing.Size(100, 35); - 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); - // - // TestBtn - // - this.TestBtn.Cursor = System.Windows.Forms.Cursors.Hand; - this.TestBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.TestBtn.Location = new System.Drawing.Point(27, 457); - this.TestBtn.MinimumSize = new System.Drawing.Size(1, 1); - this.TestBtn.Name = "TestBtn"; - this.TestBtn.Size = new System.Drawing.Size(100, 35); - this.TestBtn.TabIndex = 14; - this.TestBtn.Text = "测试按钮"; - 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); - // - // ManualBtn1 - // - this.ManualBtn1.BackColor = System.Drawing.Color.Gray; - this.ManualBtn1.Cursor = System.Windows.Forms.Cursors.Hand; - this.ManualBtn1.Location = new System.Drawing.Point(491, 284); - 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(398, 284); - 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.Location = new System.Drawing.Point(46, 147); - 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.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; // // 扭矩轴控制 // @@ -505,6 +565,7 @@ namespace BRS.Process.A020.UI this.Load += new System.EventHandler(this.扭矩轴控制_Load); ((System.ComponentModel.ISupportInitialize)(this.chart2)).EndInit(); this.uiPanel1.ResumeLayout(false); + this.uiPanel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); this.ResumeLayout(false); @@ -550,5 +611,10 @@ namespace BRS.Process.A020.UI private Sunny.UI.UIButton StartBtn1; private CircleButton MoveStateLight1; private CircleButton ESBtn; + private System.Windows.Forms.Timer timer2; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; } } \ 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 ca2afa8..e62f12c 100644 --- a/src/BRS.Process.A020/UI/ContorlShaft.cs +++ b/src/BRS.Process.A020/UI/ContorlShaft.cs @@ -20,17 +20,20 @@ using static BRS.Common.Model.Helper.EnumHelper; namespace BRS.Process.A020.UI { [MenuNode("ControlShaft", "扭矩轴控制", 5, "View2", true)] + public partial class 扭矩轴控制 : MenuFormBase, IRunCtrl { - - private DateTime X_minValue;//横坐标最初值 - - private bool is_btn_manual { get; set; } = false; + + private bool is_btn_manual { get; set; } = false;//是否手动 + private bool isOpenAuto { get; set; } = false;//是否正在自动操作 + int resValue1; + int resValue2; A020Process ProcessA020 => Process as A020Process; A020Config Config => Process?.IConfig as A020Config; - private bool isSingleStepOperating = false; + //private bool isSingleStepOperating = false; + public 扭矩轴控制() { @@ -52,11 +55,11 @@ namespace BRS.Process.A020.UI } private async void StartBtn_Click(object sender, EventArgs e) { - + } private async void StopBtn_Click(object sender, EventArgs e) { - + } private void uiButton1_Click(object sender, EventArgs e) { @@ -141,8 +144,8 @@ namespace BRS.Process.A020.UI #endif private void ToughBtn_MouseDown(object sender, MouseEventArgs e) { - - + + } private void 扭矩轴控制_Load(object sender, EventArgs e) @@ -304,12 +307,12 @@ namespace BRS.Process.A020.UI //获取扭矩反馈值D251 高速计数器当前值D351 private void uiButton2_Click(object sender, EventArgs e) { - + //ShowdataLab.Text = ProcessReadInt(MelsecPlc, "D251", "int"); } private void ToughBtn_MouseUp(object sender, MouseEventArgs e) { - + } #if true /// @@ -448,12 +451,12 @@ namespace BRS.Process.A020.UI private void LoosenBtn_MouseDown(object sender, MouseEventArgs e) { - + } private void LoosenBtn_MouseUp(object sender, MouseEventArgs e) { - + } private void AutoBtn_Click(object sender, EventArgs e) @@ -462,11 +465,11 @@ namespace BRS.Process.A020.UI { this.AutoBtn.BackColor = Color.GreenYellow;//在流程可用时,点击按钮变颜色 this.manualBtn.BackColor = Color.Gray; - + } else LogAsync(DateTime.Now, LogLevel.Error, "流程未启动,无法选择"); - + } private void manualBtn_Click(object sender, EventArgs e) { @@ -503,11 +506,11 @@ namespace BRS.Process.A020.UI try { ProcessOperation(true);//点击开始按钮后执行 - //if (isStart) - //{ - // await ProcessOperation(true); - // //ProcessOperation(true); - //} + //if (isStart) + //{ + // await ProcessOperation(true); + // //ProcessOperation(true); + //} } catch (Exception ex) { @@ -528,12 +531,14 @@ namespace BRS.Process.A020.UI } private void StopBtn2_Click(object sender, EventArgs e) { + 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 { @@ -558,7 +563,10 @@ namespace BRS.Process.A020.UI this.ManualBtn1.BackColor = Color.Gray; //点击停止后初始化图表 InitChart(); + timer1.Stop(); + timer2.Stop(); StopBtn2.Enabled = true; + isOpenAuto = false; } } /// @@ -612,7 +620,7 @@ namespace BRS.Process.A020.UI { return; } - else if(MoveStateLight1.BackColor == Color.GreenYellow&&ManualBtn1.BackColor==Color.Gray) + else if (MoveStateLight1.BackColor == Color.GreenYellow && ManualBtn1.BackColor == Color.Gray) { return; } @@ -665,7 +673,7 @@ namespace BRS.Process.A020.UI return; } } - + } private void ManualLoosenBtn_MouseUp(object sender, MouseEventArgs e) { @@ -692,25 +700,155 @@ namespace BRS.Process.A020.UI LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); } } - + /// + /// 点击自动按钮 + /// + /// + /// private void AutoBtn1_Click(object sender, EventArgs e) { + var MelsecPLC = ProcessA020.DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + if (MoveStateLight1.BackColor == Color.GreenYellow) { - AutoBtn1.BackColor = Color.GreenYellow; - ManualBtn1.BackColor = Color.Gray; + if (isOpenAuto == true) + { + LogAsync(DateTime.Now, LogLevel.Error, "流程已启动,请勿重新启动!"); + } + else + { + ProcessWriteInt(MelsecPLC, "D7", "int", "1"); + AutoBtn1.BackColor = Color.GreenYellow; + ManualBtn1.BackColor = Color.Gray; + is_btn_manual = false; + } } else if (StopStateLight1.BackColor == Color.Red) { LogAsync(DateTime.Now, LogLevel.Error, "当前流程未启动,无法选择操作模式"); } + } private void ManualBtn1_Click(object sender, EventArgs e) { + var MelsecPLC = ProcessA020.DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + if (MoveStateLight1.BackColor == Color.GreenYellow) { - AutoBtn1.BackColor = Color.Gray; - ManualBtn1.BackColor = Color.GreenYellow; + if (isOpenAuto == true) + { + LogAsync(DateTime.Now, LogLevel.Error, "当前正在进行自动操作,请勿切换!"); + } + else + { + ProcessWriteInt(MelsecPLC, "D7", "int", "0"); + AutoBtn1.BackColor = Color.Gray; + ManualBtn1.BackColor = Color.GreenYellow; + } + + } + else if (StopStateLight1.BackColor == Color.Red) + { + LogAsync(DateTime.Now, LogLevel.Error, "当前流程未启动,无法选择操作模式"); + } + is_btn_manual = true; + + } + + /// + /// 自动拧紧 + /// + /// + /// + private void AutoToughBtn1_Click(object sender, EventArgs e) + { + var MelsecPLC = ProcessA020.DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + string addressD07 = ProcessReadInt(MelsecPLC, "D07", "int"); + if (MoveStateLight1.BackColor == Color.GreenYellow) + { + if (addressD07 == "1") + { + if (!ProcessA020.IsSingleStepOperating) + { + if (isOpenAuto == true) + { + LogAsync(DateTime.Now, LogLevel.Error, "流程已启动,请勿重新启动!"); + return; + } + isOpenAuto = true; + ProcessA020.IsSingleStepOperating = true; + ProcessA020.ShaftAutoTough(MachineState.Ready); + timer1.Start(); + timer2.Start(); + } + else + LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); + } + else + { + + LogAsync(DateTime.Now, LogLevel.Error, $"未打到自动状态"); + } + } + else + { + LogAsync(DateTime.Now, LogLevel.Error, $"当前流程未启动"); + } + + } + /// + /// 自动拧松 + /// + /// + /// + private void AutoLoosenBtn1_Click(object sender, EventArgs e) + { + var MelsecPLC = ProcessA020.DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + string addressD07 = ProcessReadInt(MelsecPLC, "D07", "int"); + if (MoveStateLight1.BackColor == Color.GreenYellow) + { + if (addressD07 == "1") + { + if (!ProcessA020.IsSingleStepOperating) + { + if (isOpenAuto == true) + { + LogAsync(DateTime.Now, LogLevel.Error, "流程已启动,请勿重新启动!"); + return; + } + isOpenAuto = true; + ProcessA020.IsSingleStepOperating = true; + ProcessA020.ShaftAutoLoosen(MachineState.Ready); + timer1.Start(); + timer2.Start(); + } + else + LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); + } + else + { + LogAsync(DateTime.Now, LogLevel.Error, $"未打到自动状态"); + } + } + else + { + LogAsync(DateTime.Now, LogLevel.Error, $"当前流程未启动"); + } + } + private void timer2_Tick(object sender, EventArgs e) + { + var MelsecPLC = ProcessA020.DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + string torsionValue = ProcessReadInt(MelsecPLC, "D251", "int"); + string angleValue = ProcessReadInt(MelsecPLC, "D351", "int"); + resValue1 = Convert.ToInt32(torsionValue);//将接收到的返回值转为int类型 + resValue2 = Convert.ToInt32(angleValue); + while (resValue1 >= 200 && resValue2 <= 6) + { + ProcessA020.StopProcess(); + LogAsync(DateTime.Now, LogLevel.Information, "已完成"); + timer2.Stop(); + timer1.Stop(); + return; } } } diff --git a/src/BRS.Process.A020/UI/ContorlShaft.resx b/src/BRS.Process.A020/UI/ContorlShaft.resx index acf2eb7..da0109c 100644 --- a/src/BRS.Process.A020/UI/ContorlShaft.resx +++ b/src/BRS.Process.A020/UI/ContorlShaft.resx @@ -120,6 +120,9 @@ 17, 17 + + 107, 17 + 45 diff --git a/src/BRS.UI.Main/Properties/AssemblyInfo.cs b/src/BRS.UI.Main/Properties/AssemblyInfo.cs index 5af7593..63c3677 100644 --- a/src/BRS.UI.Main/Properties/AssemblyInfo.cs +++ b/src/BRS.UI.Main/Properties/AssemblyInfo.cs @@ -4,7 +4,8 @@ using System.Runtime.InteropServices; // 有关程序集的一般信息由以下 // 控制。更改这些特性值可修改 // 与程序集关联的信息。 -[assembly: AssemblyTitle("磁环分选系统")] +//[assembly: AssemblyTitle("磁环分选系统")] +[assembly: AssemblyTitle("大扭矩拧紧轴操作系统")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")]