终端一体化运控平台
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.
 
 
 

77 rivejä
2.1 KiB

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