AdaptiveOpticsControl
AOloopControl.c File Reference

Adaptive Optics Control loop engine. More...

Functions

int clock_gettime (int clk_id, struct mach_timespec *t)
 
static void AOloopControl_logFunctionCall (const int logfuncMODE, const char *FunctionName, const long line, char *comments)
 
int_fast8_t AOloopControl_loadconfigure_cli ()
 
int_fast8_t AOloopControl_stream3Dto2D_cli ()
 
int_fast8_t AOloopControl_CrossProduct_cli ()
 
int_fast8_t AOloopControl_AveStream_cli ()
 
int_fast8_t AOloopControl_frameDelay_cli ()
 
int_fast8_t AOloopControl_mkSimpleZpokeM_cli ()
 
int_fast8_t AOloopControl_dm2opdmaploop_cli ()
 
int_fast8_t AOloopControl_camimage_extract2D_sharedmem_loop_cli ()
 
int_fast8_t AOloopControl_RespMatrix_Fast_cli ()
 
int_fast8_t AOloopControl_Measure_WFSrespC_cli ()
 
int_fast8_t AOloopControl_Measure_WFS_linResponse_cli ()
 
int_fast8_t AOloopControl_Measure_zonalRM_cli ()
 
int_fast8_t AOloopControl_Measure_Resp_Matrix_cli ()
 
int_fast8_t AOloopControl_mkSlavedAct_cli ()
 
int_fast8_t AOloopControl_mkloDMmodes_cli ()
 
int_fast8_t AOloopControl_mkCM_cli ()
 
int_fast8_t AOloopControl_mkModes_cli ()
 
int_fast8_t AOloopControl_mkModes_Simple_cli ()
 
int_fast8_t AOloopControl_computeCM_cli ()
 
int_fast8_t AOloopControl_loadCM_cli ()
 
int_fast8_t AOloopControl_mkHadamardModes_cli ()
 
int_fast8_t AOloopControl_Hadamard_decodeRM_cli ()
 
int_fast8_t AOloopControl_mkCalib_map_mask_cli ()
 
int_fast8_t AOloopControl_Process_zrespM_cli ()
 
int_fast8_t AOloopControl_ProcessZrespM_cli ()
 
int_fast8_t AOloopControl_compute_CombinedControlMatrix_cli ()
 
int_fast8_t AOloopControl_WFSzpupdate_loop_cli ()
 
int_fast8_t AOloopControl_WFSzeropoint_sum_update_loop_cli ()
 
int_fast8_t AOloopControl_CompModes_loop_cli ()
 
int_fast8_t AOloopControl_GPUmodecoeffs2dm_filt_loop_cli ()
 
int_fast8_t AOloopControl_computeWFSresidualimage_cli ()
 
int_fast8_t AOloopControl_ComputeOpenLoopModes_cli ()
 
int_fast8_t AOloopControl_AutoTuneGains_cli ()
 
int_fast8_t AOloopControl_dm2dm_offload_cli ()
 
int_fast8_t AOloopControl_sig2Modecoeff_cli ()
 
int_fast8_t AOloopControl_builPFloop_WatchInput_cli ()
 
int_fast8_t AOloopControl_mapPredictiveFilter_cli ()
 
int_fast8_t AOloopControl_testPredictiveFilter_cli ()
 
int_fast8_t AOloopControl_setLoopNumber_cli ()
 
int_fast8_t AOloopControl_set_modeblock_gain_cli ()
 
int_fast8_t AOloopControl_loopstep_cli ()
 
int_fast8_t AOloopControl_set_loopfrequ_cli ()
 
int_fast8_t AOloopControl_set_hardwlatency_frame_cli ()
 
int_fast8_t AOloopControl_set_complatency_frame_cli ()
 
int_fast8_t AOloopControl_set_wfsmextrlatency_frame_cli ()
 
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_delta_cli ()
 
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_perc_cli ()
 
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_mcoeff_cli ()
 
int_fast8_t AOloopControl_setgain_cli ()
 
int_fast8_t AOloopControl_setARPFgain_cli ()
 
int_fast8_t AOloopControl_setWFSnormfloor_cli ()
 
int_fast8_t AOloopControl_setmaxlimit_cli ()
 
int_fast8_t AOloopControl_setmult_cli ()
 
int_fast8_t AOloopControl_setframesAve_cli ()
 
int_fast8_t AOloopControl_setgainrange_cli ()
 
int_fast8_t AOloopControl_setlimitrange_cli ()
 
int_fast8_t AOloopControl_setmultfrange_cli ()
 
int_fast8_t AOloopControl_setgainblock_cli ()
 
int_fast8_t AOloopControl_setlimitblock_cli ()
 
int_fast8_t AOloopControl_setmultfblock_cli ()
 
int_fast8_t AOloopControl_scanGainBlock_cli ()
 
int_fast8_t AOcontrolLoop_TestDMSpeed_cli ()
 
int_fast8_t AOcontrolLoop_TestSystemLatency_cli ()
 
int_fast8_t AOloopControl_TestDMmodeResp_cli ()
 
int_fast8_t AOloopControl_TestDMmodes_Recovery_cli ()
 
int_fast8_t AOloopControl_blockstats_cli ()
 
int_fast8_t AOloopControl_InjectMode_cli ()
 
int_fast8_t AOloopControl_loopMonitor_cli ()
 
