From 7780648e8a0fdee8a7ae417d8ffcab1886d71cad Mon Sep 17 00:00:00 2001 From: cvs Date: Wed, 14 Jan 2004 15:01:10 +0000 Subject: [PATCH] - New napi5.c with fix for deep group linking problem - New file name scheme implemented SKIPPED: psi/amorscan.c --- napi5.c | 2 +- nxdata.c | 15 ++++++++++++-- nxscript.c | 7 ++++--- nxscript.h | 1 + nxscript.w | 1 + scan.c | 59 +++++++----------------------------------------------- scan.i | 1 - scan.tex | 1 - scan.w | 1 - 9 files changed, 27 insertions(+), 61 deletions(-) diff --git a/napi5.c b/napi5.c index 0f83403a..28ba1082 100644 --- a/napi5.c +++ b/napi5.c @@ -1096,7 +1096,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid); strcpy(sLink->iTag5,pFile->name_ref); } else { /* group link */ - strcpy(buffer,pFile->iCurrentLGG); + strcpy(buffer, pFile->name_ref); strcat(buffer, sLink->iTag5); strcpy(sLink->iTag5,"/"); strcat(sLink->iTag5,buffer); diff --git a/nxdata.c b/nxdata.c index 80764f47..ff060a11 100644 --- a/nxdata.c +++ b/nxdata.c @@ -59,6 +59,7 @@ #include "HistMem.h" #include "udpquieck.h" #include "evcontroller.h" +#include "nxscript.h" #define DMCDETNAM "DMC-BF3-Detector" @@ -74,9 +75,19 @@ pCon = (SConnection *)pData; SCWrite(pCon,text,eError); } - +/*-----------------------------------------------------------------------*/ +char *SNXMakeFileName(SicsInterp *pSics, SConnection *pCon) +{ + char *pPtr = NULL; + pPtr = makeFilename(pSics,pCon); + if(pPtr == NULL) + { + pPtr = strdup("emergency.hdf"); + } + return pPtr; +} /*------------------------------------------------------------------------*/ - char *SNXMakeFileName(SicsInterp *pSics, SConnection *pCon) + char *SNXMakeFileNameOld(SicsInterp *pSics, SConnection *pCon) { pSicsVariable pPath = NULL, pPref = NULL, pEnd = NULL; char *pRes = NULL; diff --git a/nxscript.c b/nxscript.c index 2b13e12d..f191c1ee 100644 --- a/nxscript.c +++ b/nxscript.c @@ -64,7 +64,7 @@ char *makeFilename(SicsInterp *pSics, SConnection *pCon) { /* find length */ iLen = strlen(pPath->text) + 4; /* extra 4 for dir number */ iLen += strlen(pPref->text); - iLen += 8; /* for number + year */ + iLen += 9; /* for number + year */ iLen += strlen(pEnd->text); iLen += 10; /* safety margin */ @@ -106,10 +106,11 @@ char *makeFilename(SicsInterp *pSics, SConnection *pCon) { */ strcat(pRes,"/"); strcat(pRes,pPref->text); - sprintf(pNumText,"%5.5d",iNum); - strcat(pRes,pNumText); sprintf(pNumText,"%4.4d",iYear); strcat(pRes,pNumText); + strcat(pRes,"n"); + sprintf(pNumText,"%5.5d",iNum); + strcat(pRes,pNumText); strcat(pRes,pEnd->text); return pRes; diff --git a/nxscript.h b/nxscript.h index 860a67c0..8fb88926 100644 --- a/nxscript.h +++ b/nxscript.h @@ -17,4 +17,5 @@ int MakeNXScript(SConnection *pCon, SicsInterp *pSics, void *pData, int NXScriptAction(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]); +char *makeFilename(SicsInterp *pSics, SConnection *pCon); #endif diff --git a/nxscript.w b/nxscript.w index d539ce3a..cd54dae5 100644 --- a/nxscript.w +++ b/nxscript.w @@ -43,6 +43,7 @@ int MakeNXScript(SConnection *pCon, SicsInterp *pSics, void *pData, int NXScriptAction(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]); +char *makeFilename(SicsInterp *pSics, SConnection *pCon); #endif @} diff --git a/scan.c b/scan.c index b71fdbb1..cea764c6 100644 --- a/scan.c +++ b/scan.c @@ -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", diff --git a/scan.i b/scan.i index 940c928f..8da81bfe 100644 --- a/scan.i +++ b/scan.i @@ -32,7 +32,6 @@ int iMode; float fPreset; char pFile[1024]; - char ext[5]; FILE *fd; SicsInterp *pSics; SConnection *pCon; diff --git a/scan.tex b/scan.tex index cef6af28..aa0ebeb8 100644 --- a/scan.tex +++ b/scan.tex @@ -60,7 +60,6 @@ $\langle$scandata {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ int iMode;@\\ \mbox{}\verb@ float fPreset;@\\ \mbox{}\verb@ char pFile[1024];@\\ -\mbox{}\verb@ char ext[5];@\\ \mbox{}\verb@ FILE *fd;@\\ \mbox{}\verb@ SicsInterp *pSics;@\\ \mbox{}\verb@ SConnection *pCon;@\\ diff --git a/scan.w b/scan.w index 41a9ffb2..199cc5be 100644 --- a/scan.w +++ b/scan.w @@ -55,7 +55,6 @@ steps in scan processing which is already partly implemented. int iMode; float fPreset; char pFile[1024]; - char ext[5]; FILE *fd; SicsInterp *pSics; SConnection *pCon;