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

62 rivejä
1.8 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. if (!IsConnected) IsWork = false;
  19. while (IsConnected)
  20. {
  21. IsWork = true;
  22. if (status != null)
  23. {
  24. SetStatus("GetJuicerDeviceStatus", juicerHelper.GetDeviceStatus());
  25. SetStatus("GetJuicerConnected", IsConnected);
  26. }
  27. Thread.Sleep(500);
  28. }
  29. Thread.Sleep(1000);
  30. }), $"设备[{DeviceId}]果汁机读取线程", true);
  31. EventBus.EventBus.GetInstance().Subscribe<WriteJuicer>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  32. {
  33. if (@event == null) return;
  34. var par = @event as WriteJuicer;
  35. juicerHelper.StartCook(Convert.ToByte(par?.Value));
  36. });
  37. }
  38. //public override void ReadData(string address)
  39. //{
  40. //}
  41. public override void Start()
  42. {
  43. }
  44. public override void Stop()
  45. {
  46. }
  47. public override void WriteData(string address, object value)
  48. {
  49. }
  50. protected override void InitStatus()
  51. {
  52. }
  53. }
  54. }