Commit 223dc70f authored by Ivan Tyagov's avatar Ivan Tyagov

Switch from int to unsigned int as anywa both values should ahve only positive values.

parent a98c0ae2
......@@ -38,7 +38,7 @@
static int COUPLER_ID = 0;
// global HEART BEATs of coupler
static int HEART_BEATS = 0;
static unsigned int HEART_BEATS = 0;
// the heart beat interval
static int HEART_BEAT_INTERVAL = 250;
......@@ -139,10 +139,10 @@ void callbackTicHeartBeat()
// set OPC UA's heat_beat node value
UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "heart_beat");
UA_Int32 myInteger = HEART_BEATS;
UA_UInt32 myInteger = HEART_BEATS;
UA_Variant myVar;
UA_Variant_init(&myVar);
UA_Variant_setScalar(&myVar, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
UA_Variant_setScalar(&myVar, &myInteger, &UA_TYPES[UA_TYPES_UINT32]);
UA_Server_writeValue(server, myIntegerNodeId, myVar);
}
......@@ -259,22 +259,22 @@ int main(int argc, char **argv)
UA_UInt64 callbackId = 1;
UA_Server_addRepeatedCallback(server, callbackTicHeartBeat, NULL, HEART_BEAT_INTERVAL, &callbackId);
UA_Int32 defaultInt32 = 0; //XXX: use unsigned int
UA_Int32 couplerID = COUPLER_ID; //XXX: use unsigned int
UA_UInt32 defaultUInt32 = 0;
UA_UInt32 couplerID = COUPLER_ID;
const PublishedVariable publishedVariableArray[] = {
// representing time in millis since start of process
{
.name = "heart_beat",
.description = "Heart beat",
.pdefaultValue = &defaultInt32,
.type = UA_TYPES_INT32
.pdefaultValue = &defaultUInt32,
.type = UA_TYPES_UINT32
},
// representing the ID of the coupler
{
.name = "id",
.description = "ID",
.pdefaultValue = &couplerID,
.type = UA_TYPES_INT32
.type = UA_TYPES_UINT32
}
};
......
......@@ -28,10 +28,10 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
void *monitoredItemContext, const UA_NodeId *nodeId,
void *nodeContext, UA_UInt32 attributeId,
const UA_DataValue *var) {
if(UA_Variant_hasScalarType(&var->value, &UA_TYPES[UA_TYPES_INT32])) {
if(UA_Variant_hasScalarType(&var->value, &UA_TYPES[UA_TYPES_UINT32])) {
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
"Received Notification with value %d",
*(UA_Int32*) var->value.data);
*(UA_UInt32*) var->value.data);
}
}
......@@ -221,17 +221,17 @@ static void fillTestDataSetMetaData(UA_DataSetMetaDataType *pMetaData) {
/* heartbeat */
UA_FieldMetaData_init (&pMetaData->fields[0]);
UA_NodeId_copy (&UA_TYPES[UA_TYPES_INT32].typeId,
UA_NodeId_copy (&UA_TYPES[UA_TYPES_UINT32].typeId,
&pMetaData->fields[0].dataType);
pMetaData->fields[0].builtInType = UA_NS0ID_INT32;
pMetaData->fields[0].builtInType = UA_NS0ID_UINT32;
pMetaData->fields[0].name = UA_STRING ("Heartbeat (subscribed)");
pMetaData->fields[0].valueRank = -1; /* scalar */
// ID
UA_FieldMetaData_init (&pMetaData->fields[1]);
UA_NodeId_copy (&UA_TYPES[UA_TYPES_INT32].typeId,
UA_NodeId_copy (&UA_TYPES[UA_TYPES_UINT32].typeId,
&pMetaData->fields[1].dataType);
pMetaData->fields[1].builtInType = UA_NS0ID_INT32;
pMetaData->fields[1].builtInType = UA_NS0ID_UINT32;
pMetaData->fields[1].name = UA_STRING ("ID (subscribed)");
pMetaData->fields[1].valueRank = -1; /* scalar */
}
......
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