/// <summary> /// Create a new MmsValue instance of type MMS_ARRAY. Array elements have the fiven type /// </summary> /// <returns>the newly created array</returns> /// <param name="elementType">array element type</param> /// <param name="size">number of array elements</param> public static MmsValue NewArray(MmsVariableSpecification elementType, int size) { if (size < 1) { throw new MmsValueException("array requires at least one element"); } IntPtr newValue = MmsValue_createArray(elementType.self, size); return(new MmsValue(newValue, true)); }
/// <summary> /// Gets the type of the array elements. /// </summary> /// <returns> /// The array element type. /// </returns> /// <exception cref="MmsValueException">This exception is thrown if the value is not of type MMS_ARRAY</exception> public MmsVariableSpecification getArrayElementType() { if (GetType() == MmsType.MMS_ARRAY) { IntPtr varSpecPtr = MmsVariableSpecification.MmsVariableSpecification_getArrayElementSpecification(self); return(new MmsVariableSpecification(varSpecPtr, this)); } else { throw new MmsValueException("specification is of wrong type"); } }
/// <summary> /// Gets the child value with the given name /// </summary> /// <returns>the child value or null if no matching child has been found.</returns> /// <param name="childPath">path specifying the child using '.' or '$' as path element separator.</param> /// <param name="specification">the variable specification to use.</param> public MmsValue GetChildValue(string childPath, MmsVariableSpecification specification) { StringBuilder childPathStr = new StringBuilder(childPath); childPathStr.Replace('.', '$'); IntPtr childPtr = MmsVariableSpecification_getChildValue(specification.self, valueReference, childPathStr.ToString()); if (childPtr == IntPtr.Zero) { return(null); } else { return(new MmsValue(childPtr)); } }
public static void Main(string[] args) { Console.WriteLine("Hello World!"); IedConnection con = new IedConnection(); string hostname; if (args.Length > 0) { hostname = args[0]; } else { hostname = "127.0.0.1"; } int port = 102; if (args.Length > 1) { port = Int32.Parse(args [1]); } Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, port); /* Get variable specification of the SGCB (optional) */ MmsVariableSpecification sgcbVarSpec = con.GetVariableSpecification("DEMOPROT/LLN0.SGCB", FunctionalConstraint.SP); /* Read SGCB */ MmsValue sgcbVal = con.ReadValue("DEMOPROT/LLN0.SGCB", FunctionalConstraint.SP); Console.WriteLine("NumOfSG: {0}", sgcbVal.GetChildValue("NumOfSG", sgcbVarSpec).ToString()); Console.WriteLine("ActSG: {0}", sgcbVal.GetChildValue("ActSG", sgcbVarSpec).ToString()); Console.WriteLine("EditSG: {0}", sgcbVal.GetChildValue("EditSG", sgcbVarSpec).ToString()); Console.WriteLine("CnfEdit: {0}", sgcbVal.GetChildValue("CnfEdit", sgcbVarSpec).ToString()); /* Set active setting group */ con.WriteValue("DEMOPROT/LLN0.SGCB.ActSG", FunctionalConstraint.SP, new MmsValue((uint)2)); /* Set edit setting group */ con.WriteValue("DEMOPROT/LLN0.SGCB.EditSG", FunctionalConstraint.SP, new MmsValue((uint)1)); /* Change a setting group value */ con.WriteValue("DEMOPROT/PTOC1.StrVal.setMag.f", FunctionalConstraint.SE, new MmsValue(1.0f)); /* Confirm new setting group values */ con.WriteValue("DEMOPROT/LLN0.SGCB.CnfEdit", FunctionalConstraint.SP, new MmsValue(true)); /* Read SGCB again */ sgcbVal = con.ReadValue("DEMOPROT/LLN0.SGCB", FunctionalConstraint.SP); Console.WriteLine("ActSG: {0}", sgcbVal.GetChildValue("ActSG", sgcbVarSpec).ToString()); con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } // release all resources - do NOT use the object after this call!! con.Dispose(); }
public MmsVariableSpecificationEnumerator(MmsVariableSpecification value) { this.value = value; }
internal MmsVariableSpecification(IntPtr self, MmsVariableSpecification parent) { this.self = self; this.responsableForDeletion = false; this.parent = parent; }
public static void Main(string[] args) { IedConnection con = new IedConnection(); string hostname; if (args.Length > 0) { hostname = args[0]; } else { hostname = "localhost"; } try { Console.WriteLine("Connect to " + hostname + " ..."); con.Connect(hostname, 102); Console.WriteLine("Connected."); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string ldName in serverDirectory) { Console.WriteLine("LD: " + ldName); List <string> lnNames = con.GetLogicalDeviceDirectory(ldName); foreach (string lnName in lnNames) { Console.WriteLine(" LN: " + lnName); string logicalNodeReference = ldName + "/" + lnName; // discover data objects List <string> dataObjects = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_DATA_OBJECT); foreach (string dataObject in dataObjects) { Console.WriteLine(" DO: " + dataObject); List <string> dataDirectory = con.GetDataDirectoryFC(logicalNodeReference + "." + dataObject); foreach (string dataDirectoryElement in dataDirectory) { string daReference = logicalNodeReference + "." + dataObject + "." + ObjectReference.getElementName(dataDirectoryElement); // get the type specification of a variable MmsVariableSpecification specification = con.GetVariableSpecification(daReference, ObjectReference.getFC(dataDirectoryElement)); Console.WriteLine(" DA/SDO: [" + ObjectReference.getFC(dataDirectoryElement) + "] " + ObjectReference.getElementName(dataDirectoryElement) + " : " + specification.GetType() + "(" + specification.Size() + ")"); if (specification.GetType() == MmsType.MMS_STRUCTURE) { foreach (MmsVariableSpecification elementSpec in specification) { Console.WriteLine(" " + elementSpec.GetName() + " : " + elementSpec.GetType()); } } } } // discover data sets List <string> dataSets = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_DATA_SET); foreach (string dataSet in dataSets) { Console.WriteLine(" Dataset: " + dataSet); } // discover unbuffered report control blocks List <string> urcbs = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_URCB); foreach (string urcb in urcbs) { Console.WriteLine(" URCB: " + urcb); } // discover buffered report control blocks List <string> brcbs = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_BRCB); foreach (string brcb in brcbs) { Console.WriteLine(" BRCB: " + brcb); } } } con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } }