using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using HBLConsole.Service; using HBLConsole.Model; namespace HBLConsole.Communication { public class ConnectHelper { private volatile static ConnectHelper _Instance; public static ConnectHelper GetInstance => _Instance ?? (_Instance = new ConnectHelper()); private ConnectHelper() { } public void Init() { Json.Read(); foreach (var item in Json.Data.communicationSets) { //if (item.ClientDeviceType == GVL.GeneralConfig.DeviceType.ToString()) //{ if (item.IsActive) { switch (item.deviceType) { case EDeviceType.Siemens: break; case EDeviceType.ModbusRtu: if (item.Device is ModbusRtu rtu) { //咖啡机主控程序 //private CoffeeMachine coffeeMachine; ////冰淇淋主控程序 //private IceCreamMachine iceCreamMachine; } break; case EDeviceType.ModbusTcp: if (item.Device is ModbusTcp modbus) { ModbusTcpHelper.GetInstance.ModbusTcpConnect(modbus.IP, modbus.PortNum); } break; case EDeviceType.SerialPort: break; case EDeviceType.Lebai: if (item.Device is ModbusTcp tcp) { LebaiHelper.GetInstance.Connect(tcp.IP); } break; default: break; } //} } } ActionManage.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk"); } } }