InOutParam.cs 16.0 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 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;


namespace OnlineStore.DeviceLibrary
{
    /// <summary>
    /// 出入库参数
    /// </summary>
    public class InOutParam
    {
        public InOutParam()
        {
            ACStoreP = null;
            this.PosInfo = new InOutPosInfo("", "");
            MoveP = null;
        }

        public InOutParam(InOutPosInfo inoutInfo, LineMoveP linePosition = null)
        {
            ACStoreP = null;
            MoveP = linePosition;
            this.PosInfo = inoutInfo;
        }
        private XLRPosition ACStoreP = null;

        public XLRPosition GetACPosition()
        {
            try
            {
                if (ACStoreP == null)
                {
                    string posId = PosInfo != null ? PosInfo.PosId : "";
                    ACStoreP = CSVPositionReader<XLRPosition>.GetPositon(posId);
                }
            }
            catch (Exception ex)
            {
                LogUtil.error("出入库获取库位信息GetKTKPosition出错:" + ex.ToString());
            }
            return ACStoreP;
        }

        public InOutPosInfo PosInfo { get; set; }
        /// <summary>
        /// 料叉已取料的信息
        /// </summary>
        public InOutPosInfo PosInfoBack { get; set; } = null;
        public LineMoveP MoveP { get; set; }
        /// <summary>
        /// 入料机构从哪个料串取料,或出库放到哪个料串
        /// 0=未知,1=A侧料串,2=B侧料串
        /// </summary>
        public int ShelfType { get; set; } = 0;
    }
    /// <summary>
    /// 出入库料盘信息
    /// </summary>
    public class InOutPosInfo
    {
        public InOutPosInfo() { }
        public InOutPosInfo(string barcode, string posId, int platew = 0, int plateh = 0, bool urgentReel = false, bool cutReel = false, bool smallReel = false, string rfid = "", int rfidLoc = 0, bool singleOut = false)
        {
            this.barcode = barcode;
            this.PosId = posId;
            this.PlateW = platew;
            this.PlateH = plateh;
            this.urgentReel = urgentReel;
            this.cutReel = cutReel;
            this.smallReel = smallReel;
            this.rfid = rfid;
            this.rfidLoc = rfidLoc;
            this.singleOut = singleOut;
        }

        public static InOutPosInfo NewNgPos(string barcode, string posId, int platew, int plateh, string ngMsg)
        {
            InOutPosInfo inOut = new InOutPosInfo(barcode, posId, platew, plateh);
            inOut.IsNG = true;
            inOut.NgMsg = ngMsg;
            return inOut;
        }

        /// <summary>
        /// 物品二维码
        /// </summary>
        public string barcode { get; set; }
        /// <summary>
        /// 库位号编码
        /// </summary>
        public string PosId { get; set; }
        /// <summary>
        /// 料盘宽
        /// </summary>
        public int PlateW { get; set; }
        /// <summary>
        /// 料盘高
        /// </summary>
        public int PlateH { get; set; }

        /// <summary>
        /// urgentReel: true 表示紧急料,
        /// </summary>
        public bool urgentReel { get; set; }
        /// <summary>
        /// cutReel: true 表示分盘料,
        /// </summary>
        public bool cutReel { get; set; }
        /// <summary>
        /// smallReel: true  小料(7x8),
        /// </summary>
        public bool smallReel { get; set; }

        /// <summary>
        /// rfid: 分配的料架RFID
        /// </summary>
        public string rfid { get; set; }
        /// <summary>
        /// 料架位置
        /// </summary>
        public int rfidLoc { get; set; }

        public bool singleOut = false;
        public string ToStr()
        {
            return "  [" + barcode + "] [" + PosId + "] [" + PlateW + "x" + PlateH + "],urgentReel [" + urgentReel
                + "],cutReel [" + cutReel + "],smallReel [" + smallReel + "],rfid [" + rfid + "],rfidLoc [" + rfidLoc + "],singleOut[" + singleOut + "]";
        }

        public bool IsNG { get; set; } = false;

