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

MagAO-X standard motion stage interface. More...

#include <stdMotionStage.hpp>

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

Public Member Functions

 ~stdMotionStage () noexcept
 Destructor. More...
 
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 ()
 Application logic. More...
 
int onPowerOff ()
 Actions on power off. More...
 
int whilePowerOff ()
 Actions while powered off. More...
 
int appShutdown ()
 Application the shutdown. More...
 
Telemeter Interface
int recordStage (bool force=false)
 

Protected Attributes

std::string m_presetNotation {"preset"}
 Notation used to refer to a preset, should be singular, as in "preset" or "filter". More...
 
bool m_fractionalPresets {true}
 Flag to set in constructor determining if fractional presets are allowed. Used for INDI/GUIs. More...
 
bool m_defaultPositions {true}
 Flag controlling whether the default preset positions (the vector index) are set in loadConfig. More...
 
int8_t m_moving {0}
 Whether or not the stage is moving. -2 means powered off, -1 means not homed, 0 means not moving, 1 means moving, 2 means homing.
More...
 
int8_t m_movingState {0}
 Used to track the type of command. If > 1 this is a command to move to a preset. If 0 then it is a move to an arbitrary position. More...
 
double m_preset {0}
 The current numerical preset position [1.0 is index 0 in the preset name vector]. More...
 
double m_preset_target {0}
 The target numerical preset position [1.0 is index 0 in the preset name vector]. More...
 
Configurable Parameters
bool m_powerOnHome {false}
 If true, then the motor is homed at startup (by this software or actual power on) More...
 
int m_homePreset {-1}
 If >=0, this preset position is moved to after homing. More...
 
std::vector< std::string > m_presetNames
 The names of each position on the stage. More...
 
std::vector< double > m_presetPositions
 The positions, in arbitrary units, of each preset. If 0, then the integer position number (starting from 1) is used to calculate. More...
 

Private Member Functions

derivedT & derived ()
 

INDI

pcf::IndiProperty m_indiP_preset
 The position of the stage in presets. More...
 
pcf::IndiProperty m_indiP_presetName
 The name of the nearest preset for this position. More...
 
pcf::IndiProperty m_indiP_home
 Command the stage to home. . More...
 
pcf::IndiProperty m_indiP_stop
 Command the stage to halt. More...
 
int newCallBack_m_indiP_preset (const pcf::IndiProperty &ipRecv)
 Callback to process a NEW preset position request. More...
 
int newCallBack_m_indiP_presetName (const pcf::IndiProperty &ipRecv)
 Callback to process a NEW preset name request. More...
 
int newCallBack_m_indiP_home (const pcf::IndiProperty &ipRecv)
 Callback to process a NEW home request switch toggle. More...
 
int newCallBack_m_indiP_stop (const pcf::IndiProperty &ipRecv)
 Callback to process a NEW stop request switch toggle. More...
 
int updateINDI ()
 Update the INDI properties for this device controller. More...
 
static int st_newCallBack_stdMotionStage (void *app, const pcf::IndiProperty &ipRecv)
 The static callback function to be registered for stdMotionStage properties. More...
 

Detailed Description

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

MagAO-X standard motion stage interface.

Implements the standard interface to a MagAO-X motion stage. This includes the mcbl filter wheels, the zaber stages.

The required interface to be implemented in derivedT is

int stop(); //Note that the INDI mutex will not be locked on this call
int startHoming(); //INDI mutex will be locked on this call.
double presetNumber();
int moveTo(double); //INDI mutex will be locked on this call.

In addition the derived class is responsible for setting m_moving and m_preset. m_preset_target should also be set if the wheel is moved via a low-level position command.

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

friend class dev::stdMotionStage<derivedT>;

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

Definition at line 53 of file stdMotionStage.hpp.

Constructor & Destructor Documentation

◆ ~stdMotionStage()

template<class derivedT >
MagAOX::app::dev::stdMotionStage< derivedT >::~stdMotionStage
noexcept

Destructor.

Definition at line 263 of file stdMotionStage.hpp.

Member Function Documentation

◆ appLogic()

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

Application logic.

Checks the stdMotionStage thread

This should be called from the derived's appLogic() as in

with appropriate error checking.

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

Definition at line 368 of file stdMotionStage.hpp.

◆ appShutdown()

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

Application the shutdown.

Shuts down the stdMotionStage thread

with appropriate error checking.

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

Definition at line 395 of file stdMotionStage.hpp.

◆ appStartup()

template<class derivedT >
int MagAOX::app::dev::stdMotionStage< 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 312 of file stdMotionStage.hpp.

Referenced by MagAOX::app::filterWheelCtrl::appStartup(), MagAOX::app::smc100ccCtrl::appStartup(), and MagAOX::app::zaberCtrl::appStartup().

◆ derived()

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

Definition at line 256 of file stdMotionStage.hpp.

◆ loadConfig()

template<class derivedT >
int MagAOX::app::dev::stdMotionStage< derivedT >::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 286 of file stdMotionStage.hpp.

Referenced by MagAOX::app::filterWheelCtrl::loadConfig(), MagAOX::app::hsfwCtrl::loadConfig(), MagAOX::app::smc100ccCtrl::loadConfig(), and MagAOX::app::zaberCtrl::loadConfigImpl().

◆ newCallBack_m_indiP_home()

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

Callback to process a NEW home request switch toggle.

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

Definition at line 480 of file stdMotionStage.hpp.

◆ newCallBack_m_indiP_preset()

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

Callback to process a NEW preset position request.

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

Definition at line 418 of file stdMotionStage.hpp.

◆ newCallBack_m_indiP_presetName()

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

