Skip to content

Commit

Permalink
allow to add data source variable with non-good status
Browse files Browse the repository at this point in the history
  • Loading branch information
max65482 committed Dec 5, 2023
1 parent 71613cd commit ade6b14
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/server/ua_services_nodemanagement.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,15 @@ useVariableTypeAttributes(UA_Server *server, UA_Session *session,
/* If no value is set, see if the vt provides one and copy it. This needs to
* be done before copying the datatype from the vt, as setting the datatype
* triggers a typecheck. */
UA_Variant orig;
UA_StatusCode retval =
readWithReadValue(server, &node->head.nodeId, UA_ATTRIBUTEID_VALUE, &orig);
if(retval != UA_STATUSCODE_GOOD)
return retval;
UA_ReadValueId item;
UA_ReadValueId_init(&item);
item.nodeId = node->head.nodeId;
item.attributeId = UA_ATTRIBUTEID_VALUE;
UA_DataValue dv = readWithSession(server, session, &item,
UA_TIMESTAMPSTORETURN_NEITHER);

if(orig.type) {
/* A value is present */
UA_Variant_clear(&orig);
} else {
UA_StatusCode retval = UA_STATUSCODE_GOOD;
if(dv.hasValue && !dv.value.type) {
UA_DataValue v;
UA_DataValue_init(&v);
retval = readValueAttribute(server, session, (const UA_VariableNode*)vt, &v);
Expand All @@ -439,6 +438,7 @@ useVariableTypeAttributes(UA_Server *server, UA_Session *session,
retval = UA_STATUSCODE_GOOD;
}
}
UA_DataValue_clear(&dv);

/* If no datatype is given, use the datatype of the vt */
if(UA_NodeId_isNull(&node->dataType)) {
Expand All @@ -461,6 +461,9 @@ useVariableTypeAttributes(UA_Server *server, UA_Session *session,
retval = writeAttribute(server, session, &node->head.nodeId,
UA_ATTRIBUTEID_ARRAYDIMENSIONS, &v,
&UA_TYPES[UA_TYPES_VARIANT]);

if(retval != UA_STATUSCODE_GOOD)
return retval;
}

return retval;
Expand Down

0 comments on commit ade6b14

Please sign in to comment.