- made fixes to hkl
- Introduced a help system - introduced a module for handling automatic updates of files during long measurements - Added a circular buffer and handling facilities to varlog - Upgraded documentation SKIPPED: psi/faverage.h psi/nxamor.tex psi/pimotor.h psi/pimotor.tex
This commit is contained in:
154
nxscript.c
154
nxscript.c
@@ -234,6 +234,34 @@ static void putCounter(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
|
||||
return;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void updateHMDim(NXScript *self, pHistMem mem){
|
||||
int iDim[MAXDIM];
|
||||
int i, rank, timeLength, status;
|
||||
char dummy[40], value[20];
|
||||
const float *timeBin;
|
||||
|
||||
/*
|
||||
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){
|
||||
sprintf(dummy,"%d",timeLength);
|
||||
status = NXDupdate(self->dictHandle,"timedim",dummy);
|
||||
if(status == 0) {
|
||||
NXDadd(self->dictHandle,"timedim",dummy);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------
|
||||
The sequence of things is important in here: The code for updating
|
||||
the dimensions variables also applies the time binning to the length.
|
||||
@@ -244,11 +272,9 @@ 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;
|
||||
int status, start, length, i, subset = 0;
|
||||
HistInt *iData = NULL;
|
||||
char buffer[256], dummy[40], value[20];
|
||||
const float *timeBin;
|
||||
int timeLength;
|
||||
char buffer[256];
|
||||
|
||||
if(argc < 4){
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to puthm",
|
||||
@@ -272,26 +298,7 @@ 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){
|
||||
sprintf(dummy,"%d",timeLength);
|
||||
status = NXDupdate(self->dictHandle,"timedim",dummy);
|
||||
if(status == 0) {
|
||||
NXDadd(self->dictHandle,"timedim",dummy);
|
||||
}
|
||||
}
|
||||
updateHMDim(self,mem);
|
||||
|
||||
/*
|
||||
check for further arguments specifying a subset
|
||||
@@ -314,6 +321,105 @@ static void putHistogramMemory(SConnection *pCon, SicsInterp *pSics,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
read HM
|
||||
*/
|
||||
if(subset){
|
||||
iData = (HistInt *)malloc(length*sizeof(HistInt));
|
||||
if(!iData){
|
||||
SCWrite(pCon,"ERROR: out of memory for reading histogram memory",
|
||||
eError);
|
||||
return;
|
||||
}
|
||||
memset(iData,0,length*sizeof(HistInt));
|
||||
status = GetHistogramDirect(mem,pCon,0,start,start+length,iData,
|
||||
length*sizeof(HistInt));
|
||||
}else{
|
||||
/*
|
||||
status = GetHistogram(mem,pCon,0,start,length,iData,
|
||||
length*sizeof(HistInt));
|
||||
*/
|
||||
iData = GetHistogramPointer(mem,pCon);
|
||||
if(iData == NULL){
|
||||
status = 0;
|
||||
} else {
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
if(!status){
|
||||
SCWrite(pCon,"ERROR: failed to read histogram memory",eError);
|
||||
if(subset){
|
||||
free(iData);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
finally: write
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
if(subset){
|
||||
free(iData);
|
||||
}
|
||||
SCSendOK(pCon);
|
||||
|
||||
return;
|
||||
}
|
||||
/*---------------------------------------------------------------------
|
||||
defunct as of december 2003
|
||||
*/
|
||||
static void putHistogramMemoryChunked(SConnection *pCon, SicsInterp *pSics,
|
||||
pNXScript self,
|
||||
int argc, char *argv[]){
|
||||
pHistMem mem = NULL;
|
||||
int status, start, length, i, noChunks, chunkDim[MAXDIM], rank;
|
||||
HistInt *iData = NULL;
|
||||
char buffer[256];
|
||||
int subset;
|
||||
|
||||
if(argc < 5){
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to puthmchunked",
|
||||
eError);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
find Histogram Memory
|
||||
*/
|
||||
mem = (pHistMem)FindCommandData(pSics,argv[3],"HistMem");
|
||||
if(!mem){
|
||||
sprintf(buffer,"ERROR: HistMem %s not found!", argv[3]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
default: everything
|
||||
*/
|
||||
start = 0;
|
||||
length = GetHistLength(mem);
|
||||
|
||||
updateHMDim(self,mem);
|
||||
|
||||
/*
|
||||
check for an argument defining the number of chunks
|
||||
*/
|
||||
status = Tcl_GetInt(InterpGetTcl(pSics),argv[4],&noChunks);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to integer",
|
||||
argv[4]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
read HM
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user