Robot_Config.cs 8.0 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
{
    public class Robot_Config : DeviceConfig
    {
        public Robot_Config()
            : base()
        {
        }
       
        public Robot_Config(int id,  string type, string filepath)
            : base(id,  LoadCSVLibrary.DeviceType.Line, filepath)
        {
        }

        /// <summary>
        /// 设备是否处于调试状态(1=调试,0=正常)
        /// </summary>
        [ConfigProAttribute("IsDebug",false)]
        public int IsDebug { get; set; }

        /// <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>
        ///  AXIS,,取料机构旋转轴_SVD01,Take_Middle_Axis,1,COM1,,,,250,80,80,80,60,50,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Take_Middle_Axis")]
        public ConfigMoveAxis Take_Middle_Axis { get; set; }
        /// <summary>
        ///  AXIS,,取料机构上下轴_SVD02,Take_UpDown_Axis,2,COM1,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Take_UpDown_Axis")]
        public ConfigMoveAxis Take_UpDown_Axis { get; set; }
        /// <summary>
        ///  AXIS,,取料机构进出轴_SVD03,Take_InOut_Axis,3,COM1,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Take_InOut_Axis")]
        public ConfigMoveAxis Take_InOut_Axis { get; set; }
        /// <summary>
        ///  AXIS,,左轨道提升轴_SVD04,Left_Batch_Axis,4,COM1,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Left_Batch_Axis")]
        public ConfigMoveAxis Left_Batch_Axis { get; set; }
        /// <summary>
        ///  AXIS,,右轨道提升轴_SVD05,Right_Batch_Axis,5,COM1,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Right_Batch_Axis")]
        public ConfigMoveAxis Right_Batch_Axis { get; set; }
        /// <summary>
        ///  AXIS,,取料移栽机构X轴_SVD06,Move_X_Axis,1,COM2,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Move_X_Axis")]
        public ConfigMoveAxis Move_X_Axis { get; set; }
        /// <summary>
        ///  AXIS,,取料移栽机构Z轴_SVD07,Move_Z_Axis,2,COM2,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Move_Z_Axis")]
        public ConfigMoveAxis Move_Z_Axis { get; set; }
        /// <summary>
        ///  AXIS,,贴标移栽机构X轴_SVD08,Label_X_Axis,3,COM2,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Label_X_Axis")]
        public ConfigMoveAxis Label_X_Axis { get; set; }
        /// <summary>
        ///  AXIS,,贴标移栽机构Y轴_SVD09,Label_Y_Axis,4,COM2,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Label_Y_Axis")]
        public ConfigMoveAxis Label_Y_Axis { get; set; }
        /// <summary>
        ///  AXIS,,贴标移栽机构Z轴_SVD10,Label_Z_Axis,5,COM2,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Label_Z_Axis")]
        public ConfigMoveAxis Label_Z_Axis { get; set; }
        /// <summary>
        ///  AXIS,,贴标移栽机构R轴_SVD11,Label_R_Axis,6,COM2,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Label_R_Axis")]
        public ConfigMoveAxis Label_R_Axis { get; set; }
        /// <summary>
        ///  AXIS,,出料工位提升轴_SVD12,Out_Batch_Axis,7,COM2,,,,100,300,200,20,50,200,10,1000,0,0
        /// </summary>
        [ConfigProAttribute("Out_Batch_Axis")]
        public ConfigMoveAxis Out_Batch_Axis { get; set; }


        public void SetAxisParam()
        {
            Left_Batch_Axis.ServerOnDO = IO_Type.LeftBatchAxis_ON;
            Left_Batch_Axis.BreakOnDO = IO_Type.LeftBatchAxis_Break;

            Right_Batch_Axis.ServerOnDO = IO_Type.RightBatchAxis_ON;
            Right_Batch_Axis.BreakOnDO = IO_Type.RightBatchAxis_Break;

            Out_Batch_Axis.ServerOnDO = IO_Type.OutBatchAxis_ON;
            Out_Batch_Axis.BreakOnDO = IO_Type.OutBatchAxis_Break;

            Take_Middle_Axis.ServerOnDO = IO_Type.TakeAxis_ON;
            Take_InOut_Axis.ServerOnDO = IO_Type.TakeAxis_ON;
            Take_UpDown_Axis.ServerOnDO = IO_Type.TakeAxis_ON;

            Take_UpDown_Axis.BreakOnDO = IO_Type.Take_Axis_Break;
             
            Move_X_Axis.ServerOnDO = IO_Type.MoveAxis_ON;
            Move_Z_Axis.ServerOnDO = IO_Type.MoveAxis_ON;
            Move_Z_Axis.BreakOnDO = IO_Type.MoveAxis_Break;
             
            Label_R_Axis.ServerOnDO = IO_Type.LabelAxis_ON;
            Label_X_Axis.ServerOnDO = IO_Type.LabelAxis_ON;
            Label_Y_Axis.ServerOnDO = IO_Type.LabelAxis_ON;
            Label_Z_Axis.ServerOnDO = IO_Type.LabelAxis_ON;
            Label_Z_Axis.BreakOnDO = IO_Type.LabelAxis_Break; 
        }


        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;
        }


      
    }
}