int_fast8_t AOloopControl_statusStats_cli ()
 
int_fast8_t AOloopControl_mkTestDynamicModeSeq_cli ()
 
int_fast8_t AOloopControl_AnalyzeRM_sensitivity_cli ()
 
int_fast8_t AOloopControl_DMmodulateAB_cli ()
 
int_fast8_t AOloopControl_logprocess_modeval_cli ()
 
int_fast8_t AOloopControl_setparam_cli ()
 
int_fast8_t init_AOloopControl ()
 Initialize AOloopControl command line interface. More...
 
static int_fast8_t AOloopControl_loadconfigure (long loop, int mode, int level)
 
static int_fast8_t AOloopControl_InitializeMemory (int mode)
 
long AOloopControl_2Dloadcreate_shmim (const char *name, const char *fname, long xsize, long ysize)
 
long AOloopControl_3Dloadcreate_shmim (const char *name, const char *fname, long xsize, long ysize, long zsize)
 
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)
 
long AOloopControl_frameDelay (const char *IDin_name, const char *IDkern_name, const char *IDout_name, int insem)
 
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. More...
 
static long AOloopControl_CrossProduct (const char *ID1_name, const char *ID2_name, const char *IDout_name)
 
static void * compute_function_imtotal (void *ptr)
 
static void * compute_function_dark_subtract (void *ptr)
 
long AOloopControl_mkSimpleZpokeM (long dmxsize, long dmysize, char *IDout_name)
 
long AOloopControl_dm2opdmaploop (char *DMdisp_name, char *OPDmap_name, int semindex)
 
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)
 
int_fast8_t Read_cam_frame (long loop, int RM, int normalize, int PixelStreamMode, int InitSem)
 
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. More...
 
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)
 
long AOloopControl_Measure_zonalRM (long loop, double ampl, long delayfr, long delayRM1us, long NBave, long NBexcl, const char *zrespm_name, const char *WFSref0_name, const char *WFSmap_name, const char *DMmap_name, long mode, int normalize, int AOinitMode, long NBcycle)
 
int_fast8_t Measure_Resp_Matrix (long loop, long NbAve, float amp, long nbloop, long fDelay, long NBiter)
 
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)
 
long AOloopControl_mkHadamardModes (const char *DMmask_name, const char *outname)
 
long AOloopControl_Hadamard_decodeRM (const char *inname, const char *Hmatname, const char *indexname, const char *outname)
 
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)
 
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)
 
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)
 
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)
 
long AOloopControl_mkCM (const char *respm_name, const char *cm_name, float SVDlim)
 
long AOloopControl_mkSlavedAct (const char *IDmaskRM_name, float pixrad, const char *IDout_name)
 
static long AOloopControl_DMedgeDetect (const char *IDmaskRM_name, const char *IDout_name)
 
static long AOloopControl_DMextrapolateModes (const char *IDin_name, const char *IDmask_name, const char *IDcpa_name, const char *IDout_name)
 
long AOloopControl_DMslaveExt (const char *IDin_name, const char *IDmask_name, const char *IDsl_name, const char *IDout_name, float r0)
 
long AOloopControl_mkModes (const char *ID_name, long msizex, long msizey, float CPAmax, float deltaCPA, double xc, double yc, double r0, double r1, int MaskMode, int BlockNB, float SVDlim)
 
long AOloopControl_mkModes_Simple (const char *IDin_name, long NBmblock, long Cmblock, float SVDlim)
 
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. More...
 
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)
 
long AOloopControl_loadCM (long loop, const char *CMfname)
 
int_fast8_t AOloopControl_WFSzpupdate_loop (const char *IDzpdm_name, const char *IDzrespM_name, const char *IDwfszp_name)
 
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)
 
int_fast8_t AOloopControl_run ()
 
int_fast8_t ControlMatrixMultiply (float *cm_array, float *imarray, long m, long n, float *outvect)
 
int_fast8_t set_DM_modes (long loop)
 
int_fast8_t set_DM_modesRM (long loop)
 
int_fast8_t AOcompute (long loop, int normalize)
 
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)
 
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)
 
long AOloopControl_sig2Modecoeff (const char *WFSim_name, const char *IDwfsref_name, const char *WFSmodes_name, const char *outname)
 
long AOloopControl_computeWFSresidualimage (long loop, float alpha)
 
long AOloopControl_ComputeOpenLoopModes (long loop)
 
int_fast8_t AOloopControl_AutoTuneGains (long loop, const char *IDout_name)
 
long AOloopControl_dm2dm_offload (const char *streamin, const char *streamout, float twait, float offcoeff, float multcoeff)
 
int_fast8_t AOloopControl_mapPredictiveFilter (const char *IDmodecoeff_name, long modeout, double delayfr)
 
double AOloopControl_testPredictiveFilter (const char *IDtrace_name, long modeout, double delayfr, long filtsize, const char *IDfilt_name, double SVDeps)
 
long AOloopControl_builPFloop_WatchInput (long loop, long PFblock)
 
int_fast8_t AOloopControl_setLoopNumber (long loop)
 
int_fast8_t AOloopControl_setparam (long loop, const char *key, double value)
 
int_fast8_t AOloopControl_loopon ()
 
int_fast8_t AOloopControl_loopoff ()
 
int_fast8_t AOloopControl_loopkill ()
 
int_fast8_t AOloopControl_loopstep (long loop, long NBstep)
 
