- Fixed a bug in conman.c which could cause a core dump when terminating
a connection during an active run. - Added an additional output mode for the connection in order to support the batch run editor. - Made clientput send everything with eWarning mode in order to support the batch run editor. - Added a better NetReadTillTerm - Fixed a problem in synchronize.c - Fixed an issue with reading empty line on normal connection sockets. - Added a psi scan mode to mesure.c for TRICS - Made motor print warnings when trying to reposition. - Fixed abug in hkl.c which cause wrong signs. SKIPPED: psi/el734driv.c psi/el734hp.c psi/el737driv.c psi/el737hpdriv.c psi/nextrics.c psi/nxamor.c psi/psi.c psi/slsmagnet.c psi/swmotor2.c psi/tasscan.c psi/tasutil.c
This commit is contained in:
57
nxscript.c
57
nxscript.c
@@ -109,6 +109,17 @@ char *makeFilename(SicsInterp *pSics, SConnection *pCon) {
|
||||
|
||||
return pRes;
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
void changeExtension(char *filename, char *newExtension){
|
||||
char *pPtr = NULL;
|
||||
|
||||
pPtr = strrchr(filename,(int)'.');
|
||||
assert(pPtr != NULL);
|
||||
|
||||
pPtr++;
|
||||
assert(strlen(pPtr) >= strlen(newExtension));
|
||||
strcpy(pPtr,newExtension);
|
||||
}
|
||||
/*======================== Action =======================================*/
|
||||
static int handleFileOperations(SConnection *pCon, pNXScript self,
|
||||
int argc, char *argv[]){
|
||||
@@ -560,9 +571,10 @@ static void putTimeBinning(SConnection *pCon, SicsInterp *pSics,
|
||||
pNXScript self,
|
||||
int argc, char *argv[]){
|
||||
pHistMem mem = NULL;
|
||||
int status, timeLength;
|
||||
int i, status, timeLength;
|
||||
char buffer[256], defString[512], dummy[40];
|
||||
const float *timeBin;
|
||||
float *timeCopy = NULL;
|
||||
|
||||
if(argc < 4){
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to puttimebinning",
|
||||
@@ -595,10 +607,25 @@ static void putTimeBinning(SConnection *pCon, SicsInterp *pSics,
|
||||
sprintf(defString,"%s -dim {%d} ",buffer,timeLength);
|
||||
|
||||
/*
|
||||
write
|
||||
*/
|
||||
status = NXDputdef(self->fileHandle, self->dictHandle,
|
||||
defString,(void *)timeBin);
|
||||
Divide the time binning when appropriate and write
|
||||
*/
|
||||
if(self->timeDivisor != 1){
|
||||
timeCopy = (float *)malloc(timeLength*sizeof(float));
|
||||
if(timeCopy == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory writing time binning",eError);
|
||||
return;
|
||||
}
|
||||
for(i = 0; i < timeLength; i++){
|
||||
timeCopy[i] = timeBin[i]/self->timeDivisor;
|
||||
}
|
||||
status = NXDputdef(self->fileHandle, self->dictHandle,
|
||||
defString,(void *)timeCopy);
|
||||
free(timeCopy);
|
||||
} else {
|
||||
status = NXDputdef(self->fileHandle, self->dictHandle,
|
||||
defString,(void *)timeBin);
|
||||
}
|
||||
|
||||
if(status != NX_OK){
|
||||
sprintf(buffer,"ERROR: failed to write time binning");
|
||||
SCWrite(pCon,buffer,eError);
|
||||
@@ -754,12 +781,12 @@ static int handlePut(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
sprintf(buffer,"ERROR: failed to convert %s to int",
|
||||
argv[3]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
status = NXDputalias(self->fileHandle, self->dictHandle,
|
||||
argv[2],&iVal);
|
||||
if(status != NX_OK){
|
||||
sprintf(buffer,"ERROR: failed to write %f to alias %s",
|
||||
sprintf(buffer,"ERROR: failed to write %d to alias %s",
|
||||
iVal, argv[2]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
}
|
||||
@@ -767,11 +794,12 @@ static int handlePut(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
} else if (strcmp(argv[1],"puttext") == 0){
|
||||
/*====================*/
|
||||
if(argc < 4){
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to putfloat",
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to puttext",
|
||||
eError);
|
||||
return 1;
|
||||
}
|
||||
Arg2Text(argc-3,&argv[3],buffer,1023);
|
||||
trim(buffer);
|
||||
status = NXDdefget(self->dictHandle,argv[2],defString,1023);
|
||||
if(status != NX_OK){
|
||||
sprintf(buffer,"ERROR: alias %s not found in puttext",
|
||||
@@ -889,8 +917,20 @@ int NXScriptAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
SCWrite(pCon,"ERROR: failed to create filename",eError);
|
||||
return 0;
|
||||
}
|
||||
} else if(strcmp(argv[1],"divisor") == 0){
|
||||
if(argc < 3) {
|
||||
SCWrite(pCon,"ERROR: no diviso found",eError);
|
||||
return 1;
|
||||
}
|
||||
if(!SCMatchRights(pCon,usMugger)){
|
||||
return 1;
|
||||
}
|
||||
self->timeDivisor = atoi(argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(handleFileOperations(pCon,self,argc,argv)){
|
||||
return 1;
|
||||
}
|
||||
@@ -954,6 +994,7 @@ int MakeNXScript(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
free(self);
|
||||
return 0;
|
||||
}
|
||||
self->timeDivisor = 1;
|
||||
|
||||
/*
|
||||
create with with a default name if none specified
|
||||
|
||||
Reference in New Issue
Block a user