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