From 6a0ed042fa9cb68f7b2a742fba3257ab1418b4aa Mon Sep 17 00:00:00 2001 From: Jonathan Lin Date: Mon, 16 Oct 2023 17:04:57 -1000 Subject: [PATCH] adding new test func --- AOloopControl_IOtools/AOloopControl_IOtools.c | 2 + AOloopControl_IOtools/CMakeLists.txt | 2 + AOloopControl_IOtools/pl_column_sum.c | 128 ++++++++++++++++++ AOloopControl_IOtools/pl_column_sum.h | 6 + 4 files changed, 138 insertions(+) create mode 100644 AOloopControl_IOtools/pl_column_sum.c create mode 100644 AOloopControl_IOtools/pl_column_sum.h diff --git a/AOloopControl_IOtools/AOloopControl_IOtools.c b/AOloopControl_IOtools/AOloopControl_IOtools.c index c8eede5a..b405fa03 100644 --- a/AOloopControl_IOtools/AOloopControl_IOtools.c +++ b/AOloopControl_IOtools/AOloopControl_IOtools.c @@ -35,6 +35,7 @@ #include "WFSmap.h" #include "ao188_preprocessor.h" #include "pl_trace_renorm.h" +#include "pl_column_sum.h" @@ -59,6 +60,7 @@ static errno_t init_module_CLI() CLIADDCMD_AOloopControl_IOtools__findspots(); CLIADDCMD_AOloopControl_IOtools__AO188Preproc(); CLIADDCMD_AOloopControl_IOtools__PLtracerenorm(); + CLIADDCMD_AOloopControl_IOtools__PLcolumnsum(); // add atexit functions here // atexit((void*) myfunc); diff --git a/AOloopControl_IOtools/CMakeLists.txt b/AOloopControl_IOtools/CMakeLists.txt index 3243dd2f..21f0b81c 100644 --- a/AOloopControl_IOtools/CMakeLists.txt +++ b/AOloopControl_IOtools/CMakeLists.txt @@ -11,6 +11,7 @@ set(SOURCEFILES acquireWFSim.c ao188_preprocessor.c pl_trace_renorm.c + pl_column_sum.c findspots.c WFScamsim.c WFSmap.c @@ -22,6 +23,7 @@ set(INCLUDEFILES acquireWFSim.h ao188_preprocessor.h pl_trace_renorm.h + pl_column_sum.h findspots.h WFScamsim.h WFSmap.h diff --git a/AOloopControl_IOtools/pl_column_sum.c b/AOloopControl_IOtools/pl_column_sum.c new file mode 100644 index 00000000..fdfc1b6a --- /dev/null +++ b/AOloopControl_IOtools/pl_column_sum.c @@ -0,0 +1,128 @@ +/** + * @file pl_column_sum.c + * @brief sum the columns of input shm + * + * + * + */ + +#include +#include "CommandLineInterface/CLIcore.h" + +// Local variables pointers +static char *input_shm_name; // input shared memory +static long fpi_inputshmname; + +static char *output_shm_name; // output shared memory +static long fpi_outputshmname; + +static CLICMDARGDEF farg[] = +{ + { + CLIARG_IMG, + ".wfsin", + "Wavefront sensor input", + "wfsin", + CLIARG_VISIBLE_DEFAULT, + (void **) &input_shm_name, + &fpi_inputshmname + }, + { + CLIARG_STR, + ".wfsout", + "Wavefront sensor output", + "wfsim", + CLIARG_VISIBLE_DEFAULT, + (void **) &output_shm_name, + &fpi_outputshmname + }, +}; + +// Optional custom configuration setup. +// Runs once at conf startup +// +static errno_t customCONFsetup() +{ + if(data.fpsptr != NULL) + { + + } + + return RETURN_SUCCESS; +} + +// Optional custom configuration checks. +// Runs at every configuration check loop iteration +// +static errno_t customCONFcheck() +{ + return RETURN_SUCCESS; +} + +static CLICMDDATA CLIcmddata = +{ + "column_sum", "sum columns", CLICMD_FIELDS_DEFAULTS +}; + + +// detailed help +static errno_t help_function() +{ + return RETURN_SUCCESS; +} + +static errno_t compute_function() +{ + DEBUG_TRACE_FSTART(); + // JON YOU GET TO INIT HERE + + IMGID wfsin = mkIMGID_from_name(input_shm_name); + resolveIMGID(&wfsin, ERRMODE_ABORT); + + uint32_t sizeoutx = wfsin.size[0]; + uint32_t sizeouty = wfsin.size[1]; + + // Create output + // trying to copy shape of wfsin. Assume a structure 3 rows x N columns, N goes along wavelength + IMGID wfsout; + wfsout = + stream_connect_create_2D(output_shm_name, sizeoutx,1, _DATATYPE_FLOAT); + + // This is the while(True) { + //INSERT_STD_PROCINFO_COMPUTEFUNC_INIT + INSERT_STD_PROCINFO_COMPUTEFUNC_START + { + // JON YOU GET TO WORK HERE + int i; + for (i = 0; i < sizeoutx; i++){ + double tot = 0.0; + int j; + for (j = 0; j < sizeouty; i++) { + tot += wfsin.im->array.F[i*sizeouty+j]; + } + wfsout.im->array.F[i] = tot; + } + + // Done and post downstream. + processinfo_update_output_stream(processinfo, wfsout.ID); + } + INSERT_STD_PROCINFO_COMPUTEFUNC_END // } // while (true) + + DEBUG_TRACE_FEXIT(); + + return RETURN_SUCCESS; +} + + +INSERT_STD_FPSCLIfunctions + +// Register function in CLI +errno_t CLIADDCMD_AOloopControl_IOtools__PLcolumnsum() +{ + + CLIcmddata.FPS_customCONFsetup = customCONFsetup; + CLIcmddata.FPS_customCONFcheck = customCONFcheck; + INSERT_STD_CLIREGISTERFUNC + + return RETURN_SUCCESS; +} diff --git a/AOloopControl_IOtools/pl_column_sum.h b/AOloopControl_IOtools/pl_column_sum.h new file mode 100644 index 00000000..9a9e3aa5 --- /dev/null +++ b/AOloopControl_IOtools/pl_column_sum.h @@ -0,0 +1,6 @@ +#ifndef AOLOOPCONTROL_IOTOOLS_PLCOLUMNSUM_H +#define AOLOOPCONTROL_IOTOOLS_PLCOLUMNSUM_H + +errno_t CLIADDCMD_AOloopControl_IOtools__PLcolumnsum(); + +#endif