using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Project
{
    public partial class fMain
    {
        public Boolean _SM_RUN_POSCHK(bool isFirst, TimeSpan stepTime)
        {
            //현재 위치가 찾아지지 않았다면. 먼저 위치를 찾는다. 위로 이동시켜서 찾는다.
            if (PUB.Result.CurrentPos == ePosition.NONE)
            {
                if (isFirst)
                {
                    PUB.Speak( Lang.현재위치를검색합니다);
                }

                if (PUB.AGV.system1.agv_run)
                {
                    //방향을 체크한다
                    var basedir = PUB.setting.AGV_Direction_FVI_Backward ? 'F' : 'B';
                    if (PUB.AGV.data.Direction == basedir)
                    {
                        var ts = DateTime.Now - LastCommandTime;
                        if (ts.TotalMilliseconds >= 1999)
                        {
                            PUB.AGV.AGVMoveStop("SM_RUN_POSCHK",arDev.Narumi.eStopOpt.Stop);
                            LastCommandTime = DateTime.Now;
                        }
                    }
                }
                else if (PUB.AGV.system1.agv_run == false)
                {
                    //전진이동한다
                    var ts = DateTime.Now - LastCommandTime;
                    if (ts.TotalMilliseconds >= 1999)
                    {
                        if (PUB.setting.AGV_Direction_FVI_Backward)
                            PUB.AGV.AGVMoveRun(arDev.Narumi.eRunOpt.Backward);//
                        else
                            PUB.AGV.AGVMoveRun(arDev.Narumi.eRunOpt.Forward);//
                        LastCommandTime = DateTime.Now;
                    }
                }

                return false;
            }
            else return true;
        }
    }
}