int_fast8_t AOloopControl_loopreset ()
 
int_fast8_t AOloopControl_DMprimaryWrite_on ()
 
int_fast8_t AOloopControl_DMprimaryWrite_off ()
 
int_fast8_t AOloopControl_AUTOTUNE_LIMITS_on ()
 
int_fast8_t AOloopControl_AUTOTUNE_LIMITS_off ()
 
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_delta (float AUTOTUNE_LIMITS_delta)
 
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_perc (float AUTOTUNE_LIMITS_perc)
 
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_mcoeff (float AUTOTUNE_LIMITS_mcoeff)
 
int_fast8_t AOloopControl_AUTOTUNE_GAINS_on ()
 
int_fast8_t AOloopControl_AUTOTUNE_GAINS_off ()
 
int_fast8_t AOloopControl_ARPFon ()
 
int_fast8_t AOloopControl_ARPFoff ()
 
int_fast8_t AOloopControl_set_loopfrequ (float loopfrequ)
 
int_fast8_t AOloopControl_set_hardwlatency_frame (float hardwlatency_frame)
 
int_fast8_t AOloopControl_set_complatency_frame (float complatency_frame)
 
int_fast8_t AOloopControl_set_wfsmextrlatency_frame (float wfsmextrlatency_frame)
 
int_fast8_t AOloopControl_setgain (float gain)
 
int_fast8_t AOloopControl_setARPFgain (float gain)
 
int_fast8_t AOloopControl_setWFSnormfloor (float WFSnormfloor)
 
int_fast8_t AOloopControl_setmaxlimit (float maxlimit)
 
int_fast8_t AOloopControl_setmult (float multcoeff)
 
int_fast8_t AOloopControl_setframesAve (long nbframes)
 
int_fast8_t AOloopControl_set_modeblock_gain (long loop, long blocknb, float gain, int add)
 
int_fast8_t AOloopControl_scanGainBlock (long NBblock, long NBstep, float gainStart, float gainEnd, long NBgain)
 
int_fast8_t AOloopControl_printloopstatus (long loop, long nbcol, long IDmodeval_dm, long IDmodeval, long IDmodevalave, long IDmodevalrms, long ksize)
 
int_fast8_t AOloopControl_loopMonitor (long loop, double frequ, long nbcol)
 
int_fast8_t AOloopControl_statusStats (int updateconf)
 
int_fast8_t AOloopControl_resetRMSperf ()
 
int_fast8_t AOloopControl_showparams (long loop)
 
int_fast8_t AOcontrolLoop_TestDMSpeed (const char *dmname, long delayus, long NBpts, float ampl)
 
int_fast8_t AOcontrolLoop_TestSystemLatency (const char *dmname, char *wfsname, float OPDamp, long NBiter)
 
long AOloopControl_blockstats (long loop, const char *IDout_name)
 
int_fast8_t AOloopControl_InjectMode (long index, float ampl)
 
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)
 
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)
 
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)
 
int_fast8_t AOloopControl_OptimizePSF_LO (const char *psfstream_name, const char *IDmodes_name, const char *dmstream_name, long delayframe, long NBframes)
 
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)
 
int_fast8_t AOloopControl_logprocess_modeval (const char *IDname)
 
long AOloopControl_TweakRM (char *ZRMinname, char *DMinCname, char *WFSinCname, char *DMmaskname, char *WFSmaskname, char *RMoutname)
 
int_fast8_t AOloopControl_setgainrange (long m0, long m1, float gainval)
 
int_fast8_t AOloopControl_setlimitrange (long m0, long m1, float limval)
 
int_fast8_t AOloopControl_setmultfrange (long m0, long m1, float multfval)
 
int_fast8_t AOloopControl_setgainblock (long mb, float gainval)
 
int_fast8_t AOloopControl_setlimitblock (long mb, float limitval)
 
int_fast8_t AOloopControl_setmultfblock (long mb, float multfval)
 
long AOloopControl_mkTestDynamicModeSeq (const char *IDname_out, long NBpt, long NBmodes)
 
int_fast8_t AOloopControl_AutoTune ()
 

Variables

static int AOLOOPCONTROL_logfunc_level = 0
 
static int AOLOOPCONTROL_logfunc_level_max = 2
 
static char AOLOOPCONTROL_logfunc_fname [] = "AOloopControl.fcall.log"
 
static char flogcomment [200]
 
static struct timespec tnow
 
static struct timespec tdiff
 
static double tdiffv
 
static int AOLCOMPUTE_TOTAL_ASYNC_THREADinit = 0
 
static sem_t AOLCOMPUTE_TOTAL_ASYNC_sem_name
 
static int AOLCOMPUTE_TOTAL_INIT = 0
 
static int AOLCOMPUTE_DARK_SUBTRACT_THREADinit = 0
 
static int COMPUTE_DARK_SUBTRACT_NBTHREADS = 1
 
static sem_t AOLCOMPUTE_DARK_SUBTRACT_sem_name [32]
 
static sem_t AOLCOMPUTE_DARK_SUBTRACT_RESULT_sem_name [32]
 
static int COMPUTE_GPU_SCALING = 0
 
static 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}
 
static 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}
 
static float GPU_alpha = 0.0
 
static float GPU_beta = 0.0
 
static int COMPUTE_PIXELSTREAMING = 0
 
