refactor: Remove unused functions and fields from pathfinding and models
Removed from AGVPathfinder.cs: - ConvertToDetailedPath() - unused private method - CalculatePathDistance() - unused private method - ValidatePath() - unused public method - ValidatePhysicalConstraints() - only called by ValidatePath (now removed) - OptimizePath() - unused public method (TODO placeholder only) - GetPathSummary() - unused public method (debug helper) Kept essential methods: - FindNearestJunction() - used by FindPath_test - FindNearestJunctionOnPath() - used by FindPath_test - MakeDetailData() - used by FindPath_test - MakeMagnetDirection() - used by FindPath_test Removed from VirtualAGV.cs: - _targetId field - never used - _currentId field - never used - _rotationSpeed field - never used (read-only, no references) Removed from UnifiedAGVCanvas.cs: - AGVSelected event - unused - AGVStateChanged event - unused Result: Cleaner codebase, reduced technical debt, easier maintenance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -144,10 +144,6 @@ namespace AGVNavigationCore.Controls
|
|||||||
public event EventHandler<(MapNode From, MapNode To)> ConnectionDeleted;
|
public event EventHandler<(MapNode From, MapNode To)> ConnectionDeleted;
|
||||||
public event EventHandler MapChanged;
|
public event EventHandler MapChanged;
|
||||||
|
|
||||||
// AGV 이벤트
|
|
||||||
public event EventHandler<IAGV> AGVSelected;
|
|
||||||
public event EventHandler<IAGV> AGVStateChanged;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ namespace AGVNavigationCore.Models
|
|||||||
private string _agvId;
|
private string _agvId;
|
||||||
private Point _currentPosition;
|
private Point _currentPosition;
|
||||||
private Point _prevPosition;
|
private Point _prevPosition;
|
||||||
private string _targetId;
|
|
||||||
private string _currentId;
|
|
||||||
private AgvDirection _currentDirection;
|
private AgvDirection _currentDirection;
|
||||||
private AgvDirection _prevDirection;
|
private AgvDirection _prevDirection;
|
||||||
private AGVState _currentState;
|
private AGVState _currentState;
|
||||||
@@ -75,7 +73,6 @@ namespace AGVNavigationCore.Models
|
|||||||
|
|
||||||
// 시뮬레이션 설정
|
// 시뮬레이션 설정
|
||||||
private readonly float _moveSpeed = 50.0f; // 픽셀/초
|
private readonly float _moveSpeed = 50.0f; // 픽셀/초
|
||||||
private readonly float _rotationSpeed = 90.0f; // 도/초
|
|
||||||
private bool _isMoving;
|
private bool _isMoving;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -261,169 +261,5 @@ namespace AGVNavigationCore.PathFinding.Planning
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 기본 경로를 상세 경로로 변환
|
|
||||||
/// </summary>
|
|
||||||
private List<NodeMotorInfo> ConvertToDetailedPath(List<string> simplePath, AgvDirection initialDirection)
|
|
||||||
{
|
|
||||||
var detailedPath = new List<NodeMotorInfo>();
|
|
||||||
var currentDirection = initialDirection;
|
|
||||||
|
|
||||||
for (int i = 0; i < simplePath.Count; i++)
|
|
||||||
{
|
|
||||||
string currentNodeId = simplePath[i];
|
|
||||||
string nextNodeId = (i + 1 < simplePath.Count) ? simplePath[i + 1] : null;
|
|
||||||
|
|
||||||
// 마그넷 방향 계산
|
|
||||||
MagnetDirection magnetDirection = MagnetDirection.Straight;
|
|
||||||
if (i > 0 && nextNodeId != null)
|
|
||||||
{
|
|
||||||
string prevNodeId = simplePath[i - 1];
|
|
||||||
magnetDirection = _junctionAnalyzer.GetRequiredMagnetDirection(prevNodeId, currentNodeId, nextNodeId, currentDirection);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 노드 정보 생성
|
|
||||||
var nodeMotorInfo = new NodeMotorInfo(
|
|
||||||
currentNodeId,
|
|
||||||
currentDirection,
|
|
||||||
nextNodeId,
|
|
||||||
magnetDirection
|
|
||||||
);
|
|
||||||
|
|
||||||
// 회전 가능 노드 설정
|
|
||||||
var mapNode = _mapNodes.FirstOrDefault(n => n.NodeId == currentNodeId);
|
|
||||||
if (mapNode != null)
|
|
||||||
{
|
|
||||||
nodeMotorInfo.CanRotate = mapNode.CanRotate;
|
|
||||||
}
|
|
||||||
|
|
||||||
detailedPath.Add(nodeMotorInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return detailedPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 경로 총 거리 계산
|
|
||||||
/// </summary>
|
|
||||||
private float CalculatePathDistance(List<NodeMotorInfo> detailedPath)
|
|
||||||
{
|
|
||||||
float totalDistance = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < detailedPath.Count - 1; i++)
|
|
||||||
{
|
|
||||||
var currentNode = _mapNodes.FirstOrDefault(n => n.NodeId == detailedPath[i].NodeId);
|
|
||||||
var nextNode = _mapNodes.FirstOrDefault(n => n.NodeId == detailedPath[i + 1].NodeId);
|
|
||||||
|
|
||||||
if (currentNode != null && nextNode != null)
|
|
||||||
{
|
|
||||||
float dx = nextNode.Position.X - currentNode.Position.X;
|
|
||||||
float dy = nextNode.Position.Y - currentNode.Position.Y;
|
|
||||||
totalDistance += (float)Math.Sqrt(dx * dx + dy * dy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return totalDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 경로 유효성 검증
|
|
||||||
/// </summary>
|
|
||||||
public bool ValidatePath(List<NodeMotorInfo> detailedPath)
|
|
||||||
{
|
|
||||||
if (detailedPath == null || detailedPath.Count == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// 1. 모든 노드가 존재하는지 확인
|
|
||||||
foreach (var nodeInfo in detailedPath)
|
|
||||||
{
|
|
||||||
if (!_mapNodes.Any(n => n.NodeId == nodeInfo.NodeId))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 연결성 확인
|
|
||||||
for (int i = 0; i < detailedPath.Count - 1; i++)
|
|
||||||
{
|
|
||||||
string currentId = detailedPath[i].NodeId;
|
|
||||||
string nextId = detailedPath[i + 1].NodeId;
|
|
||||||
|
|
||||||
if (!_basicPathfinder.AreNodesConnected(currentId, nextId))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 물리적 제약사항 확인
|
|
||||||
return ValidatePhysicalConstraints(detailedPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 물리적 제약사항 검증
|
|
||||||
/// </summary>
|
|
||||||
private bool ValidatePhysicalConstraints(List<NodeMotorInfo> detailedPath)
|
|
||||||
{
|
|
||||||
for (int i = 1; i < detailedPath.Count; i++)
|
|
||||||
{
|
|
||||||
var prevNode = detailedPath[i - 1];
|
|
||||||
var currentNode = detailedPath[i];
|
|
||||||
|
|
||||||
// 급작스러운 방향 전환 검증
|
|
||||||
if (prevNode.MotorDirection != currentNode.MotorDirection)
|
|
||||||
{
|
|
||||||
// 방향 전환은 반드시 회전 가능 노드에서만
|
|
||||||
if (!currentNode.CanRotate && !currentNode.IsDirectionChangePoint)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 경로 최적화
|
|
||||||
/// </summary>
|
|
||||||
public AGVPathResult OptimizePath(AGVPathResult originalResult)
|
|
||||||
{
|
|
||||||
if (!originalResult.Success)
|
|
||||||
return originalResult;
|
|
||||||
|
|
||||||
// TODO: 경로 최적화 로직 구현
|
|
||||||
// - 불필요한 중간 노드 제거
|
|
||||||
// - 마그넷 방향 최적화
|
|
||||||
// - 방향 전환 최소화
|
|
||||||
|
|
||||||
return originalResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 디버깅용 경로 정보
|
|
||||||
/// </summary>
|
|
||||||
public string GetPathSummary(AGVPathResult result)
|
|
||||||
{
|
|
||||||
if (!result.Success)
|
|
||||||
return $"경로 계산 실패: {result.ErrorMessage}";
|
|
||||||
|
|
||||||
var summary = new List<string>
|
|
||||||
{
|
|
||||||
$"=== AGV 고급 경로 계획 결과 ===",
|
|
||||||
$"총 노드 수: {result.DetailedPath.Count}",
|
|
||||||
$"총 거리: {result.TotalDistance:F1}px",
|
|
||||||
$"계산 시간: {result.CalculationTimeMs}ms",
|
|
||||||
$"방향 전환: {(result.RequiredDirectionChange ? $"필요 (노드: {result.DirectionChangeNode})" : "불필요")}",
|
|
||||||
$"설명: {result.PlanDescription}",
|
|
||||||
"",
|
|
||||||
"=== 상세 경로 ===",
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var nodeInfo in result.DetailedPath)
|
|
||||||
{
|
|
||||||
summary.Add(nodeInfo.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Join("\n", summary);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user