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

MagAO-X Uniblitz DSS Shutter interface. More...

#include <dssShutter.hpp>

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

Public Member Functions

 dssShutter ()
 Default c'tor. More...
 
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 ()
 application logic More...
 
int appShutdown ()
 applogic shutdown More...
 
int onPowerOff ()
 Actions on power off. More...
 
int whilePowerOff ()
 Actions while powered off. More...
 
int setShutterState (int sh)
 Change shutter state. More...
 
int open ()
 Open the shutter. More...
 
int shut ()
 Shut the shutter. More...
 

Protected Attributes

int m_powerState {-1}
 The current power state, -1 is unknown, 0 is off, 1 is on. More...
 
int m_sensorState {-1}
 The current sensor state, -1 is unknown, 0 is shut, 1 is open. More...
 
int m_triggerState {-1}
 The current trigger state. -1 is unknown, 0 is low, 1 is high. More...
 
Configurable Parameters
std::string m_powerDevice
 The device controlling this shutter's power. More...
 
std::string m_powerChannel
 The channel controlling this shutter's power. More...
 
std::string m_dioDevice
 The device controlling this shutter's digital I/O. More...
 
std::string m_sensorChannel
 The channel reading this shutter's sensor. More...
 
std::string m_triggerChannel
 The channel sending this shutter's trigger. More...
 
unsigned m_shutterWait {100}
 The time to pause between checks of the sensor state during open/shut [msec]. Default is 100. More...
 
unsigned m_shutterTimeout {2000}
 Total time to wait for sensor to change state before timing out [msec]. Default is 2000. More...
 

Private Member Functions

derivedT & derived ()
 Access the derived class. More...
 

Open/Shut Threads

Separate threads are used since we need INDI updates while trying to open/shut. These threads sleep(1), unless interrupted by a signal. When signaled, they check for the m_doOpen or m_doShut flag, and if true the appropriate open() or shut() function is called. If not, they go back to sleep unless m_shutdown is true.

bool m_doOpen {false}
 Flag telling the open thread that it should actually open the shutter, not just go back to sleep. More...
 
bool m_openThreadInit {true}
 Initialization flag for the open thread. More...
 
pid_t m_openThreadID {0}
 Open thread PID. More...
 
pcf::IndiProperty m_openThreadProp
 The property to hold the open thread details. More...
 
std::thread m_openThread
 The opening thread. More...
 
bool m_doShut {false}
 Flag telling the shut thread that it should actually shut the shutter, not just go back to sleep. More...
 
bool m_shutThreadInit {true}
 Initialization flag for the shut thread. More...
 
pid_t m_shutThreadID {0}
 Shut thread PID. More...
 
pcf::IndiProperty m_shutThreadProp
 The property to hold the shut thread details. More...
 
std::thread m_shutThread
 The shutting thread. More...
 
static void openThreadStart (dssShutter *d)
 Open thread starter function. More...
 
static void shutThreadStart (dssShutter *d)
 Shut thread starter function. More...
 
void openThreadExec ()
 Open thread function. More...
 
void shutThreadExec ()
 Shut thread function. More...
 

INDI

pcf::IndiProperty m_indiP_powerChannel
 Property used to monitor the shutter's power state. More...
 
pcf::IndiProperty m_indiP_sensorChannel
 Property used to monitor the shutter's hall sensor. More...
 
pcf::IndiProperty m_indiP_triggerChannel
 Property used to monitor and set the shutter's trigger. More...
 
int setCallBack_powerChannel (const pcf::IndiProperty &ipRecv)
 The callback called by the static version, to actually process the new request. More...
 
int setCallBack_sensorChannel (const pcf::IndiProperty &ipRecv)
 The callback called by the static version, to actually process the new request. More...
 
int setCallBack_triggerChannel (const pcf::IndiProperty &ipRecv)
 The callback called by the static version, to actually process the new request. More...
 
static int st_setCallBack_powerChannel (void *app, const pcf::IndiProperty &ipRecv)
 The static callback function to be registered for shutter power channel changes. More...
 
static int st_setCallBack_sensorChannel (void *app, const pcf::IndiProperty &ipRecv)
 The static callback function to be registered for shutter sensor channel changes. More...
 
