using BPASmartClient.DRCoffee; using BPA.Helper; using BPASmartClient.Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BPASmartClient.DRCoffee { public class MorkCStatus : Singleton { private DRCoffee_CoffeEndCookEvent coffeEndCook = new DRCoffee_CoffeEndCookEvent(); private DateTime lastRefreshTime = DateTime.MinValue; /// /// 是否在线 /// public bool OnLine { get { return DateTime.Now.Subtract(lastRefreshTime).TotalSeconds <= 3; } } /// /// 咖啡机状态 /// public DrCoffeeStatus CoffeeStatus { get; set; } /// /// 应用状态 /// public DrCoffeeAppStatus AppStatus { get; set; } /// /// 警告信息 /// public DrCoffeeWarning Warning { get; set; } /// /// 故障信息 /// 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; } } /// /// 咖啡机状态解析 /// /// public void ProcessPackage(DrCoffeePackage package) { if (CoffeeStatus == DrCoffeeStatus.Running && package.Status != DrCoffeeStatus.Running) { CoffeeStatus = package.Status; coffeEndCook.Publish(); } else { CoffeeStatus = package.Status; } AppStatus = package.ApplicationStatus; Warning = package.Warning; Fault = package.Fault; lastRefreshTime = DateTime.Now; } } }