|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using BPASmartClient.EventBus;
- using BPASmartClient.Helper;
- using BPASmartClient.Model;
- using BPASmartClient.Peripheral;
- using BPASmartClient.SerialPort;
- using static BPASmartClient.EventBus.EventBus;
-
- namespace BPASmartClient.Juicer
- {
- public class JuicerMachine : BasePeripheral
- {
- JuicerHelper juicerHelper = new JuicerHelper();
- public override void Init()
- {
- juicerHelper.Open(communicationPar.SerialPort, communicationPar.BaudRate);
-
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- IsConnected = juicerHelper.IsOpen;
- status["JuiceIsConnect"] = juicerHelper.IsOpen;
- if (!IsConnected) IsWork = false;
- while (IsConnected)
- {
- IsWork = true;
- if (status != null)
- {
- SetStatus("GetJuicerDeviceStatus", juicerHelper.GetDeviceStatus());
- SetStatus("GetJuicerConnected", IsConnected);
- }
- Thread.Sleep(500);
- }
- Thread.Sleep(1000);
- }), $"设备[{DeviceId}]果汁机读取线程", true);
-
- EventBus.EventBus.GetInstance().Subscribe<WriteJuicer>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- var par = @event as WriteJuicer;
- juicerHelper.StartCook(Convert.ToByte(par?.Value));
- });
- }
-
- //public override void ReadData(string address)
- //{
- //}
-
- public override void Start()
- {
- }
-
- public override void Stop()
- {
- }
-
- public override void WriteData(string address, object value)
- {
- }
-
- protected override void InitStatus()
- {
- }
- }
- }
|