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

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