26#include "../../libMagAOX/libMagAOX.hpp"
27#include "../../magaox_git_version.h"
225 config.add(
"dm.serialNumber",
"",
"dm.serialNumber", argType::Required,
"dm",
"serialNumber",
false,
"string",
"The BMC serial number used to find correct DM Profile.");
226 config.add(
"dm.calibRelDir",
"",
"dm.calibRelDir", argType::Required,
"dm",
"calibRelDir",
false,
"string",
"Used to find the default config directory.");
227 config.add(
"dm.satThresh",
"",
"dm.satThresh", argType::Required,
"dm",
"satThresh",
false,
"string",
"Threshold above which to log saturation.");
284 std::cerr <<
"initing DM" << std::endl;
452 dmT::m_tact0 = mx::sys::get_curr_time();
482 dmT::m_tact1 = mx::sys::get_curr_time();
489 dmT::m_tact2 = mx::sys::get_curr_time();
503 dmT::m_tact3 = mx::sys::get_curr_time();
527 dmT::m_tact4 = mx::sys::get_curr_time();
651 printf(
"Error: this program only works on images, not tables\n");
659 printf(
"Error: NAXIS = %d. Only 2-D images are supported.\n",
naxis);
666 printf(
"Memory allocation error\n");
The base-class for MagAO-X applications.
stateCodes::stateCodeT state()
Get the current state code.
int shutdown()
Get the value of the shutdown flag.
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
The MagAO-X BMC DM Controller.
uint32_t m_nbAct
The number of actuators.
double m_act_gain
Actuator gain (microns/volt)
bool m_dmopen
Track whether the DM connection has been opened.
virtual int whilePowerOff()
Maintenace while powered off.
DM m_dm
BMC SDK handle for the DM.
int commandDM(void *curr_src)
Send a command to the DM.
dev::shmimMonitor< bmcCtrl > shmimMonitorT
int initDM()
Initialize the DM and prepare for operation.
virtual void setupConfig()
Setup the configuration system.
double * m_dminputs
Pre-allocated command vector, used only in commandDM.
std::string m_serialNumber
The BMC serial number used to open the correct DM profile.
double m_volume_factor
the volume factor to convert from displacement to commands
virtual int appLogic()
Implementation of the FSM for bmcCtrl.
long m_satThresh
Threshold above which to log saturation.
virtual int appShutdown()
Shutdown the app.
virtual void loadConfig()
Load the configuration.
friend class bmcCtrl_test
int releaseDM()
Release the DM, making it safe to turn off power.
int zeroDM()
Zero all commands on the DM.
int loadConfigImpl(mx::app::appConfigurator &_config)
Implementation of loadConfig logic, separated for testing.
virtual int onPowerOff()
Cleanup after a power off.
float realT
This defines the datatype used to signal the DM using the ImageStreamIO library.
int * m_actuator_mapping
Array containing the mapping from 2D grid position to linear index in the command vector.
int get_actuator_mapping()
Read the actuator mapping from a FITS file.
virtual int appStartup()
Startup function.
dev::dm< bmcCtrl, float > dmT
int parse_calibration_file()
Parse the BMC calibration file.
~bmcCtrl() noexcept
D'tor.
std::string m_calibPath
The path to this DM's calibration files.
std::string m_calibRelDir
The directory relative to the calibPath. Set this before calling dm<derivedT,realT>::loadConfig().
int appShutdown()
DM shutdown.
mx::improc::eigenImage< uint8_t > m_instSatMap
The instantaneous saturation map, 0/1, set by the commandDM() function of the derived class.
int loadConfig(mx::app::appConfigurator &config)
load the configuration system results
int appStartup()
Startup function.
int setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
int appLogic()
DM application logic.
std::thread m_smThread
A separate thread for the actual monitoring.
@ OPERATING
The device is operating, other than homing.
@ POWEROFF
The device power is off.
@ READY
The device is ready for operation, but is not operating.
@ POWERON
The device power is on.
static constexpr logPrioT LOG_NOTICE
A normal but significant condition.
static constexpr logPrioT LOG_WARNING
A condition has occurred which may become an error, but the process continues.
static constexpr logPrioT LOG_ERROR
An error has occured which the software will attempt to correct.