- make GetLogicalNodeDirectory(DATA SET) dynamic. Creates a request at each call.

pull/6/head
Michael Zillgith 9 years ago
parent 2b28c0fed3
commit 922c5eec50

@ -49,8 +49,6 @@ int main(int argc, char** argv) {
IedServer iedServer = IedServer_create(&iedModel);
// get stored values from persistent storage
// set initial measurement and status values from process
/* MMS server will be instructed to start listening to client connections. */

@ -39,7 +39,6 @@ typedef struct sICLogicalDevice
{
char* name;
LinkedList variables;
LinkedList dataSets;
} ICLogicalDevice;
struct sClientDataSet
@ -165,12 +164,6 @@ ICLogicalDevice_setVariableList(ICLogicalDevice* self, LinkedList variables)
self->variables = variables;
}
static void
ICLogicalDevice_setDataSetList(ICLogicalDevice* self, LinkedList dataSets)
{
self->dataSets = dataSets;
}
static void
ICLogicalDevice_destroy(ICLogicalDevice* self)
{
@ -179,9 +172,6 @@ ICLogicalDevice_destroy(ICLogicalDevice* self)
if (self->variables != NULL)
LinkedList_destroy(self->variables);
if (self->dataSets != NULL)
LinkedList_destroy(self->dataSets);
GLOBAL_FREEMEM(self);
}
@ -1015,16 +1005,6 @@ IedConnection_getDeviceModelFromServer(IedConnection self, IedClientError* error
break;
}
LinkedList dataSets = MmsConnection_getDomainVariableListNames(self->connection,
&mmsError, name);
if (dataSets != NULL)
ICLogicalDevice_setDataSetList(icLogicalDevice, dataSets);
else {
*error = iedConnection_mapMmsErrorToIedError(mmsError);
break;
}
LinkedList_add(logicalDevices, icLogicalDevice);
logicalDevice = LinkedList_getNext(logicalDevice);
@ -1354,6 +1334,41 @@ getLogicalNodeDirectoryDataSets(IedConnection self, IedClientError* error, const
const char* logicalNodeName)
{
MmsConnection mmsCon = self->connection;
MmsError mmsError;
LinkedList dataSets = MmsConnection_getDomainVariableListNames(mmsCon, &mmsError, logicalDeviceName);
if (mmsError != MMS_ERROR_NONE) {
*error = iedConnection_mapMmsErrorToIedError(mmsError);
return NULL;
}
LinkedList lnDataSets = LinkedList_create();
LinkedList dataSet = LinkedList_getNext(dataSets);
while (dataSet != NULL) {
char* dataSetName = (char*) LinkedList_getData(dataSet);
char* lnDataSetName = strchr(dataSetName, '$');
if (lnDataSetName != NULL) {
lnDataSetName[0] = 0;
lnDataSetName += 1;
if (strcmp(dataSetName, logicalNodeName) == 0) {
char* lnDataSet = copyString(lnDataSetName);
LinkedList_add(lnDataSets, (void*) lnDataSet);
}
}
dataSet = LinkedList_getNext(dataSet);
}
LinkedList_destroy(dataSets);
return lnDataSets;
}
LinkedList /*<char*>*/
@ -1385,9 +1400,11 @@ IedConnection_getLogicalNodeDirectory(IedConnection self, IedClientError* error,
char* logicalNodeName = ldSep + 1;
if (acsiClass == ACSI_CLASS_LOG) {
if (acsiClass == ACSI_CLASS_LOG)
return getLogicalNodeDirectoryLogs(self, error, logicalDeviceName, logicalNodeName);
}
if (acsiClass == ACSI_CLASS_DATA_SET)
return getLogicalNodeDirectoryDataSets(self, error, logicalDeviceName, logicalNodeName);
if (self->logicalDevices == NULL)
IedConnection_getDeviceModelFromServer(self, error);
@ -1498,35 +1515,6 @@ IedConnection_getLogicalNodeDirectory(IedConnection self, IedClientError* error,
addVariablesWithFc("LG", logicalNodeName, ld->variables, lnDirectory);
break;
case ACSI_CLASS_DATA_SET:
{
LinkedList dataSet = LinkedList_getNext(ld->dataSets);
while (dataSet != NULL) {
char* dataSetName = (char*) dataSet->data;
char* fcPos = strchr(dataSetName, '$');
if (fcPos == NULL)
goto next_data_set_element;
size_t lnNameLen = fcPos - dataSetName;
if (strlen(logicalNodeName) != lnNameLen)
goto next_data_set_element;
if (memcmp(dataSetName, logicalNodeName, lnNameLen) != 0)
goto next_data_set_element;
LinkedList_add(lnDirectory, copyString(fcPos + 1));
next_data_set_element:
dataSet = LinkedList_getNext(dataSet);
}
}
break;
default:
if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: ACSI class not yet supported!\n");

@ -1661,7 +1661,10 @@ IedConnection_getLogicalNodeVariables(IedConnection self, IedClientError* error,
/**
* \brief returns the directory of the given logical node (LN) containing elements of the specified ACSI class
*
* Implementation of the GetLogicalNodeDirectory ACSI service.
* Implementation of the GetLogicalNodeDirectory ACSI service. In contrast to the ACSI description this
* function does not always creates a request to the server. For most ACSI classes it simply accesses the
* data model that was retrieved before. An exception to this rule are the ACSI classes ACSI_CLASS_DATASET and
* ACSI_CLASS_LOG. Both always perform a request to the server.
*
* \param self the connection object
* \param error the error code if an error occurs

Loading…
Cancel
Save