This commit is contained in:
backuppc
2025-07-14 16:32:56 +09:00
parent fb8c488890
commit 4a45ae15d6
20 changed files with 663 additions and 153 deletions

View File

@@ -64,7 +64,7 @@ namespace AGVControl
PredictResult = CreatePrediction("이전 작업이 완료되지 않았습니다",
AGVActionReasonCode.busy,
AGVMoveState.Stop,
agv.CurrentMOTDirection, false);
agv.Current_Motor_Direction, false);
return PredictResult;
}
@@ -80,9 +80,9 @@ namespace AGVControl
PredictResult = CreatePrediction("AGV 위치 미확정(처음 기동)",
AGVActionReasonCode.NoPosition,
AGVMoveState.Run,
Direction.Backward, true,
AgvDir.Backward, true,
moveSpeed: AgvSpeed.Low,
moveDiv: AgvRunDirection.Straight);
moveDiv: AgvSts.Straight);
return PredictResult;
}
@@ -92,9 +92,9 @@ namespace AGVControl
PredictResult = CreatePrediction("AGV이동방향 알수없음",
AGVActionReasonCode.NoDirection,
AGVMoveState.Run,
Direction.Backward, true,
AgvDir.Backward, true,
moveSpeed: AgvSpeed.Low,
moveDiv: AgvRunDirection.Straight);
moveDiv: AgvSts.Straight);
return PredictResult;
}
@@ -107,7 +107,7 @@ namespace AGVControl
PredictResult = CreatePrediction("경로 없음 또는 현재 위치 미확정",
AGVActionReasonCode.NoPath,
AGVMoveState.Stop,
agv.CurrentMOTDirection, true);
agv.Current_Motor_Direction, true);
return PredictResult;
}
else
@@ -117,10 +117,10 @@ namespace AGVControl
var prlt = CalculatePath(CurPt, agv.TargetRFID);
if (prlt.Success == false)
{
PredictResult = CreatePrediction("목적지 경로 예측 실패",
PredictResult = CreatePrediction("목적지 경로 예측 실패",
AGVActionReasonCode.Unknown,
AGVMoveState.Stop,
agv.CurrentMOTDirection, true,
agv.Current_Motor_Direction, true,
nextRFID: agv.TargetRFID);
return PredictResult;
}
@@ -140,12 +140,10 @@ namespace AGVControl
PredictResult = CreatePrediction("현재 위치가 경로에 없음",
AGVActionReasonCode.NotOnPath,
AGVMoveState.Stop,
agv.CurrentMOTDirection, true);
agv.Current_Motor_Direction, true);
return PredictResult;
}
// 4. 목적지 도달 전, 회전이 필요한경우인가?
// 목적지 RFID 정보
var destRFID = agv.MainPath.Last();
@@ -163,7 +161,7 @@ namespace AGVControl
if (IsLiftDir == false)
{
AgvSpeed? agv_spd = null;
AgvRunDirection? agv_dir = null;
AgvSts? agv_dir = null;
//회전가능한 위치로 이동을 해야한다
@@ -174,7 +172,7 @@ namespace AGVControl
PredictResult = CreatePrediction("회전 가능한 위치가 없습니다",
AGVActionReasonCode.NoTurnPoint,
AGVMoveState.Stop,
agv.CurrentMOTDirection, true);
agv.Current_Motor_Direction, true);
return PredictResult;
}
@@ -195,7 +193,7 @@ namespace AGVControl
PredictResult = CreatePrediction("회전 위치까지의 경로를 계산할 수 없습니다",
AGVActionReasonCode.PathCalcError,
AGVMoveState.Stop,
agv.CurrentMOTDirection, true,
agv.Current_Motor_Direction, true,
nextRFID: nearTurnPoint);
return PredictResult;
}
@@ -205,7 +203,7 @@ namespace AGVControl
//현재 모터방향을 확인하여 대상까지 이동하도록 해야한다
var curidx = agv.SubPath.FindIndex(t => t.Value == curPT.Value);
var preidx = agv.SubPath.FindIndex(t => t.Value == PrePT.Value);
Direction newdirection = agv.CurrentMOTDirection;
AgvDir newdirection = agv.Current_Motor_Direction;
string message = "턴위치로 이동중";
@@ -213,13 +211,11 @@ namespace AGVControl
if (preidx > curidx)
{
//지정경로를 거꾸로 이동하고 있다
if (agv.CurrentMOTDirection == Direction.Forward)
newdirection = Direction.Backward;
if (agv.Current_Motor_Direction == AgvDir.Forward)
newdirection = AgvDir.Backward;
else
newdirection = Direction.Forward;
newdirection = AgvDir.Forward;
message += "(방향전환)";
}
//도로정보를 확인하여 속도와 분기명령을 실행한다
@@ -232,7 +228,7 @@ namespace AGVControl
AGVMoveState.Run,
newdirection, true,
moveSpeed: agv_spd,
moveDiv: agv_dir,
moveDiv: agv_dir,
nextRFID: nearTurnPoint);
return PredictResult;
}
@@ -242,10 +238,10 @@ namespace AGVControl
agv_dir = roadinfo2.dir;
PredictResult = CreatePrediction("턴 완료 대기",
AGVActionReasonCode.NeedTurn,
PredictResult = CreatePrediction("턴(이동) 완료 대기",
AGVActionReasonCode.NeedTurnMove,
AGVMoveState.Stop,
agv.CurrentMOTDirection, true,
agv.Current_Motor_Direction, true,
moveSpeed: agv_spd,
moveDiv: agv_dir,
nextRFID: nearTurnPoint);
@@ -256,21 +252,53 @@ namespace AGVControl
if (agv.SubPath != null && agv.SubPath.Any())
agv.SubPath.Clear();
//현재위치의 RFID에서 턴이 필요한경우
if (agv.CurrentRFID.NeedTurn)
{
//Turn이 완료되지 않았다면 턴 완료를 대기한다.
if (agv.CurrentRFID.TurnOK == false)
{
//아직 턴위치에 멈추지 않았다
if (agv.CurrentRFID.TurnStop == false)
{
//현재위치로 마크스탑이동을 하게한다
PredictResult = CreatePrediction("Wait for Turn(P)-Mark Stop",
AGVActionReasonCode.WaitForMarkStop,
AGVMoveState.Run,
agv.Current_Motor_Direction, true,
moveSpeed: agv.CurrentSpeed,
moveDiv: agv.CurrentSTS);
}
else
{
//턴위치에 정지했으니. 턴완료를 기다려야 한다
PredictResult = CreatePrediction("Wait for Turn(P)",
AGVActionReasonCode.NeedTurnPoint,
AGVMoveState.Run,
agv.Current_Motor_Direction, true,
moveSpeed: agv.CurrentSpeed,
moveDiv: agv.CurrentSTS);
}
return PredictResult;
}
}
//3. 목적지위치까지 이동이 완료되지 않았다면 계속 이동을 하게한다
if (agv.CurrentRFID.Value != destRFID.Value)
{
//현재 모터방향을 확인하여 대상까지 이동하도록 해야한다
var curidx = agv.MainPath.FindIndex(t => t.Value == curPT.Value);
var preidx = agv.MainPath.FindIndex(t => t.Value == PrePT.Value);
Direction newdirection = agv.CurrentMOTDirection;
AgvDir newdirection = agv.Current_Motor_Direction;
string message = "목적지 이동중";
if (preidx > curidx)
{
//지정경로를 거꾸로 이동하고 있다
if (agv.CurrentMOTDirection == Direction.Forward)
newdirection = Direction.Backward;
if (agv.Current_Motor_Direction == AgvDir.Forward)
newdirection = AgvDir.Backward;
else
newdirection = Direction.Forward;
newdirection = AgvDir.Forward;
message += "(방향전환)";
}
@@ -294,7 +322,7 @@ namespace AGVControl
PredictResult = CreatePrediction("경로의 마지막 지점(목적지 도달)",
AGVActionReasonCode.Arrived,
AGVMoveState.Stop,
agv.CurrentMOTDirection, true,
agv.Current_Motor_Direction, true,
nextRFID: destRFID);
return PredictResult;
}
@@ -304,7 +332,7 @@ namespace AGVControl
PredictResult = CreatePrediction($"ERR:{ex.Message}",
AGVActionReasonCode.Unknown,
AGVMoveState.Stop,
agv.CurrentMOTDirection, true);
agv.Current_Motor_Direction, true);
return PredictResult;
}
finally
@@ -314,11 +342,11 @@ namespace AGVControl
}
(AgvSpeed? spd, AgvRunDirection? dir, RFIDConnection info) GetRoadInfo(List<RFIDPoint> paths, RFIDPoint curPT)
(AgvSpeed? spd, AgvSts? dir, RFIDConnection info) GetRoadInfo(List<RFIDPoint> paths, RFIDPoint curPT)
{
//도로정보를 확인하여 속도와 분기명령을 실행한다
AgvSpeed? agv_spd = null;
AgvRunDirection? agv_div = null;
AgvSts? agv_div = null;
RFIDConnection info = null;
var nextpt = paths.Skip(paths.FindIndex(t => t.Value == curPT.Value) + 1).FirstOrDefault();
@@ -504,7 +532,7 @@ namespace AGVControl
var lstpt = agv.MovementHistory.Last();
//뒤로이동하는경우라면 이전위치에 리프트가 있다.
if (lstpt.Direction == Direction.Backward)
if (lstpt.Direction == AgvDir.Backward)
{
TargetPT = prept;
}
@@ -566,9 +594,9 @@ namespace AGVControl
string reason,
AGVActionReasonCode reasonCode,
AGVMoveState moveState,
Direction direction, bool IDXUpdate = true,
AgvDir direction, bool IDXUpdate = true,
AgvSpeed? moveSpeed = null,
AgvRunDirection? moveDiv = null,
AgvSts? moveDiv = null,
RFIDPoint nextRFID = null
)
{
@@ -581,7 +609,8 @@ namespace AGVControl
Direction = direction,
MoveSpeed = moveSpeed,
MoveDiv = moveDiv,
Idx = IDXUpdate ? (PredictResult?.Idx + 1 ?? 1) : (PredictResult?.Idx ?? 0)
Idx = IDXUpdate ? (PredictResult?.Idx + 1 ?? 1) : (PredictResult?.Idx ?? 0),
CreateTime = DateTime.Now,
};
newPrediction.Changed = IsPredictionChanged(newPrediction);