- fixed data set handling problem when using functional naming (ldName) (LIB61850-160)

v1.6_develop_rgoose_sntp
Michael Zillgith 3 years ago
parent 0a1ddb7ca9
commit e02b85f147

@ -3978,85 +3978,109 @@ MmsMapping_stopEventWorkerThread(MmsMapping* self)
DataSet* DataSet*
MmsMapping_createDataSetByNamedVariableList(MmsMapping* self, MmsNamedVariableList variableList) MmsMapping_createDataSetByNamedVariableList(MmsMapping* self, MmsNamedVariableList variableList)
{ {
DataSet* dataSet = (DataSet*) GLOBAL_MALLOC(sizeof(DataSet)); DataSet* dataSet = (DataSet*) GLOBAL_CALLOC(1, sizeof(DataSet));
if (variableList->domain != NULL) if (dataSet) {
dataSet->logicalDeviceName = MmsDomain_getName(variableList->domain) + strlen(self->model->name);
else
dataSet->logicalDeviceName = NULL; /* name is not relevant for association specific data sets */
dataSet->name = variableList->name; if (variableList->domain != NULL) {
dataSet->elementCount = LinkedList_size(variableList->listOfVariables); LogicalDevice* ld = IedModel_getDevice(self->model, MmsDomain_getName(variableList->domain));
LinkedList element = LinkedList_getNext(variableList->listOfVariables); if (ld) {
dataSet->logicalDeviceName = ld->name;
}
else {
if (DEBUG_IED_SERVER)
printf("IED_SERVER: LD lookup error!");
}
}
else
dataSet->logicalDeviceName = NULL; /* name is not relevant for association specific data sets */
DataSetEntry* lastDataSetEntry = NULL; dataSet->name = variableList->name;
dataSet->elementCount = LinkedList_size(variableList->listOfVariables);
while (element != NULL) { LinkedList element = LinkedList_getNext(variableList->listOfVariables);
MmsAccessSpecifier* listEntry = (MmsAccessSpecifier*) element->data;
DataSetEntry* dataSetEntry = (DataSetEntry*) GLOBAL_MALLOC(sizeof(DataSetEntry)); DataSetEntry* lastDataSetEntry = NULL;
/* use variable name part of domain name as logicalDeviceName */ while (element != NULL) {
dataSetEntry->logicalDeviceName = MmsDomain_getName(listEntry->domain) + strlen(self->model->name); MmsAccessSpecifier* listEntry = (MmsAccessSpecifier*) element->data;
dataSetEntry->variableName = listEntry->variableName;
dataSetEntry->index = listEntry->arrayIndex;
dataSetEntry->componentName = listEntry->componentName;
dataSetEntry->sibling = NULL;
dataSetEntry->value = NULL;
if (lastDataSetEntry == NULL) LogicalDevice* entryLd = IedModel_getDevice(self->model, MmsDomain_getName(listEntry->domain));
dataSet->fcdas =dataSetEntry;
else
lastDataSetEntry->sibling = dataSetEntry;
MmsVariableSpecification* dataSetEntryVarSpec = NULL; if (entryLd) {
MmsValue* dataSetEntryValue = MmsServer_getValueFromCacheEx(self->mmsServer, listEntry->domain, listEntry->variableName, &dataSetEntryVarSpec); DataSetEntry* dataSetEntry = (DataSetEntry*) GLOBAL_MALLOC(sizeof(DataSetEntry));
if (dataSetEntryValue) { if (dataSetEntry) {
if (dataSetEntry->index != -1) {
if (dataSetEntryVarSpec->type == MMS_ARRAY) {
MmsValue* elementValue = MmsValue_getElement(dataSetEntryValue, dataSetEntry->index);
if (elementValue) { /* use variable name part of domain name as logicalDeviceName */
dataSetEntry->logicalDeviceName = entryLd->name;
dataSetEntry->variableName = listEntry->variableName;
dataSetEntry->index = listEntry->arrayIndex;
dataSetEntry->componentName = listEntry->componentName;
dataSetEntry->sibling = NULL;
dataSetEntry->value = NULL;
if (dataSetEntry->componentName) { if (lastDataSetEntry == NULL)
MmsVariableSpecification* elementType = dataSetEntryVarSpec->typeSpec.array.elementTypeSpec; dataSet->fcdas =dataSetEntry;
else
lastDataSetEntry->sibling = dataSetEntry;
MmsVariableSpecification* dataSetEntryVarSpec = NULL;
MmsValue* dataSetEntryValue = MmsServer_getValueFromCacheEx(self->mmsServer, listEntry->domain, listEntry->variableName, &dataSetEntryVarSpec);
if (dataSetEntryValue) {
if (dataSetEntry->index != -1) {
if (dataSetEntryVarSpec->type == MMS_ARRAY) {
MmsValue* elementValue = MmsValue_getElement(dataSetEntryValue, dataSetEntry->index);
MmsValue* subElementValue = MmsVariableSpecification_getChildValue(elementType, elementValue, dataSetEntry->componentName); if (elementValue) {
if (dataSetEntry->componentName) {
MmsVariableSpecification* elementType = dataSetEntryVarSpec->typeSpec.array.elementTypeSpec;
MmsValue* subElementValue = MmsVariableSpecification_getChildValue(elementType, elementValue, dataSetEntry->componentName);
if (subElementValue) {
dataSetEntry->value = subElementValue;
}
else {
if (DEBUG_IED_SERVER)
printf("IED_SERVER: ERROR - component %s of array element not found\n", dataSetEntry->componentName);
}
if (subElementValue) { }
dataSetEntry->value = subElementValue; else {
dataSetEntry->value = elementValue;
}
}
else {
if (DEBUG_IED_SERVER)
printf("IED_SERVER: ERROR - array element %i not found\n", dataSetEntry->index);
}
} }
else { else {
if (DEBUG_IED_SERVER) if (DEBUG_IED_SERVER)
printf("IED_SERVER: ERROR - component %s of array element not found\n", dataSetEntry->componentName); printf("IED_SERVER: ERROR - variable %s/%s is not an array\n", dataSetEntry->logicalDeviceName, dataSetEntry->variableName);
} }
} }
else { else {
dataSetEntry->value = elementValue; dataSetEntry->value = dataSetEntryValue;
} }
} }
else {
if (DEBUG_IED_SERVER) lastDataSetEntry = dataSetEntry;
printf("IED_SERVER: ERROR - array element %i not found\n", dataSetEntry->index);
}
}
else {
if (DEBUG_IED_SERVER)
printf("IED_SERVER: ERROR - variable %s/%s is not an array\n", dataSetEntry->logicalDeviceName, dataSetEntry->variableName);
} }
} }
else { else {
dataSetEntry->value = dataSetEntryValue; if (DEBUG_IED_SERVER)
printf("IED_SERVER: LD lookup error!\n");
} }
}
lastDataSetEntry = dataSetEntry;
element = LinkedList_getNext(element); element = LinkedList_getNext(element);
}
} }
return dataSet; return dataSet;

@ -721,7 +721,21 @@ updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet,
char externalVisibleName[256]; char externalVisibleName[256];
/* Construct external visible name */ /* Construct external visible name */
StringUtils_concatString(externalVisibleName, 256, mapping->model->name, dataSetLdName);
LogicalDevice* ld = IedModel_getDeviceByInst(mapping->model, dataSetLdName);
if (ld == NULL) {
success = false;
goto exit_function;
}
if (ld->ldName) {
StringUtils_copyStringMax(externalVisibleName, 256, ld->ldName);
}
else {
StringUtils_concatString(externalVisibleName, 256, mapping->model->name, dataSetLdName);
}
StringUtils_appendString(externalVisibleName, 256, "/"); StringUtils_appendString(externalVisibleName, 256, "/");
StringUtils_appendString(externalVisibleName, 256, dataSetName); StringUtils_appendString(externalVisibleName, 256, dataSetName);

@ -39,9 +39,11 @@ MmsDomain_create(char* domainName)
{ {
MmsDomain* self = (MmsDomain*) GLOBAL_CALLOC(1, sizeof(MmsDomain)); MmsDomain* self = (MmsDomain*) GLOBAL_CALLOC(1, sizeof(MmsDomain));
self->domainName = StringUtils_copyString(domainName); if (self) {
self->namedVariableLists = LinkedList_create(); self->domainName = StringUtils_copyString(domainName);
self->journals = NULL; self->namedVariableLists = LinkedList_create();
self->journals = NULL;
}
return self; return self;
} }

@ -481,34 +481,34 @@ handleWriteNamedVariableListRequest(
void void
mmsServer_handleWriteRequest( mmsServer_handleWriteRequest(
MmsServerConnection connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)
{ {
(void)bufPos; (void)bufPos;
(void)maxBufPos; (void)maxBufPos;
MmsPdu_t* mmsPdu = 0; MmsPdu_t* mmsPdu = 0;
asn_dec_rval_t rval; /* Decoder return value */ asn_dec_rval_t rval; /* Decoder return value */
rval = ber_decode(NULL, &asn_DEF_MmsPdu, (void**) &mmsPdu, buffer, CONFIG_MMS_MAXIMUM_PDU_SIZE); rval = ber_decode(NULL, &asn_DEF_MmsPdu, (void**) &mmsPdu, buffer, CONFIG_MMS_MAXIMUM_PDU_SIZE);
if (rval.code != RC_OK) { if (rval.code != RC_OK) {
mmsMsg_createMmsRejectPdu(&invokeId, MMS_ERROR_REJECT_INVALID_PDU, response); mmsMsg_createMmsRejectPdu(&invokeId, MMS_ERROR_REJECT_INVALID_PDU, response);
goto exit_function; goto exit_function;
} }
MmsServer_lockModel(connection->server); MmsServer_lockModel(connection->server);
WriteRequest_t* writeRequest = &(mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.choice.write); WriteRequest_t* writeRequest = &(mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.choice.write);
if (writeRequest->variableAccessSpecification.present == VariableAccessSpecification_PR_variableListName) { if (writeRequest->variableAccessSpecification.present == VariableAccessSpecification_PR_variableListName) {
handleWriteNamedVariableListRequest(connection, writeRequest, invokeId, response); handleWriteNamedVariableListRequest(connection, writeRequest, invokeId, response);
goto exit_function; goto exit_function;
} }
else if (writeRequest->variableAccessSpecification.present == VariableAccessSpecification_PR_listOfVariable) { else if (writeRequest->variableAccessSpecification.present == VariableAccessSpecification_PR_listOfVariable) {
int numberOfWriteItems = writeRequest->variableAccessSpecification.choice.listOfVariable.list.count; int numberOfWriteItems = writeRequest->variableAccessSpecification.choice.listOfVariable.list.count;
@ -571,7 +571,7 @@ mmsServer_handleWriteRequest(
variable = MmsDomain_getNamedVariable(domain, nameIdStr); variable = MmsDomain_getNamedVariable(domain, nameIdStr);
} }
#if (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) #if (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1)
else if (varSpec->variableSpecification.choice.name.present == ObjectName_PR_vmdspecific) { else if (varSpec->variableSpecification.choice.name.present == ObjectName_PR_vmdspecific) {
Identifier_t nameId = varSpec->variableSpecification.choice.name.choice.vmdspecific; Identifier_t nameId = varSpec->variableSpecification.choice.name.choice.vmdspecific;
@ -579,7 +579,7 @@ mmsServer_handleWriteRequest(
variable = MmsDevice_getNamedVariable(device, nameIdStr); variable = MmsDevice_getNamedVariable(device, nameIdStr);
} }
#endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */ #endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */
else { else {
accessResults[i] = DATA_ACCESS_ERROR_OBJECT_ACCESS_UNSUPPORTED; accessResults[i] = DATA_ACCESS_ERROR_OBJECT_ACCESS_UNSUPPORTED;
@ -616,7 +616,7 @@ mmsServer_handleWriteRequest(
if (alternateAccess != NULL) { if (alternateAccess != NULL) {
if (domain == NULL) if (domain == NULL)
domain = (MmsDomain*) device; domain = (MmsDomain*) device;
MmsValue* cachedArray = MmsServer_getValueFromCache(connection->server, domain, nameIdStr); MmsValue* cachedArray = MmsServer_getValueFromCache(connection->server, domain, nameIdStr);
@ -701,7 +701,7 @@ mmsServer_handleWriteRequest(
accessResults[i] = valueIndication; accessResults[i] = valueIndication;
end_of_main_loop: end_of_main_loop:
MmsValue_delete(value); MmsValue_delete(value);
} }
@ -714,7 +714,7 @@ end_of_main_loop:
goto exit_function; goto exit_function;
} }
exit_function: exit_function:
MmsServer_unlockModel(connection->server); MmsServer_unlockModel(connection->server);

Loading…
Cancel
Save