- New batch file management module

- New oscillator module
- Bug fixes


SKIPPED:
	psi/buffer.c
	psi/el734hp.c
	psi/el737hpdriv.c
	psi/make_gen
	psi/nextrics.c
	psi/nxamor.c
	psi/pimotor.c
	psi/polterwrite.c
	psi/psi.c
	psi/swmotor2.c
	psi/tasscan.c
	psi/tricssupport.c
	psi/tricssupport.h
	psi/tecs/make_gen
	psi/utils/ecb_load_new/ecb_load.c
	psi/utils/ecb_load_new/ecb_load.h
	psi/utils/ecb_load_new/ecbdriv_els.c
	psi/utils/ecb_load_new/gpib_els.c
	psi/utils/ecb_load_new/makefile
	psi/utils/ecb_load_new/makefile_EGPIB
	psi/utils/ecb_load_new/makefile_GPIB
This commit is contained in:
cvs
2004-11-17 10:50:15 +00:00
parent f7c8ae30c6
commit 0f4e959e22
46 changed files with 3675 additions and 834 deletions

264
napi.c
View File

@@ -23,13 +23,12 @@
----------------------------------------------------------------------------*/
static const char* rscid = "$Id: napi.c,v 1.7 2003/05/23 15:06:47 cvs Exp $"; /* Revision interted by CVS */
static const char* rscid = "$Id: napi.c,v 1.8 2004/11/17 10:50:16 cvs Exp $"; /* Revision interted by CVS */
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <time.h>
#include "fortify.h"
#include "napi.h"
/*
@@ -71,13 +70,13 @@ static const char* rscid = "$Id: napi.c,v 1.7 2003/05/23 15:06:47 cvs Exp $"; /*
/*------------------------------------------------------------------------
HDF-5 cache size special stuff
-------------------------------------------------------------------------*/
static long cacheSize = 1024000; /* 1MB, HDF-5 default */
long nx_cacheSize = 1024000; /* 1MB, HDF-5 default */
NXstatus CALLING_STYLE NXsetcache(long newVal)
{
if(newVal > 0)
{
cacheSize = newVal;
nx_cacheSize = newVal;
return NX_OK;
}
return NX_ERROR;
@@ -98,7 +97,7 @@ NXstatus CALLING_STYLE NXsetcache(long newVal)
/*---------------------------------------------------------------------*/
void CALLING_STYLE NXMSetError(void *pData, void (*NewError)(void *pD, char *text))
NX_EXTERNAL void CALLING_STYLE NXMSetError(void *pData, void (*NewError)(void *pD, char *text))
{
NXpData = pData;
NXIReportError = NewError;
@@ -126,6 +125,7 @@ NXstatus CALLING_STYLE NXsetcache(long newVal)
NXhandle hdf5_handle;
NXhandle hdf4_handle;
pNexusFunction fHandle;
NXstatus retstat;
/* configure fortify
iFortifyScope = Fortify_EnterScope();
@@ -165,7 +165,11 @@ NXstatus CALLING_STYLE NXsetcache(long newVal)
if (hdf_type==1) {
/* HDF4 type */
#ifdef HDF4
NX4open((const char *)filename,am,&hdf4_handle);
retstat = NX4open((const char *)filename,am,&hdf4_handle);
if(retstat != NX_OK){
free(fHandle);
return retstat;
}
fHandle->pNexusData=hdf4_handle;
fHandle->nxclose=NX4close;
fHandle->nxflush=NX4flush;
@@ -194,13 +198,21 @@ NXstatus CALLING_STYLE NXsetcache(long newVal)
fHandle->nxsameID=NX4sameID;
fHandle->nxinitgroupdir=NX4initgroupdir;
fHandle->nxinitattrdir=NX4initattrdir;
#endif
*gHandle = fHandle;
return NX_OK;
#else
NXIReportError (NXpData,"ERROR: Attempt to create HDF4 file when not linked with HDF4");
*gHandle = NULL;
retstat = NX_ERROR;
#endif /* HDF4 */
return retstat;
} else if (hdf_type==2) {
/* HDF5 type */
#ifdef HDF5
NX5open(filename,am,&hdf5_handle);
retstat = NX5open(filename,am,&hdf5_handle);
if(retstat != NX_OK){
free(fHandle);
return retstat;
}
fHandle->pNexusData=hdf5_handle;
fHandle->nxclose=NX5close;
fHandle->nxflush=NX5flush;
@@ -229,11 +241,16 @@ NXstatus CALLING_STYLE NXsetcache(long newVal)
fHandle->nxsameID=NX5sameID;
fHandle->nxinitgroupdir=NX5initgroupdir;
fHandle->nxinitattrdir=NX5initattrdir;
#endif
*gHandle = fHandle;
return NX_OK;
#else
NXIReportError (NXpData,"ERROR: Attempt to create HDF5 file when not linked with HDF5");
*gHandle = NULL;
retstat = NX_ERROR;
#endif /* HDF5 */
return retstat;
} else {
NXIReportError (NXpData,"ERROR: Format not readable by this NeXus library");
NXIReportError (NXpData,
"ERROR: Format not readable by this NeXus library");
*gHandle = NULL;
return NX_ERROR;
}
@@ -539,6 +556,229 @@ NXstatus CALLING_STYLE NXsetcache(long newVal)
pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxinitgroupdir(pFunc->pNexusData);
}
/*------------------------------------------------------------------------
Implementation of NXopenpath.
--------------------------------------------------------------------------*/
static int isDataSetOpen(NXhandle hfil)
{
NXlink id;
/*
This uses the (sensible) feauture that NXgetdataID returns NX_ERROR
when no dataset is open
*/
if(NXgetdataID(hfil,&id) == NX_ERROR)
{
return 0;
}
else
{
return 1;
}
}
/*----------------------------------------------------------------------*/
static int isRoot(NXhandle hfil)
{
NXlink id;
/*
This uses the feauture that NXgetgroupID returns NX_ERROR
when we are at root level
*/
if(NXgetgroupID(hfil,&id) == NX_ERROR)
{
return 1;
}
else
{
return 0;
}
}
/*--------------------------------------------------------------------
copies the next path element into element.
returns a pointer into path beyond the extracted path
---------------------------------------------------------------------*/
static char *extractNextPath(char *path, NXname element)
{
char *pPtr, *pStart;
int length;
pPtr = path;
/*
skip over leading /
*/
if(*pPtr == '/')
{
pPtr++;
}
pStart = pPtr;
/*
find next /
*/
pPtr = strchr(pStart,'/');
if(pPtr == NULL)
{
/*
this is the last path element
*/
strcpy(element,pStart);
return NULL;
} else {
length = pPtr - pStart;
strncpy(element,pStart,length);
element[length] = '\0';
}
return pPtr + 1;
}
/*-------------------------------------------------------------------*/
static NXstatus gotoRoot(NXhandle hfil)
{
int status;
if(isDataSetOpen(hfil))
{
status = NXclosedata(hfil);
if(status == NX_ERROR)
{
return status;
}
}
while(!isRoot(hfil))
{
status = NXclosegroup(hfil);
if(status == NX_ERROR)
{
return status;
}
}
return NX_OK;
}
/*--------------------------------------------------------------------*/
static int isRelative(char *path)
{
if(path[0] == '.' && path[1] == '.')
return 1;
else
return 0;
}
/*------------------------------------------------------------------*/
static NXstatus moveOneDown(NXhandle hfil)
{
if(isDataSetOpen(hfil))
{
return NXclosedata(hfil);
}
else
{
return NXclosegroup(hfil);
}
}
/*-------------------------------------------------------------------
returns a pointer to the remaining path string to move up
--------------------------------------------------------------------*/
static char *moveDown(NXhandle hfil, char *path, int *code)
{
int status;
NXname pathElem;
char *pPtr;
*code = NX_OK;
if(path[0] == '/')
{
*code = gotoRoot(hfil);
return path;
}
else
{
pPtr = path;
while(isRelative(pPtr))
{
status = moveOneDown(hfil);
if(status == NX_ERROR)
{
*code = status;
return pPtr;
}
pPtr += 3;
}
return pPtr;
}
}
/*--------------------------------------------------------------------*/
static NXstatus stepOneUp(NXhandle hfil, char *name)
{
int status, datatype;
NXname name2, xclass;
char pBueffel[256];
/*
catch the case when we are there: i.e. no further stepping
necessary. This can happen with paths like ../
*/
if(strlen(name) < 1)
{
return NX_OK;
}
NXinitgroupdir(hfil);
while(NXgetnextentry(hfil,name2,xclass,&datatype) != NX_EOD)
{
if(strcmp(name2,name) == 0)
{
if(strcmp(xclass,"SDS") == 0)
{
return NXopendata(hfil,name);
}
else
{
return NXopengroup(hfil,name,xclass);
}
}
}
snprintf(pBueffel,255,"ERROR: NXopenpath cannot step into %s",name);
NXIReportError (NXpData, pBueffel);
return NX_ERROR;
}
/*---------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXopenpath(NXhandle hfil, CONSTCHAR *path)
{
int status, run = 1;
NXname pathElement;
char *pPtr;
if(hfil == NULL || path == NULL)
{
NXIReportError(NXpData,
"ERROR: NXopendata needs both a file handle and a path string");
return NX_ERROR;
}
pPtr = moveDown(hfil,(char *)path,&status);
if(status != NX_OK)
{
NXIReportError (NXpData,
"ERROR: NXopendata failed to move down in hierarchy");
return status;
}
while(run == 1)
{
pPtr = extractNextPath(pPtr, pathElement);
status = stepOneUp(hfil,pathElement);
if(status != NX_OK)
{
return status;
}
if(pPtr == NULL)
{
run = 0;
}
}
return NX_OK;
}
/*----------------------------------------------------------------------
F77 - API - Support - Routines
----------------------------------------------------------------------*/