2#include "../../../tests/catch2/catch.hpp"
4#include <mx/sys/timeUtils.hpp>
6#include "../MagAOXApp.hpp"
76 pcf::IndiProperty
ip(pcf::IndiProperty::Switch);
78 ip.setName(
"fsm_clear_alert");
79 ip.add(pcf::IndiElement(
"request"));
80 ip[
"request"].setSwitchState(pcf::IndiElement::On);
87int callback(
void *app,
const pcf::IndiProperty &ipRecv )
89 static_cast<void>( ipRecv );
98SCENARIO(
"MagAOXApp INDI NewProperty",
"[app::MagAOXApp]" )
100 GIVEN(
"a new property request" )
102 WHEN(
"a wrong device name" )
110 pcf::IndiProperty prop;
113 pcf::IndiProperty::Number,
114 pcf::IndiProperty::ReadWrite,
115 pcf::IndiProperty::Idle,
118 pcf::IndiProperty nprop;
121 nprop.setDevice(
"test" );
122 nprop.setName(
"nprop" );
131 nprop.setDevice(
"wrong" );
142 SECTION(
"using default paths, configname is invoked name" )
144 std::vector<std::string> argvstr( {
"./execname" } );
146 std::vector<const char *> argv( argvstr.size() + 1, NULL );
147 for(
size_t index = 0; index < argvstr.size(); ++index )
149 argv[index] = argvstr[index].c_str();
155 app.
setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
173 SECTION(
"using default paths, with config-ed name" )
175 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
177 std::vector<const char *> argv( argvstr.size() + 1, NULL );
178 for(
size_t index = 0; index < argvstr.size(); ++index )
180 argv[index] = argvstr[index].c_str();
186 app.
setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
206 SECTION(
"using environment paths, with config-ed name" )
208 std::vector<const char *> argv;
209 std::vector<std::string> argvstr( {
"./execname",
"--name",
"testapp2" } );
211 argv.resize( argvstr.size() + 1, NULL );
212 for(
size_t index = 0; index < argvstr.size(); ++index )
214 argv[index] = argvstr[index].c_str();
218 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
234 snprintf( syspath,
sizeof( syspath ),
"%s=sys2",
MAGAOX_env_sys );
237 char secretspath[1024];
239 putenv( secretspath );
242 snprintf( cpupath,
sizeof( cpupath ),
"%s=/tmp/MagAOX/cpuset",
MAGAOX_env_cpuset );
250 app.
setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
270 SECTION(
"setup basic config" )
280 SECTION(
"load basic config w all defaults w/out pwr management" )
297 SECTION(
"load basic config w all defaults w/out pwr management, git modified" )
299 std::vector<const char *> argv;
300 std::vector<std::string> argvstr( {
"./execname",
"--name",
"testapp" } );
302 argv.resize( argvstr.size() + 1, NULL );
303 for(
size_t index = 0; index < argvstr.size(); ++index )
305 argv[index] = argvstr[index].c_str();
313 app.
setDefaults(argv.size()-1,
const_cast<char**
>(argv.data()));
331 SECTION(
"load basic config w all defaults w unconfigured pwr management" )
The base-class for XWCTk applications.
bool gitAlert()
Get the value of the git alert flag.
std::string basePath()
Get the.
std::string m_configName
The name of the configuration file (minus .conf).
std::string configBase()
Get the config base file.
int registerIndiPropertyNew(pcf::IndiProperty &prop, int(*)(void *, const pcf::IndiProperty &))
Register an INDI property which is exposed for others to request a New Property for.
int shutdown()
Get the value of the shutdown flag.
indiDriver< MagAOXApp > * m_indiDriver
The INDI driver wrapper. Constructed and initialized by execute, which starts and stops communication...
void handleNewProperty(const pcf::IndiProperty &ipRecv)
Handler for the new INDI property request.
std::string configDir()
Get the config directory.
std::string secretsPath()
Get the secrets path.
static int st_newCallBack_clearFSMAlert(void *app, const pcf::IndiProperty &ipRecv)
The static callback function to be registered for requesting to clear the FSM alert.
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
MagAOXApp()=delete
Default c'tor is deleted.
virtual void setDefaults(int argc, char **argv)
Set the paths for config files.
std::string cpusetPath()
Get the cpuset path.
virtual void setupBasicConfig()
The basic MagAO-X configuration setup method. Should not normally be overridden.
std::string m_configBase
The name of a base config class for this app (minus .conf).
std::string configName()
Get the config name.
virtual void checkConfig()
Check for unused and unrecognized config options and settings.
virtual void loadBasicConfig()
The basic MagAO-X configuration processing method. Should not normally be overridden.
std::string sysPath()
Get the system path.
std::string calibDir()
Get the calibration directory.
bool stateAlert()
Get the value of the state alert flag.
#define MAGAOX_calibRelPath
The relative path to the calibration files.
#define MAGAOX_configRelPath
The relative path to the configuration files.
#define MAGAOX_logRelPath
The relative path to the log directory.
#define MAGAOX_sysRelPath
The relative path to the system directory.
#define MAGAOX_path
The path to the MagAO-X system files.
#define MAGAOX_secretsRelPath
The relative path to the secrets directory. Used for storing passwords, etc.
#define MAGAOX_cpusetPath
The absolute path to the cpuset mount point.
#define MAGAOX_env_sys
Environment variable setting the relative system directory path.
#define MAGAOX_env_path
Environment variable setting the MagAO-X path.
#define MAGAOX_env_log
Environment variable setting the relative log path.
#define MAGAOX_env_calib
Environment variable setting the relative calib path.
#define MAGAOX_env_secrets
Environment variable setting the relative secrets path.
#define MAGAOX_env_config
Environment variable setting the relative config path.
#define MAGAOX_env_cpuset
Environment variable setting the cpu set path.
int callback(void *app, const pcf::IndiProperty &ipRecv)
std::string configPathGlobal()
virtual int appStartup()
Any tasks to perform prior to the main event loop go here.
std::string configPathUser()
MagAOXApp_test(bool gitmod=false)
virtual int appLogic()
This is where derived applications implement their main FSM logic.
void setConfigBase(const std::string &cb)
std::string configPathLocal()
void setPowerMgtEnabled(bool pme)
void setConfigName(const std::string &cn)
virtual int appShutdown()
Any tasks to perform after main loop exit go here.
std::string & invokedName()