Commit b55ee0b9 authored by Ivan Tyagov's avatar Ivan Tyagov

Enable heart beat checks only if we have list of IDs to check.

parent ba769996
......@@ -19,7 +19,7 @@ static struct argp_option options[] = {
{"heart-beat", 'b', "0", 0, "Publish heart beat to other couplers."},
{"heart-beat-interval", 't', "500", 0, "Heart beat interval in ms."},
{"heart-beat-id-list", 'l', "", 0, "Comma separated list of IDs of couplers to watch for heart beats. \
If heart beat is missing coupler goes to safe mode."},
If a heart beat is missing coupler goes to safe mode."},
{"network-address-url-data-type", 'n', "opc.udp://224.0.0.22:4840/", 0, "Netwrok address URL type used for Pub/Sub."},
{0}
......@@ -114,6 +114,7 @@ void handleCLI(int argc, char **argv) {
arguments.certificate = "";
arguments.id = DEFAULT_COUPLER_ID;
arguments.heart_beat_interval = DEFAULT_HEART_BEAT_INTERVAL;
arguments.heart_beat_id_list = "";
arguments.network_address_url_data_type = NETWORK_ADDRESS_URL_DATA_TYPE;
argp_parse(&argp, argc, argv, 0, 0, &arguments);
......@@ -163,6 +164,8 @@ void handleCLI(int argc, char **argv) {
// from CLI we get a comma separated list on INTs representing coupler' ID
result = strtol(tk, &eptr, 16);
HEART_BEAT_ID_LIST[i++] = result;
// enable heart beat checks
ENABLE_HEART_BEAT_CHECK = true;
tk = strtok(NULL, ",");
}
}
......
......@@ -196,10 +196,11 @@ static UA_StatusCode addSubscribedVariables(UA_Server *server, UA_NodeId dataSet
UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
vAttr, NULL, &newNode);
/*monitor variable*/
if (ENABLE_HEART_BEAT_CHECK) {
UA_MonitoredItemCreateRequest monRequest = UA_MonitoredItemCreateRequest_default(newNode);
UA_Server_createDataChangeMonitoredItem(server, UA_TIMESTAMPSTORETURN_SOURCE,
monRequest, NULL, dataChangeNotificationCallback);
}
/* For creating Targetvariables */
UA_FieldTargetDataType_init(&targetVars[i].targetVariable);
targetVars[i].targetVariable.attributeId = UA_ATTRIBUTEID_VALUE;
......
......@@ -49,6 +49,7 @@ const int DEFAULT_COUPLER_ID = 0;
int OPC_UA_PORT;
bool ENABLE_HEART_BEAT = false;
bool ENABLE_HEART_BEAT_CHECK = false;
bool ENABLE_X509 = false;
bool ENABLE_USERNAME_PASSWORD_AUTHENTICATION = false;
char *USERNAME;
......
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