Skip to content

Commit

Permalink
streamFITSlog echo + FPS disable FLFLAG_WRITERUN for some params.
Browse files Browse the repository at this point in the history
  • Loading branch information
scexao6 committed Oct 5, 2023
1 parent 79c15a2 commit 29bcd8f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 60 deletions.
91 changes: 39 additions & 52 deletions src/COREMOD_memory/logshmim.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,13 @@ static errno_t customCONFsetup()
data.fpsptr->parray[fpi_lastcubeON].fpflag |= FPFLAG_WRITERUN;
data.fpsptr->parray[fpi_nextcube].fpflag |= FPFLAG_WRITERUN;

data.fpsptr->parray[fpi_savedirname].fpflag |= FPFLAG_WRITERUN;
//data.fpsptr->parray[fpi_savedirname].fpflag |= FPFLAG_WRITERUN;

data.fpsptr->parray[fpi_cubesize].fpflag |= FPFLAG_WRITERUN;
// Disabled. Causes undefined behavior.
//data.fpsptr->parray[fpi_cubesize].fpflag |= FPFLAG_WRITERUN;
data.fpsptr->parray[fpi_maxfilecnt].fpflag |= FPFLAG_WRITERUN;
data.fpsptr->parray[fpi_maxframecnt].fpflag |= FPFLAG_WRITERUN;
data.fpsptr->parray[fpi_compressON].fpflag |= FPFLAG_WRITERUN;
//data.fpsptr->parray[fpi_compressON].fpflag |= FPFLAG_WRITERUN;

data.fpsptr->parray[fpi_writerRTprio].fpflag |= FPFLAG_WRITERUN;
}
Expand Down Expand Up @@ -547,14 +548,6 @@ static void *save_telemetry_fits_function(
}










static errno_t compute_function()
{
DEBUG_TRACE_FSTART();
Expand All @@ -566,7 +559,8 @@ static errno_t compute_function()
// 1: print statements outside fast loop
// 2: print everything

STREAMSAVE_THREAD_MESSAGE *tmsg = (STREAMSAVE_THREAD_MESSAGE*) malloc(sizeof(STREAMSAVE_THREAD_MESSAGE));
STREAMSAVE_THREAD_MESSAGE *tmsg = (STREAMSAVE_THREAD_MESSAGE *) malloc(sizeof(
STREAMSAVE_THREAD_MESSAGE));


IMGID inimg = mkIMGID_from_name(streamname);
Expand Down Expand Up @@ -613,7 +607,7 @@ static errno_t compute_function()
// copy keywords
{
printf("Cppying %d keywords\n", inimg.md->NBkw);
if( inimg.md->NBkw > 0 )
if(inimg.md->NBkw > 0)
{
memcpy(imgbuff0.im->kw,
inimg.im->kw,
Expand Down Expand Up @@ -655,19 +649,21 @@ static errno_t compute_function()
int saveON_last = (*saveON);

char FITSffilename[STRINGMAXLEN_FULLFILENAME];
strcpy(FITSffilename,"null");
strcpy(FITSffilename, "null");

char ASCIITIMEffilename[STRINGMAXLEN_FULLFILENAME];
strcpy(ASCIITIMEffilename,"null");
strcpy(ASCIITIMEffilename, "null");



// array are zsize * 2 long to hold double buffer
//
double * array_time = (double *) malloc(sizeof(double) * (*cubesize) * 2);
double * array_aqtime = (double *) malloc(sizeof(double) * (*cubesize) * 2);
uint64_t * array_cnt0 = (uint64_t *) malloc(sizeof(uint64_t) * (*cubesize) * 2);
uint64_t * array_cnt1 = (uint64_t *) malloc(sizeof(uint64_t) * (*cubesize) * 2);
double *array_time = (double *) malloc(sizeof(double) * (*cubesize) * 2);
double *array_aqtime = (double *) malloc(sizeof(double) * (*cubesize) * 2);
uint64_t *array_cnt0 = (uint64_t *) malloc(sizeof(uint64_t) *
(*cubesize) * 2);
uint64_t *array_cnt1 = (uint64_t *) malloc(sizeof(uint64_t) *
(*cubesize) * 2);



Expand All @@ -688,19 +684,19 @@ static errno_t compute_function()
INSERT_STD_PROCINFO_COMPUTEFUNC_LOOPSTART
{

if (processinfo->triggerstatus == PROCESSINFO_TRIGGERSTATUS_TIMEDOUT)
if(processinfo->triggerstatus == PROCESSINFO_TRIGGERSTATUS_TIMEDOUT)
{
printf("------------ TIMEOUT\n");
}
else
{
if( lastcnt0 != inimg.md->cnt0)
if(lastcnt0 != inimg.md->cnt0)
{
// new frame has arrived
IsNewFrame = 1;

// printf("<<<<<<<<<<<<<<<<<<<< RECEIVED NEW FRAME %ld >>>>>>>>>>>>>>>>\n", inimg.md->cnt0);
// fflush(stdout);
// printf("<<<<<<<<<<<<<<<<<<<< RECEIVED NEW FRAME %ld >>>>>>>>>>>>>>>>\n", inimg.md->cnt0);
// fflush(stdout);

lastcnt0 = inimg.md->cnt0;
}
Expand All @@ -710,10 +706,10 @@ static errno_t compute_function()
IsNewFrame = 0;
}

if( IsNewFrame == 1 )
if(IsNewFrame == 1)
{

if( (saveON_last == 0) && ((*saveON) == 1) )
if((saveON_last == 0) && ((*saveON) == 1))
{
// We just turned on saving
lastcube = 0;
Expand All @@ -723,15 +719,15 @@ static errno_t compute_function()



if ((*framecnt) >= (*maxframecnt))
if((*framecnt) >= (*maxframecnt))
{
// we've logged the requested number of frames
(*saveON) = 0;
data.fpsptr->parray[fpi_saveON].fpflag &= ~FPFLAG_ONOFF;
}


if ((*filecnt) >= (*maxfilecnt)-1 )
if((*filecnt) >= (*maxfilecnt) - 1)
{
// last cube
lastcube = 1;
Expand All @@ -741,7 +737,7 @@ static errno_t compute_function()



if ( (*saveON) == 1 )
if((*saveON) == 1)
{
if((*frameindex) == 0)
{
Expand Down Expand Up @@ -795,7 +791,7 @@ static errno_t compute_function()

// timing buffer index
{
long tindex = (*frameindex) + buffindex*(*cubesize);
long tindex = (*frameindex) + buffindex * (*cubesize);
{
array_cnt0[tindex] = inimg.md->cnt0;
array_cnt1[tindex] = inimg.md->cnt1;
Expand All @@ -822,8 +818,8 @@ static errno_t compute_function()

{

// printf("[[copy frame %ld to frame %ld of buffer %d]]\n", inimg.md->cnt0, (*frameindex), buffindex);
// fflush(stdout);
// printf("[[copy frame %ld to frame %ld of buffer %d]]\n", inimg.md->cnt0, (*frameindex), buffindex);
// fflush(stdout);


long framesize = typesize * xsize * ysize;
Expand All @@ -832,7 +828,7 @@ static errno_t compute_function()
char *ptr0; // source image data, after offset

ptr0_0 = (char *) inimg.im->array.raw;
if( inimg.md->naxis == 3)
if(inimg.md->naxis == 3)
{
// this is a rolling buffer
ptr0 = ptr0_0 + framesize * inimg.md->cnt1;
Expand All @@ -845,7 +841,7 @@ static errno_t compute_function()

char *ptr1_0; // destination image data
char *ptr1; // destination image data, after offset
if(buffindex == 0 )
if(buffindex == 0)
{
ptr1_0 = (char *) imgbuff0.im->array.raw;
}
Expand Down Expand Up @@ -886,50 +882,45 @@ static errno_t compute_function()

int SaveCube = 0;

if( (*frameindex) >= (*cubesize) )
if((*frameindex) >= (*cubesize))
{
// cube is full
SaveCube = 1;
}

if( (saveON_last == 1) && ((*saveON) == 0) )
if((saveON_last == 1) && ((*saveON) == 0))
{
// We just turned off saving
SaveCube = 1;
}

if( (*nextcube) == 1)
if((*nextcube) == 1)
{
(*nextcube) = 0;
data.fpsptr->parray[fpi_nextcube].fpflag &= ~FPFLAG_ONOFF;
SaveCube = 1;
}

if (processinfo->triggerstatus == PROCESSINFO_TRIGGERSTATUS_TIMEDOUT)
if(processinfo->triggerstatus == PROCESSINFO_TRIGGERSTATUS_TIMEDOUT)
{
SaveCube = 1;
}







if(SaveCube == 1)
{
if((*frameindex) > 0)
{
// Saving buffer to filesystem
//

printf("SAVING %5ld FRAMES of BUFFER %d to FILE %s\n", (*frameindex), buffindex, FITSffilename);
printf("SAVING %5ld FRAMES of BUFFER %d to FILE %s\n", (*frameindex), buffindex,
FITSffilename);
fflush(stdout);


// update buffer content

if(buffindex == 0 )
if(buffindex == 0)
{
memcpy(imgbuff0.im->kw,
inimg.im->kw,
Expand Down Expand Up @@ -966,7 +957,7 @@ static errno_t compute_function()
}


if(buffindex == 0 )
if(buffindex == 0)
{
strcpy(tmsg->iname, imgbuff0.md->name);
tmsg->arrayindex = array_cnt0;
Expand All @@ -991,7 +982,7 @@ static errno_t compute_function()
streamname);


if ( (*compressON) == 0 )
if((*compressON) == 0)
{
strcpy(tmsg->compress_string, "");
}
Expand Down Expand Up @@ -1062,16 +1053,14 @@ static errno_t compute_function()


}


SaveCube = 0;
}



// report buffer is ready
//
if(buffindex == 0 )
if(buffindex == 0)
{
processinfo_update_output_stream(processinfo, imgbuff0.ID);
}
Expand Down Expand Up @@ -1102,9 +1091,7 @@ static errno_t compute_function()
}
}


saveON_last = (*saveON);

}
INSERT_STD_PROCINFO_COMPUTEFUNC_END

Expand Down
18 changes: 10 additions & 8 deletions src/COREMOD_memory/scripts/milk-streamFITSlog
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ MSextdescr="
List of actions:
pstart start log process
pstop stop log process
kill kill log process and tmux
kill kill log process and tmux
on set logging ON
off set logging OFF
offc set logging OFF after cube complete
Expand Down Expand Up @@ -234,7 +234,7 @@ function runupdatesfps()
echo "setval streamFITSlog-${STREAMNAME}.dirname ${fulllogdir}" >> ${fifoname}
mkdir -p ${fulllogdir}
fi

if [ $update_cubesize == 1 ]; then
echo "setval streamFITSlog-${STREAMNAME}.cubesize ${cubesize}" >> ${fifoname}
fi
Expand Down Expand Up @@ -262,8 +262,8 @@ function runupdatesfps()
if [ $update_cset == 1 ]; then
echo "setval streamFITSlog-${STREAMNAME}.procinfo.cset ${cset}" >> ${fifoname}
fi


echo "confwupdate streamFITSlog-${STREAMNAME}" >> ${fifoname}
}

Expand All @@ -272,7 +272,7 @@ function logresetdefault()
{
echo "setval streamFITSlog-${STREAMNAME}.cubesize ${cubesize}" >> ${fifoname}
echo "setval streamFITSlog-${STREAMNAME}.cubesize ${cubesize}" >> ${fifoname}

}


Expand Down Expand Up @@ -323,13 +323,15 @@ EOF
echo "found fifo -> continuing"

echo "echo \"confstart streamFITSlog-${STREAMNAME}\" >> ${fifoname}"

echo "confstart streamFITSlog-${STREAMNAME}" >> ${fifoname}

echo "echo \"setval streamFITSlog-${STREAMNAME}.procinfo.cset ${cset}\" >> ${fifoname}"
echo "setval streamFITSlog-${STREAMNAME}.procinfo.cset ${cset}" >> ${fifoname}


ecoh "echo \"confwupdate streamFITSlog-${STREAMNAME}\" >> ${fifoname}"
echo "confwupdate streamFITSlog-${STREAMNAME}" >> ${fifoname}

echo "echo \"runstart streamFITSlog-${STREAMNAME}\" >> ${fifoname}"
echo "runstart streamFITSlog-${STREAMNAME}" >> ${fifoname}
fi

Expand Down

0 comments on commit 29bcd8f

Please sign in to comment.