|
-
- using BPA.Helper;
- using BPASmartClient.Model;
- using BPASmartClient.Peripheral;
- using BPASmartClient.SerialPort;
- using static BPA.Helper.EventBus;
-
- namespace BPASmartClient.IceMaker
- {
- public class IceMakerMachine : BasePeripheral
- {
- IceMakerHelper iceMakerHelper = new IceMakerHelper();
- public override void Init()
- {
- iceMakerHelper.Open(communicationPar.SerialPort, communicationPar.BaudRate);
-
- TaskManage.GetInstance.StartLong(new Action(() =>
- {
- IsConnected = iceMakerHelper.IsOpen;
- if (!IsConnected) IsWork = false;
- while (IsConnected)
- {
- IsWork = true;
- if (status != null)
- {
- SetStatus("MakeIceDeviceStatus", iceMakerHelper.GetDeviceStatus());
- SetStatus("MakeIceConnected", IsConnected);
- }
- Thread.Sleep(500);
- }
- Thread.Sleep(1000);
- }), $"设备[{DeviceId}]制冰机读取线程", true);
-
- EventBus.GetInstance.Subscribe<StartMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- iceMakerHelper.StartCook();
- });
- EventBus.GetInstance.Subscribe<StopMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- iceMakerHelper.EndCook();
- });
- EventBus.GetInstance.Subscribe<PumpMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- iceMakerHelper.pump();
- });
- EventBus.GetInstance.Subscribe<StandbyMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- iceMakerHelper.Standby();
- });
- EventBus.GetInstance.Subscribe<PowerOnMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- iceMakerHelper.PowerOn();
- });
- EventBus.GetInstance.Subscribe<SetIceNumber>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- var parm = @event as SetIceNumber;
- iceMakerHelper.IceValue(Convert.ToByte(parm?.Value));
- });
- }
-
- public override void Start()
- {
- }
-
- public override void Stop()
- {
- }
-
- public override void WriteData(string address, object value)
- {
- }
-
- protected override void InitStatus()
- {
- }
- }
- }
|