API
MagAOX::app::dev::telemeter< derivedT > Struct Template Reference

A device which saves telemetry. More...

#include <telemeter.hpp>

Collaboration diagram for MagAOX::app::dev::telemeter< derivedT >:
Collaboration graph

Public Types

typedef logger::logManager< derivedT, logFileRaw > logManagerT
 The log manager type. More...
 

Public Member Functions

 telemeter ()
 
template<typename telT >
int telem (const typename telT::messageT &msg)
 Make a telemetry recording. More...
 
template<typename telT >
int telem ()
 Make a telemetry recording, for an empty record. More...
 
int setupConfig (appConfigurator &config)
 Setup an application configurator for the device section. More...
 
int loadConfig (appConfigurator &config)
 Load the device section from an application configurator. More...
 
int appStartup ()
 Starts the telemetry log thread. More...
 
int appLogic ()
 Perform telemeter application logic. More...
 
int appShutdown ()
 Perform telemeter application shutdown. More...
 
template<class telT , class... telTs>
int checkRecordTimes (const telT &tel, telTs... tels)
 Check the time of the last record for each telemetry type and make an entry if needed. More...
 
template<class telT , class... telTs>
int checkRecordTimes (timespec &ts, const telT &tel, telTs... tels)
 Worker function to actually perform the record time checking logic. More...
 
int checkRecordTimes (timespec &ts)
 Empty function called at the end of the template list. More...
 

Public Attributes

logManagerT m_tel
 
double m_maxInterval {10.0}
 The maximum interval, in seconds, between telemetry records. Default is 10.0 seconds. More...
 

Private Member Functions

derivedT & derived ()
 Access the derived class. More...
 

Detailed Description

template<class derivedT>
struct MagAOX::app::dev::telemeter< derivedT >

A device which saves telemetry.

The derivedT class must be a MagAOXApp, and must implement the following interface:

1) int checkRecordTimes() This function MUST be implemented as follows:

{
return dev::telemeter<derivedT>::checkRecordTimes( telem_type1(), telem_type2(), ..., telem_typeN());
}
int checkRecordTimes(const telT &tel, telTs... tels)
Check the time of the last record for each telemetry type and make an entry if needed.
Definition: telemeter.hpp:266

where there is one constructor-call argument for each telemetry log type recorded by this device. The resultant objects are not used, rather the types are used for variadic template resolution.

2) Next, there must be one overload of the function

int recordTelem( telem_type1 * )
{
return m_tel<telem_type1>( { message entered here } );
}

for each of the telemetry types. You MUST NOT use the pointer argument, it is for type resolution only – you should fill in the telemetry log message using internal values. Note that calls to this function should result in a telemetry log entry every time – it is called when the minimum interval has elapsed since the last entry.

Additionally, calls to this classes setupConfig, loadConfig, appStartup, appLogic, and appShutdown should be placed in the corresponding function of derivedT, with error checking.

Definition at line 51 of file telemeter.hpp.

Member Typedef Documentation

◆ logManagerT

template<class derivedT >
typedef logger::logManager<derivedT, logFileRaw> MagAOX::app::dev::telemeter< derivedT >::logManagerT

The log manager type.

Definition at line 54 of file telemeter.hpp.

Constructor & Destructor Documentation

◆ telemeter()

template<class derivedT >
MagAOX::app::dev::telemeter< derivedT >::telemeter

Definition at line 164 of file telemeter.hpp.

Member Function Documentation

◆ appLogic()

template<class derivedT >
int MagAOX::app::dev::telemeter< derivedT >::appLogic

Perform telemeter application logic.

This calls derivedT::checkRecordTimes(), and should be called from derivedT::appLogic, but only when the FSM is in states where telemetry logging makes sense.

Returns
0 on success
-1 on error

Definition at line 253 of file telemeter.hpp.

◆ appShutdown()

◆ appStartup()

template<class derivedT >
int MagAOX::app::dev::telemeter< derivedT >::appStartup

Starts the telemetry log thread.

This should be called from derivedT::appStartup

Returns
0 on success
-1 on error

