AgvInfo.cs 3.2 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 { private set; get; } = "";
        /// <summary>
        /// 在Fleet中的ID
        /// </summary>
        public string FleetID { private set; get; } = "";
        /// <summary>
        /// 小车IP地址
        /// </summary>
        public string IP { private set; get; } = "";
        /// <summary>
        /// 授权码
        /// </summary>
        public string Authorization { private 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>
        /// 小车状态ID号
        /// </summary>
        public int StateID { set; get; } = -1;
        /// <summary>
        /// 小车状态文本
        /// </summary>
        public string StateText { set; get; } = "";
        /// <summary>
        /// 小车当前任务名称
        /// </summary>
        public string MissionName { set; get; } = "";
        /// <summary>
        /// 小车当前任务说明描述
        /// </summary>
        public string MissionExplain { set; get; } = "";
        /// <summary>
        /// 小车坐标位置
        /// </summary>
        public System.Drawing.PointF Position { set; get; }
        /// <summary>
        /// 是否正在被调用
        /// </summary>
        public bool IsCall { set; get; } = false;
        /// <summary>
        /// 当前地点
        /// </summary>
        public string Place { set; get; } = "";
        /// <summary>
        /// 当前的工作
        /// </summary>
        public IJob CurrentJob { set; get; } = null;
        /// <summary>
        /// 任务结束后最终是否应该存在货架,0不存在,1存在,-1不判断,这个并不是实际是否存在,只是用于任务报错终止后判断是否需要重发任务
        /// </summary>
        public int ExistShelf { set; get; } = -1;

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





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

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

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

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

    }
}