ClientInfo.cs 1.3 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeviceLibrary.Models
{
    public class ClientInfo
    {
        /// <summary>
        /// 任务来源系统标识
        /// </summary>
        public string sourceClient { get; set; }
        private bool idleAgv = false;
        /// <summary>
        /// 是否有空闲AGV可用
        /// </summary>
        public bool hasIdleAgv { 
        get { return idleAgv && Online; }
            set { idleAgv = value; }
        }
        /// <summary>
        /// 在线状态
        /// </summary>
        public bool Online { get 
            {
                double upInterval = (DateTime.Now - lastUpdateTime).TotalSeconds;
                if (upInterval > 5)
                    return false;
                return true;
            } }
        private DateTime lastUpdateTime = new DateTime();

        public void SetInfo(string client,bool hasIdleAdv)
        {
            sourceClient = client;
            this.idleAgv = hasIdleAdv;
            lastUpdateTime = DateTime.Now;
        }
        public ClientInfo() { }
        public ClientInfo(string sourceclient,bool hasidleagv)
        {
            sourceClient = sourceclient;
            idleAgv = hasidleagv;
            lastUpdateTime = DateTime.Now;
        }
    }
}