        public string NgMsg { get; set; } = "";
        public int GetPosType()
        {
            int startP = 0;
            if (String.IsNullOrEmpty(PosId))
            {
                return 0;
            }
            if (PosId.Contains("AA"))
            {
                startP = 1;
            }
            else if (PosId.Contains("BB"))
            {
                startP = 2;
            }
            return startP;
        }
        /// <summary>
        /// 库位在存储机构哪个面
        /// 0=未知,1=A面,2=B面
        /// 例:05AA03040102
        //	05:表示料仓编号,01-08
        //	AA:存储机构A面或B面,AA或者BB
        //	03:表示抽屉在第几行
        //	04:表示抽屉在第几列
        //	01:表示在抽屉中的第几行
        //02:表示在抽屉中的第几列
        /// </summary>
        public string GetPosSide()
        {
            if (PosId.Substring(2, 2).Equals("AA")) return "A";
            else if (PosId.Substring(2, 2).Equals("BB")) return "B";
            return "";
        }
        /// <summary>
        /// 检查库位是否存在
        /// </summary>
        /// <returns></returns>
        public bool CheckPosition()
        {
            BoxPosition position = CSVPositionReader<BoxPosition>.GetPositon(PosId);
            if (position == null)
            {
                return false;
            }
            return true;
        }
        /// <summary>
        /// 获取料盘所在料屉的层序号
        /// </summary>
        /// <returns></returns>
        public int GetTrayRow()
        {
            int.TryParse(PosId.Substring(4, 2), out int result);
            return result;
        }
        /// <summary>
        /// 获取料盘所在料屉的列序号
        /// </summary>
        /// <returns></returns>
        public int GetTrayColumn()
        {
            int.TryParse(PosId.Substring(6, 2), out int result);
            return result;
        }
        /// <summary>
        /// 获取料盘在抽屉里的行
        /// </summary>
        /// <returns></returns>
        public int GetRowInTray()
        {
            int.TryParse(PosId.Substring(8, 2), out int result);
            return result;
        }
        /// <summary>
        /// 获取料盘在抽屉里的列
        /// </summary>
        /// <returns></returns>
        public int GetColumnInTray()
        {
            int.TryParse(PosId.Substring(10, 2), out int result);
            return result;
        }
        /// <summary>
        /// 拷贝一个新的实例
        /// </summary>
        /// <returns></returns>
        public InOutPosInfo ToCopy()
        {
            InOutPosInfo posInfo = new InOutPosInfo();
            System.Reflection.PropertyInfo[] info1 = posInfo.GetType().GetProperties();
            System.Reflection.PropertyInfo[] info2 = this.GetType().GetProperties();
            for (int i = 0; i < info1.Length; i++)
                info1[i].SetValue(posInfo, info2[i].GetValue(this));
            return posInfo;

        }
    }
    /// <summary>
    /// 出入库位置信息
    /// </summary>
    public class LineMoveP
    {
        public LineMoveP() { }

        public LineMoveP(BoxEquip_Config equip_Config, string posId = "")
        {
            if (!string.IsNullOrEmpty(posId))
                UpdatePosById(posId);
            LoadStaticPos(equip_Config);
        }
        /// <summary>
        /// 根据库位编号获取库位位置
        /// </summary>
        /// <param name="posId"></param>
        public void UpdatePosById(string posId)
        {
            BoxPosition position = CSVPositionReader<BoxPosition>.GetPositon(posId);
            if (position == null)
            {
                LogUtil.error("GetPositon[" + posId + "] =null,没有库位不能执行出入库");
            }

            PullAxis_Inout_P2_P4 = position.PullAxis_Inout_P2_P4;
            PullAxis_Inout_P3_P5 = position.PullAxis_Inout_P3_P5;
            PullAxis_Updown_P2 = position.PullAxis_Updown_P2;
            PullAxis_Updown_P3 = position.PullAxis_Updown_P3;
            PullAxis_Updown_P4 = position.PullAxis_Updown_P4;
            Updown_P6_P12 = position.Updown_P6_P12;
            Updown_P7_P13 = position.Updown_P7_P13;
            XAxis_AB_P3 = position.XAxis_AB_P3;
            ComAxis_AB_P2 = position.ComAxis_AB_P2;
            ComAxis_AB_P3 = position.ComAxis_AB_P3;
            MoveAxis_P3 = position.MoveAxis_P3;
            Updown_P2 = position.Updown_P2;
            Updown_P3 = position.Updown_P3;
            Updown_P4 = position.Updown_P4;
            Updown_P5 = position.Updown_P5;
            Updown_P8 = position.Updown_P8;
            Updown_P9 = position.Updown_P9;
            Updown_P10 = position.Updown_P10;
            Updown_P11 = position.Updown_P11;
        }
        /// <summary>
        /// 加载固定点位位置
        /// </summary>
        public void LoadStaticPos(BoxEquip_Config equip_Config)
        {
            MoveAxis_P1 = equip_Config.MoveAxis_P1;
            MoveAxis_P2 = equip_Config.MoveAxis_P2;
            PullAxis_Inout_P1 = equip_Config.PullAxis_Inout_P1;
            Updown_P1 = equip_Config.Updown_P1;
            PullAxis_Updown_P1 = equip_Config.PullAxis_Updown_P1;
            XAxis_A_P1 = equip_Config.XAxis_A_P1;
            XAxis_A_P2 = equip_Config.XAxis_A_P2;
            MiddleAxis_A_P1 = equip_Config.MiddleAxis_A_P1;
            MiddleAxis_A_P2 = equip_Config.MiddleAxis_A_P2;
            MiddleAxis_A_P3 = equip_Config.MiddleAxis_A_P3;
            ComAxis_A_P1 = equip_Config.ComAxis_A_P1;
            XAxis_B_P1 = equip_Config.XAxis_B_P1;
            XAxis_B_P2 = equip_Config.XAxis_B_P2;
            MiddleAxis_B_P1 = equip_Config.MiddleAxis_B_P1;
            MiddleAxis_B_P2 = equip_Config.MiddleAxis_B_P2;
            MiddleAxis_B_P3 = equip_Config.MiddleAxis_B_P3;
            ComAxis_B_P1 = equip_Config.ComAxis_B_P1;
        }
        #region 固定轴移动点位信息
        /// <summary>
        ///  PRO,0,行走机构_待机点P1,MoveAxis_P1,100,,,,,,,,,,,,
        /// </summary>
        public int MoveAxis_P1 = 0;

