#include <dm.hpp>
Public Member Functions | |
int | setupConfig (mx::app::appConfigurator &config) |
Setup the configuration system. | |
int | loadConfig (mx::app::appConfigurator &config) |
load the configuration system results | |
int | appStartup () |
Startup function. | |
int | appLogic () |
DM application logic. | |
int | appShutdown () |
DM shutdown. | |
int | onPowerOff () |
DM Poweroff. | |
int | whilePowerOff () |
DM Poweroff Updates. | |
int | findDMChannels () |
Find the DM comb channels. | |
int | allocate (const dev::shmimT &sp) |
Called after shmimMonitor connects to the dmXXdisp stream. Checks for proper size. | |
int | processImage (void *curr_src, const dev::shmimT &sp) |
Called by shmimMonitor when a new DM command is available. This is just a pass-through to derivedT::commandDM(char*). | |
int | releaseDM () |
Calls derived()->releaseDM() and then 0s all channels and the sat map. | |
int | checkFlats () |
Check the flats directory and update the list of flats if anything changes. | |
int | loadFlat (const std::string &target) |
Load a flat file. | |
int | setFlat (bool update=false) |
Send the current flat command to the DM. | |
int | zeroFlat () |
Zero the flat command on the DM. | |
int | checkTests () |
Check the tests directory and update the list of tests if anything changes. | |
int | loadTest (const std::string &target) |
Load a test file. | |
int | setTest () |
Send the current test command to the DM. | |
int | zeroTest () |
Zero the test command on the DM. | |
int | zeroAll (bool nosem=false) |
Zero all channels. | |
Protected Member Functions | |
int | clearSat () |
Clear the saturation maps and zero the shared membory. | |
Protected Attributes | |
std::string | m_calibRelDir |
The directory relative to the calibPath. Set this before calling dm<derivedT,realT>::loadConfig(). | |
int | m_channels {0} |
The number of dmcomb channels found as part of allocation. | |
std::map< std::string, std::string > | m_flatCommands |
Map of flat file name to full path. | |
std::string | m_flatCurrent |
The name of the current flat command. | |
mx::improc::eigenImage< realT > | m_flatCommand |
Data storage for the flat command. | |
bool | m_flatLoaded {false} |
Flag indicating whether a flat is loaded in memory. | |
IMAGE | m_flatImageStream |
The ImageStreamIO shared memory buffer for the flat. | |
bool | m_flatSet {false} |
Flag indicating whether the flat command has been set. | |
std::map< std::string, std::string > | m_testCommands |
Map of test file name to full path. | |
std::string | m_testCurrent |
mx::improc::eigenImage< realT > | m_testCommand |
Data storage for the test command. | |
bool | m_testLoaded {false} |
Flag indicating whether a test command is loaded in memory. | |
IMAGE | m_testImageStream |
The ImageStreamIO shared memory buffer for the test. | |
bool | m_testSet {false} |
Flag indicating whether the test command has been set. | |
int | m_overSatAct {0} |
int | m_intervalSatExceeds {0} |
bool | m_intervalSatTrip {0} |
mx::improc::eigenImage< uint8_t > | m_instSatMap |
The instantaneous saturation map, 0/1, set by the commandDM() function of the derived class. | |
mx::improc::eigenImage< uint16_t > | m_accumSatMap |
The accumulated saturation map, which acccumulates for m_satAvgInt then is publised as a 0/1 image. | |
mx::improc::eigenImage< float > | m_satPercMap |
Map of the percentage of time each actator was saturated during the avg. interval. | |
IMAGE | m_satImageStream |
The ImageStreamIO shared memory buffer for the sat map. | |
IMAGE | m_satPercImageStream |
The ImageStreamIO shared memory buffer for the sat percentage map. | |
Private Types | |
typedef mx::verbose::vvv | verboseT |
Private Member Functions | |
derivedT & | derived () |
Configurable Parameters | |
std::string | m_calibPath |
The path to this DM's calibration files. | |
std::string | m_flatPath |
The path to this DM's flat files (usually the same as calibPath) | |
std::string | m_testPath |
The path to this DM's test files (default is calibPath/tests;. | |
std::string | m_flatDefault |
The file name of the this DM's default flat command. Path and extension will be ignored and can be omitted. | |
std::string | m_testDefault |
The file name of the this DM's default test command. Path and extension will be ignored and can be omitted. | |
std::string | m_shmimFlat |
The name of the shmim stream to write the flat to. | |
std::string | m_shmimTest |
The name of the shmim stream to write the test to. | |
std::string | m_shmimSat |
The name of the shmim stream to write the saturation map to. | |
std::string | m_shmimSatPerc |
The name of the shmim stream to write the saturation percentage map to. | |
int | m_satAvgInt {100} |
The time in milliseconds to accumulate saturation over. | |
int | m_satThreadPrio {0} |
Priority of the saturation thread, should normally be > 0. | |
uint32_t | m_dmWidth {0} |
The width of the images in the stream. | |
uint32_t | m_dmHeight {0} |
The height of the images in the stream. | |
float | m_percThreshold {0.98} |
float | m_intervalSatThreshold {0.50} |
int | m_intervalSatCountThreshold {10} |
std::vector< std::string > | m_satTriggerDevice |
std::vector< std::string > | m_satTriggerProperty |
static constexpr uint8_t | m_dmDataType = ImageStreamTypeCode<realT>() |
The ImageStreamIO type code. | |
Saturation Thread | |
This thread processes the saturation maps | |
sem_t | m_satSemaphore |
Semaphore used to tell the saturation thread to run. | |
bool | m_satThreadInit {true} |
Synchronizer for thread startup, to allow priority setting to finish. | |
pid_t | m_satThreadID {0} |
The ID of the saturation thread. | |
pcf::IndiProperty | m_satThreadProp |
The property to hold the saturation thread details. | |
std::thread | m_satThread |
A separate thread for the actual saturation processing. | |
void | satThreadExec () |
Execute saturation processing. | |
void | intervalSatTrip () |
static void | satThreadStart (dm *d) |
Thread starter, called by MagAOXApp::threadStart on thread construction. Calls satThreadExec. | |
INDI | |
pcf::IndiProperty | m_indiP_flat |
Property used to set and report the current flat. | |
pcf::IndiProperty | m_indiP_init |
pcf::IndiProperty | m_indiP_zero |
pcf::IndiProperty | m_indiP_release |
pcf::IndiProperty | m_indiP_flats |
INDI Selection switch containing the flat files. | |
pcf::IndiProperty | m_indiP_flatShmim |
Publish the shmim being used for the flat. | |
pcf::IndiProperty | m_indiP_setFlat |
INDI toggle switch to set the current flat. | |
pcf::IndiProperty | m_indiP_tests |
INDI Selection switch containing the test pattern files. | |
pcf::IndiProperty | m_indiP_testShmim |
Publish the shmim being used for the test command. | |
pcf::IndiProperty | m_indiP_setTest |
INDI toggle switch to set the current test pattern. | |
pcf::IndiProperty | m_indiP_zeroAll |
int | newCallBack_init (const pcf::IndiProperty &ipRecv) |
The callback called by the static version, to actually process the new request. | |
int | newCallBack_zero (const pcf::IndiProperty &ipRecv) |
The callback called by the static version, to actually process the new request. | |
int | newCallBack_release (const pcf::IndiProperty &ipRecv) |
The callback called by the static version, to actually process the new request. | |
int | newCallBack_flats (const pcf::IndiProperty &ipRecv) |
The callback called by the static version, to actually process the new request. | |
int | newCallBack_setFlat (const pcf::IndiProperty &ipRecv) |
The callback called by the static version, to actually process the new request. | |
int | newCallBack_tests (const pcf::IndiProperty &ipRecv) |
The callback called by the static version, to actually process the new request. | |
int | newCallBack_setTest (const pcf::IndiProperty &ipRecv) |
The callback called by the static version, to actually process the new request. | |
int | newCallBack_zeroAll (const pcf::IndiProperty &ipRecv) |
The callback for the zeroAll toggle switch, called by the static version. | |
int | updateINDI () |
Update the INDI properties for this device controller. | |
static int | st_newCallBack_init (void *app, const pcf::IndiProperty &ipRecv) |
The static callback function to be registered for initializing the DM. | |
static int | st_newCallBack_zero (void *app, const pcf::IndiProperty &ipRecv) |
The static callback function to be registered for initializing the DM. | |
static int | st_newCallBack_release (void *app, const pcf::IndiProperty &ipRecv) |
The static callback function to be registered for initializing the DM. | |
static int | st_newCallBack_flats (void *app, const pcf::IndiProperty &ipRecv) |
The static callback function to be registered for selecting the flat file. | |
static int | st_newCallBack_setFlat (void *app, const pcf::IndiProperty &ipRecv) |
The static callback function to be registered for setting the flat. | |
static int | st_newCallBack_tests (void *app, const pcf::IndiProperty &ipRecv) |
The static callback function to be registered for selecting the test file. | |
static int | st_newCallBack_setTest (void *app, const pcf::IndiProperty &ipRecv) |
The static callback function to be registered for setting the test shape. | |
static int | st_newCallBack_zeroAll (void *app, const pcf::IndiProperty &ipRecv) |
The static callback function to be registered for zeroing all channels. | |
MagAO-X generic deformable mirror controller
The derived class derivedT
must expose the following interface
Each of the above functions should return 0 on success, and -1 on an error.
This class should be declared a friend in the derived class, like so:
Calls to this class's setupConfig
, loadConfig
, appStartup
, appLogic
, appShutdown
, and udpdateINDI
functions must be placed in the derived class's functions of the same name.
|
private |
int MagAOX::app::dev::dm< derivedT, realT >::allocate | ( | const dev::shmimT & | sp | ) |
Called after shmimMonitor connects to the dmXXdisp stream. Checks for proper size.
int MagAOX::app::dev::dm< derivedT, realT >::appLogic | ( | ) |
DM application logic.
This should be called in derivedT::appLogic
as
with appropriate error checking.
Definition at line 829 of file dm.hpp.
Referenced by MagAOX::app::alpaoCtrl::appLogic(), MagAOX::app::bmcCtrl::appLogic(), and MagAOX::app::irisaoCtrl::appLogic().
int MagAOX::app::dev::dm< derivedT, realT >::appShutdown | ( | ) |
DM shutdown.
This should be called in derivedT::appShutdown
as
with appropriate error checking.
Definition at line 886 of file dm.hpp.
Referenced by MagAOX::app::alpaoCtrl::appShutdown(), MagAOX::app::bmcCtrl::appShutdown(), and MagAOX::app::irisaoCtrl::appShutdown().
int MagAOX::app::dev::dm< derivedT, realT >::appStartup | ( | ) |
Startup function.
This should be called in derivedT::appStartup
as
with appropriate error checking.
Definition at line 695 of file dm.hpp.
Referenced by MagAOX::app::alpaoCtrl::appStartup(), MagAOX::app::bmcCtrl::appStartup(), and MagAOX::app::irisaoCtrl::appStartup().
int MagAOX::app::dev::dm< derivedT, realT >::checkFlats | ( | ) |
Check the flats directory and update the list of flats if anything changes.
This is called once per appLogic and whilePowerOff loops.
Definition at line 1085 of file dm.hpp.
References MagAOX::app::it.
int MagAOX::app::dev::dm< derivedT, realT >::checkTests | ( | ) |
Check the tests directory and update the list of tests if anything changes.
This is called once per appLogic and whilePowerOff loops.
Definition at line 1444 of file dm.hpp.
References MagAOX::app::it.
|
protected |
|
inlineprivate |
Definition at line 573 of file dm.hpp.
Referenced by MagAOX::app::dev::dm< derivedT, realT >::intervalSatTrip().
int MagAOX::app::dev::dm< derivedT, realT >::findDMChannels | ( | ) |
|
inlineprotected |
Definition at line 354 of file dm.hpp.
References MagAOX::app::dev::dm< derivedT, realT >::derived(), MagAOX::app::dev::dm< derivedT, realT >::m_satTriggerDevice, and MagAOX::app::dev::dm< derivedT, realT >::m_satTriggerProperty.
int MagAOX::app::dev::dm< derivedT, realT >::loadConfig | ( | mx::app::appConfigurator & | config | ) |
load the configuration system results
This should be called in derivedT::loadConfig
as
with appropriate error checking.
[in] | config | the derived classes configurator |
Definition at line 622 of file dm.hpp.
Referenced by MagAOX::app::alpaoCtrl::loadConfigImpl(), MagAOX::app::bmcCtrl::loadConfigImpl(), and MagAOX::app::irisaoCtrl::loadConfigImpl().
int MagAOX::app::dev::dm< derivedT, realT >::loadFlat | ( | const std::string & | target | ) |
int MagAOX::app::dev::dm< derivedT, realT >::loadTest | ( | const std::string & | target | ) |
int MagAOX::app::dev::dm< derivedT, realT >::newCallBack_flats | ( | const pcf::IndiProperty & | ipRecv | ) |
The callback called by the static version, to actually process the new request.
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2166 of file dm.hpp.
References MagAOX::app::ipRecv.
int MagAOX::app::dev::dm< derivedT, realT >::newCallBack_init | ( | const pcf::IndiProperty & | ipRecv | ) |
The callback called by the static version, to actually process the new request.
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2091 of file dm.hpp.
References MagAOX::app::ipRecv.
int MagAOX::app::dev::dm< derivedT, realT >::newCallBack_release | ( | const pcf::IndiProperty & | ipRecv | ) |
The callback called by the static version, to actually process the new request.
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2141 of file dm.hpp.
References MagAOX::app::ipRecv.
int MagAOX::app::dev::dm< derivedT, realT >::newCallBack_setFlat | ( | const pcf::IndiProperty & | ipRecv | ) |
The callback called by the static version, to actually process the new request.
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2216 of file dm.hpp.
References MagAOX::app::ipRecv.
int MagAOX::app::dev::dm< derivedT, realT >::newCallBack_setTest | ( | const pcf::IndiProperty & | ipRecv | ) |
The callback called by the static version, to actually process the new request.
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2294 of file dm.hpp.
References MagAOX::app::ipRecv.
int MagAOX::app::dev::dm< derivedT, realT >::newCallBack_tests | ( | const pcf::IndiProperty & | ipRecv | ) |
The callback called by the static version, to actually process the new request.
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2244 of file dm.hpp.
References MagAOX::app::ipRecv.
int MagAOX::app::dev::dm< derivedT, realT >::newCallBack_zero | ( | const pcf::IndiProperty & | ipRecv | ) |
The callback called by the static version, to actually process the new request.
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2116 of file dm.hpp.
References MagAOX::app::ipRecv.
int MagAOX::app::dev::dm< derivedT, realT >::newCallBack_zeroAll | ( | const pcf::IndiProperty & | ipRecv | ) |
The callback for the zeroAll toggle switch, called by the static version.
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2322 of file dm.hpp.
References INDI_BUSY, MagAOX::app::ipRecv, and MagAOX::app::indi::updateSwitchIfChanged().
int MagAOX::app::dev::dm< derivedT, realT >::onPowerOff | ( | ) |
DM Poweroff.
This should be called in derivedT::onPowerOff
as
with appropriate error checking.
int MagAOX::app::dev::dm< derivedT, realT >::processImage | ( | void * | curr_src, |
const dev::shmimT & | sp | ||
) |
Called by shmimMonitor when a new DM command is available. This is just a pass-through to derivedT::commandDM(char*).
int MagAOX::app::dev::dm< derivedT, realT >::releaseDM | ( | ) |
Calls derived()->releaseDM() and then 0s all channels and the sat map.
This is called by the relevant INDI callback
|
protected |
Execute saturation processing.
Definition at line 1900 of file dm.hpp.
References IMAGESTRUCT_FLOAT, and IMAGESTRUCT_UINT8.
Referenced by MagAOX::app::dev::dm< derivedT, realT >::satThreadStart().
|
staticprotected |
Thread starter, called by MagAOXApp::threadStart on thread construction. Calls satThreadExec.
[in] | d | a pointer to a dm instance (normally this) |
Definition at line 1894 of file dm.hpp.
References MagAOX::app::dev::dm< derivedT, realT >::satThreadExec().
int MagAOX::app::dev::dm< derivedT, realT >::setFlat | ( | bool | update = false | ) |
Send the current flat command to the DM.
Writes the command to the designated shmim.
[in] | update | If true, this is an update rather than a new set |
int MagAOX::app::dev::dm< derivedT, realT >::setTest | ( | ) |
Send the current test command to the DM.
Writes the command to the designated shmim.
int MagAOX::app::dev::dm< derivedT, realT >::setupConfig | ( | mx::app::appConfigurator & | config | ) |
Setup the configuration system.
This should be called in derivedT::setupConfig
as
with appropriate error checking.
[out] | config | the derived classes configurator |
Definition at line 580 of file dm.hpp.
Referenced by MagAOX::app::alpaoCtrl::setupConfig(), MagAOX::app::bmcCtrl::setupConfig(), and MagAOX::app::irisaoCtrl::setupConfig().
|
static |
The static callback function to be registered for selecting the flat file.
[in] | app | a pointer to this, will be static_cast-ed to derivedT. |
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2159 of file dm.hpp.
References MagAOX::app::ipRecv.
|
static |
The static callback function to be registered for initializing the DM.
[in] | app | a pointer to this, will be static_cast-ed to derivedT. |
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2084 of file dm.hpp.
References MagAOX::app::ipRecv.
|
static |
The static callback function to be registered for initializing the DM.
[in] | app | a pointer to this, will be static_cast-ed to derivedT. |
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2134 of file dm.hpp.
References MagAOX::app::ipRecv.
|
static |
The static callback function to be registered for setting the flat.
[in] | app | a pointer to this, will be static_cast-ed to derivedT. |
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2209 of file dm.hpp.
References MagAOX::app::ipRecv.
|
static |
The static callback function to be registered for setting the test shape.
[in] | app | a pointer to this, will be static_cast-ed to derivedT. |
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2287 of file dm.hpp.
References MagAOX::app::ipRecv.
|
static |
The static callback function to be registered for selecting the test file.
[in] | app | a pointer to this, will be static_cast-ed to derivedT. |
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2237 of file dm.hpp.
References MagAOX::app::ipRecv.
|
static |
The static callback function to be registered for initializing the DM.
[in] | app | a pointer to this, will be static_cast-ed to derivedT. |
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2109 of file dm.hpp.
References MagAOX::app::ipRecv.
|
static |
The static callback function to be registered for zeroing all channels.
[in] | app | a pointer to this, will be static_cast-ed to derivedT. |
[in] | ipRecv | the INDI property sent with the the new property request. |
Definition at line 2315 of file dm.hpp.
References MagAOX::app::ipRecv.
int MagAOX::app::dev::dm< derivedT, realT >::updateINDI | ( | ) |
int MagAOX::app::dev::dm< derivedT, realT >::whilePowerOff | ( | ) |
DM Poweroff Updates.
This should be called in derivedT::whilePowerOff
as
with appropriate error checking.
int MagAOX::app::dev::dm< derivedT, realT >::zeroAll | ( | bool | nosem = false | ) |
int MagAOX::app::dev::dm< derivedT, realT >::zeroFlat | ( | ) |
Zero the flat command on the DM.
Writes a 0 array the designated shmim.
int MagAOX::app::dev::dm< derivedT, realT >::zeroTest | ( | ) |
Zero the test command on the DM.
Writes a 0 array the designated shmim.
|
protected |
|
protected |
|
protected |
The directory relative to the calibPath. Set this before calling dm<derivedT,realT>::loadConfig().
|
protected |
|
staticconstexprprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Definition at line 108 of file dm.hpp.
Referenced by MagAOX::app::dev::dm< derivedT, realT >::intervalSatTrip().
|
protected |
Definition at line 109 of file dm.hpp.
Referenced by MagAOX::app::dev::dm< derivedT, realT >::intervalSatTrip().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |