API
 
Loading...
Searching...
No Matches
MagAOX::app::dev::shmimMonitor< derivedT, specificT > Class Template Reference

#include <shmimMonitor.hpp>

Collaboration diagram for MagAOX::app::dev::shmimMonitor< derivedT, specificT >:
Collaboration graph

Public Member Functions

const std::string & shmimName () const
 
const uint32_t & width () const
 
const uint32_t & height () const
 
const uint32_t & depth () const
 
const uint8_t & dataType () const
 
const size_t & typeSize () const
 
int setupConfig (mx::app::appConfigurator &config)
 Setup the configuration system.
 
int loadConfig (mx::app::appConfigurator &config)
 load the configuration system results
 
int appStartup ()
 Startup function.
 
int appLogic ()
 Checks the shmimMonitor thread.
 
int appShutdown ()
 Shuts down the shmimMonitor thread.
 

Protected Attributes

bool m_getExistingFirst { false }
 
shmimMonitorState m_smState { shmimMonitorState::init }
 
int m_semaphoreNumber { 5 }
 The image structure semaphore index.
 
uint32_t m_width { 0 }
 The width of the images in the stream.
 
uint32_t m_height { 0 }
 The height of the images in the stream.
 
uint32_t m_depth { 0 }
 The depth of the circular buffer in the stream.
 
uint8_t m_dataType { 0 }
 The ImageStreamIO type code.
 
size_t m_typeSize { 0 }
 The size of the type, in bytes. Result of sizeof.
 
IMAGE m_imageStream
 The ImageStreamIO shared memory buffer.
 
ino_t m_inode { 0 }
 The inode of the image stream file.
 
Configurable Parameters
std::string m_shmimName { "" }
 
int m_smThreadPrio { 2 }
 Priority of the shmimMonitor thread, should normally be > 00.
 
std::string m_smCpuset
 The cpuset to assign the shmimMonitor thread to. Ignored if empty (the default).
 
SIGSEGV & SIGBUS signal handling

These signals occur as a result of a ImageStreamIO source server resetting (e.g. changing frame sizes). When they occur a restart of the shmim monitor thread main loops is triggered.

bool m_restart { false }
 Flag indicating tha the shared memory should be reinitialized.
 

Private Member Functions

derivedT & derived ()
 

shmimmonitor Thread

This thread actually monitors the shared memory buffer

bool m_smThreadInit { true }
 Synchronizer for thread startup, to allow priority setting to finish.
 
pid_t m_smThreadID { 0 }
 The s.m. thread PID.
 
pcf::IndiProperty m_smThreadProp
 The property to hold the s.m. thread details.
 
std::thread m_smThread
 A separate thread for the actual monitoring.
 
static void smThreadStart (shmimMonitor *s)
 Thread starter, called by MagAOXApp::threadStart on thread construction. Calls smThreadExec.
 
void smThreadExec ()
 Execute the monitoring thread.
 
int create (uint32_t width, uint32_t height, uint32_t depth, uint8_t datatype, void *initData=nullptr)
 Create the image.
 

INDI

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

Detailed Description

template<class derivedT, class specificT = shmimT>
class MagAOX::app::dev::shmimMonitor< derivedT, specificT >

MagAO-X generic shared memory monitor

The derived class derivedT has the following requirements (see below for discussion of specificT):

The template specifier specificT allows inheritance of multiple shmimMonitor classes. This type must have at least the static member function:

static std::string indiPrefix()

which returns the string which is prefixed to INDI properties. The default shmimT uses "sm".

Additionally, if specificT is used, the following convenience macros can be used:

SHMIMMONITORT_SETUP_CONFIG( SHMIMMONITORT, cfig )
SHMIMMONITORT_LOAD_CONFIG( SHMIMMONITORT, cfig )
SHMIMMONITORT_APP_STARTUP( SHMIMMONITORT )
SHMIMMONITORT_APP_LOGIC( SHMIMMONITORT )
#define SHMIMMONITORT_APP_STARTUP(SHMIMMONITORT)
Call shmimMonitorT::appStartup with error checking for a typedef-ed shmimMonitor.
#define SHMIMMONITORT_SETUP_CONFIG(SHMIMMONITORT, cfig)
Call shmimMonitorT::setupConfig with error checking for a typedef-ed shmimMonitor.
#define SHMIMMONITORT_APP_LOGIC(SHMIMMONITORT)
Call shmimMonitorT::appLogic with error checking for a typedef-ed shmimMonitor.
#define SHMIMMONITORT_APP_SHUTDOWN(SHMIMMONITORT)
Call shmimMonitorT::appShutodwn with error checking for a typedef-ed shmimMonitor.
#define SHMIMMONITORT_LOAD_CONFIG(SHMIMMONITORT, cfig)
Call shmimMonitorT::loadConfig with error checking for a typedef-ed shmimMonitor.

Definition at line 111 of file shmimMonitor.hpp.

Member Function Documentation

◆ appLogic()

template<class derivedT , class specificT >
int MagAOX::app::dev::shmimMonitor< derivedT, specificT >::appLogic ( )

Checks the shmimMonitor thread.

This should be called in derivedT::appLogic as

with appropriate error checking.

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

Definition at line 470 of file shmimMonitor.hpp.

◆ appShutdown()

template<class derivedT , class specificT >
int MagAOX::app::dev::shmimMonitor< derivedT, specificT >::appShutdown ( )

Shuts down the shmimMonitor thread.

This should be called in derivedT::appShutdown as

with appropriate error checking.

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

Definition at line 485 of file shmimMonitor.hpp.

◆ appStartup()

template<class derivedT , class specificT >
int MagAOX::app::dev::shmimMonitor< derivedT, specificT >::appStartup ( )

Startup function.

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

with appropriate error checking.

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

Definition at line 394 of file shmimMonitor.hpp.

◆ create()

template<class derivedT , class specificT >
int MagAOX::app::dev::shmimMonitor< derivedT, specificT >::create ( uint32_t  width,
uint32_t  height,
uint32_t  depth,
uint8_t  datatype,
void *  initData = nullptr 
)
protected

Create the image.

This will create the shared memory image, erasing an existing. This is independent of the actual shmim monitoring function, which will pick up the new inode change on its own and restart the allocate() and processImage() cycle.

Returns
0 on success
<0 on error
Parameters
[in]widthwidth of the new image
[in]heightheight of the new image
[in]depthdepth of the new image
[in]datatypeCACAO data type of the new image
[in]initData[optional] data to initialize the new image with. Must be of size width*height*depth*sizeof(dataType)

Definition at line 857 of file shmimMonitor.hpp.

◆ dataType()

template<class derivedT , class specificT >
const uint8_t & MagAOX::app::dev::shmimMonitor< derivedT, specificT >::dataType ( ) const

Definition at line 322 of file shmimMonitor.hpp.

◆ depth()

template<class derivedT , class specificT >
const uint32_t & MagAOX::app::dev::shmimMonitor< derivedT, specificT >::depth ( ) const

Definition at line 316 of file shmimMonitor.hpp.

◆ derived()

template<class derivedT , class specificT = shmimT>
derivedT & MagAOX::app::dev::shmimMonitor< derivedT, specificT >::derived ( )
inlineprivate

Definition at line 287 of file shmimMonitor.hpp.

◆ height()

template<class derivedT , class specificT >
const uint32_t & MagAOX::app::dev::shmimMonitor< derivedT, specificT >::height ( ) const

Definition at line 310 of file shmimMonitor.hpp.

◆ loadConfig()

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

load the configuration system results

This should be called in derivedT::loadConfig as

int loadConfig(mx::app::appConfigurator &config)
load the configuration system results

with appropriate error checking.

Parameters
[in]configthe derived classes configurator

Definition at line 383 of file shmimMonitor.hpp.

◆ setupConfig()

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

Setup the configuration system.

This should be called in derivedT::setupConfig as

int setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.

with appropriate error checking.

Parameters
[out]configthe derived classes configurator

Definition at line 334 of file shmimMonitor.hpp.

◆ shmimName()

template<class derivedT , class specificT >
const std::string & MagAOX::app::dev::shmimMonitor< derivedT, specificT >::shmimName ( ) const

Definition at line 298 of file shmimMonitor.hpp.

◆ smThreadExec()

template<class derivedT , class specificT >
void MagAOX::app::dev::shmimMonitor< derivedT, specificT >::smThreadExec ( )
protected

Execute the monitoring thread.

<

Todo:
this isn't right--> isn't there a define in cacao to use?

< The semaphore to monitor for new image data

Todo:
change to naxis?
Todo:
change to naxis?

Definition at line 509 of file shmimMonitor.hpp.

Referenced by MagAOX::app::dev::shmimMonitor< derivedT, specificT >::smThreadStart().

◆ smThreadStart()

template<class derivedT , class specificT >
void MagAOX::app::dev::shmimMonitor< derivedT, specificT >::smThreadStart ( shmimMonitor< derivedT, specificT > *  s)
staticprotected

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

Parameters
[in]sa pointer to a shmimMonitor instance (normally this)

Definition at line 503 of file shmimMonitor.hpp.

◆ typeSize()

template<class derivedT , class specificT >
const size_t & MagAOX::app::dev::shmimMonitor< derivedT, specificT >::typeSize ( ) const

Definition at line 328 of file shmimMonitor.hpp.

◆ updateINDI()

