The VisAO Camera
WollastonStatus.h
Go to the documentation of this file.
1 /************************************************************
2 * WollastonStatus.h
3 *
4 * Author: Jared R. Males (jrmales@email.arizona.edu)
5 *
6 * Declarations for the VisAO wollaston lift status maintainer.
7 *
8 * Developed as part of the Magellan Adaptive Optics system.
9 ************************************************************/
10 
11 /** \file WollastonStatus.h
12  * \author Jared R. Males
13  * \brief Declarations for the VisAO wollaston lift status maintainer.
14  *
15 */
16 
17 #ifndef __WollastonStatus_h__
18 #define __WollastonStatus_h__
19 
20 #include "VisAOApp_standalone.h"
21 #include "libvisao.h"
22 
23 #include "AOStates.h"
24 
25 namespace VisAO
26 {
27 
28 /// The wollaston lift status maintainer.
29 /** Tracks the status of the wollaston lift.
30  *
31 */
33 {
34 public:
35  /// Standard constructor with a config file.
36  WollastonStatus( std::string name, const std::string& conffile) throw (AOException);
37 
38  /// Standard constructor with a command line.
39  WollastonStatus( int argc, char**argv) throw (AOException);
40 
41  /// Initialization common to both constructors.
42  /** Reads the app specific config detals, and sets up the fifo_list and connects it.
43  * Upon exit, SIGIO is blocked.
44  */
45  void initApp();
46 
47 protected:
48  int cur_pos; ///<The current position of the lift, -1 is down, 0 is intermediate, 1 is up.
49 
51  int last_type;
52  int prompt;
53  int ignored;
54 
55 public:
56  ///Set the value of cur_pos of the motor.
57  /** Does not move the motor.
58  * \param cp the current position.
59  * \retval 0 on success
60  * \retval -1 on failure.
61  */
62  int set_cur_pos(int cp);
63 
64  ///Get the current positon of the motor.
65  /** \retval the value of cur_pos.
66  */
67  int get_cur_pos(){return cur_pos;}
68 
69  /// The main loop.
70  /** Sets the signal handling for SIGIO then
71  * starts pausing()-ing.
72  */
73  virtual int Run();
74 
75  /// Overridden from VisAOApp_base::remote_command, here just calls common_command.
76  virtual std::string remote_command(std::string com);
77  /// Overridden from VisAOApp_base::local_command, here just calls common_command.
78  virtual std::string local_command(std::string com);
79 
80  /// The common command processor for commands received by fifo.
81  /** The return value depends on the command received. Recognized commands are:
82  * - POS? the return value is the current position, 1 for up, 0 for intermediate, -1 for down.
83  * - STATE? returns the result of get_state_str()
84  * - UP if control_mode allows it, and lift is not up, raises the lift, and returns "1\n". If lift is already up, returns "0\n". Otherwise returns
85  * the control_mode in 1 letter.
86  * - DOWN if control_mode allows it, and lift is not down, lowers the lift, and returns "1\n". If lift is already up, returns "0\n". Otherwise
87  * returns the control_mode in 1 letter.
88  * - For any other inputs returns "UNKNOWN COMMAND: (str)\n"
89  */
90  std::string common_command(std::string com, int cmode);
91 
92  /// Get the state string.
93  /** The state string encodes the current state of the controller as:
94  * C P
95  * Where C is the current control_mode, P is the current position
96  * \returns the state string
97  */
98  std::string get_state_str();
99 
100  virtual int update_statusboard();
101 
102 };
103 
104 } //namespace VisAO
105 #endif //__WollastonStatus_h__
106 
The wollaston lift status maintainer.
int get_cur_pos()
Get the current positon of the motor.
virtual std::string remote_command(std::string com)
Overridden from VisAOApp_base::remote_command, here just calls common_command.
virtual int update_statusboard()
Update the status board.
The standalone VisAO application, does not interface with the AO Supervisor.
Declarations for the standalone VisAO application.
int set_cur_pos(int cp)
Set the value of cur_pos of the motor.
WollastonStatus(std::string name, const std::string &conffile)
Standard constructor with a config file.
VisAO software utilitites, declarations.
virtual std::string local_command(std::string com)
Overridden from VisAOApp_base::local_command, here just calls common_command.
int cur_pos
The current position of the lift, -1 is down, 0 is intermediate, 1 is up.
std::string get_state_str()
Get the state string.
virtual int Run()
The main loop.
std::string common_command(std::string com, int cmode)
The common command processor for commands received by fifo.
The namespace of VisAO software.
void initApp()
Initialization common to both constructors.