static int PIXSTREAM_NBSLICES = 1
 
static int PIXSTREAM_SLICE
 
static long ti
 
static int MATRIX_COMPUTATION_MODE = 0
 
static int wcol
 
static int wrow
 
static long aoconfID_wfsim = -1
 
static uint8_t WFSatype
 
static long aoconfID_wfsdark = -1
 
static long aoconfID_imWFS0 = -1
 
static long aoconfID_imWFS0tot = -1
 
static long aoconfID_imWFS1 = -1
 
static long aoconfID_imWFS2 = -1
 
static long aoconfID_wfsref0 = -1
 
static long aoconfID_wfsref = -1
 
static long aoconfID_dmC = -1
 
static long aoconfID_dmRM = -1
 
static long aoconfID_DMmodes = -1
 
static long aoconfID_dmdisp = -1
 
static long aoconfID_cmd_modes = -1
 
static long aoconfID_meas_modes = -1
 
static long aoconfID_RMS_modes = -1
 
static long aoconfID_AVE_modes = -1
 
static long aoconfID_gainb = -1
 
static long aoconfID_multfb = -1
 
static long aoconfID_limitb = -1
 
static long aoconfID_GAIN_modes = -1
 
static long aoconfID_LIMIT_modes = -1
 
static long aoconfID_MULTF_modes = -1
 
static long aoconfID_cmd_modesRM = -1
 
static long aoconfID_wfsmask = -1
 
static long aoconfID_dmmask = -1
 
static long aoconfID_respM = -1
 
static long aoconfID_contrM = -1
 
static long aoconfID_contrMc = -1
 
static long aoconfID_meas_act = -1
 
static long aoconfID_contrMcact [100] = { -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}
 
static long aoconfID_pixstream_wfspixindex
 
static long aoconfID_looptiming = -1
 
static long NBtimers = 21
 
static long aoconfIDlogdata = -1
 
static long aoconfIDlog0 = -1
 
static long aoconfIDlog1 = -1
 
static int * WFS_active_map
 
static int * DM_active_map
 
static long aoconfID_meas_act_active
 
static long aoconfID_imWFS2_active [100]
 
static int RMACQUISITION = 0
 
static long wfsrefcnt0 = -1
 
static long contrMcactcnt0 [100] = { -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}
 
static char Average_cam_frames_dname [200]
 
static long Average_cam_frames_IDdark = -1
 
static long Average_cam_frames_nelem = 1
 
static int GPUcntMax = 100
 
static int * GPUset0
 
static int * GPUset1
 
DATA data
 
static long LOOPNUMBER = 0
 
static int AOloopcontrol_meminit = 0
 
static int AOlooploadconf_init = 0
 
static AOLOOPCONTROL_CONFAOconf
 
static float * arrayftmp
 
static unsigned short * arrayutmp
 
static int avcamarraysInit = 0
 
static float normfloorcoeff = 1.0
 
static float IMTOTAL = 0.0
 
static int loadcreateshm_log = 0
 
static FILE * loadcreateshm_fplog
 

Detailed Description

Adaptive Optics Control loop engine.

AO engine uses stream data structure

Author
O. Guyon
Date
10 Jun 2017
Bug:
No known bugs.
See also
http://oguyon.github.io/AdaptiveOpticsControl/src/AOloopControl/doc/AOloopControl.html

Function Documentation

