255 lines
9.8 KiB
C#
255 lines
9.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace AGVPathTester
|
|
{
|
|
/// <summary>
|
|
/// AGV 경로 탐색 및 방향전환 로직 테스트 프로그램
|
|
/// </summary>
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
Console.Title = "AGV Path Tester - ENIG Navigation System";
|
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
|
Console.WriteLine("======================================");
|
|
Console.WriteLine(" AGV Path Tester v1.0");
|
|
Console.WriteLine(" ENIG Navigation System");
|
|
Console.WriteLine("======================================");
|
|
Console.ResetColor();
|
|
Console.WriteLine();
|
|
|
|
try
|
|
{
|
|
// 맵 파일 경로
|
|
string mapFilePath = @"C:\Data\Source\(5613#) ENIG AGV\Source\Cs_HMI\Data\NewMap.agvmap";
|
|
|
|
if (!File.Exists(mapFilePath))
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
Console.WriteLine($"❌ 맵 파일을 찾을 수 없습니다: {mapFilePath}");
|
|
Console.ResetColor();
|
|
Console.WriteLine("Enter 키를 눌러 종료하세요...");
|
|
Console.ReadLine();
|
|
return;
|
|
}
|
|
|
|
// PathTester 초기화
|
|
var pathTester = new PathTester(mapFilePath);
|
|
|
|
if (!pathTester.Initialize())
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
Console.WriteLine("❌ PathTester 초기화 실패");
|
|
Console.ResetColor();
|
|
Console.WriteLine("Enter 키를 눌러 종료하세요...");
|
|
Console.ReadLine();
|
|
return;
|
|
}
|
|
|
|
Console.ForegroundColor = ConsoleColor.Green;
|
|
Console.WriteLine("✅ PathTester 초기화 완료");
|
|
Console.WriteLine($"📍 로드된 맵 노드 수: {pathTester.GetNodeCount()}");
|
|
Console.ResetColor();
|
|
Console.WriteLine();
|
|
|
|
// 자동 테스트 모드 체크
|
|
bool autoMode = args.Length > 0 && (args[0].ToLower() == "auto" || args[0].ToLower() == "batch");
|
|
|
|
if (autoMode)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
|
Console.WriteLine("🚀 자동 테스트 모드 실행");
|
|
Console.ResetColor();
|
|
Console.WriteLine();
|
|
|
|
// 먼저 맵 정보 표시
|
|
ShowMapInfo(pathTester);
|
|
Console.WriteLine("\n" + new string('=', 50) + "\n");
|
|
|
|
// 자동으로 모든 테스트 실행
|
|
RunBatchTests(pathTester);
|
|
|
|
Console.WriteLine();
|
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
|
Console.WriteLine("📊 모든 자동 테스트 완료!");
|
|
Console.ResetColor();
|
|
return;
|
|
}
|
|
|
|
// 빠른 테스트 모드 체크 (quick 002 015 forward)
|
|
if (args.Length >= 4 && args[0].ToLower() == "quick")
|
|
{
|
|
string startRfid = args[1];
|
|
string targetRfid = args[2];
|
|
string directionStr = args[3].ToLower();
|
|
|
|
var direction = directionStr == "backward" ?
|
|
AGVNavigationCore.Models.AgvDirection.Backward :
|
|
AGVNavigationCore.Models.AgvDirection.Forward;
|
|
|
|
pathTester.RunQuickTest(startRfid, targetRfid, direction);
|
|
return;
|
|
}
|
|
|
|
// 이동 기반 테스트 모드 체크 (movement 033 032 001 backward)
|
|
if (args.Length >= 5 && args[0].ToLower() == "movement")
|
|
{
|
|
string previousRfid = args[1];
|
|
string currentRfid = args[2];
|
|
string targetRfid = args[3];
|
|
string directionStr = args[4].ToLower();
|
|
|
|
var userDirection = directionStr == "backward" ?
|
|
AGVNavigationCore.Models.AgvDirection.Backward :
|
|
AGVNavigationCore.Models.AgvDirection.Forward;
|
|
|
|
pathTester.RunMovementBasedTestWithUserDirection(previousRfid, currentRfid, targetRfid, userDirection);
|
|
return;
|
|
}
|
|
|
|
// 대화형 메뉴
|
|
bool continueRunning = true;
|
|
while (continueRunning)
|
|
{
|
|
ShowMenu();
|
|
|
|
Console.Write("선택: ");
|
|
var input = Console.ReadLine()?.Trim();
|
|
|
|
switch (input)
|
|
{
|
|
case "1":
|
|
RunBasicPathTests(pathTester);
|
|
break;
|
|
case "2":
|
|
RunDirectionChangeTests(pathTester);
|
|
break;
|
|
case "3":
|
|
RunCustomTest(pathTester);
|
|
break;
|
|
case "4":
|
|
RunBatchTests(pathTester);
|
|
break;
|
|
case "5":
|
|
ShowMapInfo(pathTester);
|
|
break;
|
|
case "0":
|
|
case "q":
|
|
case "quit":
|
|
case "exit":
|
|
continueRunning = false;
|
|
break;
|
|
default:
|
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
|
Console.WriteLine("❓ 잘못된 선택입니다.");
|
|
Console.ResetColor();
|
|
break;
|
|
}
|
|
|
|
if (continueRunning)
|
|
{
|
|
Console.WriteLine("\nEnter 키를 눌러 계속하세요...");
|
|
Console.ReadLine();
|
|
// Console.Clear(); // Windows 콘솔 호환성 문제로 제거
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
Console.WriteLine($"❌ 프로그램 오류: {ex.Message}");
|
|
Console.WriteLine($"상세 정보: {ex}");
|
|
Console.ResetColor();
|
|
Console.WriteLine("Enter 키를 눌러 종료하세요...");
|
|
Console.ReadLine();
|
|
}
|
|
}
|
|
|
|
static void ShowMenu()
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.White;
|
|
Console.WriteLine("============ 메뉴 ============");
|
|
Console.WriteLine("1. 기본 경로 탐색 테스트");
|
|
Console.WriteLine("2. 방향 전환 경로 테스트");
|
|
Console.WriteLine("3. 사용자 정의 테스트");
|
|
Console.WriteLine("4. 배치 테스트 실행");
|
|
Console.WriteLine("5. 맵 정보 보기");
|
|
Console.WriteLine("0. 종료");
|
|
Console.WriteLine("=============================");
|
|
Console.ResetColor();
|
|
}
|
|
|
|
static void RunBasicPathTests(PathTester pathTester)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Magenta;
|
|
Console.WriteLine("🧪 기본 경로 탐색 테스트 실행");
|
|
Console.ResetColor();
|
|
|
|
pathTester.RunBasicPathTests();
|
|
}
|
|
|
|
static void RunDirectionChangeTests(PathTester pathTester)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Magenta;
|
|
Console.WriteLine("🔄 방향 전환 경로 테스트 실행");
|
|
Console.ResetColor();
|
|
|
|
pathTester.RunDirectionChangeTests();
|
|
}
|
|
|
|
static void RunCustomTest(PathTester pathTester)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Magenta;
|
|
Console.WriteLine("🎯 사용자 정의 테스트");
|
|
Console.ResetColor();
|
|
|
|
Console.Write("시작 노드 ID: ");
|
|
string startNodeId = Console.ReadLine()?.Trim();
|
|
|
|
Console.Write("목표 노드 ID: ");
|
|
string targetNodeId = Console.ReadLine()?.Trim();
|
|
|
|
Console.WriteLine("현재 방향 선택:");
|
|
Console.WriteLine("1. Forward (전진)");
|
|
Console.WriteLine("2. Backward (후진)");
|
|
Console.Write("선택 (기본값: Forward): ");
|
|
|
|
var directionInput = Console.ReadLine()?.Trim();
|
|
var currentDirection = (directionInput == "2") ?
|
|
AGVNavigationCore.Models.AgvDirection.Backward :
|
|
AGVNavigationCore.Models.AgvDirection.Forward;
|
|
|
|
if (!string.IsNullOrEmpty(startNodeId) && !string.IsNullOrEmpty(targetNodeId))
|
|
{
|
|
pathTester.RunSingleTest(startNodeId, targetNodeId, currentDirection);
|
|
}
|
|
else
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
|
Console.WriteLine("❓ 시작 노드 또는 목표 노드 ID가 비어있습니다.");
|
|
Console.ResetColor();
|
|
}
|
|
}
|
|
|
|
static void RunBatchTests(PathTester pathTester)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Magenta;
|
|
Console.WriteLine("📦 배치 테스트 실행");
|
|
Console.ResetColor();
|
|
|
|
pathTester.RunBatchTests();
|
|
}
|
|
|
|
static void ShowMapInfo(PathTester pathTester)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
|
Console.WriteLine("🗺️ 맵 정보");
|
|
Console.ResetColor();
|
|
|
|
pathTester.ShowMapInfo();
|
|
}
|
|
}
|
|
} |