diff --git a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
index e1b0c813..55903ec8 100644
--- a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
+++ b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
@@ -797,7 +797,10 @@ namespace IEC61850
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ModelNode_getObjectReference(IntPtr self, IntPtr objectReference);
- public IntPtr self;
+ [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
+ static extern IntPtr ModelNode_getObjectReferenceEx(IntPtr self, IntPtr objectReference, [MarshalAs(UnmanagedType.I1)] bool withoutIedName);
+
+ public IntPtr self;
internal ModelNode()
{
@@ -836,9 +839,14 @@ namespace IEC61850
}
- public string GetObjectReference()
+ ///
+ /// Gets the object reference of the model node
+ ///
+ /// the object reference
+ /// If set to true the object reference is created without IED name.
+ public string GetObjectReference(bool withoutIedName = false)
{
- IntPtr objRefPtr = ModelNode_getObjectReference(self, IntPtr.Zero);
+ IntPtr objRefPtr = ModelNode_getObjectReferenceEx(self, IntPtr.Zero, withoutIedName);
if (objRefPtr != IntPtr.Zero) {
string objRef = Marshal.PtrToStringAnsi(objRefPtr);
diff --git a/src/iec61850/inc/iec61850_model.h b/src/iec61850/inc/iec61850_model.h
index dc5fa918..9c23f105 100644
--- a/src/iec61850/inc/iec61850_model.h
+++ b/src/iec61850/inc/iec61850_model.h
@@ -397,6 +397,19 @@ ModelNode_getChildWithFc(ModelNode* self, const char* name, FunctionalConstraint
LIB61850_API char*
ModelNode_getObjectReference(ModelNode* self, char* objectReference);
+/**
+ * \brief Return the IEC 61850 object reference of a model node
+ *
+ * \param self the model node instance
+ * \param objectReference pointer to a buffer where to write the object reference string. If NULL
+ * is given the buffer is allocated by the function.
+ * \param withoutIedName create object reference without IED name part
+ *
+ * \return the object reference string
+ */
+LIB61850_API char*
+ModelNode_getObjectReferenceEx(ModelNode* node, char* objectReference, bool withoutIedName);
+
/**
* \brief Get the type of the ModelNode
*
diff --git a/src/iec61850/server/model/model.c b/src/iec61850/server/model/model.c
index 0c6e4d62..5d98c7f5 100644
--- a/src/iec61850/server/model/model.c
+++ b/src/iec61850/server/model/model.c
@@ -513,12 +513,12 @@ LogicalDevice_getChildByMmsVariableName(LogicalDevice* logicalDevice, const char
}
static int
-createObjectReference(ModelNode* node, char* objectReference)
+createObjectReference(ModelNode* node, char* objectReference, bool withoutIedName)
{
int bufPos;
if (node->modelType != LogicalNodeModelType) {
- bufPos = createObjectReference(node->parent, objectReference);
+ bufPos = createObjectReference(node->parent, objectReference, withoutIedName);
objectReference[bufPos++] = '.';
}
@@ -531,10 +531,18 @@ createObjectReference(ModelNode* node, char* objectReference)
bufPos = 0;
- int nameLength = strlen (iedModel->name) + strlen(lDevice->name);
+ int nameLength = 0;
- strncpy(objectReference, iedModel->name, 64);
- strncat(objectReference, lDevice->name, 64);
+ if (withoutIedName) {
+ nameLength = strlen(lDevice->name);
+ strncpy(objectReference, lDevice->name, 64);
+ }
+ else {
+ nameLength = strlen (iedModel->name) + strlen(lDevice->name);
+
+ strncpy(objectReference, iedModel->name, 64);
+ strncat(objectReference, lDevice->name, 64);
+ }
bufPos += nameLength;
@@ -558,7 +566,20 @@ ModelNode_getObjectReference(ModelNode* node, char* objectReference)
if (objectReference == NULL)
objectReference = (char*) GLOBAL_MALLOC(130);
- int bufPos = createObjectReference(node, objectReference);
+ int bufPos = createObjectReference(node, objectReference, false);
+
+ objectReference[bufPos] = 0;
+
+ return objectReference;
+}
+
+char*
+ModelNode_getObjectReferenceEx(ModelNode* node, char* objectReference, bool withoutIedName)
+{
+ if (objectReference == NULL)
+ objectReference = (char*) GLOBAL_MALLOC(130);
+
+ int bufPos = createObjectReference(node, objectReference, withoutIedName);
objectReference[bufPos] = 0;