AgvBean.cs 1.6 KB
using Acc.Common;
using System;
using System.Collections.Generic;

namespace Acc.AgvManager
{
    public class AgvBean
    {
        public AgvStatus agvStatus;
        public AgvApi AgvApi { get; set; }
        public Job CurrentJob { get; set; }

        public string Name { get; set; }

        public bool IsIdle()
        {
            return false;
        }

        public bool NeedCharge()
        {
            return false;
        }

        public void ExecuteNewJob(Job newJob)
        {
            CurrentJob = newJob;
        }

        public void JobContinue(AgvBean currentAgvBean, Dictionary<string, Node> nodeMap, Dictionary<string, AgvBean> agvBeanMap)
        {
            if (CurrentJob != null)
            {
                if (!CurrentJob.IsProcess)
                {
                    try
                    {
                        CurrentJob.IsProcess = true;
                        CurrentJob.Execute(currentAgvBean, nodeMap, agvBeanMap);
                    }catch(Exception e)
                    {
                        LogUtil.error("AGV["+Name+"]执行任务["+ CurrentJob.ToString()+"]出错",e);
                    }
                    finally
                    {
                        CurrentJob.IsProcess = false;
                    }
                }
                
                if (CurrentJob.IsEnd())
                {
                    //添加任务已经完成日志
                    CurrentJob = null;
                }
            }
        }

        internal bool IsInCharge()
        {
            throw new NotImplementedException();
        }
    }
}