コード例 #1
0
            /// <summary>Write the value of a data attribute (DA) or functional constraint data object (FCDO).</summary>
            /// <description>This function can be used to write simple or complex variables (setpoints, parameters, descriptive values...)
            /// of the server.</description>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <param name="value">MmsValue object representing asimple or complex variable data</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public void WriteValue(string objectReference, FunctionalConstraint fc, MmsValue value)
            {
                int error;

                IedConnection_writeObject(connection, out error, objectReference, (int)fc, value.valueReference);

                if (error != 0)
                {
                    throw new IedConnectionException("Write value failed", error);
                }
            }
コード例 #2
0
            /// <summary>Read the value of a basic data attribute (BDA) of type boolean.</summary>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <returns>the received boolean value</returns>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public bool ReadBooleanValue(string objectReference, FunctionalConstraint fc)
            {
                var mmsValue = ReadValue(objectReference, fc);

                if (mmsValue.GetType() == MmsType.MMS_BOOLEAN)
                {
                    return(mmsValue.GetBoolean());
                }
                else
                {
                    throw new IedConnectionException("Result is not of type timestamp (MMS_UTC_TIME)", 0);
                }
            }
コード例 #3
0
            /// <summary>Read the value of a basic data attribute (BDA) of type timestamp (MMS_UTC_TIME).</summary>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public UInt64 ReadTimestampValue(string objectReference, FunctionalConstraint fc)
            {
                var mmsValuePtr = readObjectInternal(objectReference, fc);

                var mmsValue = new MmsValue(mmsValuePtr, true);

                if (mmsValue.GetType() == MmsType.MMS_UTC_TIME)
                {
                    return(mmsValue.GetUtcTimeInMs());
                }
                else
                {
                    throw new IedConnectionException("Result is not of type timestamp (MMS_UTC_TIME)", 0);
                }
            }
コード例 #4
0
            /// <summary>Read the value of a basic data attribute (BDA) of type float.</summary>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public float ReadFloatValue(string objectReference, FunctionalConstraint fc)
            {
                IntPtr mmsValue = readObjectInternal(objectReference, fc);

                if (MmsValue_getType(mmsValue) != (int)MmsType.MMS_FLOAT)
                {
                    throw new IedConnectionException("Result is not of type float", 0);
                }

                float value = MmsValue_toFloat(mmsValue);

                MmsValue_delete(mmsValue);

                return(value);
            }
コード例 #5
0
            /// <summary>Read the value of a basic data attribute (BDA) of type integer (MMS_INTEGER).</summary>
            /// <description>This function should also be used if enumerations are beeing read. Because
            /// enumerations are mapped to integer types for the MMS mapping</description>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public Int64 ReadIntegerValue(string objectReference, FunctionalConstraint fc)
            {
                var mmsValuePtr = readObjectInternal(objectReference, fc);

                var mmsValue = new MmsValue(mmsValuePtr, true);

                if (mmsValue.GetType() == MmsType.MMS_INTEGER)
                {
                    return(mmsValue.ToInt64());
                }
                else
                {
                    throw new IedConnectionException("Result is not of type integer (MMS_INTEGER)", 0);
                }
            }
コード例 #6
0
            /// <summary>Read the value of a basic data attribute (BDA) of type quality.</summary>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public Quality ReadQualityValue(string objectReference, FunctionalConstraint fc)
            {
                IntPtr mmsValue = readObjectInternal(objectReference, fc);

                if (MmsValue_getType(mmsValue) == (int)MmsType.MMS_BIT_STRING)
                {
                    int bitStringValue = (int)MmsValue_getBitStringAsInteger(mmsValue);

                    MmsValue_delete(mmsValue);
                    return(new Quality(bitStringValue));
                }
                else
                {
                    MmsValue_delete(mmsValue);
                    throw new IedConnectionException("Result is not of type bit string(Quality)", 0);
                }
            }
コード例 #7
0
            private IntPtr readObjectInternal(string objectReference, FunctionalConstraint fc)
            {
                int error;

                IntPtr mmsValue = IedConnection_readObject(connection, out error, objectReference, (int)fc);

                if (error != 0)
                {
                    throw new IedConnectionException("Reading value failed", error);
                }

                if (mmsValue.ToInt32() == 0)
                {
                    throw new IedConnectionException("Variable not found on server", error);
                }

                return(mmsValue);
            }
コード例 #8
0
            /// <summary>Read the value of a basic data attribute (BDA) of type string (VisibleString or MmsString).</summary>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public string ReadStringValue(string objectReference, FunctionalConstraint fc)
            {
                IntPtr mmsValue = readObjectInternal(objectReference, fc);

                if (!((MmsValue_getType(mmsValue) == (int)MmsType.MMS_VISIBLE_STRING) || (MmsValue_getType(mmsValue) == (int)MmsType.MMS_STRING)))
                {
                    MmsValue_delete(mmsValue);
                    throw new IedConnectionException("Result is not of type string", 0);
                }

                IntPtr ptr = MmsValue_toString(mmsValue);

                string returnString = Marshal.PtrToStringAnsi(ptr);

                MmsValue_delete(mmsValue);

                return(returnString);
            }
コード例 #9
0
ファイル: SclServer.cs プロジェクト: ttgzs/iedexplorer
        void createData(NodeBase dt, ModelNode mn)
        {
            ModelNode newmn = null;
            NodeBase  iter  = null;
            bool      isArr = false;

            if (dt is NodeDO)
            {
                NodeDO dO = (dt as NodeDO);
                isArr = dO.SCL_ArraySize > 0;
                newmn = new DataObject(dt.Name, mn, dO.SCL_ArraySize);
            }
            else if (dt is NodeData && !(dt is NodeDO))
            {   // dt is NodeDA
                NodeData dA = (NodeData)dt;
                isArr = dA.SCL_ArraySize > 0;
                FunctionalConstraint fc             = DataAttribute.fcFromString(dA.SCL_FCDesc);
                IEC61850.Server.DataAttributeType t = DataAttribute.typeFromSCLString(dA.SCL_BType);
                newmn = new DataAttribute(dt.Name, mn, t, fc, dA.SCL_TrgOps, dA.SCL_ArraySize, 0);
                logger.LogDebug("DataAttribute " + dt.IecAddress + " TrgOps:" + dA.SCL_TrgOps.ToString());
            }
            dt.SCLServerModelObject = newmn;
            if (isArr)
            {
                iter = dt.GetChildNode(0);
            }
            else
            {
                iter = dt;
            }
            foreach (NodeBase nb in iter.GetChildNodes())
            {
                // Recursion
                createData(nb, newmn);
            }
        }
コード例 #10
0
            /// <summary>Read the value of a basic data attribute (BDA) of type timestamp (MMS_UTC_TIME).</summary>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public UInt64 ReadTimestampValue(string objectReference, FunctionalConstraint fc)
            {
                var mmsValuePtr = readObjectInternal (objectReference, fc);

                var mmsValue = new MmsValue (mmsValuePtr, true);

                if (mmsValue.GetType () == MmsType.MMS_UTC_TIME)
                    return mmsValue.GetUtcTimeInMs ();
                else
                    throw new IedConnectionException ("Result is not of type timestamp (MMS_UTC_TIME)", 0);
            }
コード例 #11
0
 static extern IntPtr IedConnection_getDataDirectoryByFC(IntPtr self, out int error, string dataReference, FunctionalConstraint fc);
コード例 #12
0
            /// <summary>Get the list of attributes with the specified FC of a DO, SDO, or DA</summary>
            /// <param name="dataReference">The object reference of a DO, SDO, or DA.</param>
            /// <param name="fc">Functional constraint</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public List<string> GetDataDirectory(string dataReference, FunctionalConstraint fc)
            {
                int error;

                IntPtr linkedList = IedConnection_getDataDirectoryByFC (connection, out error, dataReference, fc);

                if (error != 0)
                    throw new IedConnectionException ("GetDataDirectory failed", error);

                IntPtr element = LinkedList_getNext (linkedList);

                List<string> newList = new List<string> ();

                while (element != IntPtr.Zero) {
                    string dataObject = Marshal.PtrToStringAnsi (LinkedList_getData (element));

                    newList.Add (dataObject);

                    element = LinkedList_getNext (element);
                }

                LinkedList_destroy (linkedList);

                return newList;
            }
コード例 #13
0
            /// <summary>Read the value of a data attribute (DA) or functional constraint data object (FCDO).</summary>
            /// <param name="objectReference">The object reference of a DA or FCDO.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <returns>the received value as an MmsValue instance</returns>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public MmsValue ReadValue(String objectReference, FunctionalConstraint fc)
            {
                var value = readObjectInternal(objectReference, fc);

                return(new MmsValue(value, true));
            }
コード例 #14
0
            /// <summary>Read the variable specification (type description of a DA or FDCO</summary>
            /// <param name="objectReference">The object reference of a DA or FCDO.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public MmsVariableSpecification GetVariableSpecification(string objectReference, FunctionalConstraint fc)
            {
                int error;

                IntPtr varSpecPtr = IedConnection_getVariableSpecification(connection, out error, objectReference, (int)fc);

                if (error != 0)
                {
                    throw new IedConnectionException("GetVariableSpecification failed", error);
                }

                return(new MmsVariableSpecification(varSpecPtr, true));
            }
コード例 #15
0
 static extern void IedServer_setWriteAccessPolicy(IntPtr self, FunctionalConstraint fc, AccessPolicy policy);
コード例 #16
0
            private IntPtr readObjectInternal(string objectReference, FunctionalConstraint fc)
            {
                int error;

                IntPtr mmsValue = IedConnection_readObject (connection, out error, objectReference, (int)fc);

                if (error != 0)
                    throw new IedConnectionException ("Reading value failed", error);

                if (mmsValue.ToInt32 () == 0)
                    throw new IedConnectionException ("Variable not found on server", error);

                return mmsValue;
            }
コード例 #17
0
            /// <summary>Read the variable specification (type description of a DA or FDCO</summary>
            /// <param name="objectReference">The object reference of a DA or FCDO.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public MmsVariableSpecification GetVariableSpecification(string objectReference, FunctionalConstraint fc)
            {
                int error;

                IntPtr varSpecPtr = IedConnection_getVariableSpecification(connection, out error, objectReference, (int) fc);

                if (error != 0)
                    throw new IedConnectionException ("GetVariableSpecification failed", error);

                return new MmsVariableSpecification(varSpecPtr, true);
            }
コード例 #18
0
            /// <summary>Read the value of a basic data attribute (BDA) of type bit string.</summary>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public int ReadBitStringValue(string objectReference, FunctionalConstraint fc)
            {
                IntPtr mmsValue = readObjectInternal (objectReference, fc);

                if (MmsValue_getType (mmsValue) == (int)MmsType.MMS_BIT_STRING) {
                    int bitStringValue = (int)MmsValue_getBitStringAsInteger (mmsValue);

                    MmsValue_delete (mmsValue);
                    return bitStringValue;
                } else {
                    MmsValue_delete (mmsValue);
                    throw new IedConnectionException ("Result is not of type bit string", 0);
                }
            }
コード例 #19
0
            /// <summary>Read the value of a basic data attribute (BDA) of type string (VisibleString or MmsString).</summary>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public string ReadStringValue(string objectReference, FunctionalConstraint fc)
            {
                IntPtr mmsValue = readObjectInternal (objectReference, fc);

                if (!((MmsValue_getType (mmsValue) == (int)MmsType.MMS_VISIBLE_STRING) || (MmsValue_getType (mmsValue) == (int)MmsType.MMS_STRING))) {
                    MmsValue_delete (mmsValue);
                    throw new IedConnectionException ("Result is not of type string", 0);
                }

                IntPtr ptr = MmsValue_toString (mmsValue);

                string returnString = Marshal.PtrToStringAnsi (ptr);

                MmsValue_delete (mmsValue);

                return returnString;
            }
コード例 #20
0
            /// <summary>Read the value of a basic data attribute (BDA) of type float.</summary>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public float ReadFloatValue(string objectReference, FunctionalConstraint fc)
            {
                IntPtr mmsValue = readObjectInternal (objectReference, fc);

                if (MmsValue_getType (mmsValue) != (int)MmsType.MMS_FLOAT)
                    throw new IedConnectionException ("Result is not of type float", 0);

                float value = MmsValue_toFloat (mmsValue);

                MmsValue_delete (mmsValue);

                return value;
            }
コード例 #21
0
            /// <summary>Read the value of a basic data attribute (BDA) of type boolean.</summary>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <returns>the received boolean value</returns>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public bool ReadBooleanValue(string objectReference, FunctionalConstraint fc)
            {
                var mmsValue = ReadValue (objectReference, fc);

                if (mmsValue.GetType () == MmsType.MMS_BOOLEAN)
                    return mmsValue.GetBoolean ();
                else
                    throw new IedConnectionException ("Result is not of type timestamp (MMS_UTC_TIME)", 0);
            }
コード例 #22
0
            /// <summary>Read the value of a data attribute (DA) or functional constraint data object (FCDO).</summary>
            /// <param name="objectReference">The object reference of a DA or FCDO.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <returns>the received value as an MmsValue instance</returns>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public MmsValue ReadValue(String objectReference, FunctionalConstraint fc)
            {
                var value = readObjectInternal (objectReference, fc);

                return new MmsValue (value, true);
            }
コード例 #23
0
            /// <summary>Read the value of a basic data attribute (BDA) of type integer (MMS_INTEGER).</summary>
            /// <description>This function should also be used if enumerations are beeing read. Because
            /// enumerations are mapped to integer types for the MMS mapping</description>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public Int64 ReadIntegerValue(string objectReference, FunctionalConstraint fc)
            {
                var mmsValuePtr = readObjectInternal (objectReference, fc);

                var mmsValue = new MmsValue (mmsValuePtr, true);

                if (mmsValue.GetType () == MmsType.MMS_INTEGER)
                    return mmsValue.ToInt64 ();
                else
                    throw new IedConnectionException ("Result is not of type integer (MMS_INTEGER)", 0);
            }
コード例 #24
0
            /// <summary>Write the value of a data attribute (DA) or functional constraint data object (FCDO).</summary>
            /// <description>This function can be used to write simple or complex variables (setpoints, parameters, descriptive values...)
            /// of the server.</description>
            /// <param name="objectReference">The object reference of a BDA.</param>
            /// <param name="fc">The functional constraint (FC) of the object</param>
            /// <param name="value">MmsValue object representing asimple or complex variable data</param>
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public void WriteValue(string objectReference, FunctionalConstraint fc, MmsValue value)
            {
                int error;

                IedConnection_writeObject (connection, out error, objectReference, (int)fc, value.valueReference);

                if (error != 0)
                    throw new IedConnectionException ("Write value failed", error);
            }
コード例 #25
0
 public DataAttribute(string name, ModelNode parent, DataAttributeType type, FunctionalConstraint fc, TriggerOptions trgOps,
                      int arrayElements, UInt32 sAddr)
 {
     self = DataAttribute_create(name, parent.self, (int)type, (int)fc, (byte)trgOps, arrayElements, sAddr);
 }
コード例 #26
0
ファイル: DataAttribute.cs プロジェクト: ttgzs/iedexplorer
 /**
  * \brief create a new data attribute and add it to a parent model node
  *
  * The parent model node has to be of type LogicalNode or DataObject
  *
  * \param name the name of the data attribute (e.g. "stVal")
  * \param parent the parent model node
  * \param type the type of the data attribute (CONSTRUCTED if the type contains sub data attributes)
  * \param fc the functional constraint (FC) of the data attribte
  * \param triggerOptions the trigger options (dupd, dchg, qchg) that cause an event notification
  * \param arrayElements the number of array elements if the data attribute is an array or 0
  * \param sAddr an optional short address
  *
  * \return the newly create DataAttribute instance
  */
 public DataAttribute(string name, ModelNode parentNode, DataAttributeType type, FunctionalConstraint fc, byte triggerOptions, int arrayElements, uint sAddr)
 {
     self   = DataAttribute_create(name, parentNode.GetLibraryObject(), (int)type, (int)fc, triggerOptions, arrayElements, sAddr);
     daType = type;
     daFc   = fc;
 }
コード例 #27
0
 public void SetWriteAccessPolicy(FunctionalConstraint fc, AccessPolicy policy)
 {
     IedServer_setWriteAccessPolicy(self, fc, policy);
 }
コード例 #28
0
 public Item61850(string pathStr, FunctionalConstraint typeFc, MmsType typeMms)
 {
     path    = pathStr;
     typeFC  = typeFc;
     typeMMS = typeMms;
 }