int_fast8_t AOcompute ( long  loop,
int  normalize 
)
int_fast8_t AOcontrolLoop_TestDMSpeed ( const char *  dmname,
long  delayus,
long  NBpts,
float  ampl 
)
int_fast8_t AOcontrolLoop_TestDMSpeed_cli ( )
int_fast8_t AOcontrolLoop_TestSystemLatency ( const char *  dmname,
char *  wfsname,
float  OPDamp,
long  NBiter 
)
int_fast8_t AOcontrolLoop_TestSystemLatency_cli ( )
long AOloopControl_2Dloadcreate_shmim ( const char *  name,
const char *  fname,
long  xsize,
long  ysize 
)
long AOloopControl_3Dloadcreate_shmim ( const char *  name,
const char *  fname,
long  xsize,
long  ysize,
long  zsize 
)
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 
)
int_fast8_t AOloopControl_AnalyzeRM_sensitivity_cli ( )
int_fast8_t AOloopControl_ARPFoff ( )
int_fast8_t AOloopControl_ARPFon ( )
int_fast8_t AOloopControl_AutoTune ( )
int_fast8_t AOloopControl_AUTOTUNE_GAINS_off ( )
int_fast8_t AOloopControl_AUTOTUNE_GAINS_on ( )
int_fast8_t AOloopControl_AUTOTUNE_LIMITS_off ( )
int_fast8_t AOloopControl_AUTOTUNE_LIMITS_on ( )
int_fast8_t AOloopControl_AutoTuneGains ( long  loop,
const char *  IDout_name 
)
int_fast8_t AOloopControl_AutoTuneGains_cli ( )
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 
)
int_fast8_t AOloopControl_AveStream_cli ( )
long AOloopControl_blockstats ( long  loop,
const char *  IDout_name 
)
int_fast8_t AOloopControl_blockstats_cli ( )
long AOloopControl_builPFloop_WatchInput ( long  loop,
long  PFblock 
)
int_fast8_t AOloopControl_builPFloop_WatchInput_cli ( )
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 
)
int_fast8_t AOloopControl_camimage_extract2D_sharedmem_loop_cli ( )
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 
)
int_fast8_t AOloopControl_CompModes_loop_cli ( )
int_fast8_t AOloopControl_compute_CombinedControlMatrix_cli ( )
int_fast8_t AOloopControl_computeCM_cli ( )
long AOloopControl_ComputeOpenLoopModes ( long  loop)
int_fast8_t AOloopControl_ComputeOpenLoopModes_cli ( )
long AOloopControl_computeWFSresidualimage ( long  loop,
float  alpha 
)
int_fast8_t AOloopControl_computeWFSresidualimage_cli ( )
static long AOloopControl_CrossProduct ( const char *  ID1_name,
const char *  ID2_name,
const char *  IDout_name 
)
static
int_fast8_t AOloopControl_CrossProduct_cli ( )
long AOloopControl_dm2dm_offload ( const char *  streamin,
const char *  streamout,
float  twait,
float  offcoeff,
float  multcoeff 
)
int_fast8_t AOloopControl_dm2dm_offload_cli ( )
long AOloopControl_dm2opdmaploop ( char *  DMdisp_name,
char *  OPDmap_name,
int  semindex 
)
int_fast8_t AOloopControl_dm2opdmaploop_cli ( )
static long AOloopControl_DMedgeDetect ( const char *  IDmaskRM_name,
const char *  IDout_name 
)
static
static long AOloopControl_DMextrapolateModes ( const char *  IDin_name,
const char *  IDmask_name,
const char *  IDcpa_name,
const char *  IDout_name 
)
static
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 
)
int_fast8_t AOloopControl_DMmodulateAB_cli ( )
int_fast8_t AOloopControl_DMprimaryWrite_off ( )
int_fast8_t AOloopControl_DMprimaryWrite_on ( )
long AOloopControl_DMslaveExt ( const char *  IDin_name,
const char *  IDmask_name,
const char *  IDsl_name,
const char *  IDout_name,
float  r0 
)
long AOloopControl_frameDelay ( const char *  IDin_name,
const char *  IDkern_name,
const char *  IDout_name,
int  insem 
)
int_fast8_t AOloopControl_frameDelay_cli ( )
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 
)
int_fast8_t AOloopControl_GPUmodecoeffs2dm_filt_loop_cli ( )
long AOloopControl_Hadamard_decodeRM ( const char *  inname,
const char *  Hmatname,
const char *  indexname,
const char *  outname 
)
int_fast8_t AOloopControl_Hadamard_decodeRM_cli ( )
static int_fast8_t AOloopControl_InitializeMemory ( int  mode)
static
int_fast8_t AOloopControl_InjectMode ( long  index,
float  ampl 
)
int_fast8_t AOloopControl_InjectMode_cli ( )
long AOloopControl_loadCM ( long  loop,
const char *  CMfname 
)
int_fast8_t AOloopControl_loadCM_cli ( )
static int_fast8_t AOloopControl_loadconfigure ( long  loop,
int  mode,
int  level 
)
static
int_fast8_t AOloopControl_loadconfigure_cli ( )
static void AOloopControl_logFunctionCall ( const int  logfuncMODE,
const char *  FunctionName,
const long  line,
char *  comments 
)
static
int_fast8_t AOloopControl_logprocess_modeval ( const char *  IDname)
int_fast8_t AOloopControl_logprocess_modeval_cli ( )
int_fast8_t AOloopControl_loopkill ( )
int_fast8_t AOloopControl_loopMonitor ( long  loop,
double  frequ,
long  nbcol 
)
int_fast8_t AOloopControl_loopMonitor_cli ( )
int_fast8_t AOloopControl_loopoff ( )
int_fast8_t AOloopControl_loopon ( )
int_fast8_t AOloopControl_loopreset ( )
int_fast8_t AOloopControl_loopstep ( long  loop,
long  NBstep 
)
int_fast8_t AOloopControl_loopstep_cli ( )
int_fast8_t AOloopControl_mapPredictiveFilter ( const char *  IDmodecoeff_name,
long  modeout,
double  delayfr 
)
int_fast8_t AOloopControl_mapPredictiveFilter_cli ( )
int_fast8_t AOloopControl_Measure_Resp_Matrix_cli ( )
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 
)
int_fast8_t AOloopControl_Measure_WFS_linResponse_cli ( )
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.

Parameters
[in]loopLoop index
[in]delayfrInteger delay [frame]
[in]delayRM1usFractional delay [us]
[in]NBaveNumber of frames averaged per DM state
[in]NBexclNumber of frames excluded
[in]IDpokeC_namePoke pattern
[out]IDoutC_nameOutput cube
[in]normalizeNormalize flag
[in]AOinitModeAO structure initialization flag
int_fast8_t AOloopControl_Measure_WFSrespC_cli ( )
long AOloopControl_Measure_zonalRM ( long  loop,
double  ampl,
long  delayfr,
long  delayRM1us,
long  NBave,
long  NBexcl,
const char *  zrespm_name,
const char *  WFSref0_name,
const char *  WFSmap_name,
const char *  DMmap_name,
long  mode,
int  normalize,
int  AOinitMode,
long  NBcycle 
)

Measures zonal response matrix -> collapses it to DM response map and WFS response map (both maps show amplitude of actuator effect on WFS)

