- .NET API: IedConnection - added new method GetLogicalDeviceVariablesAsync and property MaxPduSize

pull/93/head
Michael Zillgith 7 years ago
parent 0ff713b7f1
commit 916f9da92e

@ -414,6 +414,12 @@ namespace IEC61850
IedConnection_getServerDirectoryAsync(IntPtr self, out int error, string continueAfter, IntPtr result,
IedConnection_GetNameListHandler handler, IntPtr parameter);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern UInt32
IedConnection_getLogicalDeviceVariablesAsync(IntPtr self, out int error, string ldName, string continueAfter, IntPtr result,
IedConnection_GetNameListHandler handler, IntPtr parameter);
/********************
* FileDirectoryEntry
*********************/
@ -522,7 +528,8 @@ namespace IEC61850
/// Gets or sets the timeout used for connection attempts.
/// </summary>
/// <value>The connect timeout in milliseconds</value>
public UInt32 ConnectTimeout {
public UInt32 ConnectTimeout
{
get {
return connectTimeout;
}
@ -531,6 +538,20 @@ namespace IEC61850
}
}
/// <summary>
/// Gets or sets the maximum size if a PDU (has to be set before calling connect!).
/// </summary>
/// <value>The maximum allowed size of an MMS PDU.</value>
public int MaxPduSize
{
get {
return GetMmsConnection().GetLocalDetail();
}
set {
GetMmsConnection().SetLocalDetail(value);
}
}
public MmsConnection GetMmsConnection ()
{
@ -1645,6 +1666,30 @@ namespace IEC61850
throw new IedConnectionException("Get server directory failed", error);
}
return invokeId;
}
public UInt32 GetLogicalDeviceVariablesAsync(string ldName, string continueAfter, GetNameListHandler handler, object parameter)
{
return GetLogicalDeviceVariablesAsync(null, ldName, continueAfter, handler, parameter);
}
public UInt32 GetLogicalDeviceVariablesAsync(List<string> result, string ldName, string continueAfter, GetNameListHandler handler, object parameter)
{
int error;
Tuple<GetNameListHandler, object, List<string>> callbackInfo = Tuple.Create(handler, parameter, result);
GCHandle handle = GCHandle.Alloc(callbackInfo);
UInt32 invokeId = IedConnection_getLogicalDeviceVariablesAsync(connection, out error, ldName, continueAfter, IntPtr.Zero, nativeGetNameListHandler, GCHandle.ToIntPtr(handle));
if (error != 0)
{
handle.Free();
throw new IedConnectionException("Get logical device variables failed", error);
}
return invokeId;
}

@ -2,6 +2,7 @@
using IEC61850.Client;
using IEC61850.Common;
using System.Threading;
using System.Collections.Generic;
namespace client_example_async
{
@ -28,8 +29,84 @@ namespace client_example_async
try
{
con.MaxPduSize = 1000;
con.Connect(hostname, port);
AutoResetEvent waitForCallback = new AutoResetEvent(false);
List<string> ldList = null;
con.GetServerDirectoryAsync(ldList, null, delegate(uint invokeId, object parameter, IedClientError err, System.Collections.Generic.List<string> nameList, bool moreFollows) {
if (nameList != null) {
ldList = nameList;
}
else
{
Console.WriteLine("Get server directory error: " + err.ToString());
}
waitForCallback.Set();
}, null);
waitForCallback.WaitOne();
if (ldList != null) {
string firstLdName = null;
Console.WriteLine("Server directory:");
foreach (string ldName in ldList) {
Console.WriteLine(" LD: " + ldName);
if (firstLdName == null)
firstLdName = ldName;
}
bool moreVariabesFollows = true;
string lastVariableName = null;
List<string> variablesList = new List<string>();
while (moreVariabesFollows) {
waitForCallback.Reset();
con.GetLogicalDeviceVariablesAsync(variablesList, firstLdName, lastVariableName, delegate(uint invokeId, object parameter, IedClientError err, List<string> nameList, bool moreFollows) {
if (nameList != null) {
if (moreFollows)
Console.WriteLine("More variables available...");
lastVariableName = nameList[nameList.Count - 1];
}
else
{
Console.WriteLine("Get logical device variables error: " + err.ToString());
}
moreVariabesFollows = moreFollows;
waitForCallback.Set();
}, null);
waitForCallback.WaitOne();
}
Console.WriteLine("Variables in logical device {0}:", firstLdName);
foreach (string variableName in variablesList) {
Console.WriteLine(" {0}", variableName);
}
}
Console.WriteLine("Now read variables...");
/* read FCDO */
con.ReadValueAsync("simpleIOGenericIO/GGIO1.AnIn1", FunctionalConstraint.MX, delegate(uint invokeId, object parameter, IedClientError err, MmsValue value) {
@ -81,8 +158,7 @@ namespace client_example_async
}, null);
// Thread.Sleep(5000);
Thread.Sleep(5000);
con.Abort();
}

@ -28,7 +28,7 @@ namespace example3
con.ConnectTimeout = 10000;
con.GetMmsConnection().SetLocalDetail(1200);
con.MaxPduSize = 1200;
con.Connect(hostname, 102);

Loading…
Cancel
Save