Commit f5265d02 authored by Ivan Tyagov's avatar Ivan Tyagov

When a coupler is in a DOWN state it must NOT

increase it heart beats which itself will cause
dependent couplers to detect that a coupler is DOWN.
parent 5d3573e2
...@@ -39,7 +39,7 @@ char *NETWORK_INTERFACE = ""; ...@@ -39,7 +39,7 @@ char *NETWORK_INTERFACE = "";
static unsigned int HEART_BEATS = 0; static unsigned int HEART_BEATS = 0;
// handling coupler's state // handling coupler's state
static unsigned int CURRENT_STATE; static int CURRENT_STATE=-1;
const int STATE_UP = 1; const int STATE_UP = 1;
const int STATE_DOWN = 0; const int STATE_DOWN = 0;
const int STATE_NO_INITIAL_HEART_BEAT = 2; const int STATE_NO_INITIAL_HEART_BEAT = 2;
......
...@@ -147,6 +147,7 @@ static void addPubSubDataSetField(UA_Server *server, PublishedVariable varDetail ...@@ -147,6 +147,7 @@ static void addPubSubDataSetField(UA_Server *server, PublishedVariable varDetail
void callbackTicHeartBeat() void callbackTicHeartBeat()
{ {
if (CURRENT_STATE != STATE_DOWN) {
/* Increase periodically heart beats of the server */ /* Increase periodically heart beats of the server */
HEART_BEATS += 1; HEART_BEATS += 1;
...@@ -174,6 +175,7 @@ void callbackTicHeartBeat() ...@@ -174,6 +175,7 @@ void callbackTicHeartBeat()
UA_Variant_init(&myVar); UA_Variant_init(&myVar);
UA_Variant_setScalar(&myVar, &myFloat, &UA_TYPES[UA_TYPES_FLOAT]); UA_Variant_setScalar(&myVar, &myFloat, &UA_TYPES[UA_TYPES_FLOAT]);
UA_Server_writeValue(server, myFloatNodeId, myVar); UA_Server_writeValue(server, myFloatNodeId, myVar);
}
} }
static void enablePublishHeartBeat(UA_Server *server){ static void enablePublishHeartBeat(UA_Server *server){
......
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