mz-automation / libiec61850

Official repository for libIEC61850, the open-source library for the IEC 61850 protocols
http://libiec61850.com/libiec61850
GNU General Public License v3.0
828 stars 444 forks source link

Structure data object from MmsVariableSpecification is diffrent with value when received dataset from rcb #502

Open Tivaty opened 2 months ago

Tivaty commented 2 months ago

Problem:

Structure data object from MmsVariableSpecification is diffrent with value when received dataset from rcb

Code:

Debug.WriteLine("\t" + dataObj.name);
// when receiving data from rcb, we receive full dataset so we need index element to retrieve data correctly

List<string> daNames = con.GetDataDirectoryFC(ObjectReference.getElementName(dataObj.name));
for (int ii = 0; ii < daNames.Count; ii++)
{
    // only DA with same type FC is add to dataset tree
    if (ObjectReference.getFC(daNames[ii]) == ObjectReference.getFC(dataObj.name)) 
    {
        string daName = daNames[ii];
        string daRef = ObjectReference.getElementName(dataObj.name) + "." + ObjectReference.getElementName(daName);

        var daElements = new DataElement(daRef, rcbRef: dsNode.rcbRef, dsNode.rptId, new List<int>(doElement.ElementIndex));
        daElements.ElementIndex.Add(ii);

        MmsVariableSpecification specification = con.GetVariableSpecification(daRef, ObjectReference.getFC(daName));

        Debug.WriteLine("\t\t" + daName + " : " + specification.GetType() + "(" + specification.Size() + ")");
        doElement.AddChild(daElements);

        if (specification.GetType() == MmsType.MMS_STRUCTURE)
        {
            for (int iii = 0; iii < specification.Size(); iii++)
            {
                MmsVariableSpecification elementSpec = specification.GetElement(iii);

                string daSpecName = daRef + "." + elementSpec.GetName();
                var daSpecElement = new DataElement(daSpecName, dsNode.rcbRef, dsNode.rptId, new List<int>(daElements.ElementIndex));
                daSpecElement.ElementIndex.Add(iii);

                Debug.WriteLine("\t\t\t" + elementSpec.GetName() + " : " + elementSpec.GetType());
                daElements.AddChild(daSpecElement);

                if (elementSpec.GetType() == MmsType.MMS_STRUCTURE)
                {
                    for (int iiii = 0; iiii < elementSpec.Size(); iiii++)
                    {
                        MmsVariableSpecification elementSpecSpec = elementSpec.GetElement(iiii);
                        string daSpecSpecName = daSpecName + "." + elementSpecSpec.GetName();
                        var daSpecSpecElement = new DataElement(daSpecSpecName, dsNode.rcbRef, dsNode.rptId, new List<int>(daSpecElement.ElementIndex));
                        daSpecSpecElement.ElementIndex.Add(iiii);

                        Debug.WriteLine("\t\t\t\t" + elementSpecSpec.GetName() + " : " + elementSpecSpec.GetType());
                        daSpecElement.AddChild(daSpecSpecElement);
                    }
                }
            }
        }
    }
}

Result when read DataObject atrribute names:

17:25:13:418        BCU_131_T1SP/GGIO110.Ind1[ST]
17:25:14:179            q[ST] : MMS_BIT_STRING(-13)
17:25:14:179            stVal[ST] : MMS_BOOLEAN(-1)
17:25:14:179            t[ST] : MMS_UTC_TIME(-1)

=> quality is in position 0

Result when received a rcb:

element 0 included for reason REASON_INTEGRITY {True, 0000000000000, 4/10/2024 8:29:26 AM +00:00} data-ref: BCU_131_T1SP/GGIO110$ST$Ind1

=> quality is in position 1

mzillgith commented 2 months ago

The GetDataDirectoryFC function is based on the get-name-list-service. This service returns the result in alphabetic order and not the real order in the data model. Therefore this service is not suitable to determine the order of elements in data set entries.

Tivaty commented 2 months ago

The GetDataDirectoryFC function is based on the get-name-list-service. This service returns the result in alphabetic order and not the real order in the data model. Therefore this service is not suitable to determine the order of elements in data set entries.

==> Please tell me which service or method I can get the correct order of data set / data object entries

Tivaty commented 1 month ago

@mzillgith Please, Can you tell me how to get the correct order of Data Attribute name ? I can not parse data from Dataset - Report because I can not get to the correct order name