API
MagAOXApp.hpp File Reference
#include <signal.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <thread>
#include <mutex>
#include <unordered_map>
#include <mx/mxlib.hpp>
#include <mx/app/application.hpp>
#include <mx/sys/environment.hpp>
#include <mx/sys/timeUtils.hpp>
#include <mx/ioutils/fileUtils.hpp>
#include "../common/environment.hpp"
#include "../common/paths.hpp"
#include "../common/defaults.hpp"
#include "../common/config.hpp"
#include "../logger/logFileRaw.hpp"
#include "../logger/logManager.hpp"
#include "../sys/thSetuid.hpp"
#include "stateCodes.hpp"
#include "indiDriver.hpp"
#include "indiMacros.hpp"
#include "indiUtils.hpp"
Include dependency graph for MagAOXApp.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  MagAOX::app::MagAOXApp< _useINDI >
 The base-class for MagAO-X applications. More...
 
class  MagAOX::app::MagAOXApp< _useINDI >::elevatedPrivileges
 Internal class to manage setuid privilege escalation with RAII. More...
 
struct  MagAOX::app::MagAOXApp< _useINDI >::indiCallBack
 Structure to hold the call-back details for handling INDI communications. More...
 

Namespaces

 MagAOX
 
 MagAOX::app
 

Macros

#define XWCAPP_THREAD_START(thrdSt, thrdInit, thrdId, thrdProp, thrdPrio, thrdCpuset, thrdName, thrdStart)
 Error handling wrapper for the threadStart function of the XWCApp. More...
 
#define XWCAPP_THREAD_CHECK(thrdSt, thrdName)
 Error handling wrapper for checking on thread status with tryjoin. More...
 
#define XWCAPP_THREAD_STOP(thrdSt)
 Error handlng wrapper for stopping a thread. More...
 

Functions

void MagAOX::app::sigUsr1Handler (int signum, siginfo_t *siginf, void *ucont)
 Empty signal handler. SIGUSR1 is used to interrupt sleep in various threads. More...
 
template<typename T >
pcf::IndiProperty::Type MagAOX::app::propType ()
 
template<>
pcf::IndiProperty::Type MagAOX::app::propType< char * > ()
 
template<>
pcf::IndiProperty::Type MagAOX::app::propType< std::string > ()
 
template<>
pcf::IndiProperty::Type MagAOX::app::propType< int > ()
 
template<>
pcf::IndiProperty::Type MagAOX::app::propType< double > ()
 
 MagAOX::app::if (ipRecv.find(m_powerElement))
 
 MagAOX::app::if (ipRecv.find(m_powerTargetElement))
 

Variables

template<bool _useINDI>
const pcf::IndiProperty & MagAOX::app::ipRecv
 
 MagAOX::app::return
 

Macro Definition Documentation

◆ XWCAPP_THREAD_CHECK

#define XWCAPP_THREAD_CHECK (   thrdSt,
  thrdName 
)
Value:
try \
{ \
if( pthread_tryjoin_np( thrdSt.native_handle(), 0 ) == 0 ) \
{ \
log<software_error>( { __FILE__, __LINE__, #thrdName " thread has exited" } ); \
return -1; \
} \
} \
catch( ... ) \
{ \
log<software_error>( { __FILE__, __LINE__, #thrdName " thread has exited" } ); \
return -1; \
}

Error handling wrapper for checking on thread status with tryjoin.

This should be placed in appLogic for each thread managed by an MagAOXApp. If the thread has exited or otherwise causes an error the app will exit.

Parameters
thrdSt[in] (std::thread) The thread object to start executing
thrdName[in] (const std::string &) The name of the thread (just for logging)

Definition at line 3541 of file MagAOXApp.hpp.

◆ XWCAPP_THREAD_START

#define XWCAPP_THREAD_START (   thrdSt,
  thrdInit,
  thrdId,
  thrdProp,
  thrdPrio,
  thrdCpuset,
  thrdName,
  thrdStart 
)
Value:
if( threadStart( thrdSt, thrdInit, thrdId, thrdProp, thrdPrio, thrdCpuset, thrdName, this, thrdStart ) < 0 ) \
{ \
log<software_error>( { __FILE__, __LINE__, "error from threadStart for " #thrdName } ); \
return -1; \
}

Error handling wrapper for the threadStart function of the XWCApp.

This should be placed in appLogic for each thread managed by an MagAOXApp. On error, this will cause the app to shutdown.

See also
MagAOXApp::threadStart
Parameters
thrdSt[out] (std::thread) The thread object to start executing
thrdInit[in/out] (bool) The thread initilization synchronizer.
thrdId[in/out] (pid_t) The thread pid to be filled in by thrdStart immediately upon call
thrdProp[in/out](pcf::IndiProperty) The INDI property to publish the thread details
thrdPrio[in] (int) The r/t priority to set for this thread
thrdCpuset[in] (const std::string &) the cpuset to place this thread on. Ignored if "".
thrdName[in] (const std::string &) The name of the thread (just for logging)
thrdStart[in] (function) The thread starting function, a static function taking a this pointer as argument.

Definition at line 3527 of file MagAOXApp.hpp.

◆ XWCAPP_THREAD_STOP

#define XWCAPP_THREAD_STOP (   thrdSt)
Value:
if( thrdSt.joinable() ) \
{ \
pthread_kill( thrdSt.native_handle(), SIGUSR1 ); \
try \
{ \
thrdSt.join(); \
} \
catch( ... ) \
{ \
} \
}

Error handlng wrapper for stopping a thread.

This should be placed in appShutdown for each thread managed by an MagAOXApp.

Parameters
thrdSt[in] (std::thread) The thread object to start executing

Definition at line 3561 of file MagAOXApp.hpp.