Skip to content

Commit

Permalink
refactor(examples): server_ctt uses "static" variables that always co…
Browse files Browse the repository at this point in the history
…ntain the current source timestamp
  • Loading branch information
jpfr committed Nov 8, 2023
1 parent dd74bd6 commit 5326413
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/server_ctt.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ setInformationModel(UA_Server *server) {
parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId, parentReferenceNodeId,
myIntegerName, baseDataVariableType, myVar, NULL, NULL);
UA_Server_setVariableNodeDynamic(server, myIntegerNodeId, false);

/* add a static variable that is readable but not writable*/
myVar = UA_VariableAttributes_default;
Expand All @@ -419,6 +420,7 @@ setInformationModel(UA_Server *server) {
const UA_NodeId myInteger2NodeId = UA_NODEID_STRING(1, "the.answer.no.read");
UA_Server_addVariableNode(server, myInteger2NodeId, parentNodeId, parentReferenceNodeId,
myInteger2Name, baseDataVariableType, myVar, NULL, NULL);
UA_Server_setVariableNodeDynamic(server, myInteger2NodeId, false);

/* add a variable that is not readable or writable for the current user */
myVar = UA_VariableAttributes_default;
Expand All @@ -432,6 +434,7 @@ setInformationModel(UA_Server *server) {
const UA_QualifiedName accessDeniedName = UA_QUALIFIEDNAME(1, "the answer - not current user");
UA_Server_addVariableNode(server, accessDenied, parentNodeId, parentReferenceNodeId,
accessDeniedName, baseDataVariableType, myVar, NULL, NULL);
UA_Server_setVariableNodeDynamic(server, accessDenied, false);

/* add a variable with the datetime data source */
UA_DataSource dateDataSource;
Expand Down Expand Up @@ -463,6 +466,7 @@ setInformationModel(UA_Server *server) {
UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), byteStringName,
baseDataVariableType, myVar, NULL, NULL);
UA_Server_setVariableNodeDynamic(server, UA_NODEID_STRING(1, "myByteString"), false);

/* Add HelloWorld method to the server */
#ifdef UA_ENABLE_METHODCALLS
Expand Down Expand Up @@ -579,6 +583,7 @@ setInformationModel(UA_Server *server) {
UA_NODEID_NUMERIC(1, SCALARID), UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
qualifiedName, baseDataVariableType, attr, NULL, NULL);
UA_Variant_clear(&attr.value);
UA_Server_setVariableNodeDynamic(server, UA_NODEID_NUMERIC(1, id), false);

/* add an array node for every built-in type */
UA_UInt32 arrayDims = 0;
Expand All @@ -590,6 +595,7 @@ setInformationModel(UA_Server *server) {
UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), qualifiedName,
baseDataVariableType, attr, NULL, NULL);
UA_Variant_clear(&attr.value);
UA_Server_setVariableNodeDynamic(server, UA_NODEID_NUMERIC(1, id), false);

/* add an matrix node for every built-in type */
attr.valueRank = UA_VALUERANK_TWO_DIMENSIONS;
Expand All @@ -607,6 +613,7 @@ setInformationModel(UA_Server *server) {
UA_NODEID_NUMERIC(1, MATRIXID),
UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), qualifiedName,
baseDataVariableType, attr, NULL, NULL);
UA_Server_setVariableNodeDynamic(server, UA_NODEID_NUMERIC(1, id), false);
UA_Variant_clear(&attr.value);
#ifdef UA_ENABLE_TYPEDESCRIPTION
UA_LocalizedText_clear(&attr.displayName);
Expand All @@ -626,6 +633,7 @@ setInformationModel(UA_Server *server) {
UA_Server_addVariableNode(server, UA_NODEID_STRING(1, "integer"),
UA_NODEID_NUMERIC(1, SCALARID), UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
iQualifiedName, baseDataVariableType, iattr, NULL, NULL);
UA_Server_setVariableNodeDynamic(server, UA_NODEID_STRING(1, "integer"), false);

iattr.dataType = UA_NODEID_NUMERIC(0, UA_NS0ID_UINTEGER);
iattr.displayName = UA_LOCALIZEDTEXT("en-US", "UInteger");
Expand All @@ -634,6 +642,7 @@ setInformationModel(UA_Server *server) {
UA_NODEID_NUMERIC(1, SCALARID), UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
uQualifiedName, baseDataVariableType, iattr, NULL, NULL);
UA_Variant_clear(&iattr.value);
UA_Server_setVariableNodeDynamic(server, UA_NODEID_STRING(1, "uinteger"), false);

/* Hierarchy of depth 10 for CTT testing with forward and inverse references */
/* Enter node "depth 9" in CTT configuration - Project->Settings->Server
Expand Down Expand Up @@ -854,6 +863,7 @@ setInformationModel(UA_Server *server) {
UA_Server_setVariableNode_valueCallback(server,
UA_NODEID_STRING(1, "event-trigger-1"),
eventTriggerValueBackend);
UA_Server_setVariableNodeDynamic(server, UA_NODEID_STRING(1, "event-trigger-1"), false);

myVar.description = UA_LOCALIZEDTEXT("en-US", "event trigger 2");
myVar.displayName = UA_LOCALIZEDTEXT("en-US", "event trigger 2");
Expand All @@ -864,6 +874,7 @@ setInformationModel(UA_Server *server) {
UA_Server_setVariableNode_valueCallback(server,
UA_NODEID_STRING(1, "event-trigger-2"),
eventTriggerValueBackend);
UA_Server_setVariableNodeDynamic(server, UA_NODEID_STRING(1, "event-trigger-2"), false);
#endif
}

Expand Down

0 comments on commit 5326413

Please sign in to comment.