AgvInfo.cs 4.8 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    public class AgvInfo
    {
        /// <summary>
        /// 小车名称
        /// </summary>
        public string Name { set; get; } = "";
        /// <summary>
        /// 在Fleet中的ID
        /// </summary>
        public string FleetID { set; get; } = "";
        /// <summary>
        /// 小车IP地址
        /// </summary>
        public string IP { set; get; } = "";
        /// <summary>
        /// 授权码
        /// </summary>
        public string Authorization { set; get; } = "";
        /// <summary>
        /// 工作车间
        /// </summary>
        public string Workshop { set; get; } = "";
        /// <summary>
        /// 是否自动使用
        /// </summary>
        public bool IsAuto { set; get; } = false;
        /// <summary>
        /// 是否在线
        /// </summary>
        public bool IsOnline { set; get; } = false;
        /// <summary>
        /// 电量百分比
        /// </summary>
        public int Battery { set; get; } = 0;
        /// <summary>
        /// AGV最大充电电量
        /// </summary>
        public int BatteryMax { set; get; } = 0;
        /// <summary>
        /// AGV最低电量,小于此值必须充电
        /// </summary>
        public int BatteryMin { set; get; } = 0;
        /// <summary>
        /// 状态ID号
        /// </summary>
        public int StateID { set; get; } = -1;
        /// <summary>
        /// 状态文本
        /// </summary>
        public string StateText { set; get; } = "";
        /// <summary>
        /// 任务文本
        /// </summary>
        public string MissionText { set; get; } = "";
        /// <summary>
        /// 小车坐标位置
        /// </summary>
        public System.Drawing.PointF Position { set; get; }
        /// <summary>
        /// 是否正在被调用
        /// </summary>
        public bool IsCall { set; get; } = false;

        /// <summary>
        /// 当前的工作
        /// </summary>
        public IJob CurrentJob { set; get; } = null;

        public string From { set; get; } = "";

        public string Place { set; get; } = "";

        public int OldSteel { set; get; } = 0;

        public int NewSteel { set; get; } = 0;

        public string TaskName { set; get; } = "";

        public LogJson LogJson { set; get; }






        public AgvInfo(string fleetID, string name, string ip, string workshop, string authorization)
        {
            Name = name;
            FleetID = fleetID;
            IP = ip;
            Workshop = workshop;
            Authorization = authorization;

            if (int.TryParse(name.Substring(0, 2), out int result))
                LogJson = new LogJson(result + "号车", "RunLog");


            //if (name.IndexOf("11") >= 0)
            //    LogJson = new LogJson("11号车", "RunLog");
            //else if (name.IndexOf("13") >= 0)
            //    LogJson = new LogJson("13号车", "RunLog");
            //else if (name.IndexOf("21") >= 0)
            //    LogJson = new LogJson("21号车", "RunLog");
        }

        public string[] ToGridRow()
        {
            string[] arr = new string[] { Name, Place, StateText, Battery.ToString(), IsOnline.ToString(), IsAuto.ToString(), "清除" };
            return arr;
        }

        public string ToMissionState()
        {
            string s = Name + " [" + IP + "]\r\n\r\n" + MissionText;
            return s;
        }

        /// <summary>
        /// 在自己的工作区域
        /// </summary>
        /// <returns></returns>
        public bool IsWorkspace()
        {
            //3楼
            if (Workshop.ToUpper().IndexOf("3S") > -1)
                return true;

            //4楼
            if (Position.Y < 55)
            {
                if (Workshop.ToUpper().IndexOf("4D") > -1)
                    return true;
                else if (Workshop.ToUpper().IndexOf("4C") > -1)
                    return false;
            }
            else if (Position.Y > 62)
            {
                if (Workshop.ToUpper().IndexOf("4D") > -1)
                    return false;
                else if (Workshop.ToUpper().IndexOf("4C") > -1)
                    return true;
            }

            return false;
        }

        public bool Is4DWorkshop()
        {
            if (Position.Y < 55)
                return true;
            else if (Position.Y > 62)
                return false;
            else
                return false;
        }

        /// <summary>
        /// 在无尘室内
        /// </summary>
        /// <returns></returns>
        public bool InAirRoom()
        {
            if (Config.AirRoom_PosX < 51.5f && Config.AirRoom_PosY > 65.7f)
                return true;
            else
                return false;
        }
    }
}