2014-12-01 10:34:45 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using IEC61850.Client;
|
|
|
|
using IEC61850.Common;
|
|
|
|
|
|
|
|
namespace example1
|
|
|
|
{
|
|
|
|
class MainClass
|
|
|
|
{
|
|
|
|
public static void Main (string[] args)
|
|
|
|
{
|
|
|
|
IedConnection con = new IedConnection ();
|
|
|
|
|
|
|
|
string hostname;
|
|
|
|
|
|
|
|
if (args.Length > 0)
|
|
|
|
hostname = args[0];
|
|
|
|
else
|
2017-01-17 21:13:05 +01:00
|
|
|
hostname = "127.0.0.1";
|
|
|
|
|
|
|
|
int port = 102;
|
|
|
|
|
|
|
|
if (args.Length > 1)
|
|
|
|
port = Int32.Parse(args [1]);
|
2014-12-01 10:34:45 +01:00
|
|
|
|
|
|
|
Console.WriteLine("Connect to " + hostname);
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2017-01-17 21:13:05 +01:00
|
|
|
con.Connect(hostname, port);
|
2014-12-01 10:34:45 +01:00
|
|
|
|
|
|
|
List<string> serverDirectory = con.GetServerDirectory(false);
|
|
|
|
|
|
|
|
foreach (string entry in serverDirectory)
|
|
|
|
{
|
|
|
|
Console.WriteLine("LD: " + entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<string> lnDirectory = con.GetLogicalNodeDirectory("simpleIOGenericIO/LLN0", ACSIClass.ACSI_CLASS_DATA_SET);
|
|
|
|
|
|
|
|
foreach (string entry in lnDirectory)
|
|
|
|
{
|
|
|
|
Console.WriteLine("Dataset: " + entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
string vendor = con.ReadStringValue ("simpleIOGenericIO/LLN0.NamPlt.vendor", FunctionalConstraint.DC);
|
|
|
|
Console.WriteLine ("Vendor: " + vendor);
|
|
|
|
|
|
|
|
/* read FCDO */
|
|
|
|
MmsValue value = con.ReadValue("simpleIOGenericIO/GGIO1.AnIn1", FunctionalConstraint.MX);
|
|
|
|
|
|
|
|
if (value.GetType() == MmsType.MMS_STRUCTURE)
|
|
|
|
{
|
|
|
|
Console.WriteLine("Value is of complex type");
|
|
|
|
|
|
|
|
for (int i = 0; i < value.Size(); i++)
|
|
|
|
{
|
|
|
|
Console.WriteLine(" element: " + value.GetElement(i).GetType());
|
|
|
|
if (value.GetElement(i).GetType() == MmsType.MMS_UTC_TIME)
|
|
|
|
{
|
|
|
|
Console.WriteLine(" -> " + value.GetElement(i).GetUtcTimeAsDateTimeOffset());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DataSet dataSet = con.ReadDataSetValues("simpleIOGenericIO/LLN0.Events", null);
|
|
|
|
|
|
|
|
Console.WriteLine("Read data set " + dataSet.GetReference());
|
|
|
|
|
|
|
|
con.Abort();
|
|
|
|
}
|
|
|
|
catch (IedConnectionException e)
|
|
|
|
{
|
|
|
|
Console.WriteLine(e.Message);
|
|
|
|
}
|
|
|
|
|
2015-10-27 17:13:00 +01:00
|
|
|
System.Threading.Thread.Sleep(2000);
|
|
|
|
|
|
|
|
// release all resources - do NOT use the object after this call!!
|
|
|
|
con.Dispose ();
|
2014-12-01 10:34:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|