Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tivaty opened this issue Apr 10, 2024 · 6 comments
Labels

Comments

@Tivaty
Copy link

Tivaty commented Apr 10, 2024

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
Copy link
Contributor

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
Copy link
Author

Tivaty commented Apr 11, 2024

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
Copy link
Author

Tivaty commented May 28, 2024

@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

@CarlosMC124
Copy link

What you mention is correct, regarding the IEC61850 documentation, the order of the attributes is obtained with GetDataDirectory, I have been able to compare that with programs from companies such as SIEMENS, ABB using Wireshark (the correct order of DA appears), but for the MZ C# library, the request message by Wireshark does not appear with the GetDataDiretory and GetDataDiretoryFC functions, I am using version 1.6, even in C there is already an example with the use of that function, but when debugging I see that it never sends a message to the IED through Wireshark.

@CarlosMC124
Copy link

@mzillgith I was modifying the C code a little, specifically the IedConnection_getDataDirectory function of ied_connection.c

IedConnection_getDataDirectory(IedConnection self, IedClientError* error, const char* dataReference)
{
// return getDataDirectory(self, error, dataReference, false);

//My Test Code
MmsError err;
char* domainId;
char* itemId;
char domainIdBuffer[65];
char itemIdBuffer[65];
int functionalConstraint = 0;
FunctionalConstraint fc = (FunctionalConstraint)functionalConstraint;
domainId = MmsMapping_getMmsDomainFromObjectReference(dataReference, domainIdBuffer);
itemId = MmsMapping_createMmsVariableNameFromObjectReference(dataReference, fc, itemIdBuffer);
MmsVariableSpecification *s2;
s2= MmsConnection_getVariableAccessAttributes(self->connection, &err, domainId, itemId);
//My Test Code

return getDataDirectory(self, error, dataReference, false);

}

As a test, I was able to see that now if the request is made and through wireshark I see that the data structure responds (the correct order of the attributes when we read a DO).
I don't know much about c, and I find it difficult to interpret the MMS message that the relay returns,
BR
Carlos

@mzillgith
Copy link
Contributor

Use IedConnection_getVariableSpecification instead if you want to get the exact order of the objects as in the device as well as additional type information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants