MoveEquip_Partial.cs 32.3 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 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;

namespace OnlineStore.DeviceLibrary
{
    partial class MoveEquip
    {

        #region 出库 
        public override bool StartOutStoreMove(InOutParam param)
        { 
            string posId = param != null ? param.PosId : "";
            //调试模式移栽装置不需要有操作
            if (IsDebug)
            {
                LogInfo("需要出库【" + posId + "】处于调试模式,暂时不再进行出入库操作");
                return false;
            }
            if (param.Equals(null))
            {
                LogUtil.error(Name + "出库【" + posId + "】失败,param=null");
                return false;
            }
            if (runStatus.Equals(LineRunStatus.Runing))
            {
                LogInfo("启动出库【" + posId + "】:开始叫托盘 ");
                runStatus = LineRunStatus.Busy;
                lineStatus = LineStatus.OutStoreExecute;
                MoveInfo.NewMove(LineMoveType.OutStore);
                MoveInfo.MoveParam = param;
                MoveInfo.NextMoveStep(LineMoveStep.MO_50_StartOutProcess);
                TrayManager.AddNeedEmptyTrayNum();
                return true;
            }
            else
            {
                LogUtil.error(Name + " 启动出库【" + posId + "】失败,当前状态,storeStatus=" + runStatus);
                return false;
            }

        }

