API
MagAOX::app::dev::frameGrabber< derivedT > Class Template Reference

#include <frameGrabber.hpp>

Collaboration diagram for MagAOX::app::dev::frameGrabber< derivedT >:
Collaboration graph

Public Types

enum  fgFlip { fgFlipNone , fgFlipUD , fgFlipLR , fgFlipUDLR }
 

Public Member Functions

int setupConfig (mx::app::appConfigurator &config)
 Setup the configuration system. More...
 
int loadConfig (mx::app::appConfigurator &config)
 load the configuration system results More...
 
int appStartup ()
 Startup function. More...
 
int appLogic ()
 Checks the framegrabber thread. More...
 
int onPowerOff ()
 On power off, sets m_reconfig to true. More...
 
int appShutdown ()
 Shuts down the framegrabber thread. More...
 
Telemeter Interface
int recordFGTimings (bool force=false)
 

Protected Types

typedef uint16_t cbIndexT
 

Protected Member Functions

void * loadImageIntoStreamCopy (void *dest, void *src, size_t width, size_t height, size_t szof)
 

Protected Attributes

int m_currentFlip {fgFlipNone}
 
uint32_t m_width {0}
 The width of the image, once deinterlaced etc. More...
 
uint32_t m_height {0}
 The height of the image, once deinterlaced etc. More...
 
uint8_t m_dataType {0}
 The ImageStreamIO type code. More...
 
size_t m_typeSize {0}
 The size of the type, in bytes. Result of sizeof. More...
 
int m_xbinning {0}
 The x-binning according to the framegrabber. More...
 
int m_ybinning {0}
 The y-binning according to the framegrabber. More...
 
timespec m_currImageTimestamp {0,0}
 The timestamp of the current image. More...
 
bool m_reconfig {false}
 Flag to set if a camera reconfiguration requires a framegrabber reset. More...
 
IMAGE * m_imageStream {nullptr}
 The ImageStreamIO shared memory buffer. More...
 
mx::sigproc::circularBufferIndex< timespec, cbIndexTm_atimes
 
mx::sigproc::circularBufferIndex< timespec, cbIndexTm_wtimes
 
std::vector< double > m_atimesD
 
std::vector< double > m_wtimesD
 
std::vector< double > m_watimesD
 
timespec m_dummy_ts {0,0}
 
uint64_t m_dummy_cnt {0}
 
char m_dummy_c {0}
 
double m_mna
 
double m_vara
 
double m_mnw
 
double m_varw
 
double m_mnwa
 
double m_varwa
 
Configurable Parameters
std::string m_shmimName {""}
 The name of the shared memory image, is used in /tmp/<shmimName>.im.shm. Derived classes should set a default. More...
 
int m_fgThreadPrio {2}
 Priority of the framegrabber thread, should normally be > 00. More...
 
std::string m_fgCpuset
 The cpuset to assign the framegrabber thread to. Not used if empty, the default. More...
 
uint32_t m_circBuffLength {1}
 Length of the circular buffer, in frames. More...
 
uint16_t m_latencyCircBuffMaxLength {3600}
 Maximum length of the latency measurement circular buffers. More...
 
float m_latencyCircBuffMaxTime {5}
 Maximum time of the latency meaurement circular buffers. More...
 
int m_defaultFlip {fgFlipNone}
 

Private Member Functions

derivedT & derived ()
 

Framegrabber Thread

This thread actually manages the framegrabbing hardware

bool m_fgThreadInit {true}
 Synchronizer for thread startup, to allow priority setting to finish. More...
 
pid_t m_fgThreadID {0}
 The ID of the framegrabber thread. More...
 
pcf::IndiProperty m_fgThreadProp
 The property to hold the f.g. thread details. More...
 
std::thread m_fgThread
 A separate thread for the actual framegrabbings. More...
 
static void fgThreadStart (frameGrabber *o)
 Thread starter, called by MagAOXApp::threadStart on thread construction. Calls fgThreadExec. More...
 
void fgThreadExec ()
 Execute framegrabbing. More...
 

INDI

pcf::IndiProperty m_indiP_shmimName
 Property used to report the shmim buffer name. More...
 
