Skip to content

Commit

Permalink
adding new test func
Browse files Browse the repository at this point in the history
  • Loading branch information
jw-lin committed Oct 17, 2023
1 parent 2d9776d commit 6a0ed04
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 0 deletions.
2 changes: 2 additions & 0 deletions AOloopControl_IOtools/AOloopControl_IOtools.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "WFSmap.h"
#include "ao188_preprocessor.h"
#include "pl_trace_renorm.h"
#include "pl_column_sum.h"



Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions AOloopControl_IOtools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
128 changes: 128 additions & 0 deletions AOloopControl_IOtools/pl_column_sum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/**
* @file pl_column_sum.c
* @brief sum the columns of input shm
*
*
*
*/

#include <math.h>
#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;
}
6 changes: 6 additions & 0 deletions AOloopControl_IOtools/pl_column_sum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef AOLOOPCONTROL_IOTOOLS_PLCOLUMNSUM_H
#define AOLOOPCONTROL_IOTOOLS_PLCOLUMNSUM_H

errno_t CLIADDCMD_AOloopControl_IOtools__PLcolumnsum();

#endif

0 comments on commit 6a0ed04

Please sign in to comment.