#include <shmimMonitor.hpp>
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 shmimMonitor thread. More... | |
int | appShutdown () |
Shuts down the shmimMonitor thread. More... | |
Protected Attributes | |
bool | m_getExistingFirst {false} |
If set to true by derivedT, any existing image will be grabbed and sent to processImage before waiting on the semaphore. More... | |
int | m_semaphoreNumber {5} |
The image structure semaphore index. More... | |
uint32_t | m_width {0} |
The width of the images in the stream. More... | |
uint32_t | m_height {0} |
The height of the images in the stream. More... | |
uint32_t | m_depth {0} |
The depth of the circular buffer in the stream. 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... | |
IMAGE | m_imageStream |
The ImageStreamIO shared memory buffer. More... | |
ino_t | m_inode {0} |
The inode of the image stream file. More... | |
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_smThreadPrio {2} |
Priority of the shmimMonitor thread, should normally be > 00. More... | |
std::string | m_smCpuset |
The cpuset to assign the shmimMonitor thread to. Ignored if empty (the default). More... | |
Private Member Functions | |
derivedT & | derived () |
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. More... | |
static shmimMonitor * | m_selfMonitor = nullptr |
Static pointer to this (set in constructor). Used for getting out of the static SIGSEGV handler. More... | |
int | setSigSegvHandler () |
Sets the handler for SIGSEGV and SIGBUS. More... | |
void | handlerSigSegv (int signum, siginfo_t *siginf, void *ucont) |
Handles SIGSEGV and SIGBUS. Sets m_restart to true. More... | |
static void | _handlerSigSegv (int signum, siginfo_t *siginf, void *ucont) |
The handler called when SIGSEGV or SIGBUS is received, which will be due to ImageStreamIO server resets. Just a wrapper for handlerSigSegv. More... | |
shmimmonitor Thread | |
bool | m_smThreadInit {true} |
Synchronizer for thread startup, to allow priority setting to finish. More... | |
pid_t | m_smThreadID {0} |
The s.m. thread PID. More... | |
pcf::IndiProperty | m_smThreadProp |
The property to hold the s.m. thread details. More... | |
std::thread | m_smThread |
A separate thread for the actual monitoring. More... | |
void | smThreadExec () |
Execute the monitoring thread. More... | |
static void | smThreadStart (shmimMonitor *s) |
Thread starter, called by MagAOXApp::threadStart on thread construction. Calls smThreadExec. 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... | |
int | updateINDI () |
Update the INDI properties for this device controller. More... | |
MagAO-X generic shared memory monitor
The derived class derivedT
must expose the following interface
Each of the above functions should return 0 on success, and -1 on an error.
This class should be declared a friend in the derived class, like so:
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.
The template specifier specificT
allows inheritance of multiple shmimMonitor classes. This type must have at least the static member function:
which returns the string to prefix to INDI properties. The default shmimT
uses "sm".
Definition at line 78 of file shmimMonitor.hpp.
|
staticprotected |
The handler called when SIGSEGV or SIGBUS is received, which will be due to ImageStreamIO server resets. Just a wrapper for handlerSigSegv.
Definition at line 431 of file shmimMonitor.hpp.
int MagAOX::app::dev::shmimMonitor< derivedT, specificT >::appLogic |
Checks the shmimMonitor thread.
This should be called in derivedT::appLogic
as
with appropriate error checking.
Definition at line 360 of file shmimMonitor.hpp.
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.
Definition at line 375 of file shmimMonitor.hpp.
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.
Definition at line 283 of file shmimMonitor.hpp.
|
inlineprivate |
Definition at line 246 of file shmimMonitor.hpp.
|
protected |
Handles SIGSEGV and SIGBUS. Sets m_restart to true.
Definition at line 440 of file shmimMonitor.hpp.
void MagAOX::app::dev::shmimMonitor< derivedT, specificT >::loadConfig | ( | mx::app::appConfigurator & | config | ) |
load the configuration system results
This should be called in derivedT::loadConfig
as
with appropriate error checking.
[in] | config | the derived classes configurator |
Definition at line 274 of file shmimMonitor.hpp.
|
protected |
Sets the handler for SIGSEGV and SIGBUS.
These are caused by ImageStreamIO server resets.
Definition at line 393 of file shmimMonitor.hpp.
void MagAOX::app::dev::shmimMonitor< derivedT, specificT >::setupConfig | ( | mx::app::appConfigurator & | config | ) |
Setup the configuration system.
This should be called in derivedT::setupConfig
as
with appropriate error checking.
[out] | config | the derived classes configurator |
Definition at line 258 of file shmimMonitor.hpp.
|
protected |
Execute the monitoring thread.
<
< The semaphore to monitor for new image data
Definition at line 462 of file shmimMonitor.hpp.
Referenced by MagAOX::app::dev::shmimMonitor< derivedT, specificT >::smThreadStart().
|
staticprotected |
Thread starter, called by MagAOXApp::threadStart on thread construction. Calls smThreadExec.
[in] | s | a pointer to a shmimMonitor instance (normally this) |
Definition at line 455 of file shmimMonitor.hpp.
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.
Definition at line 769 of file shmimMonitor.hpp.
|
protected |
The ImageStreamIO type code.
Definition at line 101 of file shmimMonitor.hpp.
|
protected |
The depth of the circular buffer in the stream.
Definition at line 99 of file shmimMonitor.hpp.
|
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 93 of file shmimMonitor.hpp.
|
protected |
The height of the images in the stream.
Definition at line 98 of file shmimMonitor.hpp.
|
protected |
The ImageStreamIO shared memory buffer.
Definition at line 104 of file shmimMonitor.hpp.
|
protected |
Property used to report the current frame size.
Definition at line 230 of file shmimMonitor.hpp.
|
protected |
Property used to report the shmim buffer name.
Definition at line 228 of file shmimMonitor.hpp.
|
protected |
The inode of the image stream file.
Definition at line 106 of file shmimMonitor.hpp.
|
protected |
Flag indicating tha the shared memory should be reinitialized.
Definition at line 175 of file shmimMonitor.hpp.
|
staticprotected |
Static pointer to this (set in constructor). Used for getting out of the static SIGSEGV handler.
Definition at line 177 of file shmimMonitor.hpp.
|
protected |
The image structure semaphore index.
Definition at line 95 of file shmimMonitor.hpp.
|
protected |
The name of the shared memory image, is used in /tmp/<shmimName>.im.shm
. Derived classes should set a default.
Definition at line 85 of file shmimMonitor.hpp.
|
protected |
The cpuset to assign the shmimMonitor thread to. Ignored if empty (the default).
Definition at line 89 of file shmimMonitor.hpp.
|
protected |
A separate thread for the actual monitoring.
Definition at line 208 of file shmimMonitor.hpp.
|
protected |
The s.m. thread PID.
Definition at line 204 of file shmimMonitor.hpp.
|
protected |
Synchronizer for thread startup, to allow priority setting to finish.
Definition at line 202 of file shmimMonitor.hpp.
|
protected |
Priority of the shmimMonitor thread, should normally be > 00.
Definition at line 87 of file shmimMonitor.hpp.
|
protected |
The property to hold the s.m. thread details.
Definition at line 206 of file shmimMonitor.hpp.
|
protected |
The size of the type, in bytes. Result of sizeof.
Definition at line 102 of file shmimMonitor.hpp.
|
protected |
The width of the images in the stream.
Definition at line 97 of file shmimMonitor.hpp.