增加报警信息代码
This commit is contained in:
@@ -64,6 +64,8 @@ namespace PLCCommunication
|
||||
/// 欧姆龙Fins协议
|
||||
/// </summary>
|
||||
public HslCommunication.Profinet.Omron.OmronCipNet omronCipNet = null;
|
||||
|
||||
public HslCommunication.Profinet.Omron.OmronFinsNet omronFinsNet = null;
|
||||
/// <summary>
|
||||
/// 是否链接PLC
|
||||
/// </summary>
|
||||
@@ -198,6 +200,10 @@ namespace PLCCommunication
|
||||
InitializeComponent();
|
||||
omronCipNet = new OmronCipNet();
|
||||
omronCipNet.ConnectTimeOut = 2000;
|
||||
|
||||
omronFinsNet = new OmronFinsNet();
|
||||
omronFinsNet.ConnectTimeOut = 2000;
|
||||
|
||||
PanelTest.Enabled = false;
|
||||
}
|
||||
|
||||
@@ -336,6 +342,11 @@ namespace PLCCommunication
|
||||
omronCipNet.Port = port;
|
||||
omronCipNet.Slot = solt;
|
||||
omronCipNet.ConnectClose();
|
||||
|
||||
omronFinsNet.IpAddress = address.ToString();
|
||||
omronFinsNet.Port = 9600;
|
||||
omronFinsNet.ConnectClose();
|
||||
|
||||
try
|
||||
{
|
||||
omronCipNet.ConnectTimeOut = 2000;
|
||||
@@ -355,7 +366,10 @@ namespace PLCCommunication
|
||||
str = StringResources.Language.ConnectedFailed;
|
||||
AddLog(lstRecv,1, StringResources.Language.ConnectedFailed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
omronFinsNet.ConnectTimeOut = 2000;
|
||||
OperateResult connectFins = omronFinsNet.ConnectServer();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -939,6 +953,30 @@ namespace PLCCommunication
|
||||
return result;
|
||||
}
|
||||
|
||||
public byte[] ReadByteFins(string iAddr, ushort length)
|
||||
{
|
||||
byte[] result = null;
|
||||
try
|
||||
{
|
||||
//string type = iAddr.Substring(0, 1);
|
||||
//if (type != "D" && type != "R")
|
||||
//{
|
||||
// AddLog(lstSend, 2, "暂只支持D,R存储区");
|
||||
//}
|
||||
if (IsConnected)
|
||||
{
|
||||
result = omronFinsNet.Read(iAddr, length).Content;
|
||||
AddLog(lstResWrite, 0, $"{iAddr} --> {result?.ToString()}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog(lstResWrite, 2, $"{iAddr} --> {ex.Message}");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入byte数组
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user