Skip to content

Commit

Permalink
fixed mising indi prop in modalPSDs; added modalPSDs tests; updated s…
Browse files Browse the repository at this point in the history
…hmimMonitor docs
  • Loading branch information
jaredmales committed Aug 11, 2024
1 parent 6281890 commit 5e7656f
Show file tree
Hide file tree
Showing 8 changed files with 342 additions and 274 deletions.
461 changes: 221 additions & 240 deletions apps/modalPSDs/modalPSDs.hpp

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions apps/modalPSDs/tests/modalPSDs_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** \file modalPSDs_test.cpp
* \brief Catch2 tests for the modalPSDs app.
* \author Jared R. Males ([email protected])
*
* History:
*/



#include "../../../tests/catch2/catch.hpp"
#include "../../../tests/testMacrosINDI.hpp"

#include "../modalPSDs.hpp"

using namespace MagAOX::app;

//namespace MPSDTEST
//{

class modalPSDs_test : public modalPSDs
{

public:
modalPSDs_test(const std::string & device)
{
m_configName = device;

XWCTEST_SETUP_INDI_NEW_PROP(psdTime);
XWCTEST_SETUP_INDI_NEW_PROP(psdAvgTime);
XWCTEST_SETUP_INDI_ARB_PROP(m_indiP_fpsSource, modeamps, fps )
}
};

SCENARIO( "INDI Callbacks", "[modalPSDs]" )
{
XWCTEST_INDI_NEW_CALLBACK( modalPSDs, psdTime);
XWCTEST_INDI_NEW_CALLBACK( modalPSDs, psdAvgTime);
XWCTEST_INDI_SET_CALLBACK( modalPSDs, m_indiP_fpsSource, modeamps, fps);
}