pcf::IndiProperty m_indiP_frameSize
 Property used to report the current frame size. More...
 
pcf::IndiProperty m_indiP_timing
 
int updateINDI ()
 Update the INDI properties for this device controller. More...
 

Detailed Description

template<class derivedT>
class MagAOX::app::dev::frameGrabber< derivedT >

MagAO-X generic frame grabber

The derived class derivedT has the following requirements:

  • Must be derived from MagAOXApp<true>
  • Must contain the following friend declaration:
    friend class dev::frameGrabber<derivedT>; //replace derivedT
  • Must declare the following typedef:
    typedef dev::frameGrabber<derivedT> frameGrabberT; //replace derivedT
  • must expose the following interface
    //Configures the camera for acquistion, must also set m_width, m_height, and m_dataType
    //so that the shared memory can be allocated
    int derivedT::configureAcquisition();
    //Gets the frames-per-second readout rate
    //used for the latency statistics
    float derivedT::fps();
    //Start acquisition.
    int derivedT::startAcquisition();
    //Acquires the data, and checks if it is valid.
    //This should set m_currImageTimestamp to the image timestamp.
    // returns 0 if valid, < 0 on error, > 0 on no data.
    int derivedT::acquireAndCheckValid()
    //Loads the acquired image into the stream, copying it to the appropriate member of m_imageStream->array.
    //This could simply be a memcpy.
    int derivedT::loadImageIntoStream(void * dest);
    //Take any actions needed to reconfigure the system. Called if m_reconfig is set to true.
    int derivedT::reconfig()
    Each of the above functions should return 0 on success, and -1 on an error (except fps). For acquireAndCheckValid >0 will indicate no data but not an error. In most cases, an appropriate state code, such as NOTCONNECTED, should be set as well.

A static configuration variable must be defined in derivedT as

static constexpr bool c_frameGrabber_flippable =true; //or: false

which determines whether or not the images can be flipped programatically.

Calls to this class's setupConfig, loadConfig, appStartup, appLogic, updateINDI, and appShutdown functions must be placed in the derived class's functions of the same name. For convenience the following macros are defined to provide error checking:

#define FRAMEGRABBER_SETUP_CONFIG(cfig)
Call frameGrabberT::setupConfig with error checking for frameGrabber.
#define FRAMEGRABBER_APP_LOGIC
Call frameGrabberT::appLogic with error checking for frameGrabber.
#define FRAMEGRABBER_APP_SHUTDOWN
Call frameGrabberT::appShutdown with error checking for frameGrabber.
#define FRAMEGRABBER_UPDATE_INDI
Call frameGrabberT::updateINDI with error checking for frameGrabber.
#define FRAMEGRABBER_LOAD_CONFIG(cfig)
Call frameGrabberT::loadConfig with error checking for frameGrabber.
#define FRAMEGRABBER_APP_STARTUP
Call frameGrabberT::appStartup with error checking for frameGrabber.


Definition at line 101 of file frameGrabber.hpp.

Member Typedef Documentation

◆ cbIndexT

template<class derivedT >
typedef uint16_t MagAOX::app::dev::frameGrabber< derivedT >::cbIndexT
protected

Definition at line 143 of file frameGrabber.hpp.

Member Enumeration Documentation

◆ fgFlip

template<class derivedT >
enum MagAOX::app::dev::frameGrabber::fgFlip
Enumerator
fgFlipNone 
fgFlipUD 
fgFlipLR 
fgFlipUDLR 

Definition at line 104 of file frameGrabber.hpp.

Member Function Documentation

◆ appLogic()

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::appLogic

Checks the framegrabber thread.

This should be called in derivedT::appLogic as

framegrabber<derivedT>::appLogic();

with appropriate error checking.

Returns
0 on success
-1 on error, which is logged.

Definition at line 461 of file frameGrabber.hpp.

◆ appShutdown()

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::appShutdown

Shuts down the framegrabber thread.

This should be called in derivedT::appShutdown as

framegrabber<derivedT>::appShutdown();

with appropriate error checking.

Returns
0 on success
-1 on error, which is logged.

Definition at line 552 of file frameGrabber.hpp.

