终端一体化运控平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

63 строки
1.9 KiB

  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. }