The VisAO Camera
VisAOSimpleMotorCtrl.h
Go to the documentation of this file.
1 /************************************************************
2 * VisAOSimpleMotorCtrl.h
3 *
4 * Author: Jared R. Males (jrmales@email.arizona.edu)
5 *
6 * Declarations for the VisAOSimpleMotorCtrl class, which adapts
7 * the SimpleMotorCtrl class for use as a VisAO App.
8 *
9 * Developed as part of the Magellan Adaptive Optics system.
10 ************************************************************/
11 
12 /** \file VisAOSimpleMotorCtrl.h
13  * \author Jared R. Males
14  * \brief Declarations for the VisAOSimpleMotorCtrl class.
15  *
16 */
17 
18 #ifndef __VisAOSimpleMotorCtrl_h__
19 #define __VisAOSimpleMotorCtrl_h__
20 
21 #include "SimpleMotorCtrl.h"
22 #include "VisAOFilterWheel.h"
23 
24 #include "VisAOApp_base.h"
25 
26 #include <cmath>
27 
28 
29 namespace VisAO
30 {
31 
32 /// A class to provide VisAO functionality to the adopt motor controller.
33 /** Uses the control logic unchanged from SimpleMotorCtrl, and adds the
34  * VisAOApp_base command fifos for local and script control using a signal thread.
35  * No remote fifo is provided, as remote control is via the RTDB. Intercepts
36  * the PosReqChanged notification to test if in remote control, and provides
37  * the facility for changing control mode from RTDB.
38 */
40 {
41  public:
42  ///Standard adopt style config file constructor.
43  VisAOSimpleMotorCtrl( std::string name, const std::string &conffile) throw (AOException);
44 
45  ///Standard adopt style command line constructor.
46  VisAOSimpleMotorCtrl( int argc, char **argv) throw (AOException);
47 
48  protected:
49  RTDBvar var_cmode_cur; ///<The current control mode in the RTDB.
50  RTDBvar var_cmode_req; ///<The requested control mode in the RTDB.
51 
52  double cur_pos;
53 
54  ///An iterator for accessing the custom pos list.
55  map<std::string, float>::iterator cpos_it;
56 
57  /// Custom filter types list
58  multimap<int, float> _customTypes;
59  ///An iterator for accessing the custom pos list.
60  multimap<int, float>::iterator ctype_it;
61 
62  /// Virtual function to setup variables in RTDB
63  void SetupVars();
64 
65  /// Overridden to test if this is a VisAOFilterWheel.
66  /** Handle notifications if it is. If not this behaves
67  * as a standard adopt SimpleMotorCtrl.
68  */
69  virtual SimpleMotor *CreateMotor();
70 
71  /// Update position variables in RTDB
72  virtual void updatePos( bool force=false);
73 
74  ///Get the position name from wheel position
75  std::string GetPosName(double pos);
76 
77  ///Get the position type from the wheel position
78  int GetType(double pos);
79 
80  public:
81  ///The current control mode.
82  /** Is static so it can be used by static RTDB handlers.
83  */
84  static int control_mode;
85 
86  ///The default control mode.
87  /** If not -1, then this mode is always returned to, instead of NONE.
88  */
90 
91  ///The control modes.
92  enum control_modes{CMODE_NONE, CMODE_REMOTE, CMODE_LOCAL, CMODE_SCRIPT, CMODE_AUTO, CMODE_max};
93 
94  virtual int request_control(int cmode); ///< Calls \ref request_control(int,bool) "request_control(cmode, 0)"
95 
96  ///Attempts to change the control type.
97  /** \param cmode The requested control mode \see control_modes.
98  * \param override If not true, forces the change no matter what current mode is.
99  * \retval control_mode if successful.
100  * \retval -1 if unsuccessful.
101  */
102  virtual int request_control(int cmode, bool override);
103 
104  public:
105  /// RTDB handler for a control mode change request from the AO Supervisor.
106  static int CModeReqChanged(void *pt, Variable *msgb);
107 
108  /// RTDB handler for a position change by the AO Supervisor
109  /** After checking if control_mode == CMODE_REMOTE, just calls
110  * SimpleMotorCtrl::PosReqChanged.
111  */
112  static int VisAO_PosReqChanged( void *pt, Variable *msgb);
113 
114  /// RTDB handler for a position change by the AO Supervisor
115  /** After checking if control_mode == CMODE_LOCAL, just calls
116  * SimpleMotorCtrl::PosReqChanged.
117  */
118  static int VisAO_PosLocalReqChanged( void *pt, Variable *msgb);
119 
120  /// RTDB handler for a position change by the AO Supervisor
121  /** After checking if control_mode == CMODE_SCRIPT, just calls
122  * SimpleMotorCtrl::PosReqChanged.
123  */
124  static int VisAO_PosScriptReqChanged( void *pt, Variable *msgb);
125 
126  /// Exposes the abort Position (_abortPos) for use in PosReqChanged (which is static)
127  double getAbortPos(){ return _abortPos;}
128 
129 };
130 
131 } //namespace VisAO
132 
133 #endif //__VisAOSimpleMotorCtrl_h__
134 
135 
map< std::string, float >::iterator cpos_it
An iterator for accessing the custom pos list.
multimap< int, float > _customTypes
Custom filter types list.
static int control_mode
The current control mode.
virtual SimpleMotor * CreateMotor()
Overridden to test if this is a VisAOFilterWheel.
double getAbortPos()
Exposes the abort Position (_abortPos) for use in PosReqChanged (which is static) ...
static int CModeReqChanged(void *pt, Variable *msgb)
RTDB handler for a control mode change request from the AO Supervisor.
virtual void updatePos(bool force=false)
Update position variables in RTDB.
static int VisAO_PosLocalReqChanged(void *pt, Variable *msgb)
RTDB handler for a position change by the AO Supervisor.
static int VisAO_PosReqChanged(void *pt, Variable *msgb)
RTDB handler for a position change by the AO Supervisor.
int GetType(double pos)
Get the position type from the wheel position.
static int VisAO_PosScriptReqChanged(void *pt, Variable *msgb)
RTDB handler for a position change by the AO Supervisor.
RTDBvar var_cmode_req
The requested control mode in the RTDB.
std::string GetPosName(double pos)
Get the position name from wheel position.
A class to provide VisAO functionality to the adopt motor controller.
Declarations for VisAOApp_base.
void SetupVars()
Virtual function to setup variables in RTDB.
VisAOSimpleMotorCtrl(std::string name, const std::string &conffile)
Standard adopt style config file constructor.
multimap< int, float >::iterator ctype_it
An iterator for accessing the custom pos list.
virtual int request_control(int cmode)
Calls request_control(cmode, 0).
The namespace of VisAO software.
RTDBvar var_cmode_cur
The current control mode in the RTDB.
static int default_control_mode
The default control mode.