static int st_setCallBack_triggerChannel (void *app, const pcf::IndiProperty &ipRecv)
 The static callback function to be registered for shutter trigger channel changes. More...
 

Detailed Description

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

MagAO-X Uniblitz DSS Shutter interface.

This is actually an interface to the digital I/O system, which controls the shutter.

The derived class derivedT must be a MagAOXApp<true>, and should declare this class a friend like so:

friend class dev::dssShutter<derivedT>;

Calls to this class's setupConfig, loadConfig, appStartup, appLogic, appShutdown onPowerOff, whilePowerOff, functions must be placed in the derived class's functions of the same name.

Definition at line 36 of file dssShutter.hpp.

Constructor & Destructor Documentation

◆ dssShutter()

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

Default c'tor.

Sets derived().m_hasShutter to true.

Definition at line 299 of file dssShutter.hpp.

Member Function Documentation

◆ appLogic()

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

application logic

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 403 of file dssShutter.hpp.

◆ appShutdown()

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

applogic shutdown

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 437 of file dssShutter.hpp.

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

◆ appStartup()

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

Startup function.

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 335 of file dssShutter.hpp.

◆ derived()

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

Access the derived class.

Definition at line 292 of file dssShutter.hpp.

◆ loadConfig()

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

load the configuration system results

This should be called in derivedT::loadConfig as

void loadConfig(mx::app::appConfigurator &config)
load the configuration system results
Definition: dssShutter.hpp:322

with appropriate error checking.

Parameters
[in]configthe derived classes configurator

Definition at line 322 of file dssShutter.hpp.

Referenced by MagAOX::app::ocam2KCtrl::loadConfig(), and MagAOX::app::picamCtrl::loadConfig().

◆ onPowerOff()

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

Actions on power off.

This should be called in derivedT::appPowerOff as

dssShutter<derivedT>::appPowerOff();

with appropriate error checking.

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

Definition at line 474 of file dssShutter.hpp.

◆ open()

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::open

Open the shutter.

Do not lock the mutex before calling this.

Returns
0 on success
-1 on error
Todo:
need shutter log types

Definition at line 513 of file dssShutter.hpp.

◆ openThreadExec()

template<class derivedT >
void MagAOX::app::dev::dssShutter< derivedT >::openThreadExec
protected

Open thread function.

Runs until m_shutdown is true.

Definition at line 646 of file dssShutter.hpp.

Referenced by MagAOX::app::dev::dssShutter< derivedT >::openThreadStart().

◆ openThreadStart()

template<class derivedT >
void MagAOX::app::dev::dssShutter< derivedT >::openThreadStart ( dssShutter< derivedT > *  d)
staticprotected

Open thread starter function.

Parameters
[in]dpointer to this

Definition at line 640 of file dssShutter.hpp.

◆ setCallBack_powerChannel()

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::setCallBack_powerChannel ( const pcf::IndiProperty &  ipRecv)

The callback called by the static version, to actually process the new request.

Returns
0 on success.
-1 on error.
Parameters
[in]ipRecvthe INDI property sent with the the new property request.

Definition at line 715 of file dssShutter.hpp.

◆ setCallBack_sensorChannel()

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::setCallBack_sensorChannel ( const pcf::IndiProperty &  ipRecv)

The callback called by the static version, to actually process the new request.

Returns
0 on success.
-1 on error.
Parameters
[in]ipRecvthe INDI property sent with the the new property request.

Definition at line 752 of file dssShutter.hpp.

◆ setCallBack_triggerChannel()

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::setCallBack_triggerChannel ( const pcf::IndiProperty &  ipRecv)

The callback called by the static version, to actually process the new request.

Returns
0 on success.
-1 on error.
Parameters
[in]ipRecvthe INDI property sent with the the new property request.

Definition at line 789 of file dssShutter.hpp.

◆ setShutterState()

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::setShutterState ( int  sh)

Change shutter state.

Sets m_doOpen or m_doShut and signals the appropriate thread.

Returns
0 on success
-1 on error
Parameters
shDesired shutter state. 0 for shut,1 for open

