FeedingEquip_OutStore.cs 26.9 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
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OnlineStore.DeviceLibrary
{
    partial class FeedingEquip
    {
        #region 出料流程
        private int OutStoreHeight = -1;
        private int OutStoreCount = -1;
        private ShelfData serverShelfData = null;
        internal bool CanStartCheckOut(int trayNum)
        {
            preTrayNum = currTrayNum;
            currTrayNum = trayNum;
            if (CurrTrayIsNeed(currTrayNum, true))
            {
                SecondMoveInfo.NewMove(LineMoveType.CheckFixture, CheckParam);
                SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_06_TopUp);
                CheckLog("检测到SW_TrayCheck:" + SecondMoveInfo.SLog + "横移顶升气缸上升 )");
                CylinderMove(SecondMoveInfo, IO_Type.SW_TopCylinder_Down, IO_Type.SW_TopCylinder_Up);
                return true;
            }
            else
            {
                // currTrayNum = num; 
                return false;
            }
        }

        private bool StartTrayOut(InOutParam outParam)
        {
            if (outParam == null || outParam.PosId == null || outParam.PosId.Equals(""))
            {
                LogUtil.error(Name + "出库失败,参数不完整:");
                LogUtil.error(outParam.ToStr());
                return false;
            }
            if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.LOW) || OutStoreHeight < 0)
            {
                LogUtil.error(Name + "出库" + outParam.ToStr() + "失败,未准备好料架");
                return false;
            }
            runStatus = LineRunStatus.Busy;
            lineStatus = LineStatus.OutStoreExecute;
            MoveInfo.NewMove(LineMoveType.OutStore, outParam);
            //可以开始出库啦
            MoveInfo.NextMoveStep(LineMoveStep.FO_211_AxisDownMove);
            int targetPosition = BatchAxis.GetAclPosition() - outParam.PlateH * Config.Height_ChangeValue;
            if (targetPosition < Config.BatchAxisP2)
            {
                targetPosition = Config.BatchAxisP2;
            }
            OutLog("出库移栽 " + MoveInfo.SLog + " :提升伺服下降指定的高度,目标:"+ targetPosition);
            BatchAxis.AbsMove(MoveInfo, targetPosition, Config.BatchAxis_P2Speed);
            return true; 
        }
        public void StartOutStoreP()
        {
            if (OutStoreHeight >= 0)
            {
                return;
            }
            //若定位工位,阻挡工位,有 料架,直接进入定位工位,并上升好位置,若需要出库,直接下降高度即可
            if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.SL_Stop_Check).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.SL_Entry_Check).Equals(IO_VALUE.HIGH))
            {
                StartOutStoreMove(null);
            }
            else if (IOValue(IO_Type.SL_Entry_Check).Equals(IO_VALUE.HIGH))
            {
                //小车到达处理
            }
            else if (IOValue(IO_Type.SL_Out_Check).Equals(IO_VALUE.HIGH))
            {
                //线体出口检测到料架,需要通知AGV小车
                //  AgvClient.NeedLeave(Config.AgvOutName); 
            }
        }
        public override bool StartOutStoreMove(InOutParam param)
        {

            runStatus = LineRunStatus.Busy;
            lineStatus = LineStatus.OutStoreExecute;
            MoveInfo.NewMove(LineMoveType.OutStore);
            MoveInfo.MoveParam = new InOutParam();
            serverShelfData = null;
            if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.HIGH))
            {
                FO_04_WaitTime();
            }
            else
            {
                //如果升降盘在锁紧状态,需要返回P2
                if (IsTrayLCylinderAfter())
                {
                    MoveInfo.NextMoveStep(LineMoveStep.FO_01_TrayLocation_After);
                    OutLog("准备出库料架, " + MoveInfo.SLog + "  :升降盘定位气缸后退");
                    TrayLCylinderAfter(MoveInfo);
                }
                else
                {
                    MoveInfo.NextMoveStep(LineMoveStep.FO_00_BatchAxisToP2);
                    BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
                    OutLog("准备出库料架,升降盘不在后退端 " + MoveInfo.SLog + "  :提升伺服先回到P2");
                }
            }
            return true;
        }
        private void FO_04_WaitTime()
        {
            //定位工位有料架,等待1秒后再次检测
            MoveInfo.NextMoveStep(LineMoveStep.FO_04_WaitTime);
            OutLog("准备出库料架 " + MoveInfo.SLog + "定位工位检测到料架:进料阻挡上升, 等待1秒再次检测");

            IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.LOW);
            IOMove(IO_Type.SL_Entry_StopDown, IO_VALUE.LOW);
            MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
        }
        private void LineOutStoreProcess()
        {
            IOMove(IO_Type.SL_Line_Run, IO_VALUE.LOW);

            //判断是哪个工位有料架
            if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.HIGH))
            {
                FO_04_WaitTime();
            }
            //阻挡工位有料架,流水线转动一个工位
            else if (IOValue(IO_Type.SL_Stop_Check).Equals(IO_VALUE.HIGH))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_03_LineStart);
                OutLog("准备出库料架: " + MoveInfo.SLog + "   阻挡工位检测有料架,进料阻挡下降,缓冲阻挡下降,流水线转动 1000");
                IOMove(IO_Type.SL_Entry_StopDown, IO_VALUE.HIGH);
                IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.LOW);
                IOMove(IO_Type.SL_Line_Run, IO_VALUE.HIGH);
                //等待指定时间
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
                MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Location_Check, IO_VALUE.HIGH));
            }
            else if (IOValue(IO_Type.SL_Entry_Check).Equals(IO_VALUE.HIGH))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_03_LineStart);
                OutLog("准备出库料架: " + MoveInfo.SLog + "   进料口检测有料架,进料阻挡上升,缓冲阻挡上升,流水线转动 1000");
                IOMove(IO_Type.SL_Entry_StopDown, IO_VALUE.LOW);//进料阻挡上升
                IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.HIGH);//缓冲阻挡下降
                IOMove(IO_Type.SL_Line_Run, IO_VALUE.HIGH);
                //等待指定时间
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
                MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Stop_Check, IO_VALUE.HIGH));
            }
            else
            {
                MoveInfo.EndMove();
                runStatus = LineRunStatus.Runing;
                OutLog(" 未检测到料架, 准备出库料架结束");
            }
        }
        protected override void OutStoreProcess()
        {
            if (MoveInfo.IsInWait)
            {
                CheckWait(MoveInfo);
            }
            if (MoveInfo.IsInWait)
            {
                return;
            }
            if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_00_BatchAxisToP2))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_01_TrayLocation_After);
                TrayLCylinderAfter(MoveInfo);
                OutLog("准备出库料架, " + MoveInfo.SLog + "  :升降盘定位气缸后退");
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_01_TrayLocation_After))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_02_LocationDown);
                OutLog("出库:  " + MoveInfo.SLog + " 开始:定位气缸下降,提升轴移动到P1");
                CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Up, IO_Type.SL_LocationCylinder_Down);
                BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_02_LocationDown))
            {
                LineOutStoreProcess();
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_03_LineStart))
            {
                LineOutStoreProcess();
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_04_WaitTime))
            {
                if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.HIGH))
                {
                    //定位工位有料架,直接开始入料
                    MoveInfo.NextMoveStep(LineMoveStep.FO_05_LocationUp);
                    OutLog("定位工位检测到料架: " + MoveInfo.SLog + " 缓冲阻挡下降, 定位气缸上升,读取料架号");
                    IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.LOW);//缓冲阻挡下降  
                    CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Down, IO_Type.SW4_LocationCylinder_Up);

                    UpdateShelfId();
                }
                else
                {
                    MoveInfo.EndMove();
                    runStatus = LineRunStatus.Runing;
                    lineStatus = LineStatus.StoreOnline;
                    OutLog(" 未检测到料架,料架处理结束");
                }
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_05_LocationUp))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_06_BatchAxisToP2);
                OutLog("准备出库料架 " + MoveInfo.SLog + " :提升轴下降到位P2,定位气缸上升");
                IOMove(IO_Type.SL_Line_Run, IO_VALUE.LOW);
                BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
                CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Down, IO_Type.SL_LocationCylinder_Up);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_06_BatchAxisToP2))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_07_TrayLocation_Before);
                OutLog("准备出库料架 " + MoveInfo.SLog + " :升降盘定位气缸前进");
                TrayLCylinderBefore(MoveInfo);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_07_TrayLocation_Before))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_08_AxisUpMove);
                OutLog("准备出库料架 " + MoveInfo.SLog + " :上料轴开始慢速上升到P3点,等待检测到料盘");
                BatchAxisToP3();
            }

            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_08_AxisUpMove))
            {
                //判断信号是否亮
                if (IOValue(IO_Type.SL_AxisLocationCheck).Equals(IO_VALUE.LOW))
                {
                    OutStoreHeight = 0;
                    OutStoreCount = 0;
                    //如果再出库中直接出库
                    MoveInfo.EndMove();
                    runStatus = LineRunStatus.Runing;
                    lineStatus = LineStatus.StoreOnline;
                    //  MoveInfo.NextMoveStep(LineMoveStep.FO_39_OutLineRun);
                    OutLog("准备出库料架完成");
                    // FO_11_AxisDownMove(); 
                }
                else
                {
                    //检测到料盘,需要下降指定高度,此处默认下降1cm
                    int tp = BatchAxis.GetAclPosition() - Config.Height_ChangeValue * 10;
                    if (tp < Config.BatchAxisP2)
                    {
                        OutLog("准备出库料架 " + MoveInfo.SLog + " :检测到料盘,下降的目标高度为【" + tp + "】<【" + Config.BatchAxisP2 + "】,料架已满,直接送出料架");
                        MoveInfo.NextMoveStep(LineMoveStep.FO_30_BatchAxisToP2);
                        OutLog("出库移栽 " + MoveInfo.SLog + ":提升伺服到P2点");
                        BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
                    }
                    else
                    {
                        MoveInfo.NextMoveStep(LineMoveStep.FO_08_AxisUpMove);
                        OutLog("准备出库料架 " + MoveInfo.SLog + " :检测到料盘,需要下降指定高度,目标位置:" + tp + ",等待检测不到料盘");
                        MoveInfo.TimeOutSeconds = 200;
                        MoveInfo.CanWhileCount = 0;
                        MoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxis(Config.Batch_Axis, tp, Config.BatchAxis_P3Speed));
                        Config.Batch_Axis.TargetPosition = tp;
                        BatchAxis.AbsMove(null, tp, Config.BatchAxis_P3Speed);
                        //开始检测信号
                        BatchAxisStartCheck(IO_Type.SL_AxisLocationCheck, IO_VALUE.LOW);
                    }
                }
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_30_BatchAxisToP2))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_31_TrayLocation_After);
                OutLog("送出料串: " + MoveInfo.SLog + ": 升降盘定位气缸后退,重置 OutEndSendShelfOut=fasle ,OutStoreCount = 0");
                OutEndSendShelfOut = false;
                OutStoreHeight = -1;
                OutStoreCount = 0;
                TrayLCylinderAfter(MoveInfo);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_31_TrayLocation_After))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_32_BatchAxisToP1);
                OutLog("送出料串: " + MoveInfo.SLog + ":提升伺服到P1点,定位气缸下降");
                BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
                CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Up, IO_Type.SL_LocationCylinder_Down);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_32_BatchAxisToP1))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_34_OutCheck);
                OutLog("送出料串: " + MoveInfo.SLog + ",等待出料线体无料架"); 
                MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Out_Check, IO_VALUE.LOW));
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_34_OutCheck))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_34_OutTopCylinder_Up);
                OutLog("送出料串: " + MoveInfo.SLog + ",出口顶升气缸上升,出料缓冲阻挡上升");
                CylinderMove(MoveInfo, IO_Type.SL_OutTopCylinder_Down, IO_Type.SL_OutTopCylinder_Up);
                IOMove(IO_Type.SL_Out_StopDown, IO_VALUE.LOW);

            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_34_OutTopCylinder_Up))
            {
                //TODO 
                MoveInfo.NextMoveStep(LineMoveStep.FO_35_SideWayLineRun);
                OutLog("送出料串: " + MoveInfo.SLog + ", 线体横移电机运转,等待料架离开定位工位");
                IOMove(IO_Type.SL_LocationSideWay_Run, IO_VALUE.HIGH);
                IOMove(IO_Type.SL_OutSideWay_Run, IO_VALUE.HIGH);
                MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Location_Check, IO_VALUE.LOW));

            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_35_SideWayLineRun))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_36_WaitShelfGo);
                OutLog("送出料串:" + MoveInfo.SLog + ", 线体横移电机运转,等待料架到达出口");
                IOMove(IO_Type.SL_LocationSideWay_Run, IO_VALUE.HIGH);
                IOMove(IO_Type.SL_OutSideWay_Run, IO_VALUE.HIGH);
                MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Out_Check, IO_VALUE.HIGH));
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_36_WaitShelfGo))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_37_LineStop);
                OutLog("送出料串: " + MoveInfo.SLog + ", 料架到达出口,线体横移电机停止 ");
                IOMove(IO_Type.SL_LocationSideWay_Run, IO_VALUE.LOW);
                IOMove(IO_Type.SL_OutSideWay_Run, IO_VALUE.LOW);
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
            }

            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_37_LineStop))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_38_TopDown);
                OutLog("送出料串: " + MoveInfo.SLog + ", 料架到达出口,出口顶升下降 , ");
                CylinderMove(MoveInfo, IO_Type.SL_OutTopCylinder_Up, IO_Type.SL_OutTopCylinder_Down);
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_38_TopDown))
            {
                MoveInfo.EndMove();
                runStatus = LineRunStatus.Runing;
                //  MoveInfo.NextMoveStep(LineMoveStep.FO_39_OutLineRun);
                OutLog("送出料串: " + MoveInfo.SLog + ", 出口线体运转,料架到达出口处, 通知AGV取空料架, 出料结束");
                AgvClient.NeedLeave(Config.AgvOutName);
            }
            else if (MoveInfo.MoveStep >= LineMoveStep.FO_211_AxisDownMove && MoveInfo.MoveStep < LineMoveStep.FO_30_BatchAxisToP2)
            {
                TrayOutProcess();
            }
            else
            {
                LogUtil.error(Name + " " + MoveInfo.MoveType + MoveInfo.SLog + "未找到相关处理", 19);
            }
        }

        private void TrayOutProcess()
        {
            if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_211_AxisDownMove))
            {
                //判断伺服检测信号是否亮
                if (IOValue(IO_Type.SL_AxisLocationCheck).Equals(IO_VALUE.LOW) || BatchAxis.IsInPosition(Config.BatchAxisP2))
                {
                    if (MoveCylineCanTakeOrGive())
                    {
                        MoveInfo.NextMoveStep(LineMoveStep.FO_212_CylinderTake);
                        OutLog("紧急出料" + MoveInfo.SLog + ":上料横移机构取料端");
                        CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Give, IO_Type.SL_MoveCylinder_Take);
                    }
                    else
                    {
                        MoveInfo.NextMoveStep(LineMoveStep.FO_211_AxisDownMove);
                        OutLog("紧急出料" + MoveInfo.SLog + ":上料横移机构取料端  前先上升横移气缸");
                        CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
                    }
                }
                else
                {
                    //可以开始出库啦
                    MoveInfo.NextMoveStep(LineMoveStep.FO_211_AxisDownMove);
                    int targetPosition = BatchAxis.GetAclPosition() - MoveInfo.MoveParam.PlateH * Config.Height_ChangeValue;
                    if (targetPosition < Config.BatchAxisP2)
                    {
                        targetPosition = Config.BatchAxisP2;
                    }
                    OutLog("出库移栽 " + MoveInfo.SLog + " :TrayOutProcess 伺服检测信号亮并且不再P2点,再次下降指定的高度,目标:" + targetPosition);
                    BatchAxis.AbsMove(MoveInfo, targetPosition, Config.BatchAxis_P2Speed);
                }
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_212_CylinderTake))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_213_UpdownAxisToP2);
                int targetP = Config.GetUpdownPositionP2(MoveInfo.MoveParam.PlateH);
                OutLog("紧急出料" + MoveInfo.SLog + ":升降伺服下降到P2:" + targetP);
                UpdownAxis.AbsMove(MoveInfo, targetP, Config.UpdownAxis_P2Speed);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_213_UpdownAxisToP2))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_214_CylinderDown);
                OutLog("紧急出料" + MoveInfo.SLog + ":上料横移机构下降");
                CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Up, IO_Type.SL_MoveCylinder_Down);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_214_CylinderDown))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_215_CylinderTighten);
                OutLog("紧急出料" + MoveInfo.SLog + ":上料气缸夹紧");
                CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Slack, IO_Type.SL_MoveCylinder_Tighten);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_215_CylinderTighten))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_216_CylinderUp);
                OutLog("紧急出料" + MoveInfo.SLog + ":上料横移机构上升");
                CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_216_CylinderUp))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_217_UpdownAxisToP1);
                OutLog("紧急出料" + MoveInfo.SLog + ":升降伺服到P1");
                UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);

                int trayNum = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.TrayNumber : currTrayNum;
                //更新此托盘为空托盘
                TrayManager.UpdateTrayInfo(trayNum, false);
                SecondMoveInfo.NextMoveStep(LineMoveStep.MO_12_MoveOk);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_217_UpdownAxisToP1))
            {
                if (MoveCylineCanTakeOrGive())
                {
                    MoveInfo.NextMoveStep(LineMoveStep.FO_218_CylinderGive);
                    OutLog("紧急出料" + MoveInfo.SLog + ":上料横移机构到放料端");
                    CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give);
                }
                else
                {
                    MoveInfo.NextMoveStep(LineMoveStep.FO_217_UpdownAxisToP1);
                    OutLog("紧急出料" + MoveInfo.SLog + ":上料横移机构到放料端前,先上升横移气缸");
                    CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
                }

            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_218_CylinderGive))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_219_UpdownAxisToP3);
                OutLog("紧急出料 " + MoveInfo.SLog + ":移栽伺服到P3");
                UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP3, Config.UpdownAxis_P3Speed);
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_219_UpdownAxisToP3))
            {
                OutStoreHeight += MoveInfo.MoveParam.PlateH;
                OutStoreCount++;
                MoveInfo.NextMoveStep(LineMoveStep.FO_220_CylinderSlack);
                OutLog("紧急出料 " + MoveInfo.SLog + ":出料横移机构放松,累积出库【" + OutStoreCount + "】盘【" + OutStoreHeight + "】mm");
                CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Tighten, IO_Type.SL_MoveCylinder_Slack);

            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_220_CylinderSlack))
            {
                MoveInfo.NextMoveStep(LineMoveStep.FO_221_UpdownAxisToP1);
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
                OutLog("紧急出料 " + MoveInfo.SLog + ":移栽伺服上升到待机点P1,通知服务器PutShelfFinished");
                UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
                Task.Factory.StartNew(delegate
                {
                    string msg = SServerManager.PutShelfFinished(Name, MoveInfo.MoveParam.WareCode, CurrShelfId, OutStoreCount.ToString(), out serverShelfData);
                    if (String.IsNullOrEmpty(msg).Equals(false))
                    {
                        LogUtil.error(Name + "【" + MoveInfo.MoveParam.WareCode + "】【" + CurrShelfId + "】【" + OutStoreCount.ToString() + "】PutShelfFinished 结果:" + msg);
                        serverShelfData = null;
                    }
                });
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_221_UpdownAxisToP1))
            { 
                if (MoveCylineCanTakeOrGive())
                {
                    MoveInfo.NextMoveStep(LineMoveStep.FO_222_CylinderTake);
                    OutLog("紧急出料" + MoveInfo.SLog + ":上料横移机构回到取料端");
                    CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Give, IO_Type.SL_MoveCylinder_Take);
                }
                else
                {
                    MoveInfo.NextMoveStep(LineMoveStep.FO_221_UpdownAxisToP1);
                    OutLog("紧急出料" + MoveInfo.SLog + ":上料横移机构取料端  前先上升横移气缸");
                    CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
                }
            }
            else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_222_CylinderTake))
            {
                //出库结束 TODO
                //    bool isNeedSendShelf = false;
                //判断料架是否满了
                int currPositon = BatchAxis.GetAclPosition();
                int tp = currPositon - Config.Height_ChangeValue * 10;
                if (tp < Config.BatchAxisP2)
                {
                    SendOutShelfOut("当前提升轴位置:" + currPositon + ",料架已满,需要送出料架");
                }
                else if (OutEndSendShelfOut)
                {
                    SendOutShelfOut("当前提升轴位置:" + currPositon + ",OutEndSendShelfOut,需要送出料架");
                }
                else
                {
                    //判断是否需要送出料架
                    if (serverShelfData != null && serverShelfData.cutTask <= 0)
                    {
                        SendOutShelfOut("服务器返回cutTask=" + serverShelfData.cutTask + ",需要送出料架");
                    }
                    else
                    {
                        OutLog("紧急出料完成,出料结束");
                        MoveInfo.EndMove();
                        runStatus = LineRunStatus.Runing;
                    }
                }
            }
        }
        private void SendOutShelfOut(string msg="")
        {
            MoveInfo.NextMoveStep(LineMoveStep.FO_30_BatchAxisToP2);
            OutStoreHeight = -1;
            OutLog("紧急出料完成, " + MoveInfo.SLog + ":"+msg+ ",送出料串,提升伺服到P2点,重置OutStoreHeight=-1");
            BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
        }
        #endregion
    }
}