PSI sics-cvs-psi-complete-tree-post-site-support
This commit is contained in:
103
scan.c
103
scan.c
@@ -25,16 +25,17 @@
|
||||
#include "udpquieck.h"
|
||||
#include "splitter.h"
|
||||
#include "danu.h"
|
||||
#include "amorscan.h"
|
||||
#include "userscan.h"
|
||||
#include "motor.h"
|
||||
#include "nxscript.h"
|
||||
#include "site.h"
|
||||
|
||||
extern void SNXFormatTime(char *pBuffer, int iLen);
|
||||
/*
|
||||
from nxdata.c
|
||||
*/
|
||||
/*------------------------------------------------------------------------*/
|
||||
char *ScanMakeFileName(SicsInterp *pSics, SConnection *pCon, char *pExt)
|
||||
char *ScanMakeFileName(SicsInterp *pSics, SConnection *pCon)
|
||||
{
|
||||
pSicsVariable pPath = NULL, pPref = NULL, pEnd = NULL;
|
||||
char *pRes = NULL;
|
||||
@@ -48,55 +49,11 @@ extern void SNXFormatTime(char *pBuffer, int iLen);
|
||||
if(pServ->simMode)
|
||||
return strdup("sim001001901.sim");
|
||||
|
||||
|
||||
/* Try, get all the Variables */
|
||||
pPath = FindVariable(pSics,"sicsdatapath");
|
||||
pPref = FindVariable(pSics,"sicsdataprefix");
|
||||
pCom = FindCommand(pSics,"sicsdatanumber");
|
||||
|
||||
if( (!pPath) || (!pPref) || (!pCom))
|
||||
pRes = makeFilename(pSics,pCon);
|
||||
if(pRes == NULL)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: cannot read variables for automatic data file name creation",
|
||||
eError);
|
||||
SCWrite(pCon,"ERROR: This is a VERY, VERY, VERY serious installation problem",
|
||||
eError);
|
||||
SCWrite(pCon,"ERROR: your data will be dumped into emergency.hdf",eError);
|
||||
return strdup("emergency.hdf");
|
||||
pRes = strdup("emergency.scn");
|
||||
}
|
||||
|
||||
/* find length */
|
||||
iLen = strlen(pPath->text);
|
||||
iLen += strlen(pPref->text);
|
||||
iLen += 8; /* for number + year */
|
||||
iLen += 3;
|
||||
iLen += 10; /* safety margin */
|
||||
|
||||
/* allocate memory */
|
||||
pRes = (char *)malloc(iLen*sizeof(char));
|
||||
if(!pRes)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: no memory in SNXMakeFileName",eError);
|
||||
return NULL;
|
||||
}
|
||||
memset(pRes,0,iLen);
|
||||
|
||||
/* build the filename */
|
||||
strcpy(pRes,pPath->text);
|
||||
strcat(pRes,pPref->text);
|
||||
iNum = IncrementDataNumber(pCom->pData,&iYear);
|
||||
if(iNum < 0)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: cannot increment data number!",eError);
|
||||
SCWrite(pCon,"ERROR: your data will be dumped to emergency.dat",eError);
|
||||
free(pRes);
|
||||
return strdup("emergency.dat");
|
||||
}
|
||||
sprintf(pNumText,"%5.5d",iNum);
|
||||
strcat(pRes,pNumText);
|
||||
sprintf(pNumText,"%4.4d",iYear);
|
||||
strcat(pRes,pNumText);
|
||||
strcat(pRes,pExt);
|
||||
|
||||
return pRes;
|
||||
}
|
||||
@@ -509,7 +466,6 @@ extern void SNXFormatTime(char *pBuffer, int iLen);
|
||||
pNew->ScanDrive = ScanDrive;
|
||||
pNew->ScanCount = ScanCount;
|
||||
pNew->CollectScanData = CollectScanData;
|
||||
strcpy(pNew->ext,".dat");
|
||||
pNew->iWindow = 6;
|
||||
|
||||
return pNew;
|
||||
@@ -557,7 +513,7 @@ extern void SNXFormatTime(char *pBuffer, int iLen);
|
||||
self->ScanDrive = ScanDrive;
|
||||
self->ScanCount = ScanCount;
|
||||
self->CollectScanData = CollectScanData;
|
||||
strcpy(self->ext,".dat");
|
||||
self->posSoft = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1234,6 +1190,10 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
case eContinue:
|
||||
break;
|
||||
case eAbortOperation:
|
||||
SCSetInterrupt(self->pCon,eContinue);
|
||||
SCWrite(self->pCon,
|
||||
"WARNING: skipped scan point due to motor failure",
|
||||
eWarning);
|
||||
continue;
|
||||
break;
|
||||
case eAbortScan:
|
||||
@@ -1357,7 +1317,7 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
}
|
||||
|
||||
/* allocate a new data file */
|
||||
pPtr = ScanMakeFileName(self->pSics,self->pCon,self->ext);
|
||||
pPtr = ScanMakeFileName(self->pSics,self->pCon);
|
||||
if(!pPtr)
|
||||
{
|
||||
SCWrite(self->pCon,
|
||||
@@ -1487,7 +1447,7 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
|
||||
|
||||
/* new scan data file */
|
||||
pPtr = ScanMakeFileName(self->pSics,self->pCon,self->ext);
|
||||
pPtr = ScanMakeFileName(self->pSics,self->pCon);
|
||||
if(!pPtr)
|
||||
{
|
||||
SCWrite(self->pCon,"ERROR: cannot allocate new data filename, Scan aborted",
|
||||
@@ -1715,6 +1675,10 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
int isScanVarSoft(pScanData self){
|
||||
return self->posSoft;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int GetScanVarStep(pScanData self, int iWhich, float *fStep)
|
||||
{
|
||||
@@ -2033,6 +1997,7 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
float fSum, fVar;
|
||||
double x;
|
||||
float fPos, FWHM, fHeight;
|
||||
pSite site = NULL;
|
||||
|
||||
self = (pScanData)pData;
|
||||
assert(self);
|
||||
@@ -2309,6 +2274,9 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
SCWrite(pCon,"ERROR: missing configure option",eError);
|
||||
return 0;
|
||||
}
|
||||
/* this is for userss only */
|
||||
if(!SCMatchRights(pCon,usUser))
|
||||
return 0;
|
||||
strtolower(argv[2]);
|
||||
if(strcmp(argv[2],"standard") == 0)
|
||||
{
|
||||
@@ -2316,15 +2284,6 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[2],"amor") == 0)
|
||||
{
|
||||
/* managers only */
|
||||
if(!SCMatchRights(pCon,usMugger))
|
||||
return 0;
|
||||
ConfigureAmor(self);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[2],"user") == 0)
|
||||
{
|
||||
ConfigureUserScan(self);
|
||||
@@ -2335,16 +2294,26 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
{
|
||||
ResetScanFunctions(self);
|
||||
self->CollectScanData = CollectScanDataJochen;
|
||||
self->posSoft = 1;
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: option %s not recognized by configure",
|
||||
argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
site = getSite();
|
||||
if(site != NULL){
|
||||
iRet = site->ConfigureScan(self,argv[2]);
|
||||
}
|
||||
if(!iRet){
|
||||
sprintf(pBueffel,"ERROR: option %s not recognized by configure",
|
||||
argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
} else {
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------- scan */
|
||||
else if(strcmp(argv[1],"run") == 0)
|
||||
|
||||
Reference in New Issue
Block a user