Callback to process a NEW preset name request.

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

Definition at line 439 of file stdMotionStage.hpp.

◆ newCallBack_m_indiP_stop()

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

Callback to process a NEW stop request switch toggle.

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

Definition at line 498 of file stdMotionStage.hpp.

◆ onPowerOff()

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

Actions on power off.

This should be called from the derived's onPowerOff() as in

with appropriate error checking.

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

Definition at line 375 of file stdMotionStage.hpp.

◆ recordStage()

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

◆ setupConfig()

template<class derivedT >
int MagAOX::app::dev::stdMotionStage< derivedT >::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 271 of file stdMotionStage.hpp.

Referenced by MagAOX::app::filterWheelCtrl::setupConfig(), MagAOX::app::hsfwCtrl::setupConfig(), MagAOX::app::smc100ccCtrl::setupConfig(), and MagAOX::app::zaberCtrl::setupConfig().

◆ st_newCallBack_stdMotionStage()

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

The static callback function to be registered for stdMotionStage properties.

Dispatches to the relevant handler

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 402 of file stdMotionStage.hpp.

◆ updateINDI()

template<class derivedT >
int MagAOX::app::dev::stdMotionStage< 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 522 of file stdMotionStage.hpp.

Referenced by MagAOX::app::hsfwCtrl::appLogic(), MagAOX::app::smc100ccCtrl::appLogic(), and MagAOX::app::zaberCtrl::appLogic().

◆ whilePowerOff()

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

Actions while powered off.

This should be called from the derived's whilePowerOff() as in

with appropriate error checking.

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

Definition at line 387 of file stdMotionStage.hpp.

Member Data Documentation

◆ m_defaultPositions

template<class derivedT >
bool MagAOX::app::dev::stdMotionStage< derivedT >::m_defaultPositions {true}
protected

Flag controlling whether the default preset positions (the vector index) are set in loadConfig.

Definition at line 75 of file stdMotionStage.hpp.

◆ m_fractionalPresets

template<class derivedT >
bool MagAOX::app::dev::stdMotionStage< derivedT >::m_fractionalPresets {true}
protected

Flag to set in constructor determining if fractional presets are allowed. Used for INDI/GUIs.

Definition at line 73 of file stdMotionStage.hpp.

◆ m_homePreset

template<class derivedT >
int MagAOX::app::dev::stdMotionStage< derivedT >::m_homePreset {-1}
protected

If >=0, this preset position is moved to after homing.

Definition at line 63 of file stdMotionStage.hpp.

◆ m_indiP_home

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::stdMotionStage< derivedT >::m_indiP_home
protected

Command the stage to home. .

Definition at line 191 of file stdMotionStage.hpp.

◆ m_indiP_preset

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::stdMotionStage< derivedT >::m_indiP_preset
protected

The position of the stage in presets.

Definition at line 185 of file stdMotionStage.hpp.

◆ m_indiP_presetName

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::stdMotionStage< derivedT >::m_indiP_presetName
protected

The name of the nearest preset for this position.

Definition at line 188 of file stdMotionStage.hpp.

◆ m_indiP_stop

template<class derivedT >
pcf::IndiProperty MagAOX::app::dev::stdMotionStage< derivedT >::m_indiP_stop
protected

Command the stage to halt.

Definition at line 194 of file stdMotionStage.hpp.

◆ m_moving

template<class derivedT >
int8_t MagAOX::app::dev::stdMotionStage< derivedT >::m_moving {0}
protected

Whether or not the stage is moving. -2 means powered off, -1 means not homed, 0 means not moving, 1 means moving, 2 means homing.

Definition at line 77 of file stdMotionStage.hpp.

◆ m_movingState

template<class derivedT >
int8_t MagAOX::app::dev::stdMotionStage< derivedT >::m_movingState {0}
protected

Used to track the type of command. If > 1 this is a command to move to a preset. If 0 then it is a move to an arbitrary position.

Definition at line 78 of file stdMotionStage.hpp.

◆ m_powerOnHome

template<class derivedT >
bool MagAOX::app::dev::stdMotionStage< derivedT >::m_powerOnHome {false}
protected

If true, then the motor is homed at startup (by this software or actual power on)

Definition at line 61 of file stdMotionStage.hpp.

◆ m_preset

template<class derivedT >
double MagAOX::app::dev::stdMotionStage< derivedT >::m_preset {0}
protected

The current numerical preset position [1.0 is index 0 in the preset name vector].

Definition at line 80 of file stdMotionStage.hpp.

◆ m_preset_target

template<class derivedT >
double MagAOX::app::dev::stdMotionStage< derivedT >::m_preset_target {0}
protected

The target numerical preset position [1.0 is index 0 in the preset name vector].

Definition at line 81 of file stdMotionStage.hpp.

◆ m_presetNames

template<class derivedT >
std::vector<std::string> MagAOX::app::dev::stdMotionStage< derivedT >::m_presetNames
protected

The names of each position on the stage.

Definition at line 65 of file stdMotionStage.hpp.

◆ m_presetNotation

template<class derivedT >
std::string MagAOX::app::dev::stdMotionStage< derivedT >::m_presetNotation {"preset"}
protected

Notation used to refer to a preset, should be singular, as in "preset" or "filter".

Definition at line 71 of file stdMotionStage.hpp.

◆ m_presetPositions

template<class derivedT >
std::vector<double> MagAOX::app::dev::stdMotionStage< derivedT >::m_presetPositions
protected

The positions, in arbitrary units, of each preset. If 0, then the integer position number (starting from 1) is used to calculate.

Definition at line 67 of file stdMotionStage.hpp.


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