36 #include <yarp/os/SystemClock.h>
37 #include <yarp/os/Log.h>
38 #include <yarp/os/LogStream.h>
58 lastMissingReportTime = 0;
60 reportedMissing =
false;
74 if(
true == configuration.enabled)
76 yDebug() <<
"eth::EthMonitorPresence::config(): monitoring of presence is ON for BOARD" << configuration.
name <<
"with timeout =" << configuration.timeout <<
"sec and period of missing report =" << configuration.periodmissingreport <<
"sec";
80 yDebug() <<
"eth::EthMonitorPresence::config(): monitoring of presence is OFF for BOARD" << configuration.name;
87 configuration.enabled = en;
93 return configuration.enabled;
99 lastTickTime = yarp::os::SystemClock::nowSystem();
106 if(
false == configuration.enabled)
112 double tnow = yarp::os::SystemClock::nowSystem();
114 if((
true == reportedMissing) && (lastTickTime > 0))
116 yDebug() <<
"eth::EthMonitorPresence: BOARD" << configuration.name <<
"has shown after being lost for" << tnow - lastHeardTime <<
"sec";
117 reportedMissing =
false;
118 lastHeardTime = tnow;
121 if((
true == reportedMissing) && (configuration.periodmissingreport > 0))
124 if((tnow - lastMissingReportTime) >= configuration.periodmissingreport)
126 yDebug() <<
"eth::EthMonitorPresence: BOARD" << configuration.name <<
"has been silent for another" << tnow - lastMissingReportTime <<
"sec, for a total of" << tnow - lastHeardTime <<
"sec";
127 lastMissingReportTime = tnow;
134 double delta = tnow - lastTickTime;
136 if(delta > configuration.timeout)
138 yDebug() <<
"eth::EthMonitorPresence: BOARD" << configuration.name <<
"has been silent for" << delta <<
"sec (its timeout is" << configuration.timeout <<
"sec)";
141 lastMissingReportTime = tnow;
142 reportedMissing =
true;
143 lastHeardTime = lastTickTime;
void config(const Config &cfg)