API
 
Loading...
Searching...
No Matches
MagAOXApp_test.hpp
Go to the documentation of this file.
1#ifndef app_tests_MagAOXApp_test_hpp
2#define app_tests_MagAOXApp_test_hpp
3
4namespace libXWCTest
5{
6namespace appTest
7{
8namespace MagAOXAppTest
9{
10
11#undef APP_XWCTEST_BASE
12#ifdef XWCTEST_NAMESPACE
13 #define APP_XWCTEST_BASE MagAOX::app::XWCTEST_NAMESPACE::MagAOXApp<true>
14#else
15 #define APP_XWCTEST_BASE MagAOX::app::MagAOXApp<true>
16#endif
17
18#ifdef XWCTEST_NAMESPACE
19namespace XWCTEST_NAMESPACE
20{
21#endif
22
24{
25 MagAOXApp_test( bool gitmod = false ) : MagAOXApp( "sha1", gitmod )
26 {
27 }
28
30 {
31 config.add( "name2", "", "name2", argType::Required, "", "", true, "string", "" );
32 config.m_sources = true;
33 }
34
35 void setup( int argc, char **argv )
36 {
37 APP_XWCTEST_BASE::setup( argc, argv );
38 }
39
40 virtual int appStartup()
41 {
42 return 0;
43 }
44 virtual int appLogic()
45 {
46 return 0;
47 }
48 virtual int appShutdown()
49 {
50 return 0;
51 }
52
53 std::string configPathGlobal()
54 {
55 return APP_XWCTEST_BASE::m_configPathGlobal;
56 }
57
58 std::string configPathUser()
59 {
60 return APP_XWCTEST_BASE::m_configPathUser;
61 }
62
63 std::string configPathLocal()
64 {
65 return APP_XWCTEST_BASE::m_configPathLocal;
66 }
67
68 std::string &invokedName()
69 {
70 return APP_XWCTEST_BASE::invokedName;
71 }
72
73 bool &doHelp()
74 {
75 return APP_XWCTEST_BASE::doHelp;
76 }
77
79 {
80 return APP_XWCTEST_BASE::m_configOnly;
81 }
82
83 void setPowerMgtEnabled( bool pme )
84 {
85 m_powerMgtEnabled = pme;
86 }
87
88 void setConfigName( const std::string &cn )
89 {
90 m_configName = cn;
91
92 m_indiDriver = new MagAOX::app::indiDriver<APP_XWCTEST_BASE>( this, m_configName, "0", "0" );
93 }
94
95 void setConfigBase( const std::string &cb )
96 {
97 m_configBase = cb;
98 }
99
100 int called_back{ 0 };
101
102 void setAlert()
103 {
104 m_stateAlert = true;
105 }
106
108 {
109 pcf::IndiProperty ip( pcf::IndiProperty::Switch );
110 ip.setDevice( configName() );
111 ip.setName( "fsm_clear_alert" );
112 ip.add( pcf::IndiElement( "request" ) );
113 ip["request"].setSwitchState( pcf::IndiElement::On );
114
115 st_newCallBack_clearFSMAlert( this, ip );
116 }
117
118 std::string powerDevice()
119 {
120 return m_powerDevice;
121 }
122
123 std::string powerChannel()
124 {
125 return m_powerChannel;
126 }
127
128 std::string powerElement()
129 {
130 return m_powerElement;
131 }
132
133 std::string powerTargetElement()
134 {
135 return m_powerTargetElement;
136 }
137
139 {
140 return m_powerOnWait;
141 }
142
144 {
145 return APP_XWCTEST_BASE::onPowerOff();
146 }
147
149 {
150 return APP_XWCTEST_BASE::whilePowerOff();
151 }
152
154 {
155 return APP_XWCTEST_BASE::powerOnWaitElapsed();
156 }
157
159 {
160 return APP_XWCTEST_BASE::powerState();
161 }
162
163 void configurePowerManagement( const std::string &device, const std::string &channel )
164 {
165 m_indiP_powerChannel = pcf::IndiProperty( pcf::IndiProperty::Text );
166 m_powerDevice = device;
167 m_indiP_powerChannel.setDevice( device );
168
169 m_powerChannel = channel;
170 m_indiP_powerChannel.setName( channel );
171 }
172
173 void configurePowerOnWait( unsigned long powerOnWait, int powerOnCounter, int loopPause )
174 {
175 m_powerOnWait = powerOnWait;
176 m_powerOnCounter = powerOnCounter;
177 m_loopPause = loopPause;
178 }
179
180 int setPowerState( const std::string &state, const std::string target )
181 {
182 pcf::IndiProperty ip( pcf::IndiProperty::Text );
183 ip.setDevice( m_powerDevice );
184 ip.setName( m_powerChannel );
185 ip.add( pcf::IndiElement( "state" ) );
186 ip["state"].setValue( state );
187
188 ip.add( pcf::IndiElement( "target" ) );
189 ip["target"].setValue( target );
190
191 return setCallBack_m_indiP_powerChannel( ip );
192 }
193
195 {
196 return APP_XWCTEST_BASE::setSigTermHandler();
197 }
198
199 void _handlerSigTerm( int signum, siginfo_t *siginf, void *ucont )
200 {
201 APP_XWCTEST_BASE::_handlerSigTerm( signum, siginf, ucont );
202 }
203
205 {
206 return APP_XWCTEST_BASE::setEuidReal();
207 }
208
209 int setEuidReal( int euidr )
210 {
211 m_euidReal = euidr;
212 return APP_XWCTEST_BASE::setEuidReal();
213 }
214
216 {
217 return APP_XWCTEST_BASE::setEuidCalled();
218 }
219
220 int setEuidCalled( int euidc )
221 {
222 m_euidCalled = euidc;
223 return APP_XWCTEST_BASE::setEuidCalled();
224 }
225
227 {
228 return APP_XWCTEST_BASE::lockPID();
229 }
230
232 {
233 return APP_XWCTEST_BASE::unlockPID();
234 }
235};
236
237int callback( void *app, const pcf::IndiProperty &ipRecv )
238{
239 static_cast<void>( ipRecv ); // be unused
240
241 MagAOXApp_test *appt = static_cast<MagAOXApp_test *>( app );
242
243 appt->called_back = 1;
244
245 return 0;
246}
247
248#ifdef XWCTEST_NAMESPACE
249} // namespace XWCTEST_NAMESPACE
250#endif
251
252} // namespace MagAOXAppTest
253} // namespace appTest
254} // namespace libXWCTest
255
256#endif // app_tests_MagAOXApp_test_hpp
#define XWCTEST_NAMESPACE
#define APP_XWCTEST_BASE
int callback(void *app, const pcf::IndiProperty &ipRecv)
void _handlerSigTerm(int signum, siginfo_t *siginf, void *ucont)
void configurePowerManagement(const std::string &device, const std::string &channel)
void configurePowerOnWait(unsigned long powerOnWait, int powerOnCounter, int loopPause)
int setPowerState(const std::string &state, const std::string target)