Definition at line 486 of file dssShutter.hpp.

◆ setupConfig()

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

Setup the configuration system.

This should be called in derivedT::setupConfig as

void setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
Definition: dssShutter.hpp:304

with appropriate error checking.

Parameters
[out]configthe derived classes configurator

Definition at line 304 of file dssShutter.hpp.

Referenced by MagAOX::app::ocam2KCtrl::setupConfig(), and MagAOX::app::picamCtrl::setupConfig().

◆ shut()

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::shut

Shut the shutter.

Do not lock the mutex before calling this.

Returns
0 on success
-1 on error
Todo:
need shutter log types
Todo:
need shutter log types

Definition at line 575 of file dssShutter.hpp.

◆ shutThreadExec()

template<class derivedT >
void MagAOX::app::dev::dssShutter< derivedT >::shutThreadExec
protected

Shut thread function.

Runs until m_shutdown is true.

Definition at line 680 of file dssShutter.hpp.

Referenced by MagAOX::app::dev::dssShutter< derivedT >::shutThreadStart().

◆ shutThreadStart()

template<class derivedT >
void MagAOX::app::dev::dssShutter< derivedT >::shutThreadStart ( dssShutter< derivedT > *  d)
staticprotected

Shut thread starter function.

Parameters
[in]dpointer to this

Definition at line 674 of file dssShutter.hpp.

◆ st_setCallBack_powerChannel()

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::st_setCallBack_powerChannel ( void *  app,
const pcf::IndiProperty &  ipRecv 
)
static

The static callback function to be registered for shutter power channel changes.

Returns
0 on success.
-1 on error.
Parameters
[in]appa pointer to this, will be static_cast-ed to derivedT.
[in]ipRecvthe INDI property sent with the the new property request.

Definition at line 707 of file dssShutter.hpp.

◆ st_setCallBack_sensorChannel()

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::st_setCallBack_sensorChannel ( void *  app,
const pcf::IndiProperty &  ipRecv 
)
static

The static callback function to be registered for shutter sensor channel changes.

Returns
0 on success.
-1 on error.
Parameters
[in]appa pointer to this, will be static_cast-ed to derivedT.
[in]ipRecvthe INDI property sent with the the new property request.

Definition at line 744 of file dssShutter.hpp.

◆ st_setCallBack_triggerChannel()

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::st_setCallBack_triggerChannel ( void *  app,
const pcf::IndiProperty &  ipRecv 
)
static

The static callback function to be registered for shutter trigger channel changes.

Returns
0 on success.
-1 on error.
Parameters
[in]appa pointer to this, will be static_cast-ed to derivedT.
[in]ipRecvthe INDI property sent with the the new property request.

Definition at line 781 of file dssShutter.hpp.

◆ whilePowerOff()

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::whilePowerOff

Actions while powered off.

This should be called in derivedT::whilePowerOff as

with appropriate error checking.

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

Definition at line 480 of file dssShutter.hpp.

Member Data Documentation

◆ m_dioDevice

template<class derivedT >
std::string MagAOX::app::dev::dssShutter< derivedT >::m_dioDevice
protected

The device controlling this shutter's digital I/O.

Definition at line 47 of file dssShutter.hpp.

◆ m_doOpen

template<class derivedT >
bool MagAOX::app::dev::dssShutter< derivedT >::m_doOpen {false}
protected

Flag telling the open thread that it should actually open the shutter, not just go back to sleep.

Definition at line 186 of file dssShutter.hpp.

◆ m_doShut

template<class derivedT >
bool MagAOX::app::dev::dssShutter< derivedT >::m_doShut {false}
protected

Flag telling the shut thread that it should actually shut the shutter, not just go back to sleep.

Definition at line 204 of file dssShutter.hpp.

◆ m_indiP_powerChannel

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::dssShutter< derivedT >::m_indiP_powerChannel
protected

Property used to monitor the shutter's power state.

Definition at line 231 of file dssShutter.hpp.

◆ m_indiP_sensorChannel

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::dssShutter< derivedT >::m_indiP_sensorChannel
protected

Property used to monitor the shutter's hall sensor.

