From ad64840cc04dac2278ca02f22ddc02b1a218e9cf Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 15 四月 2026 22:44:18 +0800
Subject: [PATCH] feat(机器人任务): 实现换盘任务假电芯补充逻辑
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs | 33 ++++++++++++++++++---------------
1 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
index 08ffb97..5d3cf9e 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging;
using Quartz;
-using System.Net;
using WIDESEA_Core;
+using WIDESEAWCS_Common;
using WIDESEAWCS_Core.Caches;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core.LogHelper;
@@ -29,15 +29,6 @@
[DisallowConcurrentExecution]
public class RobotJob : IJob
{
- /// <summary>
- /// 浠诲姟鎬绘暟涓婇檺
- /// </summary>
- /// <remarks>
- /// 褰撴満鍣ㄤ汉澶勭悊鐨勮揣鐗╂暟閲忚揪鍒版涓婇檺鏃讹紝涓嶅啀涓嬪彂鏂颁换鍔°��
- /// 闃叉鏈哄櫒浜鸿繃搴﹀姵绱垨绯荤粺杩囪浇銆�
- /// </remarks>
- private const int MaxTaskTotalNum = 48;
-
/// <summary>
/// 娑堟伅浜嬩欢璁㈤槄鏍囧織
/// </summary>
@@ -113,7 +104,8 @@
ITaskService taskService,
ICacheService cache,
HttpClientHelper httpClientHelper,
- ILogger<RobotJob> logger)
+ ILogger<RobotJob> logger,
+ IFakeBatteryPositionService fakeBatteryPositionService)
{
// 鍒濆鍖栫姸鎬佺鐞嗗櫒锛屼紶鍏ョ紦瀛樻湇鍔�
_stateManager = new RobotStateManager(cache, _logger);
@@ -124,14 +116,14 @@
ISocketClientGateway socketGateway = new SocketClientGateway(tcpSocket);
// 鍒濆鍖栦换鍔″鐞嗗櫒
- _taskProcessor = new RobotTaskProcessor(socketGateway, _stateManager, robotTaskService, taskService, httpClientHelper, _logger);
+ _taskProcessor = new RobotTaskProcessor(socketGateway, _stateManager, robotTaskService, taskService, httpClientHelper, _logger, fakeBatteryPositionService);
// 鍒濆鍖栧鎴风绠$悊鍣�
_clientManager = new RobotClientManager(tcpSocket, _stateManager, _logger);
// 鍒濆鍖栧懡浠ゅ鐞嗗櫒
// 绠�鍗曞懡浠ゅ鐞嗗櫒锛氬鐞嗙姸鎬佹洿鏂扮瓑绠�鍗曞懡浠�
- var simpleCommandHandler = new RobotSimpleCommandHandler(_taskProcessor);
+ var simpleCommandHandler = new RobotSimpleCommandHandler(_taskProcessor, socketGateway);
// 鍓嶇紑鍛戒护澶勭悊鍣細澶勭悊 pickfinished銆乸utfinished 绛夊甫鍙傛暟鐨勫懡浠�
var prefixCommandHandler = new RobotPrefixCommandHandler(robotTaskService, _taskProcessor, _stateManager, socketGateway);
@@ -214,8 +206,19 @@
return;
}
+ if (state.CurrentAction == "Picking" || state.CurrentAction == "Puting")
+ {
+ return;
+ }
+
// 杞鑾峰彇璇ヨ澶囩殑寰呭鐞嗕换鍔�
var task = _taskProcessor.GetTask(robotCrane);
+
+ // 濡傛灉娌℃湁鑾峰彇鍒板緟澶勭悊浠诲姟锛屼笖RobotArmObject涓�1锛堟湁鐗╂枡锛夛紝鍒欒幏鍙栬璁惧鎵ц涓殑浠诲姟
+ if (task == null && state.RobotArmObject == 1)
+ {
+ task = _taskProcessor.GetExecutingTask(robotCrane);
+ }
// 濡傛灉鏈夊緟澶勭悊浠诲姟
if (task != null)
@@ -229,7 +232,7 @@
}
// 妫�鏌ヤ换鍔℃�绘暟鏄惁鏈揪鍒颁笂闄�
- if (latestState.RobotTaskTotalNum < MaxTaskTotalNum)
+ if (latestState.RobotTaskTotalNum < RobotConst.MaxTaskTotalNum)
{
// 璋冪敤宸ヤ綔娴佺紪鎺掑櫒鎵ц浠诲姟
// 缂栨帓鍣ㄤ細鏍规嵁褰撳墠鐘舵�佸喅瀹氫笅涓�姝ュ姩浣�
@@ -246,4 +249,4 @@
}
}
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3