template<class derivedT , class specificT >
int MagAOX::app::dev::shmimMonitor< derivedT, specificT >::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 923 of file shmimMonitor.hpp.

◆ width()

template<class derivedT , class specificT >
const uint32_t & MagAOX::app::dev::shmimMonitor< derivedT, specificT >::width ( ) const

Definition at line 304 of file shmimMonitor.hpp.

Member Data Documentation

◆ m_dataType

template<class derivedT , class specificT = shmimT>
uint8_t MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_dataType { 0 }
protected

The ImageStreamIO type code.

Definition at line 138 of file shmimMonitor.hpp.

◆ m_depth

template<class derivedT , class specificT = shmimT>
uint32_t MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_depth { 0 }
protected

The depth of the circular buffer in the stream.

Definition at line 136 of file shmimMonitor.hpp.

◆ m_getExistingFirst

template<class derivedT , class specificT = shmimT>
bool MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_getExistingFirst { false }
protected

If set to true by derivedT, any existing image will be grabbed and sent to processImage before waiting on the semaphore.

Definition at line 127 of file shmimMonitor.hpp.

◆ m_height

template<class derivedT , class specificT = shmimT>
uint32_t MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_height { 0 }
protected

The height of the images in the stream.

Definition at line 135 of file shmimMonitor.hpp.

◆ m_imageStream

template<class derivedT , class specificT = shmimT>
IMAGE MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_imageStream
protected

The ImageStreamIO shared memory buffer.

Definition at line 141 of file shmimMonitor.hpp.

◆ m_indiP_frameSize

template<class derivedT , class specificT = shmimT>
pcf::IndiProperty MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_indiP_frameSize
protected

Property used to report the current frame size.

Definition at line 272 of file shmimMonitor.hpp.

◆ m_indiP_shmimName

template<class derivedT , class specificT = shmimT>
pcf::IndiProperty MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_indiP_shmimName
protected

Property used to report the shmim buffer name.

Definition at line 270 of file shmimMonitor.hpp.

◆ m_inode

template<class derivedT , class specificT = shmimT>
ino_t MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_inode { 0 }
protected

The inode of the image stream file.

Definition at line 143 of file shmimMonitor.hpp.

◆ m_restart

template<class derivedT , class specificT = shmimT>
bool MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_restart { false }
protected

Flag indicating tha the shared memory should be reinitialized.

Definition at line 222 of file shmimMonitor.hpp.

◆ m_semaphoreNumber

template<class derivedT , class specificT = shmimT>
int MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_semaphoreNumber { 5 }
protected

The image structure semaphore index.

Definition at line 132 of file shmimMonitor.hpp.

◆ m_shmimName

template<class derivedT , class specificT = shmimT>
std::string MagAOX::app::dev::shmimMonitor< derivedT, specificT >::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 118 of file shmimMonitor.hpp.

◆ m_smCpuset

template<class derivedT , class specificT = shmimT>
std::string MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_smCpuset
protected

The cpuset to assign the shmimMonitor thread to. Ignored if empty (the default).

Definition at line 123 of file shmimMonitor.hpp.

◆ m_smState

template<class derivedT , class specificT = shmimT>
shmimMonitorState MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_smState { shmimMonitorState::init }
protected

Definition at line 130 of file shmimMonitor.hpp.

◆ m_smThread

template<class derivedT , class specificT = shmimT>
std::thread MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_smThread
protected

A separate thread for the actual monitoring.

Definition at line 238 of file shmimMonitor.hpp.

◆ m_smThreadID

template<class derivedT , class specificT = shmimT>
pid_t MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_smThreadID { 0 }
protected

The s.m. thread PID.

Definition at line 234 of file shmimMonitor.hpp.

◆ m_smThreadInit

template<class derivedT , class specificT = shmimT>
bool MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_smThreadInit { true }
protected

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

Definition at line 232 of file shmimMonitor.hpp.

◆ m_smThreadPrio

template<class derivedT , class specificT = shmimT>
int MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_smThreadPrio { 2 }
protected

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

Definition at line 121 of file shmimMonitor.hpp.

◆ m_smThreadProp

template<class derivedT , class specificT = shmimT>
pcf::IndiProperty MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_smThreadProp
protected

The property to hold the s.m. thread details.

Definition at line 236 of file shmimMonitor.hpp.

◆ m_typeSize

template<class derivedT , class specificT = shmimT>
size_t MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_typeSize { 0 }
protected

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

Definition at line 139 of file shmimMonitor.hpp.

◆ m_width

template<class derivedT , class specificT = shmimT>
uint32_t MagAOX::app::dev::shmimMonitor< derivedT, specificT >::m_width { 0 }
protected

The width of the images in the stream.

Definition at line 134 of file shmimMonitor.hpp.


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