AdaptiveOpticsControl
AOloopControl.h
Go to the documentation of this file.
1 
14 #ifndef _AOLOOPCONTROL_H
15 #define _AOLOOPCONTROL_H
16 
17 
18 
19 
20 
21 #define maxNBMB 100
22 #define MAX_NUMBER_TIMER 100
23 
24 
25 
31 typedef struct
32 {
33 
34  /* =============================================================================================== */
38 
40  float loopfrequ;
42  // Hardware latency = time from DM command issued to WFS response changed
43  float hardwlatency;
46  // Computation time for direct WFS->DM mode through single matrix multiplication
47  float complatency;
50  // Computation time for full computation including open loop computation
54  int_fast8_t status;
55  int_fast8_t statusM;
56  int_fast8_t statusM1;
58  int_fast8_t GPUstatus[50];
59  uint_fast16_t NBtimer;
60  struct timespec timer[MAX_NUMBER_TIMER];
61  /* =============================================================================================== */
63 
64 
65 
66  /* =============================================================================================== */
70  int_fast8_t init;
72  uint_fast64_t cnt;
73  uint_fast64_t cntmax;
74  uint_fast64_t DMupdatecnt;
75  int_fast8_t kill;
76  char name[80];
77 
78  int_fast8_t init_RM;
79  int_fast8_t init_CM;
80  int_fast8_t init_CMc;
81  int_fast8_t initmapping;
82  char respMname[80];
83  char contrMname[80];
85  /* =============================================================================================== */
86 
87 
88 
89  /* =============================================================================================== */
93  char WFSname[80];
95  float DarkLevel;
96  uint_fast32_t sizexWFS;
97  uint_fast32_t sizeyWFS;
98  uint_fast32_t sizeWFS;
99  uint_fast32_t activeWFScnt; // number of active WFS pixels
100  uint_fast32_t sizeWFS_active[100]; // only takes into account WFS pixels in use/active for each slice
101  uint_fast64_t WFScnt;
102  uint_fast64_t WFScntRM;
103 
104  int_fast8_t WFSnormalize; // 1 if each WFS frame should be normalized to 1
106  float WFStotalflux; // after dark subtraction
108  /* =============================================================================================== */
109 
110 
111 
112  /* =============================================================================================== */
116  char dmCname[80];
118  char dmdispname[80];
119  char dmRMname[80];
120  uint_fast32_t sizexDM;
121  uint_fast32_t sizeyDM;
122  uint_fast32_t sizeDM;
123  uint_fast32_t activeDMcnt;
124  uint_fast32_t sizeDM_active;
125  /* =============================================================================================== */
127 
128 
129 
130  /* =============================================================================================== */
134  char DMmodesname[80];
136  // BLOCKS OF MODES
137  uint_fast16_t DMmodesNBblock; // number of mode blocks
138  uint_fast16_t NBmodes_block[100]; // number of modes within each block
139  uint_fast16_t indexmaxMB[maxNBMB];
140 
141  uint_fast16_t NBDMmodes;
142 
143  int_fast8_t init_wfsref0; // WFS reference image loaded
144 
145  float maxlimit; // maximum absolute value for mode values
146  float mult; // multiplication coefficient to be applied at each loop iteration
148  /* =============================================================================================== */
149 
150 
151 
152 
153  /* =============================================================================================== */
157  int_fast8_t on; // goes to 1 when loop starts, put to 0 to turn loop off
159  float gain; // overall loop gain
160  uint_fast16_t framesAve; // number of frames to average
161  int_fast8_t DMprimaryWrite_ON; // primary DM write
162 
163 
164  // MODAL AUTOTUNING
165  // limits
166  int_fast8_t AUTOTUNE_LIMITS_ON;
167  float AUTOTUNE_LIMITS_perc; // percentile limit for autotuning
168  float AUTOTUNE_LIMITS_mcoeff; // multiplicative coeff
169  float AUTOTUNE_LIMITS_delta; // autotune loop increment
170 
171  int_fast8_t AUTOTUNE_GAINS_ON;
172  float AUTOTUNE_GAINS_gain; // averaging coefficient (usually about 0.1)
173  float AUTOTUNEGAIN_evolTimescale; // evolution timescale, beyond which errors stop growing
175  /* =============================================================================================== */
176 
177 
178 
179  /* =============================================================================================== */
183  int_fast8_t ARPFon; // 1 if auto-regressive predictive filter is ON
185  float ARPFgain;
187  /* =============================================================================================== */
188 
189 
190 
191  /* =============================================================================================== */
195  int_fast8_t GPU; // 1 if matrix multiplication done by GPU
197  int_fast8_t GPUall; // 1 if scaling computations done by GPU
198  int_fast8_t GPUusesem; // 1 if using semaphores to control GPU
199  int_fast8_t AOLCOMPUTE_TOTAL_ASYNC; // 1 if performing image total in separate thread (runs faster, but image total dates from last frame)
201  /* =============================================================================================== */
202 
203 
204 
205 
206 
207  /* =============================================================================================== */
211 
213  // COMPUTED BY OPEN LOOP RETRIEVAL PROCESS
214  double RMSmodes;
216  uint_fast64_t RMSmodesCumulcnt;
217 
218  // block statistics (instantaneous)
219  double block_OLrms[100]; // open loop RMS
220  double block_Crms[100]; // correction RMS
221  double block_WFSrms[100]; // WFS residual RMS
222  double block_limFrac[100]; // fraction of mode coefficients exceeding limit
223 
224  double ALL_OLrms; // open loop RMS
225  double ALL_Crms; // correction RMS
226  double ALL_WFSrms; // WFS residual RMS
227  double ALL_limFrac; // fraction of mode coefficients exceeding limit
228 
229  // averaged
230  uint_fast32_t AveStats_NBpt; // averaging interval
231  double blockave_OLrms[100]; // open loop RMS
232  double blockave_Crms[100]; // correction RMS
233  double blockave_WFSrms[100]; // WFS residual RMS
234  double blockave_limFrac[100]; // fraction of mode coefficients exceeding limit
235 
236  double ALLave_OLrms; // open loop RMS
237  double ALLave_Crms; // correction RMS
238  double ALLave_WFSrms; // WFS residual RMS
239  double ALLave_limFrac; // fraction of mode coefficients exceeding limit
241  /* =============================================================================================== */
242 
243 
244 
245 
246 
247  // semaphores for communication with GPU computing threads
248  //sem_t *semptr; // semaphore for this image
249 
251 
252 
253 
254 
255 
256 
257 // data passed to each thread
258 typedef struct
259 {
260  long nelem;
261  float *arrayptr;
262  float *result; // where to white status
264 
265 
266 
267 
268 
269 // image streams and semaphores
270 
271 
272 
273 
274 /* =============================================================================================== */
275 /* LOGGING ACCESS TO FUNCTIONS */
276 /* =============================================================================================== */
311 static void AOloopControl_logFunctionCall(const int logfuncMODE, const char *FunctionName, const long line, char *comments);
312 
313 
314 
315 
316 
320 int_fast8_t init_AOloopControl();
321 
322 
323 
324 /* =============================================================================================== */
325 /* =============================================================================================== */
329 /* =============================================================================================== */
331 /* =============================================================================================== */
332 
333 static int_fast8_t AOloopControl_loadconfigure(long loop, int mode, int level);
334 
338 static int_fast8_t AOloopControl_InitializeMemory();
339 
341 
342 
343 
344 
345 
346 
347 /* =============================================================================================== */
348 /* =============================================================================================== */
352 /* =============================================================================================== */
354 /* =============================================================================================== */
355 
357 
358 /* =============================================================================================== */
361 /* =============================================================================================== */
363 
364 long AOloopControl_2Dloadcreate_shmim(const char *name, const char *fname, long xsize, long ysize);
365 
366 long AOloopControl_3Dloadcreate_shmim(const char *name, const char *fname, long xsize, long ysize, long zsize);
368 
369 /* =============================================================================================== */
372 /* =============================================================================================== */
374 
375 int_fast8_t AOloopControl_AveStream(const char *IDname, double alpha, const char *IDname_out_ave, const char *IDname_out_AC, const char *IDname_out_RMS);
376 
377 long AOloopControl_frameDelay(const char *IDin_name, const char *IDkern_name, const char *IDout_name, int insem);
378 
381 long AOloopControl_stream3Dto2D(const char *in_name, const char *out_name, int NBcols, int insem);
383 
384 /* =============================================================================================== */
387 /* =============================================================================================== */
389 
390 // compute cross product between two 3D arrays
391 static long AOloopControl_CrossProduct(const char *ID1_name, const char *ID2_name, const char *IDout_name);
392 
393 // compute sum of image pixels
394 static void *compute_function_imtotal( void *ptr );
395 
396 static void *compute_function_dark_subtract( void *ptr );
397 
398 long AOloopControl_mkSimpleZpokeM( long dmxsize, long dmysize, char *IDout_name);
399 
400 long AOloopControl_dm2opdmaploop(char *DMdisp_name, char *OPDmap_name, int semindex);
401 
403 
404 
405 
406 /* =============================================================================================== */
407 /* =============================================================================================== */
411 /* =============================================================================================== */
413 /* =============================================================================================== */
414 
415 int_fast8_t AOloopControl_camimage_extract2D_sharedmem_loop(const char *in_name, const char *dark_name, const char *out_name, long size_x, long size_y, long xstart, long ystart);
416 
417 int_fast8_t Read_cam_frame(long loop, int RM, int normalize, int PixelStreamMode, int InitSem);
418 
420 
421 
422 
423 /* =============================================================================================== */
424 /* =============================================================================================== */
428 /* =============================================================================================== */
430 /* =============================================================================================== */
431 
459 long AOloopControl_Measure_WFSrespC(long loop, long delayfr, long delayRM1us, long NBave, long NBexcl, const char *IDpokeC_name, const char *IDoutC_name, int normalize, int AOinitMode, long NBcycle);
460 
461 
462 long AOloopControl_Measure_WFS_linResponse(long loop, float ampl, long delayfr, long delayRM1us, long NBave, long NBexcl, const char *IDpokeC_name, const char *IDrespC_name, const char *IDwfsref_name, int normalize, int AOinitMode, long NBcycle);
463 
464 
465 long AOloopControl_Measure_zonalRM(long loop, double ampl, long delayfr, long delayRM1us, long NBave, long NBexcl, const char *zrespm_name, const char *WFSref_name, const char *WFSmap_name, const char *DMmap_name, long mode, int normalize, int AOinitMode, long NBcycle);
466 
467 
468 int_fast8_t Measure_Resp_Matrix(long loop, long NbAve, float amp, long nbloop, long fDelay, long NBiter);
469 
470 
471 long AOloopControl_RespMatrix_Fast(const char *DMmodes_name, const char *dmRM_name, const char *imWFS_name, long semtrig, float HardwareLag, float loopfrequ, float ampl, const char *outname);
472 
474 
475 
476 
477 
478 
479 /* =============================================================================================== */
480 /* =============================================================================================== */
484 /* =============================================================================================== */
486 /* =============================================================================================== */
487 
488 long AOloopControl_mkHadamardModes(const char *DMmask_name, const char *outname);
489 
490 long AOloopControl_Hadamard_decodeRM(const char *inname, const char *Hmatname, const char *indexname, const char *outname);
491 
492 long AOloopControl_mkloDMmodes(const char *ID_name, long msizex, long msizey, float CPAmax, float deltaCPA, double xc, double yc, double r0, double r1, int MaskMode);
493 
494 int_fast8_t AOloopControl_mkCalib_map_mask(long loop, const char *zrespm_name, const char *WFSmap_name, const char *DMmap_name, float dmmask_perclow, float dmmask_coefflow, float dmmask_perchigh, float dmmask_coeffhigh, float wfsmask_perclow, float wfsmask_coefflow, float wfsmask_perchigh, float wfsmask_coeffhigh);
495 
496 int_fast8_t AOloopControl_Process_zrespM(long loop, const char *IDzrespm0_name, const char *IDwfsref_name, const char *IDzrespm_name, const char *WFSmap_name, const char *DMmap_name);
497 
498 int_fast8_t AOloopControl_ProcessZrespM_medianfilt(long loop, const char *zrespm_name, const char *WFSref0_name, const char *WFSmap_name, const char *DMmap_name, double rmampl, int normalize);
499 
500 long AOloopControl_mkCM(const char *respm_name, const char *cm_name, float SVDlim);
501 
502 long AOloopControl_mkSlavedAct(const char *IDmaskRM_name, float pixrad, const char *IDout_name);
503 
504 static long AOloopControl_DMedgeDetect(const char *IDmaskRM_name, const char *IDout_name);
505 
506 static long AOloopControl_DMextrapolateModes(const char *IDin_name, const char *IDmask_name, const char *IDcpa_name, const char *IDout_name);
507 
508 long AOloopControl_DMslaveExt(const char *IDin_name, const char *IDmask_name, const char *IDsl_name, const char *IDout_name, float r0);
509 
510 long AOloopControl_mkModes(const char *ID_name, long msizex, long msizey, float CPAmax, float deltaCPA, double xc, double yx, double r0, double r1, int MaskMode, int BlockNB, float SVDlim);
511 
512 long AOloopControl_mkModes_Simple(const char *IDin_name, long NBmblock, long Cmblock, float SVDlim);
513 
514 int_fast8_t compute_ControlMatrix(long loop, long NB_MODE_REMOVED, const char *ID_Rmatrix_name, const char *ID_Cmatrix_name, const char *ID_VTmatrix_name, double Beta, long NB_MODE_REMOVED_STEP, float eigenvlim);
515 
516 long compute_CombinedControlMatrix(const char *IDcmat_name, const char *IDmodes_name, const char* IDwfsmask_name, const char *IDdmmask_name, const char *IDcmatc_name, const char *IDcmatc_active_name);
517 
518 long AOloopControl_loadCM(long loop, const char *CMfname);
519 
521 
522 
523 /* =============================================================================================== */
524 /* =============================================================================================== */
528 /* =============================================================================================== */
530 /* =============================================================================================== */
531 
532 int_fast8_t AOloopControl_WFSzpupdate_loop(const char *IDzpdm_name, const char *IDzrespM_name, const char *IDwfszp_name);
533 
534 int_fast8_t AOloopControl_WFSzeropoint_sum_update_loop(long loopnb, const char *ID_WFSzp_name, int NBzp, const char *IDwfsref0_name, const char *IDwfsref_name);
535 
536 int_fast8_t AOloopControl_run();
537 
538 int_fast8_t ControlMatrixMultiply( float *cm_array, float *imarray, long m, long n, float *outvect);
539 
540 int_fast8_t set_DM_modes(long loop);
541 
542 int_fast8_t set_DM_modesRM(long loop);
543 
544 int_fast8_t AOcompute(long loop, int normalize);
545 
546 int_fast8_t AOloopControl_CompModes_loop(const char *ID_CM_name, const char *ID_WFSref_name, const char *ID_WFSim_name, const char *ID_WFSimtot_name, const char *ID_coeff_name);
547 
548 int_fast8_t AOloopControl_GPUmodecoeffs2dm_filt_loop(const char *modecoeffs_name, const char *DMmodes_name, int semTrigg, const char *out_name, int GPUindex, long loop, int offloadMode);
549 
550 long AOloopControl_sig2Modecoeff(const char *WFSim_name, const char *IDwfsref_name, const char *WFSmodes_name, const char *outname);
551 
552 long AOloopControl_computeWFSresidualimage(long loop, float alpha);
553 
554 long AOloopControl_ComputeOpenLoopModes(long loop);
555 
556 int_fast8_t AOloopControl_AutoTuneGains(long loop, const char *IDout_name);
557 
558 long AOloopControl_dm2dm_offload(const char *streamin, const char *streamout, float twait, float offcoeff, float multcoeff);
559 
561 
562 
563 
564 /* =============================================================================================== */
565 /* =============================================================================================== */
569 /* =============================================================================================== */
571 /* =============================================================================================== */
572 
573 int_fast8_t AOloopControl_mapPredictiveFilter(const char *IDmodecoeff_name, long modeout, double delayfr);
574 
575 double AOloopControl_testPredictiveFilter(const char *IDtrace_name, long mode, double delayfr, long filtsize, const char *IDfilt_name, double SVDeps);
576 
577 long AOloopControl_builPFloop_WatchInput(long loop, long PFblock);
578 
580 
581 
582 
583 
584 /* =============================================================================================== */
585 /* =============================================================================================== */
589 /* =============================================================================================== */
591 /* =============================================================================================== */
592 
593 int_fast8_t AOloopControl_setLoopNumber(long loop);
594 
595 int_fast8_t AOloopControl_setparam(long loop, const char *key, double value);
597 
598 
599 /* =============================================================================================== */
603 /* =============================================================================================== */
605 
606 int_fast8_t AOloopControl_loopon();
607 
608 int_fast8_t AOloopControl_loopoff();
609 
610 int_fast8_t AOloopControl_loopkill();
611 
612 int_fast8_t AOloopControl_loopstep(long loop, long NBstep);
613 
614 int_fast8_t AOloopControl_loopreset();
616 
617 
618 /* =============================================================================================== */
621 /* =============================================================================================== */
623 
624 int_fast8_t AOloopControl_logon();
625 
626 int_fast8_t AOloopControl_logoff();
628 
629 /* =============================================================================================== */
632 /* =============================================================================================== */
634 
635 int_fast8_t AOloopControl_DMprimaryWrite_on();
636 
639 
640 /* =============================================================================================== */
643 /* =============================================================================================== */
645 
647 
649 
650 int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_delta(float AUTOTUNE_LIMITS_delta);
651 
652 int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_perc(float AUTOTUNE_LIMITS_perc);
653 
654 int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_mcoeff(float AUTOTUNE_LIMITS_mcoeff);
655 
656 int_fast8_t AOloopControl_AUTOTUNE_GAINS_on();
657 
660 
661 /* =============================================================================================== */
664 /* =============================================================================================== */
666 
667 int_fast8_t AOloopControl_ARPFon();
668 
669 int_fast8_t AOloopControl_ARPFoff();
671 
672 /* =============================================================================================== */
675 /* =============================================================================================== */
677 
678 int_fast8_t AOloopControl_set_loopfrequ(float loopfrequ);
679 
680 int_fast8_t AOloopControl_set_hardwlatency_frame(float hardwlatency_frame);
681 
682 int_fast8_t AOloopControl_set_complatency_frame(float complatency_frame);
683 
684 int_fast8_t AOloopControl_set_wfsmextrlatency_frame(float wfsmextrlatency_frame);
686 
687 /* =============================================================================================== */
690 /* =============================================================================================== */
692 
693 int_fast8_t AOloopControl_setgain(float gain);
694 
695 int_fast8_t AOloopControl_setARPFgain(float gain);
696 
697 int_fast8_t AOloopControl_setWFSnormfloor(float WFSnormfloor);
698 
699 int_fast8_t AOloopControl_setmaxlimit(float maxlimit);
700 
701 int_fast8_t AOloopControl_setmult(float multcoeff);
702 
703 int_fast8_t AOloopControl_setframesAve(long nbframes);
704 
705 int_fast8_t AOloopControl_set_modeblock_gain(long loop, long blocknb, float gain, int add);// modal blocks
706 
707 int_fast8_t AOloopControl_scanGainBlock(long NBblock, long NBstep, float gainStart, float gainEnd, long NBgain);
708 
710 
711 
712 
713 /* =============================================================================================== */
714 /* =============================================================================================== */
718 /* =============================================================================================== */
720 /* =============================================================================================== */
721 
722 int_fast8_t AOloopControl_printloopstatus(long loop, long nbcol, long IDmodeval_dm, long IDmodeval, long IDmodevalave, long IDmodevalrms, long ksize);
723 
724 int_fast8_t AOloopControl_loopMonitor(long loop, double frequ, long nbcol);
725 
726 int_fast8_t AOloopControl_statusStats(int updateconf);
727 
728 int_fast8_t AOloopControl_resetRMSperf();
729 
730 int_fast8_t AOloopControl_showparams(long loop);
731 
732 int_fast8_t AOcontrolLoop_TestDMSpeed(const char *dmname, long delayus, long NBpts, float ampl);
733 
734 int_fast8_t AOcontrolLoop_TestSystemLatency(const char *dmname, char *wfsname, float OPDamp, long NBiter);
735 
736 long AOloopControl_blockstats(long loop, const char *IDout_name);
737 
738 int_fast8_t AOloopControl_InjectMode( long index, float ampl );
739 
740 long AOloopControl_TestDMmodeResp(const char *DMmodes_name, long index, float ampl, float fmin, float fmax, float fmultstep, float avetime, long dtus, const char *DMmask_name, const char *DMstream_in_name, const char *DMstream_out_name, const char *IDout_name);
741 
742 long AOloopControl_TestDMmodes_Recovery(const char *DMmodes_name, float ampl, const char *DMmask_name, const char *DMstream_in_name, const char *DMstream_out_name, const char *DMstream_meas_name, long tlagus, long NBave, const char *IDout_name, const char *IDoutrms_name, const char *IDoutmeas_name, const char *IDoutmeasrms_name);
743 
744 long AOloopControl_mkTestDynamicModeSeq(const char *IDname_out, long NBpt, long NBmodes);
745 
746 int_fast8_t AOloopControl_AnalyzeRM_sensitivity(const char *IDdmmodes_name, const char *IDdmmask_name, const char *IDwfsref_name, const char *IDwfsresp_name, const char *IDwfsmask_name, float amplimitnm, float lambdanm, const char *foutname);
747 
749 
750 
751 
752 
753 /* =============================================================================================== */
754 /* =============================================================================================== */
758 /* =============================================================================================== */
760 /* =============================================================================================== */
761 
762 int_fast8_t AOloopControl_OptimizePSF_LO(const char *psfstream_name, const char *IDmodes_name, const char *dmstream_name, long delayframe, long NBframes);
763 
764 int_fast8_t AOloopControl_DMmodulateAB(const char *IDprobeA_name, const char *IDprobeB_name, const char *IDdmstream_name, const char *IDrespmat_name, const char *IDwfsrefstream_name, double delay, long NBprobes);
765 
767 
768 
769 
770 /* =============================================================================================== */
771 /* =============================================================================================== */
775 /* =============================================================================================== */
777 /* =============================================================================================== */
778 
779 int_fast8_t AOloopControl_logprocess_modeval(const char *IDname);
780 
782 
783 
784 
785 
786 
787 
788 
789 
790 
791 
792 
793 
794 
795 
796 
797 
798 /* =============================================================================================== */
799 /* */
803 /* =============================================================================================== */
805 
806 // "old" blocks (somewhat obsolete)
807 int_fast8_t AOloopControl_setgainrange(long m0, long m1, float gainval);
808 int_fast8_t AOloopControl_setlimitrange(long m0, long m1, float limval);
809 int_fast8_t AOloopControl_setmultfrange(long m0, long m1, float multfval);
810 int_fast8_t AOloopControl_setgainblock(long mb, float gainval);
811 int_fast8_t AOloopControl_setlimitblock(long mb, float limitval);
812 int_fast8_t AOloopControl_setmultfblock(long mb, float multfval);
813 
814 int_fast8_t AOloopControl_AutoTune();
815 
817 
818 
819 #endif
int_fast8_t Read_cam_frame(long loop, int RM, int normalize, int PixelStreamMode, int InitSem)
Definition: AOloopControl.c:3779
float AUTOTUNE_GAINS_gain
Definition: AOloopControl.h:172
int_fast8_t AOloopControl_logon()
int_fast8_t AOloopControl_setgain(float gain)
Definition: AOloopControl.c:13848
static long AOloopControl_DMedgeDetect(const char *IDmaskRM_name, const char *IDout_name)
long AOloopControl_mkSimpleZpokeM(long dmxsize, long dmysize, char *IDout_name)
Definition: AOloopControl.c:3480
int_fast8_t AOloopControl_scanGainBlock(long NBblock, long NBstep, float gainStart, float gainEnd, long NBgain)
Definition: AOloopControl.c:14119
int_fast8_t AOloopControl_run()
Definition: AOloopControl.c:10488
long AOloopControl_mkloDMmodes(const char *ID_name, long msizex, long msizey, float CPAmax, float deltaCPA, double xc, double yc, double r0, double r1, int MaskMode)
Definition: AOloopControl.c:5986
uint_fast64_t WFScntRM
Definition: AOloopControl.h:102
int_fast8_t AOloopControl_setmult(float multcoeff)
Definition: AOloopControl.c:13932
int_fast8_t AOloopControl_WFSzpupdate_loop(const char *IDzpdm_name, const char *IDzrespM_name, const char *IDwfszp_name)
Definition: AOloopControl.c:10243
float * result
Definition: AOloopControl.h:262
int_fast8_t statusM1
Definition: AOloopControl.h:56
int_fast8_t GPUusesem
Definition: AOloopControl.h:198
long AOloopControl_stream3Dto2D(const char *in_name, const char *out_name, int NBcols, int insem)
Re-arrange a 3D cube into an array of images into a single 2D frame.
Definition: AOloopControl.c:3186
int_fast8_t AOloopControl_setARPFgain(float gain)
Definition: AOloopControl.c:13868
static void * compute_function_dark_subtract(void *ptr)
int_fast8_t AOloopControl_AUTOTUNE_LIMITS_on()
Definition: AOloopControl.c:13569
double ALL_Crms
Definition: AOloopControl.h:225
Definition: AOloopControl.h:31
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_mcoeff(float AUTOTUNE_LIMITS_mcoeff)
Definition: AOloopControl.c:13648
uint_fast16_t NBtimer
Definition: AOloopControl.h:59
uint_fast32_t AveStats_NBpt
Definition: AOloopControl.h:230
double ALLave_WFSrms
Definition: AOloopControl.h:238
static long AOloopControl_DMextrapolateModes(const char *IDin_name, const char *IDmask_name, const char *IDcpa_name, const char *IDout_name)
int_fast8_t AOloopControl_loopstep(long loop, long NBstep)
Definition: AOloopControl.c:13448
uint_fast32_t activeWFScnt
Definition: AOloopControl.h:99
int_fast8_t AOloopControl_setparam(long loop, const char *key, double value)
Definition: AOloopControl.c:13348
double AOloopControl_testPredictiveFilter(const char *IDtrace_name, long mode, double delayfr, long filtsize, const char *IDfilt_name, double SVDeps)
Definition: AOloopControl.c:12991
long AOloopControl_3Dloadcreate_shmim(const char *name, const char *fname, long xsize, long ysize, long zsize)
Definition: AOloopControl.c:2774
float * arrayptr
Definition: AOloopControl.h:261
int_fast8_t init_RM
Definition: AOloopControl.h:78
long AOloopControl_TestDMmodes_Recovery(const char *DMmodes_name, float ampl, const char *DMmask_name, const char *DMstream_in_name, const char *DMstream_out_name, const char *DMstream_meas_name, long tlagus, long NBave, const char *IDout_name, const char *IDoutrms_name, const char *IDoutmeas_name, const char *IDoutmeasrms_name)
Definition: AOloopControl.c:15751
long AOloopControl_blockstats(long loop, const char *IDout_name)
Definition: AOloopControl.c:15355
long nelem
Definition: AOloopControl.h:260
float gain
Definition: AOloopControl.h:159
float mult
Definition: AOloopControl.h:146
float DarkLevel
Definition: AOloopControl.h:95
long AOloopControl_dm2dm_offload(const char *streamin, const char *streamout, float twait, float offcoeff, float multcoeff)
Definition: AOloopControl.c:12872
float maxlimit
Definition: AOloopControl.h:145
int_fast8_t set_DM_modesRM(long loop)
Definition: AOloopControl.c:10912
int_fast8_t AOloopControl_set_wfsmextrlatency_frame(float wfsmextrlatency_frame)
Definition: AOloopControl.c:13821
int_fast8_t AOloopControl_resetRMSperf()
Definition: AOloopControl.c:14882
int_fast8_t AOloopControl_AUTOTUNE_GAINS_off()
Definition: AOloopControl.c:13687
int_fast8_t AOloopControl_setmultfrange(long m0, long m1, float multfval)
Definition: AOloopControl.c:16980
uint_fast16_t NBDMmodes
Definition: AOloopControl.h:141
int_fast8_t Measure_Resp_Matrix(long loop, long NbAve, float amp, long nbloop, long fDelay, long NBiter)
Definition: AOloopControl.c:5171
int_fast8_t AOloopControl_setmaxlimit(float maxlimit)
Definition: AOloopControl.c:13912
long AOloopControl_TestDMmodeResp(const char *DMmodes_name, long index, float ampl, float fmin, float fmax, float fmultstep, float avetime, long dtus, const char *DMmask_name, const char *DMstream_in_name, const char *DMstream_out_name, const char *IDout_name)
Definition: AOloopControl.c:15529
uint_fast32_t sizeyDM
Definition: AOloopControl.h:121
static int_fast8_t AOloopControl_InitializeMemory()
Initialize memory - function called within C code only (no CLI call)
int_fast8_t AOloopControl_loopkill()
Definition: AOloopControl.c:13429
int_fast8_t DMprimaryWrite_ON
Definition: AOloopControl.h:161
int_fast8_t AOloopControl_loopreset()
Definition: AOloopControl.c:13474
int_fast8_t GPUall
Definition: AOloopControl.h:197
int_fast8_t AOloopControl_mapPredictiveFilter(const char *IDmodecoeff_name, long modeout, double delayfr)
Definition: AOloopControl.c:12932
int_fast8_t AOloopControl_set_loopfrequ(float loopfrequ)
Definition: AOloopControl.c:13761
long AOloopControl_frameDelay(const char *IDin_name, const char *IDkern_name, const char *IDout_name, int insem)
Definition: AOloopControl.c:3066
long AOloopControl_dm2opdmaploop(char *DMdisp_name, char *OPDmap_name, int semindex)
Definition: AOloopControl.c:3507
int_fast8_t AOcompute(long loop, int normalize)
Definition: AOloopControl.c:10954
int_fast8_t AOloopControl_GPUmodecoeffs2dm_filt_loop(const char *modecoeffs_name, const char *DMmodes_name, int semTrigg, const char *out_name, int GPUindex, long loop, int offloadMode)
Definition: AOloopControl.c:11530
uint_fast32_t activeDMcnt
Definition: AOloopControl.h:123
int_fast8_t AOloopControl_ARPFon()
Definition: AOloopControl.c:13714
float AUTOTUNEGAIN_evolTimescale
Definition: AOloopControl.h:173
int_fast8_t AOcontrolLoop_TestSystemLatency(const char *dmname, char *wfsname, float OPDamp, long NBiter)
Definition: AOloopControl.c:14999
int_fast8_t init_wfsref0
Definition: AOloopControl.h:143
int_fast8_t AOloopControl_setLoopNumber(long loop)
Definition: AOloopControl.c:13327
int_fast8_t AOloopControl_AUTOTUNE_GAINS_on()
Definition: AOloopControl.c:13667
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_delta(float AUTOTUNE_LIMITS_delta)
Definition: AOloopControl.c:13609
static long AOloopControl_CrossProduct(const char *ID1_name, const char *ID2_name, const char *IDout_name)
float hardwlatency_frame
Definition: AOloopControl.h:44
int_fast8_t AOloopControl_DMmodulateAB(const char *IDprobeA_name, const char *IDprobeB_name, const char *IDdmstream_name, const char *IDrespmat_name, const char *IDwfsrefstream_name, double delay, long NBprobes)
Definition: AOloopControl.c:16257
double RMSmodesCumul
Definition: AOloopControl.h:215
long AOloopControl_mkSlavedAct(const char *IDmaskRM_name, float pixrad, const char *IDout_name)
Definition: AOloopControl.c:6991
int_fast8_t AOloopControl_logoff()
long AOloopControl_2Dloadcreate_shmim(const char *name, const char *fname, long xsize, long ysize)
Definition: AOloopControl.c:2639
int_fast8_t AOloopControl_DMprimaryWrite_on()
Definition: AOloopControl.c:13524
int_fast8_t AOloopControl_set_complatency_frame(float complatency_frame)
Definition: AOloopControl.c:13801
uint_fast32_t sizeyWFS
Definition: AOloopControl.h:97
double ALLave_limFrac
Definition: AOloopControl.h:239
int_fast8_t AOloopControl_setlimitrange(long m0, long m1, float limval)
Definition: AOloopControl.c:16953
double ALLave_OLrms
Definition: AOloopControl.h:236
uint_fast16_t DMmodesNBblock
Definition: AOloopControl.h:137
int_fast8_t AOloopControl_statusStats(int updateconf)
Definition: AOloopControl.c:14543
float wfsmextrlatency
Definition: AOloopControl.h:51
int_fast8_t AOloopControl_OptimizePSF_LO(const char *psfstream_name, const char *IDmodes_name, const char *dmstream_name, long delayframe, long NBframes)
Definition: AOloopControl.c:16182
uint_fast64_t cnt
Definition: AOloopControl.h:72
double RMSmodes
Definition: AOloopControl.h:214
float AUTOTUNE_LIMITS_delta
Definition: AOloopControl.h:169
int_fast8_t init_CM
Definition: AOloopControl.h:79
static void * compute_function_imtotal(void *ptr)
double ALL_OLrms
Definition: AOloopControl.h:224
int_fast8_t AOloopControl_AveStream(const char *IDname, double alpha, const char *IDname_out_ave, const char *IDname_out_AC, const char *IDname_out_RMS)
Definition: AOloopControl.c:2993
int_fast8_t AOloopControl_mkCalib_map_mask(long loop, const char *zrespm_name, const char *WFSmap_name, const char *DMmap_name, float dmmask_perclow, float dmmask_coefflow, float dmmask_perchigh, float dmmask_coeffhigh, float wfsmask_perclow, float wfsmask_coefflow, float wfsmask_perchigh, float wfsmask_coeffhigh)
Definition: AOloopControl.c:6359
uint_fast16_t framesAve
Definition: AOloopControl.h:160
float loopfrequ
Definition: AOloopControl.h:40
int_fast8_t AOloopControl_AUTOTUNE_LIMITS_off()
Definition: AOloopControl.c:13589
int_fast8_t compute_ControlMatrix(long loop, long NB_MODE_REMOVED, const char *ID_Rmatrix_name, const char *ID_Cmatrix_name, const char *ID_VTmatrix_name, double Beta, long NB_MODE_REMOVED_STEP, float eigenvlim)
Computes control matrix using SVD.
Definition: AOloopControl.c:9575
int_fast8_t AUTOTUNE_LIMITS_ON
Definition: AOloopControl.h:166
int_fast8_t AOloopControl_setgainrange(long m0, long m1, float gainval)
Definition: AOloopControl.c:16925
int_fast8_t AOloopControl_setgainblock(long mb, float gainval)
Definition: AOloopControl.c:17007
float wfsmextrlatency_frame
Definition: AOloopControl.h:52
uint_fast64_t RMSmodesCumulcnt
Definition: AOloopControl.h:216
long AOloopControl_Measure_WFSrespC(long loop, long delayfr, long delayRM1us, long NBave, long NBexcl, const char *IDpokeC_name, const char *IDoutC_name, int normalize, int AOinitMode, long NBcycle)
Acquire WFS response to a series of DM pattern.
Definition: AOloopControl.c:4211
int_fast8_t set_DM_modes(long loop)
Definition: AOloopControl.c:10836
int_fast8_t AOloopControl_showparams(long loop)
Definition: AOloopControl.c:14908
long AOloopControl_Measure_WFS_linResponse(long loop, float ampl, long delayfr, long delayRM1us, long NBave, long NBexcl, const char *IDpokeC_name, const char *IDrespC_name, const char *IDwfsref_name, int normalize, int AOinitMode, long NBcycle)
Definition: AOloopControl.c:4541
float complatency
Definition: AOloopControl.h:47
long AOloopControl_mkTestDynamicModeSeq(const char *IDname_out, long NBpt, long NBmodes)
Definition: AOloopControl.c:17096
double ALL_limFrac
Definition: AOloopControl.h:227
Definition: AOloopControl.h:258
int_fast8_t init_CMc
Definition: AOloopControl.h:80
static void AOloopControl_logFunctionCall(const int logfuncMODE, const char *FunctionName, const long line, char *comments)
Log function call (for testing / debugging only).
int_fast8_t AOloopControl_CompModes_loop(const char *ID_CM_name, const char *ID_WFSref_name, const char *ID_WFSim_name, const char *ID_WFSimtot_name, const char *ID_coeff_name)
Definition: AOloopControl.c:11401
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_perc(float AUTOTUNE_LIMITS_perc)
Definition: AOloopControl.c:13629
long AOloopControl_computeWFSresidualimage(long loop, float alpha)
Definition: AOloopControl.c:11750
long AOloopControl_Measure_zonalRM(long loop, double ampl, long delayfr, long delayRM1us, long NBave, long NBexcl, const char *zrespm_name, const char *WFSref_name, const char *WFSmap_name, const char *DMmap_name, long mode, int normalize, int AOinitMode, long NBcycle)
Definition: AOloopControl.c:4642
uint_fast64_t DMupdatecnt
Definition: AOloopControl.h:74
int_fast8_t AOloopControl_ARPFoff()
Definition: AOloopControl.c:13734
float hardwlatency
Definition: AOloopControl.h:43
long compute_CombinedControlMatrix(const char *IDcmat_name, const char *IDmodes_name, const char *IDwfsmask_name, const char *IDdmmask_name, const char *IDcmatc_name, const char *IDcmatc_active_name)
Definition: AOloopControl.c:9910
uint_fast64_t WFScnt
Definition: AOloopControl.h:101
double ALL_WFSrms
Definition: AOloopControl.h:226
int_fast8_t status
Definition: AOloopControl.h:54
int_fast8_t kill
Definition: AOloopControl.h:75
long AOloopControl_ComputeOpenLoopModes(long loop)
Definition: AOloopControl.c:11880
int_fast8_t AOloopControl_WFSzeropoint_sum_update_loop(long loopnb, const char *ID_WFSzp_name, int NBzp, const char *IDwfsref0_name, const char *IDwfsref_name)
Definition: AOloopControl.c:10379
int_fast8_t AOloopControl_setlimitblock(long mb, float limitval)
Definition: AOloopControl.c:17029
int_fast8_t AOloopControl_loopon()
Definition: AOloopControl.c:13386
long AOloopControl_mkHadamardModes(const char *DMmask_name, const char *outname)
Definition: AOloopControl.c:5782
int_fast8_t statusM
Definition: AOloopControl.h:55
int_fast8_t AUTOTUNE_GAINS_ON
Definition: AOloopControl.h:171
uint_fast32_t sizexDM
Definition: AOloopControl.h:120
uint_fast32_t sizeDM_active
Definition: AOloopControl.h:124
long AOloopControl_Hadamard_decodeRM(const char *inname, const char *Hmatname, const char *indexname, const char *outname)
Definition: AOloopControl.c:5914
uint_fast32_t sizeDM
Definition: AOloopControl.h:122
int_fast8_t AOloopControl_InjectMode(long index, float ampl)
Definition: AOloopControl.c:15472
char * line
Definition: CLIcore.c:121
float WFSnormfloor
Definition: AOloopControl.h:105
int_fast8_t AOloopControl_printloopstatus(long loop, long nbcol, long IDmodeval_dm, long IDmodeval, long IDmodevalave, long IDmodevalrms, long ksize)
Definition: AOloopControl.c:14191
int_fast8_t AOloopControl_AnalyzeRM_sensitivity(const char *IDdmmodes_name, const char *IDdmmask_name, const char *IDwfsref_name, const char *IDwfsresp_name, const char *IDwfsmask_name, float amplimitnm, float lambdanm, const char *foutname)
Definition: AOloopControl.c:15989
long AOloopControl_sig2Modecoeff(const char *WFSim_name, const char *IDwfsref_name, const char *WFSmodes_name, const char *outname)
Definition: AOloopControl.c:11660
float WFStotalflux
Definition: AOloopControl.h:106
static int_fast8_t AOloopControl_loadconfigure(long loop, int mode, int level)
int_fast8_t AOloopControl_logprocess_modeval(const char *IDname)
Definition: AOloopControl.c:16483
int_fast8_t AOloopControl_camimage_extract2D_sharedmem_loop(const char *in_name, const char *dark_name, const char *out_name, long size_x, long size_y, long xstart, long ystart)
Definition: AOloopControl.c:3596
float AUTOTUNE_LIMITS_mcoeff
Definition: AOloopControl.h:168
uint_fast32_t sizeWFS
Definition: AOloopControl.h:98
uint_fast64_t cntmax
Definition: AOloopControl.h:73
long AOloopControl_builPFloop_WatchInput(long loop, long PFblock)
Definition: AOloopControl.c:13136
int_fast8_t AOloopControl_loopoff()
Definition: AOloopControl.c:13409
long AOloopControl_mkModes_Simple(const char *IDin_name, long NBmblock, long Cmblock, float SVDlim)
Definition: AOloopControl.c:9318
long AOloopControl_loadCM(long loop, const char *CMfname)
Definition: AOloopControl.c:10139
int_fast8_t AOcontrolLoop_TestDMSpeed(const char *dmname, long delayus, long NBpts, float ampl)
Definition: AOloopControl.c:14939
long AOloopControl_mkModes(const char *ID_name, long msizex, long msizey, float CPAmax, float deltaCPA, double xc, double yx, double r0, double r1, int MaskMode, int BlockNB, float SVDlim)
Definition: AOloopControl.c:7374
int_fast8_t AOloopControl_AutoTune()
Definition: AOloopControl.c:17144
int_fast8_t init_AOloopControl()
Initialize AOloopControl command line interface.
Definition: AOloopControl.c:1108
float ARPFgain
Definition: AOloopControl.h:185
uint_fast32_t sizexWFS
Definition: AOloopControl.h:96
int_fast8_t AOloopControl_set_modeblock_gain(long loop, long blocknb, float gain, int add)
Definition: AOloopControl.c:13973
int_fast8_t initmapping
Definition: AOloopControl.h:81
int_fast8_t AOloopControl_ProcessZrespM_medianfilt(long loop, const char *zrespm_name, const char *WFSref0_name, const char *WFSmap_name, const char *DMmap_name, double rmampl, int normalize)
Definition: AOloopControl.c:6646
float AUTOTUNE_LIMITS_perc
Definition: AOloopControl.h:167
long AOloopControl_RespMatrix_Fast(const char *DMmodes_name, const char *dmRM_name, const char *imWFS_name, long semtrig, float HardwareLag, float loopfrequ, float ampl, const char *outname)
Definition: AOloopControl.c:5596
int_fast8_t AOloopControl_DMprimaryWrite_off()
Definition: AOloopControl.c:13544
long AOloopControl_DMslaveExt(const char *IDin_name, const char *IDmask_name, const char *IDsl_name, const char *IDout_name, float r0)
Definition: AOloopControl.c:7239
int_fast8_t AOloopControl_setframesAve(long nbframes)
Definition: AOloopControl.c:13952
int_fast8_t AOloopControl_Process_zrespM(long loop, const char *IDzrespm0_name, const char *IDwfsref_name, const char *IDzrespm_name, const char *WFSmap_name, const char *DMmap_name)
Definition: AOloopControl.c:6501
int_fast8_t AOLCOMPUTE_TOTAL_ASYNC
Definition: AOloopControl.h:199
long AOloopControl_mkCM(const char *respm_name, const char *cm_name, float SVDlim)
Definition: AOloopControl.c:6957
double ALLave_Crms
Definition: AOloopControl.h:237
int_fast8_t AOloopControl_setmultfblock(long mb, float multfval)
Definition: AOloopControl.c:17050
int_fast8_t AOloopControl_set_hardwlatency_frame(float hardwlatency_frame)
Definition: AOloopControl.c:13781
int_fast8_t AOloopControl_setWFSnormfloor(float WFSnormfloor)
Definition: AOloopControl.c:13888
int_fast8_t AOloopControl_AutoTuneGains(long loop, const char *IDout_name)
Definition: AOloopControl.c:12459
int_fast8_t WFSnormalize
Definition: AOloopControl.h:104
int_fast8_t ControlMatrixMultiply(float *cm_array, float *imarray, long m, long n, float *outvect)
Definition: AOloopControl.c:10818
float complatency_frame
Definition: AOloopControl.h:48
int_fast8_t AOloopControl_loopMonitor(long loop, double frequ, long nbcol)
Definition: AOloopControl.c:14392