mode : 0: compute WFSmap and DMmap 1: compute WFSmap, DMmap, WFSmask and DMmask -> images wfsmask and dmmask NOTE can take custom poke matrix (loaded in image name RMpokeCube)

ASYNC = 1 -> record ALL frames and assemble the RM off-line

AOinitMode = 0: create AO shared mem struct AOinitMode = 1: connect only to AO shared mem struct

int_fast8_t AOloopControl_Measure_zonalRM_cli ( )
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 
)
int_fast8_t AOloopControl_mkCalib_map_mask_cli ( )
long AOloopControl_mkCM ( const char *  respm_name,
const char *  cm_name,
float  SVDlim 
)
int_fast8_t AOloopControl_mkCM_cli ( )
long AOloopControl_mkHadamardModes ( const char *  DMmask_name,
const char *  outname 
)
int_fast8_t AOloopControl_mkHadamardModes_cli ( )
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 
)

CPA for each Zernike (somewhat arbitrary... used to sort modes in CPA)

extract xc and yc from mask

Remove excluded modes

SLAVED ACTUATORS

int_fast8_t AOloopControl_mkloDMmodes_cli ( )
long AOloopControl_mkModes ( const char *  ID_name,
long  msizex,
long  msizey,
float  CPAmax,
float  deltaCPA,
double  xc,
double  yc,
double  r0,
double  r1,
int  MaskMode,
int  BlockNB,
float  SVDlim 
)

CPA for each Zernike (somewhat arbitrary... used to sort modes in CPA)

modesfreqcpa ID

STEP 1: CREATE STARTING POINT : ZERNIKES + FOURIER MODES

if Mmask exists, use it, otherwise create it

extract xc and yc from mask

3: tip, tilt, focus

Remove excluded modes if they exist

Remove excluded modes if they exist

COMPUTE WFS RESPONSE TO MODES -> fmodesWFS00all.fits

STEP 2: SEPARATE DM MODES INTO BLOCKS AND MASK

STEP 3: REMOVE NULL SPACE WITHIN EACH BLOCK - USE SVDlim00 FOR CUTOFF -> fmodes1all.fits (DM space)

STEP 4: REMOVE MODES THAT ARE CONTAINED IN PREVIOUS BLOCKS, AND ENFORCE DM-SPACE ORTHOGONALITY BETWEEN BLOCKS -> fmodes2all.fits (DM space) fmodes1all -> fmodes2all

STEP 5: REMOVE NULL SPACE WITHIN EACH BLOCK - USE SVDlim01 FOR CUTOFF -> fmodes2ball.fits (DM space)

STEP 6: COMPUTE WFS RESPONSE TO MODES fmodes2ball -> fmodesWFS0all.fits

Load ... or create WFS mask

STEP 7: REMOVE WFS MODES THAT ARE CONTAINED IN PREVIOUS BLOCKS, AND ENFORCE WFS-SPACE ORTHOGONALITY BETWEEN BLOCKS Input: fmodesWFS0all (corresponding to fmodes2ball) Output -> fmodesWFS1all / fmodes3all

STEP 8: SVD WFS SPACE IN EACH BLOCK fmodesWFS1all, fmodes3 -> fmodesall

eigen mode index

WFS MODES, MODAL CONTROL MATRICES

int_fast8_t AOloopControl_mkModes_cli ( )
long AOloopControl_mkModes_Simple ( const char *  IDin_name,
long  NBmblock,
long  Cmblock,
float  SVDlim 
)
int_fast8_t AOloopControl_mkModes_Simple_cli ( )
long AOloopControl_mkSimpleZpokeM ( long  dmxsize,
long  dmysize,
char *  IDout_name 
)
int_fast8_t AOloopControl_mkSimpleZpokeM_cli ( )
long AOloopControl_mkSlavedAct ( const char *  IDmaskRM_name,
float  pixrad,
const char *  IDout_name 
)
int_fast8_t AOloopControl_mkSlavedAct_cli ( )
long AOloopControl_mkTestDynamicModeSeq ( const char *  IDname_out,
long  NBpt,
long  NBmodes 
)
int_fast8_t AOloopControl_mkTestDynamicModeSeq_cli ( )
int_fast8_t AOloopControl_OptimizePSF_LO ( const char *  psfstream_name,
const char *  IDmodes_name,
const char *  dmstream_name,
long  delayframe,
long  NBframes 
)
int_fast8_t AOloopControl_printloopstatus ( long  loop,
long  nbcol,
long  IDmodeval_dm,
long  IDmodeval,
long  IDmodevalave,
long  IDmodevalrms,
long  ksize 
)
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 
)
int_fast8_t AOloopControl_Process_zrespM_cli ( )
int_fast8_t AOloopControl_ProcessZrespM_cli ( )
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 
)
int_fast8_t AOloopControl_resetRMSperf ( )
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 
)
int_fast8_t AOloopControl_RespMatrix_Fast_cli ( )
int_fast8_t AOloopControl_run ( )

main routine

