9 #ifndef app_telemeter_hpp
10 #define app_telemeter_hpp
50 template<
class derivedT>
69 template<
typename telT>
70 int telem(
const typename telT::messageT &
msg );
79 template<
typename telT>
130 template<
class telT,
class... telTs>
141 template<
class telT,
class... telTs>
159 return *
static_cast<derivedT *
>(
this);
163 template<
class derivedT>
168 template<
class derivedT>
169 template<
typename telT>
176 clock_gettime(CLOCK_REALTIME, &telT::lastRecord);
181 template<
class derivedT>
182 template<
typename telT>
189 clock_gettime(CLOCK_REALTIME, &telT::lastRecord);
194 template<
class derivedT>
197 m_tel.m_configSection =
"telemeter";
200 m_tel.setupConfig(config);
202 config.add(
"telemeter.maxInterval",
"",
"telemeter.maxInterval", argType::Required,
"telemeter",
"maxInterval",
false,
"double",
"The maximum interval, in seconds, between telemetry records. Default is 10.0 seconds.");
207 template<
class derivedT>
214 m_tel.logExt(
"bintel");
216 m_tel.logName(derived().m_configName);
218 m_tel.loadConfig(config);
220 config(m_maxInterval,
"telemeter.maxInterval");
225 template<
class derivedT>
232 m_tel.logThreadStart();
236 while(m_tel.logThreadRunning() ==
false && w < 20)
239 std::this_thread::sleep_for( std::chrono::duration<unsigned long, std::nano>(100000000));
243 if(m_tel.logThreadRunning() ==
false)
245 derivedT::template log<software_critical>({__FILE__, __LINE__,
"telemetry thread not running. exiting."});
252 template<
class derivedT>
255 return derived().checkRecordTimes();
258 template<
class derivedT>
264 template<
class derivedT>
265 template<
class telT,
class... telTs>
270 clock_gettime(CLOCK_REALTIME, &ts);
271 return checkRecordTimes(ts, tel, tels...);
275 template<
class derivedT>
276 template<
class telT,
class... telTs>
280 if( ( (
double) ts.tv_sec - ((
double) ts.tv_nsec)/1e9)- ((
double) telT::lastRecord.tv_sec - ((
double) telT::lastRecord.tv_nsec)/1e9) > m_maxInterval - ((
double)derived().m_loopPause) / 1e9)
282 derived().recordTelem( &tel );
285 return checkRecordTimes(ts, tels...);
289 template<
class derivedT>
292 static_cast<void>(ts);
#define MAGAOX_telRelPath
The relative path to the telemetry directory.
constexpr static logPrioT LOG_TELEM
A telemetry recording.
A device which saves telemetry.
double m_maxInterval
The maximum interval, in seconds, between telemetry records. Default is 10.0 seconds.
int telem()
Make a telemetry recording, for an empty record.
int appShutdown()
Perform telemeter application shutdown.
int loadConfig(appConfigurator &config)
Load the device section from an application configurator.
int telem(const typename telT::messageT &msg)
Make a telemetry recording.
int appLogic()
Perform telemeter application logic.
logger::logManager< derivedT, logFileRaw > logManagerT
The log manager type.
int checkRecordTimes(timespec &ts)
Empty function called at the end of the template list.
int setupConfig(appConfigurator &config)
Setup an application configurator for the device section.
int appStartup()
Starts the telemetry log thread.
int checkRecordTimes(timespec &ts, const telT &tel, telTs... tels)
Worker function to actually perform the record time checking logic.
int checkRecordTimes(const telT &tel, telTs... tels)
Check the time of the last record for each telemetry type and make an entry if needed.
derivedT & derived()
Access the derived class.