Referenced by MagAOX::app::andorCtrl::appShutdown(), MagAOX::app::ocam2KCtrl::appShutdown(), MagAOX::app::picamCtrl::appShutdown(), MagAOX::app::qhyCtrl::appShutdown(), and MagAOX::app::zylaCtrl::appShutdown().

◆ appStartup()

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::appStartup

Startup function.

Starts the framegrabber thread This should be called in derivedT::appStartup as

framegrabber<derivedT>::appStartup();

with appropriate error checking.

Returns
0 on success
-1 on error, which is logged.

Definition at line 394 of file frameGrabber.hpp.

◆ derived()

template<class derivedT >
derivedT& MagAOX::app::dev::frameGrabber< derivedT >::derived ( )
inlineprivate

Definition at line 306 of file frameGrabber.hpp.

◆ fgThreadExec()

template<class derivedT >
void MagAOX::app::dev::frameGrabber< derivedT >::fgThreadExec
protected

Execute framegrabbing.

Todo:
this ought to wait until OPERATING, using READY as a sign of "not integrating"

Definition at line 580 of file frameGrabber.hpp.

Referenced by MagAOX::app::dev::frameGrabber< derivedT >::fgThreadStart().

◆ fgThreadStart()

template<class derivedT >
void MagAOX::app::dev::frameGrabber< derivedT >::fgThreadStart ( frameGrabber< derivedT > *  o)
staticprotected

Thread starter, called by MagAOXApp::threadStart on thread construction. Calls fgThreadExec.

Parameters
[in]oa pointer to a frameGrabber instance (normally this)

Definition at line 573 of file frameGrabber.hpp.

◆ loadConfig()

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::loadConfig ( mx::app::appConfigurator &  config)

load the configuration system results

This should be called in derivedT::loadConfig as

framegrabber<derivedT>::loadConfig(config);

with appropriate error checking.

Parameters
[in]configthe derived classes configurator

Definition at line 337 of file frameGrabber.hpp.

Referenced by MagAOX::app::andorCtrl::loadConfig(), MagAOX::app::ocam2KCtrl::loadConfig(), MagAOX::app::picamCtrl::loadConfig(), MagAOX::app::qhyCtrl::loadConfig(), MagAOX::app::zylaCtrl::loadConfig(), and MagAOX::app::pvcamCtrl::loadConfigImpl().

◆ loadImageIntoStreamCopy()

template<class derivedT >
void * MagAOX::app::dev::frameGrabber< derivedT >::loadImageIntoStreamCopy ( void *  dest,
void *  src,
size_t  width,
size_t  height,
size_t  szof 
)
protected

Definition at line 761 of file frameGrabber.hpp.

◆ onPowerOff()

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::onPowerOff

On power off, sets m_reconfig to true.

This should be called in derivedT::onPowerOff as

framegrabber<derivedT>::onPowerOff();

with appropriate error checking.

Returns
0 on success
-1 on error, which is logged.

Definition at line 530 of file frameGrabber.hpp.

◆ recordFGTimings()

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::recordFGTimings ( bool  force = false)

Definition at line 813 of file frameGrabber.hpp.

◆ setupConfig()

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::setupConfig ( mx::app::appConfigurator &  config)

Setup the configuration system.

This should be called in derivedT::setupConfig as

framegrabber<derivedT>::setupConfig(config);

with appropriate error checking.

Parameters
[out]configthe derived classes configurator

Definition at line 313 of file frameGrabber.hpp.

Referenced by MagAOX::app::andorCtrl::setupConfig(), MagAOX::app::ocam2KCtrl::setupConfig(), MagAOX::app::picamCtrl::setupConfig(), MagAOX::app::pvcamCtrl::setupConfig(), MagAOX::app::qhyCtrl::setupConfig(), and MagAOX::app::zylaCtrl::setupConfig().

◆ updateINDI()

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::updateINDI

Update the INDI properties for this device controller.

You should call this once per main loop. It is not called automatically.

Returns
0 on success.
-1 on error.

Definition at line 793 of file frameGrabber.hpp.

Member Data Documentation

◆ m_atimes

template<class derivedT >
mx::sigproc::circularBufferIndex<timespec, cbIndexT> MagAOX::app::dev::frameGrabber< derivedT >::m_atimes
protected

