cacao  Release 0.1.03-dev
Compute And Control For Adaptive Optics
AOloopControl_DM.h
Go to the documentation of this file.
1 #ifndef _AOLOOPCONTROL_DM_H
2 #define _AOLOOPCONTROL_DM_H
3 
4 
5 
6 #define DISPCOMB_FILENAME_CONF "/tmp/dmdispcombconf.conf.shm"
7 #define DMTURBCONF_FILENAME "/tmp/dmturb.conf.shm"
8 
9 #define DM_NUMBER_CHANMAX 20 // max number of channel per DM
10 
11 
12 
13 
14 /* =============================================================================================== */
15 /*
16  * DM description and status
17  * contains DM physical characteristics, settings
18  * defines how DM is controlled (input and output)
19  * sets up DM channels, allowing DM control to be split in parallel channels
20  */
21 /* =============================================================================================== */
22 
23 typedef struct
24 {
25  int ON;
26 
27  uint32_t xsize; // DM xsize
28  uint32_t ysize; // DM ysize
29  uint64_t xysize; // total number of actuators
30  long NBchannel; // number of control channels
31 
32  long loopcnt;
33  long updatecnt; // DM update counter
34  int busy; // if set to 1, hold off and wait
35 
36  int voltmode; // 1 if DM drives voltmap
37  long IDvolt;
38  char voltname[12];
39  int voltON; // 1 if applying voltage
40  int volttype; // 1: linear bipolar, 2: quadratic uniplolar
41  float stroke100; // displacement [um] for 100 V
42  float MAXVOLT; // maximum voltage on DM
43  int AveMode;
44  float DClevel;
45 
46  int TrigMode; // 0 (std) : any channel update triggers disp update, 1: use specific channel and semaphore
47  int TrigChan; // if TrigMode = 1, use this channel for trigger
48  int TrigSem; // if TrigMode = 1, use this semaphore for trigger
49 
50 
51  long nsecwait; // inner wait loop duration, interrupted if sem[1] of disp posted
52  struct timespec tstart;
53  struct timespec tend;
54  double tdelay;
55  double time_disp2V;
56 
57 
58 
59  long dmdispID[DM_NUMBER_CHANMAX];
60  float dmdispgain[DM_NUMBER_CHANMAX];
61  long dmdispcnt[DM_NUMBER_CHANMAX];
62  long IDdisp;
63 
64  int dm2dm_mode; // 1 if output disp should be remapped to output DM disp
65  // following only applies of dm2dm_mode = 1
66  long xsizeout;
67  long ysizeout;
69  char dm2dm_DMmodes_name[200];
71  char dm2dm_outdisp_name[200];
72 
73  int wfsrefmode; // 1 if wfsref offset should be computed
77  char wfsref_RespMat_name[200];
79  char wfsref_out_name[200];
80 
81  int status;
82  long moninterval; // [us]
83 
85 
86 
87 
88 
89 
90 typedef struct
91 {
92  int on;
93  long cnt;
94 
95  double wspeed; // wind speed [m/s]
96  double ampl; // [um RMS]
97  double LOcoeff; // 0 for full correction of low orders, 1 for no correction
98 
99  long tint; // interval between consecutive DM updates [us]
100 
101 
102  double simtime;
103 
104  struct timespec tstart;
105  struct timespec tend;
106 
108 
109 
110 
111 
112 
113 
114 void __attribute__((constructor)) libinit_AOloopControl_DM();
115 
116 
117 
118 /* =============================================================================================== */
119 /* =============================================================================================== */
120 /* */
121 /* TOOLBOX */
122 /* */
123 /* =============================================================================================== */
124 /* =============================================================================================== */
125 
126 struct timespec time_diff(
127  struct timespec start,
128  struct timespec end
129 );
130 
132  const char *ID_name1,
133  const char *ID_name2,
134  long size,
135  float outerscale,
136  float innerscale
137 );
138 
139 
140 
141 /* =============================================================================================== */
142 /* =============================================================================================== */
143 /* */
144 /* 1. INITIALIZATION, LOAD/CREATE */
145 /* */
146 /* =============================================================================================== */
147 /* =============================================================================================== */
148 
149 //static errno_t AOloopControl_DM_createconf();
150 
152 
154 
155 
156 
157 
158 
159 /* =============================================================================================== */
160 /* =============================================================================================== */
161 /* */
162 /* 2. RUNTIME COMPUTATION */
163 /* */
164 /* =============================================================================================== */
165 /* =============================================================================================== */
166 
167 int AOloopControl_DM_disp2V(long DMindex);
168 
169 int AOloopControl_DM_CombineChannels_FPCONF(char *fpsname, uint32_t CMDmode,
170  long DMindex);
171 int AOloopControl_DM_CombineChannels_RUN(char *fpsname);
172 
173 int AOloopControl_DM_CombineChannels(long DMindex,
174  long xsize,
175  long ysize,
176  int NBchannel,
177  int AveMode,
178  int dm2dm_mode,
179  const char *dm2dm_DMmodes,
180  const char *dm2dm_outdisp,
181  int wfsrefmode,
182  const char *wfsref_WFSRespMat,
183  const char *wfsref_out,
184  int voltmode,
185  int volttype,
186  float stroke100,
187  const char *IDvolt_name,
188  float DClevel,
189  float maxvolt
190  );
191 
192 
193 int AOloopControl_DM_dmdispcomboff(long DMindex);
194 
195 int AOloopControl_DM_dmtrigoff(long DMindex);
196 
197 
198 
199 
200 
201 /* =============================================================================================== */
202 /* =============================================================================================== */
203 /* */
204 /* 3. CONFIGURATION */
205 /* */
206 /* =============================================================================================== */
207 /* =============================================================================================== */
208 
210 
211 int AOloopControl_DM_dmdispcombstatus(long DMindex);
212 
213 int AOloopControl_DM_chan_setgain(long DMindex, int ch, float gain);
214 
215 int AOloopControl_DM_setvoltON(long DMindex);
216 
217 int AOloopControl_DM_setvoltOFF(long DMindex);
218 
219 int AOloopControl_DM_setMAXVOLT(long DMindex, float maxvolt);
220 
221 int AOloopControl_DM_setDClevel(long DMindex, float DClevel);
222 
223 int AOloopControl_DM_setAveMode(long DMindex, int AveMode);
224 
225 int AOloopControl_DM_setTrigMode(long DMindex, int mode);
226 
227 int AOloopControl_DM_setTrigChan(long DMindex, int chan);
228 
229 int AOloopControl_DM_setTrigSem(long DMindex, int sem);
230 
231 
232 
233 /* =============================================================================================== */
234 /* =============================================================================================== */
235 /* */
236 /* 4. TURBULENCE SIMULATOR */
237 /* */
238 /* =============================================================================================== */
239 /* =============================================================================================== */
240 
242 
244 
246 
247 int AOloopControl_DM_dmturboff(long DMindex);
248 
249 int AOloopControl_DM_dmturb_wspeed(long DMindex, double wspeed);
250 
251 int AOloopControl_DM_dmturb_ampl(long DMindex, double ampl);
252 
253 int AOloopControl_DM_dmturb_LOcoeff(long DMindex, double LOcoeff);
254 
255 int AOloopControl_DM_dmturb_tint(long DMindex, long tint);
256 
257 int AOloopControl_DM_dmturb_printstatus(long DMindex);
258 
259 int AOloopControl_DM_dmturb(long DMindex, int mode, const char *IDout_name,
260  long NBsamples);
261 
262 
263 
264 /* =============================================================================================== */
265 /* =============================================================================================== */
266 /* */
267 /* 5. MISC TESTS & UTILS */
268 /* */
269 /* =============================================================================================== */
270 /* =============================================================================================== */
271 
272 long AOloopControl_mkDM_TT_circle(char *IDoutname, long DMindex, long NBpts,
273  float ampl);
274 
275 long AOloopControl_DM_mkAstroGrid_seq(char *IDoutname, long DMindex, int XYmode,
276  int bin, long NBcycle);
277 
278 
279 #endif
280 
int on
Definition: AOloopControl_DM.h:92
#define DM_NUMBER_CHANMAX
Definition: AOloopControl_DM.h:9
long cnt
Definition: AOloopControl_DM.h:93
long NBchannel
Definition: AOloopControl_DM.h:30
int AOloopControl_DM_dmturb_wspeed(long DMindex, double wspeed)
Definition: AOloopControl_DM_turbusimul.c:234
void __attribute__((constructor)) libinit_AOloopControl_DM()
Initialize module.
Definition: ImageStreamIO.c:77
int AOloopControl_DM_CombineChannels_RUN(char *fpsname)
Definition: AOloopControl_DM_runtimecomp.c:452
double LOcoeff
Definition: AOloopControl_DM.h:97
int AOloopControl_DM_dmturb(long DMindex, int mode, const char *IDout_name, long NBsamples)
Definition: AOloopControl_DM_turbusimul.c:324
int AOloopControl_DM_dmdispcombstatus(long DMindex)
Definition: AOloopControl_DM_config.c:139
long xsizeout
Definition: AOloopControl_DM.h:66
int wfsrefmode
Definition: AOloopControl_DM.h:73
int dm2dm_mode
Definition: AOloopControl_DM.h:64
uint32_t xsize
Definition: AOloopControl_DM.h:27
int AOloopControl_DM_dmdispcomboff(long DMindex)
Definition: AOloopControl_DM_runtimecomp.c:1758
int AOloopControl_printDMconf()
Definition: AOloopControl_DM_config.c:89
int ON
Definition: AOloopControl_DM.h:25
int AOloopControl_DMturb_createconf()
Definition: AOloopControl_DM_turbusimul.c:92
long AOloopControl_DM_mkAstroGrid_seq(char *IDoutname, long DMindex, int XYmode, int bin, long NBcycle)
Definition: AOloopControl_DM_TTcircle_astrogrid.c:94
int AOloopControl_DM_dmturb_LOcoeff(long DMindex, double LOcoeff)
Definition: AOloopControl_DM_turbusimul.c:258
int AOloopControl_DM_setTrigChan(long DMindex, int chan)
Definition: AOloopControl_DM_config.c:335
double wspeed
Definition: AOloopControl_DM.h:95
int AOloopControl_DM_setAveMode(long DMindex, int AveMode)
Definition: AOloopControl_DM_config.c:316
errno_t AOloopControl_DMturb_loadconf()
Definition: AOloopControl_DM_turbusimul.c:187
errno_t AOloopControl_DM_loadconf()
Definition: AOloopControl_DM_init.c:133
long loopcnt
Definition: AOloopControl_DM.h:32
int TrigMode
Definition: AOloopControl_DM.h:46
long IDvolt
Definition: AOloopControl_DM.h:37
int AOloopControl_DM_dmturboff(long DMindex)
Definition: AOloopControl_DM_turbusimul.c:222
int AOloopControl_DM_dmturb_ampl(long DMindex, double ampl)
Definition: AOloopControl_DM_turbusimul.c:246
long ID_wfsref_out
Definition: AOloopControl_DM.h:78
int AOloopControl_DM_setvoltON(long DMindex)
Definition: AOloopControl_DM_config.c:276
Definition: AOloopControl_DM.h:90
uint32_t ysize
Definition: AOloopControl_DM.h:28
long xsizewfsref
Definition: AOloopControl_DM.h:74
int AOloopControl_DM_CombineChannels(long DMindex, long xsize, long ysize, int NBchannel, int AveMode, int dm2dm_mode, const char *dm2dm_DMmodes, const char *dm2dm_outdisp, int wfsrefmode, const char *wfsref_WFSRespMat, const char *wfsref_out, int voltmode, int volttype, float stroke100, const char *IDvolt_name, float DClevel, float maxvolt)
Definition: AOloopControl_DM_runtimecomp.c:1106
long nsecwait
Definition: AOloopControl_DM.h:51
int AOloopControl_DM_CombineChannels_FPCONF(char *fpsname, uint32_t CMDmode, long DMindex)
Definition: AOloopControl_DM_runtimecomp.c:245
int errno_t
Definition: AOloopControl_IOtools.h:20
double ampl
Definition: AOloopControl_DM.h:96
errno_t AOloopControl_DM_unloadconf()
Definition: AOloopControl_DM_init.c:171
int AveMode
Definition: AOloopControl_DM.h:43
int TrigSem
Definition: AOloopControl_DM.h:48
int busy
Definition: AOloopControl_DM.h:34
float stroke100
Definition: AOloopControl_DM.h:41
long moninterval
Definition: AOloopControl_DM.h:82
long ID_wfsref_RespMat
Definition: AOloopControl_DM.h:76
float MAXVOLT
Definition: AOloopControl_DM.h:42
int AOloopControl_DM_setMAXVOLT(long DMindex, float maxvolt)
Definition: AOloopControl_DM_config.c:296
int AOloopControl_DM_chan_setgain(long DMindex, int ch, float gain)
Definition: AOloopControl_DM_config.c:262
long ID_dm2dm_outdisp
Definition: AOloopControl_DM.h:70
long ID_dm2dm_DMmodes
Definition: AOloopControl_DM.h:68
int AOloopControl_DM_dmtrigoff(long DMindex)
Definition: AOloopControl_DM_runtimecomp.c:1768
long tint
Definition: AOloopControl_DM.h:99
errno_t AOloopControl_printDMturbconf()
Definition: AOloopControl_DM_turbusimul.c:67
int AOloopControl_DM_setTrigSem(long DMindex, int sem)
Definition: AOloopControl_DM_config.c:344
long AOloopControl_mkDM_TT_circle(char *IDoutname, long DMindex, long NBpts, float ampl)
Definition: AOloopControl_DM_TTcircle_astrogrid.c:43
double time_disp2V
Definition: AOloopControl_DM.h:55
uint64_t xysize
Definition: AOloopControl_DM.h:29
int voltmode
Definition: AOloopControl_DM.h:36
long ysizeout
Definition: AOloopControl_DM.h:67
long ysizewfsref
Definition: AOloopControl_DM.h:75
Definition: AOloopControl_DM.h:23
double simtime
Definition: AOloopControl_DM.h:102
int AOloopControl_DM_dmturb_printstatus(long DMindex)
Definition: AOloopControl_DM_turbusimul.c:284
long updatecnt
Definition: AOloopControl_DM.h:33
int status
Definition: AOloopControl_DM.h:81
errno_t make_master_turbulence_screen_local(const char *ID_name1, const char *ID_name2, long size, float outerscale, float innerscale)
Definition: AOloopControl_DM_toolbox.c:64
long IDdisp
Definition: AOloopControl_DM.h:62
float DClevel
Definition: AOloopControl_DM.h:44
int AOloopControl_DM_disp2V(long DMindex)
Definition: AOloopControl_DM_runtimecomp.c:106
int voltON
Definition: AOloopControl_DM.h:39
int AOloopControl_DM_setvoltOFF(long DMindex)
Definition: AOloopControl_DM_config.c:286
struct timespec time_diff(struct timespec start, struct timespec end)
Definition: AOloopControl_DM_toolbox.c:40
int volttype
Definition: AOloopControl_DM.h:40
int AOloopControl_DM_setDClevel(long DMindex, float DClevel)
Definition: AOloopControl_DM_config.c:306
double tdelay
Definition: AOloopControl_DM.h:54
int TrigChan
Definition: AOloopControl_DM.h:47
int AOloopControl_DM_dmturb_tint(long DMindex, long tint)
Definition: AOloopControl_DM_turbusimul.c:270
int AOloopControl_DM_setTrigMode(long DMindex, int mode)
Definition: AOloopControl_DM_config.c:326