From 9fa649954b3e19a46f20213206c8546c43b7aacd Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 30 Mar 2007 17:57:07 +1000 Subject: [PATCH] putslab can now get histogram memory data directly if you specify start, length and bank parameters for the histogram memory object. This is useful if you need to make an unbuffered get call to the hmm r1747 | ffr | 2007-03-30 17:57:07 +1000 (Fri, 30 Mar 2007) | 2 lines --- nxscript.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/nxscript.c b/nxscript.c index 1857b78e..1e1bd1a3 100644 --- a/nxscript.c +++ b/nxscript.c @@ -668,6 +668,7 @@ static int listToArray(SicsInterp *pSics, char *list, return TCL_OK; } /*----------------------------------------------------------------------*/ +#define HANUM 3 static void putSlab(SConnection *pCon, SicsInterp *pSics, pNXScript self, int argc, char *argv[]){ int start[NX_MAXRANK], size[NX_MAXRANK]; @@ -675,6 +676,9 @@ static void putSlab(SConnection *pCon, SicsInterp *pSics, pNXScript self, pHistMem mem = NULL; HistInt *histData = NULL; pSICSData data = NULL; + char buffer[256]; + enum histargs {haStart, haLength, haBank}; + int i, haIndex, hpars[HANUM], haFirst=6; if(argc < 6){ SCWrite(pCon,"ERROR: insufficient number of arguments to putslab", @@ -705,7 +709,29 @@ static void putSlab(SConnection *pCon, SicsInterp *pSics, pNXScript self, */ mem = (pHistMem)FindCommandData(pSics,argv[5],"HistMem"); if(mem != NULL){ + if (argc == 6) { histData = GetHistogramPointer(mem,pCon); + } else if (argc > 6) { + for (i=0, haIndex=haFirst; i < HANUM; i++, haIndex++) { + status = Tcl_GetInt(InterpGetTcl(pSics),argv[haIndex],&hpars[i]); + if(status != TCL_OK){ + sprintf(buffer,"ERROR: failed to convert %s to integer", + argv[haIndex]); + SCWrite(pCon,buffer,eError); + return; + } + } + histData = (HistInt *)malloc(hpars[haLength]*sizeof(HistInt)); + if(!histData){ + SCWrite(pCon,"ERROR: out of memory for reading histogram memory", + eError); + return; + } + memset(histData,0,hpars[haLength]*sizeof(HistInt)); + status = GetHistogramDirect(mem,pCon,hpars[haBank], + hpars[haStart],hpars[haStart]+hpars[haLength],histData, + hpars[haLength]*sizeof(HistInt)); + } if(histData){ status = NXputslab(self->fileHandle, histData, start, size); if(status == NX_OK){