        /// <summary>
        ///  PRO,0,行走机构_进出料机构取放点位P2,MoveAxis_P2,100,,,,,,,,,,,,
        /// </summary>
        public int MoveAxis_P2 = 0;

        /// <summary>
        ///  PRO,0,料斗拉取进出轴_待机点P1,PullAxis_Inout_P1,100,,,,,,,,,,,,
        /// </summary>
        public int PullAxis_Inout_P1 = 0;

        /// <summary>
        ///  PRO,0,移栽升降轴_待机点P1,Updown_P1,100,,,,,,,,,,,,
        /// </summary>
        public int Updown_P1 = 0;

        /// <summary>
        ///  PRO,0,移栽升降轴_A上暂存区取料高点P2,Updown_P2,100,,,,,,,,,,,,
        /// </summary>
        public int Updown_P2 = 0;

        /// <summary>
        /// PRO,0,移栽升降轴_A上暂存区取料低点P3,Updown_P3,100,,,,,,,,,,,,
        /// </summary>
        public int Updown_P3 = 0;

        /// <summary>
        /// PRO,0,移栽升降轴_A下暂存区放料高点P4,Updown_P4,100,,,,,,,,,,,,
        /// </summary>
        public int Updown_P4 = 0;

        /// <summary>
        ///  PRO,0,移栽升降轴_A下暂存区放料低点P5,Updown_P5,100,,,,,,,,,,,,
        /// </summary>
        public int Updown_P5 = 0;

        /// <summary>
        ///  PRO,0,移栽升降轴_B上暂存区取料高点P8,Updown_P8,100,,,,,,,,,,,,
        /// </summary>
        public int Updown_P8 = 0;

        /// <summary>
        ///  PRO,0,移栽升降轴_B上暂存区取料低点P9,Updown_P9,100,,,,,,,,,,,,
        /// </summary>
        public int Updown_P9 = 0;

        /// <summary>
        ///  PRO,0,移栽升降轴_B下暂存区取料高点P10,Updown_P10,100,,,,,,,,,,,,
        /// </summary>
        public int Updown_P10 = 0;

        /// <summary>
        ///  PRO,0,移栽升降轴_B下暂存区取料低点P11,Updown_P11,100,,,,,,,,,,,,
        /// </summary>
        public int Updown_P11 = 0;

        /// <summary>
        ///  PRO,0,料斗拉取升降轴_待机点P1,PullAxis_Updown_P1,100,,,,,,,,,,,,
        /// </summary>
        public int PullAxis_Updown_P1 = 0;

        /// <summary>
        ///  PRO,0,料斗拉取升降轴_料屉提取水平点P2,PullAxis_Updown_P2,100,,,,,,,,,,,,
        /// </summary>
        public int PullAxis_Updown_P2 = 0;

        /// <summary>
        ///  PRO,0,A面移栽X轴_待机点P1,XAxis_A_P1,100,,,,,,,,,,,,
        /// </summary>
        public int XAxis_A_P1 = 0;

