using System;

namespace AGVNavigationCore.Models
{
 

    /// <summary>
    /// 노드 타입 열거형
    /// </summary>
    public enum NodeType
    {
        /// <summary>일반 경로 노드</summary>
        Normal,
        /// <summary>로더</summary>
        Loader,
        /// <summary>
        /// 언로더
        /// </summary>
        UnLoader,
        /// <summary>
        /// 클리너
        /// </summary>
        Clearner,
        /// <summary>
        /// 버퍼
        /// </summary>
        Buffer,
        /// <summary>충전 스테이션</summary>
        Charging,
        /// <summary>라벨 (UI 요소)</summary>
        Label,
        /// <summary>이미지 (UI 요소)</summary>
        Image
    }

    /// <summary>
    /// 도킹 방향 열거형
    /// </summary>
    public enum DockingDirection
    {
        /// <summary>도킹 방향 상관없음 (일반 경로 노드)</summary>
        DontCare,
        /// <summary>전진 도킹 (충전기)</summary>
        Forward,
        /// <summary>후진 도킹 (로더, 클리너, 오프로더, 버퍼)</summary>
        Backward
    }

    /// <summary>
    /// AGV 이동 방향 열거형
    /// </summary>
    public enum AgvDirection
    {
        /// <summary>전진 (모니터 방향)</summary>
        Forward,
        /// <summary>후진 (리프트 방향)</summary>
        Backward,
        /// <summary>좌회전</summary>
        Left,
        /// <summary>우회전</summary>
        Right,
        /// <summary>정지</summary>
        Stop
    }

    /// <summary>
    /// 장비 타입 열거형
    /// </summary>
    public enum StationType
    {
        /// <summary>
        /// 일반노드
        /// </summary>
        Node,
        /// <summary>로더</summary>
        Loader,
        /// <summary>클리너</summary>
        Cleaner,
        /// <summary>오프로더</summary>
        Offloader,
        /// <summary>버퍼</summary>
        Buffer,
        /// <summary>충전기</summary>
        Charger
    }

    /// <summary>
    /// AGV턴상태
    /// </summary>
    public enum AGVTurn
    {
        None=0,

        /// <summary>
        /// left turn 90"
        /// </summary>
        L90,
        /// <summary>
        /// right turn 90"
        /// </summary>
        R90
    }


    /// <summary>
    /// 모터 명령 열거형 (실제 AGV 제어용)
    /// </summary>
    public enum MotorCommand
    {
        /// <summary>정지</summary>
        Stop,
        /// <summary>전진 (Forward - 모니터 방향)</summary>
        Forward,
        /// <summary>후진 (Backward - 리프트 방향)</summary>
        Backward
    }

    /// <summary>
    /// 마그넷 위치 열거형 (실제 AGV 제어용)
    /// </summary>
    public enum MagnetPosition
    {
        /// <summary>직진 (Straight)</summary>
        S,
        /// <summary>왼쪽 (Left)</summary>
        L,
        /// <summary>오른쪽 (Right)</summary>
        R
    }

    /// <summary>
    /// 속도 레벨 열거형 (실제 AGV 제어용)
    /// </summary>
    public enum SpeedLevel
    {
        /// <summary>저속 (Low)</summary>
        L,
        /// <summary>중속 (Medium)</summary>
        M,
        /// <summary>고속 (High)</summary>
        H
    }

    /// <summary>
    /// AGV 제어 명령 클래스 (실제 AGV 제어용)
    /// Predict() 메서드가 반환하는 다음 동작 명령
    /// </summary>
    public class AGVCommand
    {
        /// <summary>모터 명령 (정지/전진/후진)</summary>
        public MotorCommand Motor { get; set; }

        /// <summary>마그넷 위치 (직진/왼쪽/오른쪽)</summary>
        public MagnetPosition Magnet { get; set; }

        /// <summary>속도 레벨 (저속/중속/고속)</summary>
        public SpeedLevel Speed { get; set; }

        /// <summary>명령 이유 (디버깅/로깅용)</summary>
        public string Reason { get; set; }

        /// <summary>
        /// 생성자
        /// </summary>
        public AGVCommand(MotorCommand motor, MagnetPosition magnet, SpeedLevel speed, string reason = "")
        {
            Motor = motor;
            Magnet = magnet;
            Speed = speed;
            Reason = reason;
        }

        /// <summary>
        /// 기본 생성자
        /// </summary>
        public AGVCommand()
        {
            Motor = MotorCommand.Stop;
            Magnet = MagnetPosition.S;
            Speed = SpeedLevel.L;
            Reason = "";
        }

        public override string ToString()
        {
            return $"Motor:{Motor}, Magnet:{Magnet}, Speed:{Speed}" +
                   (string.IsNullOrEmpty(Reason) ? "" : $" ({Reason})");
        }
    }
}