- New napi5.c with fix for deep group linking problem

- New file name scheme implemented


SKIPPED:
	psi/amorscan.c
This commit is contained in:
cvs
2004-01-14 15:01:10 +00:00
parent 0fb0458341
commit 7780648e8a
9 changed files with 27 additions and 61 deletions

59
scan.c
View File

@ -27,6 +27,7 @@
#include "danu.h"
#include "userscan.h"
#include "motor.h"
#include "nxscript.h"
#include "site.h"
extern void SNXFormatTime(char *pBuffer, int iLen);
@ -34,7 +35,7 @@ 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;
@ -558,7 +514,6 @@ extern void SNXFormatTime(char *pBuffer, int iLen);
self->ScanCount = ScanCount;
self->CollectScanData = CollectScanData;
self->posSoft = 0;
strcpy(self->ext,".dat");
return 1;
}
@ -1362,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,
@ -1492,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",