using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeviceLibrary.bean.agv
{
    /// <summary>
    /// Agv职责类
    /// </summary>
    public class Scope
    {
        /// <summary>
        /// 工作车间
        /// </summary>
        public string Workshop { get; set; } 
        /// <summary>
        /// 楼层
        /// </summary>
        public int Floor { get {
                try
                {
                    return int.Parse(Workshop.Substring(0,1));
                }
                catch {
                    return 0;
                }
            } }
        /// <summary>
        /// 可执行的任务
        /// </summary>

        public List<string> Tasks { get; set; }
        /// <summary>
        /// 备注使用的电梯
        /// </summary>

        public string Remark { get; set; }
        /// <summary>
        /// 任务系统标识
        /// </summary>
        public string client { get { return Workshop; } }
        /// <summary>
        /// 是否有空料车在电梯中准备送出
        /// </summary>
        /// <param name="liftname"></param>
        /// <returns></returns>
        public bool HasEmptyShelfInLift(out string liftname,out lift.LiftStatus liftStatus)
        {
            liftname = "";
            liftStatus = null;
            string[] lifts = Remark.Split(',');
            foreach (string item in lifts)
            {
                if(lift.LiftContext.HasShelfNeedLeave(item,client,out liftStatus))
                {
                    liftname = item;
                    return true;
                }
            }
            return false;
        }
    }
}