终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

77 行
2.2 KiB

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