- A few fixes to the hsitogram memory codes
- Many fixes for the triple axis code
This commit is contained in:
71
nxscript.c
71
nxscript.c
@@ -234,14 +234,19 @@ static void putCounter(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
|
||||
return;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------
|
||||
The sequence of things is important in here: The code for updating
|
||||
the dimensions variables also applies the time binning to the length.
|
||||
Thus subsets can only be checked for after that. And then we can allocate
|
||||
memory.
|
||||
-------------------------------------------------------------------------*/
|
||||
static void putHistogramMemory(SConnection *pCon, SicsInterp *pSics,
|
||||
pNXScript self,
|
||||
int argc, char *argv[]){
|
||||
pHistMem mem = NULL;
|
||||
int status, start, length, iDim[MAXDIM], rank, i, subset = 0;
|
||||
HistInt *iData = NULL;
|
||||
char buffer[256], defString[512], dummy[40];
|
||||
char buffer[256], dummy[40], value[20];
|
||||
const float *timeBin;
|
||||
int timeLength;
|
||||
|
||||
@@ -266,7 +271,29 @@ static void putHistogramMemory(SConnection *pCon, SicsInterp *pSics,
|
||||
*/
|
||||
start = 0;
|
||||
length = GetHistLength(mem);
|
||||
|
||||
|
||||
/*
|
||||
update the dimension variables in the dictionary
|
||||
*/
|
||||
GetHistDim(mem,iDim,&rank);
|
||||
for(i = 0; i < rank; i++){
|
||||
sprintf(dummy,"dim%1.1d", i);
|
||||
sprintf(value,"%d",iDim[i]);
|
||||
status = NXDupdate(self->dictHandle,dummy,value);
|
||||
if(status == 0) {
|
||||
NXDadd(self->dictHandle,dummy,value);
|
||||
}
|
||||
}
|
||||
timeBin = GetHistTimeBin(mem,&timeLength);
|
||||
if(timeLength > 2){
|
||||
length *= timeLength;
|
||||
sprintf(dummy,"%d",timeLength);
|
||||
status = NXDupdate(self->dictHandle,"timedim",dummy);
|
||||
if(status == 0) {
|
||||
NXDadd(self->dictHandle,"timedim",dummy);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
check for further arguments specifying a subset
|
||||
*/
|
||||
@@ -298,39 +325,7 @@ static void putHistogramMemory(SConnection *pCon, SicsInterp *pSics,
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
build the definition string
|
||||
*/
|
||||
status = NXDget(self->dictHandle,argv[2],buffer,254);
|
||||
if(!status){
|
||||
sprintf(buffer,"ERROR: alias %s for histogram memory not found",
|
||||
argv[2]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
free(iData);
|
||||
return;
|
||||
}
|
||||
if(subset){
|
||||
strcpy(defString,buffer);
|
||||
timeBin = GetHistTimeBin(mem,&timeLength);
|
||||
if(timeLength > 2){
|
||||
sprintf(dummy,"%d",timeLength);
|
||||
NXDupdate(self->dictHandle,"timedim",dummy);
|
||||
}
|
||||
} else {
|
||||
strcpy(defString,buffer);
|
||||
GetHistDim(mem,iDim,&rank);
|
||||
sprintf(dummy," -rank %d", rank);
|
||||
strcat(defString,dummy);
|
||||
strcat(defString," -dim { ");
|
||||
sprintf(dummy,"%d",iDim[0]);
|
||||
strcat(defString,dummy);
|
||||
for(i = 1; i < rank; i++){
|
||||
sprintf(dummy,", %d",iDim[i]);
|
||||
strcat(defString,dummy);
|
||||
}
|
||||
strcat(defString," } ");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
read HM
|
||||
*/
|
||||
@@ -350,7 +345,7 @@ static void putHistogramMemory(SConnection *pCon, SicsInterp *pSics,
|
||||
/*
|
||||
finally: write
|
||||
*/
|
||||
status = NXDputdef(self->fileHandle, self->dictHandle,defString,iData);
|
||||
status = NXDputalias(self->fileHandle, self->dictHandle,argv[2],iData);
|
||||
if(status != NX_OK){
|
||||
sprintf(buffer,"ERROR: failed to write histogram memory data");
|
||||
SCWrite(pCon,buffer,eError);
|
||||
@@ -606,7 +601,7 @@ static int handlePut(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: put command not recognised",eError);
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void makeLink(SConnection *pCon, SicsInterp *pSics,
|
||||
|
||||
Reference in New Issue
Block a user