7 #ifndef w2tcsOffloader_hpp
8 #define w2tcsOffloader_hpp
12 #include <mx/improc/eigenCube.hpp>
13 #include <mx/improc/eigenImage.hpp>
15 #include "../../libMagAOX/libMagAOX.hpp"
16 #include "../../magaox_git_version.h"
146 config.add(
"offload.wZModesPath",
"",
"offload.wZModesPath", argType::Required,
"offload",
"wZModesPath",
false,
"string",
"The path to the woofer Zernike modes.");
147 config.add(
"offload.wMaskPath",
"",
"offload.wMaskPath", argType::Required,
"offload",
"wMaskPath",
false,
"string",
"Path to the woofer Zernike mode mask.");
148 config.add(
"offload.gain",
"",
"offload.gain", argType::Required,
"offload",
"gain",
false,
"float",
"The starting offload gain. Default is 0.1.");
149 config.add(
"offload.nModes",
"",
"offload.nModes", argType::Required,
"offload",
"nModes",
false,
"int",
"Number of modes to offload to the TCS.");
160 _config(
m_gain,
"offload.gain");
161 _config(
m_nModes,
"offload.nModes");
175 mx::fits::fitsFile<float> ff;
190 createStandardIndiNumber<unsigned>(
m_indiP_gain,
"gain", 0, 1, 0,
"%0.2f");
196 log<software_error>({__FILE__,__LINE__});
200 createStandardIndiNumber<unsigned>(
m_indiP_nModes,
"nModes", 1, std::numeric_limits<unsigned>::max(), 1,
"%u");
205 log<software_error>({__FILE__,__LINE__});
213 for(
size_t n=0; n <
m_zCoeffs.size(); ++n)
216 m_elNames[n] = mx::ioutils::convertToString<size_t, 2, '0'>(n);
231 log<software_error>({__FILE__,__LINE__});
253 log<software_error>({__FILE__, __LINE__});
272 static_cast<void>(dummy);
288 static_cast<void>(dummy);
294 for(
size_t i=0; i <
m_zCoeffs.size(); ++i)
331 if( indiTargetUpdate( m_indiP_gain, target,
ipRecv,
true) < 0)
333 log<software_error>({__FILE__,__LINE__});
353 if( indiTargetUpdate( m_indiP_nModes, target,
ipRecv,
true) < 0)
355 log<software_error>({__FILE__,__LINE__});
374 for(
size_t n=0; n < m_zCoeffs.size(); ++n)
376 if(
ipRecv.find(m_elNames[n]))
378 realT zcoeff =
ipRecv[m_elNames[n]].get<realT>();
379 m_zCoeffs[n] = zcoeff;
385 return log<
software_error,-1>({__FILE__,__LINE__,
"invalid indi property name"});
394 if(
ipRecv[
"toggle"].getSwitchState() == pcf::IndiElement::On)
The base-class for MagAO-X applications.
int createStandardIndiRequestSw(pcf::IndiProperty &prop, const std::string &name, const std::string &label="", const std::string &group="")
Create a standard R/W INDI switch with a single request element.
stateCodes::stateCodeT state()
Get the current state code.
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.
indiDriver< MagAOXApp > * m_indiDriver
The INDI driver wrapper. Constructed and initialized by execute, which starts and stops communication...
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
std::mutex m_indiMutex
Mutex for locking INDI communications.
int appStartup()
Startup function.
uint32_t m_width
The width of the images in the stream.
int setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
int updateINDI()
Update the INDI properties for this device controller.
int appLogic()
Checks the shmimMonitor thread.
uint32_t m_height
The height of the images in the stream.
int appShutdown()
Shuts down the shmimMonitor thread.
int loadConfig(mx::app::appConfigurator &config)
load the configuration system results
INDI_NEWCALLBACK_DECL(w2tcsOffloader, m_indiP_nModes)
virtual int appLogic()
Implementation of the FSM for w2tcsOffloader.
mx::improc::eigenImage< realT > m_wMask
std::vector< realT > m_zCoeffs
mx::improc::eigenCube< realT > m_wZModes
int allocate(const dev::shmimT &dummy)
int loadConfigImpl(mx::app::appConfigurator &_config)
Implementation of loadConfig logic, separated for testing.
dev::shmimMonitor< w2tcsOffloader > shmimMonitorT
pcf::IndiProperty m_indiP_nModes
mx::improc::eigenImage< realT > m_woofer
INDI_NEWCALLBACK_DECL(w2tcsOffloader, m_indiP_gain)
std::string m_wZModesPath
virtual int appStartup()
Startup function.
friend class w2tcsOffloader_test
INDI_NEWCALLBACK_DECL(w2tcsOffloader, m_indiP_zero)
pcf::IndiProperty m_indiP_gain
INDI_NEWCALLBACK_DECL(w2tcsOffloader, m_indiP_zCoeffs)
~w2tcsOffloader() noexcept
D'tor, declared and defined for noexcept.
float realT
Floating point type in which to do all calculations.
w2tcsOffloader()
Default c'tor.
pcf::IndiProperty m_indiP_zCoeffs
virtual void loadConfig()
std::vector< std::string > m_elNames
virtual void setupConfig()
virtual int appShutdown()
Shutdown the app.
int processImage(void *curr_src, const dev::shmimT &dummy)
pcf::IndiProperty m_indiP_zero
#define INDI_NEWCALLBACK(prop)
Get the name of the static callback wrapper for a new property.
#define REG_INDI_NEWPROP(prop, propName, type)
Register a NEW INDI property with the class, using the standard callback name.
@ OPERATING
The device is operating, other than homing.
INDI_VALIDATE_CALLBACK_PROPS(function, ipRecv)
const pcf::IndiProperty & ipRecv
updateIfChanged(m_indiP_angle, "target", m_angle)
INDI_NEWCALLBACK_DEFN(acesxeCtrl, m_indiP_windspeed)(const pcf
std::unique_lock< std::mutex > lock(m_indiMutex)
constexpr static logPrioT LOG_ERROR
An error has occured which the software will attempt to correct.
constexpr static logPrioT LOG_NOTICE
A normal but significant condition.
A simple text log, a string-type log.