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

A device base class 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 base class which saves telemetry.

CRTP class derivedT has the following requirements:

  • Must be a MagAOXApp
  • Must include the following friend declaration:
    friend class dev::telemeter<DERIVEDNAME>; //replace DERIVEDNAME with derivedT class name
  • Must include the following typedef:
    typedef dev::telemeter<DERIVEDNAME> telemeterT; //replace DERIVEDNAME with derivedT class name
  • Must implement the following interface:
    {
    // Must call this variadic template function with each relevant telemetry type exactly like this
    return telemeterT::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:281
    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 just used for variadic template resolution.
  • Must provide one overload of the following function for each telemetry type:
    int recordTelem( const telem_type1 * )
    {
    //DO NOT USE telem_type1
    return m_tel<telem_type1>( { message entered here } );
    }
    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.
  • Must call this class's setupConfig(), loadConfig(), appStartup(), appLogic(), and appShutdown() in the corresponding function of derivedT, with error checking. For convenience the following macros are defined to provide error checking:
    #define TELEMETER_APP_LOGIC
    Call telemeter::appLogic with error checking.
    Definition: telemeter.hpp:339
    #define TELEMETER_LOAD_CONFIG(cfig)
    Call telemeter::loadConfig with error checking.
    Definition: telemeter.hpp:325
    #define TELEMETER_APP_STARTUP
    Call telemeter::appStartup with error checking.
    Definition: telemeter.hpp:332
    #define TELEMETER_SETUP_CONFIG(cfig)
    Call telemeter::setupConfig with error checking.
    Definition: telemeter.hpp:314
    #define TELEMETER_APP_SHUTDOWN
    Call telemeter::appShutdown with error checking.
    Definition: telemeter.hpp:346

Definition at line 68 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 71 of file telemeter.hpp.

Constructor & Destructor Documentation

◆ telemeter()

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

Definition at line 180 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 268 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 241 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 281 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 303 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 291 of file telemeter.hpp.

◆ derived()

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

Access the derived class.

Definition at line 173 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 199 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 186 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 75 of file telemeter.hpp.

◆ m_tel

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

Definition at line 73 of file telemeter.hpp.


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