VerticalStoreConfig.cs 8.6 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace OnlineStore.LoadCSVLibrary
{
    public class VerticalStoreConfig : StoreConfig
    {
        public VerticalStoreConfig()
            : base()
        {
        }
        public VerticalStoreConfig(int id, string cid, string type, string filepath)
            : base(id, cid, type, filepath)
        {
        }
        /// <summary>
        ///  AXIS,(轴一)料斗旋转轴,Middle_Axis,1,COM1,,,,250,80,80,80,60,50,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Middle_Axis")]
        public ConfigMoveAxis Middle_Axis { get; set; }
        /// <summary>
        ///  PRO,IO模块对应的DI数量,IO_DILength,192.168.200.21#16,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("IO_DILength")]
        public string  IO_DILength { get; set; }
        /// <summary>
        ///  PRO,模块对应的DO数量,IO_DOLength,192.168.200.21#16,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("IO_DOLength")]
        public string  IO_DOLength { get; set; }
        /// <summary>
        ///  PRO,旋转轴 P1待机原位点 ,MiddleAxis_P1,268000,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("MiddleAxis_P1")]
        public int MiddleAxis_P1 { get; set; }
        /// <summary>
        ///  PRO,设备是否处于调试状态(1=调试,0=正常),IsInDebug,0,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("IsInDebug")]
        public int IsInDebug { get; set; }
        /// <summary>
        ///  PRO,IO信号超时时间(毫秒),IOSingle_TimerOut,10000,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("IOSingle_TimerOut")]
        public int IOSingle_TimerOut { get; set; }
        /// <summary>
        ///  PRO,旋转轴(轴1)P1速度,MiddleAxis_P1_Speed,120,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("MiddleAxis_P1_Speed")]
        public int MiddleAxis_P1_Speed { get; set; }
        /// <summary>
        ///  PRO,旋转轴(轴1)P2速度,MiddleAxis_P2_Speed,120,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("MiddleAxis_P2_Speed")]
        public int MiddleAxis_P2_Speed { get; set; }
        /// <summary>
        ///  PRO,伺服停止时可误差的脉冲数的最小值,Axis_ErrorCountMin,10,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("Axis_ErrorCountMin")]
        public int Axis_ErrorCountMin { get; set; }
        /// <summary>
        ///  PRO,伺服停止时可误差的脉冲数的最大值,Axis_ErrorCountMax,1000,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("Axis_ErrorCountMax")]
        public int Axis_ErrorCountMax { get; set; }
        /// <summary>
        ///  PRO,(轴一)旋转轴最小限位,MiddleAxis_PositionMin,0,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("MiddleAxis_PositionMin")]
        public int MiddleAxis_PositionMin { get; set; }
        /// <summary>
        ///  PRO,(轴一)旋转轴最大限位,MiddleAxis_PositionMax,0,,,,,,,,,,,,,,
        /// </summary>
        [ConfigProAttribute("MiddleAxis_PositionMax")]
        public int MiddleAxis_PositionMax { get; set; } 

        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.Door_Up);
            MustHaveDIList.Add(IO_Type.Door_Down);
            MustHaveDIList.Add(IO_Type.SafetyLightCurtains);
            MustHaveDIList.Add(IO_Type.SafetyLightCurtains); 

            MustHaveDOList.Add(IO_Type.AutoRun_HddLed);
            MustHaveDOList.Add(IO_Type.Alarm_HddLed);
            MustHaveDOList.Add(IO_Type.RunSign_HddLed);
            MustHaveDOList.Add(IO_Type.Alarm_Buzzer);
       //     MustHaveDOList.Add(IO_Type.StartOrStopBlow);
            MustHaveDOList.Add(IO_Type.Run_Signal);
            MustHaveDOList.Add(IO_Type.Axis_Brake);
            MustHaveDOList.Add(IO_Type.Door_Up);
            MustHaveDOList.Add(IO_Type.Door_Down);
            MustHaveDOList.Add(IO_Type.Camera_Led);
        }
        public static void ConfigAxis(VerticalStoreConfig con)
        {  
            con.Middle_Axis.CanErrorCountMin = con.Axis_ErrorCountMin;  
            con.Middle_Axis.CanErrorCountMax = con.Axis_ErrorCountMax;  
            con.Middle_Axis.PositionMin = con.MiddleAxis_PositionMin;
            con.Middle_Axis.PositionMax = con.MiddleAxis_PositionMax;  
            con.Middle_Axis.DefaultPosition = con.MiddleAxis_P1; 
        }
        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;
        }

        //private Dictionary<string, string> CodeSizeMap = null;
        //private static char codeSpilt = '#';

        //public string GetCodeSize(ref string code)
        //{
        //    try
        //    {
        //        if (CodeSizeMap == null)
        //        {
        //            CodeSizeMap = new Dictionary<string, string>();
        //            string[] array = CodeSizeConfig.Split(codeSpilt);
        //            if (array.Length > 0)
        //            {
        //                foreach (string str in array)
        //                {
        //                    string[] codeStr = str.Split('=');
        //                    if (codeStr.Length == 2)
        //                    {
        //                        string key = codeStr[0].Trim();
        //                        string value = codeStr[1].Trim();
        //                        CodeSizeMap.Add(key, value);
        //                    }

        //                }
        //            }
        //        }

        //        foreach (string key in CodeSizeMap.Keys)
        //        {
        //            string[] array = key.Split(';');
        //            if (array.Length == 1 && code.Trim().StartsWith(key))
        //            {
        //                return CodeSizeMap[key];
        //            }
        //            else if (array.Length >= 2)
        //            {
        //                if (code.Trim().StartsWith(array[0]))
        //                {
        //                    int leng = array[0].Length;
        //                    code = code.Trim() + key.Substring(leng, key.Length - leng);
        //                    return CodeSizeMap[key];
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        LOGGER.Error("获取二维码【" + code + "】的固定尺寸出错:" + ex.ToString());
        //    }
        //    return "";
        //}

    }
}