Definition at line 232 of file dssShutter.hpp.

◆ m_indiP_triggerChannel

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::dssShutter< derivedT >::m_indiP_triggerChannel
protected

Property used to monitor and set the shutter's trigger.

Definition at line 233 of file dssShutter.hpp.

◆ m_openThread

template<class derivedT >
std::thread MagAOX::app::dev::dssShutter< derivedT >::m_openThread
protected

The opening thread.

Definition at line 194 of file dssShutter.hpp.

◆ m_openThreadID

template<class derivedT >
pid_t MagAOX::app::dev::dssShutter< derivedT >::m_openThreadID {0}
protected

Open thread PID.

Definition at line 190 of file dssShutter.hpp.

◆ m_openThreadInit

template<class derivedT >
bool MagAOX::app::dev::dssShutter< derivedT >::m_openThreadInit {true}
protected

Initialization flag for the open thread.

Definition at line 188 of file dssShutter.hpp.

◆ m_openThreadProp

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::dssShutter< derivedT >::m_openThreadProp
protected

The property to hold the open thread details.

Definition at line 192 of file dssShutter.hpp.

◆ m_powerChannel

template<class derivedT >
std::string MagAOX::app::dev::dssShutter< derivedT >::m_powerChannel
protected

The channel controlling this shutter's power.

Definition at line 45 of file dssShutter.hpp.

◆ m_powerDevice

template<class derivedT >
std::string MagAOX::app::dev::dssShutter< derivedT >::m_powerDevice
protected

The device controlling this shutter's power.

Definition at line 44 of file dssShutter.hpp.

◆ m_powerState

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::m_powerState {-1}
protected

The current power state, -1 is unknown, 0 is off, 1 is on.

Definition at line 56 of file dssShutter.hpp.

◆ m_sensorChannel

template<class derivedT >
std::string MagAOX::app::dev::dssShutter< derivedT >::m_sensorChannel
protected

The channel reading this shutter's sensor.

Definition at line 48 of file dssShutter.hpp.

◆ m_sensorState

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::m_sensorState {-1}
protected

The current sensor state, -1 is unknown, 0 is shut, 1 is open.

Definition at line 58 of file dssShutter.hpp.

◆ m_shutterTimeout

template<class derivedT >
unsigned MagAOX::app::dev::dssShutter< derivedT >::m_shutterTimeout {2000}
protected

Total time to wait for sensor to change state before timing out [msec]. Default is 2000.

Definition at line 53 of file dssShutter.hpp.

◆ m_shutterWait

template<class derivedT >
unsigned MagAOX::app::dev::dssShutter< derivedT >::m_shutterWait {100}
protected

The time to pause between checks of the sensor state during open/shut [msec]. Default is 100.

Definition at line 51 of file dssShutter.hpp.

◆ m_shutThread

template<class derivedT >
std::thread MagAOX::app::dev::dssShutter< derivedT >::m_shutThread
protected

The shutting thread.

Definition at line 212 of file dssShutter.hpp.

◆ m_shutThreadID

template<class derivedT >
pid_t MagAOX::app::dev::dssShutter< derivedT >::m_shutThreadID {0}
protected

Shut thread PID.

Definition at line 208 of file dssShutter.hpp.

◆ m_shutThreadInit

template<class derivedT >
bool MagAOX::app::dev::dssShutter< derivedT >::m_shutThreadInit {true}
protected

Initialization flag for the shut thread.

Definition at line 206 of file dssShutter.hpp.

◆ m_shutThreadProp

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::dssShutter< derivedT >::m_shutThreadProp
protected

The property to hold the shut thread details.

Definition at line 210 of file dssShutter.hpp.

◆ m_triggerChannel

template<class derivedT >
std::string MagAOX::app::dev::dssShutter< derivedT >::m_triggerChannel
protected

The channel sending this shutter's trigger.

Definition at line 49 of file dssShutter.hpp.

◆ m_triggerState

template<class derivedT >
int MagAOX::app::dev::dssShutter< derivedT >::m_triggerState {-1}
protected

The current trigger state. -1 is unknown, 0 is low, 1 is high.

Definition at line 60 of file dssShutter.hpp.


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