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

namespace LFP_Manager.DataStructure
{
    public static class csCanConstData
    {
        public static class CanDeviceInfo
        {
            public const int VCI_PCI5121 = 1;
            public const int VCI_PCI9810 = 2;
            public const int VCI_USBCAN1 = 3;
            public const int VCI_USBCAN2 = 4;
            public const int VCI_USBCAN2A = 4;
            public const int VCI_PCI9820 = 5;
            public const int VCI_CAN232 = 6;
            public const int VCI_PCI5110 = 7;
            public const int VCI_CANLITE = 8;
            public const int VCI_ISA9620 = 9;
            public const int VCI_ISA5420 = 10;
            public const int VCI_PC104CAN = 11;
            public const int VCI_CANETUDP = 12;
            public const int VCI_CANETE = 12;
            public const int VCI_DNP9810 = 13;
            public const int VCI_PCI9840 = 14;
            public const int VCI_PC104CAN2 = 15;
            public const int VCI_PCI9820I = 16;
            public const int VCI_CANETTCP = 17;
            public const int VCI_PEC9920 = 18;
            public const int VCI_PCI5010U = 19;
            public const int VCI_USBCAN_E_U = 20;
            public const int VCI_USBCAN_2E_U = 21;
            public const int VCI_PCI5020U = 22;
            public const int VCI_EG20T_CAN = 23;
            public const int VCI_VALUE_CAN4_1 = 30;

            private static readonly string[] _deviceNames = new[]
            {
                "PCI5121", "PCI9810", "USBCAN1", "USBCAN2", "USBCAN2A",
                "PCI9820", "CAN232", "PCI5110", "CANLITE", "ISA9620",
                "ISA5420", "PC104CAN", "CANETUDP", "CANETE", "DNP9810",
                "PCI9840", "PC104CAN2", "PCI9820I", "CANETTCP", "PEC9920",
                "PCI5010U", "USBCAN_E_U", "USBCAN_2E_U", "PCI5020U",
                "EG20T_CAN", "VALUE_CAN4-1"
            };

            private static readonly int[] _deviceIds = new[]
            {
                1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 13, 14,
                15, 16, 17, 18, 19, 20, 21, 22, 23, 30
            };

            public static string[] DeviceNames => _deviceNames;
            public static int[] DeviceIds => _deviceIds;
        }

        public static class BaudRate
        {
            /// <summary>
            /// CAN 통신 속도 (bps)
            /// </summary>
            private static readonly int[] _baudRateInts = new[]
            {
                1000000, 800000, 500000, 250000, 125000,
                100000, 50000, 20000, 10000, 5000
            };

            /// <summary>
            /// CAN 통신 속도 설정값
            /// </summary>
            private static readonly int[] _baudRates = new[]
            {
                0x060003, // 1000Kbps
                0x060004, // 800Kbps
                0x060007, // 500Kbps
                0x1C0008, // 250Kbps
                0x1C0011, // 125Kbps
                0x160023, // 100Kbps
                0x1C002C, // 50Kbps
                0x1600B3, // 20Kbps
                0x1C00E0, // 10Kbps
                0x1C01C1  // 5Kbps
            };

            /// <summary>
            /// USBCAN II 전용 통신 속도 설정값 (Timer 0 + Timer 1)
            /// </summary>
            private static readonly int[] _baudRatesOther = new[]
            {
                0x0014, // 1000Kbps
                0x0016, // 800Kbps
                0x001C, // 500Kbps
                0x011C, // 250Kbps
                0x031C, // 125Kbps
                0x041C, // 100Kbps
                0x091C, // 50Kbps
                0x181C, // 20Kbps
                0x311C, // 10Kbps
                0xBFFF  // 5Kbps
            };

            private static readonly string[] _baudRateStrings = new[]
            {
                "1000Kbps", "800Kbps", "500Kbps", "250Kbps", "125Kbps",
                "100Kbps", "50Kbps", "20Kbps", "10Kbps", "5Kbps"
            };

            public static int[] BaudRateInts => _baudRateInts;
            public static int[] BaudRates => _baudRates;
            public static int[] BaudRatesOther => _baudRatesOther;
            public static string[] BaudRateStrings => _baudRateStrings;
        }

        public static class SendType
        {
            public const int Normal = 0;
            public const int Single_Normal = 1;
            public const int Loop_Back = 2;
            public const int Single_Loop_Back = 3;
        }

        public static class FrameType
        {
            public const int Standard = 0;
            public const int Extended = 1;
        }

        public static class FrameFormat
        {
            public const int Data_Frame = 0;
            public const int Remote_Frame = 1;
        }
    }
}
