cacao  Release 0.1.03-dev
Compute And Control For Adaptive Optics
AOloopControl.h
Go to the documentation of this file.
1 
14 #include <stdint.h>
15 #include <stdio.h>
16 #include <time.h>
17 
19 #include "AOloopControl/AOloopControl_aorun.h" // AOLOOPCONF_WFSim
24 
25 
26 #ifndef _AOLOOPCONTROL_H
27 #define _AOLOOPCONTROL_H
28 
29 
30 
31 
32 
33 // OVERVIEW
34 
35 
36 // AOloopControl_var
37 // structure unique to specific process
38 // used for convenience to store process-specific values, for example image IDs
39 
40 // AOLOOPCONTROL_CONF
41 // shared memory structure for sharing between processes and provide outside control and visibility
42 
43 
44 
45 
46 // PROCESSES
47 /*
48  * AO loop can launch a number of processes
49  *
50  *
51  *
52  * All AO loop instances MUST start a AOloopControl_aorun() function call
53  * FUNCTION: AOloopControl_aorun()
54  * in file : AOloopControl_aorun.c
55  * AOloopControl_aorun() -> AOcompute() -> Read_cam_frame()
56  *
57  *
58  *
59  *
60  * FUNCTION: AOloopControl_ProcessModeCoefficients()
61  * in file : AOloopControl_aorun.c
62  *
63  *
64  *
65  */
66 
67 
68 
69 
70 
71 
72 #define MAX_NUMBER_TIMER 100
73 
74 
75 
76 
77 
78 
79 
80 // REAL TIME DATA LOGGING
81 
82 //
83 // Real-time streams are updated once per loop iteration
84 // Realtime logging buffers are synchronized
85 // Two buffers are created for each stream to be logged
86 //
87 // Saving to disk is handled outside of cacao real-time
88 //
89 
90 
91 #define MAX_NUMBER_RTLOGSTREAM 20
92 
93 #define RTSLOGindex_wfsim 0
94 #define RTSLOGindex_imWFS0 1
95 #define RTSLOGindex_imWFS1 2
96 #define RTSLOGindex_imWFS2 3
97 #define RTSLOGindex_modeval 4
98 #define RTSLOGindex_modeval_dm 5
99 #define RTSLOGindex_modeval_dm_corr 6
100 #define RTSLOGindex_modeval_dm_now 7
101 #define RTSLOGindex_modeval_dm_now_filt 8
102 #define RTSLOGindex_modevalPF 9
103 #define RTSLOGindex_modevalPFsync 10
104 #define RTSLOGindex_modevalPFres 11
105 #define RTSLOGindex_modeval_ol 12
106 #define RTSLOGindex_dmC 13
107 #define RTSLOGindex_dmdisp 14
108 
109 
110 
111 // Real-time streams use this struc to hold relevant info
112 
113 //int RTLOG_ON; // set to 1 to start logging all RT streams -> ensures synchronization
114 //int RTstreamLOG_buff; // Which buffer is currently being written (0 or 1)
115 //long RTstreamLOG_frame; // Which frame is to be written in buffer
116 //int RTstreamLOG_buffSwitch; // Goes to 1 when buffer switches. Goes back to zero on next iteration.
117 
118 // For each stream, there are two data buffers and two timing buffers
119 // Buffer names:
120 // aol%ld_<stream>_logbuff0
121 // aol%ld_<stream>_logbuff1
122 // aol%ld_<stream>_logbuffinfo0
123 // aol%ld_<stream>_logbuffinfo1
124 //
125 // Timing buffer contains loop iteration, frame counter cnt0 and time stamps when entry is written
126 //
127 
128 // ENABLES, ON and save are read/set up in AOloopControl_loadconfigure()
129 
130 typedef struct
131 {
132  int active; // 1 if used
133  char name[100]; // stream name (excludes aol#_)
134  int ENABLE; // Is logging enabled ? This needs to be specified at startup, if set to zero, no RT logging will be performed
135  int INIT; // 1 if memory is initiated
136  int ON; // Is logging ON ?
137  uint32_t SIZE; // Max number of samples per buffer
138  int buffindex; // which buffer (0 or 1)
139  long frameindex; // frame index
140  long frameindexend0; // last frame in buffer 0
141  long frameindexend1; // last frame in buffer 1
142  int save; // 0: do not save, 1: save data+timing, 2: save timing only
143  int memcpToggle; // 1 if file buffer #0 ready to be memcpied, 2 if file buffer #1 ready to be memcpied, 0 otherwise
144 
145  long IDbuff;
146  long IDbuff0; // local identifier
147  long IDbuff1; // local identifier
148 
150  long IDbuffinfo0; // local identifier
151  long IDbuffinfo1; // local identifier
152 
153  float *srcptr; // source stream pointer
154  long IDsrc; // source ID
155 
156  char *destptr; // destination pointer
157  char *destptr0; // destination pointer 0
158  char *destptr1; // destination pointer 1
159 
160  size_t memsize; // size of stream frame (byte)
161  int NBcubeSaved; // Number of cubes to save, default = -1
162 
163 
164 
165  int NBFileBuffer; // Number of buffers per big file
166  int FileBuffer; // File buffer index
167  char timestring[100]; // current timestring
168  char timestring0[100]; // timestring for file to be saved to
169 
170  int tActive; // 1: save thread is active, 0 otherwise
171 
172 } RTstreamLOG;
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 // LOGGING
183 //#define RT_LOGsize 30000
184 
185 
186 
187 // logging
188 //static int loadcreateshm_log = 0; // 1 if results should be logged in ASCII file
189 //static FILE *loadcreateshm_fplog;
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
207 typedef struct
208 {
209 
210  char name[80]; // AO loop name
211 
212 
213  // These structures are always part of AO loop control (not optional)
214 
215  // High level AO loop parameters and variables
216  // includes both status and some top level control (gain, mult, max)
218  aorun; // defined in AOloopControl_aorun.h
219 
220  // Wavefront sensor image
222  WFSim; // defined in AOloopControl_aorun.h
223 
224  // AO loop timing parameters
226  AOtiminginfo; // defined in AOloopControl_aorun.h
227 
228  // Computation parameters
230  AOcompute; // defined in AOloopControl_AOcompute.h
231 
232  // DM control
234  DMctrl; // defined in AOloopControl_dm.h
235 
236  // Modal control
238  AOpmodecoeffs; // defined in AOloopControl_ProcessModeCoefficients.h
239 
240  // Automatic loop tuning (experimental)
242  AOAutoTune; // defined in AOloopControl_autotune.h
243 
244 
245  // Realtime logging
246  long
247  RTLOGsize; // Number of samples per shared memory stream
249 
250 
252 
253 
254 
255 
256 
257 
258 
259 
260 
261 
262 
263 
264 
265 
266 
267 typedef struct
268 {
269  /* =============================================================================================== */
270  /* aoconfID are global variables for convenience */
271  /* These variables are LOCAL to each process, and not shared between processes */
272  /* aoconfID can be used in other modules as well (with extern) */
273  /* =============================================================================================== */
274 
275  long LOOPNUMBER;// = 0; // current loop index
276 
277  // TIMING
278  //struct timespec tnow; //static
279  //struct timespec tdiff; //static
280  //double tdiffv; //static
281 
282  //int initWFSref_GPU[100];// = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
283  int initcontrMcact_GPU[100];// = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
284  //used in AOloopControl_loop_param.c
285  // static
286 
287  float GPU_alpha;
288  float GPU_beta;
289 
290 
292  // local copies to avoid reset to zero by other process
293  int_fast8_t init_RM_local;
294  int_fast8_t init_CM_local;
295  int_fast8_t
299  int COMPUTE_PIXELSTREAMING; // static. multiple pixel groups
300  int PIXSTREAM_NBSLICES;// number of image slices (= pixel groups)
301  int PIXSTREAM_SLICE; // slice index 0 = all pixels
302 
303 
304  // Logging REAL TIME data (internal logging)
305  // (note: non real time streams are logged externally)
306  //
307  // To optimize logging speed, each stream can be logged in a 3D data cube within the function where it is created.
308  // 3rd axis is time
309  // A timing array is also created.
310  //
311  // List of REAL TIME streams logged with the internal process
312  //
313  //
314  // wfsim logged in function ??
315  // modeval_ol logged in function AOloopControl_ProcessModeCoefficients
316  //
317 
318 
319 
320  //
321  // Shared between REAL TIME STREAMS:
322  //
323  // streamLOG_buff which buffer to use (0 or 1) -> in AOLOOPCONTROL_CONF (needs to be shared and visible)
324  // streamLOG_frame frame index within buffer -> in AOLOOPCONTROL_CONF (needs to be shared and visible)
325  // streamLOG_saveToggle 1 to force a save now -> in AOLOOPCONTROL_CONF (needs to be shared and visible)
326  //
327  //
328  // For each REAL TIME stream <sname> :
329  //
330  // aoconfLOG_<sname>_databuffID0 logging data buffer 0 ID
331  // aoconfLOG_<sname>_databuffID1 logging data buffer 1 ID
332  // aoconfLOG_<sname>_infobuff0 logging info buffer 0
333  // aoconfLOG_<sname>_infobuff1 logging info buffer 1
334  // aoconfLOG_<sname>_databuffID active data buffer ID
335  // aoconfLOG_<sname>_infobuff active info buffer pointer
336  //
337  // streamLOG_<sname>_ON - NEEDS TO BE SET UP AT STARTUP -> in AOLOOPCONTROL_CONF (needs to be shared and visible)
338  // 0 : No logging, no writing into 3D cube
339  // 1 : Create 3D cube and write into it
340  // streamLOG_<sname>_save 1 if saved to disk -> in AOLOOPCONTROL_CONF (needs to be shared and visible)
341 
342 
343 
344 
345 
346  // Hardware connections
347 
348  // WFS image
349  long aoconfID_wfsim; // identifier to stream
350  uint8_t WFSatype;
351 
352  /*LOG
353 
354  long aoconfLOG_wfsim_buffID0; // buffer 0
355  long aoconfLOG_wfsim_buffID1; // buffer 1
356  long aoconfLOG_wfsim_timerbuffID0; // timer buffer 0
357  long aoconfLOG_wfsim_timerbuffID1; // timer buffer 1
358  long aoconfLOG_wfsim_buffID; // active buffer ID
359  long aoconfLOG_wfsim_timerbuffID; // active timer buffer ID
360  */
361 
364 
365 
366 
367 
368 
370 
371  long aoconfID_imWFS0; // identifier to stream
372 
374 
376 
378 
379 
380  long aoconfID_imWFSlinlimit; // WFS linearity limit
381 
385 
387  long aoconfID_dmdisp; // to notify DMcomb that DM maps should be summed
388 
389 
390 
391  // Control Modes
393  long aoconfID_meas_modes; // measured
398 
399  // mode gains, multf, limit are set in 3 tiers
400  // global gain
401  // block gain
402  // individual gains
403 
404  // blocks
405  long aoconfID_gainb; // block modal gains
406  long aoconfID_multfb; // block modal gains
407  long aoconfID_limitb; // block modal gains
408 
409  // individual modesaol0PFb1comp:
413 
415 
418 
419  //long aoconfID_respM;// = -1; static
420  //only in loadconfigure.c
421 
422  long aoconfID_contrM;// pixels -> modes
423 
424  //long long aoconfcnt0_contrM_current;// = -1; static
425 
426  long aoconfID_contrMc;// combined control matrix: pixels -> DM actuators
428  long aoconfID_contrMcact[100];
429 
430  //static
431  // pixel streaming
432  long aoconfID_pixstream_wfspixindex; // index of WFS pixels
433 
434  // timing
435  long aoconfID_looptiming;// control loop timing data. Pixel values correspond to time offset
436  // currently has 20 timing slots
437  // beginning of iteration is defined when entering "wait for image"
438  // md[0].atime.ts is absolute time at beginning of iteration
439  //
440  // pixel 0 is dt since last iteration
441  //
442  // pixel 1 is time from beginning of loop to status 01
443  // pixel 2 is time from beginning of loop to status 02
444  // ...
446 
448  //long aoconfIDlog0;// = -1; static
449  //long aoconfIDlog1;// = -1; static
450  // those two last don't exist in any functions
451 
452 
453  int *WFS_active_map; // used to map WFS pixels into active array
454  int *DM_active_map; // used to map DM actuators into active array
456  //long aoconfID_imWFS2_active[100]; wfs_dm.c & computeCalib.c
457 
458  float normfloorcoeff;// = 1.0; static
459 
460  //long wfsrefcnt0;// = -1; static
461  //long contrMcactcnt0[100];// static = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};;
462  //both in wfs_dm.c
463 
464  // variables used by functions
465 
466  //int GPUcntMax;// = 100; static initmem.c
467  int *GPUset0; //static
468  int *GPUset1; //static
469 
470 
471 
472  // Realtime logging, local init flag
473  // will be equal to 1 only if the current process "owns" the realtime logging
474  int RTSLOGarrayInitFlag[MAX_NUMBER_RTLOGSTREAM];
475 
476 
478 
479 
480 
481 
482 
483 
484 void __attribute__((constructor)) libinit_AOloopControl();
485 
486 
488 
490  long loop,
491  double frequ
492 );
493 
494 
495 
496 
497 
498 
499 
500 
501 
502 
503 
504 
505 /* =============================================================================================== */
507 /* =============================================================================================== */
509 float AOloopControl_readParam_float(char *paramname, float defaultValue,
510  FILE *fplog);
511 
513 int AOloopControl_readParam_int(char *paramname, int defaultValue, FILE *fplog);
514 
516 char *AOloopControl_readParam_string(char *paramname, char *defaultValue,
517  FILE *fplog);
518 
519 
520 /* =============================================================================================== */
521 /* =============================================================================================== */
527 /* =============================================================================================== */
528 /* =============================================================================================== */
529 
531 errno_t AOloopControl_loadconfigure(long loop, int mode, int level);
532 
533 
536  int mode
537 );
538 
539 
540 /* =============================================================================================== */
541 /* =============================================================================================== */
544 /* =============================================================================================== */
545 /* =============================================================================================== */
546 
549  const char *IDzpdm_name,
550  const char *IDzrespM_name,
551  const char *IDwfszp_name
552 );
553 
554 
557  long loopnb,
558  const char *ID_WFSzp_name,
559  int NBzp,
560  const char *IDwfsref0_name,
561  const char *IDwfsref_name
562 );
563 
565 int AOloopControl_aorun_RUN(char *fpsname);
566 int AOloopControl_aorun_FPCONF(char *fpsname, uint32_t CMDmode);
568 
569 
570 
572 errno_t ControlMatrixMultiply(float *cm_array, float *imarray, long m, long n,
573  float *outvect);
574 
576 errno_t set_DM_modes(long loop);
577 
579 errno_t set_DM_modesRM(long loop);
580 
582 errno_t AOcompute(long loop, int normalize);
583 
585 errno_t AOloopControl_CompModes_loop(const char *ID_CM_name,
586  const char *ID_WFSref_name, const char *ID_WFSim_name,
587  const char *ID_WFSimtot_name, const char *ID_coeff_name);
588 
590 errno_t AOloopControl_GPUmodecoeffs2dm_filt_loop(const int GPUMATMULTCONFindex,
591  const char *modecoeffs_name, const char *DMmodes_name, int semTrigg,
592  const char *out_name, int GPUindex, long loop, int offloadMode);
593 
595 long AOloopControl_sig2Modecoeff(const char *WFSim_name,
596  const char *IDwfsref_name, const char *WFSmodes_name, const char *outname);
597 
599 long AOloopControl_computeWFSresidualimage(long loop, char *IDalpha_name);
600 
602 imageID __attribute__((hot)) AOloopControl_ProcessModeCoefficients(
603  long loop
604 );
605 
607 errno_t AOloopControl_AutoTuneGains(long loop, const char *IDout_name,
608  float GainCoeff, long NBsamples);
609 
611 long AOloopControl_dm2dm_offload(const char *streamin, const char *streamout,
612  float twait, float offcoeff, float multcoeff);
613 
614 
615 
616 /* =============================================================================================== */
617 /* =============================================================================================== */
620 /* =============================================================================================== */
621 /* =============================================================================================== */
622 
625 
627 errno_t AOloopControl_setparam(long loop, const char *key, double value);
628 
629 
630 /* =============================================================================================== */
633 /* =============================================================================================== */
634 
637 
640 
643 
646 
649 
651 errno_t AOloopControl_loopstep(long loop, long NBstep);
652 
655 
656 
657 /* =============================================================================================== */
659 /* =============================================================================================== */
660 
661 // NB : doesn't exist anywhere ??
664 
667 
668 
669 /* ============================================================================================================ */
671 /* ============================================================================================================ */
672 
675 
678 
681 
684 
685 
686 /* ====================================================================================================== */
688 /* ====================================================================================================== */
689 
692 
695 
701 errno_t AOloopControl_set_AUTOTUNE_LIMITS_delta(float AUTOTUNE_LIMITS_delta);
702 errno_t AOloopControl_set_AUTOTUNE_LIMITS_perc(float AUTOTUNE_LIMITS_perc);
703 errno_t AOloopControl_set_AUTOTUNE_LIMITS_mcoeff(float AUTOTUNE_LIMITS_mcoeff);
704 
707 
710 
711 /* ======================================================================================================== */
713 /* ======================================================================================================== */
714 
717 
720 
721 /* =================================================================================================== */
723 /* =================================================================================================== */
724 
726 errno_t AOloopControl_set_loopfrequ(float loopfrequ);
727 
729 errno_t AOloopControl_set_hardwlatency_frame(float hardwlatency_frame);
730 
732 errno_t AOloopControl_set_complatency_frame(float complatency_frame);
733 
737 errno_t AOloopControl_set_wfsmextrlatency_frame(float wfsmextrlatency_frame);
738 
739 /* ========================================================================================================= */
741 /* ========================================================================================================= */
742 
745 
747 errno_t AOloopControl_setgain(float gain);
748 
753 
754 
757 
760 
761 
763 errno_t AOloopControl_setWFSnormfloor(float WFSnormfloor);
764 
766 errno_t AOloopControl_setmaxlimit(float maxlimit);
767 
769 errno_t AOloopControl_setmult(float multcoeff);
770 
772 errno_t AOloopControl_setframesAve(long nbframes);
773 
775 errno_t AOloopControl_set_modeblock_gain(long loop, long blocknb, float gain,
776  int add);// modal blocks
777 
779 errno_t AOloopControl_scanGainBlock(long NBblock, long NBstep, float gainStart,
780  float gainEnd, long NBgain);
781 
782 
783 
784 /* =============================================================================================== */
785 /* =============================================================================================== */
788 /* =============================================================================================== */
789 /* =============================================================================================== */
790 
792 errno_t AOloopControl_OptimizePSF_LO(const char *psfstream_name,
793  const char *IDmodes_name, const char *dmstream_name, long delayframe,
794  long NBframes);
795 
797 errno_t AOloopControl_DMmodulateAB(const char *IDprobeA_name,
798  const char *IDprobeB_name, const char *IDdmstream_name,
799  const char *IDrespmat_name, const char *IDwfsrefstream_name, double delay,
800  long NBprobes);
801 
802 
803 
804 
805 /* =============================================================================================== */
806 /* =============================================================================================== */
809 /* =============================================================================================== */
810 /* =============================================================================================== */
811 
814  const char *IDname
815 );
816 
819  char *ZRMinname,
820  char *DMinCname,
821  char *WFSinCname,
822  char *DMmaskname,
823  char *WFSmaskname,
824  char *RMoutname
825 );
826 
827 
828 
829 
830 
831 /* =============================================================================================== */
832 /* =============================================================================================== */
835 /* =============================================================================================== */
836 /* =============================================================================================== */
837 
839  int loop
840 );
841 
842 
844  long loop,
845  long rtlindex,
846  char *streamname
847 );
848 
850  long loop,
851  long rtlindex,
852  struct timespec tnow
853 );
854 
856  int loop
857 );
858 
859 int AOloopControl_RTstreamLOG_GUI(int loop);
860 int AOloopControl_RTstreamLOG_saveloop(int loop, char *dirname);
861 
862 int AOloopControl_RTstreamLOG_set_saveON(int loop, int rtlindex);
863 int AOloopControl_RTstreamLOG_set_saveOFF(int loop, int rtlindex);
864 int AOloopControl_RTstreamLOG_set_ON(int loop, int rtlindex);
865 int AOloopControl_RTstreamLOG_set_OFF(int loop, int rtlindex);
866 
867 /* =============================================================================================== */
868 /* =============================================================================================== */
870 /* =============================================================================================== */
871 /* =============================================================================================== */
872 
873 // "old" blocks (somewhat obsolete)
874 errno_t AOloopControl_setgainrange(long m0, long m1, float gainval);
875 errno_t AOloopControl_setlimitrange(long m0, long m1, float limval);
876 errno_t AOloopControl_setmultfrange(long m0, long m1, float multfval);
877 errno_t AOloopControl_setgainblock(long mb, float gainval);
878 errno_t AOloopControl_setlimitblock(long mb, float limitval);
879 errno_t AOloopControl_setmultfblock(long mb, float multfval);
880 
882 
883 
884 
885 #endif
errno_t AOloopControl_set_AUTOTUNE_LIMITS_mcoeff(float AUTOTUNE_LIMITS_mcoeff)
Definition: AOloopControl_autotune.c:117
errno_t AOloopControl_logoff()
Log off AO interface.
Definition: AOloopControl_ProcessModeCoefficients.h:9
errno_t AOloopControl_set_AUTOTUNE_LIMITS_delta(float AUTOTUNE_LIMITS_delta)
Options auto tune limit The limit is fixed at the beginning. When the fraction of mode values higher ...
Definition: AOloopControl_autotune.c:93
long IDsrc
Definition: AOloopControl.h:154
int AOloopControl_RTstreamLOG_set_saveOFF(int loop, int rtlindex)
Definition: AOloopControl_RTstreamLOG.c:876
errno_t AOloopControl_set_wfsmextrlatency_frame(float wfsmextrlatency_frame)
Set computation latency of filtered DM write mode time between the moment where the WF arrives at the...
Definition: AOloopControl_time_param.c:75
errno_t ControlMatrixMultiply(float *cm_array, float *imarray, long m, long n, float *outvect)
CPU based matrix-vector multiplication - when no GPU.
Definition: AOloopControl_wfs.c:359
errno_t AOloopControl_setLoopNumber(long loop)
Set loop number. Ex : for the Pyramid WFS, loop number = 0.
Definition: AOloopControl_loop_ctr.c:35
long aoconfID_MULTF_modes
Definition: AOloopControl.h:412
int memcpToggle
Definition: AOloopControl.h:143
errno_t AOloopControl_InitializeMemory(int mode)
Initialize memory - function called within C code only (no CLI call)
Definition: AOloopControl_initmem.c:56
float GPU_beta
Definition: AOloopControl.h:288
long aoconfID_dmmask
Definition: AOloopControl.h:417
long aoconfID_multfb
Definition: AOloopControl.h:406
long aoconfID_meas_modes
Definition: AOloopControl.h:393
Definition: AOloopControl.h:267
int PIXSTREAM_NBSLICES
Definition: AOloopControl.h:300
AOLOOPCONF_AutoTune AOAutoTune
Definition: AOloopControl.h:242
errno_t AOloopControl_AUTOTUNE_GAINS_on()
Set gain auto tune : on.
Definition: AOloopControl_autotune.c:128
size_t memsize
Definition: AOloopControl.h:160
int_fast8_t init_CMc_local
Definition: AOloopControl.h:296
long aoconfID_AVE_modes
Definition: AOloopControl.h:395
long frameindex
Definition: AOloopControl.h:139
errno_t AOloopControl_loopstep(long loop, long NBstep)
Close loop for finite number of steps.
Definition: AOloopControl_loop_onoff.c:121
Function prototypes for Adaptive Optics Control loop engine I/O tools.
errno_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)
Main computation function, runs once per loop iteration.
long aoconfID_imWFS0tot
Definition: AOloopControl.h:373
long IDbuffinfo
Definition: AOloopControl.h:149
errno_t AOloopControl_logon()
Log on the AO interface.
Definition: AOloopControl_autotune.h:8
errno_t set_DM_modesRM(long loop)
Response Matrix DM-WFS.
Definition: AOloopControl_dm.c:176
errno_t AOloopControl_loadconfigure(long loop, int mode, int level)
Load configuation parameters from disk - AOloopControl_loadconfigure.c.
Definition: AOloopControl_loadconfigure.c:69
float AOloopControl_readParam_float(char *paramname, float defaultValue, FILE *fplog)
Read parameter value - float, char or int - AOloopControl_read_param.c.
Definition: AOloopControl_read_param.c:61
Definition: AOloopControl.h:207
errno_t AOloopControl_setgainrange(long m0, long m1, float gainval)
Definition: AOloopControl.c:2338
AOloopTimingInfo AOtiminginfo
Definition: AOloopControl.h:226
errno_t AOloopControl_GPUmodecoeffs2dm_filt_loop(const int GPUMATMULTCONFindex, const char *modecoeffs_name, const char *DMmodes_name, int semTrigg, const char *out_name, int GPUindex, long loop, int offloadMode)
Matrix multiplication on GPU to transfom modes coefficients into DM shape.
Definition: AOloopControl_dm.c:219
int AOloopControl_readParam_int(char *paramname, int defaultValue, FILE *fplog)
read parameters int
Definition: AOloopControl_read_param.c:126
long aoconfID_contrM
Definition: AOloopControl.h:422
long aoconfID_dmRM
Definition: AOloopControl.h:363
long aoconfID_looptiming
Definition: AOloopControl.h:435
errno_t AOcompute(long loop, int normalize)
Main computation function, runs once per loop iteration.
int save
Definition: AOloopControl.h:142
long aoconfID_RMS_modes
Definition: AOloopControl.h:394
int AOloopControl_RTstreamLOG_saveloop(int loop, char *dirname)
Definition: AOloopControl_RTstreamLOG.c:955
long aoconfID_imWFSlinlimit
Definition: AOloopControl.h:380
long aoconfID_DMmodes
Definition: AOloopControl.h:386
int AOloopControl_RTstreamLOG_printstatus(int loop)
Definition: AOloopControl_RTstreamLOG.c:424
errno_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)
Experimental dm modulation.
Definition: AOloopControl_fpspeckle_mod.c:119
long IDbuffinfo0
Definition: AOloopControl.h:150
int INIT
Definition: AOloopControl.h:135
errno_t AOloopControl_AUTOTUNE_GAINS_off()
Set gain auto tune : off.
Definition: AOloopControl_autotune.c:140
long aoconfID_wfsdark
Definition: AOloopControl.h:369
Definition: AOloopControl_aorun.h:60
int ON
Definition: AOloopControl.h:136
float normfloorcoeff
Definition: AOloopControl.h:458
long aoconfID_dmC
Definition: AOloopControl.h:362
int ENABLE
Definition: AOloopControl.h:134
long AOloopControl_dm2dm_offload(const char *streamin, const char *streamout, float twait, float offcoeff, float multcoeff)
Mixes streamin into streamout, in order to make streamout converge to streamin.
Definition: AOloopControl_dm.c:439
long aoconfIDlogdata
Definition: AOloopControl.h:447
AOLOOPCONF_ProcessModeCoefficients AOpmodecoeffs
Definition: AOloopControl.h:238
errno_t AOloopControl_RTstreamLOG_init(int loop)
Definition: AOloopControl_RTstreamLOG.c:49
uint32_t SIZE
Definition: AOloopControl.h:137
int buffindex
Definition: AOloopControl.h:138
Definition: AOloopControl.h:130
errno_t AOloopControl_set_hardwlatency_frame(float hardwlatency_frame)
Set hardware latency in unity of frame.
Definition: AOloopControl_time_param.c:46
errno_t AOloopControl_setWFSnormfloor(float WFSnormfloor)
Coefficient attenuates AO correction in low loght level.
Definition: AOloopControl_loop_param.c:97
char * destptr0
Definition: AOloopControl.h:157
errno_t AOloopControl_setmultfrange(long m0, long m1, float multfval)
Definition: AOloopControl.c:2418
errno_t AOloopControl_aorun()
errno_t set_DM_modes(long loop)
Sends modal commands to DM by matrix-vector multiplication.
Definition: AOloopControl_dm.c:95
errno_t AOloopControl_loopoff()
Open AO loop : AO off.
Definition: AOloopControl_loop_onoff.c:59
errno_t AOloopControl_ARPFon()
ARPF = auto regressive predictive filter: on.
Definition: AOloopControl_arpf_onoff.c:33
errno_t AOloopControl_setARPFgainAutoMax(float val)
Set ARPF.
Definition: AOloopControl_loop_param.c:81
long aoconfID_wfsmask
Definition: AOloopControl.h:416
long RTLOGsize
Definition: AOloopControl.h:247
char * AOloopControl_readParam_string(char *paramname, char *defaultValue, FILE *fplog)
read parameters string
Definition: AOloopControl_read_param.c:191
int active
Definition: AOloopControl.h:132
int errno_t
Definition: AOloopControl_IOtools.h:20
errno_t AOloopControl_ARPFoff()
ARPF = auto regressive predictive filter: off.
Definition: AOloopControl_arpf_onoff.c:45
errno_t AOloopControl_set_AUTOTUNE_LIMITS_perc(float AUTOTUNE_LIMITS_perc)
Definition: AOloopControl_autotune.c:106
long imageID
Definition: CLIcore.h:54
int AOloopControl_RTstreamLOG_set_saveON(int loop, int rtlindex)
Definition: AOloopControl_RTstreamLOG.c:859
long aoconfID_wfsref0
Definition: AOloopControl.h:382
errno_t AOloopControl_loopWFScompoff()
Open AO loop : AO off.
Definition: AOloopControl_loop_onoff.c:94
int_fast8_t init_RM_local
Definition: AOloopControl.h:293
int NBcubeSaved
Definition: AOloopControl.h:161
errno_t AOloopControl_setRTLOG_OFF()
errno_t AOloopControl_logprocess_modeval(const char *IDname)
Log the process of the mode evaluation.
Definition: AOloopControl_process_files.c:36
Definition: AOloopControl_AOcompute.h:6
errno_t AOloopControl_setframesAve(long nbframes)
Set an average of frames.
int AOloopControl_aorun_FPCONF(char *fpsname, uint32_t CMDmode)
Definition: AOloopControl_aorun.c:214
errno_t AOloopControl_AUTOTUNE_LIMITS_on()
Set limit auto tune : on.
Definition: AOloopControl_autotune.c:31
int * WFS_active_map
Definition: AOloopControl.h:453
long aoconfID_limitb
Definition: AOloopControl.h:407
errno_t AOloopControl_loopWFScompon()
Close AO loop : AO on.
Definition: AOloopControl_loop_onoff.c:73
long AOcontrolNBtimers
Definition: AOloopControl.h:445
long aoconfID_cmd_modesRM
Definition: AOloopControl.h:414
long aoconfID_wfsref
Definition: AOloopControl.h:383
int * GPUset1
Definition: AOloopControl.h:468
Definition: AOloopControl_dm.h:6
float GPU_alpha
Definition: AOloopControl.h:287
int * DM_active_map
Definition: AOloopControl.h:454
long aoconfID_meas_act
Definition: AOloopControl.h:427
long LOOPNUMBER
Definition: AOloopControl.h:275
int tActive
Definition: AOloopControl.h:170
static struct timespec tnow
Definition: AOloopControl_AOcompute.c:51
errno_t AOloopControl_WFSzpupdate_loop(const char *IDzpdm_name, const char *IDzrespM_name, const char *IDwfszp_name)
WFS zero point update.
Definition: AOloopControl_wfs.c:85
int AOloopControl_RTstreamLOG_GUI(int loop)
Definition: AOloopControl_RTstreamLOG.c:541
errno_t AOloopControl_set_loopfrequ(float loopfrequ)
Set AO loop frequency.
Definition: AOloopControl_time_param.c:32
uint8_t WFSatype
Definition: AOloopControl.h:350
errno_t AOloopControl_setgain(float gain)
Set gain of the loop.
Definition: AOloopControl_loop_param.c:40
errno_t AOloopControl_setmultfblock(long mb, float multfval)
Definition: AOloopControl.c:2522
long AOloopControl_computeWFSresidualimage(long loop, char *IDalpha_name)
Compute WFS residual image.
Definition: AOloopControl_wfs.c:404
long IDbuffinfo1
Definition: AOloopControl.h:151
errno_t AOloopControl_setlimitrange(long m0, long m1, float limval)
Definition: AOloopControl.c:2378
#define MAX_NUMBER_RTLOGSTREAM
Definition: AOloopControl.h:91
int AOloopControl_RTstreamLOG_set_ON(int loop, int rtlindex)
Definition: AOloopControl_RTstreamLOG.c:890
int PIXSTREAM_SLICE
Definition: AOloopControl.h:301
errno_t AOloopControl_DMfilteredWrite_off()
Writing on DM, after filtering : off.
Definition: AOloopControl_dmwrite.c:71
errno_t AOloopControl_RTstreamLOG_setup(long loop, long rtlindex, char *streamname)
Definition: AOloopControl_RTstreamLOG.c:173
errno_t AOloopControl_loopon()
Close AO loop : AO on.
Definition: AOloopControl_loop_onoff.c:38
int COMPUTE_PIXELSTREAMING
Definition: AOloopControl.h:299
errno_t AOloopControl_DMprimaryWrite_off()
Writing on DM, unfiltered actuators (primary) : off.
Definition: AOloopControl_dmwrite.c:47
int * GPUset0
Definition: AOloopControl.h:467
Definition: AOloopControl_aorun.h:10
errno_t AOloopControl_setparam(long loop, const char *key, double value)
Set one function for many parameters.
errno_t AOloopControl_scanGainBlock(long NBblock, long NBstep, float gainStart, float gainEnd, long NBgain)
Scan block gains.
Definition: AOloopControl_loop_param.c:309
long aoconfID_imWFS1
Definition: AOloopControl.h:375
long aoconfID_gainb
Definition: AOloopControl.h:405
int AOloopControl_aorun_GUI(long loop, double frequ)
Definition: AOloopControl_aorun.c:127
long aoconfID_meas_act_active
Definition: AOloopControl.h:455
long aoconfID_DMmode_GAIN
Definition: AOloopControl.h:410
errno_t AOloopControl_AUTOTUNE_LIMITS_off()
Set limit auto tune : off.
Definition: AOloopControl_autotune.c:44
char * destptr1
Definition: AOloopControl.h:158
errno_t AOloopControl_DMprimaryWrite_on()
Writing on DM, unfiltered actuators (primary) : on.
Definition: AOloopControl_dmwrite.c:35
long aoconfID_wfsim
Definition: AOloopControl.h:349
errno_t AOloopControl_WFSzeropoint_sum_update_loop(long loopnb, const char *ID_WFSzp_name, int NBzp, const char *IDwfsref0_name, const char *IDwfsref_name)
WFS sum zero point update.
long IDbuff0
Definition: AOloopControl.h:146
int AOloopControl_bogusfunc()
Definition: AOloopControl.c:1531
errno_t AOloopControl_loopkill()
Kill AO loop : finish the process of the run.
Definition: AOloopControl_loop_onoff.c:109
errno_t AOloopControl_setRTLOG_ON()
errno_t AOloopControl_setgainblock(long mb, float gainval)
Definition: AOloopControl.c:2457
errno_t AOloopControl_DMfilteredWrite_on()
Writing on DM, after filtering : on.
Definition: AOloopControl_dmwrite.c:59
long aoconfID_contrMc
Definition: AOloopControl.h:426
int NBFileBuffer
Definition: AOloopControl.h:165
long aoconfID_imWFS0
Definition: AOloopControl.h:371
errno_t AOloopControl_AutoTuneGains(long loop, const char *IDout_name, float GainCoeff, long NBsamples)
Auto tune gains of the closed loop.
Definition: AOloopControl_AutoTuneGains.c:64
errno_t AOloopControl_TweakRM(char *ZRMinname, char *DMinCname, char *WFSinCname, char *DMmaskname, char *WFSmaskname, char *RMoutname)
tweak zonal response matrix in accordance to WFS response to modes
void __attribute__((constructor)) libinit_AOloopControl()
Definition: ImageStreamIO.c:77
long aoconfID_modevalPF
Definition: AOloopControl.h:397
Definition: AOloopControl_aorun.h:89
long AOloopControl_sig2Modecoeff(const char *WFSim_name, const char *IDwfsref_name, const char *WFSmodes_name, const char *outname)
CPU matrix multiplication to transfom WFS signal into modes coefficients.
Definition: AOloopControl_sig2Modecoeff.c:65
long aoconfID_cmd_modes
Definition: AOloopControl.h:392
long IDbuff
Definition: AOloopControl.h:145
AOLOOPCONF_WFSim WFSim
Definition: AOloopControl.h:222
int AOloopControl_RTstreamLOG_set_OFF(int loop, int rtlindex)
Definition: AOloopControl_RTstreamLOG.c:904
long IDbuff1
Definition: AOloopControl.h:147
AOLOOPCONF_aorun aorun
Definition: AOloopControl.h:218
errno_t AOloopControl_AutoTune()
Definition: AOloopControl.c:2554
int_fast8_t init_CM_local
Definition: AOloopControl.h:294
errno_t AOloopControl_setARPFgain(float gain)
Set ARPF gain (auto regressive predictive filter) Ex : a gain of 0.5 will correct 50% of the predicte...
Definition: AOloopControl_loop_param.c:54
char * destptr
Definition: AOloopControl.h:156
void AOloopControl_RTstreamLOG_update(long loop, long rtlindex, struct timespec tnow)
Definition: AOloopControl_RTstreamLOG.c:350
long long aoconfcnt0_wfsref_current
Definition: AOloopControl.h:384
errno_t AOloopControl_set_modeblock_gain(long loop, long blocknb, float gain, int add)
Set gain of block of modes.
Definition: AOloopControl_loop_param.c:146
float * srcptr
Definition: AOloopControl.h:153
errno_t AOloopControl_setlimitblock(long mb, float limitval)
Definition: AOloopControl.c:2490
errno_t AOloopControl_setmaxlimit(float maxlimit)
Set the limit maximum.
Definition: AOloopControl_loop_param.c:115
int AOloopcontrol_meminit
Definition: AOloopControl.h:291
errno_t AOloopControl_loopreset()
Reset the AO loop.
Definition: AOloopControl_loop_onoff.c:141
AOLOOPCONF_DMctrl DMctrl
Definition: AOloopControl.h:234
long aoconfID_modeARPFgainAuto
Definition: AOloopControl.h:396
int FileBuffer
Definition: AOloopControl.h:166
long aoconfID_dmdisp
Definition: AOloopControl.h:387
errno_t AOloopControl_setARPFgainAutoMin(float val)
Set ARPF.
Definition: AOloopControl_loop_param.c:68
AOLOOPCONF_AOcompute AOcompute
Definition: AOloopControl.h:230
errno_t AOloopControl_OptimizePSF_LO(const char *psfstream_name, const char *IDmodes_name, const char *dmstream_name, long delayframe, long NBframes)
Optimize PSF low order.
long frameindexend1
Definition: AOloopControl.h:141
int AOloopControl_aorun_RUN(char *fpsname)
Main loop function.
Definition: AOloopControl_aorun.c:371
errno_t AOloopControl_setmult(float multcoeff)
Multiplying coefficient, close to 1, in order to avoid divergence.
Definition: AOloopControl_loop_param.c:129
long aoconfID_imWFS2
Definition: AOloopControl.h:377
long aoconfID_pixstream_wfspixindex
Definition: AOloopControl.h:432
long frameindexend0
Definition: AOloopControl.h:140
errno_t AOloopControl_set_complatency_frame(float complatency_frame)
Set computation latency of primary DM write in unity of frame.
Definition: AOloopControl_time_param.c:61
long aoconfID_LIMIT_modes
Definition: AOloopControl.h:411