        /// <summary>
        ///  PRO,0,A面移栽X轴_A进出料暂存区取放料点P2,XAxis_A_P2,100,,,,,,,,,,,,
        /// </summary>
        public int XAxis_A_P2 = 0;

        /// <summary>
        ///  PRO,0,A面移栽旋转轴_待机点P1,MiddleAxis_A_P1,100,,,,,,,,,,,,
        /// </summary>
        public int MiddleAxis_A_P1 = 0;

        /// <summary>
        ///  PRO,0,A面移栽旋转轴_A进出料暂存区取放料水平点P2,MiddleAxis_A_P2,100,,,,,,,,,,,,
        /// </summary>
        public int MiddleAxis_A_P2 = 0;

        /// <summary>
        /// PRO,0,A面移栽旋转轴_A面料屉库位垂直取放料点P3,MiddleAxis_A_P3,100,,,,,,,,,,,,
        /// </summary>
        public int MiddleAxis_A_P3 = 0;

        /// <summary>
        ///  PRO,0,A面移栽压紧轴_待机点P1,ComAxis_A_P1,100,,,,,,,,,,,,
        /// </summary>
        public int ComAxis_A_P1 = 0;

        /// <summary>
        ///  PRO,0,B面移栽X轴_待机点P1,XAxis_B_P1,100,,,,,,,,,,,,
        /// </summary>
        public int XAxis_B_P1 = 0;

        /// <summary>
        ///  PRO,0,B面移栽X轴_B进出料暂存区取放料点P2,XAxis_B_P2,100,,,,,,,,,,,,
        /// </summary>
        public int XAxis_B_P2 = 0;

        /// <summary>
        ///  PRO,0,B面移栽旋转轴_待机点P1,MiddleAxis_B_P1,100,,,,,,,,,,,,
        /// </summary>
        public int MiddleAxis_B_P1 = 0;

        /// <summary>
        /// PRO,0,B面移栽旋转轴_B进出料暂存区取放料水平点P2,MiddleAxis_B_P2,100,,,,,,,,,,,,
        /// </summary>
        public int MiddleAxis_B_P2 = 0;

        /// <summary>
        ///  PRO,0,B面移栽旋转轴_B面料屉库位垂直取放料点P3,MiddleAxis_B_P3,100,,,,,,,,,,,,
        /// </summary>
        public int MiddleAxis_B_P3 = 0;

        /// <summary>
        ///  PRO,0,B面移栽压紧轴_待机点P1,ComAxis_B_P1,100,,,,,,,,,,,,
        /// </summary>
        public int ComAxis_B_P1 = 0;

        #endregion

        #region 灵活轴移动点位信息
        /// <summary>
        /// PRO,0,行走机构_存储库位取放点位P3,MoveAxis_P3,100,,,,,,,,,,,,
        /// </summary>
        public int MoveAxis_P3 = 0;
        /// <summary>
        /// 料斗进出轴料屉提取点
        /// P2 对应 A面
        /// P4 对应 B面
        /// </summary>
        public int PullAxis_Inout_P2_P4 = 0;

        /// <summary>
        /// 料斗进出轴料屉库位点
        /// P3 对应 A面
        /// P5 对应 B面
        /// </summary>
        public int PullAxis_Inout_P3_P5 = 0;
        /// <summary>
        /// 料斗升降轴料屉提取高点P3
        /// </summary>
        public int PullAxis_Updown_P3 = 0;
        /// <summary>
        /// 料斗升降轴料屉提取低点P4
        /// </summary>
        public int PullAxis_Updown_P4 = 0;

        /// <summary>
        /// 移栽升降轴料屉上方过渡点
        /// P6 对应 A面
        /// P12 对应 B面
        /// </summary>
        public int Updown_P6_P12 = 0;
        /// <summary>
        /// 移栽升降轴料屉取放点
        /// P7 对应 A面
        /// P13 对应 B面
        /// </summary>
        public int Updown_P7_P13 = 0;
        /// <summary>
        /// AB移栽X轴料屉库位取放料点P3
        /// </summary>
        public int XAxis_AB_P3 = 0;

        /// <summary>
        /// AB移栽压紧轴压紧前点P2
        /// </summary>
        public int ComAxis_AB_P2 = 0;
        /// <summary>
        /// AB移栽压紧轴压紧点P3
        /// </summary>
        public int ComAxis_AB_P3 = 0;
        #endregion
    }
}