7#ifndef w2tcsOffloader_hpp
8#define w2tcsOffloader_hpp
13#include <mx/improc/eigenCube.hpp>
14#include <mx/improc/eigenImage.hpp>
16#include "../../libMagAOX/libMagAOX.hpp"
17#include "../../magaox_git_version.h"
69 std::vector<std::string>
109 mx::app::appConfigurator &
_config );
168 config.add(
"offload.wZModesPath",
170 "offload.wZModesPath",
176 "The path to the woofer Zernike modes." );
177 config.add(
"offload.wMaskPath",
185 "Path to the woofer Zernike mode mask." );
186 config.add(
"offload.nModes",
194 "Number of modes to offload to the TCS." );
218 mx::fits::fitsFile<float>
ff;
220 if(
errc != mx::error_t::noerror )
236 return log<
text_log, -1>(
"w2tcsOffloader supports at most 100 offload modes because INDI element names are "
237 "formatted with two digits.",
242 if(
errc != mx::error_t::noerror )
264 -std::numeric_limits<realT>::max(),
265 std::numeric_limits<realT>::max(),
316 static_cast<void>(
dummy );
325 static_cast<void>(
dummy );
327 Eigen::Map<mx::improc::eigenImage<realT>>
wooferImage(
374 std::vector<float> coeffs;
The base-class for XWCTk applications.
stateCodes::stateCodeT state()
Get the current state code.
int m_shutdown
Flag to signal it's time to shutdown. When not 0, the main loop exits.
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.
int createROIndiNumber(pcf::IndiProperty &prop, const std::string &propName, const std::string &propLabel="", const std::string &propGroup="")
Create a ReadOnly INDI Number property.
int registerIndiPropertyReadOnly(pcf::IndiProperty &prop)
Register an INDI property which is read only.
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
virtual int appLogic()
Implementation of the FSM for w2tcsOffloader.
mx::improc::eigenImage< realT > m_wMask
Mask selecting valid pixels for the coefficient projection.
std::vector< realT > m_zCoeffs
Current coefficient vector sent to INDI and telemetry.
mx::improc::eigenCube< realT > m_wZModes
Basis cube used to project the incoming woofer image.
int allocate(const dev::shmimT &dummy)
Allocate image buffers for a new shared-memory image stream.
int loadConfigImpl(mx::app::appConfigurator &_config)
Implementation of loadConfig logic, separated for testing.
dev::shmimMonitor< w2tcsOffloader > shmimMonitorT
std::string m_wMaskPath
Filesystem path to the mask used for coefficient projection.
pcf::IndiProperty m_indiP_nModes
INDI property publishing the number of active offload modes.
dev::telemeter< w2tcsOffloader > telemeterT
mx::improc::eigenImage< realT > m_woofer
Copy of the most recently processed woofer image.
std::vector< realT > m_lastZCoeffs
Last coefficient vector recorded to telemetry.
std::string m_wZModesPath
Filesystem path to the woofer Zernike basis cube.
virtual int appStartup()
Start the application and validate the loaded mode cube against the configured mode count.
int recordTelem(const logger::telem_w2tcsoffloader *)
Record the current coefficient vector for telemetry when requested by the telemeter.
float m_norm
Mask normalization applied to each coefficient measurement.
unsigned m_nModes
Number of low-order modes to retain when offloading, clamped to the loaded cube size at startup.
friend class w2tcsOffloader_test
~w2tcsOffloader() noexcept
Destructor, declared and defined for noexcept.
int checkRecordTimes()
Check whether the telemetry max-interval requires a record.
float realT
Floating point type in which to do all calculations.
int recordZCoeffs(bool force=false)
Record the current coefficient vector when it changes or when forced.
w2tcsOffloader()
Default constructor.
pcf::IndiProperty m_indiP_zCoeffs
INDI property publishing the current offload coefficients.
virtual void loadConfig()
Load the application configuration.
std::vector< std::string > m_elNames
INDI element names corresponding to the coefficient vector, formatted as 00 through 99.
virtual void setupConfig()
Set up the application configuration.
virtual int appShutdown()
Shut down the application.
int processImage(void *curr_src, const dev::shmimT &dummy)
Process a new woofer image and update offload outputs using the currently allowed mode count.
std::unique_lock< std::mutex > lock(m_indiMutex)
static constexpr logPrioT LOG_CRITICAL
The process can not continue and will shut down (fatal)
static constexpr logPrioT LOG_ERROR
An error has occured which the software will attempt to correct.
A device base class which saves telemetry.
int checkRecordTimes(const telT &tel, telTs... tels)
Check the time of the last record for each telemetry type and make an entry if needed.
@ OPERATING
The device is operating, other than homing.
The type of the input message.
Log entry recording the woofer-to-TCS Zernike coefficient vector.
A simple text log, a string-type log.
#define TELEMETER_APP_LOGIC
Call telemeter::appLogic with error checking.
#define TELEMETER_LOAD_CONFIG(cfig)
Call telemeter::loadConfig with error checking.
#define TELEMETER_APP_STARTUP
Call telemeter::appStartup with error checking.
#define TELEMETER_SETUP_CONFIG(cfig)
Call telemeter::setupConfig with error checking.
#define TELEMETER_APP_SHUTDOWN
Call telemeter::appShutdown with error checking.