using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace arDev
{
    public partial class Narumi
    {
        public enum eMoveDir
        {
            Forward,
            Backward,
        }
        public enum eMoveSpd
        {
            High,
            Mid,
            Low,
        }
        public enum eSetPIDSpeed
        {
            High,
            Middle,
            Low,
            Stop,
        }
        public enum eSetSpeed
        {
            High,
            Middle,
            Low,
            Stop,
            Rotation,
        }
        public enum eBunki
        {
            Right,
            Strate,
            Left,
        }

        public enum Messagetype
        {
            Normal,
            Error,
            Send,
            Recv,
        }
        public enum DataType
        {
            UNKNOWN,
            TAG,
            CALL,
            STS,
            ACK,
            NAK,
            CCA,
        }
        public class BunkiData
        {
            public BunkiData()
            {

            }
            public BunkiData(char dir, char bunki, char speed)
            {
                if (dir == 'F') Direction = eMoveDir.Forward;
                else if (dir == 'B') Direction = eMoveDir.Backward;

                if (bunki == 'S') Bunki = eBunki.Strate;
                else if (bunki == 'L') Bunki = eBunki.Left;
                else if (bunki == 'R') Bunki = eBunki.Right;

                if (speed == 'H') this.Speed = eMoveSpd.High;
                else if (speed == 'M') this.Speed = eMoveSpd.Mid;
                else if (speed == 'L') this.Speed = eMoveSpd.Low;
            }
            public eMoveDir Direction { get; set; } = eMoveDir.Forward;
            public eBunki Bunki { get; set; } = eBunki.Strate;
            public eMoveSpd Speed { get; set; } = eMoveSpd.Mid;
            public int PBSSensor { get; set; } = 1;
            public override string ToString()
            {
                System.Text.StringBuilder sb = new StringBuilder();
                sb.Append(Direction.ToString()[0]);
                sb.Append(Bunki.ToString()[0]);
                sb.Append(Speed.ToString()[0]);
                sb.Append(PBSSensor.ToString()[0]);

                return sb.ToString();
            }
        }
        public enum eAgvCmd
        {
            /// <summary>
            /// 충전시작
            /// CMD : CBT02{nBatteryNo}I0103
            /// </summary>
            ChargeOn,

            /// <summary>
            /// 충전취소
            /// CMD : CBT02{nBatteryNo}O0103
            /// </summary>
            ChargeOf,

            /// <summary>
            /// 이동명령(파라미터필요)
            /// 이동대상,속도(H,M,L),센서사용여부(1,0)            
            /// ex) BSLTH0
            /// CMD : CRT{param}
            /// </summary>
            ManualMove,

            /// <summary>
            /// 기동명령
            /// CMD : CRN0000
            /// </summary>
            MoveStart,

            /// <summary>
            /// 분기명령
            /// CMD : CBR{param}
            /// </summary>
            MoveSet,

            /// <summary>
            /// 정지 명령
            /// CMD : CST0S000000
            /// </summary>
            MoveStop,

            /// <summary>
            /// 콜 취소,
            /// Param : 번호  char(1)
            /// CMD : CCL0{param}010000
            /// </summary>
            CallCancle,

            /// <summary>
            /// CMD : CTL0000
            /// </summary>
            TurnLeft,

            /// <summary>
            /// CMD : CTR0000
            /// </summary>
            TurnRight,

            /// <summary>
            /// CMD : CTB0000
            /// </summary>
            BackAndTurn,

            /// <summary>
            /// CMD : CBZ
            /// </summary>
            TowerLamp,

            /// <summary>
            /// CMD : SFR
            /// </summary>
            ErrorReset,

            /// <summary>
            /// CMD : CLF
            /// </summary>
            LiftControl,

            /// <summary>
            /// SS(H/M/L/S)
            /// SRS
            /// </summary>
            SetSpeed,

            CPUReset,

            TurnGDSCenterScope,
         
            BackTrunResumeTime,
            GateoutTime,

        }
        public enum eForm
        {
            DriveControl,
            ManualControl,
            RouteSelect,
            Setting,
            ModeChange,
        }
        public enum eNotify
        {
            ReadTag,
            IpAddresschanged,
            NameChanged,
            ReadViewStep,
            ReadViewCall,
            WatchError,

            /// <summary>
            /// 통신에서받은 AGV의 상태값이며, 속도 진행 방향을 가지고 있음
            /// Dashboardform 하단에 상태 표시 함
            /// </summary>
            StatusDisplay,
            StatusComm,
            StatusRiv,
            StatusETC,

            ChangeMode,
            /// <summary>
            /// 편집대상경로는 아래 변수에 저장되어잇음
            /// datamanager.sEditrRoute
            /// </summary>
            EditRoute,
        }


        public enum LiftCommand
        {
            /// <summary>
            /// lift up
            /// </summary>
            UP,
            /// <summary>
            /// lift down
            /// </summary>
            DN,
            /// <summary>
            /// lift 동작 정지
            /// </summary>
            STP,
            /// <summary>
            /// magnet holder on
            /// </summary>
            ON,
            /// <summary>
            /// magnet holder off
            /// </summary>
            OFF
        }

        public enum eflag
        {
            Emergency = 0,
            Overcurrent,
            Charger_run_error,
            Charger_pos_error,
            line_out_error = 4,

            /// <summary>
            /// 기동시 자석 감지 에러
            /// </summary>
            runerror_by_no_magent_line = 5,
            /// <summary>
            /// 호출제어기 통신 오류
            /// </summary>
            controller_comm_error = 6,

            /// <summary>
            /// 배터리 저전압
            /// </summary>
            battery_low_voltage = 7,

            spare08 = 8,

            lift_timeout = 9,
            lift_driver_overcurrent = 10,
            lift_driver_emergency = 11,

            /// <summary>
            /// 도착경보기 통신 오류 
            /// </summary>
            arrive_ctl_comm_error,

            /// <summary>
            /// 자동문제어기 통신 오류
            /// </summary>
            door_ctl_comm_error,

            /// <summary>
            /// 자동충전기 통신 오류
            /// </summary>
            charger_comm_error,

            /// <summary>
            /// 교차로 제어기 통신 오류
            /// </summary>
            cross_ctrl_comm_error,
        }
    }
}
