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.

ConnectHelper.cs 2.3 KiB

2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using HBLConsole.Service;
  7. using HBLConsole.Model;
  8. namespace HBLConsole.Communication
  9. {
  10. public class ConnectHelper
  11. {
  12. private volatile static ConnectHelper _Instance;
  13. public static ConnectHelper GetInstance => _Instance ?? (_Instance = new ConnectHelper());
  14. private ConnectHelper() { }
  15. public void Init()
  16. {
  17. Json<CommunicationPar>.Read();
  18. foreach (var item in Json<CommunicationPar>.Data.communicationSets)
  19. {
  20. //if (item.ClientDeviceType == GVL.GeneralConfig.DeviceType.ToString())
  21. //{
  22. if (item.IsActive)
  23. {
  24. switch (item.deviceType)
  25. {
  26. case EDeviceType.Siemens:
  27. break;
  28. case EDeviceType.ModbusRtu:
  29. if (item.Device is ModbusRtu rtu)
  30. {
  31. //咖啡机主控程序
  32. //private CoffeeMachine coffeeMachine;
  33. ////冰淇淋主控程序
  34. //private IceCreamMachine iceCreamMachine;
  35. }
  36. break;
  37. case EDeviceType.ModbusTcp:
  38. if (item.Device is ModbusTcp modbus)
  39. {
  40. ModbusTcpHelper.GetInstance.ModbusTcpConnect(modbus.IP, modbus.PortNum);
  41. }
  42. break;
  43. case EDeviceType.SerialPort:
  44. break;
  45. case EDeviceType.Lebai:
  46. if (item.Device is ModbusTcp tcp)
  47. {
  48. LebaiHelper.GetInstance.Connect(tcp.IP);
  49. }
  50. break;
  51. default:
  52. break;
  53. }
  54. //}
  55. }
  56. }
  57. ActionManage.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk");
  58. }
  59. }
  60. }