MmsValue* IedConnection_readObject(IedConnection self, IedClientError* error, char* objectReference, FunctionalConstraint fc) { char domainIdBuffer[65]; char itemIdBuffer[129]; MmsValue* value = NULL; char* domainId; char* itemId; domainId = MmsMapping_getMmsDomainFromObjectReference(objectReference, domainIdBuffer); itemId = MmsMapping_createMmsVariableNameFromObjectReference(objectReference, fc, itemIdBuffer); if ((domainId == NULL) || (itemId == NULL)) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; return NULL; } MmsError mmsError; value = MmsConnection_readVariable(self->connection, &mmsError, domainId, itemId); if (value != NULL) { *error = IED_ERROR_OK; } else *error = iedConnection_mapMmsErrorToIedError(mmsError); return value; }
MmsVariableSpecification* IedConnection_getVariableSpecification(IedConnection self, IedClientError* error, char* objectReference, FunctionalConstraint fc) { char domainIdBuffer[65]; char itemIdBuffer[129]; char* domainId; char* itemId; MmsError mmsError; MmsVariableSpecification* varSpec = NULL; domainId = MmsMapping_getMmsDomainFromObjectReference(objectReference, domainIdBuffer); itemId = MmsMapping_createMmsVariableNameFromObjectReference(objectReference, fc, itemIdBuffer); if ((domainId == NULL) || (itemId == NULL)) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; goto cleanup_and_exit; } varSpec = MmsConnection_getVariableAccessAttributes(self->connection, &mmsError, domainId, itemId); if (varSpec != NULL) { *error = IED_ERROR_OK; } else *error = iedConnection_mapMmsErrorToIedError(mmsError); cleanup_and_exit: return varSpec; }
static void createDataSetsFromLogicalNode(MmsDevice* mmsDevice, LogicalNode* logicalNode, MmsDomain* domain) { if (logicalNode->dataSets != NULL) { int dataSetCount = ArrayList_listSize((void**) (logicalNode->dataSets)); int i; for (i = 0; i < dataSetCount; i++) { char* dataSetName = createString(3, logicalNode->name, "$", logicalNode->dataSets[i]->name); MmsNamedVariableList varList = MmsNamedVariableList_create(dataSetName, false); int fcdaCount = ArrayList_listSize((void**) (logicalNode->dataSets[i]->fcda)); int j; MmsNamedVariableListEntry variableListEntry; for (j = 0; j < fcdaCount; j++) { char* variableName = MmsMapping_createMmsVariableNameFromObjectReference( logicalNode->dataSets[i]->fcda[j]->objectReference, logicalNode->dataSets[i]->fcda[j]->fc); char* domainName = MmsMapping_getMmsDomainFromObjectReference( logicalNode->dataSets[i]->fcda[j]->objectReference); MmsDomain* variableDomain; if (domainName != NULL) variableDomain = MmsDevice_getDomain(mmsDevice, domainName); else variableDomain = domain; variableListEntry = MmsNamedVariableListEntry_create(variableDomain, variableName); MmsNamedVariableList_addVariable(varList, variableListEntry); free(domainName); free(variableName); } MmsDomain_addNamedVariableList(domain, varList); free(dataSetName); } } }
static void installDefaultValuesForDataAttribute(IedServer self, DataAttribute* dataAttribute, char* objectReference, int position) { sprintf(objectReference + position, ".%s", dataAttribute->name); char mmsVariableName[65]; /* maximum size is 64 according to 61850-8-1 */ MmsValue* value = dataAttribute->mmsValue; MmsMapping_createMmsVariableNameFromObjectReference(objectReference, dataAttribute->fc, mmsVariableName); char domainName[65]; MmsMapping_getMmsDomainFromObjectReference(objectReference, domainName); MmsDomain* domain = MmsDevice_getDomain(self->mmsDevice, domainName); if (domain == NULL) { if (DEBUG_IED_SERVER) printf("Error domain (%s) not found!\n", domainName); return; } MmsValue* cacheValue = MmsServer_getValueFromCache(self->mmsServer, domain, mmsVariableName); dataAttribute->mmsValue = cacheValue; if (value != NULL) { MmsValue_update(cacheValue, value); MmsValue_delete(value); } int childPosition = strlen(objectReference); DataAttribute* subDataAttribute = (DataAttribute*) dataAttribute->firstChild; while (subDataAttribute != NULL) { installDefaultValuesForDataAttribute(self, subDataAttribute, objectReference, childPosition); subDataAttribute = (DataAttribute*) subDataAttribute->sibling; } }