终端一体化运控平台
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

63 righe
1.8 KiB

  1. using BPA.Helper;
  2. using BPASmartClient.Model;
  3. using BPASmartClient.Peripheral;
  4. using BPASmartClient.SerialPort;
  5. using static BPA.Helper.EventBus;
  6. namespace BPASmartClient.Juicer
  7. {
  8. public class JuicerMachine : BasePeripheral
  9. {
  10. JuicerHelper juicerHelper = new JuicerHelper();
  11. public override void Init()
  12. {
  13. juicerHelper.Open(communicationPar.SerialPort, communicationPar.BaudRate);
  14. TaskManage.GetInstance.StartLong(new Action(() =>
  15. {
  16. IsConnected = juicerHelper.IsOpen;
  17. status["JuiceIsConnect"] = 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.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. }