The VisAO Camera
coronguide.h
Go to the documentation of this file.
1 /************************************************************
2 * coronguide.h
3 *
4 * Author: Jared R. Males (jrmales@email.arizona.edu)
5 *
6 * Declarations for a class to auto guide for the coronagraph
7 *
8 * Developed as part of the Magellan Adaptive Optics system.
9 ************************************************************/
10 
11 /** \file coronguide.h
12  * \author Jared R. Males
13  * \brief Declarations for a class to auto guide for the coronagraph
14  *
15  *
16 */
17 
18 #ifndef __coronguide_h__
19 #define __coronguide_h__
20 
21 #include "VisAOApp_standalone.h"
22 
23 #include "sharedim_stack.h"
24 
25 #include "statusboard.h"
26 
27 #include <cmath>
28 #include <algorithm>
29 
30 #include "improcessing.h"
31 
32 namespace VisAO
33 {
34 
35 #define MEDSUB 0
36 #define UNSHARP 1
37 
38 #define NOAVG -10000
39 
41 {
42 
43 public:
44  coronguide(int argc, char **argv) throw (AOException);
45  coronguide(std::string name, const std::string &conffile) throw (AOException);
46 
47  int Create();
48 
49 protected:
50 
51  sharedim_stack<short> * sis; ///< Manages a VisAO shared memory image stack.
52  sharedim_stack<short> * dark_sis;
53 
54  int shmem_key; ///<shared memory key for
55 
56  bool attached_to_shmem;
57 
58  sharedim<short> sim; ///<The sharedim structure retreived from the stack
59  sharedim<short> dark_sim;
60 
64  ccd47_status_board * ccdsb;
65  int sbconn;
66 
67  int attach_status_boards();
68  int write_frame();
69  int move_gimbal(double gx, double gy);
70 
71  size_t last_x0;
72  size_t last_x1;
73  size_t last_y0;
74  size_t last_y1;
75 
76  double xcen;
77  double ycen;
78  double xcen_avg;
79  double ycen_avg;
80 
81  //double min;
82  //double max;
83  //double mean;
84 
85  int bgAlgorithm;
86 
87  double * tempIm;
88  double * backgroundIm;
89  double * kernel;
90 
91  size_t kdim;
92 
93  double kfwhm;
94  int ksize; ///Size of the kernel, in units of kfwhm.
95 
96 
97  double tgtx;
98  double tgty;
99 
100  int loopState; //0==open, 1==closed, 2==paused, 3==auto pause, 4==auto pause recovery
101 
102  int close_loop();
103  int pause_loop();
104  int nod_loop();
105  int open_loop();
106 
107  double gimbscale;
108 
109  double ap_recov_time;
110 
111  double loop_gain;
112  int set_loop_gain(double lg);
113 
114  int set_bgalgo(int bga);
115  int set_kfwhm(double kfw);
116  int set_ksize(int ks);
117 
118  int avgLen;
119  int avgidx;
120  int inAvg;
121 
122  std::vector<double> xcens;
123  std::vector<double> ycens;
124 
125  bool useAvg;
126  bool minMaxReject;
127  int setUseAvg(bool ua);
128  int setMinMaxReject(bool mmr);
129 
130  int setAvgLen(int na);
131 
132  int gimbCounter;
133 
134 
135  pthread_mutex_t memmutex;
136 
137 public:
138 
139  int set_shmem_key(int sk);
140  int get_shmem_key(){return shmem_key;}
141  int connect_shmem();
142 
143  int set_sim(sharedim<short> s);
144  sharedim<short> get_sim(){return sim;}
145 
146  virtual int Run();
147 
148  std::string get_state_str();
149 
150  int update_statusboard();
151 
152  ///Write coronguide status to the data log
153  virtual void dataLogger(timeval tv);
154 
155 protected:
156 
157  /// Overridden from VisAOApp_base::remote_command, here just calls common_command.
158  virtual std::string remote_command(std::string com);
159  /// Overridden from VisAOApp_base::local_command, here just calls common_command.
160  virtual std::string local_command(std::string com);
161  /// Overridden from VisAOApp_base::script_command, here just calls common_command.
162  virtual std::string script_command(std::string com);
163  /// Overridden from VisAOApp_base::auto_command, here just calls common_command.
164  std::string auto_command(std::string com, char *seqmsg);
165 
166  /// The common command processor for commands received by fifo.
167  /** The return value depends on the command received. Recognized commands are:
168  */
169  std::string common_command(std::string com, int cmode);
170 };
171 
172 
173 
174 } //namespace VisAO
175 
176 #endif //__coronguide_h__
177 
virtual std::string script_command(std::string com)
Overridden from VisAOApp_base::script_command, here just calls common_command.
Definition: coronguide.cpp:797
sharedim< short > sim
The sharedim structure retreived from the stack.
Definition: coronguide.h:58
virtual void dataLogger(timeval tv)
Write coronguide status to the data log.
The standalone VisAO application, does not interface with the AO Supervisor.
std::string common_command(std::string com, int cmode)
The common command processor for commands received by fifo.
Definition: coronguide.cpp:818
Declarations for the standalone VisAO application.
virtual std::string local_command(std::string com)
Overridden from VisAOApp_base::local_command, here just calls common_command.
Definition: coronguide.cpp:787
sharedim_stack< short > * sis
Manages a VisAO shared memory image stack.
Definition: coronguide.h:51
virtual std::string remote_command(std::string com)
Overridden from VisAOApp_base::remote_command, here just calls common_command.
Definition: coronguide.cpp:777
Declarations for the VisAO status information structures.
double tgtx
Size of the kernel, in units of kfwhm.
Definition: coronguide.h:97
int update_statusboard()
Update the status board.
std::string auto_command(std::string com, char *seqmsg)
Overridden from VisAOApp_base::auto_command, here just calls common_command.
Definition: coronguide.cpp:807
virtual int Run()
The application main loop, to be re-implemented in derived classes.
Definition: coronguide.cpp:365
Declarations for the shared image circular buffer.
The namespace of VisAO software.
int shmem_key
shared memory key for
Definition: coronguide.h:54