- .NET API: Added support for functional naming to LogicalDevice

v1.6_develop_rgoose_sntp
Michael Zillgith 3 years ago
parent 6b23f87b23
commit 0865b6fd99

@ -299,40 +299,70 @@ namespace IEC61850
} }
/// <summary>
/// Logical device. Representation of a logical device (LD) in a data model.
/// </summary>
public class LogicalDevice : ModelNode public class LogicalDevice : ModelNode
{ {
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr LogicalDevice_create(string name, IntPtr parent); static extern IntPtr LogicalDevice_create(string name, IntPtr parent);
private IedModel iedModel = null; [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr LogicalDevice_createEx(string name, IntPtr parent, string ldName);
public IedModel IedModel { get => iedModel; } public IedModel IedModel { get; }
public LogicalDevice (IntPtr self, IedModel iedModel) : base (self) public LogicalDevice (IntPtr self, IedModel iedModel) : base (self)
{ {
this.iedModel = iedModel; this.IedModel = iedModel;
} }
public LogicalDevice(string name, IedModel parent) /// <summary>
/// Create a new logical device in a data model
/// </summary>
/// <param name="inst">LD instance</param>
/// <param name="parent">Model containing this logical device</param>
public LogicalDevice(string inst, IedModel parent)
{ {
this.iedModel = parent; this.IedModel = parent;
self = LogicalDevice_create(name, parent.self); self = LogicalDevice_create(inst, parent.self);
}
/// <summary>
/// Create a new logical device in a data model (support for functional naming)
/// </summary>
/// <param name="inst">LD instance</param>
/// <param name="parent">Model containing this logical device</param>
/// <param name="ldName">LD name (for functional naming). When set, the exernally visible domain name for this LD</param>
public LogicalDevice(string inst, IedModel parent, string ldName)
{
this.IedModel = parent;
self = LogicalDevice_createEx(inst, parent.self, ldName);
} }
} }
/// <summary>
/// Logical node. Representation of a logical node (LN) in a data model.
/// </summary>
public class LogicalNode : ModelNode public class LogicalNode : ModelNode
{ {
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr LogicalNode_create(string name, IntPtr parent); static extern IntPtr LogicalNode_create(string name, IntPtr parent);
internal Dictionary<IntPtr, ReportControlBlock> rcbs = new Dictionary<IntPtr, ReportControlBlock>();
public LogicalNode (IntPtr self, ModelNode parent) : base(self) public LogicalNode (IntPtr self, ModelNode parent) : base(self)
{ {
this.parent = parent; this.parent = parent;
} }
internal Dictionary<IntPtr, ReportControlBlock> rcbs = new Dictionary<IntPtr, ReportControlBlock>(); /// <summary>
/// Initializes a new instance of the <see cref="T:IEC61850.Server.LogicalNode"/> class.
/// </summary>
/// <param name="name">LN name</param>
/// <param name="parent">Logical device containing this logical node.</param>
public LogicalNode(string name, LogicalDevice parent) public LogicalNode(string name, LogicalDevice parent)
{ {
this.parent = parent; this.parent = parent;

@ -12,6 +12,27 @@ namespace model_browsing
{ {
class ModelBrowsing class ModelBrowsing
{ {
private static void PrintChildSpec(MmsVariableSpecification spec, int indent)
{
string indentStr = "";
for (int i = 0; i < indent; i++)
indentStr += " ";
if (spec.GetType() == MmsType.MMS_STRUCTURE)
{
foreach (MmsVariableSpecification elementSpec in spec)
{
Console.WriteLine(indentStr + "DA: " + elementSpec.GetName() + " : " + elementSpec.GetType());
if (elementSpec.GetType() == MmsType.MMS_STRUCTURE || elementSpec.GetType() == MmsType.MMS_ARRAY)
{
PrintChildSpec(elementSpec, indent + 2);
}
}
}
}
public static void Main (string[] args) public static void Main (string[] args)
{ {
IedConnection con = new IedConnection (); IedConnection con = new IedConnection ();
@ -73,10 +94,21 @@ namespace model_browsing
ObjectReference.getElementName(dataDirectoryElement) + " : " + specification.GetType() ObjectReference.getElementName(dataDirectoryElement) + " : " + specification.GetType()
+ "(" + specification.Size() + ")"); + "(" + specification.Size() + ")");
if (specification.GetType() == MmsType.MMS_STRUCTURE) { if (specification.GetType() == MmsType.MMS_STRUCTURE)
foreach (MmsVariableSpecification elementSpec in specification) { {
Console.WriteLine(" " + elementSpec.GetName() + " : " + elementSpec.GetType()); foreach (MmsVariableSpecification elementSpec in specification)
{
PrintChildSpec(elementSpec, 8);
//Console.WriteLine(" " + elementSpec.GetName() + " : " + elementSpec.GetType());
} }
}
else if (specification.GetType() == MmsType.MMS_ARRAY)
{
MmsVariableSpecification arrayElementspec = specification.getArrayElementType();
PrintChildSpec(arrayElementspec, 8);
//Console.WriteLine(" elements: " + arrayElementspec.GetType());
} }
} }

Loading…
Cancel
Save