int_fast8_t AOloopControl_scanGainBlock ( long  NBblock,
long  NBstep,
float  gainStart,
float  gainEnd,
long  NBgain 
)
int_fast8_t AOloopControl_scanGainBlock_cli ( )
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_delta ( float  AUTOTUNE_LIMITS_delta)
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_delta_cli ( )
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_mcoeff ( float  AUTOTUNE_LIMITS_mcoeff)
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_mcoeff_cli ( )
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_perc ( float  AUTOTUNE_LIMITS_perc)
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_perc_cli ( )
int_fast8_t AOloopControl_set_complatency_frame ( float  complatency_frame)
int_fast8_t AOloopControl_set_complatency_frame_cli ( )
int_fast8_t AOloopControl_set_hardwlatency_frame ( float  hardwlatency_frame)
int_fast8_t AOloopControl_set_hardwlatency_frame_cli ( )
int_fast8_t AOloopControl_set_loopfrequ ( float  loopfrequ)
int_fast8_t AOloopControl_set_loopfrequ_cli ( )
int_fast8_t AOloopControl_set_modeblock_gain ( long  loop,
long  blocknb,
float  gain,
int  add 
)
int_fast8_t AOloopControl_set_modeblock_gain_cli ( )
int_fast8_t AOloopControl_set_wfsmextrlatency_frame ( float  wfsmextrlatency_frame)
int_fast8_t AOloopControl_set_wfsmextrlatency_frame_cli ( )
int_fast8_t AOloopControl_setARPFgain ( float  gain)
int_fast8_t AOloopControl_setARPFgain_cli ( )
int_fast8_t AOloopControl_setframesAve ( long  nbframes)
int_fast8_t AOloopControl_setframesAve_cli ( )
int_fast8_t AOloopControl_setgain ( float  gain)
int_fast8_t AOloopControl_setgain_cli ( )
int_fast8_t AOloopControl_setgainblock ( long  mb,
float  gainval 
)
int_fast8_t AOloopControl_setgainblock_cli ( )
int_fast8_t AOloopControl_setgainrange ( long  m0,
long  m1,
float  gainval 
)
int_fast8_t AOloopControl_setgainrange_cli ( )
int_fast8_t AOloopControl_setlimitblock ( long  mb,
float  limitval 
)
int_fast8_t AOloopControl_setlimitblock_cli ( )
int_fast8_t AOloopControl_setlimitrange ( long  m0,
long  m1,
float  limval 
)
int_fast8_t AOloopControl_setlimitrange_cli ( )
int_fast8_t AOloopControl_setLoopNumber ( long  loop)

append process name with loop number

int_fast8_t AOloopControl_setLoopNumber_cli ( )
int_fast8_t AOloopControl_setmaxlimit ( float  maxlimit)
int_fast8_t AOloopControl_setmaxlimit_cli ( )
int_fast8_t AOloopControl_setmult ( float  multcoeff)
int_fast8_t AOloopControl_setmult_cli ( )
int_fast8_t AOloopControl_setmultfblock ( long  mb,
float  multfval 
)
int_fast8_t AOloopControl_setmultfblock_cli ( )
int_fast8_t AOloopControl_setmultfrange ( long  m0,
long  m1,
float  multfval 
)
int_fast8_t AOloopControl_setmultfrange_cli ( )
int_fast8_t AOloopControl_setparam ( long  loop,
const char *  key,
double  value 
)
int_fast8_t AOloopControl_setparam_cli ( )
int_fast8_t AOloopControl_setWFSnormfloor ( float  WFSnormfloor)
int_fast8_t AOloopControl_setWFSnormfloor_cli ( )
int_fast8_t AOloopControl_showparams ( long  loop)
long AOloopControl_sig2Modecoeff ( const char *  WFSim_name,
const char *  IDwfsref_name,
const char *  WFSmodes_name,
const char *  outname 
)
int_fast8_t AOloopControl_sig2Modecoeff_cli ( )
int_fast8_t AOloopControl_statusStats ( int  updateconf)
int_fast8_t AOloopControl_statusStats_cli ( )
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.

int_fast8_t AOloopControl_stream3Dto2D_cli ( )
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 
)
int_fast8_t AOloopControl_TestDMmodeResp_cli ( )
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 
)
int_fast8_t AOloopControl_TestDMmodes_Recovery_cli ( )
double AOloopControl_testPredictiveFilter ( const char *  IDtrace_name,
long  modeout,
double  delayfr,
long  filtsize,
const char *  IDfilt_name,
double  SVDeps 
)

predictive control based on SVD

input: mode values trace [ii: time, jj: mode number] mode index delayfr [delay in frame unit] filtsize [number of samples in filter]

int_fast8_t AOloopControl_testPredictiveFilter_cli ( )
long AOloopControl_TweakRM ( char *  ZRMinname,
char *  DMinCname,
char *  WFSinCname,
char *  DMmaskname,
char *  WFSmaskname,
char *  RMoutname 
)
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 
)
int_fast8_t AOloopControl_WFSzeropoint_sum_update_loop_cli ( )
int_fast8_t AOloopControl_WFSzpupdate_loop ( const char *  IDzpdm_name,
const char *  IDzrespM_name,
const char *  IDwfszp_name 
)
int_fast8_t AOloopControl_WFSzpupdate_loop_cli ( )
int clock_gettime ( int  clk_id,
struct mach_timespec *  t 
)
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 
)
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.