Definition at line 145 of file frameGrabber.hpp.

◆ m_atimesD

template<class derivedT >
std::vector<double> MagAOX::app::dev::frameGrabber< derivedT >::m_atimesD
protected

Definition at line 148 of file frameGrabber.hpp.

◆ m_circBuffLength

template<class derivedT >
uint32_t MagAOX::app::dev::frameGrabber< derivedT >::m_circBuffLength {1}
protected

Length of the circular buffer, in frames.

Definition at line 116 of file frameGrabber.hpp.

◆ m_currentFlip

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::m_currentFlip {fgFlipNone}
protected

Definition at line 125 of file frameGrabber.hpp.

◆ m_currImageTimestamp

template<class derivedT >
timespec MagAOX::app::dev::frameGrabber< derivedT >::m_currImageTimestamp {0,0}
protected

The timestamp of the current image.

Definition at line 137 of file frameGrabber.hpp.

◆ m_dataType

template<class derivedT >
uint8_t MagAOX::app::dev::frameGrabber< derivedT >::m_dataType {0}
protected

The ImageStreamIO type code.

Definition at line 130 of file frameGrabber.hpp.

◆ m_defaultFlip

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::m_defaultFlip {fgFlipNone}
protected

Definition at line 121 of file frameGrabber.hpp.

◆ m_dummy_c

template<class derivedT >
char MagAOX::app::dev::frameGrabber< derivedT >::m_dummy_c {0}
protected

Definition at line 154 of file frameGrabber.hpp.

◆ m_dummy_cnt

template<class derivedT >
uint64_t MagAOX::app::dev::frameGrabber< derivedT >::m_dummy_cnt {0}
protected

Definition at line 153 of file frameGrabber.hpp.

◆ m_dummy_ts

template<class derivedT >
timespec MagAOX::app::dev::frameGrabber< derivedT >::m_dummy_ts {0,0}
protected

Definition at line 152 of file frameGrabber.hpp.

◆ m_fgCpuset

template<class derivedT >
std::string MagAOX::app::dev::frameGrabber< derivedT >::m_fgCpuset
protected

The cpuset to assign the framegrabber thread to. Not used if empty, the default.

Definition at line 114 of file frameGrabber.hpp.

◆ m_fgThread

template<class derivedT >
std::thread MagAOX::app::dev::frameGrabber< derivedT >::m_fgThread
protected

A separate thread for the actual framegrabbings.

Definition at line 253 of file frameGrabber.hpp.

◆ m_fgThreadID

template<class derivedT >
pid_t MagAOX::app::dev::frameGrabber< derivedT >::m_fgThreadID {0}
protected

The ID of the framegrabber thread.

Definition at line 249 of file frameGrabber.hpp.

◆ m_fgThreadInit

template<class derivedT >
bool MagAOX::app::dev::frameGrabber< derivedT >::m_fgThreadInit {true}
protected

Synchronizer for thread startup, to allow priority setting to finish.

Definition at line 247 of file frameGrabber.hpp.

◆ m_fgThreadPrio

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::m_fgThreadPrio {2}
protected

Priority of the framegrabber thread, should normally be > 00.

Definition at line 113 of file frameGrabber.hpp.

◆ m_fgThreadProp

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::frameGrabber< derivedT >::m_fgThreadProp
protected

The property to hold the f.g. thread details.

Definition at line 251 of file frameGrabber.hpp.

◆ m_height

template<class derivedT >
uint32_t MagAOX::app::dev::frameGrabber< derivedT >::m_height {0}
protected

The height of the image, once deinterlaced etc.

Definition at line 128 of file frameGrabber.hpp.

◆ m_imageStream

template<class derivedT >
IMAGE* MagAOX::app::dev::frameGrabber< derivedT >::m_imageStream {nullptr}
protected

The ImageStreamIO shared memory buffer.

Definition at line 141 of file frameGrabber.hpp.

◆ m_indiP_frameSize

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::frameGrabber< derivedT >::m_indiP_frameSize
protected

Property used to report the current frame size.

Definition at line 281 of file frameGrabber.hpp.

◆ m_indiP_shmimName

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::frameGrabber< derivedT >::m_indiP_shmimName
protected

