提交bug

This commit is contained in:
Admin
2025-04-24 15:45:01 +08:00
parent 77b75050b2
commit 6973d39cad
11 changed files with 332 additions and 27 deletions

View File

@ -822,25 +822,73 @@ namespace DH.Devices.PLC
//流程开启操作配置
// ProcessInitialAction();
// if (_PLC?Enabled == true)
//皮带
// _PLC.Belt(true);
// LogAsync(DateTime.Now, LogLevel.Information, $"写入流程加载点位配置");
bool? enableBelt = ConfigModel.GlobalList?.FirstOrDefault()?.EnableBelt;
if (enableBelt == true)
{
Belt(true);
}
Thread.Sleep(1000);
bool? enableVibrator = ConfigModel.GlobalList?.FirstOrDefault()?.EnableVibrator;
if (enableVibrator == true)
{
Vibrator(true);
}
Thread.Sleep(1000);
//转盘使能
TurnEnable(true);
//转盘启动
TurnStart(true);
Thread.Sleep(1000);
//计数清零
CountToZero();
LogAsync(DateTime.Now, LogLevel.Information, $"状态复位-关闭定位-写入流程加载点位配置-计数清零");
//转盘启动
TurnStart(true);
Thread.Sleep(200);
}
public void StopProcess()
{
StatusReset();
VisionPos(false);
CountToZero();
bool? enableVibrator = ConfigModel.GlobalList?.FirstOrDefault()?.EnableVibrator;
if (enableVibrator == true)
{
Vibrator(true);
}
Thread.Sleep(1000);
bool? enableBelt = ConfigModel.GlobalList?.FirstOrDefault()?.EnableBelt;
if (enableBelt == true)
{
Belt(false);
}
Thread.Sleep(1000);
StopProcessAction();
TurnStart(false);
// LogAsync(DateTime.Now, LogLevel.Information, $"PLC断开连接");
LogAsync(DateTime.Now, LogLevel.Action, $"流程停止");
Task.Run(async () => {
await ExecuteClearDelayAsync();
});
}
public async Task ExecuteClearDelayAsync()
{
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);
}
}
public void CloseProcess()
{
@ -850,6 +898,7 @@ namespace DH.Devices.PLC
TurnStart(false);
TurnEnable(false);
StopProcessAction();
TurnClear(false);
OpenHeartbeat(false);
PLCDisConnect();
// LogAsync(DateTime.Now, LogLevel.Information, $"PLC断开连接");
@ -1014,6 +1063,25 @@ namespace DH.Devices.PLC
WriteBool(pLCItem.Address, b);
Thread.Sleep(30);
}
public void Belt(bool b)
{
PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "皮带");
if (pLCItem == null)
return;
WriteBool(pLCItem.Address, b);
Thread.Sleep(30);
}
public void Vibrator(bool b)
{
PLCItem? pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "振动盘");
if (pLCItem == null)
return;
WriteBool(pLCItem.Address, b);
Thread.Sleep(30);
}
public void Motor(bool direction, int speed, int pos)
{
@ -1143,7 +1211,13 @@ namespace DH.Devices.PLC
elapsedTime += checkInterval;
}
BarrierToZero(false);
Thread.Sleep(300);
// 检查是否不在原点,如果不在,则回原点
BarrierClockwise(false);
Thread.Sleep(300);
BarrierCounterclockwise(false);
Thread.Sleep(300);
// 无论是刚回到原点还是已经在原点,执行目标位置、速度和方向设置
BarrierSpeed(speed);
Thread.Sleep(300);