You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- 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<CommunicationPar>.Read();
- foreach (var item in Json<CommunicationPar>.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;
- }
- }
- }
- }
- ActionOperate.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk");
- }
-
- }
- }
|