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; 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(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() { } } }