| | |
| | | using Microsoft.Extensions.Logging; |
| | | using WIDESEA_Core; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | |
| | | // 检查是否满足自动控制条件: |
| | | // 1. 运行模式为自动(2) |
| | | // 2. 控制模式为客户端控制(1) |
| | | // 3. 运行状态不是 Running(说明已完成当前动作) |
| | | if (latestState.RobotRunMode == 2 && latestState.RobotControlMode == 1 && latestState.OperStatus != "Running") |
| | | // 3. 运行状态是 Running |
| | | if (latestState.RobotRunMode == 2 /*&& latestState.RobotControlMode == 1*/ && latestState.OperStatus == "Running") |
| | | { |
| | | if(latestState.CurrentAction == "Picking" || latestState.CurrentAction == "Puting") |
| | | { |
| | | return; |
| | | } |
| | | |
| | | // ========== 取货完成后的放货处理 ========== |
| | | // 条件: |
| | | // - 当前动作是 PickFinished 或 AllPickFinished(取货完成) |
| | | // - 手臂上有物料(RobotArmObject == 1) |
| | | // - 任务状态为 RobotPickFinish(已记录取货完成) |
| | | if ((latestState.CurrentAction == "PickFinished" || latestState.CurrentAction == "AllPickFinished") |
| | | && latestState.RobotArmObject == 1 |
| | | && latestState.RobotArmObject == 0 |
| | | && task.RobotTaskState == TaskRobotStatusEnum.RobotPickFinish.GetHashCode()) |
| | | { |
| | | _logger.LogInformation("ExecuteAsync:满足放货条件,开始处理取货完成,任务号: {TaskNum}", task.RobotTaskNum); |
| | |
| | | // 发送放货指令 |
| | | await HandlePickFinishedStateAsync(task, ipAddress); |
| | | } |
| | | // ========== 放货完成后的取货处理 ========== |
| | | |
| | | // ========== 初始化或者放货完成后的取货处理 ========== |
| | | // 条件: |
| | | // - 当前动作是 PutFinished、AllPutFinished 或 null(放货完成) |
| | | // - 运行状态为 Homed(已归位) |
| | | // - 手臂上无物料(RobotArmObject == 0) |
| | | // - 任务状态为 RobotPutFinish 或不是 RobotExecuting |
| | | else if ((latestState.CurrentAction == "PutFinished" || latestState.CurrentAction == "AllPutFinished" || latestState.CurrentAction == null) |
| | | && latestState.OperStatus == "Homed" |
| | | else if ((latestState.CurrentAction == "PutFinished" || latestState.CurrentAction == "AllPutFinished" || latestState.CurrentAction.IsNullOrEmpty()) |
| | | && latestState.RobotArmObject == 0 |
| | | && (task.RobotTaskState == TaskRobotStatusEnum.RobotPutFinish.GetHashCode() |
| | | || task.RobotTaskState != TaskRobotStatusEnum.RobotExecuting.GetHashCode())) |