1#ifndef app_tests_MagAOXApp_test_hpp
2#define app_tests_MagAOXApp_test_hpp
11#undef APP_XWCTEST_BASE
12#ifdef XWCTEST_NAMESPACE
13 #define APP_XWCTEST_BASE MagAOX::app::XWCTEST_NAMESPACE::MagAOXApp<true>
15 #define APP_XWCTEST_BASE MagAOX::app::MagAOXApp<true>
18#ifdef XWCTEST_NAMESPACE
33 bool appStartupFail{
false };
34 bool appLogicFail{
false };
35 bool appShutdownFail{
false };
39 config.add(
"name2",
"",
"name2", argType::Required,
"",
"",
true,
"string",
"" );
40 config.m_sources =
true;
43 void setup(
int argc,
char **argv )
45 APP_XWCTEST_BASE::setup( argc, argv );
80 return APP_XWCTEST_BASE::m_configPathGlobal;
85 return APP_XWCTEST_BASE::m_configPathUser;
90 return APP_XWCTEST_BASE::m_configPathLocal;
95 return APP_XWCTEST_BASE::invokedName;
100 return APP_XWCTEST_BASE::doHelp;
105 return APP_XWCTEST_BASE::m_configOnly;
110 m_powerMgtEnabled = pme;
125 int called_back{ 0 };
134 pcf::IndiProperty ip( pcf::IndiProperty::Switch );
135 ip.setDevice( configName() );
136 ip.setName(
"fsm_clear_alert" );
137 ip.add( pcf::IndiElement(
"request" ) );
138 ip[
"request"].setSwitchState( pcf::IndiElement::On );
140 st_newCallBack_clearFSMAlert(
this, ip );
145 return m_powerDevice;
150 return m_powerChannel;
155 return m_powerElement;
160 return m_powerTargetElement;
165 return m_powerOnWait;
170 return APP_XWCTEST_BASE::onPowerOff();
175 return APP_XWCTEST_BASE::whilePowerOff();
180 return APP_XWCTEST_BASE::powerOnWaitElapsed();
185 return APP_XWCTEST_BASE::powerState();
190 m_indiP_powerChannel = pcf::IndiProperty( pcf::IndiProperty::Text );
191 m_powerDevice = device;
192 m_indiP_powerChannel.setDevice( device );
194 m_powerChannel = channel;
195 m_indiP_powerChannel.setName( channel );
200 m_powerOnWait = powerOnWait;
201 m_powerOnCounter = powerOnCounter;
202 m_loopPause = loopPause;
207 pcf::IndiProperty ip( pcf::IndiProperty::Text );
208 ip.setDevice( m_powerDevice );
209 ip.setName( m_powerChannel );
210 ip.add( pcf::IndiElement(
"state" ) );
211 ip[
"state"].setValue( state );
213 ip.add( pcf::IndiElement(
"target" ) );
214 ip[
"target"].setValue( target );
216 return setCallBack_m_indiP_powerChannel( ip );
221 return APP_XWCTEST_BASE::setSigTermHandler();
226 _handlerSigTerm( signum, siginf, ucont );
231 return APP_XWCTEST_BASE::setEuidReal();
240 return APP_XWCTEST_BASE::setEuidReal();
248 elevatedPrivileges elPriv(
this );
257 return APP_XWCTEST_BASE::setEuidCalled();
262 m_euidCalled = euidc;
263 return APP_XWCTEST_BASE::setEuidCalled();
268 return APP_XWCTEST_BASE::lockPID();
273 return APP_XWCTEST_BASE::unlockPID();
277 int m_threadPrio{ 0 };
281 bool m_threadInit{
true };
283 pid_t m_threadID{ 0 };
289 bool m_threadRunning {
false};
290 bool m_threadStopped {
false};
291 int m_threadError {0};
295 if( threadStart( m_thread,
303 threadStarter ) < 0 )
310 while(m_threadError == 0 && m_threadRunning ==
false)
315 if(m_threadError != 0)
317 return m_threadError;
320 if(m_threadRunning !=
true)
325 m_threadRunning =
false;
327 while(m_threadError == 0 && m_threadStopped ==
false)
332 if(m_threadError != 0)
334 return m_threadError;
351 m_threadID = syscall( SYS_gettid );
355 while( m_threadInit ==
true && n < 5)
367 std::cerr <<
"threading\n";
369 m_threadRunning =
true;
371 while(m_threadRunning)
376 m_threadRunning =
false;
377 m_threadStopped =
true;
381int callback(
void *app,
const pcf::IndiProperty &ipRecv )
383 static_cast<void>( ipRecv );
392#ifdef XWCTEST_NAMESPACE
#define XWCAPP_THREAD_STOP(thrdSt)
Error handlng wrapper for stopping a thread.
int callback(void *app, const pcf::IndiProperty &ipRecv)
Namespace for all libXWC tests.
MagAOXApp_test(bool gitmod=false)
std::string powerDevice()
~MagAOXApp_test() noexcept(true)
void configurePowerManagement(const std::string &device, const std::string &channel)
int setEuidReal(int euidr, bool set=true)
std::string configPathUser()
static void threadStarter(MagAOXApp_test *o)
Thread starter, called by MagAOXApp::threadStart on thread construction. Calls threadExec.
void configurePowerOnWait(unsigned long powerOnWait, int powerOnCounter, int loopPause)
std::string & invokedName()
std::string powerElement()
void setConfigBase(const std::string &cb)
int setPowerState(const std::string &state, const std::string target)
std::string m_cpuset
The cpuset to assign the framegrabber thread to. Not used if empty, the default.
void threadExec()
Execute framegrabbing.
std::string configPathLocal()
bool powerOnWaitElapsed()
void setConfigName(const std::string &cn)
std::string powerTargetElement()
void setPowerMgtEnabled(bool pme)
int setEuidCalled(int euidc)
std::string configPathGlobal()
pcf::IndiProperty m_threadProp
The property to hold the thread details.
int p_elevatePriveleges()
void p_handlerSigTerm(int signum, siginfo_t *siginf, void *ucont)
std::thread m_thread
A separate thread.
std::string powerChannel()
void setup(int argc, char **argv)
virtual int appShutdown()
#define XWCTEST_NAMESPACE