- Fixes to NXscript
- Added Pause and Continue commands - Fixed simulation counter to deal properly with pause - Fixed nxdict HDF5 problem SKIPPED: psi/makefile_alpha psi/nextrics.c psi/nxsans.c
This commit is contained in:
45
nxscript.c
45
nxscript.c
@@ -7,6 +7,7 @@
|
||||
copyright: see file COPYRIGHT
|
||||
|
||||
Mark Koennecke, February 2003
|
||||
Mark Koennecke, January 2004
|
||||
------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
@@ -125,6 +126,10 @@ static int handleFileOperations(SConnection *pCon, pNXScript self,
|
||||
close everything! and send a message to trigger file synchronisation
|
||||
to the central server
|
||||
*/
|
||||
if(self->fileHandle == NULL){
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
i = 511;
|
||||
iVal = NX_CHAR;
|
||||
NXgetattr(self->fileHandle,"file_name",buffer,&i,&iVal);
|
||||
@@ -139,8 +144,10 @@ static int handleFileOperations(SConnection *pCon, pNXScript self,
|
||||
access = NXACC_RDWR;
|
||||
} else if(strcmp(argv[1],"create4") == 0){
|
||||
access = NXACC_CREATE4;
|
||||
unlink(argv[2]); /* kill file for overwrite */
|
||||
} else if(strcmp(argv[1],"create5") == 0){
|
||||
access = NXACC_CREATE5;
|
||||
unlink(argv[2]); /* kill file for overwrite */
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -163,7 +170,6 @@ static int handleFileOperations(SConnection *pCon, pNXScript self,
|
||||
/*
|
||||
now initialize ourselves
|
||||
*/
|
||||
unlink(argv[2]); /* kill file for overwrite */
|
||||
status = NXopen(argv[2],access,&self->fileHandle);
|
||||
if(status != NX_OK){
|
||||
sprintf(buffer,"ERROR: failed to open %s",argv[2]);
|
||||
@@ -223,7 +229,7 @@ static void putMotor(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
*/
|
||||
strcpy(buffer,argv[2]);
|
||||
strcat(buffer,"_null");
|
||||
if(NXDget(self->dictHandle,buffer,dummy,255)){
|
||||
if(NXDdefget(self->dictHandle,buffer,dummy,255)){
|
||||
MotorGetPar(brumm,"softzero",&fVal);
|
||||
status = NXDputalias(self->fileHandle,self->dictHandle,buffer, &fVal);
|
||||
if(status != NX_OK){
|
||||
@@ -295,7 +301,7 @@ static void putCounter(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
fVal = GetCountTime(cter,pCon);
|
||||
strcpy(newAlias,argv[2]);
|
||||
strcat(newAlias,"_time");
|
||||
if(NXDget(self->dictHandle,newAlias,dummy,79)){
|
||||
if(NXDdefget(self->dictHandle,newAlias,dummy,79)){
|
||||
status = NXDputalias(self->fileHandle,self->dictHandle,newAlias,&fVal);
|
||||
if(status != NX_OK){
|
||||
sprintf(buffer,"ERROR: failed to write count time to %s", newAlias);
|
||||
@@ -309,7 +315,7 @@ static void putCounter(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
*/
|
||||
for(i = 0; i < 10; i++){
|
||||
sprintf(newAlias,"%s_%2.2d",argv[2],i);
|
||||
if(NXDget(self->dictHandle,newAlias,dummy,79)){
|
||||
if(NXDdefget(self->dictHandle,newAlias,dummy,79)){
|
||||
counts = GetMonitor(cter,i,pCon);
|
||||
icounts = (int)counts;
|
||||
status = NXDputalias(self->fileHandle,self->dictHandle,newAlias,
|
||||
@@ -583,7 +589,7 @@ static void putTimeBinning(SConnection *pCon, SicsInterp *pSics,
|
||||
/*
|
||||
build definition string
|
||||
*/
|
||||
status = NXDget(self->dictHandle,argv[2],buffer,254);
|
||||
status = NXDdefget(self->dictHandle,argv[2],buffer,254);
|
||||
if(!status){
|
||||
sprintf(buffer,"ERROR: alias %s for time binning not found",
|
||||
argv[2]);
|
||||
@@ -661,7 +667,7 @@ static void putArray(SConnection *pCon, SicsInterp *pSics,
|
||||
}
|
||||
data[i] = (float)dVal;
|
||||
} else {
|
||||
sprintf(buffer,"WARNING: failed to find array element %d", i);
|
||||
snprintf(buffer,254,"WARNING: failed to find array element %d", i);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
}
|
||||
}
|
||||
@@ -669,7 +675,7 @@ static void putArray(SConnection *pCon, SicsInterp *pSics,
|
||||
/*
|
||||
build definition string
|
||||
*/
|
||||
status = NXDget(self->dictHandle,argv[2],buffer,254);
|
||||
status = NXDdefget(self->dictHandle,argv[2],buffer,254);
|
||||
if(!status){
|
||||
sprintf(buffer,"ERROR: alias %s for array not found",
|
||||
argv[2]);
|
||||
@@ -677,7 +683,7 @@ static void putArray(SConnection *pCon, SicsInterp *pSics,
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
sprintf(defString,"%s -dim {%d} ",buffer,length);
|
||||
snprintf(defString,511,"%s -dim {%d} ",buffer,length);
|
||||
|
||||
/*
|
||||
write it!
|
||||
@@ -750,7 +756,7 @@ static int handlePut(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
return 1;
|
||||
}
|
||||
Arg2Text(argc-3,&argv[3],buffer,1023);
|
||||
status = NXDget(self->dictHandle,argv[2],defString,1023);
|
||||
status = NXDdefget(self->dictHandle,argv[2],defString,1023);
|
||||
if(status != NX_OK){
|
||||
sprintf(buffer,"ERROR: alias %s not found in puttext",
|
||||
argv[2]);
|
||||
@@ -822,7 +828,23 @@ static void makeLink(SConnection *pCon, SicsInterp *pSics,
|
||||
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void updateDictVar(SConnection *pCon, pNXScript self, int argc,
|
||||
char *argv[]){
|
||||
int status;
|
||||
|
||||
if(self->dictHandle == NULL){
|
||||
SCWrite(pCon,"ERROR: cannot update variable, dictionary not open",
|
||||
eError);
|
||||
return;
|
||||
}
|
||||
if(argc < 4){
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to updateDictVar",
|
||||
eError);
|
||||
return;
|
||||
}
|
||||
NXDupdate(self->dictHandle,argv[2],argv[3]);
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
int NXScriptAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]){
|
||||
@@ -865,6 +887,11 @@ int NXScriptAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(strcmp(argv[1],"updatedictvar") == 0){
|
||||
updateDictVar(pCon,self,argc,argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(strstr(argv[1],"put") != NULL){
|
||||
handlePut(pCon,pSics,self,argc,argv);
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user