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

JuicerMachine.cs 1.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using BPASmartClient.EventBus;
  2. using BPASmartClient.Helper;
  3. using BPASmartClient.Model;
  4. using BPASmartClient.Peripheral;
  5. using BPASmartClient.SerialPort;
  6. using static BPASmartClient.EventBus.EventBus;
  7. namespace BPASmartClient.Juicer
  8. {
  9. public class JuicerMachine : BasePeripheral
  10. {
  11. JuicerHelper juicerHelper = new JuicerHelper();
  12. public override void Init()
  13. {
  14. juicerHelper.Open(communicationPar.SerialPort, communicationPar.BaudRate);
  15. ThreadManage.GetInstance().StartLong(new Action(() =>
  16. {
  17. IsConnected = juicerHelper.IsOpen;
  18. status["JuiceIsConnect"] = juicerHelper.IsOpen;
  19. if (!IsConnected) IsWork = false;
  20. while (IsConnected)
  21. {
  22. IsWork = true;
  23. if (status != null)
  24. {
  25. SetStatus("GetJuicerDeviceStatus", juicerHelper.GetDeviceStatus());
  26. SetStatus("GetJuicerConnected", IsConnected);
  27. }
  28. Thread.Sleep(500);
  29. }
  30. Thread.Sleep(1000);
  31. }), $"设备[{DeviceId}]果汁机读取线程", true);
  32. EventBus.EventBus.GetInstance().Subscribe<WriteJuicer>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  33. {
  34. if (@event == null) return;
  35. var par = @event as WriteJuicer;
  36. juicerHelper.StartCook(Convert.ToByte(par?.Value));
  37. });
  38. }
  39. //public override void ReadData(string address)
  40. //{
  41. //}
  42. public override void Start()
  43. {
  44. }
  45. public override void Stop()
  46. {
  47. }
  48. public override void WriteData(string address, object value)
  49. {
  50. }
  51. protected override void InitStatus()
  52. {
  53. }
  54. }
  55. }