Commit 1b59a872 authored by Ivan Tyagov's avatar Ivan Tyagov

Small optimisation.

parent 4466677a
...@@ -6,7 +6,7 @@ char *NETWORK_ADDRESS_URL_DATA_TYPE = "opc.udp://224.0.0.22:4840/"; ...@@ -6,7 +6,7 @@ char *NETWORK_ADDRESS_URL_DATA_TYPE = "opc.udp://224.0.0.22:4840/";
static unsigned int HEART_BEATS = 0; static unsigned int HEART_BEATS = 0;
// the heart beat interval$$ // the heart beat interval$$
const int DEFAULT_HEART_BEAT_INTERVAL = 50; const int DEFAULT_HEART_BEAT_INTERVAL = 10;
static int HEART_BEAT_INTERVAL = DEFAULT_HEART_BEAT_INTERVAL; static int HEART_BEAT_INTERVAL = DEFAULT_HEART_BEAT_INTERVAL;
// the timeout in millis after which a coupler is considered down // the timeout in millis after which a coupler is considered down
......
...@@ -25,7 +25,7 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore ...@@ -25,7 +25,7 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
void *monitoredItemContext, const UA_NodeId *nodeId, void *monitoredItemContext, const UA_NodeId *nodeId,
void *nodeContext, UA_UInt32 attributeId, void *nodeContext, UA_UInt32 attributeId,
const UA_DataValue *var) { const UA_DataValue *var) {
unsigned long int milli_seconds_now = getMilliSecondsSinceEpoch(); unsigned long int milli_seconds_now;
unsigned int coupler_id; unsigned int coupler_id;
// filter out ID from Data Set // filter out ID from Data Set
...@@ -54,6 +54,7 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore ...@@ -54,6 +54,7 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
// filter out heart_beat from Data Set // filter out heart_beat from Data Set
if(UA_Variant_hasScalarType(&var->value, &UA_TYPES[UA_TYPES_FLOAT])) { if(UA_Variant_hasScalarType(&var->value, &UA_TYPES[UA_TYPES_FLOAT])) {
float heart_beat = *(UA_Float*) var->value.data; float heart_beat = *(UA_Float*) var->value.data;
milli_seconds_now = getMilliSecondsSinceEpoch();
// split <ID>.<heart_beats>, just converting to int is enough // split <ID>.<heart_beats>, just converting to int is enough
coupler_id = (int) heart_beat; coupler_id = (int) heart_beat;
if (coupler_id!=COUPLER_ID) { if (coupler_id!=COUPLER_ID) {
...@@ -217,7 +218,7 @@ static UA_StatusCode addSubscribedVariables(UA_Server *server, UA_NodeId dataSet ...@@ -217,7 +218,7 @@ static UA_StatusCode addSubscribedVariables(UA_Server *server, UA_NodeId dataSet
if (ENABLE_HEART_BEAT_CHECK) { if (ENABLE_HEART_BEAT_CHECK) {
UA_MonitoredItemCreateRequest monRequest = UA_MonitoredItemCreateRequest_default(newNode); UA_MonitoredItemCreateRequest monRequest = UA_MonitoredItemCreateRequest_default(newNode);
//monRequest.requestedParameters.samplingInterval = 100.0; /* 100 ms interval */ //monRequest.requestedParameters.samplingInterval = 100.0; /* 100 ms interval */
UA_Server_createDataChangeMonitoredItem(server, UA_TIMESTAMPSTORETURN_SOURCE, UA_Server_createDataChangeMonitoredItem(server, UA_TIMESTAMPSTORETURN_NEITHER,
monRequest, NULL, dataChangeNotificationCallback); monRequest, NULL, dataChangeNotificationCallback);
} }
/* For creating Targetvariables */ /* For creating Targetvariables */
......
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