Parcourir la source

set variable accesslevel to writable in the examples

Julius Pfrommer il y a 7 ans
Parent
commit
0b8760eefe

+ 2 - 0
examples/tutorial_server_datasource.c

@@ -42,6 +42,7 @@ addCurrentTimeVariable(UA_Server *server) {
     UA_DateTime now = 0;
     UA_VariableAttributes attr = UA_VariableAttributes_default;
     attr.displayName = UA_LOCALIZEDTEXT("en_US", "Current time");
+    attr.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;
     UA_Variant_setScalar(&attr.value, &now, &UA_TYPES[UA_TYPES_DATETIME]);
 
     UA_NodeId currentNodeId = UA_NODEID_STRING(1, "current-time");
@@ -133,6 +134,7 @@ static void
 addCurrentTimeDataSourceVariable(UA_Server *server) {
     UA_VariableAttributes attr = UA_VariableAttributes_default;
     attr.displayName = UA_LOCALIZEDTEXT("en_US", "Current time - data source");
+    attr.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;
 
     UA_NodeId currentNodeId = UA_NODEID_STRING(1, "current-time-datasource");
     UA_QualifiedName currentName = UA_QUALIFIEDNAME(1, "current-time-datasource");

+ 4 - 0
examples/tutorial_server_variable.c

@@ -9,6 +9,9 @@
  * to a server. First, we add a new variable to the server. Take a look at the
  * definition of the ``UA_VariableAttrbitues`` structure to see the list of all
  * attributes defined for VariableNodes.
+ *
+ * Note that the default settings have the AccessLevel of the variable value as
+ * read only. See below for making the variable writable.
  */
 
 #include <signal.h>
@@ -24,6 +27,7 @@ addVariable(UA_Server *server) {
     attr.description = UA_LOCALIZEDTEXT("en_US","the answer");
     attr.displayName = UA_LOCALIZEDTEXT("en_US","the answer");
     attr.dataType = UA_TYPES[UA_TYPES_INT32].typeId;
+    attr.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;
 
     /* Add the variable node to the information model */
     UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");

+ 1 - 0
examples/tutorial_server_variabletype.c

@@ -62,6 +62,7 @@ addVariable(UA_Server *server) {
     vAttr.arrayDimensions = arrayDims;
     vAttr.arrayDimensionsSize = 1;
     vAttr.displayName = UA_LOCALIZEDTEXT("en_US", "2DPoint Variable");
+    vAttr.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;
     /* vAttr.value is left empty, the server instantiates with the default value */
 
     /* Add the node */