| | |
| | | { |
| | | #region 连接PLC |
| | | Assembly assembly = Assembly.Load($"WIDESEAWCS_Communicator"); |
| | | Type type = assembly.GetType($"WIDESEAWCS_Communicator.{x.DevicePlcType}"); |
| | | object obj = Activator.CreateInstance(type, new object[] { x.DeviceIp, x.DevicePort, x.DeviceName }); |
| | | bool connectResult = (bool)type.InvokeMember("Connect", BindingFlags.Default | BindingFlags.InvokeMethod, null, obj, new object[] { }); |
| | | if (connectResult) ConsoleHelper.WriteSuccessLine(x.DeviceCode + "连接成功"); else ConsoleHelper.WriteErrorLine(x.DeviceCode + "连接失败"); |
| | | Type? type = assembly.GetType($"WIDESEAWCS_Communicator.{x.DevicePlcType}"); |
| | | object? obj = Activator.CreateInstance(type, new object[] { x.DeviceIp, x.DevicePort, x.DeviceName }); |
| | | bool? connectResult = (bool)type.InvokeMember("Connect", BindingFlags.Default | BindingFlags.InvokeMethod, null, obj, new object[] { }); |
| | | if (connectResult ?? false) ConsoleHelper.WriteSuccessLine(x.DeviceCode + "连接成功"); else ConsoleHelper.WriteErrorLine(x.DeviceCode + "连接失败"); |
| | | |
| | | #endregion |
| | | |