Definition at line 226 of file telemeter.hpp.

Referenced by MagAOX::app::smc100ccCtrl::appStartup().

◆ checkRecordTimes() [1/3]

template<class derivedT >
template<class telT , class... telTs>
int MagAOX::app::dev::telemeter< derivedT >::checkRecordTimes ( const telT &  tel,
telTs...  tels 
)

Check the time of the last record for each telemetry type and make an entry if needed.

This must be called from derivedT::checkRecordTimes(), with one template parameter for ach telemetry log type being recorded.

Returns
0 on succcess
-1 on error
Parameters
[in]tel[unused] object of the telemetry type to record
[in]tels[unused] objects of the additional telemetry types to record

Definition at line 266 of file telemeter.hpp.

Referenced by MagAOX::app::filterWheelCtrl::checkRecordTimes(), MagAOX::app::hsfwCtrl::checkRecordTimes(), MagAOX::app::rhusbMon::checkRecordTimes(), and MagAOX::app::usbtempMon::checkRecordTimes().

◆ checkRecordTimes() [2/3]

template<class derivedT >
int MagAOX::app::dev::telemeter< derivedT >::checkRecordTimes ( timespec &  ts)

Empty function called at the end of the template list.

Returns
0 on succcess
-1 on error
Parameters
[in]ts[unused] the timestamp that records are compared to

Definition at line 290 of file telemeter.hpp.

◆ checkRecordTimes() [3/3]

template<class derivedT >
template<class telT , class... telTs>
int MagAOX::app::dev::telemeter< derivedT >::checkRecordTimes ( timespec &  ts,
const telT &  tel,
telTs...  tels 
)

Worker function to actually perform the record time checking logic.

Recursively calls itself until the variadic template list is exhausted.

Returns
0 on succcess
-1 on error
Parameters
[in]ts[unused] the timestamp that records are compared to
[in]tel[unused] objects of the telemetry type to record
[in]tels[unused] objects of the additional telemetry types to record

Definition at line 277 of file telemeter.hpp.

◆ derived()

template<class derivedT >
derivedT& MagAOX::app::dev::telemeter< derivedT >::derived ( )
inlineprivate

Access the derived class.

Definition at line 157 of file telemeter.hpp.

◆ loadConfig()

◆ setupConfig()

◆ telem() [1/2]

template<class derivedT >
template<typename telT >
int MagAOX::app::dev::telemeter< derivedT >::telem

Make a telemetry recording, for an empty record.

Wrapper for logManager::log, which updates telT::lastRecord.

Template Parameters
logTthe log entry type
retvalthe value returned by this method.

Definition at line 183 of file telemeter.hpp.

Referenced by visxCtrl.xapp.VisX::emit_telem_stdcam(), audibleAlerts.core.AudibleAlerts::handle_reload_request(), and audibleAlerts.core.AudibleAlerts::handle_speech_request().

◆ telem() [2/2]

template<class derivedT >
template<typename telT >
int MagAOX::app::dev::telemeter< derivedT >::telem ( const typename telT::messageT &  msg)

Make a telemetry recording.

Wrapper for logManager::log, which updates telT::lastRecord.

Template Parameters
logTthe log entry type
retvalthe value returned by this method.
Parameters
[in]msgthe data to log

Definition at line 170 of file telemeter.hpp.

Referenced by visxCtrl.xapp.VisX::emit_telem_stdcam(), audibleAlerts.core.AudibleAlerts::handle_reload_request(), and audibleAlerts.core.AudibleAlerts::handle_speech_request().

Member Data Documentation

◆ m_maxInterval

template<class derivedT >
double MagAOX::app::dev::telemeter< derivedT >::m_maxInterval {10.0}

The maximum interval, in seconds, between telemetry records. Default is 10.0 seconds.

Definition at line 58 of file telemeter.hpp.

◆ m_tel

template<class derivedT >
logManagerT MagAOX::app::dev::telemeter< derivedT >::m_tel

Definition at line 56 of file telemeter.hpp.


The documentation for this struct was generated from the following file: