From 402f155a99a70dba6e2c561732d5a51a7944f83a Mon Sep 17 00:00:00 2001 From: backuppc Date: Fri, 24 Oct 2025 15:49:34 +0900 Subject: [PATCH] refactor: Remove unused functions and fields from pathfinding and models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../Controls/UnifiedAGVCanvas.cs | 4 - .../AGVNavigationCore/Models/VirtualAGV.cs | 3 - .../PathFinding/Planning/AGVPathfinder.cs | 164 ------------------ 3 files changed, 171 deletions(-) diff --git a/Cs_HMI/AGVLogic/AGVNavigationCore/Controls/UnifiedAGVCanvas.cs b/Cs_HMI/AGVLogic/AGVNavigationCore/Controls/UnifiedAGVCanvas.cs index c7f3c88..ca8c67e 100644 --- a/Cs_HMI/AGVLogic/AGVNavigationCore/Controls/UnifiedAGVCanvas.cs +++ b/Cs_HMI/AGVLogic/AGVNavigationCore/Controls/UnifiedAGVCanvas.cs @@ -144,10 +144,6 @@ namespace AGVNavigationCore.Controls public event EventHandler<(MapNode From, MapNode To)> ConnectionDeleted; public event EventHandler MapChanged; - // AGV ์ด๋ฒคํŠธ - public event EventHandler AGVSelected; - public event EventHandler AGVStateChanged; - #endregion #region Properties diff --git a/Cs_HMI/AGVLogic/AGVNavigationCore/Models/VirtualAGV.cs b/Cs_HMI/AGVLogic/AGVNavigationCore/Models/VirtualAGV.cs index 28ab682..47ca282 100644 --- a/Cs_HMI/AGVLogic/AGVNavigationCore/Models/VirtualAGV.cs +++ b/Cs_HMI/AGVLogic/AGVNavigationCore/Models/VirtualAGV.cs @@ -50,8 +50,6 @@ namespace AGVNavigationCore.Models private string _agvId; private Point _currentPosition; private Point _prevPosition; - private string _targetId; - private string _currentId; private AgvDirection _currentDirection; private AgvDirection _prevDirection; private AGVState _currentState; @@ -75,7 +73,6 @@ namespace AGVNavigationCore.Models // ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์„ค์ • private readonly float _moveSpeed = 50.0f; // ํ”ฝ์…€/์ดˆ - private readonly float _rotationSpeed = 90.0f; // ๋„/์ดˆ private bool _isMoving; #endregion diff --git a/Cs_HMI/AGVLogic/AGVNavigationCore/PathFinding/Planning/AGVPathfinder.cs b/Cs_HMI/AGVLogic/AGVNavigationCore/PathFinding/Planning/AGVPathfinder.cs index 80b6de6..201ae08 100644 --- a/Cs_HMI/AGVLogic/AGVNavigationCore/PathFinding/Planning/AGVPathfinder.cs +++ b/Cs_HMI/AGVLogic/AGVNavigationCore/PathFinding/Planning/AGVPathfinder.cs @@ -261,169 +261,5 @@ namespace AGVNavigationCore.PathFinding.Planning } - - /// - /// ๊ธฐ๋ณธ ๊ฒฝ๋กœ๋ฅผ ์ƒ์„ธ ๊ฒฝ๋กœ๋กœ ๋ณ€ํ™˜ - /// - private List ConvertToDetailedPath(List simplePath, AgvDirection initialDirection) - { - var detailedPath = new List(); - 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; - } - - - /// - /// ๊ฒฝ๋กœ ์ด ๊ฑฐ๋ฆฌ ๊ณ„์‚ฐ - /// - private float CalculatePathDistance(List 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; - } - - /// - /// ๊ฒฝ๋กœ ์œ ํšจ์„ฑ ๊ฒ€์ฆ - /// - public bool ValidatePath(List 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); - } - - /// - /// ๋ฌผ๋ฆฌ์  ์ œ์•ฝ์‚ฌํ•ญ ๊ฒ€์ฆ - /// - private bool ValidatePhysicalConstraints(List 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; - } - - /// - /// ๊ฒฝ๋กœ ์ตœ์ ํ™” - /// - public AGVPathResult OptimizePath(AGVPathResult originalResult) - { - if (!originalResult.Success) - return originalResult; - - // TODO: ๊ฒฝ๋กœ ์ตœ์ ํ™” ๋กœ์ง ๊ตฌํ˜„ - // - ๋ถˆํ•„์š”ํ•œ ์ค‘๊ฐ„ ๋…ธ๋“œ ์ œ๊ฑฐ - // - ๋งˆ๊ทธ๋„ท ๋ฐฉํ–ฅ ์ตœ์ ํ™” - // - ๋ฐฉํ–ฅ ์ „ํ™˜ ์ตœ์†Œํ™” - - return originalResult; - } - - /// - /// ๋””๋ฒ„๊น…์šฉ ๊ฒฝ๋กœ ์ •๋ณด - /// - public string GetPathSummary(AGVPathResult result) - { - if (!result.Success) - return $"๊ฒฝ๋กœ ๊ณ„์‚ฐ ์‹คํŒจ: {result.ErrorMessage}"; - - var summary = new List - { - $"=== 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); - } - } } \ No newline at end of file