Where does data Datatype in UAExpert come from

21 views
Skip to first unread message

k...@liberalismen.dk

unread,
Apr 20, 2022, 5:42:06 AM4/20/22
to open62541
I export an integer from the standard example:
    UA_VariableAttributes attr = UA_VariableAttributes_default;
    UA_Int32 myInteger = 42;
    UA_Variant_setScalarCopy(&attr.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
    attr.description = UA_LOCALIZEDTEXT_ALLOC("en-US","the answer");
    attr.displayName = UA_LOCALIZEDTEXT_ALLOC("en-US","the answer");
    UA_NodeId myIntegerNodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
    UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME_ALLOC(1, "the answer");
    UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
    UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
    UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
                              parentReferenceNodeId, myIntegerName,
                              UA_NODEID_NULL, attr, NULL, NULL);

When I inspect that in UAExpert, I see this
datatype.png

Now I got a request, How do I change the DataType to say Integer instead of BaseDataType

k...@liberalismen.dk

unread,
Apr 20, 2022, 7:46:06 AM4/20/22
to open62541
This seems to do the trick
attr.dataType = UA_TYPES[UA_TYPES_INT32].typeId;
Reply all
Reply to author
Forward
0 new messages