        protected override void OutStoreProcess()
        {
            string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosId : "";
            if (MoveInfo.IsInWait)
            {
                CheckWait(MoveInfo);
            }
            if (SecondMoveInfo.IsInWait)
            {
                CheckWait(SecondMoveInfo);
            }
            if (MoveInfo.IsInWait)
            {
                return;
            }
            #region 移载装置 移栽物品操作
            if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_50_StartOutProcess))
            {
                OutStoreLog("出库: MO_51_BeforeAfterCylinderBefore ( 前后气缸前进 )");
                MoveInfo.NextMoveStep(LineMoveStep.MO_51_BeforeAfterCylinderBefore);
                CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_51_BeforeAfterCylinderBefore))
            {
                OutStoreLog("出库: MO_52_UpDownCylinderDown ( 上下气缸1下降 )");
                MoveInfo.NextMoveStep(LineMoveStep.MO_52_UpDownCylinderDown);
                UpdownDownBoxMove(MoveInfo.MoveParam.PlateH);
                // CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_52_UpDownCylinderDown))
            {
                OutStoreLog("出库: MO_53_UpDownCylinderDownWait ( 上下气缸1下降 后,等待0.3秒再夹紧,防止没有下降到位就夹紧操作)");
                MoveInfo.NextMoveStep(LineMoveStep.MO_53_UpDownCylinderDownWait);
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_53_UpDownCylinderDownWait))
            {
                OutStoreLog("出库: MO_54_ClampCylinderSlack ( 夹料气缸1夹紧)");
                MoveInfo.NextMoveStep(LineMoveStep.MO_54_ClampCylinderSlack);
                CylinderMove(MoveInfo, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_54_ClampCylinderSlack))
            {
                OutStoreLog("出库: MO_55_UpDownCylinderUp ( 上下气缸1上升)");
                MoveInfo.NextMoveStep(LineMoveStep.MO_55_UpDownCylinderUp);
                UpdownUpMove();
                //   CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);

            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_55_UpDownCylinderUp))
            {
                OutStoreLog("出库: MO_56_BeforeAfterCylinderAfter( 前后气缸1后退)");
                MoveInfo.NextMoveStep(LineMoveStep.MO_56_BeforeAfterCylinderAfter);
                CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
            }
            #endregion

            #region 移载装置,放物品到流水线操作
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_11_CodeRember)
                && MoveInfo.MoveStep.Equals(LineMoveStep.MO_56_BeforeAfterCylinderAfter)
                  && !SecondMoveInfo.IsInWait)
            {
                OutStoreLog("出库:( MO_06_UpDownCylinderDown,夹具检测编码完成, 上下气缸1下降 )");
                if (MoveInfo.MoveParam != null)
                {
                    MoveInfo.MoveParam.TrayNumber = SecondMoveInfo.MoveParam.TrayNumber;
                }
                else
                {
                    MoveInfo.MoveParam = SecondMoveInfo.MoveParam;
                }

                //去掉直接丢盘处理
                MoveInfo.NextMoveStep(LineMoveStep.MO_58_UpDownCylinderDown);
                UpdownDownMove(MoveInfo.MoveParam.PlateH);

                ////判断盘号,如果是七寸盘,不需要下降,直接放盘 
                //bool isNeedPush = MoveInfo.MoveParam.PlateW.Equals(TrayManager.CanPushBagWidth);

                //if (isNeedPush)
                //{
                //    MoveInfo.NextMoveStep(LineMoveStep.MO_58_UpDownCylinderDown);
                //    MoveInfo.EndStepWait();
                //}
                //else
                //{
                //    MoveInfo.NextMoveStep(LineMoveStep.MO_58_UpDownCylinderDown);
                //    UpdownDownMove(MoveInfo.MoveParam.PlateH);
                //    //  CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
                //}
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_58_UpDownCylinderDown))
            {
                OutStoreLog("出库:(MO_07_ClampCylinderTighten   夹料气缸1放松 )");
                int bagWidth = MoveInfo.MoveParam.PlateW;

                LogInfo("【" + posId + "】出库时,更新盘空满信息 托盘号【" + MoveInfo.MoveParam.TrayNumber + "】,是否有料盘【" + true + "】,出库入库【" + 2 + "】");
                TrayManager.UpdateFixtureValue(MoveInfo.MoveParam.TrayNumber, true, ReelType.OutStore, MoveInfo.MoveParam.WareCode, MoveInfo.MoveParam.PosId, MoveInfo.MoveParam.PlateH, bagWidth);

                //出库全部完成 
                lineStatus = LineStatus.StoreOnline;
                MoveInfo.NextMoveStep(LineMoveStep.MO_59_ClampCylinderTighten);
                CylinderMove(MoveInfo, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_59_ClampCylinderTighten))
            {
                OutStoreLog("出库:(MO_08_UpDownCylinderUp  上下气缸1上升)");

                this.MoveInfo.NextMoveStep(LineMoveStep.MO_60_UpDownCylinderUp);
                UpdownUpMove();
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_60_UpDownCylinderUp))
            {
                //  减去需要的盘数
                TrayManager.DelNeedEmptyTrayNum();
                OutStoreLog("出库 SecondMove:移栽完成,放行托盘");
                SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
                SecondMoveInfo.NextMoveStep(LineMoveStep.MO_12_TopCylinder_Down);
                CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);

                LogInfo("【" + posId + "】出库处理结束,!");
                lineStatus = LineStatus.StoreOnline;
                runStatus = LineRunStatus.Runing;
                MoveInfo.EndMove();
            }

            #endregion
        }


        #endregion

        #region 入库
        /// <summary>
        /// 入库移动移动
        /// </summary> 
        public override void StartInStoreMove(InOutParam param)
        {
            string posId = param != null ? param.PosId : "";
            //调试模式移栽装置不需要有操作
            if (IsDebug)
            {
                LogInfo("需要入库【" + posId + "】处于调试模式,暂时不再进行出入库操作");
                return;
            }
            if (runStatus.Equals(LineRunStatus.Runing))
            {
                runStatus = LineRunStatus.Busy;
                lineStatus = LineStatus.InStoreExecute;
                MoveInfo.MoveParam = param;
                MoveInfo.NewMove(LineMoveType.InStore);
                LogInfo("入库【" + posId + "】处理(移栽):(MI_07_UpDownCylinderDown,上下气缸1下降)");
                MoveInfo.NextMoveStep(LineMoveStep.MI_07_UpDownCylinderDown);
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
                UpdownDownMove(MoveInfo.MoveParam.PlateH);
                //  CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
            }
            else
            {
                LogUtil.error(Name + " 启动一个 入库【" + posId + "】运动失败,当前状态,storeStatus=" + runStatus);
            }
        }

        protected override void InStoreProcess()
        {
            if (MoveInfo.IsInWait)
            {
                CheckWait(MoveInfo);
            }
            if (SecondMoveInfo.IsInWait)
            {
                CheckWait(SecondMoveInfo);
            }
            if (MoveInfo.IsInWait)
            {
                return;
            }
            string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosId : "";
            if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_07_UpDownCylinderDown))
            {
                InStoreLog("入库:(MI_07_UpDownCylinderDownWait,  编码与仓位一致,上下气缸1下降后等待0.3秒再夹紧,防止没有下降到位就夹紧");
                MoveInfo.NextMoveStep(LineMoveStep.MI_07_UpDownCylinderDownWait);
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
            }
            //只有当BOX可以进行出入库时,移栽物品,防止卡住
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_07_UpDownCylinderDownWait))
            {
                InStoreLog("入库:(MI_08_ClampCylinderSlack,夹料气缸1夹紧)");
                MoveInfo.NextMoveStep(LineMoveStep.MI_08_ClampCylinderSlack);
                CylinderMove(MoveInfo, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_08_ClampCylinderSlack))
            {
                InStoreLog("入库:(MI_09_UpDownCylinderUp,上下气缸1上升)");
                MoveInfo.NextMoveStep(LineMoveStep.MI_09_UpDownCylinderUp);
                UpdownUpMove();
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_09_UpDownCylinderUp))
            {
                int num = MoveInfo.MoveParam.TrayNumber;
                MoveInfo.NextMoveStep(LineMoveStep.MI_10_WaitBox);
                LogInfo("入库【" + posId + "】处理(等待移栽):(判断box门口没有盘, 且可以入库),更新盘号【" + num + "】为空盘");
                MoveInfo.WaitList.Add(WaitResultInfo.WaitBoxCanReviceTray());
                TrayManager.UpdateFixtureValue(num );

                //阻挡气缸移动
                InStoreLog("放托盘(放开阻挡):SecondMove=MO_12_TopCylinder_Down   物品已移走,顶升气缸1下降)");
                SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
                SecondMoveInfo.NextMoveStep(LineMoveStep.MO_12_TopCylinder_Down);
                CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_10_WaitBox))
            {
                InStoreLog("入库:(MI_10_BeforeAfterCylinderBefore,前后气缸1前进)");
                MoveInfo.NextMoveStep(LineMoveStep.MI_10_BeforeAfterCylinderBefore);
                CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_10_BeforeAfterCylinderBefore))
            {
                InStoreLog("入库:(MI_11_UpDownCylinderDown ,上下气缸1下降)");
                MoveInfo.NextMoveStep(LineMoveStep.MI_11_UpDownCylinderDown);
                UpdownDownBoxMove(MoveInfo.MoveParam.PlateH);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_11_UpDownCylinderDown))
            {
                InStoreLog("入库:  (MI_12_ClampCylinderTighten,夹料气缸1放松)");
                MoveInfo.NextMoveStep(LineMoveStep.MI_12_ClampCylinderTighten);
                CylinderMove(MoveInfo, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_12_ClampCylinderTighten))
            {
                InStoreLog("入库:(MI_13_UpdownCylinderUp,上下气缸1上升)");
                MoveInfo.NextMoveStep(LineMoveStep.MI_13_UpdownCylinderUp);
                UpdownUpMove();
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_13_UpdownCylinderUp))
            {
                InStoreLog("入库:(MI_14_BeforeAfterCylinderAfter,前后气缸1后退,等待4000 )");
                MoveInfo.NextMoveStep(LineMoveStep.MI_14_BeforeAfterCylinderAfter);
                CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(4000));
                //此时box就可以入库操作了                //触发事件,BOX入库
                LineServer.StartInStore(DeviceID, MoveInfo.MoveParam);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_14_BeforeAfterCylinderAfter))
            {
                MoveInfo.NextMoveStep(LineMoveStep.MI_15_SendEnd);
                //判断料仓是否在入库中,如果么有在入库中,需要重新发送入库消息
                if (!LineServer.IsInStorePro(DeviceID))
                {
                    InStoreLog("入库:(MI_15_SendEnd , 送料流程完成,料仓还未开始入库,再次发送starIn命令)");
                    LineServer.StartInStore(DeviceID, MoveInfo.MoveParam);
                }
                else
                {
                    InStoreLog("入库:(MI_15_SendEnd , 送料流程完成,料仓已开始入库)");
                }
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_15_SendEnd))
            {
                LogInfo("入库【" + posId + "】处理(移栽)全部完成!");
                runStatus = LineRunStatus.Runing;
                lineStatus = LineStatus.StoreOnline;
                MoveInfo.EndMove();
            }
        }

        private bool IsInStoreNeed()
        {

            if (waitInStoreList.Count > 0)
            {
                lock (waitInListLock)
                {
                    //判断是否是自己排队列表中的入库信息 
                    foreach (InOutParam cc in waitInStoreList)
                    {
                        if (cc.TrayNumber.Equals(currMoveTrayNum) && (!cc.WareCode.Equals("")))
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }

        /// <summary>
        /// 是否需要出库的托盘
        /// </summary>
        /// <param name="currMoveTrayNum"></param>
        /// <returns></returns>
        private bool CheckIsNeedOutStore()
        {
            bool isFull = TrayManager.IsFixTureFull(currMoveTrayNum);
            if (MoveInfo.MoveType.Equals(LineMoveType.OutStore) && (MoveInfo.MoveStep >= LineMoveStep.MO_56_BeforeAfterCylinderAfter)
                 && (!MoveInfo.MoveStep.Equals(LineMoveStep.MO_60_UpDownCylinderUp)))
            {
                if (isFull.Equals(false))
                {
                    LogInfo(" 托盘号【" + preTrayNum + "】,当前托盘号【(isFull=" + isFull + "):" + currMoveTrayNum + "】需要出库,不顶升直接让移栽放盘~");
                    return true;
                }
                //去掉直接丢料盘处理
                //else if (MoveInfo.MoveParam.PlateW.Equals(TrayManager.CanPushBagWidth) && TrayManager.IsCanOutPush(currMoveTrayNum))
                //{
                //    LogInfo(" 托盘号【" + preTrayNum + "】,当前托盘号【(isFull=" + isFull + "):" + currMoveTrayNum + "】需要出库," + TrayManager.CanPushBagWidth + "寸小盘可以直接出库累积~");
                //    return true;
                //}
            }
            return false;
        }
        /// <summary>
        /// 判断盘号是否需要入库
        /// </summary>
        /// <returns></returns>
        private bool CheckIsNeedInStore()
        {
            bool isfull = TrayManager.IsFixTureFull(currMoveTrayNum);
            LogInfo("***************入库*****验证入库编号,托盘号【" + currMoveTrayNum + "】,isfull【" + isfull + "】");
            //FixtureCodeInfo code = GetBox().currInOutFixture;
            if (!isfull)
            {
                LogInfo("***************入库*****空盘直接放行");
                return false;
            }
            InOutParam currCode = null;
            if (waitInStoreList.Count > 0)
            {
                lock (waitInListLock)
                {
                    //判断是否是自己排队列表中的入库信息
                    int reIndex = -1;
                    for (int i = 0; i < waitInStoreList.Count; i++)
                    {
                        InOutParam cc = waitInStoreList[i];
                        if (cc.TrayNumber.Equals(currMoveTrayNum) && (!cc.WareCode.Equals("")))
                        {
                            reIndex = i;
                            currCode = cc;
                            LogInfo("*******托盘" + currMoveTrayNum + "需要入库【" + currCode.ToStr() + "】 ,开始入库移栽");
                            SecondMoveInfo.MoveParam = new InOutParam(cc.TrayNumber, cc.WareCode, cc.PosId, cc.PlateH, cc.PlateW);
                            break;
                        }
                    }
                    if (reIndex >= 0)
                    {
                        waitInStoreList.RemoveAt(reIndex);
                        if (!LineServer.BoxCanInStore(DeviceID))
                        {
                            LogUtil.info(Name + "*******托盘" + currMoveTrayNum + "需要入库【" + currCode.ToStr() + "】,BoxCanInStore验证失败,先移栽再等待料仓可入库,开始入库移栽");
                            return true;
                        }
                        else
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }
        #endregion

        #region 托盘检测
        private void StartCheckFixture()
        {
            int num = TrayManager.GetNum(DeviceID);
            if (IOValue(IO_Type.StopCylinder_Check2).Equals(IO_VALUE.HIGH))
            {
                //托盘在两个阻挡内
                if (num > 0)
                {
                    SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
                    CheckLog("托盘检测(流水线阻挡)SecondMove:(MIO_03_StopCylinder2Down  阻挡气缸1-1上升)");
                    SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_StopCylinder2Down);
                    IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
                    SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down1, IO_VALUE.LOW));
                    //    SecondMoveInfo.EndStepWait();
                }
                else
                {
                    LogUtil.error(Name + "检测到check4亮,但是为获取到托盘号,StartCheckFixture失败~");
                }
            }
            else if (IOValue(IO_Type.StopCylinder_Check1).Equals(IO_VALUE.HIGH))
            {
                //托盘在第一个阻挡处
                SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
                SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_01_StopCylinder1Down);
                CheckLog(" 托盘检测:料盘检测 SecondMove(MIO_01_StopCylinder1Down阻挡气缸1-1下降 ,最多等待1秒)");
                IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH));
                //   SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Fixture_Check_4, IO_VALUE.HIGH));
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
            }
        }
        protected override void CheckFixtureProcess()
        {
            if (!LineManager.Line.LineCanRun())
            {
                return;
            }
            if (SecondMoveInfo.IsInWait)
            {
                CheckWait(SecondMoveInfo);
            }
            if (SecondMoveInfo.IsInWait)
            {
                return;
            }

            #region 托盘检测
            if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_01_StopCylinder1Down))
            {
                CheckLog("托盘检测(流水线阻挡)SecondMove:(MIO_02_FixtureCheck  阻挡气缸1-1上升,等待 阻挡2托盘检测=1)");
                SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_StopCylinder2Down);
                IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down1, IO_VALUE.LOW));
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.HIGH));
            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_02_FixtureCheck))
            {
                CheckLog("托盘检测(流水线阻挡)SecondMove:(MIO_03_StopCylinder2Down  阻挡气缸1-1上升)");
                SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_StopCylinder2Down);
                IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down1, IO_VALUE.LOW));
                // SecondMoveInfo.EndStepWait();
            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_03_StopCylinder2Down))
            {
                CheckLog("托盘检测(流水线阻挡)SecondMove:(MIO_04_Wait ,等待编码信号稳定)");
                SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_04_Wait);
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_04_Wait))
            {
                try
                {
                    //KTK_LA_BoxBean Box = GetBox();
                    //判断是否需要顶升
                    bool isNeed = false;
                    //此处先对托盘号进行验证
                    currMoveTrayNum = TrayManager.GetNum(DeviceID);
                    bool isFull = TrayManager.IsFixTureFull(currMoveTrayNum);
                    if (TrayManager.RightTrayCode(currMoveTrayNum, preTrayNum, false))
                    {
                        //出库中,需要拦盘
                        if (CheckIsNeedOutStore())
                        {
                            //preTrayNum = currMoveTrayNum;
                            SecondMoveInfo.MoveParam = new InOutParam(currMoveTrayNum);
                            SecondMoveInfo.NextMoveStep(LineMoveStep.MO_11_CodeRember);
                            SecondMoveInfo.EndStepWait();
                            return;
                        }
                        else if (isFull && IsInStoreNeed())
                        {
                            isNeed = true;
                        }
                    }
                    else
                    {
                        string msg = Name + " 托盘顺序错乱,上个托盘号【" + preTrayNum + "】当前托盘号 【" + currMoveTrayNum + "】最大盘号【" + TrayManager.MaxTrayNum + "】";
                        TrayManager.UpdateTrayNumError(DeviceID, msg);
                        LogUtil.error(msg);
                        return;
                    }
                    if (isNeed)
                    {
                        CheckLog("托盘检测(流水线阻挡)SecondMove:(MIO_05_WaitTime 等待一秒钟)");
                        SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_05_WaitTime);
                        SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
                    }
                    else
                    {
                        LogInfo(SecondMoveInfo.MoveNum + "***************上个托盘号【" + preTrayNum + "】,当前" + (isFull ? "有料托盘" : "空托盘") + "【" + currMoveTrayNum + "】没有出入库任务,放盘通过~");
                        //  preTrayNum = currMoveTrayNum;
                        if (TrayManager.ErrorStoreId.Equals(DeviceID))
                        {
                            TrayManager.UpdateTrayNumError(-1, "");
                        }
                        CheckLog("托盘放行  SecondMove:(MO_13_WaitCanGo ,移栽2,需要判断是否可以放盘通过,最多等待10000)");
                        SecondMoveInfo.NextMoveStep(LineMoveStep.MO_13_WaitCanGo);
                        if (DeviceID.Equals(2))
                        {
                            SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
                            SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitSideWay());
                            SecondMoveInfo.OneWaitCanEndStep = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogUtil.error("判断托盘是否需要顶升出错:" + ex.ToString());
                }
            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_05_WaitTime))
            {
                CheckLog("托盘检测(流水线阻挡)SecondMove:(MIO_06_TopCylinderUp 顶升气缸上 升 )");
                SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_06_TopCylinderUp);
                CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_06_TopCylinderUp))
            {
                CheckLog("托盘检测(流水线阻挡)SecondMove:(MIO_07_TopCylinderUpWait ,顶升气缸上升时等待1秒钟,再下降)");
                SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_07_TopCylinderUpWait);
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_07_TopCylinderUpWait))
            {
                CheckLog("托盘检测(流水线阻挡)*************** 托盘号【" + currMoveTrayNum + "】");

                //托盘号正确
                //preTrayNum = num;
                bool isNeedMove = false;
                //判断盘是空盘,空盘并且编号正确才需要放料盘过去
                if (CheckIsNeedOutStore())
                {
                    SecondMoveInfo.MoveParam = new InOutParam(currMoveTrayNum);
                    isNeedMove = true;
                    LogInfo(SecondMoveInfo.MoveNum + "*************** 托盘号【" + currMoveTrayNum + "】可以放出库托盘,正在出库中,移栽料盘");
                    SecondMoveInfo.NextMoveStep(LineMoveStep.MO_11_CodeRember);
                    SecondMoveInfo.EndStepWait();
                }
                else
                {
                    if (CheckIsNeedInStore())
                    {
                        LogInfo(SecondMoveInfo.MoveNum + "*************** 托盘号【" + currMoveTrayNum + "】不是空盘,有对应的入库任务,等待移栽");
                        SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_08_WaitInStore);
                        isNeedMove = true;
                    }
                    else
                    {
                        LogInfo(SecondMoveInfo.MoveNum + "*************** 托盘号【" + currMoveTrayNum + "】不是空盘, 放盘通过");
                    }
                }
                if (!isNeedMove)
                {
                    //preTrayNum = num;
                    if (TrayManager.ErrorStoreId.Equals(DeviceID))
                    {
                        TrayManager.UpdateTrayNumError(-1, "");
                    }
                    CheckLog("托盘检测 SecondMove:(MO_12_TopCylinder_Down ,托盘号【" + currMoveTrayNum + "】,直接放盘通过,顶升气缸下降)");
                    SecondMoveInfo.NextMoveStep(LineMoveStep.MO_12_TopCylinder_Down);
                    CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
                }

            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_08_WaitInStore) && MoveInfo.MoveType.Equals(LineMoveType.None))
            {
                CheckLog("托盘放行 SecondMove:(MIO_09_WaitLetFixtureGo ,等待移栽完成后放开阻挡)");
                StartInStoreMove(SecondMoveInfo.MoveParam);
                SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_09_WaitLetFixtureGo);
            }
            #endregion

            #region 不需要出入库,直接放行
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_12_TopCylinder_Down))
            {
                CheckLog("托盘放行  SecondMove:(MO_13_WaitCanGo ,移栽2,需要判断是否可以放盘通过,最多等待10000)");
                SecondMoveInfo.NextMoveStep(LineMoveStep.MO_13_WaitCanGo);
                if (DeviceID.Equals(2))
                {
                    SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
                    SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitSideWay());
                    SecondMoveInfo.OneWaitCanEndStep = true;
                }

            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_13_WaitCanGo))
            {
                CheckLog("托盘放行  SecondMove:(MO_14_StopCylinder2_Down ,阻挡气缸1-2下降)");
                SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_StopCylinder2_Down);
                IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
                //  SecondMoveInfo.EndStepWait();
            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_14_StopCylinder2_Down))
            {
                CheckLog("托盘放行  SecondMove:(MO_15_Tray_Check , 阻挡2托盘检测=0), 延时2秒)");
                SecondMoveInfo.NextMoveStep(LineMoveStep.MO_15_Tray_Check);
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.LOW));
            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_15_Tray_Check))
            {
                SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_StopCylinder_Back);
                CheckLog("托盘放行  SecondMove:(MO_16_StopCylinder_Back , 阻挡气缸1-2上升 )");
                IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.LOW));
                SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
            }
            else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_16_StopCylinder_Back))
            {
                preTrayNum = currMoveTrayNum;
                CheckLog("托盘放行  SecondMove:(托盘放行结束) ");
                // IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
                SecondMoveInfo.EndMove();
            }
            #endregion
        }

        #endregion
    

         
    }
}