Square_BoxBean_Partial.cs 48.6 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 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace OnlineStore.DeviceLibrary
{
    partial class Square_BoxBean
    {

        #region 自动出入库参数
        /// <summary>
        /// 料仓内所有的位置列表
        /// </summary>
        public List<string> PositionNumList = new List<string>();
        /// <summary>
        /// 入库完成后自动出库,出库完成后自动入库
        /// </summary>
        public bool autoNext = false;
        /// <summary>
        /// 自动出入库间隔
        /// </summary>
        public int autoJiange = 3;
        public int autoPositionIndex = 0;
        public int autoShelfType = 1;
        public string autoMsg = "";
        public int AutoStartIndex = -1;
        #endregion

        #region 出入库参数
        /// <summary>
        /// 当前出入库的次数,超过配置的数量时,需要自动重置一下,再进行出入库
        /// </summary>
        private int CurrInOutCount = 0;
        private int CurrInOutACount = 0;

        private bool LoadParamPosition(InOutParam param)
        {
            if (param == null)
            {
                return false;
            }
            //加载位置
            if (param.MoveP == null)
            {
                LineMoveP p = new LineMoveP();
                ACSquareSPosition position = param.GetACPosition();
                if (position == null)
                {
                    LogUtil.error(LOGGER, StoreName + "出入库时发现param中取到的Position=null,没有库位不能执行出入库");
                    return false;
                }

                p.InOut_P1 = Config.InOutAxis_P1_Position;
                p.Middle_P1 = Config.MiddleAxis_P1_Position;
                p.MiddleAxis_Safe_Position = Config.MiddleAxis_Safe_Position;
                if (param.PosInfo.ShelfType.Equals(1))
                {
                    p.InOut_P2 = Config.InOutAxis_P2_Position;
                }
                else
                {
                    p.InOut_P2 = Config.InOutAxis_P3_Position;
                }
                p.UpDown_P1 = Config.UpDownAxis_DoorO_P1;
                p.UpDown_P8 = Config.UpDownAxis_DoorIB_P8;
                p.UpDown_P2 = Config.UpDownAxis_DoorI_P2;
                p.UpDown_P7 = Config.UpDownAxis_DoorOB_P7;

                //p.ComPress_P2 = position.CompressAxis_P2;
                //p.ComPress_P3 = position.CompressAxis_C_P3;
                p.InOut_P4 = position.InOutAxis_P4;
                p.Middle_P2 = position.MiddleAxis_P2;
                p.UpDown_P3 = position.UpDownAxis_IH_P3;
                p.UpDown_P4 = position.UpDownAxis_IL_P4;
                p.UpDown_P5 = position.UpDownAxis_OH_P5;
                p.UpDown_P6 = position.UpDownAxis_OL_P6;
                param.MoveP = p;

                if (String.IsNullOrEmpty(param.PosInfo.PlateH))
                {
                    param.PosInfo.PlateH = position.BagHigh.ToString();
                }
                if (string.IsNullOrEmpty(param.PosInfo.PlateW))
                {
                    param.PosInfo.PlateW = position.BagWidth.ToString();
                }
                return true;
            }
            else if (String.IsNullOrEmpty(param.PosInfo.PlateH) || string.IsNullOrEmpty(param.PosInfo.PlateW))
            {
                ACSquareSPosition position = param.GetACPosition();
                if (position == null)
                {
                    LogUtil.error(LOGGER, StoreName + "出入库时发现param中取到的Position=null,没有库位不能执行出入库");
                    return false;
                }
                if (String.IsNullOrEmpty(param.PosInfo.PlateH))
                {
                    param.PosInfo.PlateH = position.BagHigh.ToString();
                }
                if (string.IsNullOrEmpty(param.PosInfo.PlateW))
                {
                    param.PosInfo.PlateW = position.BagWidth.ToString();
                }
                return true;
            }
            return true;
        }

        #endregion

        #region 出入库结果验证
        private void InOutBackToP1(int InOut_P1)
        {
            //判断是否在P1,如果是,不需要运行 
            int outCount = ACServerManager.GetActualtPosition(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
            int errorCount = Math.Abs(outCount - InOut_P1);
            if (errorCount <= Config.InOut_Axis.CanErrorCountMin)
            {
                LogUtil.info("进出轴当前位置:" + outCount + ",已经在P1,不需要再回P1");
            }
            else
            {
                ACAxisMove(Config.InOut_Axis, InOut_P1, Config.InOutAxis_P1_Speed);
            }
            //StoreMove.WaitList.Add(WaitResultInfo.WaitAxisOrg(Config.InOut_Axis,IO_VALUE.HIGH));
        }
        private DateTime preRWTime = DateTime.Now;
        private void CheckWait()
        {
            List<WaitResultInfo> list = StoreMove.WaitList;
            //当等待超过一分钟时,需要打印提示 
            TimeSpan span = DateTime.Now - StoreMove.LastSetpTime;
            string NotOkMsg = "";
            if (list.Count <= 0)
            {
                StoreMove.EndStepWait();
                return;
            }
            bool isOk = true;
            if (StoreMove.OneWaitCanEndStep)
            {
                isOk = false;
            }
            foreach (WaitResultInfo wait in list)
            {
                if (wait.IsEnd)
                {
                    continue;
                }
                NotOkMsg = wait.ToStr();
                if (wait.WaitType == 1)
                {
                    string msg = "";
                    if (wait.IsHomeMove)
                    {
                        wait.IsEnd = ACHomeMoveIsEnd(wait.AxisInfo, out msg);
                    }
                    else
                    {
                        wait.IsEnd = ACAxisMoveIsEnd(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
                    }
                    if (!msg.Equals(""))
                    {
                        isOk = false;
                        WarnMsg = msg;
                        Alarm(StoreAlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, StoreMove.MoveType);
                        break;
                    }
                }
                else if (wait.WaitType == 2)
                {
                    wait.IsEnd = IOManager.IOValue(wait.IoType).Equals(wait.IoValue);
                    int timeOutMs = Config.IOSingle_TimerOut;
                    //if (StoreMove.MoveStep.Equals(StoreMoveStep.SO_15_WaitTake))
                    //{
                    //    timeOutMs = 650000;
                    //}
                    if ((!wait.IsEnd) && span.TotalMilliseconds > timeOutMs)
                    {
                        ConfigIO io = Config.getWaitIO(wait.IoType);
                        WarnMsg = StoreName + " 等待信号" + io.DisplayStr + "=" + wait.IoValue + "超时!";
                        Alarm(StoreAlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, StoreMove.MoveType);
                        LogUtil.error(LOGGER, StoreName + wait.IoType + "等待信号(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", 14);
                        isOk = false;
                        break;
                    }

                    TimeSpan rwSpan = DateTime.Now - preRWTime;
                    if (!wait.IsEnd && rwSpan.TotalSeconds > 5 && span.TotalSeconds > 6)
                    {
                        preRWTime = DateTime.Now;
                        string msg = StoreName + "  " + NotOkMsg + "已等待 " + Math.Abs(span.TotalSeconds) + "秒,重写DO:";
                        bool isLog = false;
                        foreach (WaitResultInfo ww in list)
                        {
                            if (ww != null && ww.WaitType.Equals(2) && Config.StoreDOList.ContainsKey(ww.IoType))
                            {
                                isLog = true;
                                IOManager.IOMove(ww.IoType, ww.IoValue);
                                msg += ww.ToStr() + ",";
                            }
                        }
                        if (isLog)
                        {
                            LogUtil.error(msg);
                        }
                        isOk = false;
                        break;
                    }
                }
                else if (wait.WaitType == 3)
                {
                    wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
                }

                if (wait.IsEnd)
                {
                    if (StoreMove.OneWaitCanEndStep)
                    {
                        isOk = true;
                        break;
                    }
                }
                else
                {
                    if (!StoreMove.OneWaitCanEndStep)
                    {
                        isOk = false;
                        break;
                    }
                }
            }
            if (isOk)
            {
                StoreMove.EndStepWait();
            }
            else if (span.TotalSeconds > StoreMove.TimeOutSeconds)
            {
                WarnMsg = StoreName + "【" + StoreMove.MoveType + "】【" + StoreMove.MoveStep + "】等待超时  [" + NotOkMsg
                    + "]已等待[" + Math.Round(span.TotalSeconds, 1) + "]秒";
                LogUtil.error(LOGGER, WarnMsg, 100);
                Alarm(StoreAlarmType.IoSingleTimeOut, "", WarnMsg, StoreMove.MoveType);
            }
        }
        private static DateTime lastComRHomeTime = DateTime.Now;


        #endregion

        #region 入库

        private DateTime startInStoreTime = DateTime.Now;
        /// <summary>
        /// 开始入库移动移动
        /// </summary> 
        public override void StartInStoreMove(InOutParam param)
        {
            startInStoreTime = DateTime.Now;
            string posId = param != null ? param.PosInfo.PosId : "";
            posId = param.PosInfo.ToStr();
            if (storeRunStatus == StoreRunStatus.Runing)
            {
                if (!LoadParamPosition(param))
                {
                    LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错,找不到库位信息");
                    return;
                }
                if (param.PosInfo.ShelfType <= 0)
                {
                    LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错,未设置入口位置");
                    return;
                }
                if (IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
                {
                    LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错,货叉物料检测有料");
                    return;
                }
                string doorMsg = DoorIsClose();
                if (!String.IsNullOrEmpty(doorMsg))
                {
                    LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错, " + doorMsg);
                    return;
                }

                LogUtil.info(LOGGER, StoreName + " 启动入库【" + posId + "】", storeMoveColor);
                storeRunStatus = StoreRunStatus.Busy;
                storeStatus = StoreStatus.InStoreExecute;
                StoreMove.NewMove(StoreMoveType.InStore, param);
                //料盘检测
                StoreMove.NextMoveStep(StoreMoveStep.SI_00_TrayCheck);
                //if (StoreManager.UseShelfCheck)
                //{ 
                //    if (param.PosInfo.ShelfType.Equals(1))
                //    {
                //        StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftShelf_Check, IO_VALUE.HIGH));
                //    }
                //    else
                //    {
                //        StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.RightShelf_Check, IO_VALUE.HIGH));
                //    }
                //}
                //else
                //{
                //    SI_02_Move();
                //}
            }
            else
            {
                LogUtil.error(LOGGER, StoreName + " 启动【" + posId + "】入库出错,当前状态,storeStatus=" + storeRunStatus);
            }
        }
        private void SI_02_Move()
        {
            StoreMove.NextMoveStep(StoreMoveStep.SI_02_InOutToP1);
            InStoreLog("入库:进出轴(叉子)动作至P1,关闭门锁=" + StoreMove.MoveParam.PosInfo.ShelfType);
            CloseDoor(StoreMove.MoveParam.PosInfo.ShelfType);
            InOutBackToP1(StoreMove.MoveParam.MoveP.InOut_P1);
        }
        /// <summary>
        /// 打印轴状态
        /// </summary>
        /// <param name="moveInfo"></param>
        private void PrintAxisSts(StoreMoveInfo moveInfo)
        {
            List<WaitResultInfo> list = moveInfo.WaitList;
            int cutWLcount = list.Count;
            if (list.Count <= 0)
            {
                return;
            }
            foreach (WaitResultInfo wait in list)
            {
                if (wait.IsEnd)
                {
                    continue;
                }
                if (wait.WaitType.Equals(1))
                {

                    string msg = "";
                    {
                        KTK_Store.ACAxisStsInMove(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
                    }
                }
            }
        }
        protected override void InStoreProcess()
        {
            LineMoveP moveP = StoreMove.MoveParam.MoveP;
            if (StoreMove.IsInWait)
            {
                PrintAxisSts(StoreMove);
                CheckWait();
            }
            if (StoreMove.IsInWait)
            {
                return;
            }
            if (StoreMove.MoveStep == StoreMoveStep.SI_00_TrayCheck)
            {
                SI_02_Move();
            }

            else if (StoreMove.MoveStep == StoreMoveStep.SI_02_InOutToP1)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_03_ToP1);
                InStoreLog("入库:升降轴到P1[" + moveP.UpDown_P1 + "],前进轴到P1[" + moveP.Middle_P1 + "] ,托架后退,检测料盘信号");

                ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
                ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
                ShelfBack(StoreMove.MoveParam.PosInfo.ShelfType, StoreMove);
                if (StoreManager.UseShelfCheck)
                {
                    if (StoreMove.MoveParam.PosInfo.ShelfType.Equals(1))
                    {
                        StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftShelf_Check, IO_VALUE.HIGH));
                    }
                    else
                    {
                        StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.RightShelf_Check, IO_VALUE.HIGH));
                    }
                }
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SI_03_ToP1)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_05_InoutToP2);
                InStoreLog("入库:叉子进入入料口,进出轴至P2(进料口取料点) [" + moveP.InOut_P2 + "] ");
                ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SI_05_InoutToP2)
            {
                //NeedCheckSafetyLight = 0;
                StoreMove.NextMoveStep(StoreMoveStep.SI_06_UpdownAxisUp);
                InStoreLog("入库: 拿物品,  升降轴至P7(进料口取料缓冲点) [" + moveP.UpDown_P7 + "]");
                ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P7, Config.UpDownAxis_P7_Speed);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SI_06_UpdownAxisUp)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_07_InOutToP1);
                InStoreLog("入库: 叉子 从入料口抽出,进出轴至P1(待机点) [" + moveP.InOut_P1 + "]");
                InOutBackToP1(moveP.InOut_P1);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SI_07_InOutToP1)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_08_ToSafePosition);
                InStoreLog("入库: 判断是否拿到物料");
                if (StoreManager.UseShelfCheck)
                {
                    if (StoreMove.MoveParam.PosInfo.ShelfType.Equals(1))
                    {
                        StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftShelf_Check, IO_VALUE.LOW));
                    }
                    else
                    {
                        StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.RightShelf_Check, IO_VALUE.LOW));
                    }
                    StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.HIGH));
                }
            }
            //判断是否拿到料
            else if (StoreMove.MoveStep == StoreMoveStep.SI_08_ToSafePosition)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_09_MiddleToP3);
                InStoreLog("入库: 移动到安全点,前后轴至安全点, [" + moveP.MiddleAxis_Safe_Position + "]");
                ACAxisMove(Config.Middle_Axis, moveP.MiddleAxis_Safe_Position, Config.MiddleAxis_P1_Speed);
            }

            else if (StoreMove.MoveStep == StoreMoveStep.SI_09_MiddleToP3)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_10_UpdownToBag);
                InStoreLog("入库: 移动到库位点,前后轴至P2(库位点), [" + moveP.Middle_P2 + "],升降轴至P3(库位入库前点)[" + moveP.UpDown_P3 + "] ");
                ACAxisMove(Config.Middle_Axis, moveP.Middle_P2, Config.MiddleAxis_P2_Speed);
                ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
            }
            //else if (StoreMove.MoveStep == StoreMoveStep.SI_09_MiddleToP3)
            //{
            //    StoreMove.NextMoveStep(StoreMoveStep.SI_10_UpdownToBag);
            //    InStoreLog("入库: 移动到库位点,升降轴至P3(库位入库前点) [" + moveP.UpDown_P3 + "] ");
            //    //ACAxisMove(Config.Middle_Axis, moveP.Middle_P2, Config.MiddleAxis_P2_Speed);
            //    ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
            //}
            else if (StoreMove.MoveStep == StoreMoveStep.SI_10_UpdownToBag)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_11_InoutToP4);
                InStoreLog("入库:叉子进入库位中,进出轴至P4(库位取放料点) [" + moveP.InOut_P4 + "] ");
                ACAxisMove(Config.InOut_Axis, moveP.InOut_P4, Config.InOutAxis_P4_Speed);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SI_11_InoutToP4)
            {
                // 5= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态)   
                string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PosInfo.PosId : "";
                lastPosId = posId;
                lastDoor = StoreMove.MoveParam.PosInfo.ShelfType;
                lastPosIdStatus = StoreStatus.InStoreEnd;
                storeStatus = StoreStatus.InStoreEnd;
                //手动发给服务器状态,防止没有手动
                //SendLineStatus(StoreID, posId, StoreStatus.InStoreEnd);

                StoreMove.NextMoveStep(StoreMoveStep.SI_12_PutWare);
                InStoreLog("入库:放下物品,升降轴至P4(库位入料缓冲点) [" + moveP.UpDown_P4 + "], 更新状态=InStoreEnd, " + lastDoor);
                ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P4, Config.UpDownAxis_P4_Speed);

            }
            else if (StoreMove.MoveStep == StoreMoveStep.SI_12_PutWare)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_13_InoutToP1);
                InStoreLog("入库:叉子从库位中返回,进出轴动作至P1(待机点) [" + moveP.InOut_P1 + "] ");
                InOutBackToP1(moveP.InOut_P1);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SI_13_InoutToP1)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_14_CheckTrayIsGo);
                InStoreLog("入库:检查叉子物料检测信号=low");
                if (StoreManager.UseShelfCheck)
                {
                    StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
                }
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SI_14_CheckTrayIsGo)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_15_UpdownBack);
                InStoreLog("入库:升降轴 返回待机点P1[" + moveP.UpDown_P1 + "] ,前后轴返回安全位置["+moveP.MiddleAxis_Safe_Position+"]托架前进");
                //  ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
                ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
                ACAxisMove(Config.Middle_Axis, moveP.MiddleAxis_Safe_Position, Config.MiddleAxis_P1_Speed);
                ShelfForward(StoreMove.MoveParam.PosInfo.ShelfType);
            }

            else if (StoreMove.MoveStep == StoreMoveStep.SI_15_UpdownBack)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SI_16_GoBack);
                InStoreLog("入库: 前后轴 返回待机点P1 [" + moveP.Middle_P1 + "],打开门锁 ");
                ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SI_16_GoBack)
            {
                TimeSpan span = DateTime.Now - startInStoreTime;
                string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PosInfo.PosId : "";
                LogUtil.info(LOGGER, StoreName + "  【" + posId + "】 整个入库流程结束,耗时【" + FormUtil.GetSpanStr(span) + "】!", storeMoveColor);
                StoreMove.EndMove();
                storeRunStatus = StoreRunStatus.Runing;
                //设备连接,入库后,BOX恢复原始状态 
                storeStatus = StoreStatus.StoreOnline;
                InOutEndProcess(StoreMoveType.InStore, posId);
            }
            else
            {
                LogUtil.info(LOGGER, StoreName + " 入库,moveStatus=" + StoreMove.MoveStep + ",没有对应的处理!");
            }
        }
        #endregion


        #region 出库
        private DateTime startOutStoreTime = DateTime.Now;
        /// <summary>
        /// 开始出库运动
        /// </summary> 
        public override bool StartOutStoreMove(InOutParam param)
        {
            startOutStoreTime = DateTime.Now;
            string posId = param != null ? param.PosInfo.PosId : "";
            posId = param.PosInfo.ToStr();
            if (storeRunStatus == StoreRunStatus.Runing)
            {
                if (!LoadParamPosition(param))
                {
                    LogUtil.error(LOGGER, StoreName + " 启动出库【" + posId + "】出错,找不到库位信息");
                    return false;
                }
                if (IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
                {
                    LogUtil.error(LOGGER, StoreName + " 启动出库【" + posId + "】出错,货叉物料检测有料");
                    return false;
                }
                string doorMsg = DoorIsClose();
                if (!String.IsNullOrEmpty(doorMsg))
                {
                    LogUtil.error(LOGGER, StoreName + " 启动出库【" + posId + "】出错, " + doorMsg);
                    return false;
                }

                //判断对应托架是否有料盒
                int shelfType = param.PosInfo.ShelfType;

                if (shelfType.Equals(1) && IOManager.IOValue(IO_Type.LeftShelf_Check).Equals(IO_VALUE.HIGH))
                {
                    LogUtil.error(LOGGER, StoreName + " 启动出库【" + posId + "】【" + shelfType + "】出错,LeftShelf_Check 信号亮 ");
                    return false;
                }
                else if (shelfType.Equals(2) && IOManager.IOValue(IO_Type.RightShelf_Check).Equals(IO_VALUE.HIGH))
                {
                    LogUtil.error(LOGGER, StoreName + " 启动出库【" + posId + "】【" + shelfType + "】出错,RightShelf_Check 信号亮 ");
                    return false;

                }
                else if (shelfType.Equals(0))
                {
                    //如果两侧都有料 
                    if (IOManager.IOValue(IO_Type.LeftShelf_Check).Equals(IO_VALUE.HIGH) && IOManager.IOValue(IO_Type.RightShelf_Check).Equals(IO_VALUE.HIGH))
                    {
                        LogUtil.error(LOGGER, StoreName + " 启动出库【" + posId + "】【" + shelfType + "】出错,LeftShelf_Check信号亮, RightShelf_Check 信号亮 ");
                        return false;
                    }
                }

                storeStatus = StoreStatus.OutStoreExecute;
                LogUtil.info(LOGGER, StoreName + "启动出库【" + posId + "】【"+ shelfType + "】  ", storeMoveColor);
                storeRunStatus = StoreRunStatus.Busy;
                StoreMove.NewMove(StoreMoveType.OutStore, param);

                StoreMove.NextMoveStep(StoreMoveStep.SO_01_InoutToP1);
                OutStoreLog("出库: 叉子先运动到P1 ,  开始");
                InOutBackToP1(StoreMove.MoveParam.MoveP.InOut_P1);
                return true;
            }
            else
            {
                LogUtil.error(LOGGER, StoreName + " 启动出库出错,当前状态,storeStatus=" + storeRunStatus);
            }
            return false;
        }
        protected override void OutStoreProcess()
        {
            LineMoveP moveP = StoreMove.MoveParam.MoveP;
            if (StoreMove.IsInWait)
            {
                PrintAxisSts(StoreMove);
                CheckWait();
            }
            if (StoreMove.IsInWait)
            {
                return;
            }
            if (StoreMove.MoveStep == StoreMoveStep.SO_01_InoutToP1)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SO_02_MiddleToP2);
                OutStoreLog("出库: 走到安全位置, 前后轴至安全位置 [" + moveP.MiddleAxis_Safe_Position + "]");
                ACAxisMove(Config.Middle_Axis, moveP.MiddleAxis_Safe_Position, Config.MiddleAxis_P1_Speed);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_02_MiddleToP2)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SO_03_UpdownToP5);
                OutStoreLog("出库: 走到库位, 升降轴至P5(库位出库前点)  [" + moveP.UpDown_P5 + "]前后轴至P2(库位点) [" + moveP.Middle_P2 + "]");
                ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P5, Config.UpDownAxis_P5_Speed);
                ACAxisMove(Config.Middle_Axis, moveP.Middle_P2, Config.MiddleAxis_P2_Speed);
                //   ShelfBack(StoreMove.MoveParam.PosInfo.ShelfType);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_03_UpdownToP5)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SO_04_InoutToP3);
                OutStoreLog("出库: 叉子进入库位中,  进出轴至P3(库位取放料点) [" + moveP.InOut_P4 + "]");
                ACAxisMove(Config.InOut_Axis, moveP.InOut_P4, Config.InOutAxis_P3_Speed);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_04_InoutToP3)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SO_05_GetWare);
                OutStoreLog("出库: 拿起物品,升降轴至P6(库位出料缓冲点)  [" + moveP.UpDown_P6 + "]");
                ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_05_GetWare)
            {
                if (StoreMove.MoveParam.PosInfo.ShelfType <= 0)
                {
                    if (IOManager.IOValue(IO_Type.LeftShelf_Check).Equals(IO_VALUE.LOW))
                    {
                        StoreMove.MoveParam.UpdateShelfType(1, Config);
                        OutStoreLog(" 出库: 当前未设置ShelfType,默认ShelfType=" + StoreMove.MoveParam.PosInfo.ShelfType);
                    }
                    else
                    {
                        StoreMove.MoveParam.UpdateShelfType(2, Config);
                        OutStoreLog("出库:  当前未设置ShelfType,默认ShelfType=" + StoreMove.MoveParam.PosInfo.ShelfType);
                    }
                }
                //把库位的物品放到取到叉子上之后是出仓完成 
                string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PosInfo.PosId : "";
                lastPosId = posId;
                lastDoor = StoreMove.MoveParam.PosInfo.ShelfType;
                lastPosIdStatus = StoreStatus.OutStoreBoxEnd;
                storeStatus = StoreStatus.OutStoreBoxEnd;

                StoreMove.NextMoveStep(StoreMoveStep.SO_06_InoutToP1);
                OutStoreLog("出库: 叉子从库位返回,进出轴至P1(待机点)[" + moveP.InOut_P1 + "],更新状态=OutStoreBoxEnd, " + lastDoor);
                InOutBackToP1(moveP.InOut_P1);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_06_InoutToP1)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SO_07_CheckHasTray);
                OutStoreLog("出库: 判断是否拿到料");
                if (StoreManager.UseShelfCheck)
                {
                    StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.HIGH));
                }
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_07_CheckHasTray)
            {
                if (IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.LOW))
                {
                    string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PosInfo.PosId : "";
                    CodeMsg = "出库[" + posId + "]叉子从库位退出后,未检测到料盘有料";
                    LogUtil.error(CodeMsg);
                }

                StoreMove.NextMoveStep(StoreMoveStep.SO_08_UpdownBack);
                OutStoreLog("出库:升降轴至P2(进料口出料前点), [" + moveP.UpDown_P2 + "] ,前后轴至安全点,[" + moveP.MiddleAxis_Safe_Position + "] ");
                ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P2, Config.UpDownAxis_P2_Speed);
                ACAxisMove(Config.Middle_Axis, moveP.MiddleAxis_Safe_Position, Config.MiddleAxis_P1_Speed);
            }

            else if (StoreMove.MoveStep == StoreMoveStep.SO_08_UpdownBack)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SO_09_ToDoorPosition);
                OutStoreLog("出库:前后轴至P1(待机点) [" + moveP.Middle_P1 + "] "); 
                ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed); 
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_09_ToDoorPosition)
            {
                WaitNoTray(StoreMoveStep.SO_10_WaitNoTray);
                //SO_10_DeviceToDoorPro(); 
                //StoreMove.NextMoveStep(StoreMoveStep.SO_10_WaitNoTray);
                //int shelfType = StoreMove.MoveParam.PosInfo.ShelfType;
                //OutStoreLog("出库:等待托架无料 [" + shelfType + "] ");
                //if (shelfType.Equals(1))
                //{
                //    StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftShelf_Check, IO_VALUE.LOW));
                //    StoreMove.WaitList.Add(WaitResultInfo.WaitTime(300));
                //}
                //else if (shelfType.Equals(2))
                //{
                //    StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.RightShelf_Check, IO_VALUE.LOW));
                //    StoreMove.WaitList.Add(WaitResultInfo.WaitTime(300));
                //}
                //if (StoreMove.MoveParam.PosInfo.ShelfType.Equals(0))
                //{
                //    StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftShelf_Check, IO_VALUE.LOW));
                //    StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.RightShelf_Check, IO_VALUE.LOW));
                //    StoreMove.OneWaitCanEndStep = true;
                //}
            }

            else if (StoreMove.MoveStep == StoreMoveStep.SO_10_WaitNoTray)
            {

                if (!CheckLeft(StoreMoveStep.SO_10_WaitNoTray))
                {
                    return;
                }

                if (StoreMove.MoveParam.PosInfo.ShelfType > 0)
                {
                    StoreMove.NextMoveStep(StoreMoveStep.SO_11_ShelfBack);
                    OutStoreLog("出库:  托架后退 [" + StoreMove.MoveParam.PosInfo.ShelfType + "] ");
                    ShelfBack(StoreMove.MoveParam.PosInfo.ShelfType, StoreMove);
                }
            }

            else if (StoreMove.MoveStep == StoreMoveStep.SO_11_ShelfBack)
            {
                WaitNoTray(StoreMoveStep.SO_12_WaitNoTray);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_12_WaitNoTray)
            {

                if (!CheckLeft(StoreMoveStep.SO_12_WaitNoTray))
                {
                    return;
                }
                if (StoreMove.MoveParam.PosInfo.ShelfType > 0)
                {
                    StoreMove.NextMoveStep(StoreMoveStep.SO_12_InoutToP2);
                    OutStoreLog("出库: 叉子进出料口,进出轴至P2(进料口取料点) [" + moveP.InOut_P2 + "] ");
                    ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
                }
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_12_InoutToP2)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SO_13_PutWare);
                OutStoreLog("出库: 放下物品,升降轴至P8(进料口出料缓冲点) [" + moveP.UpDown_P8 + "]");
                ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P8, Config.UpDownAxis_P8_Speed);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_13_PutWare)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SO_14_InoutToP1);
                OutStoreLog("出库: 叉子从出料口返回,,进出轴动作至P1(待机点) [" + moveP.InOut_P1 + "] ");
                InOutBackToP1(moveP.InOut_P1);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_14_InoutToP1)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SO_15_CheckShelfDI);
                OutStoreLog("出库: 判断物料信号是否正确 ");
                if (StoreManager.UseShelfCheck)
                {
                    if (StoreMove.MoveParam.PosInfo.ShelfType.Equals(1))
                    {
                        StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftShelf_Check, IO_VALUE.HIGH));
                    }
                    else
                    {
                        StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.RightShelf_Check, IO_VALUE.HIGH));
                    }
                    StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
                }
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_15_CheckShelfDI)
            {
                StoreMove.NextMoveStep(StoreMoveStep.SO_16_GoBack);
                OutStoreLog("出库: 升降轴到P1(待机点) [" + moveP.UpDown_P1 + "] ,托架前进,打开门锁");
                ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
                OpenDoor(StoreMove.MoveParam.PosInfo.ShelfType);
                ShelfForward(StoreMove.MoveParam.PosInfo.ShelfType, StoreMove);
            }
            else if (StoreMove.MoveStep == StoreMoveStep.SO_16_GoBack)
            {
                TimeSpan span = DateTime.Now - startOutStoreTime;
                string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PosInfo.PosId : "";

                storeStatus = StoreStatus.StoreOnline;
                LogUtil.info(LOGGER, StoreName + " 【" + posId + "】 整个出库流程结束,耗时【" + FormUtil.GetSpanStr(span) + "】!", storeMoveColor);
                StoreMove.EndMove();
                storeRunStatus = StoreRunStatus.Runing;
                InOutEndProcess(StoreMoveType.OutStore, posId);
            }
            else
            {
                LogUtil.error(LOGGER, StoreName + " 出库处理,moveStatus=" + StoreMove.MoveStep + ",没有对应的处理!");
            }

        }

        private bool CheckLeft(StoreMoveStep sO_10_WaitNoTray)
        {
            if (StoreMove.MoveParam.PosInfo.ShelfType.Equals(0))
            {
                if (IOManager.IOValue(IO_Type.LeftShelf_Check).Equals(IO_VALUE.LOW))
                {
                    //StoreMove.MoveParam.PosInfo.ShelfType = 1;
                    StoreMove.MoveParam.UpdateShelfType(1, Config);
                    OutStoreLog(" 出库: 当前未设置ShelfType,默认ShelfType=" + StoreMove.MoveParam.PosInfo.ShelfType);
                }
                else if (IOManager.IOValue(IO_Type.RightShelf_Check).Equals(IO_VALUE.LOW))
                {
                    //StoreMove.MoveParam.PosInfo.ShelfType = 2; 
                    StoreMove.MoveParam.UpdateShelfType(2, Config);
                    OutStoreLog("出库:  当前未设置ShelfType,默认ShelfType=" + StoreMove.MoveParam.PosInfo.ShelfType);
                }
                else
                {
                    StoreMove.NextMoveStep(StoreMoveStep.SO_10_WaitNoTray);
                    int shelfType = StoreMove.MoveParam.PosInfo.ShelfType;
                    OutStoreLog("出库:  再次 等待托架无料 [" + shelfType + "] ");
                    StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftShelf_Check, IO_VALUE.LOW));
                    StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.RightShelf_Check, IO_VALUE.LOW));
                    StoreMove.OneWaitCanEndStep = true;
                    return false;
                }
            }
            return true;
        }

        #endregion
        public List<InOutPosInfo> waitOutStoreList = new List<InOutPosInfo>();
        public object waitOutListLock = "";

        private void WaitNoTray(StoreMoveStep step)
        {
            StoreMove.NextMoveStep(step);
            int shelfType = StoreMove.MoveParam.PosInfo.ShelfType;
            OutStoreLog("出库:等待托架无料 [" + shelfType + "] ");
            if (shelfType.Equals(1))
            {
                StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftShelf_Check, IO_VALUE.LOW));
                StoreMove.WaitList.Add(WaitResultInfo.WaitTime(300));
            }
            else if (shelfType.Equals(2))
            {
                StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.RightShelf_Check, IO_VALUE.LOW));
                StoreMove.WaitList.Add(WaitResultInfo.WaitTime(300));
            }
            if (StoreMove.MoveParam.PosInfo.ShelfType.Equals(0))
            {
                StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftShelf_Check, IO_VALUE.LOW));
                StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.RightShelf_Check, IO_VALUE.LOW));
                StoreMove.OneWaitCanEndStep = true;
            }
        }
        public void AddWaitOutInfo(InOutPosInfo code)
        {
            lock (waitOutListLock)
            {
                waitOutStoreList.Add(code);
            }
        }
        private string autoInoutCode = "AUTOINOUT";
        private void InOutEndProcess(StoreMoveType storeMoveType,string posId)
        {
            try
            {
                CurrInOutCount++;
                CurrInOutACount++;
                //是否自动进入出库状态
                if (!autoNext)
                {
                    return;
                }
                if (storeMoveType.Equals(StoreMoveType.InStore))
                {
                    int newIndex = autoPositionIndex;
                    if (newIndex >= PositionNumList.Count)
                    {
                        if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
                        {
                            newIndex = AutoStartIndex;
                            LogUtil.info(LOGGER, StoreName + "下一个索引不存在,重新开始自动出入库,索引【" + AutoStartIndex + "】");
                        }
                        else
                        {
                            autoNext = false;
                            autoMsg = "自动出入库结束!";
                            LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!");
                        }
                    }
                    else
                    {
                        InOutEnd(posId, storeMoveType, false);
                        autoPositionIndex = newIndex;
                        string posid = PositionNumList[autoPositionIndex];
                        InOutPosInfo inoutinfo = new InOutPosInfo(autoInoutCode, posid);
                        inoutinfo.ShelfType = autoShelfType;
                        //判断是否需要重置
                        if (CurrInOutACount >= Config.Box_ResetACount)
                        {
                            LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把出库信息存入排队列表中");
                            Reset(false);
                            autoMsg = "自动出库:" + posid;
                            AddWaitOutInfo(inoutinfo);
                        }
                        else if (CurrInOutCount >= Config.Box_ResetMCount)
                        {
                            LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutCount + "次,需要重置BOX前后轴,先把出库信息存入排队列表中");
                            //ResetMiddleAxis(false);
                            autoMsg = "自动出库:" + posid;
                            AddWaitOutInfo(inoutinfo);
                        }
                        else
                        {
                            LogUtil.info(LOGGER, StoreName + "自动出库:posid=" + posid);
                            autoMsg = "自动出库:" + posid;
                            StartOutStoreMove(new InOutParam(inoutinfo));
                        }
                    }
                }
                else if (storeMoveType.Equals(StoreMoveType.OutStore))
                {
                    int newIndex = autoPositionIndex + autoJiange;
                    if (newIndex >= PositionNumList.Count)
                    {
                        if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
                        {
                            newIndex = AutoStartIndex;
                            InOutEnd(posId, storeMoveType, true);
                            LogUtil.info(LOGGER, StoreName + "下一个索引不存在,重新开始自动出入库,索引【" + AutoStartIndex + "】");
                        }
                        else
                        {
                            autoNext = false;
                            autoMsg = "自动出入库结束!";
                            LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!");
                        }
                    }
                    else
                    {
                        InOutEnd(posId, storeMoveType, false);
                        autoPositionIndex = newIndex;
                        string posid = PositionNumList[newIndex];
                        InOutPosInfo inoutinfo = new InOutPosInfo(autoInoutCode, posid);
                        inoutinfo.ShelfType = autoShelfType;
                        //判断是否需要重置
                        //if (CurrInOutACount >= Config.Box_ResetACount)
                        //{
                        //    LogUtil.info(LOGGER, StoreName + "自动进入下一个入库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把入库信息存入排队列表中");
                        //    Reset(false);
                        //    autoMsg = "自动入库:" + posid;
                        //    AddWaitOutInfo(inoutinfo);
                        //}
                        //else if (CurrInOutCount >= Config.Box_ResetMCount)
                        //{
                        //    LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutCount + "次,需要重置BOX前后轴,先把出库信息存入排队列表中");
                        //    //ResetMiddleAxis(false);
                        //    autoMsg = "自动入库:" + posid;
                        //    AddWaitOutInfo(inoutinfo);
                        //}
                        //else
                        {
                            LogUtil.info(LOGGER, StoreName + "自动进入下一个入库:posid=" + posid);
                            autoMsg = "自动入库:" + posid;
                            StartInStoreMove(new InOutParam(inoutinfo));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtil.error(LOGGER, ex.ToString());
            }
        }
        #region 库位调试
        public delegate void InOutEndEventHandler(string posId, StoreMoveType movetype,bool isLast);
        public event InOutEndEventHandler InOutEndEvent;
       public PosDebug posDebug;
        private void InOutEnd(string posId, StoreMoveType movetype, bool isLast)
        {
            posDebug.AddResult(posId, movetype, isLast);
            InOutEndEvent?.Invoke(posId, movetype, isLast);
        }
        #endregion
        private void InStoreLog(string msg)
        {
            string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PosInfo.PosId : "";
            LogUtil.info(LOGGER, "【" + posId + "】[" + StoreMove.MoveStep + "] " + msg, storeMoveColor);
        }
        private void OutStoreLog(string msg)
        {
            string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PosInfo.PosId : "";
            LogUtil.info(LOGGER, "【" + posId + "】[" + StoreMove.MoveStep + "] " + msg, storeMoveColor);
        }
        private bool OpenDoor(int doorType)
        {
            return OpenCloseDoor(doorType, IO_VALUE.LOW);
        }
        private bool CloseDoor(int doorType)
        {
            return OpenCloseDoor(doorType, IO_VALUE.HIGH);
        }
        private bool OpenCloseDoor(int doorType, IO_VALUE value)
        {
            if (doorType.Equals(1))
            {
                //if (IOManager.IOValue(IO_Type.LeftDoor_Close).Equals(IO_VALUE.HIGH))
                //{
                IOManager.IOMove(IO_Type.LeftDoor_Close, value);
                return true;
                //}
                //else
                //{
                //    LogUtil.info("OpenCloseDoor [" + doorType + "] [" + value + "] 失败");
                //    return false;
                //}
            }
            else
            {
                //if (IOManager.IOValue(IO_Type.RightDoor_Close).Equals(IO_VALUE.HIGH))
                //{
                IOManager.IOMove(IO_Type.RightDoor_Close, value);
                return true;
                //}
                //else
                //{
                //    LogUtil.info("OpenCloseDoor [" + doorType + "] [" + value + "] 失败");
                //    return false;
                //}
            }
        }

        private string GetDoorStatus(int doorType)
        {
            ////3  仓门状态上传: 字段为door1和doo2, 状态: opened为已打开, closed为已关闭, opening为打开中, closing为关闭中
            if (doorType.Equals(1))
            {
                if (IOManager.IOValue(IO_Type.LeftDoor_Close).Equals(IO_VALUE.HIGH))
                {
                    return "opened";
                }
                else
                {
                    return "closed";
                }
            }
            else
            {
                if (IOManager.IOValue(IO_Type.RightDoor_Close).Equals(IO_VALUE.HIGH))
                {
                    return "opened";
                }
                else
                {
                    return "closed";
                }
            }
        }
    }
}