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