Commit a98c0ae2 authored by Ivan Tyagov's avatar Ivan Tyagov

Simplify structure of Pub/Sub variables' structure and make it now generic.

parent 538090e5
......@@ -99,17 +99,15 @@ typedef struct PublishedVariable {
char *name;
char *description;
void * UA_RESTRICT pdefaultValue;
UA_DataType type;
int type;
} PublishedVariable;
static void addPubSubVariable(UA_Server *server, PublishedVariable varDetails) {
UA_VariableAttributes attr = UA_VariableAttributes_default;
//UA_Variant_setScalar(&attr.value, varDetails.pdefaultValue, &varDetails.type);
UA_Variant_setScalar(&attr.value, varDetails.pdefaultValue, &UA_TYPES[UA_TYPES_INT32]); //XXX: hard-code for INT32 only, make generic
UA_Variant_setScalar(&attr.value, varDetails.pdefaultValue, &UA_TYPES[varDetails.type]);
attr.description = UA_LOCALIZEDTEXT("en-US", varDetails.description);
attr.displayName = UA_LOCALIZEDTEXT("en-US", varDetails.description);
//attr.dataType = varDetails.type.typeId;
attr.dataType = UA_TYPES[UA_TYPES_INT32].typeId; //XXX: hard-code for INT32 only, make generic
attr.dataType = UA_TYPES[varDetails.type].typeId;
attr.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;
UA_Server_addVariableNode(server, UA_NODEID_STRING(1, varDetails.name),
......
......@@ -267,14 +267,14 @@ int main(int argc, char **argv)
.name = "heart_beat",
.description = "Heart beat",
.pdefaultValue = &defaultInt32,
.type = UA_TYPES[UA_TYPES_INT32]
.type = UA_TYPES_INT32
},
// representing the ID of the coupler
{
.name = "id",
.description = "ID",
.pdefaultValue = &couplerID,
.type = UA_TYPES[UA_TYPES_INT32]
.type = UA_TYPES_INT32
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment