You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using HBLConsole.Service;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace HBLDevice.Coffee
- {
- public class MorkCStatus : Singleton<MorkCStatus>
- {
- private CoffeEndCook coffeEndCook = new CoffeEndCook();
- 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;
- coffeEndCook.Publish();
- }
- else
- {
- CoffeeStatus = package.Status;
- }
-
- AppStatus = package.ApplicationStatus;
- Warning = package.Warning;
- Fault = package.Fault;
-
- lastRefreshTime = DateTime.Now;
- }
- }
- }
|