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

namespace Common
{
    public  class ConfigHelper : INotifyPropertyChanged
    {
        //public const int plusPerRund = (3600/2);
        /// <summary>
        /// 产品列表
        /// </summary>
        public readonly static string[] Products = { "RTU-EN01", "DVP-EN01 / DVP-12SE", "Other DVP Series PLC", "AH Series PLC", "AS Series PLC" };
        /// <summary>
        /// 查询模式
        /// </summary>
        public readonly static string[] QueryModes = { "Standard MODBUS Request", "DMT Wrapped Function Code" };
        /// <summary>
        /// 支持功能
        /// </summary>
        public readonly static string[] Funcations = {"Read Coils","Read Discrete Inputs","Read Holding Registers","Read Holding Registers 32-bit",
                                                       "Read Input Registers","Write Single Coil","Write Single Register","Write Single Register 32-bit",
                                                       "Write Multiple Coils","Write Multiple Registers","Write Multiple Registers 32-bit"
                                                   };

        public event PropertyChangedEventHandler PropertyChanged;
        private static readonly ConfigHelper _Instance = new ConfigHelper();
        
        //端口配置
        private string _MotorPort;
        private string _MotorIp;
        private string _MotorGrayIp;
        private string _MotorDoorIp;
        private string _Devices_id;
        private string _IOPort;
        private string _IOPort_2;
        private string _left_display_tcs_port;
        private string _right_display_tcs_port;
        private string _power_led_tcs_port;
        private string _status_led_tcs_port;
        private string _Motor_ComPort;
        
        // 灰卡测试配置
        private int _GraySlave;
        private int _ProxPos30mm;
        private int _ProxPos20mm;
        private int _ProxPos13mm;
        private int _CapPos13mm;
        private int _CapPos20mm;
        private int _CapPos30mm;
        private int _Gray_Home;
        private ushort _GraySpeed;
        private ushort _GrayAcspeed;
        private ushort _GrayRespeed;
        // 耳机测试配置
        private ushort _HeadSlave;
        private int _HeadPos;
        private int _HeadPos_re;
        private ushort _HeadAcspeed;
        private ushort _HeadRespeed;
        private double _HeadTimeOut;
        private double _HeadStopRange_1;
        private double _HeadStopRange_2;
        private double _HeadStopSeepd;
        private double _HeadHomeTime;


        // door电机控制
        private ushort _DoorSlave ;
        private int _DoorWorkPostion = 0;
        private ushort _DoorSpeed = 500;
        private ushort _DoorAcspeed = 100;
        private ushort _DoorRespeed = 100;
        private ushort _Door_Home = 0;
        //IPDWheel旋钮电机控制
        private string _Motor_IPDWheel;
        private ushort _IPDWheelSlave ;
        private int _Motor_PositiveRotation = 100;
        private int _Motor_ReversingRotation = 100;
        private int _Motor_Position = 1;
        private int _Motor_Reversing = 1;       //旋钮电机反转扭矩百分比
        private int _Motor_StoptSpeed = 10;
        private int _Motor_IPD_TimeOut = 10000;
        private double _Torque_Range = 0.1;
        private int _Max_count = 10;            //电机停转条件一最大计数数目
        private int _Sample_length = 50;        //电机停转条件二抽样数量
        private int _Sample_range = 50;        //电机停转条件二抽样极差

        //1#IO板卡io参数
        private ushort _OUT_StartBtLight = 1; //启动按钮指示灯
        private ushort _OUT_RsetBtLight = 3; //复位按钮指示灯
        private ushort _OUT_TriColorBlue = 4; //三色灯-蓝
        private ushort _OUT_TriColorRed = 5; //三色灯-红
        private ushort _OUT_TriColorGreen = 6; //三色灯-绿
        private ushort _OUT_TriColorBuzzer = 7; //三色灯-蜂鸣器
        private ushort _OUT_StatusLightRed = 8; //状态指示灯红
        private ushort _OUT_StatusLightGreen = 9; //状态指示灯绿
        private ushort _OUT_PowerOutCylinder = 10; //Power推进气缸
        private ushort _OUT_PowerCylinder = 11; //电源键气缸
        private ushort _OUT_VolAddCylinder = 12; //音量键+气缸
        private ushort _OUT_VolReduceCylinder = 13; //音量键-气缸
        private ushort _IN_E_Stop = 1; //急停按钮
        private ushort _IN_Start = 2; //启动按钮
        private ushort _IN_Reset = 4; //复位按钮
        private ushort _IN_PoweroutOrigin = 6; //Powr推进气缸原点
        private ushort _IN_PowerOutTest = 5; //Power推进气缸到位
        private ushort _IN_PowerOrigin = 8; //电源键气缸原点
        private ushort _IN_PowerTest = 7; //电源键气缸到位
        private ushort _IN_VolAddOrigin = 10; //音量键+气缸原点
        private ushort _IN_VolAddTest = 9; //音量键+气缸到位
        private ushort _IN_VolReduOrigin = 12; //音量键-气缸原点
        private ushort _IN_VolReduTest = 11;//音量键-气缸到位
        private ushort _IN_PogoOrigin = 14; //Pogo滑台气缸原点
        private ushort _IN_PogoTest = 13; //Pogo滑台气缸到位
        private ushort _IN_CoverOpen = 15; //Holder盖子sensor
        private ushort _IN_CoverClose = 16; //Holder盖子气缸到位
        private ushort _IN_LeftCover_ON = 16; //检测左夹紧气缸伸出
        private ushort _IN_CheckDUT_1 = 15; //检测DUT到位感应1
        //2#IO板卡io参数
        private ushort _OUT_PowerRGBCylinder = 11;//PowerRGB气缸
        private ushort _OUT_PogoCylinder = 1; //Pogo气缸
        private ushort _OUT_GrayCardCylinder = 2; //灰卡气缸
        private ushort _OUT_IPDCCylinder = 3; //IPD气缸
        private ushort _OUT_ElectromagnetPower = 5; //电磁铁通电
        private ushort _OUT_PogoPower = 4; //IPD电源控制
        private ushort _OUT_HolderSensorOut = 6; //Holder盖子伸出电磁阀
        private ushort _OUT_HolderSensorIn = 7; //Holder盖子缩回电磁阀
        private ushort _OUT_Ping_VBUS = 8; //VBUS继电器
        private ushort _OUT_Ping_CC = 9; //CC继电器
        private ushort _OUT_Ping_GND = 10; //GND继电器
        private ushort _IN_RGBTest = 1; //RGB下压气缸伸出
        private ushort _IN_IPDOrigin = 6; //IPD气缸原点
        private ushort _IN_IPDTest = 5; //IPD气缸到位
        private ushort _IN_GrayCardOrigin = 4; //灰卡气缸原点
        private ushort _IN_GrayCardTest = 3; //灰卡气缸到位
        private ushort _IN_Check_safe_raster = 8; //检查光栅
        private ushort _IN_LeftCover_OFF = 9; //检测左夹紧气缸松开
        private ushort _IN_RightCover_ON = 10; //检测右夹紧气缸夹紧
        private ushort _IN_RightCover_OFF = 11; //检测右夹紧气缸松开
        private ushort _IN_CheckDUT_2 = 12; //检测DUT到位感应2