Conventions: m: number of actuators (= NB_MODES); n: number of sensors (= # of pixels) works even for m != n

gain applied to modes to enhance low orders in SVD

number of modes removed

in this procedure, m=number of actuators/modes, n=number of WFS elements

Write rotation matrix to go from DM modes to eigenmodes

Compute eigenmodes responses

eigen mode index

if modesM exists, compute eigenmodes using rotation matrix

eigen mode index

second, build the "inverse" of the diagonal matrix of eigenvalues (matrix1)

static void* compute_function_dark_subtract ( void *  ptr)
static
static void* compute_function_imtotal ( void *  ptr)
static
int_fast8_t ControlMatrixMultiply ( float *  cm_array,
float *  imarray,
long  m,
long  n,
float *  outvect 
)
int_fast8_t init_AOloopControl ( )

Initialize AOloopControl command line interface.

int_fast8_t Measure_Resp_Matrix ( long  loop,
long  NbAve,
float  amp,
long  nbloop,
long  fDelay,
long  NBiter 
)

measures response matrix AND reference

local arrays for image acquision

int_fast8_t Read_cam_frame ( long  loop,
int  RM,
int  normalize,
int  PixelStreamMode,
int  InitSem 
)

Read image from WFS camera

supports ring buffer puts image from camera buffer aoconfID_wfsim into aoconfID_imWFS1 (supplied by user)

RM = 1 if response matrix

if normalize == 1, image is normalized by dividing by (total + AOconf[loop].WFSnormfloor) if PixelStreamMode = 1, read on semaphore 1, return slice index

int_fast8_t set_DM_modes ( long  loop)
int_fast8_t set_DM_modesRM ( long  loop)

Variable Documentation

AOLOOPCONTROL_CONF* AOconf
static
long aoconfID_AVE_modes = -1
static
long aoconfID_cmd_modes = -1
static
long aoconfID_cmd_modesRM = -1
static
long aoconfID_contrM = -1
static
long aoconfID_contrMc = -1
static
long aoconfID_contrMcact[100] = { -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}
static
long aoconfID_dmC = -1
static
long aoconfID_dmdisp = -1
static
long aoconfID_dmmask = -1
static
long aoconfID_DMmodes = -1
static
long aoconfID_dmRM = -1
static
long aoconfID_GAIN_modes = -1
static
long aoconfID_gainb = -1
static
long aoconfID_imWFS0 = -1
static
long aoconfID_imWFS0tot = -1
static
long aoconfID_imWFS1 = -1
static
long aoconfID_imWFS2 = -1
static
long aoconfID_imWFS2_active[100]
static
long aoconfID_LIMIT_modes = -1
static
long aoconfID_limitb = -1
static
long aoconfID_looptiming = -1
static
long aoconfID_meas_act = -1
static
long aoconfID_meas_act_active
static
long aoconfID_meas_modes = -1
static
long aoconfID_MULTF_modes = -1
static
long aoconfID_multfb = -1
static
long aoconfID_pixstream_wfspixindex
static
long aoconfID_respM = -1
static
long aoconfID_RMS_modes = -1
static
long aoconfID_wfsdark = -1
static
long aoconfID_wfsim = -1
static
long aoconfID_wfsmask = -1
static
long aoconfID_wfsref = -1
static
long aoconfID_wfsref0 = -1
static
long aoconfIDlog0 = -1
static
long aoconfIDlog1 = -1
static
long aoconfIDlogdata = -1
static
sem_t AOLCOMPUTE_DARK_SUBTRACT_RESULT_sem_name[32]
static
sem_t AOLCOMPUTE_DARK_SUBTRACT_sem_name[32]
static
int AOLCOMPUTE_DARK_SUBTRACT_THREADinit = 0
static
sem_t AOLCOMPUTE_TOTAL_ASYNC_sem_name
static
int AOLCOMPUTE_TOTAL_ASYNC_THREADinit = 0
static
int AOLCOMPUTE_TOTAL_INIT = 0
static
char AOLOOPCONTROL_logfunc_fname[] = "AOloopControl.fcall.log"
static
int AOLOOPCONTROL_logfunc_level = 0
static
int AOLOOPCONTROL_logfunc_level_max = 2
static
int AOloopcontrol_meminit = 0
static
int AOlooploadconf_init = 0
static
float* arrayftmp
static
unsigned short* arrayutmp
static
int avcamarraysInit = 0
static
char Average_cam_frames_dname[200]
static
long Average_cam_frames_IDdark = -1
static
long Average_cam_frames_nelem = 1
static
int COMPUTE_DARK_SUBTRACT_NBTHREADS = 1
static
int COMPUTE_GPU_SCALING = 0
static
int COMPUTE_PIXELSTREAMING = 0
static
long contrMcactcnt0[100] = { -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}
static
DATA data
int* DM_active_map
static
char flogcomment[200]
static
float GPU_alpha = 0.0
static
float GPU_beta = 0.0
static
int GPUcntMax = 100
static
int* GPUset0
static
int* GPUset1
static
float IMTOTAL = 0.0
static
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}
static
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}
static
FILE* loadcreateshm_fplog
static
int loadcreateshm_log = 0
static
long LOOPNUMBER = 0
static
int MATRIX_COMPUTATION_MODE = 0
static
long NBtimers = 21
static
float normfloorcoeff = 1.0
static
int PIXSTREAM_NBSLICES = 1
static
int PIXSTREAM_SLICE
static
int RMACQUISITION = 0
static
struct timespec tdiff
static
double tdiffv
static
long ti
static
struct timespec tnow
static
int wcol
static
int* WFS_active_map
static
uint8_t WFSatype
static
long wfsrefcnt0 = -1
static
int wrow
static