提交设备状态
This commit is contained in:
parent
ae5c1122ed
commit
b749eb4266
@ -9,8 +9,9 @@ namespace DH.Commons.Enums
|
||||
{
|
||||
public enum EnumStatus
|
||||
{
|
||||
未运行,
|
||||
待机中,
|
||||
运行中,
|
||||
清料中,
|
||||
警告,
|
||||
异常
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace DH.Commons.Models
|
||||
/// <summary>
|
||||
/// 当前状态
|
||||
/// </summary>
|
||||
public static EnumStatus CurrentStatus =EnumStatus.未运行;
|
||||
public static EnumStatus CurrentStatus =EnumStatus.待机中;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -846,6 +846,9 @@ namespace DH.Devices.PLC
|
||||
Thread.Sleep(1000);
|
||||
//计数清零
|
||||
CountToZero();
|
||||
Thread.Sleep(1000);
|
||||
//绿灯
|
||||
GreenLight(true);
|
||||
LogAsync(DateTime.Now, LogLevel.Information, $"状态复位-关闭定位-写入流程加载点位配置-计数清零");
|
||||
|
||||
Thread.Sleep(200);
|
||||
@ -870,11 +873,8 @@ namespace DH.Devices.PLC
|
||||
Thread.Sleep(1000);
|
||||
StopProcessAction();
|
||||
TurnStart(false);
|
||||
LogAsync(DateTime.Now, LogLevel.Action, $"流程停止");
|
||||
Task.Run(async () => {
|
||||
|
||||
await ExecuteClearDelayAsync();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -883,10 +883,8 @@ namespace DH.Devices.PLC
|
||||
int? clearTime = ConfigModel.GlobalList?.FirstOrDefault()?.ClearTime;
|
||||
if (clearTime != null)
|
||||
{
|
||||
LogAsync(DateTime.Now, LogLevel.Action, $"转盘清料开始");
|
||||
TurnClear(true);
|
||||
await Task.Delay(clearTime.Value * 1000);
|
||||
LogAsync(DateTime.Now, LogLevel.Action, $"转盘清料完成");
|
||||
TurnClear(false);
|
||||
}
|
||||
}
|
||||
|
15
DHSoftware/MainWindow.Designer.cs
generated
15
DHSoftware/MainWindow.Designer.cs
generated
@ -62,6 +62,7 @@
|
||||
lblOEE_Total = new Label();
|
||||
label10 = new Label();
|
||||
label7 = new Label();
|
||||
tagMachineStatus = new AntdUI.Tag();
|
||||
panel2 = new AntdUI.Panel();
|
||||
panel1 = new AntdUI.Panel();
|
||||
segmented2 = new AntdUI.Segmented();
|
||||
@ -295,6 +296,7 @@
|
||||
tableLayoutNums.ColumnCount = 1;
|
||||
tableLayoutNums.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
|
||||
tableLayoutNums.Controls.Add(tableLayoutPanel3, 0, 1);
|
||||
tableLayoutNums.Controls.Add(tagMachineStatus, 0, 0);
|
||||
tableLayoutNums.Dock = DockStyle.Fill;
|
||||
tableLayoutNums.Location = new Point(0, 0);
|
||||
tableLayoutNums.Name = "tableLayoutNums";
|
||||
@ -419,6 +421,16 @@
|
||||
label7.Text = "总计数";
|
||||
label7.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// tagMachineStatus
|
||||
//
|
||||
tagMachineStatus.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
tagMachineStatus.Location = new Point(3, 3);
|
||||
tagMachineStatus.Name = "tagMachineStatus";
|
||||
tagMachineStatus.Size = new Size(141, 44);
|
||||
tagMachineStatus.TabIndex = 12;
|
||||
tagMachineStatus.Text = "待机中";
|
||||
tagMachineStatus.Type = AntdUI.TTypeMini.Primary;
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
panel2.Location = new Point(511, 86);
|
||||
@ -502,7 +514,7 @@
|
||||
btnCreateBatchNO.Name = "btnCreateBatchNO";
|
||||
btnCreateBatchNO.Size = new Size(72, 35);
|
||||
btnCreateBatchNO.TabIndex = 21;
|
||||
btnCreateBatchNO.Tag = "sys-load";
|
||||
btnCreateBatchNO.Tag = "";
|
||||
btnCreateBatchNO.Text = "生成批次";
|
||||
btnCreateBatchNO.Click += btnCreateBatchNO_Click;
|
||||
//
|
||||
@ -753,5 +765,6 @@
|
||||
private AntdUI.Button btnCreateBatchNO;
|
||||
private AntdUI.Input textBoxBatchNO;
|
||||
private AntdUI.Segmented segmented2;
|
||||
public AntdUI.Tag tagMachineStatus;
|
||||
}
|
||||
}
|
@ -700,6 +700,8 @@ namespace DHSoftware
|
||||
}
|
||||
|
||||
public void ConnectPLC()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ConfigModel.PLCBaseList.Count > 0)
|
||||
{
|
||||
@ -743,6 +745,12 @@ namespace DHSoftware
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
FrmLog frmLog;
|
||||
@ -1122,7 +1130,7 @@ namespace DHSoftware
|
||||
//EmergencyStop(null, null, null);
|
||||
}
|
||||
|
||||
Thread.Sleep(50); // 降低 CPU 占用,根据实际调整轮询间隔
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -1263,6 +1271,15 @@ namespace DHSoftware
|
||||
}
|
||||
|
||||
private void HandleStartButton()
|
||||
{
|
||||
lock (_stopLock)
|
||||
{
|
||||
if (_isStopProcessing) return;
|
||||
_isStopProcessing = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (SystemModel.CurrentStatus == EnumStatus.待机中)
|
||||
{
|
||||
InitialCameraSumsView();
|
||||
LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候...");
|
||||
@ -1270,7 +1287,43 @@ namespace DHSoftware
|
||||
//开始流程
|
||||
|
||||
StartProcess();
|
||||
SystemModel.CurrentStatus = EnumStatus.运行中;
|
||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
tagMachineStatus.Type = TTypeMini.Success;
|
||||
tagMachineStatus.Text = "运行中";
|
||||
}));
|
||||
LogAsync(DateTime.Now, LogLevel.Action, "流程启动完成!");
|
||||
|
||||
}
|
||||
else if (SystemModel.CurrentStatus == EnumStatus.运行中)
|
||||
{
|
||||
LogAsync(DateTime.Now, LogLevel.Warning, "设备正在运行,无需启动!");
|
||||
}
|
||||
else if (SystemModel.CurrentStatus == EnumStatus.清料中)
|
||||
{
|
||||
LogAsync(DateTime.Now, LogLevel.Warning, "设备正在清料,请稍候!");
|
||||
}
|
||||
else if (SystemModel.CurrentStatus == EnumStatus.警告)
|
||||
{
|
||||
LogAsync(DateTime.Now, LogLevel.Warning, "设备报警,请复位后重试!");
|
||||
}
|
||||
else if (SystemModel.CurrentStatus == EnumStatus.异常)
|
||||
{
|
||||
LogAsync(DateTime.Now, LogLevel.Warning, "设备异常,请检查!");
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock (_stopLock)
|
||||
{
|
||||
_isStopProcessing = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1279,10 +1332,7 @@ namespace DHSoftware
|
||||
{
|
||||
try
|
||||
{
|
||||
if (CurrentMachine)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
BatchNO = textBoxBatchNO.Text;
|
||||
textBoxBatchNO.ReadOnly = true;
|
||||
@ -1848,13 +1898,24 @@ namespace DHSoftware
|
||||
|
||||
}
|
||||
|
||||
private void HandleStopButton()
|
||||
private readonly object _stopLock = new object(); // 锁对象
|
||||
private bool _isStopProcessing = false; // 状态标志
|
||||
private async void HandleStopButton()
|
||||
{
|
||||
if (!CurrentMachine)
|
||||
// 通过锁和状态标志实现双重检查
|
||||
lock (_stopLock)
|
||||
{
|
||||
return;
|
||||
if (_isStopProcessing) return;
|
||||
_isStopProcessing = true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (SystemModel.CurrentStatus == EnumStatus.待机中)
|
||||
{
|
||||
LogAsync(DateTime.Now, LogLevel.Warning, "设备待机中,无需停止!");
|
||||
}
|
||||
else if (SystemModel.CurrentStatus == EnumStatus.运行中)
|
||||
{
|
||||
textBoxBatchNO.ReadOnly = false;
|
||||
btnCreateBatchNO.Enabled = true;
|
||||
|
||||
@ -1862,12 +1923,64 @@ namespace DHSoftware
|
||||
// Dectection.Clear();
|
||||
// Add the code for the "停止" button click here
|
||||
PLC.StopProcess();
|
||||
CurrentMachine = false;
|
||||
SystemModel.CurrentStatus = EnumStatus.待机中;
|
||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
tagMachineStatus.Type = TTypeMini.Primary;
|
||||
tagMachineStatus.Text = "待机中";
|
||||
}));
|
||||
LogAsync(DateTime.Now, LogLevel.Action, $"流程停止!");
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
|
||||
await ExecuteClearDelayAsync();
|
||||
});
|
||||
}
|
||||
else if (SystemModel.CurrentStatus == EnumStatus.清料中)
|
||||
{
|
||||
LogAsync(DateTime.Now, LogLevel.Warning, "设备正在清料,请稍候!");
|
||||
}
|
||||
else if (SystemModel.CurrentStatus == EnumStatus.警告)
|
||||
{
|
||||
LogAsync(DateTime.Now, LogLevel.Warning, "设备报警,请复位后重试!");
|
||||
}
|
||||
else if (SystemModel.CurrentStatus == EnumStatus.异常)
|
||||
{
|
||||
LogAsync(DateTime.Now, LogLevel.Warning, "设备异常,请检查!");
|
||||
}
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
lock (_stopLock)
|
||||
{
|
||||
_isStopProcessing = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//sLDMotion.Stop();
|
||||
}
|
||||
|
||||
private async Task ExecuteClearDelayAsync()
|
||||
{
|
||||
LogAsync(DateTime.Now, LogLevel.Action, $"转盘清料开始");
|
||||
SystemModel.CurrentStatus = EnumStatus.清料中;
|
||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
tagMachineStatus.Type = TTypeMini.Warn;
|
||||
tagMachineStatus.Text = "清料中";
|
||||
}));
|
||||
await PLC.ExecuteClearDelayAsync();
|
||||
LogAsync(DateTime.Now, LogLevel.Action, $"转盘清料完成");
|
||||
|
||||
SystemModel.CurrentStatus = EnumStatus.待机中;
|
||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
tagMachineStatus.Type = TTypeMini.Primary;
|
||||
tagMachineStatus.Text = "待机中";
|
||||
}));
|
||||
}
|
||||
|
||||
public void CalculateOEE()
|
||||
{
|
||||
|
@ -67,6 +67,8 @@ namespace DHSoftware
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemModel.CurrentStatus = EnumStatus.异常;
|
||||
MainWindow.Instance.tagMachineStatus.Type = TTypeMini.Error;
|
||||
MainWindow.Instance.tagMachineStatus.Text = "异常";
|
||||
Modal.open(WelcomeWindow.Instance, "错误!", ex.ToString(), TType.Error);
|
||||
}
|
||||
|
||||
@ -99,6 +101,8 @@ namespace DHSoftware
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemModel.CurrentStatus = EnumStatus.异常;
|
||||
MainWindow.Instance.tagMachineStatus.Type = TTypeMini.Error;
|
||||
MainWindow.Instance.tagMachineStatus.Text = "异常";
|
||||
Modal.open(WelcomeWindow.Instance, "错误!", ex.ToString(), TType.Error);
|
||||
}
|
||||
UpdateStep(80, "正在加载算法模型", true);
|
||||
@ -109,6 +113,8 @@ namespace DHSoftware
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemModel.CurrentStatus = EnumStatus.异常;
|
||||
MainWindow.Instance.tagMachineStatus.Type = TTypeMini.Error;
|
||||
MainWindow.Instance.tagMachineStatus.Text = "异常";
|
||||
Modal.open(WelcomeWindow.Instance, "错误!", ex.ToString(), TType.Error);
|
||||
}
|
||||
UpdateStep(100, "程序初始化完成", true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user