Refactor AGV error handling: Standardize AGVErrorCode usage and update SetRunStepError

This commit is contained in:
backuppc
2026-01-28 16:45:24 +09:00
parent 16d51a2712
commit 00cc0ef5b7
12 changed files with 94 additions and 84 deletions

View File

@@ -7,6 +7,9 @@ using Project.StateMachine;
using COMM;
using AR;
using AGVNavigationCore.Utils;
using AGVNavigationCore.PathFinding.Core;
using AGVNavigationCore.Models;
using AGVNavigationCore.PathFinding.Planning;
namespace Project
{
@@ -38,6 +41,32 @@ namespace Project
return true;
}
AGVPathResult CalcPath(MapNode startNode, MapNode targetNode)
{
var nodes = PUB._mapCanvas.Nodes;
var _simulatorCanvas = PUB._mapCanvas;
var _mapNodes = PUB._mapCanvas.Nodes;
// 현재 AGV 방향 가져오기
var selectedAGV = PUB._virtualAGV;
var currentDirection = selectedAGV.CurrentDirection;
// AGV의 이전 위치에서 가장 가까운 노드 찾기
var prevNode = selectedAGV.PrevNode;
var prevDir = selectedAGV.PrevDirection;
// Core Logic으로 이관됨
var pathFinder = new AGVPathfinder(nodes);
var result = pathFinder.CalculatePath(startNode, targetNode, prevNode, prevDir);
//게이트웨이노드를 하이라이트강조 한단
_simulatorCanvas.HighlightNodeId = (result.Gateway?.Id ?? string.Empty);
return result;
}
/// <summary>
/// 실행스텝을 오류로 전환합니다.
/// 로그메세지(에러)가 추가됩니다.
@@ -45,8 +74,13 @@ namespace Project
/// </summary>
/// <param name="ermsg"></param>
/// <param name="ecode"></param>
public void SetRunStepError(string errmsg, eECode ecode)
public void SetRunStepError(ENIGProtocol.AGVErrorCode ecode, string errmsg = "")
{
if (string.IsNullOrEmpty(errmsg))
{
errmsg = ENIGProtocol.AGVUtility.GetAGVErrorMessage(ecode);
}
PUB.AGV.AGVMoveStop(errmsg);
PUB.log.AddE(errmsg);
PUB._mapCanvas.SetAlertMessage(errmsg);
@@ -152,7 +186,7 @@ namespace Project
VAR.I32[eVarInt32.PathValidationError] += 1;
if (VAR.I32[eVarInt32.PathValidationError] > 50)
{
SetRunStepError($"연속 경로 무결성 오류로 인해 중지 합니다", eECode.PATH_INTEGRITY_FAIL);
SetRunStepError(ENIGProtocol.AGVErrorCode.PATH_INTEGRITY_FAIL, $"연속 경로 무결성 오류로 인해 중지 합니다");
}
return false;
}