FeedingEquip_Config.cs 14.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
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 FeedingEquip_Config : DeviceConfig
    {
        public FeedingEquip_Config()
            : base()
        {
        }
        public FeedingEquip_Config(int id, string cid, string type, string filepath)
            : base(id, cid, LoadCSVLibrary.DeviceType.FeedingEquip, filepath)
        {
        }


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

        /// <summary>
        /// PRO,0,扫码的相机名称(多个用#分隔),CameraNameList,Name1#Name1,,,,,
        /// </summary>
        [ConfigProAttribute("CameraNameList")]
        public string CameraNameList { get; set; }

        /// <summary>
        ///  PRO,0,对应的横移模块,SidesWayNum,3,,,,,
        /// </summary>
        [ConfigProAttribute("SidesWayNum",false)]
        public int SidesWayNum { get; set; }
         
        /// <summary>
        ///   PRO,0,上料流水线入口AGV小车站号名称,AgvInName,D3,,,,,
        /// </summary>
        [ConfigProAttribute("AgvInName", false)]
        public string AgvInName { get; set; }
        /// <summary>
        ///   PRO,0,上料流水线出口AGV小车站号名称,AgvOutName,D4,,,,
        /// </summary>
        [ConfigProAttribute("AgvOutName", false)]
        public string AgvOutName { get; set; }



        /// <summary>
        ///   PRO	0	移栽上下运动是否使用伺服 UpDownUseAxis	1
        /// </summary>
        [ConfigProAttribute("UpDownUseAxis")]
        public int UpDownUseAxis { get; set; }
    
        /// <summary>
        ///  AXIS	0	提升上料轴 UpDown_Axis	2
        /// </summary>
        [ConfigProAttribute("Batch_Axis", true)]
        public ConfigMoveAxis Batch_Axis { get; set; }
        



        /// <summary>
        ///  PRO	0	提升上料轴原位待机点 P1   BatchAxisP1	1000
        /// </summary>
        [ConfigProAttribute("BatchAxisP1", true)]
        public int BatchAxisP1 { get; set; }
        /// <summary>
        ///  PRO	0	提升上料轴下降位置P2 BatchAxisP2	10000
        /// </summary>
        [ConfigProAttribute("BatchAxisP2", true)]
        public int BatchAxisP2 { get; set; }
        /// <summary>
        /// PRO	0	提升上料缓慢上升目标位置P3 BatchAxisP3	500
        /// </summary>
        [ConfigProAttribute("BatchAxisP3", true)]
        public int BatchAxisP3 { get; set; }
        /// <summary>
        ///  PRO	0	提升上料轴目标速度 BatchAxis_TargetSpeed	150
        /// </summary>
        [ConfigProAttribute("BatchAxis_TargetSpeed", true)]
        public int BatchAxis_TargetSpeed { get; set; }
        /// <summary>
        ///  PRO	0	提升上料轴加速度 BatchAxis_AddSpeed	400
        /// </summary>
        [ConfigProAttribute("BatchAxis_AddSpeed", true)]
        public short BatchAxis_AddSpeed { get; set; }
        /// <summary>
        ///  PRO	0	提升上料轴减速度 BatchAxis_DelSpeed	400
        /// </summary>
        [ConfigProAttribute("BatchAxis_DelSpeed", true)]
        public short BatchAxis_DelSpeed { get; set; }
        /// <summary>
        ///  PRO	0	提升上料轴原点低速度 BatchAxis_HomeLowSpeed	100
        /// </summary>
        [ConfigProAttribute("BatchAxis_HomeLowSpeed", true)]
        public int BatchAxis_HomeLowSpeed { get; set; }
        /// <summary>
        /// PRO	0	提升上料轴原点高速 BatchAxis_HomeHighSpeed	200
        /// </summary>
        [ConfigProAttribute("BatchAxis_HomeHighSpeed", true)]
        public int BatchAxis_HomeHighSpeed { get; set; }
        /// <summary>
        /// PRO	0	提升上料轴原点加速度 BatchAxis_HomeAddSpeed	200
        /// </summary>
        [ConfigProAttribute("BatchAxis_HomeAddSpeed", true)]
        public int BatchAxis_HomeAddSpeed { get; set; }

         
        /// <summary>
        ///PRO	0	提升上料轴P1速度 BatchAxis_P1Speed	400
        /// </summary>
        [ConfigProAttribute("BatchAxis_P1Speed", true)]
        public int BatchAxis_P1Speed { get; set; }
        /// <summary>
        ///PRO	0	提升上料轴P2速度 BatchAxis_P2Speed	400
        /// </summary>
        [ConfigProAttribute("BatchAxis_P2Speed", true)]
        public int BatchAxis_P2Speed { get; set; }
        /// <summary>
        ///PRO	0	提升上料轴P3速度 BatchAxis_P3Speed	50
        /// </summary>
        [ConfigProAttribute("BatchAxis_P3Speed", true)]
        public int BatchAxis_P3Speed { get; set; }
        /// <summary>
        ///PRO,0,提升上料轴P4速度/料盘拿走后提升轴下降速度,BatchAxis_P4Speed,2000,,,,,
        /// </summary>
        [ConfigProAttribute("BatchAxis_P4Speed", true)]
        public int BatchAxis_P4Speed { get; set; }


        /// <summary>
        ///PRO,0,提升上料轴高度转换系数(1mm对应的脉冲),Height_ChangeValue,5000,,,,,
        /// </summary>
        [ConfigProAttribute("Height_ChangeValue", true)]
        public int Height_ChangeValue { get; set; }
   

        /// <summary>
        ///  AXIS	0	移栽上下轴 UpDown_Axis	2
        /// </summary>
        [ConfigProAttribute("UpDown_Axis", true)]
        public ConfigMoveAxis UpDown_Axis { get; set; }
        /// <summary>
        ///  PRO	0	移栽上下轴待机点 P1 UpDownAxisP1	403000
        /// </summary>
        [ConfigProAttribute("UpDownAxisP1", true)]
        public int UpDownAxisP1 { get; set; }
        /// <summary>
        ///  PRO,0,移栽上下轴P2移栽机构下降位置,UpDownP2List,0=180000;,,,,,
        /// </summary>
        [ConfigProAttribute("UpDownP2List", true)]
        public string UpDownP2List { get; set; }
        /// <summary>
        ///  PRO,0,移栽上下轴料架上方P3取料/放料位置,UpDownAxisP3,20000,,,,,
        /// </summary>
        [ConfigProAttribute("UpDownAxisP3", true)]
        public int UpDownAxisP3 { get; set; }
        

        /// <summary>
        ///  PRO	0	移栽上下轴目标速度 UpdownAxis_TargetSpeed	150
        /// </summary>
        [ConfigProAttribute("UpdownAxis_TargetSpeed", true)]
        public int UpdownAxis_TargetSpeed { get; set; }
        /// <summary>
        ///  PRO	0	移栽上下轴加速度 UpdownAxis_AddSpeed	400
        /// </summary>
        [ConfigProAttribute("UpdownAxis_AddSpeed", true)]
        public short UpdownAxis_AddSpeed { get; set; }
        /// <summary>
        ///  PRO	0	移栽上下轴减速度 UpdownAxis_DelSpeed	400
        /// </summary>
        [ConfigProAttribute("UpdownAxis_DelSpeed", true)]
        public short UpdownAxis_DelSpeed { get; set; }
        /// <summary>
        ///  PRO	0	移栽上下轴原点低速度 UpdownAxis_HomeLowSpeed	100
        /// </summary>
        [ConfigProAttribute("UpdownAxis_HomeLowSpeed", true)]
        public int UpdownAxis_HomeLowSpeed { get; set; }
        /// <summary>
        /// PRO	0	移栽上下轴原点高速 UpdownAxis_HomeHighSpeed	200
        /// </summary>
        [ConfigProAttribute("UpdownAxis_HomeHighSpeed", true)]
        public int UpdownAxis_HomeHighSpeed { get; set; }
        /// <summary>
        /// PRO	0	移栽上下轴原点加速度 UpdownAxis_HomeAddSpeed	200
        /// </summary>
        [ConfigProAttribute("UpdownAxis_HomeAddSpeed", true)]
        public int UpdownAxis_HomeAddSpeed { get; set; }
         

        /// <summary>
        ///   PRO,0,移栽上下轴走到待机点速度,UpdownAxis_P1Speed,400,,,,,
        /// </summary>
        [ConfigProAttribute("UpdownAxis_P1Speed", true)]
        public int UpdownAxis_P1Speed { get; set; }
        /// <summary>
        /// PRO,0,移栽上下轴P2速度,UpdownAxis_P2Speed,500,,,,,
        /// </summary>
        [ConfigProAttribute("UpdownAxis_P2Speed", true)]
        public int UpdownAxis_P2Speed { get; set; }

        /// <summary>
        /// PRO,0,移栽上下轴P3速度,UpdownAxis_P3Speed,400,,,,, 
        /// </summary>
        [ConfigProAttribute("UpdownAxis_P3Speed", true)]
        public int UpdownAxis_P3Speed { get; set; }
        /// <summary>
        ///    PRO,0,是否是用来出料,IsCanOut,1,,,,,
        /// </summary>
        [ConfigProAttribute("IsCanOut", false)]
        public int IsCanOut { get; set; }



        /// <summary>
        ///   PRO,0,移栽上下轴流水线取放料详细位置P2,UpDownP2DetialList,7*16=80000;,,,,,
        /// </summary>
        [ConfigProAttribute("UpDownP2DetialList", false)]
        public string UpDownP2DetialList { get; set; }
        /// <summary>
        ///PRO,0,最后一盘料补充高度(mm),LastReel_AHeight,1,,,,,
        /// </summary>
        [ConfigProAttribute("LastReel_AHeight", false)]
        public int LastReel_AHeight { get; set; }
        private Dictionary<string, int> UpdownP2DetialMap = null;

        public Dictionary<string, int> LoadP2DetialMap()
        {
            try
            {
                if (UpdownP2DetialMap == null)
                {
                    UpdownP2DetialMap = new Dictionary<string, int>();
                    string[] arrayList = UpDownP2DetialList.Split(';');
                    foreach (string str in arrayList)
                    {
                        string[] arrStr = str.Split('=');
                        if (arrStr.Length == 2)
                        {
                            string key = arrStr[0].Trim().ToUpper();
                            if (key.Equals("0X0"))
                            {
                                continue;
                            }
                            int length = Convert.ToInt32(arrStr[1].Trim());
                            UpdownP2DetialMap.Add(key, length);
                        }
                    }
                }
            }
            catch (Exception ex)
            {

            }
            return UpdownP2DetialMap;
        }

        public int GetUpdownP2Detial(int trayHeight, int traySize = 8)
        {
            LoadP2DetialMap();
            string fkey = traySize + "X" + trayHeight;
            if (UpdownP2DetialMap.ContainsKey(fkey))
            {
                return UpdownP2DetialMap[fkey];
            }
            else
            {
                return GetUpdownP2(trayHeight);
            }
            return -1;
        }


        public void UpdateUpdownP2Detial(int size, int height, int sizePosition)
        {
            string fkey = size + "X" + height;
            string newPositionStr = "";
            if (UpdownP2DetialMap.ContainsKey(fkey))
            {
                UpdownP2DetialMap[fkey] = sizePosition;
            }
            else
            {

                UpdownP2DetialMap.Add(fkey, sizePosition);
            }
            foreach (string key in UpdownP2DetialMap.Keys)
            {
                newPositionStr += key + "=" + UpdownP2DetialMap[key] + ";";
            }
            newPositionStr = newPositionStr.Substring(0, newPositionStr.Length - 1);
            UpDownP2DetialList = newPositionStr;
        }

        private List<string> CameraList = null;

        public List<string> GetCameraList()
        {
            if (CameraList == null)
            {
                CameraList = new List<string>();
                string[] arrayList = CameraNameList.Split('#');
                foreach (string str in arrayList)
                {
                    string camera = str.Trim();
                    if (string.IsNullOrEmpty(camera).Equals(false))
                    {
                        CameraList.Add(camera);
                    }   
                }
            }
            return CameraList;
        }

        private Dictionary<int, int> UpDownPositionP2Map = null; 
        public  int GetUpdownP2(int trayHeight)
        {
            try
            {
                if (UpDownPositionP2Map == null)
                {
                    UpDownPositionP2Map = new Dictionary<int, int>();
                    string[] arrayList = UpDownP2List.Split(';');
                    foreach (string str in arrayList)
                    {
                        string[] arrStr = str.Split('=');
                        if (arrStr.Length == 2)
                        {
                            int height = Convert.ToInt32(arrStr[0].Trim());
                            int length = Convert.ToInt32(arrStr[1].Trim());
                            UpDownPositionP2Map.Add(height, length);
                        }
                    }
                }
            }
            catch (Exception ex)
            {

            }
            if (UpDownPositionP2Map.ContainsKey(trayHeight))
            {
                return UpDownPositionP2Map[trayHeight];
            }else if (UpDownPositionP2Map.ContainsKey(0))
            {
                return UpDownPositionP2Map[0];
            }
            return -1;
        }

        public void UpdateUpdownP2(int size, int sizePosition)
        {
            string newPositionStr = "";
            if (UpDownPositionP2Map.ContainsKey(size))
            {
                UpDownPositionP2Map[size] = sizePosition;
            }
            else
            {

                UpDownPositionP2Map.Add(size, sizePosition);
            }
            foreach(int  key in UpDownPositionP2Map.Keys)
            {
                newPositionStr += key + "=" + UpDownPositionP2Map[key] + ";";
            }
            newPositionStr = newPositionStr.Substring(0, newPositionStr.Length - 1);
            UpDownP2List = newPositionStr;
        }

    
        public void SetAxisParam()
        {
            this.Batch_Axis.TargetSpeed = this.BatchAxis_TargetSpeed;
            this.Batch_Axis.AddSpeed = this.BatchAxis_AddSpeed;
            this.Batch_Axis.DelSpeed = this.BatchAxis_DelSpeed;
            this.Batch_Axis.HomeAddSpeed = this.BatchAxis_HomeAddSpeed;
            this.Batch_Axis.HomeHighSpeed = this.BatchAxis_HomeHighSpeed;
            this.Batch_Axis.HomeLowSpeed = this.BatchAxis_HomeLowSpeed;

            this.Batch_Axis.ServerOnDO = IO_Type.BatchAxis_ServoOn;
            this.Batch_Axis.BreakOnDO = IO_Type.BatchAxis_BreakOn;
            this.Batch_Axis.CanErrorCountMax = 10000;
            this.Batch_Axis.CanErrorCountMin = 1000;

            this.UpDown_Axis.TargetSpeed = this.UpdownAxis_TargetSpeed;
            this.UpDown_Axis.AddSpeed = this.UpdownAxis_AddSpeed;
            this.UpDown_Axis.DelSpeed = this.UpdownAxis_DelSpeed;
            this.UpDown_Axis.HomeAddSpeed = this.UpdownAxis_HomeAddSpeed;
            this.UpDown_Axis.HomeHighSpeed = this.UpdownAxis_HomeHighSpeed;
            this.UpDown_Axis.HomeLowSpeed = this.UpdownAxis_HomeLowSpeed;

            this.UpDown_Axis.ServerOnDO = IO_Type.UpDownAxis_ServoOn;
            this.UpDown_Axis.BreakOnDO = IO_Type.UpDownAxis_BreakOn;
        }
    }
}