- changed sorting algorithm for getNameList reponse

pull/6/head
Michael Zillgith 10 years ago
parent 9896742d12
commit 44ad37b04c

@ -1134,8 +1134,8 @@ MmsMapping_create(IedModel* model)
#endif #endif
#if (CONFIG_INCLUDE_GOOSE_SUPPORT == 1) #if (CONFIG_INCLUDE_GOOSE_SUPPORT == 1)
self->gseControls = LinkedList_create(); self->gseControls = LinkedList_create();
self->gooseInterfaceId = NULL; self->gooseInterfaceId = NULL;
#endif #endif
#if (CONFIG_IEC61850_CONTROL_SERVICE == 1) #if (CONFIG_IEC61850_CONTROL_SERVICE == 1)

@ -80,6 +80,23 @@ getNameListVMDSpecific(MmsServerConnection connection)
} }
#endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */ #endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */
static void
sortIndex(int* index, int size, MmsVariableSpecification** namedVariables)
{
int n;
int i;
for (n = size; n > 1; n = n - 1) {
for (i = 0; i < n - 1; i = i + 1) {
if (StringUtils_compareStrings(namedVariables[index[i]]->name, namedVariables[index[i + 1]]->name) > 0) {
int storedIndex = index[i];
index[i] = index[i + 1];
index[i + 1] = storedIndex;
}
}
}
}
#if (CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE == 1) #if (CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE == 1)
static char* static char*
appendMmsSubVariable(char* name, char* child) appendMmsSubVariable(char* name, char* child)
@ -116,14 +133,22 @@ addSubNamedVaribleNamesToList(LinkedList nameList, char* prefix, MmsVariableSpec
int i; int i;
MmsVariableSpecification** variables = variable->typeSpec.structure.elements; int* index = GLOBAL_MALLOC(sizeof(int) * variable->typeSpec.structure.elementCount);
for (i = 0; i < variable->typeSpec.structure.elementCount; i++)
index[i] = i;
MmsVariableSpecification** variables = variable->typeSpec.structure.elements;
sortIndex(index, variable->typeSpec.structure.elementCount, variables);
for (i = 0; i < variable->typeSpec.structure.elementCount; i++) { for (i = 0; i < variable->typeSpec.structure.elementCount; i++) {
char* variableName = appendMmsSubVariable(prefix, variables[i]->name); char* variableName = appendMmsSubVariable(prefix, variables[index[i]]->name);
listElement = LinkedList_insertAfter(listElement, variableName); listElement = LinkedList_insertAfter(listElement, variableName);
listElement = addSubNamedVaribleNamesToList(listElement, variableName, variables[i]); listElement = addSubNamedVaribleNamesToList(listElement, variableName, variables[index[i]]);
} }
} }
@ -132,6 +157,7 @@ addSubNamedVaribleNamesToList(LinkedList nameList, char* prefix, MmsVariableSpec
#endif /* (CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE == 1) */ #endif /* (CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE == 1) */
static LinkedList static LinkedList
getNameListDomainSpecific(MmsServerConnection connection, char* domainName) getNameListDomainSpecific(MmsServerConnection connection, char* domainName)
{ {
@ -149,15 +175,26 @@ getNameListDomainSpecific(MmsServerConnection connection, char* domainName)
LinkedList element = nameList; LinkedList element = nameList;
int* index = GLOBAL_MALLOC(sizeof(int) * domain->namedVariablesCount);
for (i = 0; i < domain->namedVariablesCount; i++)
index[i] = i;
sortIndex(index, domain->namedVariablesCount, domain->namedVariables);
for (i = 0; i < domain->namedVariablesCount; i++) { for (i = 0; i < domain->namedVariablesCount; i++) {
element = LinkedList_insertAfter(element, copyString(variables[i]->name));
element = LinkedList_insertAfter(element, copyString(variables[index[i]]->name));
#if (CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE == 1) #if (CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE == 1)
char* prefix = variables[i]->name; char* prefix = variables[index[i]]->name;
element = addSubNamedVaribleNamesToList(element, prefix, variables[i]); element = addSubNamedVaribleNamesToList(element, prefix, variables[index[i]]);
#endif #endif
} }
GLOBAL_FREEMEM(index);
} }
return nameList; return nameList;
@ -437,7 +474,7 @@ mmsServer_handleGetNameListRequest(
else { else {
#if (CONFIG_MMS_SORT_NAME_LIST == 1) #if (CONFIG_MMS_SORT_NAME_LIST == 1)
StringUtils_sortList(nameList); // StringUtils_sortList(nameList);
#endif #endif
createNameListResponse(connection, invokeId, nameList, response, continueAfterId); createNameListResponse(connection, invokeId, nameList, response, continueAfterId);

@ -251,7 +251,7 @@ createNamedVariableList(MmsDomain* domain, MmsDevice* device,
int variableCount = request->listOfVariable.list.count; int variableCount = request->listOfVariable.list.count;
if (variableCount > CONFIG_MMS_MAX_NUMBER_OF_DATA_SET_MEMBERS) { if ((variableCount == 0 ) || (variableCount > CONFIG_MMS_MAX_NUMBER_OF_DATA_SET_MEMBERS)) {
*mmsError = MMS_ERROR_DEFINITION_OTHER; *mmsError = MMS_ERROR_DEFINITION_OTHER;
goto exit_function; goto exit_function;
} }

Loading…
Cancel
Save