Skip to content

Commit

Permalink
CTT: Add scale test, a folder with more than 1000 dynamic variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed Jul 24, 2019
1 parent 4a11b8a commit b0971ef
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion examples/server_ctt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
*
* Copyright 2019 (c) Kalycito Infotech Private Limited
*
* Copyright 2019 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
*/

#ifdef _MSC_VER
Expand Down Expand Up @@ -216,6 +216,7 @@ setInformationModel(UA_Server *server) {
#define ARRAYID 50002
#define MATRIXID 50003
#define DEPTHID 50004
#define SCALETESTID 50005

UA_ObjectAttributes object_attr = UA_ObjectAttributes_default;
object_attr.description = UA_LOCALIZEDTEXT("en-US", "Demo");
Expand Down Expand Up @@ -245,6 +246,12 @@ setInformationModel(UA_Server *server) {
UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), UA_QUALIFIEDNAME(1, "Matrix"),
UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE), object_attr, NULL, NULL);

object_attr.description = UA_LOCALIZEDTEXT("en-US", "ScaleTest");
object_attr.displayName = UA_LOCALIZEDTEXT("en-US", "ScaleTest");
UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, SCALETESTID), UA_NODEID_NUMERIC(1, DEMOID),
UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), UA_QUALIFIEDNAME(1, "ScaleTest"),
UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE), object_attr, NULL, NULL);

/* Fill demo nodes for each type*/
UA_UInt32 matrixDims[2] = {3, 3};
UA_UInt32 id = 51000; // running id in namespace 0
Expand Down Expand Up @@ -352,6 +359,41 @@ setInformationModel(UA_Server *server) {
UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE), object_attr, NULL, NULL);
}

/* Scale Test: 100 nodes of each type */
int scale_i = 0;
UA_UInt32 scale_nodeid = 53000;
for(UA_UInt32 type = 0; type < UA_TYPES_DIAGNOSTICINFO; type++) {
if(type == UA_TYPES_VARIANT || type == UA_TYPES_DIAGNOSTICINFO)
continue;

UA_VariableAttributes attr = UA_VariableAttributes_default;
attr.dataType = UA_TYPES[type].typeId;
attr.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;
attr.writeMask = UA_WRITEMASK_DISPLAYNAME | UA_WRITEMASK_DESCRIPTION;
attr.userWriteMask = UA_WRITEMASK_DISPLAYNAME | UA_WRITEMASK_DESCRIPTION;
attr.valueRank = UA_VALUERANK_SCALAR;
void *value = UA_new(&UA_TYPES[type]);
UA_Variant_setScalar(&attr.value, value, &UA_TYPES[type]);

for(size_t j = 0; j < 100; j++) {
char name[32];
#ifndef UA_ENABLE_TYPENAMES
UA_snprintf(name, 20, "%02d - %i", type, scale_i);
#else
UA_snprintf(name, 20, "%s - %i", UA_TYPES[type].typeName, scale_i);
#endif
attr.displayName = UA_LOCALIZEDTEXT("en-US", name);
UA_QualifiedName qualifiedName = UA_QUALIFIEDNAME(1, name);
UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, ++scale_nodeid),
UA_NODEID_NUMERIC(1, SCALETESTID),
UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
qualifiedName, baseDataVariableType, attr, NULL, NULL);
scale_i++;
}

UA_Variant_clear(&attr.value);
}

/* Add the variable to some more places to get a node with three inverse references for the CTT */
UA_ExpandedNodeId answer_nodeid = UA_EXPANDEDNODEID_STRING(1, "the.answer");
UA_Server_addReference(server, UA_NODEID_NUMERIC(1, DEMOID),
Expand Down

0 comments on commit b0971ef

Please sign in to comment.