Property used to report the shmim buffer name.

Definition at line 279 of file frameGrabber.hpp.

◆ m_indiP_timing

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::frameGrabber< derivedT >::m_indiP_timing
protected

Definition at line 283 of file frameGrabber.hpp.

◆ m_latencyCircBuffMaxLength

template<class derivedT >
uint16_t MagAOX::app::dev::frameGrabber< derivedT >::m_latencyCircBuffMaxLength {3600}
protected

Maximum length of the latency measurement circular buffers.

Definition at line 118 of file frameGrabber.hpp.

◆ m_latencyCircBuffMaxTime

template<class derivedT >
float MagAOX::app::dev::frameGrabber< derivedT >::m_latencyCircBuffMaxTime {5}
protected

Maximum time of the latency meaurement circular buffers.

Definition at line 119 of file frameGrabber.hpp.

◆ m_mna

template<class derivedT >
double MagAOX::app::dev::frameGrabber< derivedT >::m_mna
protected

Definition at line 156 of file frameGrabber.hpp.

◆ m_mnw

template<class derivedT >
double MagAOX::app::dev::frameGrabber< derivedT >::m_mnw
protected

Definition at line 159 of file frameGrabber.hpp.

◆ m_mnwa

template<class derivedT >
double MagAOX::app::dev::frameGrabber< derivedT >::m_mnwa
protected

Definition at line 162 of file frameGrabber.hpp.

◆ m_reconfig

template<class derivedT >
bool MagAOX::app::dev::frameGrabber< derivedT >::m_reconfig {false}
protected

Flag to set if a camera reconfiguration requires a framegrabber reset.

Definition at line 139 of file frameGrabber.hpp.

◆ m_shmimName

template<class derivedT >
std::string MagAOX::app::dev::frameGrabber< derivedT >::m_shmimName {""}
protected

The name of the shared memory image, is used in /tmp/<shmimName>.im.shm. Derived classes should set a default.

Definition at line 111 of file frameGrabber.hpp.

◆ m_typeSize

template<class derivedT >
size_t MagAOX::app::dev::frameGrabber< derivedT >::m_typeSize {0}
protected

The size of the type, in bytes. Result of sizeof.

Definition at line 131 of file frameGrabber.hpp.

◆ m_vara

template<class derivedT >
double MagAOX::app::dev::frameGrabber< derivedT >::m_vara
protected

Definition at line 157 of file frameGrabber.hpp.

◆ m_varw

template<class derivedT >
double MagAOX::app::dev::frameGrabber< derivedT >::m_varw
protected

Definition at line 160 of file frameGrabber.hpp.

◆ m_varwa

template<class derivedT >
double MagAOX::app::dev::frameGrabber< derivedT >::m_varwa
protected

Definition at line 163 of file frameGrabber.hpp.

◆ m_watimesD

template<class derivedT >
std::vector<double> MagAOX::app::dev::frameGrabber< derivedT >::m_watimesD
protected

Definition at line 150 of file frameGrabber.hpp.

◆ m_width

template<class derivedT >
uint32_t MagAOX::app::dev::frameGrabber< derivedT >::m_width {0}
protected

The width of the image, once deinterlaced etc.

Definition at line 127 of file frameGrabber.hpp.

◆ m_wtimes

template<class derivedT >
mx::sigproc::circularBufferIndex<timespec, cbIndexT> MagAOX::app::dev::frameGrabber< derivedT >::m_wtimes
protected

Definition at line 146 of file frameGrabber.hpp.

◆ m_wtimesD

template<class derivedT >
std::vector<double> MagAOX::app::dev::frameGrabber< derivedT >::m_wtimesD
protected

Definition at line 149 of file frameGrabber.hpp.

◆ m_xbinning

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::m_xbinning {0}
protected

The x-binning according to the framegrabber.

Definition at line 133 of file frameGrabber.hpp.

◆ m_ybinning

template<class derivedT >
int MagAOX::app::dev::frameGrabber< derivedT >::m_ybinning {0}
protected

The y-binning according to the framegrabber.

Definition at line 134 of file frameGrabber.hpp.


The documentation for this class was generated from the following file: