From f9d341542aaacdd8595154c2d0bcae89f4865fa7 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 06 二月 2026 14:33:17 +0800
Subject: [PATCH] 添加HTTP助手、系统配置模型及机器人任务层
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs | 76 +++++++++++++++++++++++++++++++------
1 files changed, 63 insertions(+), 13 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
index 8503c91..ddb4821 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
@@ -2,6 +2,7 @@
using System.Collections.Concurrent;
using System.Net.Sockets;
using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO.Stock;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
@@ -17,27 +18,24 @@
private readonly TcpSocketServer _TcpSocket;
private static readonly ConcurrentDictionary<string, RobotSocketState> _socketStates = new();
private static int _eventSubscribedFlag;
- private readonly ITaskService _taskService;
+ private readonly IRobotTaskService _taskService;
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
private readonly ITaskRepository _taskRepository;
private readonly IRouterService _routerService;
- public RobotJob(TcpSocketServer TcpSocket, ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService)
+ public RobotJob(TcpSocketServer TcpSocket, IRobotTaskService taskService)
{
_TcpSocket = TcpSocket;
_taskService = taskService;
- _taskExecuteDetailService = taskExecuteDetailService;
- _taskRepository = taskRepository;
- _routerService = routerService;
}
- public Task Execute(IJobExecutionContext context)
+ public async Task Execute(IJobExecutionContext context)
{
bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
RobotCraneDevice robotCrane = (RobotCraneDevice?)value ?? new RobotCraneDevice();
if (!flag || robotCrane.IsNullOrEmpty())
{
- return Task.CompletedTask;
+ return;
}
string ipAddress = robotCrane.IPAddress;
@@ -56,7 +54,7 @@
var clientIds = _TcpSocket.GetClientIds();
if (!clientIds.Contains(ipAddress))
{
- return Task.CompletedTask;
+ return;
}
// 璁㈤槄涓�娆� message 浜嬩欢锛堝叏灞�涓�娆★級
@@ -74,13 +72,34 @@
}
// 鑾峰彇浠诲姟骞剁紦瀛樺埌鐘舵�佷腑
- Dt_Task? task = GetTask(robotCrane);
+ Dt_RobotTask? task = GetTask(robotCrane);
if (task != null)
{
state.CurrentTask = task;
+ if (task.RobotTaskTotalNum != 48)
+ {
+ // 澶勭悊姝e湪鎵ц鐨勪换鍔�
+ if (state.RobotRunMode == 1 && state.RobotControlMode == 1)
+ {
+ await Task.Delay(1000);
+ if ((state.CurrentAction == "Homed" || state.CurrentAction == "PickFinished" || state.CurrentAction == "PutFinished") && state.OperStatus == "Running")
+ {
+ // TODO 璇诲彇绾夸綋鐢垫睜鏉$爜锛屽彂閫佸彇鐢垫睜鎸囦护
+ if (true)
+ {
+ // 妯℃嫙璇诲彇鏉$爜
+ state.CellBarcode = new string[] { "CellBarcode1", "CellBarcode2", "CellBarcode3", "CellBarcode4" };
+
+ string taskString = $"Pickbattery,{task.RobotSourceAddress}";
+ // 鍙戦�佷换鍔℃寚浠�
+ bool result = await _TcpSocket.SendToClientAsync(ipAddress, taskString);
+ }
+ }
+ }
+ }
}
- return Task.CompletedTask;
+ return;
}
/// <summary>
@@ -133,6 +152,24 @@
else if (cmd.StartsWith("putfinished"))
{
state.LastPutPositions = positions;
+ // 鍙戦�佹暟鎹粰WMS缁勭洏/鎹㈢洏
+ StockDTO stockDTO = new StockDTO
+ {
+ SourceLineNo = state.CurrentTask?.RobotSourceAddressLineCode,
+ SourcePalletNo = state.CurrentTask?.RobotSourceAddressPalletCode,
+ TargetPalletNo = state.CurrentTask?.RobotTargetAddressPalletCode,
+ TargetLineNo = state.CurrentTask?.RobotTargetAddressLineCode,
+ Details = positions
+ .Where(x => x > 0)
+ .OrderBy(x => x)
+ .Select((x, idx) => new StockDetailDTO
+ {
+ Quantity = state.CurrentTask?.RobotTaskTotalNum ?? 1,
+ Channel = x > 0 ? x : throw new ArgumentOutOfRangeException(nameof(x), "Channel must be positive"),
+ CellBarcode = state.CellBarcode[idx]
+ })
+ .ToList()
+ };
state.CurrentAction = "PutFinished";
}
}
@@ -173,10 +210,18 @@
case "allpickfinished":
state.CurrentAction = "AllPickFinished";
+ if(state.CurrentTask?.RobotTaskType == 2|| state.CurrentTask?.RobotTaskType == 3)
+ {
+ // TODO 鏈烘鎵嬪彇璐у畬鎴愶紝鍒ゆ柇鏄惁鎹㈢洏銆佹媶鐩樹换鍔★紝鍒涘缓绌烘墭鐩樺洖搴撲换鍔�
+ }
return true;
case "allputfinished":
state.CurrentAction = "AllPutFinished";
+ if (state.CurrentTask?.RobotTaskType == 1 )
+ {
+ // TODO 鏈烘鎵嬪彇璐у畬鎴愶紝鍒ゆ柇鏄惁缁勭洏浠诲姟锛屽垱寤虹粍鐩樺叆搴撲换鍔�
+ }
return true;
case "running":
@@ -199,7 +244,7 @@
state.RobotRunMode = 1;
return true;
- case "runmodemode,2":
+ case "runmode,2":
state.RobotRunMode = 2;
return true;
@@ -234,7 +279,7 @@
return message.StartsWith("pickfinished") || message.StartsWith("putfinished");
}
- private Dt_Task? GetTask(RobotCraneDevice robotCrane)
+ private Dt_RobotTask? GetTask(RobotCraneDevice robotCrane)
{
return _taskService.QueryRobotCraneTask(robotCrane.DeviceCode);
}
@@ -290,8 +335,13 @@
public int[]? LastPutPositions { get; set; }
/// <summary>
+ /// 鎶撳彇浣嶇疆鏉$爜
+ /// </summary>
+ public string[] CellBarcode { get; set; }
+
+ /// <summary>
/// 褰撳墠鎶撳彇浠诲姟
/// </summary>
- public Dt_Task? CurrentTask { get; set; }
+ public Dt_RobotTask? CurrentTask { get; set; }
}
}
\ No newline at end of file
--
Gitblit v1.9.3