From 0e450768c357b45701a2e5ed162f4e93b3dd617c Mon Sep 17 00:00:00 2001
From: zhangchengsong <zhangchengsong@hnkhzn.com>
Date: 星期三, 15 四月 2026 20:53:24 +0800
Subject: [PATCH] 最新
---
项目代码/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 103 ++++++++++-----------------------------------------
1 files changed, 20 insertions(+), 83 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
index a16b52a..91bc82b 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
@@ -56,13 +56,12 @@
_DtPlatformStationService= dt_PlatformStationService;
}
- public Task Execute(IJobExecutionContext context)
+ public Task Execute(IJobExecutionContext context)
{
try
{
- CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
-
+ CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
if (commonStackerCrane != null)
{
@@ -96,13 +95,6 @@
}
}
- WriteLog.Write_Log("鍫嗗灈鏈哄綋鍓嶇姸鎬�", "鍫嗗灈鏈哄綋鍓嶇姸鎬佷俊鎭�", $"鍫嗗灈鏈鸿澶囧湴鍧�:銆怐B105.2.0銆�,璇诲彇鐨勬暟鎹細銆恵commonStackerCrane.StackerCraneAutoStatusDes}銆慭n" +
- $"鍫嗗灈鏈哄伐浣滄ā寮忓湴鍧�:銆怐B105.3.0銆�,璇诲彇鐨勬暟鎹細銆恵commonStackerCrane.StackerCraneStatusDes}銆慭n" +
- $"鍫嗗灈鏈轰綔涓氱姸鎬佸湴鍧�:銆怐B105.22.0銆�,璇诲彇鐨勬暟鎹細銆恵commonStackerCrane.StackerCraneWorkStatusDes}銆慭n" +
- $"鍫嗗灈鏈哄綋鍓嶄换鍔℃墽琛屼腑鍦板潃:銆怐B105.18.0銆�,璇诲彇鐨勬暟鎹細銆恵commonStackerCrane.CurrentTaskNum}銆慭n");
-
-
-
if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal)
{
@@ -185,7 +177,6 @@
}
else if (taskItem.TaskType == (int)TaskTypeEnum.Inbound || taskItem.TaskType == (int)TaskTypeEnum.Inventorybound)
{
- InTaskStationIsOccupied(taskItem.SourceAddress, taskItem.Roadway);
return taskItem;
}
}
@@ -220,7 +211,6 @@
int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress);
- conveyorLine.Communicator.Write<short>(HandShakeprodto.DeviceProAddress, 1);
WriteLog.Write_Log("鍑哄簱搴撳彛鐘舵�佷俊鎭�", "鍑哄簱搴撳彛鐘舵�佷俊鎭�", $"搴撳彛鏄�恵NextAddress}銆戯紝鐢宠鐘舵�佸湴鍧�锛氥�恵HandShakeprodto.DeviceProAddress}銆�,璇诲彇鐨勬暟鎹細銆恵HandShake}銆慭n" +
$"搴撳彛鏄惁鏈夎揣鐘舵�佸湴鍧�锛氥�恵deviceProDTO.DeviceProAddress}銆戯紝璇诲彇鐨勬暟鎹�恵StationNum}銆�");
@@ -256,44 +246,7 @@
return false;
}
- /// <summary>
- /// 鍏ュ簱浠诲姟搴撳彛鏈夎揣鏃犺揣鐘舵��
- /// </summary>
- private void InTaskStationIsOccupied(string SourceAddress, string Roadway)
- {
- try
- {
- if (Roadway == "C")
- {
- IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1004");
- CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
- DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "StationNum");
- DeviceProDTO? HandShakeprodto = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "HandShake");
-
- int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
- int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress);
- WriteLog.Write_Log("鍏ュ簱搴撳彛鐘舵�佷俊鎭�", "鍏ュ簱搴撳彛鐘舵�佷俊鎭�", $"搴撳彛鏄�恵SourceAddress}銆戯紝鐢宠鐘舵�佸湴鍧�锛氥�恵HandShakeprodto.DeviceProAddress}銆�,璇诲彇鐨勬暟鎹細銆恵HandShake}銆慭n" +
- $"搴撳彛鏄惁鏈夎揣鐘舵�佸湴鍧�锛氥�恵deviceProDTO.DeviceProAddress}銆戯紝璇诲彇鐨勬暟鎹�恵StationNum}銆�");
- }
- else
- {
- IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1003");
- CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
- DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "StationNum");
- DeviceProDTO? HandShakeprodto = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "HandShake");
- int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
- int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress);
- WriteLog.Write_Log("鍏ュ簱搴撳彛鐘舵�佷俊鎭�", "鍏ュ簱搴撳彛鐘舵�佷俊鎭�", $"搴撳彛鏄�恵SourceAddress}銆戯紝鐢宠鐘舵�佸湴鍧�锛氥�恵HandShakeprodto.DeviceProAddress}銆�,璇诲彇鐨勬暟鎹細銆恵HandShake}銆慭n" +
- $"搴撳彛鏄惁鏈夎揣鐘舵�佸湴鍧�锛氥�恵deviceProDTO.DeviceProAddress}銆戯紝璇诲彇鐨勬暟鎹�恵StationNum}銆�");
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("璇诲彇绔欏彴淇℃伅閿欒锛�" + ex.Message);
- }
-
- }
/// <summary>
/// 浠诲姟瀹炰綋杞崲鎴愬懡浠odel
@@ -451,53 +404,37 @@
/// <param name="stackerCraneWorkStatusDes"></param>
public void UpdateHandShake(int taskNum, string stackerCraneWorkStatusDes)
{
- // 1. 鏌ヨ浠诲姟锛岀┖鍊肩洿鎺ヨ繑鍥�
- Dt_Task? dtTask = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
- if (dtTask == null) return;
-
- // 2. 瀹氫箟鍥哄畾鍦板潃
- string[] targetAddresses = { "G03", "G04", "C02", "C01" };
-
- // 3. 鏉′欢鍒ゆ柇 + 纭畾鍐欏叆鍊�
- short writeValue = -1;
- if (dtTask.TaskType == 100 && targetAddresses.Contains(dtTask.TargetAddress))
+ try
{
- writeValue = stackerCraneWorkStatusDes switch
+ Dt_Task? dtTask = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
+ if (dtTask == null) return;
+
+ string[] targetAddresses = { "G03", "G04", "C02", "C01" };
+ if (dtTask.TaskType != 100 || !targetAddresses.Contains(dtTask.TargetAddress))
+ return;
+
+ short writeValue = stackerCraneWorkStatusDes switch
{
"鏀捐揣涓�" => 1,
"浠诲姟瀹屾垚" => 0,
_ => -1
};
- }
- // 4. 鑾峰彇璁惧缂栫爜
- string deviceCode = dtTask.CurrentAddress.StartsWith("C") ? "1004" : "1003";
+ if (writeValue == -1) return;
- // 5. 鑾峰彇璁惧锛岀┖鍊肩洿鎺ヨ繑鍥�
- IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == deviceCode);
- if (device != null && writeValue != -1)
- {
- CommonConveyorLine? conveyorLine = (CommonConveyorLine)device;
+ string deviceCode = dtTask.CurrentAddress.StartsWith("C") ? "1004" : "1003";
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == deviceCode);
+ if (device == null) return;
- // 6. 鑾峰彇鎻℃墜鐐逛綅锛岀┖鍊肩洿鎺ヨ繑鍥�
+ CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
DeviceProDTO? handShake = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == dtTask.TargetAddress && x.DeviceProParamName == "HandShake");
- if (handShake == null)
- {
- WriteLog.Write_Log("鍑哄簱搴撳彛鍏夋爡鐘舵�侀敊璇俊鎭�", "鍑哄簱搴撳彛鍏夋爡鐘舵�侀敊璇俊鎭�", $"WCS鏈壘鍒板簱鍙d俊鎭槸銆恵dtTask.TargetAddress}銆戯紝浠诲姟鍙凤細銆恵dtTask.TaskNum}銆�,鍫嗗灈鏈轰綔涓氱姸鎬侊細銆恵stackerCraneWorkStatusDes}銆�");
- return;
- }
- // 7. 鍐欏叆鍊�
- conveyorLine.Communicator.Write<short>(handShake.DeviceProAddress, writeValue);
- WriteLog.Write_Log("鍑哄簱搴撳彛鍏夋爡鐘舵�佹甯镐俊鎭�", "鍑哄簱搴撳彛鍏夋爡鐘舵�佹甯镐俊鎭�", $"搴撳彛鏄�恵dtTask.TargetAddress}銆戯紝鐢宠鐘舵�佸湴鍧�锛氥�恵handShake.DeviceProAddress}銆�,璇诲彇鐨勬暟鎹細銆恵conveyorLine.Communicator.Read<ushort>(handShake.DeviceProAddress)}銆慭n" +
- $"浠诲姟鍙凤細銆恵dtTask.TaskNum}銆�,鍫嗗灈鏈轰綔涓氱姸鎬侊細銆恵stackerCraneWorkStatusDes}銆�");
- return;
+ if (handShake == null) return;
+
+ conveyorLine.Communicator.Write<short>(handShake.DeviceProAddress, writeValue);
}
- else
+ catch
{
- WriteLog.Write_Log("鍑哄簱搴撳彛鍏夋爡鐘舵�侀敊璇俊鎭�", "鍑哄簱搴撳彛鍏夋爡鐘舵�侀敊璇俊鎭�", $"搴撳彛鏄�恵dtTask.TargetAddress}銆戯紝浠诲姟鍙凤細銆恵dtTask.TaskNum}銆�,鍫嗗灈鏈轰綔涓氱姸鎬侊細銆恵stackerCraneWorkStatusDes}銆�");
- return;
}
-
}
}
--
Gitblit v1.9.3