终端一体化运控平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

63 rader
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. status["JuiceIsConnect"] = juicerHelper.IsOpen;
  19. if (!IsConnected) IsWork = false;
  20. while (IsConnected)
  21. {
  22. IsWork = true;
  23. if (status != null)
  24. {
  25. SetStatus("GetDeviceStatus", juicerHelper.GetDeviceStatus());
  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. }