        /// <summary>
        /// 电机停转条件一最大计数数目
        /// </summary>
        public int Max_count
        {
            get { return _Max_count; }
            set
            {
                _Max_count = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "Max_count", value.ToString());
                }
                OnPropertyChanged("Max_count");
            }
        }

        /// <summary>
        /// 电机停转条件二抽样数量
        /// </summary>
        public int Sample_length
        {
            get { return _Sample_length; }
            set
            {
                _Sample_length = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "Sample_length", value.ToString());
                }
                OnPropertyChanged("Sample_length");
            }
        }

        /// <summary>
        /// 电机停转条件二抽样极差
        /// </summary>
        public int Sample_range
        {
            get { return _Sample_range; }
            set
            {
                _Sample_range = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "Sample_range", value.ToString());
                }
                OnPropertyChanged("Sample_range");
            }
        }
        
        /// <summary>
        /// IPD旋钮电机超时时间,单位 ms
        /// </summary>
        public int Motor_IPD_TimeOut
        {
            get { return _Motor_IPD_TimeOut; }
            set
            {
                _Motor_IPD_TimeOut = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "Motor_IPD_TimeOut", value.ToString());
                }
                OnPropertyChanged("Motor_IPD_TimeOut");
            }
        }
        /// <summary>
        /// IPD旋钮电机停止速度
        /// </summary>
        public int Motor_StoptSpeed
        {
            get { return _Motor_StoptSpeed; }
            set
            {
                _Motor_StoptSpeed = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "Motor_StoptSpeed", value.ToString());
                }
                OnPropertyChanged("Motor_StoptSpeed");
            }
        }

        public double Torque_Range
        {
            get { return _Torque_Range; }
            set
            {
                _Torque_Range = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "Torque_Range", value.ToString());
                }
                OnPropertyChanged("_Torque_Range");
            }
        }

        /// <summary>
        /// IPD旋钮电机扭矩百分比
        /// </summary>
        public int Motor_Position
        {
            get { return _Motor_Position; }
            set
            {
                _Motor_Position = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "Motor_Position", value.ToString());
                }
                OnPropertyChanged("Motor_Position");
            }
        }

        /// <summary>
        /// IPD旋钮电机反转扭矩百分比
        /// </summary>
        public int Motor_Reversing
        {
            get { return _Motor_Reversing; }
            set
            {
                _Motor_Reversing = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "Motor_Reversing", value.ToString());
                }
                OnPropertyChanged("Motor_Reversing");
            }
        }

        /// <summary>
        /// IPD旋钮电机反转最大速度
        /// </summary>
        public int Motor_ReversingRotation
        {
            get { return _Motor_ReversingRotation; }
            set
            {
                _Motor_ReversingRotation = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "Motor_ReversingRotation", value.ToString());
                }
                OnPropertyChanged("Motor_ReversingRotation");
            }
        }
        /// <summary>
        /// IPD旋钮电机正转最大速度
        /// </summary>
        public int Motor_PositiveRotation
        {
            get { return _Motor_PositiveRotation; }
            set
            {
                _Motor_PositiveRotation = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "Motor_PositiveRotation", value.ToString());
                }
                OnPropertyChanged("Motor_PositiveRotation");
            }
        }
        /// <summary>
        /// IPD旋钮电机从站地址
        /// </summary>
        public byte IPDWheelSlave
        {
            get { return (byte)_IPDWheelSlave; }
            set
            {
                _IPDWheelSlave = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("IPDWheel", "IPDWheelSlave", value.ToString());
                }
                OnPropertyChanged("IPDWheelSlave");
            }
        }
        /// <summary>
        /// IPDmotor 端口号
        /// </summary>
        public string Motor_IPDWheel
        {
            get { return _Motor_IPDWheel; }
            set
            {
                _Motor_IPDWheel = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "Motor_IPDWheel", value.ToString());
                }
                OnPropertyChanged("Motor_IPDWheel");
            }
        }
        /// <summary>
        /// door 从站地址
        /// </summary>
        public byte DoorSlave
        {
            get { return (byte)_DoorSlave; }
            set
            {
                _DoorSlave = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Door", "DoorSlave", value.ToString());
                }
                OnPropertyChanged("DoorSlave");
            }
        }
        /// <summary>
        /// door 测试位置
        /// </summary>
        public int DoorWorkPostion
        {
            get { return _DoorWorkPostion; }
            set
            {
                _DoorWorkPostion = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Door", "DoorWorkPostion", value.ToString());
                }
                OnPropertyChanged("DoorWorkPostion");
            }
        }
        /// <summary>
        /// door 运动速度
        /// </summary>
        public ushort DoorSpeed
        {
            get { return _DoorSpeed; }
            set
            {
                _DoorSpeed = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Door", "DoorSpeed", value.ToString());
                }
                OnPropertyChanged("DoorSpeed");
            }
        }
        /// <summary>
        /// door 加速度
        /// </summary>
        public ushort DoorAcspeed
        {
            get { return _DoorAcspeed; }
            set
            {
                _DoorAcspeed = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Door", "DoorAcspeed", value.ToString());
                }
                OnPropertyChanged("DoorAcspeed");
            }
        }

        /// <summary>
        /// door 减速度
        /// </summary>
        public ushort DoorRespeed
        {
            get { return _DoorRespeed; }
            set
            {
                _DoorRespeed = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Door", "DoorRespeed", value.ToString());
                }
                OnPropertyChanged("DoorRespeed");
            }
        }

        /// <summary>
        /// 电机端口
        /// </summary>
        public string MotorPort
        {
            get { return _MotorPort; }
            set
            {
                   _MotorPort = value;
                //_MotorPort = "502";
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "MotorPort", value.ToString());
                }
                OnPropertyChanged("MotorPort"); 
            }
        }
        public string MotorIp
        {
            get { return _MotorIp; }
            set
            {
                _MotorIp = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "MotorIp", value.ToString());
                }
                OnPropertyChanged("MotorIp");
            }
        }
        public string MotorGrayIp
        {
            get { return _MotorGrayIp; }
            set
            {
                _MotorGrayIp = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "MotorGrayIp", value.ToString());
                }
                OnPropertyChanged("MotorGrayIp");
            }
        }
        public string MotorDoorIp
        {
            get { return _MotorDoorIp; }
            set
            {
                _MotorDoorIp = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "MotorDoorIp", value.ToString());
                }
                OnPropertyChanged("MotorDoorIp");
            }
        }
        /// <summary>
        /// IO端口
        /// </summary>
        public string Devices_ID
        {
            get { return _Devices_id; }
            set
            {
                _Devices_id = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("DevicesID", "Devices_id", value.ToString());
                }
                OnPropertyChanged("Devices_id");
            }
        }
        /// <summary>
        /// IO端口
        /// </summary>
        public string IOPort
        {
            get { return _IOPort; }
            set
            {
                _IOPort = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "IOPort", value.ToString());
                }
                OnPropertyChanged("IOPort");
            }
        }
        /// <summary>
        /// IO板2端口
        /// </summary>
        public string IOPort_2
        {
            get { return _IOPort_2; }
            set
            {
                _IOPort_2 = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "_IOPort_2", value.ToString());
                }
                OnPropertyChanged("_IOPort_2");
            }
        }
        /// <summary>
        /// 电机端口
        /// </summary>
        public string Motor_ComPort
        {
            get { return _Motor_ComPort; }
            set
            {
                _Motor_ComPort = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "Motor_ComPort", value.ToString());
                }
                OnPropertyChanged("Motor_ComPort");
            }
        }

        /// <summary>
        /// 左边显示屏tcs端口
        /// </summary>
        public string left_display_tcs_port
        {
            get { return _left_display_tcs_port; }
            set
            {
                _left_display_tcs_port = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "left_display_tcs_port", value.ToString());
                }
                OnPropertyChanged("left_display_tcs_port");
            }
        }

        /// <summary>
        /// 右边显示屏tcs端口
        /// </summary>
        public string right_display_tcs_port
        {
            get { return _right_display_tcs_port; }
            set
            {
                _right_display_tcs_port = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "right_display_tcs_port", value.ToString());
                }
                OnPropertyChanged("right_display_tcs_port");
            }
        }

        /// <summary>
        /// 电源led tcs端口
        /// </summary>
        public string power_led_tcs_port
        {
            get { return _power_led_tcs_port; }
            set
            {
                _power_led_tcs_port = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "power_led_tcs_port", value.ToString());
                }
                OnPropertyChanged("power_led_tcs_port");
            }
        }

        /// <summary>
        /// 状态led tcs端口
        /// </summary>
        public string status_led_tcs_port
        {
            get { return _status_led_tcs_port; }
            set
            {
                _status_led_tcs_port = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Ports", "status_led_tcs_port", value.ToString());
                }
                OnPropertyChanged("status_led_tcs_port");
            }
        }

        /// <summary>
        /// 灰卡测试电机从站地址
        /// </summary>
        public byte GraySlave
        {
            get { return (byte)_GraySlave; }
            set 
            {
                _GraySlave = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "GraySlave", value.ToString());
                }
                OnPropertyChanged("GraySlave"); 
            }
        }

        /// <summary>
        /// 鼻子灰卡测试30mm的位置
        /// </summary>
        public int ProxPos30mm
        {
            get { return _ProxPos30mm; }
            set
            {
                _ProxPos30mm = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "ProxPos30mm", value.ToString());
                }
                OnPropertyChanged("ProxPos30mm");
            }
        }

        /// <summary>
        /// 鼻子灰卡测试20mm的位置
        /// </summary>
        public int ProxPos20mm
        {
            get { return _ProxPos20mm; }
            set
            {
                _ProxPos20mm = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "ProxPos20mm", value.ToString());
                }
                OnPropertyChanged("ProxPos20mm");
            }
        }

        /// <summary>
        /// 鼻子灰卡测试13mm的位置
        /// </summary>
        public int ProxPos13mm
        {
            get { return _ProxPos13mm; }
            set
            {
                _ProxPos13mm = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "ProxPos13mm", value.ToString());
                }
                OnPropertyChanged("ProxPos13mm");
            }
        }

        /// <summary>
        /// 眉部灰卡测试13mm的位置
        /// </summary>
        public int CapPos13mm
        {
            get { return _CapPos13mm; }
            set
            {
                _CapPos13mm = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "CapPos13mm", value.ToString());
                }
                OnPropertyChanged("CapPos13mm");
            }
        }

        /// <summary>
        /// 眉部灰卡测试20mm的位置
        /// </summary>
        public int CapPos20mm
        {
            get { return _CapPos20mm; }
            set
            {
                _CapPos20mm = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "CapPos20mm", value.ToString());
                }
                OnPropertyChanged("CapPos20mm");
            }
        }

        /// <summary>
        /// 眉部灰卡测试30mm的位置
        /// </summary>
        public int CapPos30mm
        {
            get { return _CapPos30mm; }
            set
            {
                _CapPos30mm = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "CapPos30mm", value.ToString());
                }
                OnPropertyChanged("CapPos30mm");
            }
        }

        /// <summary>
        /// 灰卡原点的位置
        /// </summary>
        public int Gray_Home
        {
            get { return _Gray_Home; }
            set
            {
                _Gray_Home = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "GrayHomePos", value.ToString());
                }
                OnPropertyChanged("GrayHomePos");
            }
        }

        /// <summary>
        /// 门原点的位置
        /// </summary>
        public ushort Door_Home
        {
            get { return _Door_Home; }
            set
            {
                _Door_Home = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Door", "DoorHomePos", value.ToString());
                }
                OnPropertyChanged("DoorHomePos");
            }
        }

        /// <summary>
        /// 耳机线控制电机从站地址
        /// </summary>
        public byte HeadSlave
        {
            get { return (byte)_HeadSlave; }
            set
            {
                _HeadSlave = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Headphone", "HeadSlave", value.ToString());
                }
                OnPropertyChanged("HeadSlave");
            }
        }

        /// <summary>
        /// 耳机线插入位置
        /// </summary>
        public int HeadPos
        {
            get { return _HeadPos; }
            set
            {
                _HeadPos = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Headphone", "HeadPos", value.ToString());
                }
                OnPropertyChanged("HeadPos");
            }
        }

        /// <summary>
        /// 耳机线回原扭矩
        /// </summary>
        public int HeadPos_re
        {
            get { return _HeadPos_re; }
            set
            {
                _HeadPos_re = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Headphone", "HeadPos_re", value.ToString());
                }
                OnPropertyChanged("HeadPos_re");
            }
        }

        public ushort HeadAcspeed
        {
            get { return _HeadAcspeed; }
            set
            {
                _HeadAcspeed = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Headphone", "HeadAcspeed", value.ToString());
                }
                OnPropertyChanged("HeadAcspeed");
            }
        }
        public ushort HeadRespeed
        {
            get { return _HeadRespeed; }
            set
            {
                _HeadRespeed = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Headphone", "HeadRespeed", value.ToString());
                }
                OnPropertyChanged("HeadRespeed");
            }
        }

        /// <summary>
        /// 耳机线控制电机超时时间
        /// </summary>
        public double HeadTimeOut
        {
            get { return _HeadTimeOut; }
            set
            {
                _HeadTimeOut = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Headphone", "HeadTimeOut", value.ToString());
                }
                OnPropertyChanged("HeadTimeOut");
            }
        }

        /// <summary>
        /// 耳机线控制电机停止条件一：扭矩百分比
        /// </summary>
        public double HeadStopRange_1
        {
            get { return _HeadStopRange_1; }
            set
            {
                _HeadStopRange_1 = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Headphone", "HeadStopRange_1", value.ToString());
                }
                OnPropertyChanged("HeadStopRange_1");
            }
        }

        /// <summary>
        /// 耳机线控制电机停止条件二：扭矩波动百分比
        /// </summary>
        public double HeadStopRange_2 
        {
            get { return _HeadStopRange_2; }
            set
            {
                _HeadStopRange_2 = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Headphone", "HeadStopRange_2 ", value.ToString());
                }
                OnPropertyChanged("HeadStopRange_2 ");
            }
        }

        /// <summary>
        /// 耳机线控制电机停止速度
        /// </summary>
        public double HeadStopSeepd
        {
            get { return _HeadStopSeepd; }
            set
            {
                _HeadStopSeepd = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Headphone", "HeadStopSeepd ", value.ToString());
                }
                OnPropertyChanged("HeadStopSeepd ");
            }
        }

        /// <summary>
        /// 耳机线控制电机回原时间
        /// </summary>
        public double HeadHome
        {
            get { return _HeadHomeTime; }
            set
            {
                _HeadHomeTime = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("Headphone", "HeadHomeTime ", value.ToString());
                }
                OnPropertyChanged("HeadHomeTime ");
            }
        }
        
        public ushort GraySpeed
        {
            get { return _GraySpeed; }
            set
            {
                _GraySpeed = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "GraySpeed", value.ToString());
                }
                OnPropertyChanged("GraySpeed");
            }
        }
        public ushort GrayAcspeed
        {
            get { return _GrayAcspeed; }
            set
            {
                _GrayAcspeed = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "GrayAcspeed", value.ToString());
                }
                OnPropertyChanged("GrayAcspeed");
            }
        }
        public ushort GrayRespeed
        {
            get { return _GrayRespeed; }
            set
            {
                _GrayRespeed = value;
                if (_IniFile != null)
                {
                    _IniFile.WriteString("GrayTest", "GrayRespeed", value.ToString());
                }
                OnPropertyChanged("GrayRespeed");
            }
        }
        private IniFile _IniFile;

        private ConfigHelper()
        {
            LoadConfig(AppConfig.ConfigFile);
        }

        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(_Instance, new PropertyChangedEventArgs(propertyName));
        }

        public void LoadConfig(string file)
        {
            _IniFile = new IniFile(file);
            //_IniFile = new IniFile(AppConfig.ConfigFile);
            _Devices_id = _IniFile.ReadString("DevicesNum", "num", "");

            _MotorPort = _IniFile.ReadString("Ports", "MotorPort", "");
            _MotorIp = _IniFile.ReadString("Ports", "MotorIp", "");
            _MotorGrayIp = _IniFile.ReadString("Ports", "MotorGrayIp", "");
            _IOPort = _IniFile.ReadString("Ports", "IOPort", "");
            _left_display_tcs_port = _IniFile.ReadString("Ports", "left_display_tcs_port", "");
            _right_display_tcs_port = _IniFile.ReadString("Ports", "right_display_tcs_port", "");
            _power_led_tcs_port = _IniFile.ReadString("Ports", "power_led_tcs_port", "");
            _status_led_tcs_port = _IniFile.ReadString("Ports", "status_led_tcs_port", "");
            _Motor_ComPort = _IniFile.ReadString("Ports", "Motor_ComPort", "");

            _IOPort_2 = _IniFile.ReadString("Ports", "IOPort_2", "");
            _Motor_IPDWheel = _IniFile.ReadString("Ports", "Motor_IPDWheel", "");

            double origin_data = 0;
            string str = _IniFile.ReadString("GrayTest", "GraySlave", null);
            if (double.TryParse(str, out origin_data) == false)
            {
                GraySlave = 0;
            }
            else
            {
                GraySlave = (byte)origin_data;
                //_ProxPos30mm = (int)(origin_data * plusPerRund);
            }

            
            str = _IniFile.ReadString("GrayTest", "ProxPos30mm", null);
            if (double.TryParse(str, out origin_data) == false)
            {
                ProxPos30mm = 0;
            }
            else
            {
                _ProxPos30mm = (int)origin_data;
                //_ProxPos30mm = (int)(origin_data * plusPerRund);
            }

            //if (int.TryParse(str, out _ProxPos30mm) == false)
            //    ProxPos30mm = 0;
            str = _IniFile.ReadString("GrayTest", "ProxPos20mm", null);
            if (double.TryParse(str, out origin_data) == false)
            {
                ProxPos20mm = 0;
            }
            else
            {
                _ProxPos20mm = (int)origin_data;
                //_ProxPos20mm = (int)(origin_data * plusPerRund);
            }

           
            //if (int.TryParse(str, out _ProxPos20mm) == false)
            //    ProxPos20mm = 0;

            str = _IniFile.ReadString("GrayTest", "ProxPos13mm", null);
            if (double.TryParse(str, out origin_data) == false)
            {
                ProxPos13mm = 0;
            }
            else
            {
                _ProxPos13mm = (int)origin_data;
                //_ProxPos13mm = (int)(origin_data * plusPerRund);
            }
            //if (int.TryParse(str, out _ProxPos13mm) == false)
            //    ProxPos13mm = 500;

            str = _IniFile.ReadString("GrayTest", "CapPos13mm", null);
            if (double.TryParse(str, out origin_data) == false)
            {
                CapPos13mm = 0;
            }
            else
            {
                _CapPos13mm = (int)origin_data;
                //_CapPos13mm = (int)(origin_data * plusPerRund);
            }

            str = _IniFile.ReadString("GrayTest", "CapPos20mm", null);
            if (double.TryParse(str, out origin_data) == false)
            {
                CapPos20mm = 0;
            }
            else
            {
                _CapPos20mm = (int)origin_data;
                //_CapPos20mm = (int)(origin_data * plusPerRund);
            }

            str = _IniFile.ReadString("GrayTest", "CapPos30mm", null);
            if (double.TryParse(str, out origin_data) == false)
            {
                CapPos30mm = 0;
            }
            else
            {
                _CapPos30mm = (int)origin_data;
                //CapPos30mm = (int)(origin_data * plusPerRund);
            }

            str = _IniFile.ReadString("Headphone", "HeadSlave", null);
            if (ushort.TryParse(str, out _HeadSlave) == false)
                HeadSlave = 2;

            str = _IniFile.ReadString("Headphone", "HeadPos", null);
            if (double.TryParse(str, out origin_data) == false)
            {
                HeadPos = 0;
            }
            else
            {
                _HeadPos = (int)origin_data;
                //_HeadPos = (int)(origin_data * plusPerRund);
            }

            str = _IniFile.ReadString("Headphone", "HeadPos_re", null);
            if (double.TryParse(str, out origin_data) == false)
            {
                HeadPos_re = 0;
            }
            else
            {
                _HeadPos_re = (int)origin_data;
                //_HeadPos = (int)(origin_data * plusPerRund);
            }

            //if (int.TryParse(str, out _HeadPos) == false)
            //    HeadPos = 0;

            str = _IniFile.ReadString("Headphone", "HeadAcspeed", null);
            if (ushort.TryParse(str, out _HeadAcspeed) == false)
                HeadAcspeed = 0;
            str = _IniFile.ReadString("Headphone", "HeadRespeed", null);
            if (ushort.TryParse(str, out _HeadRespeed) == false)
                HeadRespeed = 0;
            str = _IniFile.ReadString("GrayTest", "GraySpeed", null);
            if (ushort.TryParse(str, out _GraySpeed) == false)
                GraySpeed = 0;
            str = _IniFile.ReadString("GrayTest", "GrayAcspeed", null);
            if (ushort.TryParse(str, out _GrayAcspeed) == false)
                GrayAcspeed = 0;
            str = _IniFile.ReadString("GrayTest", "GrayRespeed", null);
            if (ushort.TryParse(str, out _GrayRespeed) == false)
                GrayRespeed = 0;
            str = _IniFile.ReadString("Headphone", "HeadStopRange_1", null);
            if (double.TryParse(str, out _HeadStopRange_1) == false)
                HeadStopRange_1 = 0;
            str = _IniFile.ReadString("Headphone", "HeadStopRange_2", null);
            if (double.TryParse(str, out _HeadStopRange_2) == false)
                HeadStopRange_2 = 0;
            str = _IniFile.ReadString("Headphone", "HeadTimeOut", null);
            if (double.TryParse(str, out _HeadTimeOut) == false)
                HeadTimeOut = 0;
            str = _IniFile.ReadString("Headphone", "HeadStopSeepd", null);
            if (double.TryParse(str, out _HeadStopSeepd) == false)
                HeadStopSeepd = 0;
            str = _IniFile.ReadString("Headphone", "HeadHomeTime", null);
            if (double.TryParse(str, out _HeadHomeTime) == false)
                HeadHome = 0;

            str = _IniFile.ReadString("Door", "DoorSlave", null);
            if (ushort.TryParse(str, out _DoorSlave) == false)
                DoorSlave = 3;

            _MotorDoorIp = _IniFile.ReadString("Door", "MotorDoorIp", null);
            if (_MotorDoorIp == null || _MotorDoorIp.Length == 0)
                MotorDoorIp = "192.168.1.30";

            str = _IniFile.ReadString("Door", "DoorWorkPostion", null);
            if (int.TryParse(str, out _DoorWorkPostion) == false)
                DoorWorkPostion = 0;

            str = _IniFile.ReadString("Door", "DoorSpeed", null);
            if (ushort.TryParse(str, out _DoorSpeed) == false)
                DoorSpeed = 500;

            str = _IniFile.ReadString("Door", "DoorAcspeed", null);
            if (ushort.TryParse(str, out _DoorAcspeed) == false)
                DoorAcspeed = 100;

            str = _IniFile.ReadString("Door", "DoorRespeed", null);
            if (ushort.TryParse(str, out _DoorRespeed) == false)
                DoorRespeed = 100;

            str = _IniFile.ReadString("Door", "DoorHomePos", null);
            if (ushort.TryParse(str, out _Door_Home) == false)
                Door_Home = 0;

            str = _IniFile.ReadString("GrayTest", "GrayHomePos", null);
            if (int.TryParse(str, out _Gray_Home) == false)
                Gray_Home = 0;

            str = _IniFile.ReadString("IPDWheel", "IPDWheelSlave", null);
            if (ushort.TryParse(str, out _IPDWheelSlave) == false)
                _IPDWheelSlave = 1;
            str = _IniFile.ReadString("IPDWheel", "Motor_PositiveRotation", null);
            if (int.TryParse(str, out _Motor_PositiveRotation) == false)
                _Motor_PositiveRotation = 100;
            str = _IniFile.ReadString("IPDWheel", "Motor_ReversingRotation", null);
            if (int.TryParse(str, out _Motor_ReversingRotation) == false)
                _Motor_ReversingRotation = 100;
            str = _IniFile.ReadString("IPDWheel", "Motor_Position", null);
            if (int.TryParse(str, out _Motor_Position) == false)
                _Motor_Position = 1;
            str = _IniFile.ReadString("IPDWheel", "Motor_Reversing", null);
            if (int.TryParse(str, out _Motor_Reversing) == false)
                _Motor_Reversing = 1;
            str = _IniFile.ReadString("IPDWheel", "Motor_StoptSpeed", null);
            if (int.TryParse(str, out _Motor_StoptSpeed) == false)
                _Motor_StoptSpeed = 10;
            str = _IniFile.ReadString("IPDWheel", "Motor_IPD_TimeOut", null);
            if (int.TryParse(str, out _Motor_IPD_TimeOut) == false)
                _Motor_Position = 10000;
            str = _IniFile.ReadString("IPDWheel", "Torque_Range", null);
            if (double.TryParse(str, out _Torque_Range) == false)
                _Torque_Range = 0.1;

            str = _IniFile.ReadString("IPDWheel", "Max_count ", null);
            if (int.TryParse(str, out _Max_count) == false)
                _Max_count = 10;
            str = _IniFile.ReadString("IPDWheel", "Sample_length ", null);
            if (int.TryParse(str, out _Sample_length) == false)
                _Sample_length = 50;
            str = _IniFile.ReadString("IPDWheel", "Sample_range ", null);
            if (int.TryParse(str, out _Sample_range) == false)
                _Sample_range = 50;

            //1#IO板卡IO初始化赋值
            str = _IniFile.ReadString("IOport1", "OUT_StartBtLight ", null);
            if (ushort.TryParse(str, out _OUT_StartBtLight) == false)
                _OUT_StartBtLight = 1;
            str = _IniFile.ReadString("IOport1", "OUT_RsetBtLight ", null);
            if (ushort.TryParse(str, out _OUT_RsetBtLight) == false)
                _OUT_RsetBtLight = 3;
            str = _IniFile.ReadString("IOport1", "OUT_TriColorBlue ", null);
            if (ushort.TryParse(str, out _OUT_TriColorBlue) == false)
                _OUT_TriColorBlue = 4;
            str = _IniFile.ReadString("IOport1", "OUT_TriColorRed ", null);
            if (ushort.TryParse(str, out _OUT_TriColorRed) == false)
                _OUT_TriColorRed = 5;
            str = _IniFile.ReadString("IOport1", "OUT_TriColorGreen ", null);
            if (ushort.TryParse(str, out _OUT_TriColorGreen) == false)
                _OUT_TriColorGreen = 6;
            str = _IniFile.ReadString("IOport1", "OUT_TriColorBuzzer ", null);
            if (ushort.TryParse(str, out _OUT_TriColorBuzzer) == false)
                _OUT_TriColorBuzzer = 7;
            str = _IniFile.ReadString("IOport1", "OUT_StatusLightRed ", null);
            if (ushort.TryParse(str, out _OUT_StatusLightRed) == false)
                _OUT_StatusLightRed = 8;
            str = _IniFile.ReadString("IOport1", "OUT_StatusLightGreen ", null);
            if (ushort.TryParse(str, out _OUT_StatusLightGreen) == false)
                _OUT_StatusLightGreen = 9;
            str = _IniFile.ReadString("IOport1", "OUT_PowerOutCylinder ", null);
            if (ushort.TryParse(str, out _OUT_PowerOutCylinder) == false)
                _OUT_PowerOutCylinder = 10;
            str = _IniFile.ReadString("IOport1", "OUT_PowerCylinder ", null);
            if (ushort.TryParse(str, out _OUT_PowerCylinder) == false)
                _OUT_PowerCylinder = 11;
            str = _IniFile.ReadString("IOport1", "OUT_VolAddCylinder ", null);
            if (ushort.TryParse(str, out _OUT_VolAddCylinder) == false)
                _OUT_VolAddCylinder = 12;
            str = _IniFile.ReadString("IOport1", "OUT_VolReduceCylinder ", null);
            if (ushort.TryParse(str, out _OUT_VolReduceCylinder) == false)
                _OUT_VolReduceCylinder = 13;
            str = _IniFile.ReadString("IOport1", "IN_E_Stop ", null);
            if (ushort.TryParse(str, out _IN_E_Stop) == false)
                _IN_E_Stop = 1;
            str = _IniFile.ReadString("IOport1", "IN_Start ", null);
            if (ushort.TryParse(str, out _IN_Start) == false)
                _IN_Start = 2;
            str = _IniFile.ReadString("IOport1", "IN_Reset ", null);
            if (ushort.TryParse(str, out _IN_Reset) == false)
                _IN_Reset = 4;
            str = _IniFile.ReadString("IOport1", "IN_PoweroutOrigin ", null);
            if (ushort.TryParse(str, out _IN_PoweroutOrigin) == false)
                _IN_PoweroutOrigin = 6;
            str = _IniFile.ReadString("IOport1", "IN_PowerOutTest ", null);
            if (ushort.TryParse(str, out _IN_PowerOutTest) == false)
                _IN_PowerOutTest = 5;
            str = _IniFile.ReadString("IOport1", "IN_PowerOrigin ", null);
            if (ushort.TryParse(str, out _IN_PowerOrigin) == false)
                _IN_PowerOrigin = 8;
            str = _IniFile.ReadString("IOport1", "IN_PowerTest ", null);
            if (ushort.TryParse(str, out _IN_PowerTest) == false)
                _IN_PowerTest = 7;
            str = _IniFile.ReadString("IOport1", "IN_VolAddOrigin ", null);
            if (ushort.TryParse(str, out _IN_VolAddOrigin) == false)
                _IN_VolAddOrigin = 10;
            str = _IniFile.ReadString("IOport1", "IN_VolAddTest ", null);
            if (ushort.TryParse(str, out _IN_VolAddTest) == false)
                _IN_VolAddTest = 9;
            str = _IniFile.ReadString("IOport1", "IN_VolReduOrigin ", null);
            if (ushort.TryParse(str, out _IN_VolReduOrigin) == false)
                _IN_VolReduOrigin = 12;
            str = _IniFile.ReadString("IOport1", "IN_VolReduTest ", null);
            if (ushort.TryParse(str, out _IN_VolReduTest) == false)
                _IN_VolReduTest = 11;
            str = _IniFile.ReadString("IOport1", "IN_PogoOrigin ", null);
            if (ushort.TryParse(str, out _IN_PogoOrigin) == false)
                _IN_PogoOrigin = 14;
            str = _IniFile.ReadString("IOport1", "IN_PogoTest ", null);
            if (ushort.TryParse(str, out _IN_PogoTest) == false)
                _IN_PogoTest = 13;
            str = _IniFile.ReadString("IOport1", "IN_CoverOpen ", null);
            if (ushort.TryParse(str, out _IN_CoverOpen) == false)
                _IN_CoverOpen = 15;
            str = _IniFile.ReadString("IOport1", "IN_CoverClose ", null);
            if (ushort.TryParse(str, out _IN_CoverClose) == false)
                _IN_CoverClose = 16;
            str = _IniFile.ReadString("IOport1", "IN_LeftCover_ON ", null);
            if (ushort.TryParse(str, out _IN_LeftCover_ON) == false)
                _IN_LeftCover_ON = 16;
            str = _IniFile.ReadString("IOport1", "IN_CheckDUT_1 ", null);
            if (ushort.TryParse(str, out _IN_CheckDUT_1) == false)
                _IN_CheckDUT_1 = 15;
            //2#IO板卡IO初始化赋值
            str = _IniFile.ReadString("IOport2", "OUT_PowerRGBCylinder ", null);
            if (ushort.TryParse(str, out _OUT_PowerRGBCylinder) == false)
                _OUT_PowerRGBCylinder = 11;
            str = _IniFile.ReadString("IOport2", "OUT_PogoCylinder ", null);
            if (ushort.TryParse(str, out _OUT_PogoCylinder) == false)
                _OUT_PogoCylinder = 1;
            str = _IniFile.ReadString("IOport2", "OUT_GrayCardCylinder ", null);
            if (ushort.TryParse(str, out _OUT_GrayCardCylinder) == false)
                _OUT_GrayCardCylinder = 2;
            str = _IniFile.ReadString("IOport2", "OUT_IPDCCylinder ", null);
            if (ushort.TryParse(str, out _OUT_IPDCCylinder) == false)
                _OUT_IPDCCylinder = 3;
            str = _IniFile.ReadString("IOport2", "OUT_ElectromagnetPower ", null);
            if (ushort.TryParse(str, out _OUT_ElectromagnetPower) == false)
                _OUT_ElectromagnetPower = 5;
            str = _IniFile.ReadString("IOport2", "OUT_PogoPower ", null);
            if (ushort.TryParse(str, out _OUT_PogoPower) == false)
                _OUT_PogoPower = 4;
            str = _IniFile.ReadString("IOport2", "OUT_HolderSensorOut ", null);
            if (ushort.TryParse(str, out _OUT_HolderSensorOut) == false)
                _OUT_HolderSensorOut = 6;
            str = _IniFile.ReadString("IOport2", "OUT_HolderSensorIn ", null);
            if (ushort.TryParse(str, out _OUT_HolderSensorIn) == false)
                _OUT_HolderSensorIn = 7;
            str = _IniFile.ReadString("IOport2", "OUT_Ping_VBUS ", null);
            if (ushort.TryParse(str, out _OUT_Ping_VBUS) == false)
                _OUT_Ping_VBUS = 8;
            str = _IniFile.ReadString("IOport2", "OUT_Ping_CC ", null);
            if (ushort.TryParse(str, out _OUT_Ping_CC) == false)
                _OUT_Ping_CC = 9;
            str = _IniFile.ReadString("IOport2", "OUT_Ping_GND ", null);
            if (ushort.TryParse(str, out _OUT_Ping_GND) == false)
                _OUT_Ping_GND = 10;
            str = _IniFile.ReadString("IOport2", "IN_RGBTest ", null);
            if (ushort.TryParse(str, out _IN_RGBTest) == false)
                _IN_RGBTest = 1;
            str = _IniFile.ReadString("IOport2", "IN_IPDOrigin ", null);
            if (ushort.TryParse(str, out _IN_IPDOrigin) == false)
                _IN_IPDOrigin = 6;
            str = _IniFile.ReadString("IOport2", "IN_IPDTest ", null);
            if (ushort.TryParse(str, out _IN_IPDTest) == false)
                _IN_IPDTest = 5;
            str = _IniFile.ReadString("IOport2", "IN_GrayCardOrigin ", null);
            if (ushort.TryParse(str, out _IN_GrayCardOrigin) == false)
                _IN_GrayCardOrigin = 4;
            str = _IniFile.ReadString("IOport2", "IN_GrayCardTest ", null);
            if (ushort.TryParse(str, out _IN_GrayCardTest) == false)
                _IN_GrayCardTest = 3;
            str = _IniFile.ReadString("IOport2", "IN_Check_safe_raster ", null);
            if (ushort.TryParse(str, out _IN_Check_safe_raster) == false)
                _IN_Check_safe_raster = 8;
            str = _IniFile.ReadString("IOport2", "IN_LeftCover_OFF ", null);
            if (ushort.TryParse(str, out _IN_LeftCover_OFF) == false)
                _IN_LeftCover_OFF = 9;
            str = _IniFile.ReadString("IOport2", "IN_RightCover_ON ", null);
            if (ushort.TryParse(str, out _IN_RightCover_ON) == false)
                _IN_RightCover_ON = 10;
            str = _IniFile.ReadString("IOport2", "IN_RightCover_OFF ", null);
            if (ushort.TryParse(str, out _IN_RightCover_OFF) == false)
                _IN_RightCover_OFF = 11;
            str = _IniFile.ReadString("IOport2", "IN_CheckDUT_2 ", null);
            if (ushort.TryParse(str, out _IN_CheckDUT_2) == false)
                _IN_CheckDUT_2 = 12;
        }

        public static ConfigHelper Instance
        {
            get { return ConfigHelper._Instance; }
        }

        #region IO板卡属性
        /// <summary>
        /// 启动按钮指示灯
        /// </summary>
        public ushort OUT_StartBtLight
        {
            get
            {
                return _OUT_StartBtLight;
            }
        }

        /// <summary>
        /// 复位按钮指示灯
        /// </summary>
        public ushort OUT_RsetBtLight
        {
            get
            {
                return _OUT_RsetBtLight;
            }
        }


        /// <summary>
        /// 三色灯-蓝
        /// </summary>
        public ushort OUT_TriColorBlue
        {
            get
            {
                return _OUT_TriColorBlue;
            }
        }


        /// <summary>
        /// 三色灯-红
        /// </summary>
        public ushort OUT_TriColorRed
        {
            get
            {
                return _OUT_TriColorRed;
            }
        }


        /// <summary>
        /// 三色灯-绿
        /// </summary>
        public ushort OUT_TriColorGreen
        {
            get
            {
                return _OUT_TriColorGreen;
            }
        }


        /// <summary>
        /// 三色灯-蜂鸣器
        /// </summary>
        public ushort OUT_TriColorBuzzer
        {
            get
            {
                return _OUT_TriColorBuzzer;
            }
        }


        /// <summary>
        /// 状态指示灯红
        /// </summary>
        public ushort OUT_StatusLightRed
        {
            get
            {
                return _OUT_StatusLightRed;
            }
        }


        /// <summary>
        /// 状态指示灯绿
        /// </summary>
        public ushort OUT_StatusLightGreen
        {
            get
            {
                return _OUT_StatusLightGreen;
            }
        }


        /// <summary>
        /// Power推进气缸
        /// </summary>
        public ushort OUT_PowerOutCylinder
        {
            get
            {
                return _OUT_PowerOutCylinder;
            }
        }


        /// <summary>
        /// 电源键气缸
        /// </summary>
        public ushort OUT_PowerCylinder
        {
            get
            {
                return _OUT_PowerCylinder;
            }
        }


        /// <summary>
        /// 音量键+气缸
        /// </summary>
        public ushort OUT_VolAddCylinder
        {
            get
            {
                return _OUT_VolAddCylinder;
            }
        }


        /// <summary>
        /// 音量键-气缸
        /// </summary>
        public ushort OUT_VolReduceCylinder
        {
            get
            {
                return _OUT_VolReduceCylinder;
            }
        }


        /// <summary>
        /// 急停按钮
        /// </summary>
        public ushort IN_E_Stop
        {
            get
            {
                return _IN_E_Stop;
            }
        }


        /// <summary>
        /// 启动按钮
        /// </summary>
        public ushort IN_Start
        {
            get
            {
                return _IN_Start;
            }
        }


        /// <summary>
        /// 复位按钮
        /// </summary>
        public ushort IN_Reset
        {
            get
            {
                return _IN_Reset;
            }
        }


        /// <summary>
        /// Powr推进气缸原点
        /// </summary>
        public ushort IN_PoweroutOrigin
        {
            get
            {
                return _IN_PoweroutOrigin;
            }
        }


        /// <summary>
        /// Power推进气缸到位
        /// </summary>
        public ushort IN_PowerOutTest
        {
            get
            {
                return _IN_PowerOutTest;
            }
        }


        /// <summary>
        /// 电源键气缸原点
        /// </summary>
        public ushort IN_PowerOrigin
        {
            get
            {
                return _IN_PowerOrigin;
            }
        }


        /// <summary>
        /// 电源键气缸到位
        /// </summary>
        public ushort IN_PowerTest
        {
            get
            {
                return _IN_PowerTest;
            }
        }


        /// <summary>
        /// 音量键+气缸原点
        /// </summary>
        public ushort IN_VolAddOrigin
        {
            get
            {
                return _IN_VolAddOrigin;
            }
        }


        /// <summary>
        /// 音量键+气缸到位
        /// </summary>
        public ushort IN_VolAddTest
        {
            get
            {
                return _IN_VolAddTest;
            }
        }


        /// <summary>
        /// 音量键-气缸原点
        /// </summary>
        public ushort IN_VolReduOrigin
        {
            get
            {
                return _IN_VolReduOrigin;
            }
        }


        /// <summary>
        /// 音量键-气缸到位
        /// </summary>
        public ushort IN_VolReduTest
        {
            get
            {
                return _IN_VolReduTest;
            }
        }


        /// <summary>
        /// Pogo滑台气缸原点
        /// </summary>
        public ushort IN_PogoOrigin
        {
            get
            {
                return _IN_PogoOrigin;
            }
        }


        /// <summary>
        /// Pogo滑台气缸到位
        /// </summary>
        public ushort IN_PogoTest
        {
            get
            {
                return _IN_PogoTest;
            }
        }


        /// <summary>
        /// Holder盖子sensor
        /// </summary>
        public ushort IN_CoverOpen
        {
            get
            {
                return _IN_CoverOpen;
            }
        }


        /// <summary>
        /// Holder盖子气缸到位
        /// </summary>
        public ushort IN_CoverClose
        {
            get
            {
                return _IN_CoverClose;
            }
        }


        /// <summary>
        /// 检测左夹紧气缸伸出
        /// </summary>
        public ushort IN_LeftCover_ON
        {
            get
            {
                return _IN_LeftCover_ON;
            }
        }


        /// <summary>
        /// 检测DUT到位感应1
        /// </summary>
        public ushort IN_CheckDUT_1
        {
            get
            {
                return _IN_CheckDUT_1;
            }
        }


        /// <summary>
        /// PowerRGB气缸
        /// </summary>
        public ushort OUT_PowerRGBCylinder
        {
            get
            {
                return _OUT_PowerRGBCylinder;
            }
        }


        /// <summary>
        /// Pogo气缸
        /// </summary>
        public ushort OUT_PogoCylinder
        {
            get
            {
                return _OUT_PogoCylinder;
            }
        }


        /// <summary>
        /// 灰卡气缸
        /// </summary>
        public ushort OUT_GrayCardCylinder
        {
            get
            {
                return _OUT_GrayCardCylinder;
            }
        }


        /// <summary>
        /// IPD气缸
        /// </summary>
        public ushort OUT_IPDCCylinder
        {
            get
            {
                return _OUT_IPDCCylinder;
            }
        }


        /// <summary>
        /// 电磁铁通电
        /// </summary>
        public ushort OUT_ElectromagnetPower
        {
            get
            {
                return _OUT_ElectromagnetPower;
            }
        }


        /// <summary>
        /// IPD电源控制
        /// </summary>
        public ushort OUT_PogoPower
        {
            get
            {
                return _OUT_PogoPower;
            }
        }


        /// <summary>
        /// Holder盖子伸出电磁阀
        /// </summary>
        public ushort OUT_HolderSensorOut
        {
            get
            {
                return _OUT_HolderSensorOut;
            }
        }


        /// <summary>
        /// Holder盖子缩回电磁阀
        /// </summary>
        public ushort OUT_HolderSensorIn
        {
            get
            {
                return _OUT_HolderSensorIn;
            }
        }


        /// <summary>
        /// VBUS继电器
        /// </summary>
        public ushort OUT_Ping_VBUS
        {
            get
            {
                return _OUT_Ping_VBUS;
            }
        }


        /// <summary>
        /// CC继电器
        /// </summary>
        public ushort OUT_Ping_CC
        {
            get
            {
                return _OUT_Ping_CC;
            }
        }


        /// <summary>
        /// GND继电器
        /// </summary>
        public ushort OUT_Ping_GND
        {
            get
            {
                return _OUT_Ping_GND;
            }
        }


        /// <summary>
        /// RGB下压气缸伸出
        /// </summary>
        public ushort IN_RGBTest
        {
            get
            {
                return _IN_RGBTest;
            }
        }


        /// <summary>
        /// IPD气缸原点
        /// </summary>
        public ushort IN_IPDOrigin
        {
            get
            {
                return _IN_IPDOrigin;
            }
        }


        /// <summary>
        /// IPD气缸到位
        /// </summary>
        public ushort IN_IPDTest
        {
            get
            {
                return _IN_IPDTest;
            }
        }


        /// <summary>
        /// 灰卡气缸原点
        /// </summary>
        public ushort IN_GrayCardOrigin
        {
            get
            {
                return _IN_GrayCardOrigin;
            }
        }


        /// <summary>
        /// 灰卡气缸到位
        /// </summary>
        public ushort IN_GrayCardTest
        {
            get
            {
                return _IN_GrayCardTest;
            }
        }


        /// <summary>
        /// 检查光栅
        /// </summary>
        public ushort IN_Check_safe_raster
        {
            get
            {
                return _IN_Check_safe_raster;
            }
        }


        /// <summary>
        /// 检测左夹紧气缸松开
        /// </summary>
        public ushort IN_LeftCover_OFF
        {
            get
            {
                return _IN_LeftCover_OFF;
            }
        }


        /// <summary>
        /// 检测右夹紧气缸夹紧
        /// </summary>
        public ushort IN_RightCover_ON
        {
            get
            {
                return _IN_RightCover_ON;
            }
        }


        /// <summary>
        /// 检测右夹紧气缸松开
        /// </summary>
        public ushort IN_RightCover_OFF
        {
            get
            {
                return _IN_RightCover_OFF;
            }
        }


        /// <summary>
        /// 检测DUT到位感应2
        /// </summary>
        public ushort IN_CheckDUT_2
        {
            get
            {
                return _IN_CheckDUT_2;
            }
        }
        #endregion

        public bool Set_value(string section, string name, string value)
        {
            try
            {
                _IniFile.IniWriteValue(section, name, value);
                return true;
            }
            catch (Exception er)
            {
                return false;
            }
        }

        public string Get_Value(string section, string name)
        {
            try
            {
                return _IniFile.IniReadValue(section, name);
            }
            catch (Exception er)
            {
                return er.ToString();
            }
        }

    }
}
