终端一体化运控平台
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

IceMakerMachine.cs 2.9 KiB

há 1 ano
há 1 ano
há 1 ano
há 1 ano
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. 
  2. using BPA.Helper;
  3. using BPASmartClient.Model;
  4. using BPASmartClient.Peripheral;
  5. using BPASmartClient.SerialPort;
  6. using static BPA.Helper.EventBus;
  7. namespace BPASmartClient.IceMaker
  8. {
  9. public class IceMakerMachine : BasePeripheral
  10. {
  11. IceMakerHelper iceMakerHelper = new IceMakerHelper();
  12. public override void Init()
  13. {
  14. iceMakerHelper.Open(communicationPar.SerialPort, communicationPar.BaudRate);
  15. TaskManage.GetInstance.StartLong(new Action(() =>
  16. {
  17. IsConnected = iceMakerHelper.IsOpen;
  18. if (!IsConnected) IsWork = false;
  19. while (IsConnected)
  20. {
  21. IsWork = true;
  22. if (status != null)
  23. {
  24. SetStatus("MakeIceDeviceStatus", iceMakerHelper.GetDeviceStatus());
  25. SetStatus("MakeIceConnected", IsConnected);
  26. }
  27. Thread.Sleep(500);
  28. }
  29. Thread.Sleep(1000);
  30. }), $"设备[{DeviceId}]制冰机读取线程", true);
  31. EventBus.GetInstance().Subscribe<StartMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  32. {
  33. if (@event == null) return;
  34. iceMakerHelper.StartCook();
  35. });
  36. EventBus.GetInstance().Subscribe<StopMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  37. {
  38. if (@event == null) return;
  39. iceMakerHelper.EndCook();
  40. });
  41. EventBus.GetInstance().Subscribe<PumpMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  42. {
  43. if (@event == null) return;
  44. iceMakerHelper.pump();
  45. });
  46. EventBus.GetInstance().Subscribe<StandbyMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  47. {
  48. if (@event == null) return;
  49. iceMakerHelper.Standby();
  50. });
  51. EventBus.GetInstance().Subscribe<PowerOnMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  52. {
  53. if (@event == null) return;
  54. iceMakerHelper.PowerOn();
  55. });
  56. EventBus.GetInstance().Subscribe<SetIceNumber>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  57. {
  58. if (@event == null) return;
  59. var parm = @event as SetIceNumber;
  60. iceMakerHelper.IceValue(Convert.ToByte(parm?.Value));
  61. });
  62. }
  63. public override void Start()
  64. {
  65. }
  66. public override void Stop()
  67. {
  68. }
  69. public override void WriteData(string address, object value)
  70. {
  71. }
  72. protected override void InitStatus()
  73. {
  74. }
  75. }
  76. }