The VisAO Camera
ShutterControlDioclient.h
Go to the documentation of this file.
1 /************************************************************
2 * ShutterControlDioclient.h
3 *
4 * Author: Jared R. Males (jrmales@email.arizona.edu)
5 *
6 * Generic shutter controller as a client of the dioserver
7 *
8 * Developed as part of the Magellan Adaptive Optics system.
9 ************************************************************/
10 
11 /** \file ShutterControlDioclient.h
12  * \author Jared R. Males (jrmales@email.arizona.edu)
13  * \brief Declarations for the shutter controller as a client of the dioserver.
14  *
15 */
16 
17 #ifndef __ShutterControlDioclient_h__
18 #define __ShutterControlDioclient_h__
19 
20 #include "ShutterControl.h"
21 #include "libvisao.h"
22 #include "VisAOApp_standalone.h"
23 
24 #include "profileutils.h"
25 
26 #include <math.h>
27 #include <time.h>
28 #include <sys/time.h>
29 
30 namespace VisAO
31 {
32 
34 {
35 public:
36  ShutterControlDioclient(int argc, char **argv) throw (AOException);
37  ShutterControlDioclient(std::string name, const std::string &conffile) throw (AOException);
38 
40 
41 protected:
42  int dio_ch_set; ///<The dioserver channel used for setting shutter state (open or shut)
43  int dio_ch_get; ///<The dioserver channel used for getting shutter state (open or shut)
44  std::string diofifo_path; ///<The base path of the dioserver fifos
45 
46  int initialize_ShutterControl() throw (AOException);
47 
48  int DO_OPENSHUT;
49  char * glob_seqmsg;
50 
51  int power_outlet; ///<Configuration variable, setting which power outlet to monitor
52  int *powerOutlet; ///<The power strip outlet controlling shutter power.
53 
54  power_status_board * psb;
55 
56  int getPowerStatus();
57 
58  sharedim_stack<char> sis; ///< The shared memory ring buffer for timestamp storage
59  sharedim<char> * sim; ///< Pointer to a shared memory "image"
60 
61  int shmem_key; ///< The key for the ring buffer shared memory
62  int num_timestamps; ///< The number of shared "images" available in the ring buffer
63 
64  int initSaveInterval;
65  uint64 cycleNo;
66 
67  //Data logger
68  pthread_t logger_th; ///<Thread which periodically logs data in the sharedim_stack data buffer
69  double logger_pause; ///<Pause time of the logger thread, seconds
70  double data_log_time_length; ///<Time duration of a shutter log file, seconds
71 
72  std::string save_path; ///<Path, relative to VISAO_ROOT, where to save data.
73 
74  ///Generate a unique data file name, using the standard VisAO timestamp.
75  std::string getDataFileName();
76 
77 public:
78  virtual int Run();
79  //Virtual functions, to be overridden by derived classes specific to shutter and controller
80  virtual int start_ShutterControl();
81  virtual int shutdown_ShutterControl();
82 
83  virtual int get_hw_state();
84  std::string get_state_str();
85 
86 protected:
87  ///Send shutter open signal for initialization, but do not log or profile this.
88  /** The shutter will almost always be open (it fails open, etc.), this is just a check.
89  * so we don't want to count the cycle.
90  */
91  int init_shutter_open();
92  virtual int do_shutter_open(void *adata);
93  virtual int do_shutter_close(void *adata);
94 
95  ///Save the initialization data to disk
96  int saveInit();
97 
98  ///Launches the data logger thread
99  /** Sets to priority 0.
100  * \retval x is the return value of pthread_create
101  */
102  int launchDataLogger();
103 
104 public:
105  ///Log data at intervals
106  void dataLogger();
107 
108 
109  std::string remote_command(std::string com, char * seqmsg = 0);
110  std::string local_command(std::string com, char *seqmsg = 0);
111  std::string script_command(std::string com, char * seqmsg = 0);
112  std::string auto_command(std::string com, char * seqmsg);
113  std::string common_command(std::string com, int calling_ctype);
114 
115  virtual int update_statusboard();
116 
117 
118 };
119 
120 ///Launches the data logger
121 /** \param Sctrl is a ShutterControlDioclient
122  */
123 void * __launch_data_logger(void * Sctrl);
124 
125 void shutter_auto_handler(int signum, siginfo_t *siginf, void *ucont);
126 
127 } //namespace VisAO
128 
129 #endif // __ShutterControlDioclient_h__
int launchDataLogger()
Launches the data logger thread.
int dio_ch_set
The dioserver channel used for setting shutter state (open or shut)
Declarations for a generic shutter controller.
double data_log_time_length
Time duration of a shutter log file, seconds.
std::string diofifo_path
The base path of the dioserver fifos.
int power_outlet
Configuration variable, setting which power outlet to monitor.
int num_timestamps
The number of shared "images" available in the ring buffer.
int shmem_key
The key for the ring buffer shared memory.
STL namespace.
The standalone VisAO application, does not interface with the AO Supervisor.
int dio_ch_get
The dioserver channel used for getting shutter state (open or shut)
virtual int update_statusboard()
Update the status board.
Class to manage a stack of images in shared memory.
Declarations for the standalone VisAO application.
int init_shutter_open()
Send shutter open signal for initialization, but do not log or profile this.
int * powerOutlet
The power strip outlet controlling shutter power.
sharedim_stack< char > sis
The shared memory ring buffer for timestamp storage.
VisAO software utilitites, declarations.
pthread_t logger_th
Thread which periodically logs data in the sharedim_stack data buffer.
sharedim< char > * sim
Pointer to a shared memory "image".
virtual int Run()
The application main loop, to be re-implemented in derived classes.
std::string auto_command(std::string com, char *seqmsg)
Processing for auto commands - to be overriden.
std::string getDataFileName()
Generate a unique data file name, using the standard VisAO timestamp.
void * __launch_data_logger(void *Sctrl)
Launches the data logger.
std::string save_path
Path, relative to VISAO_ROOT, where to save data.
Convenience structure for an image.
void dataLogger()
Log data at intervals.
The namespace of VisAO software.
double logger_pause
Pause time of the logger thread, seconds.
int saveInit()
Save the initialization data to disk.