|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using BPASmartClient.Peripheral;
- using System;
- using BPASmartClient.Modbus;
- using BPASmartClient.Helper;
- using System.Threading;
- using BPASmartClient.Model.̲ζħ;
- using BPASmartClient.EventBus;
- using static BPASmartClient.EventBus.EventBus;
-
- namespace BPASmartClient.MilkTeaCube
- {
- public class MilkTeaCubeMachine: BasePeripheral
- {
- public ModbusTcp modbus =new ModbusTcp();
- public override void Init()
- {
- modbus.ModbusTcpConnect(communicationPar.IPAddress);
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- IsConnected = modbus.Connected;
- if (!IsConnected) IsWork = false;
- if (IsConnected)
- {
- IsWork = true;
- if (status != null)
- {
- var a = modbus.Read("LB0");
- var b = modbus.Read("LB13");
- if (a is bool[] a1 && b is bool[] b1)
- {
- SetStatus("Get_MilkTeaCubeStatus", a1[0]);
- SetStatus("Get_MilkTeaCubeDosingStatus", b1[0]);
- }
- }
- Thread.Sleep(500);
- }
- Thread.Sleep(1000);
- }), $"̲ζħ豸", true);
- EventBus.EventBus.GetInstance().Subscribe<MilkTea_MakeMilkTeaEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- var par = @event as MilkTea_MakeMilkTeaEvent;
- switch (par?.TagName)
- {
- case "Start":
- modbus.Write("LB14",true);
- break;
- case "ParameterSet":
- modbus.Write("LB14", false);
- Thread.Sleep(500);
- modbus.Write("LW1002", par.MilkTeaKind[0]);
- modbus.Write("LW1006", par.MilkTeaKind[1]);
- modbus.Write("LW1008", par.MilkTeaKind[2]);
- modbus.Write("LW1010", par.MilkTeaKind[3]);
- modbus.Write("LW1012", par.MilkTeaKind[4]);
- modbus.Write("LW1014", par.MilkTeaKind[5]);
- modbus.Write("LW1016", par.MilkTeaKind[6]);
- modbus.Write("LW1018", par.MilkTeaKind[7]);
- modbus.Write("LW1020", par.MilkTeaKind[8]);
- modbus.Write("LW1022", par.MilkTeaKind[9]);
- modbus.Write("LW1024", par.MilkTeaKind[10]);
- modbus.Write("LW1026", par.MilkTeaKind[11]);
-
- break;
- case "StartSignReset":
- modbus.Write("LB14", false);
- break;
- default:
- break;
- }
- });
- }
- public override void Start()
- {
- }
-
- public override void Stop()
- {
- }
-
- public override void WriteData(string address, object value)
- {
-
- }
-
- protected override void InitStatus()
- {
- }
- }
- }
|