//} //namespace modalPSDs_test
2 changes: 1 addition & 1 deletion apps/zaberCtrl/tests/zaberCtrl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class zaberCtrl_test : public zaberCtrl
{

public:
zaberCtrl_test(const std::string device)
zaberCtrl_test(const std::string & device)
{
m_configName = device;

Expand Down
2 changes: 1 addition & 1 deletion libMagAOX/app/dev/dmPokeWFS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace dev
*
* - Must be derived from `dev::shmimMonitor<DERIVEDNAME, dev::dmPokeWFS<DERIVEDNAME>::darkShmimT>` (replace DERIVEDNAME with derivedT class name)
*
* - Must contain the following friend declalibMagAOX/app/indiMacros.hpprations (replace DERIVEDNAME with derivedT class name):
* - Must contain the following friend declarations (replace DERIVEDNAME with derivedT class name):
* \code
* friend class dev::shmimMonitor<DERIVEDNAME, dev::dmPokeWFS<DERIVEDNAME>::wfsShmimT>;
* friend class dev::shmimMonitor<DERIVEDNAME, dev::dmPokeWFS<DERIVEDNAME>::darkShmimT>;
Expand Down
69 changes: 45 additions & 24 deletions libMagAOX/app/dev/shmimMonitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,57 @@ struct shmimT
/** MagAO-X generic shared memory monitor
*
*
* The derived class `derivedT` must expose the following interface
\code
//The allocate function is called after connecting to the shared memory buffer
//It should check that the buffer has the expected size, and perform any internal allocations
//to prepare for processing.
int derivedT::allocate( const specificT & ///< [in] tag to differentiate shmimMonitor parents. Normally this is dev::shmimT for a single parent.
);
int derivedT::processImage( void * curr_src, ///< [in] pointer to the start of the current frame
const specificT & ///< [in] tag to differentiate shmimMonitor parents. Normally this is dev::shmimT for a single parent.
)
\endcode
* Each of the above functions should return 0 on success, and -1 on an error.
* The derived class `derivedT` has the following requirements (see below for discussion of specificT):
*
* - Must be derived from MagAOXApp<true>
*
* - Must contain the following friend declaration:
* \code
* friend class dev::shmimMonitor<derivedT, specificT>; //specificT may not need to be included
* \endcode
*
* - Must provide the following interfaces:
* \code
*
* This class should be declared a friend in the derived class, like so:
\code
friend class dev::shmimMonitor<derivedT, specificT>;
\endcode
* //The allocate function is called after connecting to the shared memory buffer
* //It should check that the buffer has the expected size, and perform any internal allocations
* //to prepare for processing.
* int derivedT::allocate( const specificT & ///< [in] tag to differentiate shmimMonitor parents. Normally this is dev::shmimT for a single parent.
* );
*
* Calls to this class's `setupConfig`, `loadConfig`, `appStartup`, `appLogic` and `appShutdown`
* functions must be placed in the derived class's functions of the same name.
* int derivedT::processImage( void * curr_src, ///< [in] pointer to the start of the current frame
* const specificT & ///< [in] tag to differentiate shmimMonitor parents. Normally this is dev::shmimT for a single parent.
* )
* \endcode
* Each of the above functions should return 0 on success, and -1 on an error.
*
* - Calls to this class's `setupConfig`, `loadConfig`, `appStartup`, `appLogic` and `appShutdown`
* functions must be placed in the derived class's functions of the same name. For convenience the
* following macros are defined to provide error checking:
* \code
* SHMIMMONITOR_SETUP_CONFIG( cfig )
* SHMIMMONITOR_LOAD_CONFIG( cfig )
* SHMIMMONITOR_APP_STARTUP
* SHMIMMONITOR_APP_LOGIC
* SHMIMMONITOR_APP_SHUTDOWN
* \endcode
* See below for the macros to use if `specificT` is used to specialize.
*
* The template specifier `specificT` allows inheritance of multiple shmimMonitor classes. This type must have at least
* the static member function:
\code
static std::string indiPrefix()
\endcode
* which returns the string to prefix to INDI properties. The default `shmimT` uses "sm".
* \code
* static std::string indiPrefix()
* \endcode
* which returns the string which is prefixed to INDI properties. The default `shmimT` uses "sm".
*
* Additionally, if `specificT` is used, the following convenience macros can be used:
* \code
* SHMIMMONITORT_SETUP_CONFIG( SHMIMMONITORT, cfig )
* SHMIMMONITORT_LOAD_CONFIG( SHMIMMONITORT, cfig )
* SHMIMMONITORT_APP_STARTUP( SHMIMMONITORT )
* SHMIMMONITORT_APP_LOGIC( SHMIMMONITORT )
* SHMIMMONITORT_APP_SHUTDOWN( SHMIMMONITORT )
* \endcode
*
*
* \ingroup appdev
Expand Down
35 changes: 29 additions & 6 deletions libMagAOX/app/indiMacros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,18 @@
/** \param prop1 [in] the first property to compare
* \param prop2 [in] the second property to compare
*/
#define INDI_VALIDATE_CALLBACK_PROPS_IMPL(prop1, prop2) \
if(prop1.createUniqueKey() != prop2.createUniqueKey()) \
{ \
INDI_VALIDATE_LOG_ERROR(prop1, prop2) \
return -1; \
#define INDI_VALIDATE_CALLBACK_PROPS_IMPL(prop1, prop2) \
if(prop1.createUniqueKey() != prop2.createUniqueKey()) \
{ \
INDI_VALIDATE_LOG_ERROR(prop1, prop2) \
return -1; \
}

#ifdef XWCTEST_INDI_CALLBACK_VALIDATION

// When testing validation of callback checks, we add a return 0 to avoid executing the rest of the callback.
#define INDI_VALIDATE_CALLBACK_PROPS(prop1, prop2) INDI_VALIDATE_CALLBACK_PROPS_IMPL(prop1, prop2) else {return 0;}
#define INDI_VALIDATE_CALLBACK_PROPS(prop1, prop2) INDI_VALIDATE_CALLBACK_PROPS_IMPL(prop1, prop2) \
else {return 0;}

#else

Expand Down Expand Up @@ -371,6 +372,28 @@ if( derived().template registerIndiPropertySet( prop,devName, propName, INDI_SE
return -1; \
}

/// Create and register a RO INDI property as a number, using the standard callback name.
/** This wraps createROIndiNumber and registerIndiPropertyReadOnly, with error checking.
*
* \param prop [out] the property to create and setup
* \param name [in] the name of the property
* \param label [in] [optional] the GUI label suggestion for this property
* \param group [in] [optional] the group for this property
*
* \ingroup indi
*/
#define CREATE_REG_INDI_RO_NUMBER( prop, name, label, group ) \
if( createROIndiNumber( prop, name, label, group ) < 0) \
{ \
log<software_error>({__FILE__,__LINE__, "error from createROIndiNumber"}); \
return -1; \
} \
if( registerIndiPropertyReadOnly( prop ) < 0) \
{ \
log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyReadOnly"}); \
return -1; \
}

/// Create and register a NEW INDI property as a standard toggle switch, using the standard callback name.
/** This wraps createStandardIndiToggleSw and registerIndiPropertyNew, with error checking
*
Expand Down
2 changes: 1 addition & 1 deletion tests/testMacrosINDI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define XWCTEST_INDI_CALLBACK_VALIDATION

/// Make an indi property variable name
/** This takes m_indiP_ and voltage and creates m_indiP_voltage, which is the standard way
/** This takes m_indiP_ and voltage (as the propname) and creates m_indiP_voltage, which is the standard way
* to name an INDI property which takes new requests.
*
* \param stub [in] the first part of the variable name, e.g. m_indiP_
Expand Down
3 changes: 2 additions & 1 deletion tests/tests.list
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
../apps/cacaoInterface/tests/cacaoInterface_test
../apps/closedLoopIndi/tests/closedLoopIndi_test
../apps/observerCtrl/tests/observerCtrl_test
../apps/ocam2KCtrl/tests/ocamUtils_test
../apps/ocam2KCtrl/tests/ocamUtils_test
../apps/modalPSDs/tests/modalPSDs_test
../apps/rhusbMon/tests/rhusbMonParsers_test
../apps/siglentSDG/tests/siglentSDG_test
../apps/sshDigger/tests/sshDigger_test
Expand Down

0 comments on commit 5e7656f

Please sign in to comment.