Line_Config.cs 7.5 KB
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace OnlineStore.LoadCSVLibrary
{
    /// <summary>
    /// 流水线配置
    /// </summary>
    public class Line_Config : DeviceConfig
    {
        public Line_Config()
            : base()
        {
        }
        /// <summary>
        /// 流水线配置
        /// </summary>
        /// <param name="id">ID</param>
        /// <param name="cid">CID</param>
        /// <param name="type">类型</param>
        /// <param name="filepath">配置文件</param>
        public Line_Config(int id, string cid, string type, string filepath)
            : base(id, cid, LoadCSVLibrary.DeviceType.Line, filepath)
        {
        }

        /// <summary>
        /// 气压检测信号关闭需要持续的时间 
        /// </summary>
        [ConfigProAttribute("AirCheckSeconds")]
        public int AirCheckSeconds        { get; set; }
       
          
        /// <summary>
        /// PRO,当多久没有出入库操作时,流水线进行休眠(休眠毫秒数),Sleep_MSeconds,120,,,,,
        /// </summary>
        [ConfigProAttribute("Sleep_MSeconds")]
        public int Sleep_MSeconds { get; set; }

       
        /// <summary>
        ///  PRO	IO信号超时时间(毫秒)	IOSingle_TimerOut	5000
        /// </summary>
        [ConfigProAttribute("IOSingle_TimerOut",false)]
        public int IOSingle_TimerOut { get; set; }
        /// <summary>
        ///  PRO IO模块对应的DI数量 IO_DILength	192.168.200.10#16;192.168.200.11#4	
        /// </summary>
        [ConfigProAttribute("IO_DILength")]
        public string IO_DILength { get; set; }
        /// <summary>
        /// PRO 模块对应的DO数量   IO_DOLength	192.168.200.10#16;192.168.200.11#4	
        /// </summary>
        [ConfigProAttribute("IO_DOLength")]
        public string IO_DOLength { get; set; }

        ///// <summary>
        ///// PRO 模拟量IO模块的IP地址    AIDevice_IP	192.168.200.11
        ///// </summary>
        //[ConfigProAttribute("AIDevice_IP", true)]
        //public string AIDevice_IP { get; set; }

        ///// <summary>
        /////  PRO 模拟量测高1mm对应的转换值  AI_ConvertPosition	55
        ///// </summary>
        //[ConfigProAttribute("AI_ConvertPosition", true)]
        //public int AI_ConvertPosition { get; set; }

        ///// <summary>
        ///// PRO,模拟信号1默认高度,AIDI1_DefaultPosition,1,,,,,,,
        ///// </summary>
        //[ConfigProAttribute("AIDI1_DefaultPosition", true)]
        //public double AIDI1_DefaultPosition { get; set; }
        ///// <summary>
        ///// PRO,模拟信号2默认高度,AIDI2_DefaultPosition,1,,,,,,,
        ///// </summary>
        //[ConfigProAttribute("AIDI2_DefaultPosition", true)]
        //public double AIDI2_DefaultPosition { get; set; }
        ///// <summary>
        ///// PRO,模拟信号3默认高度,AIDI3_DefaultPosition,1,,,,,,,
        ///// </summary>
        //[ConfigProAttribute("AIDI3_DefaultPosition", true)]
        //public double AIDI3_DefaultPosition { get; set; }

        ///// <summary>
        ///// PRO,模拟信号4默认高度,AIDI4_DefaultPosition,1,,,,,,,
        ///// </summary>
        //[ConfigProAttribute("AIDI4_DefaultPosition", true)]
        //public double AIDI4_DefaultPosition { get; set; }
        ///// <summary>
        /////  PRO 模拟信号1的地址    AIDI1_Addr	7
        ///// </summary>
        //[ConfigProAttribute("AIDI1_Addr", true)]
        //public int AIDI1_Addr { get; set; }
        ///// <summary>
        ///// PRO 模拟信号2的地址    AIDI2_Addr	8
        ///// </summary>
        //[ConfigProAttribute("AIDI2_Addr", true)]
        //public int AIDI2_Addr { get; set; }
        ///// <summary>
        /////  PRO 模拟信号3的地址    AIDI3_Addr	5
        ///// </summary>
        //[ConfigProAttribute("AIDI3_Addr", true)]
        //public int AIDI3_Addr { get; set; }
        ///// <summary>
        ///// PRO 模拟信号4的地址    AIDI4_Addr	6
        ///// </summary>
        //[ConfigProAttribute("AIDI4_Addr", true)]
        //public int AIDI4_Addr { get; set; }



        private Dictionary<string, ushort> DILengthMap = null;
        private Dictionary<string, ushort> DOLengthMap = null;
        public ushort GetDILength(string ip)
        {
            try
            {
                if (DILengthMap == null)
                {
                    DILengthMap = new Dictionary<string, ushort>();
                    string[] arrayList = IO_DILength.Split(';');
                    foreach (string str in arrayList)
                    {
                        string[] arrStr = str.Split('#');
                        if (arrStr.Length == 2)
                        {
                            string ioip = arrStr[0];
                            ushort length = Convert.ToUInt16(arrStr[1]);
                            DILengthMap.Add(ioip, length);
                        }
                    }
                }
            }
            catch (Exception ex)
            {

            }
            if (DILengthMap.ContainsKey(ip))
            {
                return DILengthMap[ip];
            }
            return 16;
        }
        public ushort GetDOLength(string ip)
        {
            try
            {
                if (DOLengthMap == null)
                {
                    DOLengthMap = new Dictionary<string, ushort>();
                    string[] arrayList = IO_DOLength.Split(';');
                    foreach (string str in arrayList)
                    {
                        string[] arrStr = str.Split('#');
                        if (arrStr.Length == 2)
                        {
                            string ioip = arrStr[0];
                            ushort length = Convert.ToUInt16(arrStr[1]);
                            DOLengthMap.Add(ioip, length);
                        }
                    }
                }
            }
            catch (Exception ex)
            {

            }
            if (DOLengthMap.ContainsKey(ip))
            {
                return DOLengthMap[ip];
            }
            return 16;
        }


        protected override void initMustHavePro()
        {
            MustHaveDIList = new List<string>();
            MustHaveDOList = new List<string>();
 
                MustHaveDIList.Add(IO_Type.SuddenStop_BTN);
            MustHaveDIList.Add(IO_Type.Reset_BTN);
            MustHaveDIList.Add(IO_Type.Start_BTN);
            MustHaveDIList.Add(IO_Type.Airpressure_Check);
            MustHaveDIList.Add(IO_Type.NGCylinder_Before);
            MustHaveDIList.Add(IO_Type.NGCylinder_After);
            MustHaveDIList.Add(IO_Type.TopCylinder_UP);
            MustHaveDIList.Add(IO_Type.TopCylinder_Down);

       

            MustHaveDOList.Add(IO_Type.AutoRun_HddLed);
            MustHaveDOList.Add(IO_Type.RunSign_HddLed);
            MustHaveDOList.Add(IO_Type.Alarm_HddLed);
            MustHaveDOList.Add(IO_Type.Alarm_Buzzer);
            MustHaveDOList.Add(IO_Type.DriveMotor_Run1);
            MustHaveDOList.Add(IO_Type.DriveMotor_Run2);
            MustHaveDOList.Add(IO_Type.DriveMotor_Run3);
            MustHaveDOList.Add(IO_Type.DriveMotor_Run4);
            MustHaveDOList.Add(IO_Type.SW4_MotorRun);
            MustHaveDOList.Add(IO_Type.NGCylinder_Before);
            MustHaveDOList.Add(IO_Type.NGCylinder_After);
            MustHaveDOList.Add(IO_Type.TopCylinder_UP);
            MustHaveDOList.Add(IO_Type.TopCylinder_Down);

         
        }
    }
}