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

void setupConfig (mx::app::appConfigurator &config)
 Setup the configuration system. More...
 
void 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 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 and appShutdown functions must be placed in the derived class's functions of the same name.

Definition at line 78 of file frameGrabber.hpp.

Member Typedef Documentation

◆ cbIndexT

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

Definition at line 120 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 81 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 434 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 525 of file frameGrabber.hpp.

Referenced by MagAOX::app::andorCtrl::appShutdown(), MagAOX::app::cameraSim::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 367 of file frameGrabber.hpp.

◆ derived()

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

Definition at line 283 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 553 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 546 of file frameGrabber.hpp.

◆ loadConfig()

template<class derivedT >
void 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 312 of file frameGrabber.hpp.

Referenced by MagAOX::app::andorCtrl::loadConfig(), MagAOX::app::cameraSim::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 734 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 503 of file frameGrabber.hpp.

◆ recordFGTimings()

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

Definition at line 786 of file frameGrabber.hpp.

◆ setupConfig()

template<class derivedT >
void 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 290 of file frameGrabber.hpp.

Referenced by MagAOX::app::andorCtrl::setupConfig(), MagAOX::app::cameraSim::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 766 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 122 of file frameGrabber.hpp.

◆ m_atimesD

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

Definition at line 125 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 93 of file frameGrabber.hpp.

◆ m_currentFlip

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

Definition at line 102 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 114 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 107 of file frameGrabber.hpp.

◆ m_defaultFlip

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

Definition at line 98 of file frameGrabber.hpp.

◆ m_dummy_c

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

Definition at line 131 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 130 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 129 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 91 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 230 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 226 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 224 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 90 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 228 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 105 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 118 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 258 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 256 of file frameGrabber.hpp.

◆ m_indiP_timing

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

Definition at line 260 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 95 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 96 of file frameGrabber.hpp.

◆ m_mna

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

Definition at line 133 of file frameGrabber.hpp.

◆ m_mnw

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

Definition at line 136 of file frameGrabber.hpp.

◆ m_mnwa

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

Definition at line 139 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 116 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 88 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 108 of file frameGrabber.hpp.

◆ m_vara

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

Definition at line 134 of file frameGrabber.hpp.

◆ m_varw

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

Definition at line 137 of file frameGrabber.hpp.

◆ m_varwa

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

Definition at line 140 of file frameGrabber.hpp.

◆ m_watimesD

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

Definition at line 127 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 104 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 123 of file frameGrabber.hpp.

◆ m_wtimesD

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

Definition at line 126 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 110 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 111 of file frameGrabber.hpp.


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