diff --git a/DH.Devices.PLC/XinJEPLCTcpNet.cs b/DH.Devices.PLC/XinJEPLCTcpNet.cs index 21dcf53..9b1c25c 100644 --- a/DH.Devices.PLC/XinJEPLCTcpNet.cs +++ b/DH.Devices.PLC/XinJEPLCTcpNet.cs @@ -760,6 +760,12 @@ namespace DH.Devices.PLC //LogAsync(DateTime.Now, LogLevel.Information, $"停止转盘"); //转盘使能 TurnEnable(true); + RedLight(false); + YellowLight(false); + //绿灯 + GreenLight(true); + + LogAsync(DateTime.Now, LogLevel.Information, $"启用心跳-状态复位-关闭定位-写入流程加载点位配置-计数清零-停止转盘-转盘使能"); //开启入料监听 MonitorPieces(); @@ -847,8 +853,7 @@ namespace DH.Devices.PLC //计数清零 CountToZero(); Thread.Sleep(1000); - //绿灯 - GreenLight(true); + LogAsync(DateTime.Now, LogLevel.Information, $"状态复位-关闭定位-写入流程加载点位配置-计数清零"); Thread.Sleep(200); @@ -898,6 +903,9 @@ namespace DH.Devices.PLC StopProcessAction(); TurnClear(false); OpenHeartbeat(false); + GreenLight(false); + YellowLight(false); + RedLight(true); PLCDisConnect(); // LogAsync(DateTime.Now, LogLevel.Information, $"PLC断开连接"); } diff --git a/DHSoftware/MainWindow.cs b/DHSoftware/MainWindow.cs index 0a651e9..e958579 100644 --- a/DHSoftware/MainWindow.cs +++ b/DHSoftware/MainWindow.cs @@ -57,132 +57,9 @@ namespace DHSoftware public event Action OnUpdateResult; public event Action OnUpdateCamResult; - private string _loginName; + - public string LoginName - { - get { return _loginName; } - set - { - _loginName = value; - UpdateLabel(); - } - } - private bool _ShowConfig; - - public bool ShowConfig - { - get { return _ShowConfig; } - set - { - _ShowConfig = value; - UpdateConfig(); - } - } - - private bool _addscheme; - - public bool Addscheme - { - get { return _addscheme; } - set - { - _addscheme = value; - UpdateScheme(); - } - } - - private bool _deletescheme; - - public bool Deleteschememe - { - get { return _deletescheme; } - set - { - _deletescheme = value; - UpdateScheme(); - } - } - - private bool _loadscheme; - - public bool Loadscheme - { - get { return _loadscheme; } - set - { - _loadscheme = value; - UpdateScheme(); - } - } - - private void UpdateScheme() - { - if (this.InvokeRequired) - { - this.Invoke(new Action(UpdateScheme)); - return; - } - - if (Loadscheme) - { - btnDeleteProject.Visible = true; - } - else - { - btnDeleteProject.Visible = false; - } - if (Addscheme) - { - btnAddProject.Visible = true; - } - else - { - btnAddProject.Visible = false; - } - if (Deleteschememe) - { - btnLoadProject.Visible = true; - } - else - { - btnLoadProject.Visible = false; - } - } - - private void UpdateLabel() - { - if (lbName.InvokeRequired) - { - lbName.Invoke(new Action(UpdateLabel)); - return; - } - lbName.Text = _loginName; - } - - private void UpdateConfig() - { - if (ShowConfig) - { - if (segmented1.InvokeRequired) - { - segmented1.Invoke(new Action(UpdateConfig)); - return; - } - // 恢复显示时 - segmented1.Items.Insert(4, itemToHide); - } - else - { - if (segmented1.InvokeRequired) - { - segmented1.Invoke(new Action(UpdateConfig)); - return; - } - segmented1.Items.Remove(itemToHide); - } - } public List ButtonPermissionList { set @@ -1178,11 +1055,13 @@ namespace DHSoftware { camera.CameraDisConnect(); } + StopMonitoring(); if (PLC != null) { PLC.CloseProcess(); + } - StopMonitoring(); + _visionEngine.Stop();//释放模型 CloseWindow.Instance.Close();// 关闭提示窗口 //Application.Exit(); diff --git a/DHSoftware/Views/AddCameraControl.cs b/DHSoftware/Views/AddCameraControl.cs index 4e15a31..6d61cbc 100644 --- a/DHSoftware/Views/AddCameraControl.cs +++ b/DHSoftware/Views/AddCameraControl.cs @@ -13,6 +13,7 @@ namespace DHSoftware.Views InitializeComponent(); lbTitleName.Text = TitleName; + // 绑定事件 BindEventHandler(); } @@ -21,6 +22,12 @@ namespace DHSoftware.Views { button_ok.Click += Button_ok_Click; button_cancel.Click += Button_cancel_Click; + Load += AddCameraControl_Load; + } + + private void AddCameraControl_Load(object? sender, EventArgs e) + { + input_name.Text = CubicleName; } private void Button_cancel_Click(object sender, EventArgs e) diff --git a/DHSoftware/Views/AddCubicleControl.cs b/DHSoftware/Views/AddCubicleControl.cs index 0299e6b..b60f87a 100644 --- a/DHSoftware/Views/AddCubicleControl.cs +++ b/DHSoftware/Views/AddCubicleControl.cs @@ -28,6 +28,13 @@ namespace DHSoftware.Views { button_ok.Click += Button_ok_Click; button_cancel.Click += Button_cancel_Click; + Load += AddCubicleControl_Load; + } + + private void AddCubicleControl_Load(object? sender, EventArgs e) + { + input_name.Text = CubicleName; + sltdetectionType.SelectedIndex =(int)DetectionType; } private void Button_cancel_Click(object sender, EventArgs e) diff --git a/DHSoftware/Views/SettingWindow.cs b/DHSoftware/Views/SettingWindow.cs index 08a1a0c..4c71eda 100644 --- a/DHSoftware/Views/SettingWindow.cs +++ b/DHSoftware/Views/SettingWindow.cs @@ -7,6 +7,7 @@ using DH.Commons.Base; using DH.RBAC.Model.Sys; using System.Reflection; using ScrollBar = AntdUI.ScrollBar; +using DH.Commons.Enums; namespace DHSoftware.Views { @@ -594,7 +595,8 @@ namespace DHSoftware.Views { Size = new Size(300, 200), // 传递当前名称到表单 - CubicleName = originalName + CubicleName = originalName, + }; AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None) @@ -674,12 +676,14 @@ namespace DHSoftware.Views case "重命名": // 保存原始名称用于查找 string originalName = clickedItem.Text; - + EnumDetectionType enumDetectionType= ConfigModel.DetectionList.FirstOrDefault(c => + c.Name.Equals(originalName, StringComparison.OrdinalIgnoreCase)).DetectionType; var form = new AddCubicleControl(this, "重命名工位操作") { Size = new Size(300, 500), // 传递当前名称到表单 - CubicleName = originalName + CubicleName = originalName, + DetectionType = enumDetectionType }; AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None) @@ -703,6 +707,7 @@ namespace DHSoftware.Views var detection = ConfigModel.DetectionList.FirstOrDefault(c => c.Name.Equals(originalName, StringComparison.OrdinalIgnoreCase)); detection.Name = newName; + detection.DetectionType = form.DetectionType; foreach (var tab in tabs1.Pages) { if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{originalName}")