Commit 502ab54b authored by Ivan Tyagov's avatar Ivan Tyagov

Add heart_beat callback. Cleanup tabulations.

parent 0de27517
...@@ -37,6 +37,11 @@ ...@@ -37,6 +37,11 @@
// global Id of coupler // global Id of coupler
static int COUPLER_ID = 0; static int COUPLER_ID = 0;
// global HEART BEATs of coupler
static int HEART_BEATS = 0;
// the heart beat interval
static int HEART_BEAT_INTERVAL = 250;
// The default port of OPC-UA server // The default port of OPC-UA server
const int DEFAULT_OPC_UA_PORT = 4840; const int DEFAULT_OPC_UA_PORT = 4840;
const int DEFAULT_MODE = 0; const int DEFAULT_MODE = 0;
...@@ -122,6 +127,14 @@ static void stopHandler(int sign) ...@@ -122,6 +127,14 @@ static void stopHandler(int sign)
running = false; running = false;
} }
void callbackTicHeartBeat()
{
/* Increase periodically heart beats of the server */
HEART_BEATS += 1;
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "heart_beat %d", HEART_BEATS);
// XXX: set OPC ua's heat_beat value
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int i; int i;
...@@ -180,7 +193,7 @@ int main(int argc, char **argv) ...@@ -180,7 +193,7 @@ int main(int argc, char **argv)
UA_ServerConfig *config = UA_Server_getConfig(server); UA_ServerConfig *config = UA_Server_getConfig(server);
config->verifyRequestTimestamp = UA_RULEHANDLING_ACCEPT; config->verifyRequestTimestamp = UA_RULEHANDLING_ACCEPT;
// add variables representing physical relarys / inputs, etc // add variables representing physical relaray / inputs, etc
addVariable(server); addVariable(server);
addValueCallbackToCurrentTimeVariable(server); addValueCallbackToCurrentTimeVariable(server);
...@@ -229,8 +242,13 @@ int main(int argc, char **argv) ...@@ -229,8 +242,13 @@ int main(int argc, char **argv)
#endif #endif
// enable keep-alive // enable keep-alive
UA_Int32 defaultInt32 = 0;
UA_Int32 couplerID = COUPLER_ID; // add a callback which will increment heart beat tics
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
const PublishedVariable publishedVariableArray[] = { const PublishedVariable publishedVariableArray[] = {
// representing time in millis since start of process // representing time in millis since start of process
{ {
......
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