From 6654c7a847347732a58c9625a60667fd828b7db6 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <1247017146@qq.com>
Date: 星期三, 02 四月 2025 09:53:03 +0800
Subject: [PATCH] 代码更新
---
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs | 106 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 83 insertions(+), 23 deletions(-)
diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs
index 71c7a8b..7bc6ebb 100644
--- a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs
@@ -73,15 +73,15 @@
bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
if (sendFlag)
{
- StringBuilder builder = new StringBuilder();
- builder.AppendLine();
- builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戝爢鍨涙満鐘舵�侊細銆恵commonStackerCrane.StackerCraneStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�");
- builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戞墜鑷姩鐘舵�侊細銆恵commonStackerCrane.StackerCraneAutoStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�");
- builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戜綔涓氱姸鎬侊細銆恵commonStackerCrane.StackerCraneWorkStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�");
- builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戜笅鍙戜换鍔℃垚鍔�,銆恵JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}銆�");
- builder.AppendLine($"鏃堕棿锛氥�恵DateTime.Now}銆�");
- builder.AppendLine();
- ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue);
+ //StringBuilder builder = new StringBuilder();
+ //builder.AppendLine();
+ //builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戝爢鍨涙満鐘舵�侊細銆恵commonStackerCrane.StackerCraneStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�");
+ //builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戞墜鑷姩鐘舵�侊細銆恵commonStackerCrane.StackerCraneAutoStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�");
+ //builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戜綔涓氱姸鎬侊細銆恵commonStackerCrane.StackerCraneWorkStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�");
+ //builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戜笅鍙戜换鍔℃垚鍔�,銆恵JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}銆�");
+ //builder.AppendLine($"鏃堕棿锛氥�恵DateTime.Now}銆�");
+ //builder.AppendLine();
+ //ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue);
commonStackerCrane.LastTaskType = task.TaskType;
_taskService.UpdateTaskStatusToNext(task.TaskNum);
}
@@ -152,22 +152,41 @@
if (content.Status)
{
var task = content.Data as Dt_Task;
- Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress);
- IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
- if (device != null)
+ if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && task.TargetAddress == "001-000-001")
{
- CommonConveyorLine_After conveyorLine = (CommonConveyorLine_After)device;
- var proAddress = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationManager.stationChildCode).Where(x => x.DeviceProParamName == ConveyorLineDBName_After.InteractiveSignal.ToString()).FirstOrDefault().DeviceProAddress;
- string? address = proAddress;
- if (!proAddress.Contains(".0"))
+ Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress);
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
+ if (device != null)
{
- address = proAddress + ".0";
+ str = $"鍐欏叆瀹屾垚锛岀粰绾夸綋鍐欏叆涓嬮檷淇″彿";
+ WriteInfo(commonStackerCrane.DeviceName, str);
+ ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue);
+
+ // 鑾峰彇杈撻�佺嚎瀵硅薄
+ CommonConveyorLine_After conveyorLine = (CommonConveyorLine_After)device;
+
+ // 鑾峰彇鍗忚鍦板潃
+ var proAddress = conveyorLine.DeviceProDTOs
+ .FirstOrDefault(x => x.DeviceChildCode == stationManager.stationChildCode && x.DeviceProParamName == ConveyorLineDBName_After.InteractiveSignal.ToString())
+ ?.DeviceProAddress;
+
+ if (proAddress == null)
+ {
+ str = "鏈壘鍒板崗璁湴鍧�";
+ WriteInfo(commonStackerCrane.DeviceName, str);
+ ConsoleHelper.WriteColorLine(str, ConsoleColor.Red);
+ return;
+ }
+
+ string address = proAddress.Contains(".0") ? proAddress : proAddress + ".0";
+
+ // 鍐欏叆 false 淇″彿
+ WriteSignal(conveyorLine, address, false, commonStackerCrane.DeviceName);
}
- conveyorLine.Communicator.Write(str, false);
- }
- else
- {
- _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵task.NextAddress}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曟竻闄ゅ嚭搴撶珯鍙伴《鍗囩姸鎬�");
+ else
+ {
+ _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵task.NextAddress}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曟竻闄ゅ嚭搴撶珯鍙伴《鍗囩姸鎬�");
+ }
}
}
}
@@ -211,7 +230,7 @@
if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
{
- if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
+ if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && task.TargetAddress == "001-000-001")
{
Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress);
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
@@ -361,5 +380,46 @@
return stackerCraneTaskCommand;
}
+
+ /// <summary>
+ /// 鍐欏叆淇″彿骞堕獙璇佸啓鍏ョ粨鏋�
+ /// </summary>
+ /// <param name="conveyorLine">杈撻�佺嚎瀵硅薄</param>
+ /// <param name="address">鍗忚鍦板潃</param>
+ /// <param name="signal">淇″彿鍊�</param>
+ /// <param name="deviceName">璁惧鍚嶇О</param>
+ void WriteSignal(CommonConveyorLine_After conveyorLine, string address, bool signal, string deviceName)
+ {
+ string str = string.Empty;
+
+ // 鍐欏叆淇″彿
+ conveyorLine.Communicator.Write(address, signal);
+
+ // 楠岃瘉鍐欏叆缁撴灉锛屾渶澶氶噸璇�5娆�
+ for (int i = 0; i < 5; i++)
+ {
+ var isWrite = conveyorLine.Communicator.Read<bool>(address);
+ if (isWrite == signal)
+ {
+ break;
+ }
+ conveyorLine.Communicator.Write(address, signal);
+ }
+
+ // 鏈�缁堥獙璇佸啓鍏ョ粨鏋�
+ var finalWrite = conveyorLine.Communicator.Read<bool>(address);
+ if (finalWrite == signal)
+ {
+ str = $"{address}-鍐欏叆{signal}鎴愬姛";
+ ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue);
+ WriteInfo(deviceName, str);
+ }
+ else
+ {
+ str = $"{address}-鍐欏叆{signal}澶辫触";
+ ConsoleHelper.WriteColorLine(str, ConsoleColor.Red);
+ WriteInfo(deviceName, str);
+ }
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.3