Example #1
0
 public void ConnectToPlc()
 {
     _deviceDriver?.ConnectClose();
     _deviceDriver?.Dispose();
     _deviceDriver = new ModbusTcpNet(_device.Ip, _device.Port, _device.Station);
     _deviceDriver.AddressStartWithZero = true;  //首地址从0开始
     _deviceDriver.DataFormat           = HslCommunication.Core.DataFormat.ABCD;
     _deviceDriver.IsStringReverse      = false; //字符串跌倒
     _deviceDriver.SetPersistentConnection();
     //OperateResult res= _deviceDriver.ConnectServer();
     //if(res.IsSuccess)
     //{
     //    _log.WriteLog($"{_device.Name}{_device.Ip}连接成功");
     //}
     //else
     //{
     //    _log.WriteLog($"{_device.Name}{_device.Ip}连接失败");
     //}
     //_device.IsConnected = res.IsSuccess;
 }