AutoInOutTestTask.cs 9.2 KB
using CtuDeviceLib;
using Mushiny;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeviceLibrary.CtuService
{
    public class AutoInOutTestTask : CtuTaskBase
    {
        public AutoInOutTestTask(CTU ctu) : base(ctu)
        {

        }

        public List<string> shelfCodes = null;
        int curIndex = 0;
        public override void Excute()
        {
            //switch (MoveInfo.MoveStep)
            //{
            //    case RunStep.Wait:
            //        break;
            //    case RunStep.AutoInOut_Start:
            //        MoveInfo.NextMoveStep(RunStep.AutoInOut_GetBoxFromBunker);
            //        string landcode = shelfCodes[curIndex];
            //        setDstName(landcode);
            //        MoveInfo.Info($"准备执行【{landcode}】");
            //        break;
            //    case RunStep.AutoInOut_GetBoxFromBunker:
            //        if (MushinyManager.GetBoxFromBasket(ctu, boxCode, out curPathPoint))
            //        {
            //            if (curCtu.CreatePathPoint(curPathPoint))
            //            {
            //                ctuStep = CtuStep.Ctu_GetBoxFromBunkerOk;
            //                logInfo("从背篓取货");
            //                lastSendTime = DateTime.Now;
            //            }
            //        }
            //        break;
            //    case RunStep.AutoInOut_GetBoxFromBunkerOk:
            //        if (actions?.ActionFinishCode == ActionFinishCode.从料仓取货完成)
            //        {
            //            ctuStep = CtuStep.Ctu_01_ToPointCode;
            //            logInfo($"从背篓取货完成");
            //        }
            //        else if (isSendTimeout())
            //        {
            //            ctuStep = CtuStep.Ctu_GetBoxFromBunker;
            //            logInfo($"从背篓取货超时,重发");
            //        }
            //        else
            //        {
            //            logInfo("等待从背篓取货完成");
            //        }
            //        break;
            //    case RunStep.AutoInOut_01_ToPointCode:
            //        if (curCtu.CurLandMark == curShelf.PointCode)
            //        {
            //            ctuStep = CtuStep.Ctu_02_AtPointCode;
            //            logInfo($"当前在地标[{curShelf.PointCode}],无需发送移动任务");
            //        }
            //        else if (CreateMoveTask(curCtu, curShelf.PointCode))
            //        {
            //            if (curCtu.CreatePathPoint(curPathPoint))
            //            {
            //                ctuStep = CtuStep.Ctu_02_AtPointCode_1;
            //                logInfo($"去地标[{curShelf.PointCode}]");
            //                lastSendTime = DateTime.Now;
            //            }

            //        }
            //        else
            //        {
            //            logInfo($"去地标[{curShelf.PointCode}]失败");
            //        }
            //        break;
            //    case RunStep.AutoInOut_02_AtPointCode:
            //        if (curCtu.CurLandMark == curShelf.PointCode)
            //        {
            //            ctuStep = CtuStep.Ctu_03_PutToShelf;
            //            logInfo($"到达地标[{curShelf.PointCode}]");
            //        }
            //        break;
            //    case RunStep.AutoInOut_02_AtPointCode_1:
            //        if (actions?.ActionFinishCode == ActionFinishCode.整个路径执行完成)
            //        {
            //            ctuStep = CtuStep.Ctu_03_PutToShelf;
            //            logInfo($"到达地标[{curShelf.PointCode}]");
            //        }
            //        else if (isSendTimeout())
            //        {
            //            ctuStep = CtuStep.Ctu_01_ToPointCode;
            //            logInfo($"到达地标[{curShelf.PointCode}]超时,重发");
            //        }
            //        break;
            //    case RunStep.AutoInOut_03_PutToShelf:
            //        if (MushinyManager.PutBoxToShelf(curCtu, curShelf, 1, out curPathPoint))
            //        {
            //            if (curCtu.CreatePathPoint(curPathPoint))
            //            {
            //                ctuStep = CtuStep.Ctu_04_PutToShelfOk;
            //                logInfo($"往货架放货");
            //                lastSendTime = DateTime.Now;
            //            }

            //        }
            //        break;
            //    case RunStep.AutoInOut_04_PutToShelfOk:
            //        if (actions?.ActionFinishCode == ActionFinishCode.往货架放货完成)
            //        {
            //            ctuStep = CtuStep.Ctu_05_GetFromShelf;
            //            logInfo($"往货架放货完成");
            //        }
            //        else if (isSendTimeout())
            //        {
            //            ctuStep = CtuStep.Ctu_03_PutToShelf;
            //            logInfo($"往货架放货超时,重发");
            //        }
            //        break;
            //    case RunStep.AutoInOut_05_GetFromShelf:
            //        if (MushinyManager.GetBoxFomShelf(curCtu, curShelf, out curPathPoint))
            //        {
            //            if (curCtu.CreatePathPoint(curPathPoint))
            //            {
            //                ctuStep = CtuStep.Ctu_06_GetFromShelfOk;
            //                logInfo($"从货架取货");
            //                lastSendTime = DateTime.Now;
            //            }
            //        }
            //        break;

            //    case RunStep.AutoInOut_06_GetFromShelfOk:
            //        if (actions?.ActionFinishCode == ActionFinishCode.从货架取货完成)
            //        {
            //            ctuStep = CtuStep.Ctu_07_NextShelf;
            //            logInfo($"从货架取货完成");
            //        }
            //        else if (isSendTimeout())
            //        {
            //            ctuStep = CtuStep.Ctu_05_GetFromShelf;
            //            logInfo($"从货架取货超时,重发");
            //        }
            //        break;
            //    case RunStep.AutoInOut_07_NextShelf:
            //        if (!isRun)
            //        {
            //            ctuStep = CtuStep.Ctu_08_PutToBunker;
            //            logInfo($"手动结束[{curShelf.ShelveCode}],将料箱放回背篓");
            //        }
            //        else if (curIndex == shelfCodes.Count - 1)
            //        {
            //            ctuStep = CtuStep.Ctu_08_PutToBunker;
            //            logInfo($"最后一个库位[{curShelf.ShelveCode}],将料箱放回背篓");
            //        }
            //        else if (curIndex < shelfCodes.Count - 1)
            //        {
            //            curIndex++;
            //            landcode = shelfCodes[curIndex];
            //            curShelf = ctuBean.PosInfos.Where(p => p.Name == landcode).First();
            //            if (curShelf == null)
            //            {
            //                ctuStep = CtuStep.Ctu_End;
            //            }
            //            else
            //            {
            //                ctuStep = CtuStep.Ctu_01_ToPointCode;
            //                logInfo($"去[{curShelf.PointCode}]");
            //            }
            //        }
            //        break;
            //    case RunStep.AutoInOut_08_PutToBunker:
            //        if (MushinyManager.PutBoxToBasket(curCtu, curShelf, 1, out curPathPoint))
            //        {
            //            if (curCtu.CreatePathPoint(curPathPoint))
            //            {
            //                ctuStep = CtuStep.Ctu_09_PutToBunkerOk;
            //                logInfo($"将料箱放回背篓");
            //                lastSendTime = DateTime.Now;
            //            }

            //        }
            //        break;
            //    case CtuStep.AutoInOut_09_PutToBunkerOk:
            //        if (actions?.ActionFinishCode == ActionFinishCode.往料仓放货完成)
            //        {
            //            ctuStep = CtuStep.Ctu_End;
            //            logInfo($"将料箱放回背篓完成");
            //        }
            //        else if (isSendTimeout())
            //        {
            //            ctuStep = CtuStep.Ctu_08_PutToBunker;
            //            logInfo($"将料箱放回背篓超时,重发");
            //        }
            //        break;
            //    case CtuStep.AutoInOut_End:
            //        if (curCtu != null)
            //            curCtu.PathActionFinish -= Ctu_PathActionFinish;
            //        editControl(true);
            //        curIndex = 0;
            //        curShelf = null;
            //        runningCtus.Remove(curCtu.Name);
            //        SetControlText(label4, $"跑库位:当前行走{curIndex}个库位,运行结束!");
            //        ctuStep = CtuStep.Ctu_Wait;
            //        isRun = false;
            //        break;
            //}
        }
    }
}