|
- using BPASmartClient.DRCoffee;
- using BPASmartClient.MessageCommunication;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.DRCoffee
- {
- public class MorkCStatus
- {
- private volatile static MorkCStatus _Instance;
- public static MorkCStatus GetInstance() => _Instance ?? (_Instance = new MorkCStatus());
- private MorkCStatus() { }
-
- private DateTime lastRefreshTime = DateTime.MinValue;
- /// <summary>
- /// 是否在线
- /// </summary>
- public bool OnLine { get { return DateTime.Now.Subtract(lastRefreshTime).TotalSeconds <= 3; } }
- /// <summary>
- /// 咖啡机状态
- /// </summary>
- public DrCoffeeStatus CoffeeStatus { get; set; }
- /// <summary>
- /// 应用状态
- /// </summary>
- public DrCoffeeAppStatus AppStatus { get; set; }
- /// <summary>
- /// 警告信息
- /// </summary>
- public DrCoffeeWarning Warning { get; set; }
- /// <summary>
- /// 故障信息
- /// </summary>
- public DrCoffeeFault Fault { get; set; }
-
- public bool CanDo
- {
- get
-
- {
- if (!OnLine)
- return false;
- if (Warning != DrCoffeeWarning.无警告)
- return false;
- if (Fault != DrCoffeeFault.无故障)
- return false;
- return true;
- }
- }
-
- /// <summary>
- /// 咖啡机状态解析
- /// </summary>
- /// <param name="package"></param>
- public void ProcessPackage(DrCoffeePackage package)
- {
- if (CoffeeStatus == DrCoffeeStatus.Running && package.Status != DrCoffeeStatus.Running)
- {
- CoffeeStatus = package.Status;
- Class_InnerMessageBus.GetInstance().PostMessage(this,Class_MessageName.DRCoffee_CoffeEndCook,"");
- }
- else {
- CoffeeStatus = package.Status;
- }
-
- AppStatus = package.ApplicationStatus;
- Warning = package.Warning;
- Fault = package.Fault;
-
- lastRefreshTime = DateTime.Now;
- }
- }
- }
|