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.
 
 

74 lines
2.0 KiB

  1. using HBLConsole.Service;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace HBLDevice.Coffee
  8. {
  9. public class MorkCStatus : Singleton<MorkCStatus>
  10. {
  11. private CoffeEndCook coffeEndCook = new CoffeEndCook();
  12. private DateTime lastRefreshTime = DateTime.MinValue;
  13. /// <summary>
  14. /// 是否在线
  15. /// </summary>
  16. public bool OnLine { get { return DateTime.Now.Subtract(lastRefreshTime).TotalSeconds <= 3; } }
  17. /// <summary>
  18. /// 咖啡机状态
  19. /// </summary>
  20. public DrCoffeeStatus CoffeeStatus { get; set; }
  21. /// <summary>
  22. /// 应用状态
  23. /// </summary>
  24. public DrCoffeeAppStatus AppStatus { get; set; }
  25. /// <summary>
  26. /// 警告信息
  27. /// </summary>
  28. public DrCoffeeWarning Warning { get; set; }
  29. /// <summary>
  30. /// 故障信息
  31. /// </summary>
  32. public DrCoffeeFault Fault { get; set; }
  33. public bool CanDo
  34. {
  35. get
  36. {
  37. if (!OnLine)
  38. return false;
  39. if (Warning != DrCoffeeWarning.无警告)
  40. return false;
  41. if (Fault != DrCoffeeFault.无故障)
  42. return false;
  43. return true;
  44. }
  45. }
  46. /// <summary>
  47. /// 咖啡机状态解析
  48. /// </summary>
  49. /// <param name="package"></param>
  50. public void ProcessPackage(DrCoffeePackage package)
  51. {
  52. if (CoffeeStatus == DrCoffeeStatus.Running && package.Status != DrCoffeeStatus.Running)
  53. {
  54. CoffeeStatus = package.Status;
  55. coffeEndCook.Publish();
  56. }
  57. else
  58. {
  59. CoffeeStatus = package.Status;
  60. }
  61. AppStatus = package.ApplicationStatus;
  62. Warning = package.Warning;
  63. Fault = package.Fault;
  64. lastRefreshTime = DateTime.Now;
  65. }
  66. }
  67. }