10 #include "../../libMagAOX/libMagAOX.hpp"
11 #include "../../magaox_git_version.h"
13 #include <mx/math/fit/fitGaussian.hpp>
14 #include <mx/improc/imageFilters.hpp>
102 mx::improc::eigenImage<float>
m_sm;
115 mx::sigproc::circularBufferIndex<float, cbIndexT>
m_xcb;
116 mx::sigproc::circularBufferIndex<float, cbIndexT>
m_ycb;
127 mx::math::fit::fitGaussian2Dsym<float>
m_gfit;
288 config.add(
"fitter.fpsSource",
"",
"fitter.fpsSource", argType::Required,
"fitter",
"fpsSource",
false,
"string",
"Device name for getting fps if time-based averaging is used. This device should have *.fps.current.");
330 log<software_critical>({__FILE__, __LINE__, errno,0,
"Initializing S.M. semaphore"});
396 for(
size_t n=0; n <=
m_atimesD.size(); ++n)
431 log<software_error>({__FILE__, __LINE__});
454 static_cast<void>(dummy);
473 if(cbSz < 3) cbSz = 3;
474 m_xcb.maxEntries(cbSz);
475 m_ycb.maxEntries(cbSz);
487 static_cast<void>(dummy);
495 m_image.data()[nn] = ((uint16_t*)curr_src) [nn] -
m_dark.data()[nn];
502 m_image.data()[nn] = ((uint16_t*)curr_src) [nn];
544 log<software_critical>({__FILE__, __LINE__, errno, 0,
"Error posting to semaphore"});
549 if(
m_xcb.maxEntries() > 0)
561 static_cast<void>(dummy);
581 static_cast<void>(dummy);
587 m_dark.data()[nn] += ((
float*)curr_src) [nn];
619 if(clock_gettime(CLOCK_REALTIME, &ts) < 0)
621 log<software_critical>({__FILE__,__LINE__,errno, 0,
"clock_gettime"});
650 ((
float *) dest)[0] =
m_x -
m_dx;
651 ((
float *) dest)[1] =
m_y -
m_dy;
666 if(
ipRecv.getName() != m_indiP_dx.getName())
668 log<software_error>({__FILE__,__LINE__,
"wrong INDI property received."});
674 if( indiTargetUpdate( m_indiP_dx, target,
ipRecv,
true) < 0)
676 log<software_error>({__FILE__,__LINE__});
688 if(
ipRecv.getName() != m_indiP_dy.getName())
690 log<software_error>({__FILE__,__LINE__,
"wrong INDI property received."});
696 if( indiTargetUpdate( m_indiP_dy, target,
ipRecv,
true) < 0)
698 log<software_error>({__FILE__,__LINE__});
710 if(
ipRecv.getName() != m_indiP_fpsSource.getName())
712 log<software_error>({__FILE__, __LINE__,
"Invalid INDI property."});
716 if(
ipRecv.find(
"current") !=
true )
721 std::lock_guard<std::mutex> guard(m_indiMutex);
723 realT fps =
ipRecv[
"current"].get<
float>();
728 shmimMonitorT::m_restart =
true;
#define IMAGESTRUCT_FLOAT
The base-class for MagAO-X applications.
void updateIfChanged(pcf::IndiProperty &p, const std::string &el, const T &newVal, pcf::IndiProperty::PropertyStateType ipState=pcf::IndiProperty::Ok)
Update an INDI property element value if it has changed.
stateCodes::stateCodeT state()
Get the current state code.
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
timespec m_currImageTimestamp
The timestamp of the current image.
uint32_t m_width
The width of the image, once deinterlaced etc.
int appShutdown()
Shuts down the framegrabber thread.
int recordFGTimings(bool force=false)
void loadConfig(mx::app::appConfigurator &config)
load the configuration system results
void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
int updateINDI()
Update the INDI properties for this device controller.
uint8_t m_dataType
The ImageStreamIO type code.
int appLogic()
Checks the framegrabber thread.
std::vector< double > m_atimesD
int appStartup()
Startup function.
uint32_t m_height
The height of the image, once deinterlaced etc.
int appStartup()
Startup function.
uint32_t m_width
The width of the images in the stream.
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.
uint8_t m_dataType
The ImageStreamIO type code.
void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
bool m_getExistingFirst
If set to true by derivedT, any existing image will be grabbed and sent to processImage before waitin...
void loadConfig(mx::app::appConfigurator &config)
load the configuration system results
virtual int appLogic()
Implementation of the FSM for psfFit.
int loadImageIntoStream(void *dest)
Implementation of the framegrabber loadImageIntoStream interface.
int reconfig()
Implementation of the framegrabber reconfig interface.
int loadConfigImpl(mx::app::appConfigurator &_config)
Implementation of loadConfig logic, separated for testing.
float realT
Floating point type in which to do all calculations.
static constexpr bool c_frameGrabber_flippable
app:dev config to tell framegrabber these images can not be flipped
INDI_NEWCALLBACK_DECL(psfFit, m_indiP_dy)
uint16_t m_fitCircBuffMaxLength
Maximum length of the latency measurement circular buffers.
INDI_NEWCALLBACK_DECL(psfFit, m_indiP_dx)
float fps()
Implementation of the framegrabber fps interface.
pcf::IndiProperty m_indiP_dx
std::vector< float > m_ycbD
sem_t m_smSemaphore
Semaphore used to synchronize the fg thread and the sm thread.
dev::telemeter< psfFit > telemeterT
mx::sigproc::circularBufferIndex< float, cbIndexT > m_xcb
virtual void loadConfig()
pcf::IndiProperty m_indiP_dy
~psfFit() noexcept
D'tor, declared and defined for noexcept.
int acquireAndCheckValid()
Implementation of the framegrabber acquireAndCheckValid interface.
dev::frameGrabber< psfFit > frameGrabberT
int recordTelem(const telem_fgtimings *)
int allocate(const dev::shmimT &)
float m_fitCircBuffMaxTime
Maximum time of the latency meaurement circular buffers.
mx::improc::eigenImage< float > m_dark
pcf::IndiProperty m_indiP_fpsSource
virtual void setupConfig()
mx::math::fit::fitGaussian2Dsym< float > m_gfit
virtual int appShutdown()
Shutdown the app.
mx::improc::eigenImage< float > m_sm
dev::shmimMonitor< psfFit, darkShmimT > darkShmimMonitorT
std::vector< float > m_xcbD
mx::sigproc::circularBufferIndex< float, cbIndexT > m_ycb
INDI_SETCALLBACK_DECL(psfFit, m_indiP_fpsSource)
virtual int appStartup()
Startup function.
int configureAcquisition()
Implementation of the framegrabber configureAcquisition interface.
std::string m_fpsSource
Device name for getting fps if time-based averaging is used. This device should have *....
int processImage(void *curr_src, const dev::shmimT &)
mx::improc::eigenImage< float > m_image
dev::shmimMonitor< psfFit > shmimMonitorT
int startAcquisition()
Implementation of the framegrabber startAcquisition interface.
#define CREATE_REG_INDI_NEW_NUMBERF(prop, name, min, max, step, format, label, group)
Create and register a NEW INDI property as a standard number as float, using the standard callback na...
#define REG_INDI_SETPROP(prop, devName, propName)
Register a SET INDI property with the class, using the standard callback name.
@ OPERATING
The device is operating, other than homing.
const pcf::IndiProperty & ipRecv
INDI_NEWCALLBACK_DEFN(acesxeCtrl, m_indiP_windspeed)(const pcf
INDI_SETCALLBACK_DEFN(MagAOXApp< _useINDI >, m_indiP_powerChannel)(const pcf
constexpr static logPrioT LOG_INFO
Informational. The info log level is the lowest level recorded during normal operations.
constexpr static logPrioT LOG_NOTICE
A normal but significant condition.
static std::string configSection()
static std::string indiPrefix()
A device which saves telemetry.
int appShutdown()
Perform telemeter application shutdown.
int loadConfig(appConfigurator &config)
Load the device section from an application configurator.
int appLogic()
Perform telemeter application logic.
int setupConfig(appConfigurator &config)
Setup an application configurator for the device section.
int appStartup()
Starts the telemetry log thread.
int checkRecordTimes(const telT &tel, telTs... tels)
Check the time of the last record for each telemetry type and make an entry if needed.
Log entry recording framegrabber timings.