The VisAO Camera
ShutterRemoteControl.h
Go to the documentation of this file.
1 /************************************************************
2 * ShutterRemoteControl.h
3 *
4 * Author: Jared R. Males (jrmales@email.arizona.edu)
5 *
6 * Shutter control from the AO Supervisor.
7 *
8 * Developed as part of the Magellan Adaptive Optics system.
9 ************************************************************/
10 
11 /** \file ShutterRemoteControl.h
12  * \author Jared R. Males
13  * \brief Declarations for shutter control from the AO Supervisor.
14  *
15 */
16 
17 #ifndef __ShutterRemoteControl_h__
18 #define __ShutterRemoteControl_h__
19 
20 #include "AOApp.h"
21 #include "AOStates.h"
22 
23 #include "VisAOApp_base.h"
24 
25 extern "C"
26 {
27 #include <stdio.h>
28 #include <sys/types.h>
29 #include <unistd.h>
30 #include <stdlib.h> // atof()
31 #include <math.h> // fabs()
32 #include <string.h>
33 #include <stdarg.h>
34 #include <errno.h>
35 
36 #include <pthread.h>
37 }
38 
39 #include "RTDBvar.h"
40 
41 #define DEFAULT_WAIT_TO 0.01
42 #define DEFAULT_WAIT_SLEEP 0.0001
43 
44 namespace VisAO
45 {
46 
47 ///Class to provide remote control (via the AO system) of the Shutter.
49 {
50  public:
51  ShutterRemoteControl(std::string name, const std::string &conffile) throw(AOException);
52  ShutterRemoteControl( int argc, char **argv) throw(AOException);
53 
54  static int StateReqChanged(void *pt, Variable *msgb);
55  static int CModeReqChanged(void *pt, Variable *msgb);
56  int send_shutter_command(const char * com);
57  int parse_state_string(std::string ansstr);
58 
59  protected:
60  void Create(void) throw (AOException);
61  void updateState(bool force = false);
62 
63  std::string fifo_path;
64  double wait_to; //timeout for waiting for shutter response
65  double wait_sleep; //time to sleep waiting for shutter response
66 
67  protected:
68  int LoadConfig();
69 
70  // VIRTUAL - Setup variables in RTDB
71  void SetupVars();
72 
73  // VIRTUAL - Run
74  void Run();
75 
76  const char *errmsg;
77  int ERRMSG_LEN;
78 
79  virtual int TestNetwork(void);
80 
81  protected:
82 
83  // HANDLERS
84 
85 
86  // Internal state
87 
88  int _shutter_state;
89  int _shutter_sw_state;
90  int _shutter_hw_state;
91  int _shutter_cmode;
92 
93  RTDBvar var_state_cur, var_state_req, var_sw_state, var_hw_state;
94  RTDBvar var_cmode_cur, var_cmode_req;
95 
96  pthread_mutex_t mutex; // Mutex to lock communication
97 
98  int DoFSM();
99 
100 
101 };
102 
103 } //namespace VisAO
104 
105 #endif //__ShutterRemoteControl_h__
The base class for VisAO applications.
Definition: VisAOApp_base.h:48
Class to provide remote control (via the AO system) of the Shutter.
Declarations for VisAOApp_base.
The namespace of VisAO software.