更换通讯库版本
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using HslCommunication;
|
||||
using HslCommunication.Core;
|
||||
using HslCommunication.Profinet.Omron;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -345,6 +346,11 @@ namespace PLCCommunication
|
||||
|
||||
omronFinsNet.IpAddress = address.ToString();
|
||||
omronFinsNet.Port = 9600;
|
||||
omronFinsNet.DA2 = 0;
|
||||
omronFinsNet.ByteTransform.DataFormat = DataFormat.CDAB;
|
||||
omronFinsNet.ByteTransform.IsStringReverseByteWord = true;
|
||||
omronFinsNet.ConnectTimeOut = 2000;
|
||||
omronFinsNet.ReceiveTimeOut = 2000;
|
||||
omronFinsNet.ConnectClose();
|
||||
|
||||
try
|
||||
@@ -358,6 +364,10 @@ namespace PLCCommunication
|
||||
BtnConnect.Enabled = false;
|
||||
str = StringResources.Language.ConnectedSuccess;
|
||||
AddLog(lstRecv, 0, StringResources.Language.ConnectedSuccess);
|
||||
|
||||
omronFinsNet.ConnectTimeOut = 2000;
|
||||
OperateResult connectFins = omronFinsNet.ConnectServer();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -366,10 +376,6 @@ namespace PLCCommunication
|
||||
str = StringResources.Language.ConnectedFailed;
|
||||
AddLog(lstRecv,1, StringResources.Language.ConnectedFailed);
|
||||
}
|
||||
|
||||
|
||||
omronFinsNet.ConnectTimeOut = 2000;
|
||||
OperateResult connectFins = omronFinsNet.ConnectServer();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -966,6 +972,7 @@ namespace PLCCommunication
|
||||
if (IsConnected)
|
||||
{
|
||||
result = omronFinsNet.Read(iAddr, length).Content;
|
||||
OperateResult barray = omronFinsNet.ReadBool(iAddr, length);
|
||||
AddLog(lstResWrite, 0, $"{iAddr} --> {result?.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user