- Fixes to make SL6 work
- New NeXus libraries - Added new raw binary transfer mode for mass data - Added a check script option to configurable virtual motor SKIPPED: psi/dumprot.c psi/make_gen psi/psi.c psi/rebin.c psi/sanslirebin.c
This commit is contained in:
@ -32,6 +32,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <strlutil.h>
|
||||
@ -43,7 +44,8 @@
|
||||
#define DATASOCKET 1
|
||||
#define MAXCONNECTIONS 1024
|
||||
#define RBUFFERSIZE 262144 /* 256kb */
|
||||
#define WBUFFERSIZE 20*262144 /* */
|
||||
#define WBUFFERSIZE 20*262144
|
||||
/* #define WBUFFERSIZE 100*262144 /*
|
||||
/*--------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
int socket;
|
||||
@ -198,6 +200,8 @@ int ANETregisterSocket(int socket)
|
||||
if (status < 0) {
|
||||
return ANETSOCKERROR;
|
||||
}
|
||||
flags =1;
|
||||
setsockopt(socket,IPPROTO_TCP,TCP_NODELAY,(char *) &flags, sizeof(int));
|
||||
socke.readBuffer = MakeRWPuffer(RBUFFERSIZE);
|
||||
socke.writeBuffer = MakeRWPuffer(WBUFFERSIZE);
|
||||
if (socke.readBuffer == NULL || socke.writeBuffer == NULL) {
|
||||
|
@ -13,8 +13,9 @@
|
||||
|
||||
#include "sics.h"
|
||||
|
||||
int MakeConfigurableVirtualMotor(SConnection * pCon, SicsInterp * pSics,
|
||||
void *data, int aargc, char *argv[]);
|
||||
int ConfigurableVirtualMotorAction(SConnection * pCon, SicsInterp * pSics,
|
||||
void *data, int argc, char *argv[]);
|
||||
int MakeConfigurableVirtualMotor(SConnection *pCon, SicsInterp *pSics,
|
||||
void *data, int aargc, char *argv[]);
|
||||
int ConfigurableVirtualMotorAction(SConnection *pCon, SicsInterp *pSics,
|
||||
void *data, int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
|
@ -5,18 +5,19 @@
|
||||
-----------------------------------------------------------------------*/
|
||||
|
||||
typedef struct __CONFVIRTMOT {
|
||||
pObjectDescriptor pDes;
|
||||
pIDrivable pDriv;
|
||||
pICallBack pCall;
|
||||
char *name;
|
||||
char *scriptName;
|
||||
char *readScript;
|
||||
int motorList;
|
||||
float targetValue;
|
||||
int targetReached;
|
||||
int posCount;
|
||||
char scriptError[512];
|
||||
int parseOK;
|
||||
pObjectDescriptor pDes;
|
||||
pIDrivable pDriv;
|
||||
pICallBack pCall;
|
||||
char *name;
|
||||
char *scriptName;
|
||||
char *readScript;
|
||||
char *checkScript;
|
||||
int motorList;
|
||||
float targetValue;
|
||||
int targetReached;
|
||||
int posCount;
|
||||
char scriptError[512];
|
||||
int parseOK;
|
||||
}ConfigurableVirtualMotor, *pConfigurableVirtualMotor;
|
||||
|
||||
|
||||
|
@ -289,7 +289,24 @@ static int InterestCallback(int iEvent, void *pEvent, void *pUser)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static void invokeCheckScript(pConfigurableVirtualMotor self,
|
||||
SConnection * pCon)
|
||||
{
|
||||
Tcl_Interp *pTcl;
|
||||
int status;
|
||||
|
||||
pTcl = InterpGetTcl(pServ->pSics);
|
||||
|
||||
if(self->checkScript != NULL){
|
||||
status = Tcl_Eval(pTcl, self->readScript);
|
||||
if (status != TCL_OK) {
|
||||
snprintf(self->scriptError, 510, "ERROR: Tcl subsystem reported %s",
|
||||
Tcl_GetStringResult(pTcl));
|
||||
SCWrite(pCon, self->scriptError, eError);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int ConfCheckStatus(void *pData, SConnection * pCon)
|
||||
{
|
||||
@ -327,6 +344,7 @@ static int ConfCheckStatus(void *pData, SConnection * pCon)
|
||||
}
|
||||
|
||||
if (result == HWIdle) {
|
||||
invokeCheckScript(self,pCon);
|
||||
event.pName = self->name;
|
||||
event.fVal = self->pDriv->GetValue(self, pCon);
|
||||
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
||||
@ -575,6 +593,26 @@ int ConfigurableVirtualMotorAction(SConnection * pCon, SicsInterp * pSics,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
} else if (strcmp(argv[1], "checkscript") == 0) {
|
||||
if (argc > 2) {
|
||||
/* set case */
|
||||
Arg2Text(argc - 2, &argv[2], pBueffel, 510);
|
||||
self->checkScript = strdup(pBueffel);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
} else {
|
||||
/* inquiry */
|
||||
if (self->checkScript == NULL) {
|
||||
snprintf(pBueffel, 510, "%s.checkscript = UNDEFINED", argv[0]);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
return 1;
|
||||
} else {
|
||||
snprintf(pBueffel, 510, "%s.checkscript = %s", argv[0],
|
||||
self->checkScript);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
} else if (strcmp(argv[1], "interest") == 0) {
|
||||
pRegInfo = (pRegisteredInfo) malloc(sizeof(RegisteredInfo));
|
||||
if (!pRegInfo) {
|
||||
@ -584,7 +622,7 @@ int ConfigurableVirtualMotorAction(SConnection * pCon, SicsInterp * pSics,
|
||||
pRegInfo->pName = strdup(argv[0]);
|
||||
pRegInfo->pCon = SCCopyConnection(pCon);
|
||||
value = ConfGetValue(self, pCon);
|
||||
if (!iRet) {
|
||||
if (value < -9990.) {
|
||||
snprintf(pBueffel,511,
|
||||
"Failed to register interest, Reason:Error obtaining current position for %s",
|
||||
argv[0]);
|
||||
|
@ -16,6 +16,7 @@ typedef struct __CONFVIRTMOT {
|
||||
char *name;
|
||||
char *scriptName;
|
||||
char *readScript;
|
||||
char *checkScript;
|
||||
int motorList;
|
||||
float targetValue;
|
||||
int targetReached;
|
||||
@ -33,6 +34,7 @@ The fields are:
|
||||
\item[scriptName] The name of the program to calculate the new positions
|
||||
of the real motors.
|
||||
\item[readScript] A script to read back the current value of the virtual motor.
|
||||
\item[checkScript] A script to check for success at the end of driving.
|
||||
\item[motorList] A list of the motors to start and control.
|
||||
\item[targetValue] The target value we wanted to have.
|
||||
\item[posCount] This counter prevents the callback from being invoked too often. The frequency is currently set to every 10 cycles through the task loop.
|
||||
|
156
conman.c
156
conman.c
@ -1066,6 +1066,162 @@ int SCWriteUUencoded(SConnection * pCon, char *pName, void *pData,
|
||||
#define ZIPBUF 8192
|
||||
int SCWriteZipped(SConnection * self, char *pName, void *pData,
|
||||
int iDataLen)
|
||||
{
|
||||
char outBuf[65536], *pBuf = NULL, noutBuf[ZIPBUF], *pHeader = NULL;
|
||||
int compressedLength, iRet, iRet2, iCount, protocolID;
|
||||
z_stream compStream;
|
||||
commandContext cc;
|
||||
|
||||
/* check for a valid connection */
|
||||
if (!VerifyConnection(self)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* a telnet connection will corrupt the compressed stream, so
|
||||
stop it!
|
||||
*/
|
||||
if (self->iTelnet) {
|
||||
SCWrite(self,
|
||||
"ERROR: the telnet protocol will corrupt compressed data!",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
do nothing if no data
|
||||
*/
|
||||
if (pName == NULL || pData == NULL) {
|
||||
SCWrite(self, "ERROR: no data to write in SCWriteZiped", eError);
|
||||
return 0;
|
||||
}
|
||||
pBuf = malloc(iDataLen*sizeof(char));
|
||||
memset(pBuf,0,iDataLen*sizeof(char));
|
||||
|
||||
compStream.zalloc = (alloc_func) NULL;
|
||||
compStream.zfree = (free_func) NULL;
|
||||
compStream.opaque = (voidpf) NULL;
|
||||
/* iRet = deflateInit(&compStream, Z_DEFAULT_COMPRESSION); */
|
||||
iRet = deflateInit(&compStream, 2);
|
||||
if (iRet != Z_OK) {
|
||||
sprintf(outBuf, "ERROR: zlib error: %d", iRet);
|
||||
SCWrite(self, outBuf, eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
compStream.next_in = (Bytef *) pData;
|
||||
compStream.next_out = (Bytef *) pBuf;
|
||||
compStream.avail_in = iDataLen;
|
||||
compStream.avail_out = iDataLen;
|
||||
iRet = deflate(&compStream, Z_FINISH);
|
||||
if (iRet != Z_STREAM_END) {
|
||||
sprintf(outBuf, "ERROR: zlib error: %d", iRet);
|
||||
SCWrite(self, outBuf, eError);
|
||||
return 0;
|
||||
}
|
||||
compressedLength = compStream.total_out;
|
||||
|
||||
|
||||
/* write header line */
|
||||
memset(outBuf, 0, 65536);
|
||||
|
||||
protocolID = GetProtocolID(self);
|
||||
if (protocolID == 5) {
|
||||
cc = SCGetContext(self);
|
||||
sprintf(outBuf, "SICSBIN ZIP %s %d %d\r\n", pName,
|
||||
compressedLength, cc.transID);
|
||||
} else {
|
||||
sprintf(outBuf, "SICSBIN ZIP %s %d \r\n", pName, compressedLength);
|
||||
}
|
||||
pHeader = strdup(outBuf);
|
||||
if (pHeader == NULL) {
|
||||
SCWrite(self, "ERROR: out of memory in SCWriteZipped", eError);
|
||||
return 0;
|
||||
}
|
||||
traceCommand(ConID(self),"out:SICSBIN ZIP %s %d", pName, compressedLength);
|
||||
|
||||
|
||||
iRet = ANETwrite(self->sockHandle, pHeader, strlen(pHeader));
|
||||
iRet = ANETwrite(self->sockHandle, pBuf, compStream.total_out);
|
||||
if (iRet != 1) {
|
||||
sprintf(outBuf, "ERROR: network error %d on zipped send", iRet);
|
||||
SCWrite(self, outBuf, eError);
|
||||
return 0;
|
||||
}
|
||||
/* printf("Sent zipped data: %s with %d\n", pHeader, iRet); */
|
||||
|
||||
deflateEnd(&compStream);
|
||||
free(pHeader);
|
||||
free(pBuf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
int SCWriteBinary(SConnection * self, char *pName, void *pData,
|
||||
int iDataLen)
|
||||
{
|
||||
char outBuf[65536], *pHeader = NULL;
|
||||
int iRet, iRet2, iCount, protocolID;
|
||||
commandContext cc;
|
||||
|
||||
/* check for a valid connection */
|
||||
if (!VerifyConnection(self)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* a telnet connection will corrupt the compressed stream, so
|
||||
stop it!
|
||||
*/
|
||||
if (self->iTelnet) {
|
||||
SCWrite(self,
|
||||
"ERROR: the telnet protocol will corrupt compressed data!",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
do nothing if no data
|
||||
*/
|
||||
if (pName == NULL || pData == NULL) {
|
||||
SCWrite(self, "ERROR: no data to write in SCWriteZiped", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* write header line */
|
||||
memset(outBuf, 0, 65536);
|
||||
|
||||
protocolID = GetProtocolID(self);
|
||||
if (protocolID == 5) {
|
||||
cc = SCGetContext(self);
|
||||
sprintf(outBuf, "SICSBIN BIN %s %d %d\r\n", pName,
|
||||
iDataLen, cc.transID);
|
||||
} else {
|
||||
sprintf(outBuf, "SICSBIN BIN %s %d \r\n", pName, iDataLen);
|
||||
}
|
||||
pHeader = strdup(outBuf);
|
||||
if (pHeader == NULL) {
|
||||
SCWrite(self, "ERROR: out of memory in SCWriteBinary", eError);
|
||||
return 0;
|
||||
}
|
||||
traceCommand(ConID(self),"out:SICSBIN BIN %s %d", pName, iDataLen);
|
||||
|
||||
iRet = ANETwrite(self->sockHandle, pHeader, strlen(pHeader));
|
||||
iRet = ANETwrite(self->sockHandle, pData, iDataLen);
|
||||
if (iRet != 1) {
|
||||
sprintf(outBuf, "ERROR: network error %d on zipped send", iRet);
|
||||
SCWrite(self, outBuf, eError);
|
||||
return 0;
|
||||
}
|
||||
/* printf("Sent zipped data: %s with %d\n", pHeader, iRet); */
|
||||
|
||||
free(pHeader);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------
|
||||
* left in for documentation............
|
||||
*/
|
||||
int SCWriteZippedOld(SConnection * self, char *pName, void *pData,
|
||||
int iDataLen)
|
||||
{
|
||||
char outBuf[65546], *pBuf = NULL, noutBuf[ZIPBUF], *pHeader = NULL;
|
||||
int compressedLength, iRet, iRet2, iCount, protocolID;
|
||||
|
4
conman.h
4
conman.h
@ -15,7 +15,7 @@
|
||||
|
||||
copyright: see copyright.h
|
||||
|
||||
substantially for the new asynchronous I/O system
|
||||
substantially revised for the new asynchronous I/O system
|
||||
|
||||
Mark Koennecke, January 2009
|
||||
----------------------------------------------------------------------------*/
|
||||
@ -100,6 +100,8 @@ int SCWriteUUencoded(SConnection * pCon, char *pName, void *iData,
|
||||
int iLen);
|
||||
int SCWriteZipped(SConnection * pCon, char *pName, void *pData,
|
||||
int iDataLen);
|
||||
int SCWriteBinary(SConnection * pCon, char *pName, void *pData,
|
||||
int iDataLen);
|
||||
writeFunc SCGetWriteFunc(SConnection * pCon);
|
||||
void SCSetWriteFunc(SConnection * pCon, writeFunc x);
|
||||
int SCOnlySockWrite(SConnection * self, char *buffer, int iOut);
|
||||
|
10
fourmess.c
10
fourmess.c
@ -877,7 +877,7 @@ static int SortRef(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
static int SortRefNew(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
pHdb par[], int nPar)
|
||||
{
|
||||
double *sortlist, d, lambda, om, hkl[4], ang[4];
|
||||
double *sortlist, d, lambda, om, hkl[4], ang[5];
|
||||
const double *cell;
|
||||
double *hklc;
|
||||
int nRefl, i, j, status, count;
|
||||
@ -916,6 +916,12 @@ static int SortRefNew(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
* 10.
|
||||
*/
|
||||
hkl[3] = ang[2]+10 + 0.1 * ang[0];
|
||||
} else if(mode == BiNB){
|
||||
/*
|
||||
* sort for nu in the first place. In order to cope with negativity, add
|
||||
* 10.
|
||||
*/
|
||||
hkl[3] = ang[4]+10 + 0.1 * ang[0];
|
||||
} else {
|
||||
hkl[3] = ang[0];
|
||||
}
|
||||
@ -1007,7 +1013,7 @@ static int ReadTour(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
{
|
||||
FILE *fd = NULL;
|
||||
char buffer[132];
|
||||
double hkl[4], ang[4];
|
||||
double hkl[4], ang[5];
|
||||
int idx, tour;
|
||||
pFourMess priv = self->pPrivate;
|
||||
pSingleDiff diffi = NULL;
|
||||
|
@ -974,9 +974,12 @@ int copyHdbValue(hdbValue * source, hdbValue * target)
|
||||
target->arrayLength = source->arrayLength;
|
||||
}
|
||||
if (source->v.intArray != NULL) {
|
||||
/*
|
||||
for (i = 0; i < source->arrayLength; i++) {
|
||||
target->v.intArray[i] = source->v.intArray[i];
|
||||
}
|
||||
*/
|
||||
memcpy(target->v.intArray,source->v.intArray,source->arrayLength*sizeof(int));
|
||||
}
|
||||
break;
|
||||
case HIPFLOATAR:
|
||||
|
106
hkl.c
106
hkl.c
@ -395,13 +395,13 @@ int hklInRange(void *data, double fSet[4], int mask[4])
|
||||
often restricted due to the cryogenic garbage around the sample.
|
||||
-------------------------------------------------------------------------*/
|
||||
int CalculateSettings(pHKL self, float fHKL[3], float fPsi, int iHamil,
|
||||
float fSet[4], SConnection * pCon)
|
||||
float fSet[5], SConnection * pCon)
|
||||
{
|
||||
char pBueffel[512];
|
||||
double myPsi = fPsi;
|
||||
int i, status;
|
||||
pSingleDiff single = NULL;
|
||||
double dHkl[4], dSet[4];
|
||||
double dHkl[4], dSet[5];
|
||||
|
||||
/* catch shitty input */
|
||||
if ((fHKL[0] == 0.) && (fHKL[1] == 0.) && (fHKL[2] == 0.)) {
|
||||
@ -422,7 +422,7 @@ int CalculateSettings(pHKL self, float fHKL[3], float fPsi, int iHamil,
|
||||
dHkl[3] = myPsi;
|
||||
|
||||
status = single->calculateSettings(single, dHkl, dSet);
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < 5; i++) {
|
||||
fSet[i] = dSet[i];
|
||||
}
|
||||
|
||||
@ -446,17 +446,17 @@ void stopHKLMotors(pHKL self)
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
int startHKLMotors(pHKL self, SConnection * pCon, float fSet[4])
|
||||
int startHKLMotors(pHKL self, SConnection * pCon, float fSet[5])
|
||||
{
|
||||
char pBueffel[512];
|
||||
pSingleDiff single = NULL;
|
||||
double dSet[4];
|
||||
double dSet[5];
|
||||
int i, status;
|
||||
|
||||
single = SXGetDiffractometer();
|
||||
assert(single != NULL);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < 5; i++) {
|
||||
dSet[i] = fSet[i];
|
||||
}
|
||||
single->settingsToList(single, dSet);
|
||||
@ -471,7 +471,7 @@ int startHKLMotors(pHKL self, SConnection * pCon, float fSet[4])
|
||||
int RunHKL(pHKL self, float fHKL[3],
|
||||
float fPsi, int iHamil, SConnection * pCon)
|
||||
{
|
||||
float fSet[4];
|
||||
float fSet[5];
|
||||
int iRet, i;
|
||||
char pBueffel[512];
|
||||
pDummy pDum;
|
||||
@ -496,7 +496,7 @@ int RunHKL(pHKL self, float fHKL[3],
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int DriveSettings(pHKL self, float fSet[4], SConnection * pCon)
|
||||
int DriveSettings(pHKL self, float fSet[5], SConnection * pCon)
|
||||
{
|
||||
int iRet;
|
||||
|
||||
@ -579,77 +579,6 @@ int DriveHKL(pHKL self, float fHKL[3],
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* This is only used in mesure, remove when mesure can be killed
|
||||
* ----------------------------------------------------------------------*/
|
||||
int GetCurrentPosition(pHKL self, SConnection * pCon, float fPos[4])
|
||||
{
|
||||
float fVal;
|
||||
int iRet, iResult;
|
||||
pMotor pTheta, pOmega, pChi, pPhi, pNu;
|
||||
|
||||
pTheta = SXGetMotor(TwoTheta);
|
||||
pOmega = SXGetMotor(Omega);
|
||||
pChi = SXGetMotor(Chi);
|
||||
pPhi = SXGetMotor(Phi);
|
||||
if (pTheta == NULL || pOmega == NULL || pChi == NULL || pPhi == NULL) {
|
||||
SCWrite(pCon,
|
||||
"ERROR: configuration problem, stt,om,chi,phi motors not found,",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
iResult = 1;
|
||||
iRet = MotorGetSoftPosition(pTheta, pCon, &fVal);
|
||||
if (iRet == 1) {
|
||||
fPos[0] = fVal;
|
||||
} else {
|
||||
iResult = 0;
|
||||
}
|
||||
iRet = MotorGetSoftPosition(pOmega, pCon, &fVal);
|
||||
if (iRet == 1) {
|
||||
fPos[1] = fVal;
|
||||
} else {
|
||||
iResult = 0;
|
||||
}
|
||||
|
||||
/* normal beam geometry */
|
||||
if (SXGetMode() == NB) {
|
||||
pNu = SXGetMotor(Nu);
|
||||
if (pNu) {
|
||||
SCWrite(pCon, "ERROR: configuration problem, nu motor not found,",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
iRet = MotorGetSoftPosition(pNu, pCon, &fVal);
|
||||
if (iRet == 1) {
|
||||
fPos[2] = fVal;
|
||||
} else {
|
||||
iResult = 0;
|
||||
}
|
||||
return iResult;
|
||||
}
|
||||
|
||||
/* bissecting geometry */
|
||||
iRet = MotorGetSoftPosition(pChi, pCon, &fVal);
|
||||
if (iRet == 1) {
|
||||
fPos[2] = fVal;
|
||||
} else {
|
||||
iResult = 0;
|
||||
}
|
||||
iRet = MotorGetSoftPosition(pPhi, pCon, &fVal);
|
||||
if (iRet == 1) {
|
||||
fPos[3] = fVal;
|
||||
} else {
|
||||
iResult = 0;
|
||||
}
|
||||
|
||||
return iResult;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
For the conversion from angles to HKL.
|
||||
-------------------------------------------------------------------------*/
|
||||
@ -803,14 +732,15 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
int iRet, i, iHamil;
|
||||
char pBueffel[512];
|
||||
float fUB[9], fPsi, fVal;
|
||||
float fHKL[3], fSet[4];
|
||||
double dHKL[3], dSet[4];
|
||||
float fHKL[3], fSet[5];
|
||||
double dHKL[3], dSet[5];
|
||||
double dVal, lambda, stt;
|
||||
const double *dUB;
|
||||
pHKL self = NULL;
|
||||
CommandList *pCom = NULL;
|
||||
pDummy pDum = NULL;
|
||||
pSingleDiff single = NULL;
|
||||
int mode, nargs;
|
||||
|
||||
assert(pCon);
|
||||
assert(pSics);
|
||||
@ -857,13 +787,19 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "fromangles") == 0) {
|
||||
if (argc < 6) {
|
||||
mode = SXGetMode();
|
||||
if(mode == BiNB) {
|
||||
nargs = 7;
|
||||
} else {
|
||||
nargs = 6;
|
||||
}
|
||||
if (argc < nargs) {
|
||||
SCWrite(pCon,
|
||||
"ERROR: need stt, om, chi,phi to calculate HKL from angles",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < nargs-2; i++) {
|
||||
iRet = Tcl_GetDouble(InterpGetTcl(pSics), argv[i + 2], &dVal);
|
||||
if (iRet != TCL_OK) {
|
||||
snprintf(pBueffel, 511, "ERROR: failed to convert %s to number",
|
||||
@ -1031,6 +967,10 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, " gamma = %f, omega = %f, nu = %f",
|
||||
fSet[0], fSet[1], fSet[2]);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
} else if(SXGetMode() == BiNB){
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, " 2-theta = %f, omega = %f, chi = %f, phi = %f, nu = %f",
|
||||
fSet[0], fSet[1], fSet[2], fSet[3], fSet[4]);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
} else {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, " 2-theta = %f, omega = %f, chi = %f, phi = %f",
|
||||
fSet[0], fSet[1], fSet[2], fSet[3]);
|
||||
|
6
hmdata.c
6
hmdata.c
@ -563,7 +563,7 @@ static pNXDS hmDataToNXDataset(pHMdata self)
|
||||
static pNXDS subSampleCommand(pNXDS source, char *command,
|
||||
char *error, int errLen)
|
||||
{
|
||||
int startDim[NX_MAXRANK], endDim[NX_MAXRANK];
|
||||
int64_t startDim[NX_MAXRANK], endDim[NX_MAXRANK];
|
||||
int dim = 0, start = 0, i;
|
||||
char *pPtr = NULL, token[80];
|
||||
|
||||
@ -590,12 +590,12 @@ static pNXDS subSampleCommand(pNXDS source, char *command,
|
||||
if (startDim[i] < 0 || startDim[i] >= source->dim[i]) {
|
||||
snprintf(error, errLen,
|
||||
"ERROR: invalid start value %d for dimension %d",
|
||||
startDim[1], i);
|
||||
(int)startDim[1], i);
|
||||
return NULL;
|
||||
}
|
||||
if (endDim[i] < startDim[i] || endDim[i] >= source->dim[i]) {
|
||||
snprintf(error, errLen,
|
||||
"ERROR: invalid end value %d for dimension %d", endDim[1],
|
||||
"ERROR: invalid end value %d for dimension %d", (int)endDim[1],
|
||||
i);
|
||||
return NULL;
|
||||
}
|
||||
|
2
lld.c
2
lld.c
@ -582,7 +582,7 @@ int LLDnodePtr2Next(int List)
|
||||
}
|
||||
/* to point at the dummy tail node ... */
|
||||
ListControl[List].current = ListControl[List].current->next;
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LLDnodePtr2Prev(int List)
|
||||
|
22
macro.c
22
macro.c
@ -119,6 +119,12 @@ int MacroPop(void)
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SConnection *MacroPeek(void)
|
||||
{
|
||||
assert(pUnbekannt);
|
||||
return pUnbekannt->pCon[pUnbekannt->iStack];
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int SicsUnknownProc(ClientData pData, Tcl_Interp * pInter,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
@ -269,11 +275,10 @@ static void KillExec(ClientData data)
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
This is in the Tcl sources
|
||||
*/
|
||||
extern int Tcl_ExecObjCmd(ClientData data, Tcl_Interp * interp,
|
||||
int objc, Tcl_Obj * CONST objv[]);
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* static Tcl_ObjCmdProc oldExec = NULL; */
|
||||
static int (*oldExec)(ClientData clientData,Tcl_Interp *interp,
|
||||
int objc,Tcl_Obj *const objv[] ) = NULL;
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int ProtectedExec(ClientData clientData, Tcl_Interp * interp,
|
||||
int objc, Tcl_Obj * CONST objv[])
|
||||
@ -281,13 +286,13 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp * interp,
|
||||
char *test = NULL;
|
||||
|
||||
if (objc < 2) {
|
||||
return Tcl_ExecObjCmd(clientData, interp, objc, objv);
|
||||
return oldExec(clientData, interp, objc, objv);
|
||||
}
|
||||
|
||||
test = Tcl_GetStringFromObj(objv[1], NULL);
|
||||
if (allowedCommands != NULL) {
|
||||
if (StringDictExists(allowedCommands, test)) {
|
||||
return Tcl_ExecObjCmd(clientData, interp, objc, objv);
|
||||
return oldExec(clientData, interp, objc, objv);
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,6 +318,7 @@ Tcl_Interp *MacroInit(SicsInterp * pSics)
|
||||
FILE *fp = NULL;
|
||||
char pBueffel[512];
|
||||
int iRet;
|
||||
Tcl_CmdInfo execInfo;
|
||||
|
||||
assert(pSics);
|
||||
|
||||
@ -338,6 +344,8 @@ Tcl_Interp *MacroInit(SicsInterp * pSics)
|
||||
Tcl_DeleteCommand(pInter, "exit");
|
||||
Tcl_DeleteCommand(pInter, "socket");
|
||||
Tcl_DeleteCommand(pInter, "vwait");
|
||||
Tcl_GetCommandInfo(pInter,"exec",&execInfo);
|
||||
oldExec = execInfo.objProc;
|
||||
Tcl_DeleteCommand(pInter, "exec");
|
||||
|
||||
/*
|
||||
|
1
macro.h
1
macro.h
@ -50,6 +50,7 @@ int AllowExec(SConnection * pCon, SicsInterp * pInter, void *pData,
|
||||
*/
|
||||
int MacroPush(SConnection * pCon);
|
||||
int MacroPop(void);
|
||||
SConnection *MacroPeek(void);
|
||||
|
||||
void KillSicsUnknown(void);
|
||||
|
||||
|
5
make_gen
5
make_gen
@ -41,7 +41,8 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \
|
||||
sgclib.o sgfind.o sgio.o sgsi.o sghkl.o singlediff.o singlebi.o \
|
||||
singlenb.o simindex.o simidx.o uselect.o singletas.o motorsec.o \
|
||||
rwpuffer.o asynnet.o background.o countersec.o hdbtable.o velosec.o \
|
||||
histmemsec.o sansbc.o sicsutil.o strlutil.o genbinprot.o trace.o
|
||||
histmemsec.o sansbc.o sicsutil.o strlutil.o genbinprot.o trace.o\
|
||||
singlebinb.o
|
||||
|
||||
MOTOROBJ = motor.o simdriv.o
|
||||
COUNTEROBJ = countdriv.o simcter.o counter.o
|
||||
@ -64,7 +65,7 @@ all: libmat libhlib libtecsl libpsi SICServer
|
||||
full: purge all
|
||||
|
||||
SICServer: $(OBJ) $(SUBLIBS)
|
||||
$(CC) -g -o SICServer $(OBJ) $(LIBS)
|
||||
$(CC) -g -o SICServer $(OBJ) $(LIBS)
|
||||
|
||||
matrix/libmatrix.a: libmat
|
||||
|
||||
|
@ -9,13 +9,13 @@
|
||||
SINQDIR=/afs/psi.ch/project/sinq
|
||||
NI= -DHAVENI
|
||||
NIOBJ= nigpib.o
|
||||
NILIB=$(SINQDIR)/sl5/lib/cib.o
|
||||
NILIB=$(SINQDIR)/sl6/lib/cib.o
|
||||
|
||||
include sllinux_def
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -I$(HDFROOT)/include -DNXXML -DHDF4 -DHDF5 $(NI) \
|
||||
-Ipsi/hardsup -I. -MMD \
|
||||
CFLAGS = -I$(HDFROOT)/include -DNXXML -DHDF5 $(NI) \
|
||||
-Ipsi/hardsup -I. -MMD \
|
||||
-Werror -DCYGNUS -DNONINTF -g $(DFORTIFY) \
|
||||
-Wall -Wno-unused -Wunused-value -Wno-comment -Wno-switch
|
||||
|
||||
@ -25,10 +25,9 @@ SUBLIBS = psi/libpsi.a psi/hardsup/libhlib.a matrix/libmatrix.a \
|
||||
psi/tecs/libtecsl.a
|
||||
LIBS = -L$(HDFROOT)/lib $(SUBLIBS) $(NILIB)\
|
||||
-ltcl $(HDFROOT)/lib/libhdf5.a \
|
||||
$(HDFROOT)/lib/libmfhdf.a $(HDFROOT)/lib/libdf.a \
|
||||
$(HDFROOT)/lib/libjpeg.a $(HDFROOT)/lib/libsz.a \
|
||||
$(HDFROOT)/lib/libsz.a \
|
||||
$(HDFROOT)/lib/libjson.a \
|
||||
-ldl -lz -lmxml $(HDFROOT)/lib/libghttp.a -lm -lc
|
||||
-ldl -lz $(HDFROOT)/lib/libmxml.a $(HDFROOT)/lib/libghttp.a -lm -lc -lpthread
|
||||
|
||||
include make_gen
|
||||
|
||||
|
@ -145,8 +145,8 @@ static int MOLICheckStatus(void *data, SConnection * pCon)
|
||||
return result;
|
||||
}
|
||||
/*---------------------------------------------------------
|
||||
A special version for EIGER. I am coutious: I have problems
|
||||
with this at EIGER but I do not want to propogate the fix
|
||||
A special version for EIGER. I am cautious: I have problems
|
||||
with this at EIGER but I do not want to propagate the fix
|
||||
elsewhere even if it may be the right thing to do.
|
||||
-----------------------------------------------------------*/
|
||||
int MOLIEigerStatus(void *data, SConnection * pCon)
|
||||
|
4
mumo.c
4
mumo.c
@ -460,7 +460,7 @@ const char *FindNamPos(pMulMot self, SConnection * pCon)
|
||||
int iRet, iTest;
|
||||
char pCurrCommand[1064], pTestCommand[1064];
|
||||
const char *pAlias;
|
||||
char *pName, *pVal;
|
||||
char *pVal, *pName;
|
||||
float f1, f2;
|
||||
pMotor pMot = NULL;
|
||||
pStringDict motCache = NULL;
|
||||
@ -481,7 +481,7 @@ const char *FindNamPos(pMulMot self, SConnection * pCon)
|
||||
iRet = MotorGetSoftPosition(pMot, pCon, &f1);
|
||||
if (!iRet) {
|
||||
snprintf(pTestCommand,sizeof(pTestCommand)-1,
|
||||
"ERROR: failed to get motor position for %s", pName);
|
||||
"ERROR: failed to get motor position for %s", pMot->name);
|
||||
SCWrite(pCon, pTestCommand, eError);
|
||||
return NULL;
|
||||
}
|
||||
|
96
napi4.h
96
napi4.h
@ -1,3 +1,6 @@
|
||||
#ifndef NAPI4_H
|
||||
#define NAPI4_H
|
||||
|
||||
#define NXSIGNATURE 959697
|
||||
|
||||
#include "mfhdf.h"
|
||||
@ -7,54 +10,51 @@
|
||||
* HDF4 interface
|
||||
*/
|
||||
|
||||
extern NXstatus NX4open(CONSTCHAR * filename, NXaccess access_method,
|
||||
NXhandle * pHandle);
|
||||
extern NXstatus NX4close(NXhandle * pHandle);
|
||||
extern NXstatus NX4flush(NXhandle * pHandle);
|
||||
extern NXstatus NX4open(CONSTCHAR *filename, NXaccess access_method, NXhandle* pHandle);
|
||||
extern NXstatus NX4close(NXhandle* pHandle);
|
||||
extern NXstatus NX4flush(NXhandle* pHandle);
|
||||
|
||||
extern NXstatus NX4makegroup (NXhandle handle, CONSTCHAR* Vgroup, CONSTCHAR* NXclass);
|
||||
extern NXstatus NX4opengroup (NXhandle handle, CONSTCHAR* Vgroup, CONSTCHAR* NXclass);
|
||||
extern NXstatus NX4closegroup(NXhandle handle);
|
||||
|
||||
extern NXstatus NX4makedata64 (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[]);
|
||||
extern NXstatus NX4compmakedata64 (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[], int comp_typ, int64_t bufsize[]);
|
||||
extern NXstatus NX4compress (NXhandle handle, int compr_type);
|
||||
extern NXstatus NX4opendata (NXhandle handle, CONSTCHAR* label);
|
||||
|
||||
extern NXstatus NX4makegroup(NXhandle handle, CONSTCHAR * Vgroup,
|
||||
CONSTCHAR * NXclass);
|
||||
extern NXstatus NX4opengroup(NXhandle handle, CONSTCHAR * Vgroup,
|
||||
CONSTCHAR * NXclass);
|
||||
extern NXstatus NX4closegroup(NXhandle handle);
|
||||
|
||||
extern NXstatus NX4makedata(NXhandle handle, CONSTCHAR * label,
|
||||
int datatype, int rank, int dim[]);
|
||||
extern NXstatus NX4compmakedata(NXhandle handle, CONSTCHAR * label,
|
||||
int datatype, int rank, int dim[],
|
||||
int comp_typ, int bufsize[]);
|
||||
extern NXstatus NX4compress(NXhandle handle, int compr_type);
|
||||
extern NXstatus NX4opendata(NXhandle handle, CONSTCHAR * label);
|
||||
|
||||
extern NXstatus NX4closedata(NXhandle handle);
|
||||
|
||||
extern NXstatus NX4getdata(NXhandle handle, void *data);
|
||||
extern NXstatus NX4getslab(NXhandle handle, void *data, int start[],
|
||||
int size[]);
|
||||
extern NXstatus NX4getattr(NXhandle handle, char *name, void *data,
|
||||
int *iDataLen, int *iType);
|
||||
|
||||
extern NXstatus NX4putdata(NXhandle handle, void *data);
|
||||
extern NXstatus NX4putslab(NXhandle handle, void *data, int start[],
|
||||
int size[]);
|
||||
extern NXstatus NX4putattr(NXhandle handle, CONSTCHAR * name, void *data,
|
||||
int iDataLen, int iType);
|
||||
|
||||
extern NXstatus NX4getinfo(NXhandle handle, int *rank, int dimension[],
|
||||
int *datatype);
|
||||
extern NXstatus NX4getgroupinfo(NXhandle handle, int *no_items,
|
||||
NXname name, NXname nxclass);
|
||||
extern NXstatus NX4initgroupdir(NXhandle handle);
|
||||
extern NXstatus NX4getnextentry(NXhandle handle, NXname name,
|
||||
NXname nxclass, int *datatype);
|
||||
extern NXstatus NX4getattrinfo(NXhandle handle, int *no_items);
|
||||
extern NXstatus NX4initattrdir(NXhandle handle);
|
||||
extern NXstatus NX4getnextattr(NXhandle handle, NXname pName, int *iLength,
|
||||
int *iType);
|
||||
|
||||
extern NXstatus NX4getgroupID(NXhandle handle, NXlink * pLink);
|
||||
extern NXstatus NX4getdataID(NXhandle handle, NXlink * pLink);
|
||||
extern NXstatus NX4makelink(NXhandle handle, NXlink * pLink);
|
||||
extern NXstatus NX4printlink(NXhandle handle, NXlink * pLink);
|
||||
extern NXstatus NX4closedata(NXhandle handle);
|
||||
|
||||
extern NXstatus NX4getdata(NXhandle handle, void* data);
|
||||
extern NXstatus NX4getslab64(NXhandle handle, void* data, const int64_t start[], const int64_t size[]);
|
||||
extern NXstatus NX4getattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType);
|
||||
|
||||
extern NXstatus NX4putdata(NXhandle handle, const void* data);
|
||||
extern NXstatus NX4putslab64(NXhandle handle, const void* data, const int64_t start[], const int64_t size[]);
|
||||
extern NXstatus NX4putattr(NXhandle handle, CONSTCHAR* name, const void* data, int iDataLen, int iType);
|
||||
|
||||
extern NXstatus NX4getinfo64(NXhandle handle, int* rank, int64_t dimension[], int* datatype);
|
||||
extern NXstatus NX4getgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass);
|
||||
extern NXstatus NX4initgroupdir(NXhandle handle);
|
||||
extern NXstatus NX4getnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype);
|
||||
extern NXstatus NX4getattrinfo(NXhandle handle, int* no_items);
|
||||
extern NXstatus NX4initattrdir(NXhandle handle);
|
||||
extern NXstatus NX4getnextattr(NXhandle handle, NXname pName, int *iLength, int *iType);
|
||||
|
||||
extern NXstatus NX4getgroupID(NXhandle handle, NXlink* pLink);
|
||||
extern NXstatus NX4getdataID(NXhandle handle, NXlink* pLink);
|
||||
extern NXstatus NX4makelink(NXhandle handle, NXlink* pLink);
|
||||
extern NXstatus NX4printlink(NXhandle handle, NXlink* pLink);
|
||||
|
||||
void NX4assignFunctions(pNexusFunction fHandle);
|
||||
|
||||
|
||||
/*
|
||||
* HDF changed from MAX_VAR_DIMS to H4_MAX_VAR_DIMS aronud 9/5/2007
|
||||
* to avoid potential conflicts with NetCDF-3 library
|
||||
*/
|
||||
#ifndef H4_MAX_VAR_DIMS
|
||||
#define H4_MAX_VAR_DIMS MAX_VAR_DIMS
|
||||
#endif
|
||||
|
||||
#endif /* NAPI4_H */
|
||||
|
85
napi5.h
85
napi5.h
@ -1,61 +1,54 @@
|
||||
#ifndef NAPI5_H
|
||||
#define NAPI5_H
|
||||
|
||||
#define NX5SIGNATURE 959695
|
||||
|
||||
#include <hdf5.h>
|
||||
|
||||
/* HDF5 interface */
|
||||
|
||||
extern NXstatus NX5open(CONSTCHAR * filename, NXaccess access_method,
|
||||
NXhandle * pHandle);
|
||||
extern NXstatus NX5close(NXhandle * pHandle);
|
||||
extern NXstatus NX5flush(NXhandle * pHandle);
|
||||
extern NXstatus NX5open(CONSTCHAR *filename, NXaccess access_method, NXhandle* pHandle);
|
||||
extern NXstatus NX5reopen(NXhandle pOrigHandle, NXhandle* pNewHandle);
|
||||
|
||||
extern NXstatus NX5makegroup(NXhandle handle, CONSTCHAR * name,
|
||||
CONSTCHAR * NXclass);
|
||||
extern NXstatus NX5opengroup(NXhandle handle, CONSTCHAR * name,
|
||||
CONSTCHAR * NXclass);
|
||||
extern NXstatus NX5closegroup(NXhandle handle);
|
||||
extern NXstatus NX5close(NXhandle* pHandle);
|
||||
extern NXstatus NX5flush(NXhandle* pHandle);
|
||||
|
||||
extern NXstatus NX5makegroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
|
||||
extern NXstatus NX5opengroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
|
||||
extern NXstatus NX5closegroup(NXhandle handle);
|
||||
|
||||
extern NXstatus NX5makedata64 (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[]);
|
||||
extern NXstatus NX5compmakedata64 (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[], int comp_typ, int64_t bufsize[]);
|
||||
extern NXstatus NX5compress (NXhandle handle, int compr_type);
|
||||
extern NXstatus NX5opendata (NXhandle handle, CONSTCHAR* label);
|
||||
extern NXstatus NX5closedata(NXhandle handle);
|
||||
extern NXstatus NX5putdata(NXhandle handle, const void* data);
|
||||
|
||||
extern NXstatus NX5makedata(NXhandle handle, CONSTCHAR * label,
|
||||
int datatype, int rank, int dim[]);
|
||||
extern NXstatus NX5compmakedata(NXhandle handle, CONSTCHAR * label,
|
||||
int datatype, int rank, int dim[],
|
||||
int comp_typ, int bufsize[]);
|
||||
extern NXstatus NX5compress(NXhandle handle, int compr_type);
|
||||
extern NXstatus NX5opendata(NXhandle handle, CONSTCHAR * label);
|
||||
extern NXstatus NX5closedata(NXhandle handle);
|
||||
extern NXstatus NX5putdata(NXhandle handle, void *data);
|
||||
extern NXstatus NX5putattr(NXhandle handle, CONSTCHAR* name, const void* data, int iDataLen, int iType);
|
||||
extern NXstatus NX5putslab64(NXhandle handle, const void* data, const int64_t start[], const int64_t size[]);
|
||||
|
||||
extern NXstatus NX5putattr(NXhandle handle, CONSTCHAR * name, void *data,
|
||||
int iDataLen, int iType);
|
||||
extern NXstatus NX5putslab(NXhandle handle, void *data, int start[],
|
||||
int size[]);
|
||||
extern NXstatus NX5getdataID(NXhandle handle, NXlink* pLink);
|
||||
extern NXstatus NX5makelink(NXhandle handle, NXlink* pLink);
|
||||
extern NXstatus NX5printlink(NXhandle handle, NXlink* pLink);
|
||||
|
||||
extern NXstatus NX5getdataID(NXhandle handle, NXlink * pLink);
|
||||
extern NXstatus NX5makelink(NXhandle handle, NXlink * pLink);
|
||||
extern NXstatus NX5printlink(NXhandle handle, NXlink * pLink);
|
||||
extern NXstatus NX5getdata(NXhandle handle, void* data);
|
||||
extern NXstatus NX5getinfo64(NXhandle handle, int* rank, int64_t dimension[], int* datatype);
|
||||
extern NXstatus NX5getnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype);
|
||||
|
||||
extern NXstatus NX5getdata(NXhandle handle, void *data);
|
||||
extern NXstatus NX5getinfo(NXhandle handle, int *rank, int dimension[],
|
||||
int *datatype);
|
||||
extern NXstatus NX5getnextentry(NXhandle handle, NXname name,
|
||||
NXname nxclass, int *datatype);
|
||||
extern NXstatus NX5getslab64(NXhandle handle, void* data, const int64_t start[], const int64_t size[]);
|
||||
extern NXstatus NX5getnextattr(NXhandle handle, NXname pName, int *iLength, int *iType);
|
||||
extern NXstatus NX5getattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType);
|
||||
extern NXstatus NX5getattrinfo(NXhandle handle, int* no_items);
|
||||
extern NXstatus NX5getgroupID(NXhandle handle, NXlink* pLink);
|
||||
extern NXstatus NX5getgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass);
|
||||
|
||||
extern NXstatus NX5getslab(NXhandle handle, void *data, int start[],
|
||||
int size[]);
|
||||
extern NXstatus NX5getnextattr(NXhandle handle, NXname pName, int *iLength,
|
||||
int *iType);
|
||||
extern NXstatus NX5getattr(NXhandle handle, char *name, void *data,
|
||||
int *iDataLen, int *iType);
|
||||
extern NXstatus NX5getattrinfo(NXhandle handle, int *no_items);
|
||||
extern NXstatus NX5getgroupID(NXhandle handle, NXlink * pLink);
|
||||
extern NXstatus NX5getgroupinfo(NXhandle handle, int *no_items,
|
||||
NXname name, NXname nxclass);
|
||||
|
||||
extern NXstatus NX5initgroupdir(NXhandle handle);
|
||||
extern NXstatus NX5initattrdir(NXhandle handle);
|
||||
extern NXstatus NX5initgroupdir(NXhandle handle);
|
||||
extern NXstatus NX5initattrdir(NXhandle handle);
|
||||
|
||||
void NX5assignFunctions(pNexusFunction fHandle);
|
||||
|
||||
herr_t nxgroup_info(hid_t loc_id, const char *name, void *op_data);
|
||||
herr_t attr_info(hid_t loc_id, const char *name, void *opdata);
|
||||
herr_t group_info(hid_t loc_id, const char *name, void *opdata);
|
||||
herr_t attr_info(hid_t loc_id, const char *name, const H5A_info_t *unused, void *opdata);
|
||||
herr_t group_info(hid_t loc_id, const char *name, const H5L_info_t *unused, void *opdata);
|
||||
herr_t nxgroup_info(hid_t loc_id, const char *name, const H5L_info_t *unused, void *op_data);
|
||||
|
||||
#endif /* NAPI5_H */
|
||||
|
32
napiconfig.h
32
napiconfig.h
@ -1,22 +1,28 @@
|
||||
#ifndef NAPICONFIG_H
|
||||
#define NAPICONFIG_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef __VMS
|
||||
#include <nxconfig_vms.h>
|
||||
#else
|
||||
#include <nxconfig.h>
|
||||
#endif /* __VMS */
|
||||
|
||||
|
||||
/*
|
||||
* Type definitions
|
||||
* Integer type definitions
|
||||
*
|
||||
* int32_t etc will be defined by configure in nxconfig.h
|
||||
* if they exist; otherwise include an appropriate header
|
||||
*/
|
||||
#ifdef HAVE_STDINT_H
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#else
|
||||
typedef signed char int8_t;
|
||||
typedef short int int16_t;
|
||||
typedef int int32_t;
|
||||
typedef long int64_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short int uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long uint64_t;
|
||||
#elif HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif /* HAVE_STDINT_H */
|
||||
|
||||
#endif /* HAVE_STDINT_H */
|
||||
#endif /* NAPICONFIG_H */
|
||||
|
||||
#endif /* NAPICONFIG_H */
|
||||
|
208
napiu.c
208
napiu.c
@ -21,10 +21,10 @@
|
||||
|
||||
For further information, see <http://www.nexus.anl.gov/>
|
||||
|
||||
$Id: napiu.c,v 1.3 2009/02/13 09:00:20 koennecke Exp $
|
||||
$Id: napiu.c,v 1.4 2012/03/29 08:41:06 koennecke Exp $
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
static const char *rscid = "$Id: napiu.c,v 1.3 2009/02/13 09:00:20 koennecke Exp $"; /* Revision interted by CVS */
|
||||
static const char* rscid = "$Id: napiu.c,v 1.4 2012/03/29 08:41:06 koennecke Exp $"; /* Revision interted by CVS */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
@ -41,130 +41,120 @@ static const char *rscid = "$Id: napiu.c,v 1.3 2009/02/13 09:00:20 koennecke Exp
|
||||
} \
|
||||
}
|
||||
|
||||
NXstatus NXUwriteglobals(NXhandle file_id, const char *user,
|
||||
const char *affiliation, const char *address,
|
||||
const char *telephone_number,
|
||||
const char *fax_number, const char *email)
|
||||
{
|
||||
DO_GLOBAL(user);
|
||||
DO_GLOBAL(affiliation);
|
||||
DO_GLOBAL(address);
|
||||
DO_GLOBAL(telephone_number);
|
||||
DO_GLOBAL(fax_number);
|
||||
DO_GLOBAL(email);
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUwriteglobals(NXhandle file_id, const char* user, const char* affiliation, const char* address, const char* telephone_number, const char* fax_number, const char* email)
|
||||
{
|
||||
DO_GLOBAL(user);
|
||||
DO_GLOBAL(affiliation);
|
||||
DO_GLOBAL(address);
|
||||
DO_GLOBAL(telephone_number);
|
||||
DO_GLOBAL(fax_number);
|
||||
DO_GLOBAL(email);
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
/* NXUwritegroup creates and leaves open a group */
|
||||
NXstatus NXUwritegroup(NXhandle file_id, const char *group_name,
|
||||
const char *group_class)
|
||||
{
|
||||
int status;
|
||||
status = NXmakegroup(file_id, group_name, group_class);
|
||||
if (status == NX_OK) {
|
||||
status = NXopengroup(file_id, group_name, group_class);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
NXstatus NXUwritegroup(NXhandle file_id, const char* group_name, const char* group_class)
|
||||
{
|
||||
int status;
|
||||
status = NXmakegroup(file_id, group_name, group_class);
|
||||
if (status == NX_OK)
|
||||
{
|
||||
status = NXopengroup(file_id, group_name, group_class);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
NXstatus NXUwritedata(NXhandle file_id, const char *data_name,
|
||||
const void *data, int data_type, int rank,
|
||||
const int dim[], const char *units,
|
||||
const int start[], const int size[])
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUwritedata(NXhandle file_id, const char* data_name, const void* data, int data_type, int rank, const int dim[], const char* units, const int start[], const int size[])
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
NXstatus NXUreaddata(NXhandle file_id, const char *data_name, void *data,
|
||||
char *units, const int start[], const int size[])
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUreaddata(NXhandle file_id, const char* data_name, void* data, char* units, const int start[], const int size[])
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
NXstatus NXUwritehistogram(NXhandle file_id, const char *data_name,
|
||||
const void *data, const char *units)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUwritehistogram(NXhandle file_id, const char* data_name, const void* data, const char* units)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
NXstatus NXUreadhistogram(NXhandle file_id, const char *data_name,
|
||||
void *data, char *units)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUreadhistogram(NXhandle file_id, const char* data_name, void* data, char* units)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
static int NXcompress_type = 0;
|
||||
static int NXcompress_size = 0;
|
||||
|
||||
/* NXUsetcompress sets the default compression type and minimum size */
|
||||
NXstatus NXUsetcompress(NXhandle file_id, int comp_type, int comp_size)
|
||||
{
|
||||
int status;
|
||||
if (comp_type == NX_COMP_LZW || comp_type == NX_COMP_HUF ||
|
||||
comp_type == NX_COMP_RLE || comp_type == NX_COMP_NONE) {
|
||||
NXcompress_type = comp_type;
|
||||
if (comp_size != 0) {
|
||||
NXcompress_size = comp_size;
|
||||
}
|
||||
status = NX_OK;
|
||||
} else {
|
||||
NXIReportError(NXpData, "Invalid compression option");
|
||||
status = NX_ERROR;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
NXstatus NXUsetcompress(NXhandle file_id, int comp_type, int comp_size)
|
||||
{
|
||||
int status;
|
||||
if (comp_type == NX_COMP_LZW || comp_type == NX_COMP_HUF ||
|
||||
comp_type == NX_COMP_RLE || comp_type == NX_COMP_NONE)
|
||||
{
|
||||
NXcompress_type = comp_type;
|
||||
if (comp_size != 0)
|
||||
{
|
||||
NXcompress_size = comp_size;
|
||||
}
|
||||
status = NX_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
NXReportError( "Invalid compression option");
|
||||
status = NX_ERROR;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/* !NXUfindgroup finds if a NeXus group of the specified name exists */
|
||||
NXstatus NXUfindgroup(NXhandle file_id, const char *group_name,
|
||||
char *group_class)
|
||||
{
|
||||
int status, n;
|
||||
NXname vname, vclass;
|
||||
status = NXgetgroupinfo(file_id, &n, vname, vclass);
|
||||
if (status != NX_OK) {
|
||||
return status;
|
||||
}
|
||||
return NX_OK;
|
||||
}
|
||||
/* !NXUfindgroup finds if a NeXus group of the specified name exists */
|
||||
NXstatus NXUfindgroup(NXhandle file_id, const char* group_name, char* group_class)
|
||||
{
|
||||
int status, n;
|
||||
NXname vname, vclass;
|
||||
status = NXgetgroupinfo(file_id, &n, vname, vclass);
|
||||
if (status != NX_OK)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
NXstatus NXUfindclass(NXhandle file_id, const char *group_class,
|
||||
char *group_name, int find_index)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUfindclass(NXhandle file_id, const char* group_class, char* group_name, int find_index)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
/* NXUfinddata finds if a NeXus data item is in the current group */
|
||||
NXstatus NXUfinddata(NXhandle file_id, const char *data_name)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUfinddata(NXhandle file_id, const char* data_name)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
NXstatus NXUfindattr(NXhandle file_id, const char *attr_name)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUfindattr(NXhandle file_id, const char* attr_name)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
NXstatus NXUfindsignal(NXhandle file_id, int signal, char *data_name,
|
||||
int *data_rank, int *data_type,
|
||||
int data_dimensions[])
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUfindsignal(NXhandle file_id, int signal, char* data_name, int* data_rank, int* data_type, int data_dimensions[])
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
NXstatus NXUfindaxis(NXhandle file_id, int axis, int primary,
|
||||
char *data_name, int *data_rank, int *data_type,
|
||||
int data_dimensions[])
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUfindaxis(NXhandle file_id, int axis, int primary, char* data_name, int* data_rank, int* data_type, int data_dimensions[])
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
NXstatus NXUfindlink(NXhandle file_id, NXlink * group_id,
|
||||
const char *group_class)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
NXstatus NXUfindlink(NXhandle file_id, NXlink* group_id, const char* group_class)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
NXstatus NXUresumelink(NXhandle file_id, NXlink group_id)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
NXstatus NXUresumelink(NXhandle file_id, NXlink group_id)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
5
nread.c
5
nread.c
@ -700,10 +700,13 @@ int NetReaderTask(void *pData)
|
||||
GetCharArray(self->conList));
|
||||
}
|
||||
|
||||
/*
|
||||
* This costs a surprising amount of CPU-time, in a test 10%!
|
||||
* This is why it has been commented away
|
||||
snprintf(num, sizeof num, "%d", conCount);
|
||||
IFSetOption(pSICSOptions, "ConnectionCount", num);
|
||||
IFSetOption(pSICSOptions, "ConMask", GetCharArray(self->conList));
|
||||
|
||||
*/
|
||||
|
||||
/* the select itself */
|
||||
tmo.tv_usec = self->iReadTimeout;
|
||||
|
6
nx_stptok.h
Normal file
6
nx_stptok.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef NX_STPTOK
|
||||
#define NX_STPTOK
|
||||
|
||||
extern char *stptok(const char *s, char *tok, size_t toklen, char *brk);
|
||||
|
||||
#endif /* NX_STPTOK */
|
186
nxcopy.c
186
nxcopy.c
@ -13,6 +13,7 @@
|
||||
#include "sicsdata.h"
|
||||
#include "nxcopy.h"
|
||||
#include "HistMem.h"
|
||||
#include "macro.h"
|
||||
/*-------------------------------------------------------------------------------
|
||||
* decode a SWIG style pointer into the real pointer value.
|
||||
* Stolen from SWIG generated code.
|
||||
@ -233,13 +234,190 @@ static int NXDataToHdbNode(ClientData clientData, Tcl_Interp * interp,
|
||||
val = NXDatasetToHdbValue(data);
|
||||
status = UpdateHipadabaPar(node, val, NULL);
|
||||
if (status != 1) {
|
||||
Tcl_SetStringObj(resultPtr, "data type mismatch",
|
||||
strlen("data type mismatch"));
|
||||
return TCL_ERROR;
|
||||
Tcl_SetStringObj(resultPtr, "data type mismatch",
|
||||
strlen("data type mismatch"));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int NXDataSend(ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *resultPtr;
|
||||
pNXDS data = NULL;
|
||||
SConnection *pCon = NULL;
|
||||
char *sendName = NULL;
|
||||
int *dataToSend = NULL;
|
||||
int length, i;
|
||||
const char *text;
|
||||
char buffer[256];
|
||||
|
||||
if (objc < 3) {
|
||||
Tcl_WrongNumArgs(interp, objc, objv, "Usage: nxdatasend nxdata sendname");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
resultPtr = Tcl_GetObjResult(interp);
|
||||
|
||||
/*
|
||||
* get nxdataset pointer
|
||||
*/
|
||||
text = Tcl_GetStringFromObj(objv[1], NULL);
|
||||
if (strstr(text, "NULL") != NULL) {
|
||||
strncpy(buffer, "nxdata argument is NULL pointer", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
text++;
|
||||
SWIG_UnpackData(text, &data, sizeof(void *));
|
||||
|
||||
if (data->magic != MAGIC) {
|
||||
strncpy(buffer, "nxdata argument is no valid nxdataset" , sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
length = getNXDatasetLength(data);
|
||||
|
||||
/*
|
||||
* get connection
|
||||
*/
|
||||
pCon = MacroPeek();
|
||||
if(pCon == NULL){
|
||||
strncpy(buffer, "connection not FOUND!", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* get send name
|
||||
*/
|
||||
sendName = Tcl_GetStringFromObj(objv[2], NULL);
|
||||
if (strstr(text, "NULL") != NULL) {
|
||||
strncpy(buffer, "sendname argument is NULL pointer", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
dataToSend = malloc(length*sizeof(int));
|
||||
if(dataToSend == NULL){
|
||||
strncpy(buffer, "Out-of-memory in NXDataSend", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
switch(getNXDatasetType(data)){
|
||||
case NX_INT32:
|
||||
case NX_UINT32:
|
||||
for(i = 0; i < length; i++){
|
||||
dataToSend[i] = htonl(data->u.iPtr[i]);
|
||||
}
|
||||
break;
|
||||
case NX_INT16:
|
||||
case NX_UINT16:
|
||||
for(i = 0; i < length; i++){
|
||||
dataToSend[i] = htonl((int)data->u.sPtr[i]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
strncpy(buffer, "Datatype not supported", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
SCWriteZipped(pCon, sendName, dataToSend, length * sizeof(int));
|
||||
free(dataToSend);
|
||||
strncpy(buffer, "OK", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int NXDataSendBin(ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *resultPtr;
|
||||
pNXDS data = NULL;
|
||||
SConnection *pCon = NULL;
|
||||
char *sendName = NULL;
|
||||
int *dataToSend = NULL;
|
||||
int length, i;
|
||||
const char *text;
|
||||
char buffer[256];
|
||||
|
||||
if (objc < 3) {
|
||||
Tcl_WrongNumArgs(interp, objc, objv, "Usage: nxdatasend nxdata sendname");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
resultPtr = Tcl_GetObjResult(interp);
|
||||
|
||||
/*
|
||||
* get nxdataset pointer
|
||||
*/
|
||||
text = Tcl_GetStringFromObj(objv[1], NULL);
|
||||
if (strstr(text, "NULL") != NULL) {
|
||||
strncpy(buffer, "nxdata argument is NULL pointer", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
text++;
|
||||
SWIG_UnpackData(text, &data, sizeof(void *));
|
||||
|
||||
if (data->magic != MAGIC) {
|
||||
strncpy(buffer, "nxdata argument is no valid nxdataset" , sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
length = getNXDatasetLength(data);
|
||||
|
||||
/*
|
||||
* get connection
|
||||
*/
|
||||
pCon = MacroPeek();
|
||||
if(pCon == NULL){
|
||||
strncpy(buffer, "connection not FOUND!", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* get send name
|
||||
*/
|
||||
sendName = Tcl_GetStringFromObj(objv[2], NULL);
|
||||
if (strstr(text, "NULL") != NULL) {
|
||||
strncpy(buffer, "sendname argument is NULL pointer", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
dataToSend = malloc(length*sizeof(int));
|
||||
if(dataToSend == NULL){
|
||||
strncpy(buffer, "Out-of-memory in NXDataSend", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
switch(getNXDatasetType(data)){
|
||||
case NX_INT32:
|
||||
case NX_UINT32:
|
||||
for(i = 0; i < length; i++){
|
||||
dataToSend[i] = htonl(data->u.iPtr[i]);
|
||||
}
|
||||
break;
|
||||
case NX_INT16:
|
||||
case NX_UINT16:
|
||||
for(i = 0; i < length; i++){
|
||||
dataToSend[i] = htonl((int)data->u.sPtr[i]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
strncpy(buffer, "Datatype not supported", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
SCWriteBinary(pCon, sendName, dataToSend, length * sizeof(int));
|
||||
free(dataToSend);
|
||||
strncpy(buffer, "OK", sizeof(buffer));
|
||||
Tcl_SetStringObj(resultPtr,buffer,strlen(buffer));
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int NXDataToHM(ClientData clientData, Tcl_Interp * interp,
|
||||
int objc, Tcl_Obj * CONST objv[])
|
||||
@ -306,5 +484,7 @@ int NXcopy_Init(Tcl_Interp * pInter)
|
||||
NULL);
|
||||
Tcl_CreateObjCommand(pInter, "nxToHdb", NXDataToHdbNode, NULL, NULL);
|
||||
Tcl_CreateObjCommand(pInter, "nxToHM", NXDataToHM, NULL, NULL);
|
||||
Tcl_CreateObjCommand(pInter, "nxSend", NXDataSend, NULL, NULL);
|
||||
Tcl_CreateObjCommand(pInter, "nxSendBin", NXDataSendBin, NULL, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
242
nxdataset.c
242
nxdataset.c
@ -12,9 +12,8 @@
|
||||
#include "nxdataset.h"
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int getTypeSize(int typecode)
|
||||
{
|
||||
switch (typecode) {
|
||||
static int getTypeSize(int typecode){
|
||||
switch(typecode){
|
||||
case NX_FLOAT32:
|
||||
case NX_INT32:
|
||||
case NX_UINT32:
|
||||
@ -34,51 +33,50 @@ static int getTypeSize(int typecode)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
pNXDS createNXDataset(int rank, int typecode, int dim[])
|
||||
{
|
||||
pNXDS createNXDataset(int rank, int typecode, int64_t dim[]){
|
||||
pNXDS pNew = NULL;
|
||||
int i, length;
|
||||
int64_t length;
|
||||
int i;
|
||||
|
||||
pNew = (pNXDS) malloc(sizeof(NXDS));
|
||||
if (pNew == NULL) {
|
||||
pNew = (pNXDS)malloc(sizeof(NXDS));
|
||||
if(pNew == NULL){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pNew->dim = (int *) malloc(rank * sizeof(int));
|
||||
for (i = 0, length = 1; i < rank; i++) {
|
||||
pNew->dim = (int64_t *)malloc(rank*sizeof(int64_t));
|
||||
for(i = 0, length = 1; i < rank; i++){
|
||||
length *= dim[i];
|
||||
}
|
||||
pNew->u.ptr = malloc(length * getTypeSize(typecode));
|
||||
/* add +1 in case of string NULL termination */
|
||||
pNew->u.ptr = malloc(length*getTypeSize(typecode)+1);
|
||||
|
||||
if (pNew->dim == NULL || pNew->u.ptr == NULL) {
|
||||
if(pNew->dim == NULL || pNew->u.ptr == NULL){
|
||||
free(pNew);
|
||||
return NULL;
|
||||
}
|
||||
pNew->rank = rank;
|
||||
pNew->type = typecode;
|
||||
pNew->format = NULL;
|
||||
for (i = 0; i < rank; i++) {
|
||||
for(i = 0; i < rank; i++){
|
||||
pNew->dim[i] = dim[i];
|
||||
}
|
||||
pNew->magic = MAGIC;
|
||||
memset(pNew->u.ptr, 0, length * getTypeSize(typecode));
|
||||
/* add +1 in case of string NULL termination - see above */
|
||||
memset(pNew->u.ptr,0,length*getTypeSize(typecode)+1);
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
pNXDS createTextNXDataset(char *name)
|
||||
{
|
||||
pNXDS createTextNXDataset(char *name){
|
||||
pNXDS pNew = NULL;
|
||||
|
||||
pNew = (pNXDS) malloc(sizeof(NXDS));
|
||||
if (pNew == NULL) {
|
||||
pNew = (pNXDS)malloc(sizeof(NXDS));
|
||||
if(pNew == NULL){
|
||||
return NULL;
|
||||
}
|
||||
pNew->dim = (int *) malloc(sizeof(int));
|
||||
pNew->dim = (int64_t *)malloc(sizeof(int64_t));
|
||||
pNew->u.cPtr = strdup(name);
|
||||
if (pNew->dim == NULL || pNew->u.ptr == NULL) {
|
||||
if(pNew->dim == NULL || pNew->u.ptr == NULL){
|
||||
free(pNew);
|
||||
return NULL;
|
||||
}
|
||||
@ -88,249 +86,225 @@ pNXDS createTextNXDataset(char *name)
|
||||
pNew->dim[0] = strlen(name);
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void dropNXDataset(pNXDS dataset)
|
||||
{
|
||||
if (dataset == NULL) {
|
||||
void dropNXDataset(pNXDS dataset){
|
||||
if(dataset == NULL){
|
||||
return;
|
||||
}
|
||||
if (dataset->magic != MAGIC) {
|
||||
if(dataset->magic != MAGIC){
|
||||
return;
|
||||
}
|
||||
if (dataset->dim != NULL) {
|
||||
if(dataset->dim != NULL){
|
||||
free(dataset->dim);
|
||||
}
|
||||
if (dataset->u.ptr != NULL) {
|
||||
if(dataset->u.ptr != NULL){
|
||||
free(dataset->u.ptr);
|
||||
}
|
||||
if (dataset->format != NULL) {
|
||||
if(dataset->format != NULL){
|
||||
free(dataset->format);
|
||||
}
|
||||
free(dataset);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
int getNXDatasetRank(pNXDS dataset)
|
||||
{
|
||||
if (dataset == NULL) {
|
||||
int getNXDatasetRank(pNXDS dataset){
|
||||
if(dataset == NULL){
|
||||
return 0;
|
||||
}
|
||||
if (dataset->magic != MAGIC) {
|
||||
if(dataset->magic != MAGIC){
|
||||
return 0;
|
||||
}
|
||||
return dataset->rank;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
int getNXDatasetDim(pNXDS dataset, int which)
|
||||
{
|
||||
if (dataset == NULL) {
|
||||
int getNXDatasetDim(pNXDS dataset, int which){
|
||||
if(dataset == NULL){
|
||||
return 0;
|
||||
}
|
||||
if (dataset->magic != MAGIC) {
|
||||
if(dataset->magic != MAGIC){
|
||||
return 0;
|
||||
}
|
||||
if (which < 0 || which >= dataset->rank) {
|
||||
if(which < 0 || which >= dataset->rank){
|
||||
return 0;
|
||||
}
|
||||
return dataset->dim[which];
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
int getNXDatasetType(pNXDS dataset)
|
||||
{
|
||||
if (dataset == NULL) {
|
||||
int getNXDatasetType(pNXDS dataset){
|
||||
if(dataset == NULL){
|
||||
return 0;
|
||||
}
|
||||
if (dataset->magic != MAGIC) {
|
||||
if(dataset->magic != MAGIC){
|
||||
return 0;
|
||||
}
|
||||
return dataset->type;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
int getNXDatasetLength(pNXDS dataset)
|
||||
{
|
||||
int getNXDatasetLength(pNXDS dataset){
|
||||
int length, i;
|
||||
|
||||
if (dataset == NULL) {
|
||||
if(dataset == NULL){
|
||||
return 0;
|
||||
}
|
||||
if (dataset->magic != MAGIC) {
|
||||
if(dataset->magic != MAGIC){
|
||||
return 0;
|
||||
}
|
||||
length = dataset->dim[0];
|
||||
for (i = 1; i < dataset->rank; i++) {
|
||||
for(i = 1; i < dataset->rank; i++){
|
||||
length *= dataset->dim[i];
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
int getNXDatasetByteLength(pNXDS dataset)
|
||||
{
|
||||
return getNXDatasetLength(dataset) * getTypeSize(dataset->type);
|
||||
int getNXDatasetByteLength(pNXDS dataset){
|
||||
return getNXDatasetLength(dataset)*getTypeSize(dataset->type);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
This calculates an arbitray address in C storage order
|
||||
-----------------------------------------------------------------------*/
|
||||
static int calculateAddress(pNXDS dataset, int pos[])
|
||||
{
|
||||
int result, mult;
|
||||
static int64_t calculateAddress(pNXDS dataset, int64_t pos[]){
|
||||
int64_t result, mult;
|
||||
int i, j;
|
||||
|
||||
result = pos[dataset->rank - 1];
|
||||
for (i = 0; i < dataset->rank - 1; i++) {
|
||||
for(i = 0; i < dataset->rank -1; i++){
|
||||
mult = 1;
|
||||
for (j = dataset->rank - 1; j > i; j--) {
|
||||
for(j = dataset->rank -1; j > i; j--){
|
||||
mult *= dataset->dim[j];
|
||||
}
|
||||
if (pos[i] < dataset->dim[i] && pos[i] > 0) {
|
||||
result += mult * pos[i];
|
||||
if(pos[i] < dataset->dim[i] && pos[i] > 0){
|
||||
result += mult*pos[i];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
double getNXDatasetValue(pNXDS dataset, int pos[])
|
||||
{
|
||||
int address;
|
||||
double value;
|
||||
|
||||
if (dataset == NULL) {
|
||||
double getNXDatasetValue(pNXDS dataset, int64_t pos[]){
|
||||
int64_t address;
|
||||
|
||||
if(dataset == NULL){
|
||||
return 0;
|
||||
}
|
||||
if (dataset->magic != MAGIC) {
|
||||
if(dataset->magic != MAGIC){
|
||||
return 0;
|
||||
}
|
||||
|
||||
address = calculateAddress(dataset, pos);
|
||||
address = calculateAddress(dataset,pos);
|
||||
return getNXDatasetValueAt(dataset, address);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
double getNXDatasetValueAt(pNXDS dataset, int address)
|
||||
{
|
||||
double getNXDatasetValueAt(pNXDS dataset, int64_t address){
|
||||
double value;
|
||||
|
||||
if (dataset == NULL) {
|
||||
if(dataset == NULL){
|
||||
return 0;
|
||||
}
|
||||
if (dataset->magic != MAGIC) {
|
||||
if(dataset->magic != MAGIC){
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (dataset->type) {
|
||||
switch(dataset->type){
|
||||
case NX_FLOAT64:
|
||||
value = dataset->u.dPtr[address];
|
||||
break;
|
||||
case NX_FLOAT32:
|
||||
value = (double) dataset->u.fPtr[address];
|
||||
value = (double)dataset->u.fPtr[address];
|
||||
break;
|
||||
case NX_INT32:
|
||||
case NX_UINT32:
|
||||
value = (double) dataset->u.iPtr[address];
|
||||
value = (double)dataset->u.iPtr[address];
|
||||
break;
|
||||
case NX_INT64:
|
||||
case NX_UINT64:
|
||||
value = (double) dataset->u.lPtr[address];
|
||||
value = (double)dataset->u.lPtr[address];
|
||||
break;
|
||||
case NX_INT16:
|
||||
case NX_UINT16:
|
||||
value = (double) dataset->u.sPtr[address];
|
||||
value = (double)dataset->u.sPtr[address];
|
||||
break;
|
||||
default:
|
||||
value = (double) dataset->u.cPtr[address];
|
||||
value = (double)dataset->u.cPtr[address];
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
char *getNXDatasetText(pNXDS dataset)
|
||||
{
|
||||
char *getNXDatasetText(pNXDS dataset){
|
||||
char *resultBuffer = NULL;
|
||||
int length, status = 1;
|
||||
int status = 1;
|
||||
|
||||
if (dataset == NULL) {
|
||||
if(dataset == NULL){
|
||||
return strdup("NULL");
|
||||
}
|
||||
if (dataset->magic != MAGIC) {
|
||||
if(dataset->magic != MAGIC){
|
||||
return strdup("NULL");
|
||||
}
|
||||
if (dataset->rank > 1) {
|
||||
if(dataset->rank > 1){
|
||||
status = 0;
|
||||
}
|
||||
if (dataset->type == NX_FLOAT32 ||
|
||||
dataset->type == NX_FLOAT64 ||
|
||||
dataset->type == NX_INT32 ||
|
||||
dataset->type == NX_UINT32 ||
|
||||
dataset->type == NX_INT64 ||
|
||||
dataset->type == NX_UINT64 ||
|
||||
dataset->type == NX_INT16 || dataset->type == NX_UINT16) {
|
||||
}
|
||||
if(dataset->type == NX_FLOAT32 ||
|
||||
dataset->type == NX_FLOAT64 ||
|
||||
dataset->type == NX_INT32 ||
|
||||
dataset->type == NX_UINT32 ||
|
||||
dataset->type == NX_INT64 ||
|
||||
dataset->type == NX_UINT64 ||
|
||||
dataset->type == NX_INT16 ||
|
||||
dataset->type == NX_UINT16 ) {
|
||||
status = 0;
|
||||
}
|
||||
|
||||
if (status == 0) {
|
||||
if(status == 0){
|
||||
return strdup("NO type problem");
|
||||
} else {
|
||||
resultBuffer = (char *) malloc((dataset->dim[0] + 10) * sizeof(char));
|
||||
if (resultBuffer == NULL) {
|
||||
}else{
|
||||
resultBuffer = (char *)malloc((dataset->dim[0]+10)*sizeof(char));
|
||||
if(resultBuffer == NULL){
|
||||
return strdup("NO Memory");
|
||||
}
|
||||
memset(resultBuffer, 0, (dataset->dim[0] + 10) * sizeof(char));
|
||||
strncpy(resultBuffer, dataset->u.cPtr, dataset->dim[0]);
|
||||
memset(resultBuffer,0,(dataset->dim[0]+10)*sizeof(char));
|
||||
strncpy(resultBuffer,dataset->u.cPtr,dataset->dim[0]);
|
||||
}
|
||||
return resultBuffer;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
int putNXDatasetValue(pNXDS dataset, int pos[], double value)
|
||||
{
|
||||
int address;
|
||||
int putNXDatasetValue(pNXDS dataset, int64_t pos[], double value){
|
||||
int64_t address;
|
||||
|
||||
if (dataset == NULL) {
|
||||
if(dataset == NULL){
|
||||
return 0;
|
||||
}
|
||||
if (dataset->magic != MAGIC) {
|
||||
if(dataset->magic != MAGIC){
|
||||
return 0;
|
||||
}
|
||||
|
||||
address = calculateAddress(dataset, pos);
|
||||
return putNXDatasetValueAt(dataset, address, value);
|
||||
address = calculateAddress(dataset,pos);
|
||||
return putNXDatasetValueAt(dataset,address,value);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
int putNXDatasetValueAt(pNXDS dataset, int address, double value)
|
||||
{
|
||||
int putNXDatasetValueAt(pNXDS dataset, int64_t address, double value){
|
||||
/*
|
||||
this code is dangerous, it casts without checking the data range.
|
||||
This may cause trouble in some cases
|
||||
*/
|
||||
switch (dataset->type) {
|
||||
this code is dangerous, it casts without checking the data range.
|
||||
This may cause trouble in some cases
|
||||
*/
|
||||
switch(dataset->type){
|
||||
case NX_FLOAT64:
|
||||
dataset->u.dPtr[address] = value;
|
||||
break;
|
||||
case NX_FLOAT32:
|
||||
dataset->u.fPtr[address] = (float) value;
|
||||
dataset->u.fPtr[address] = (float)value;
|
||||
break;
|
||||
case NX_INT32:
|
||||
case NX_UINT32:
|
||||
dataset->u.iPtr[address] = (int) value;
|
||||
dataset->u.iPtr[address] = (int)value;
|
||||
break;
|
||||
case NX_INT64:
|
||||
case NX_UINT64:
|
||||
dataset->u.lPtr[address] = (int64_t) value;
|
||||
dataset->u.lPtr[address] = (int64_t)value;
|
||||
break;
|
||||
case NX_INT16:
|
||||
case NX_UINT16:
|
||||
dataset->u.sPtr[address] = (short int) value;
|
||||
dataset->u.sPtr[address] = (short int)value;
|
||||
break;
|
||||
default:
|
||||
dataset->u.cPtr[address] = (char) value;
|
||||
dataset->u.cPtr[address] = (char)value;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
@ -340,8 +314,8 @@ int putNXDatasetValueAt(pNXDS dataset, int address, double value)
|
||||
This is working recursively through the dimensions. When at the last:
|
||||
actual copying takes place.
|
||||
-----------------------------------------------------------------------*/
|
||||
static void copyCutData(pNXDS source, pNXDS target, int sourceDim[],
|
||||
int targetDim[], int start[], int end[], int dim)
|
||||
static void copyCutData(pNXDS source, pNXDS target, int64_t sourceDim[],
|
||||
int64_t targetDim[], int64_t start[], int64_t end[], int dim)
|
||||
{
|
||||
int i, length;
|
||||
double val;
|
||||
@ -366,11 +340,11 @@ static void copyCutData(pNXDS source, pNXDS target, int sourceDim[],
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
pNXDS cutNXDataset(pNXDS source, int start[], int end[])
|
||||
pNXDS cutNXDataset(pNXDS source, int64_t start[], int64_t end[])
|
||||
{
|
||||
pNXDS result = NULL;
|
||||
int newDim[NX_MAXRANK], i;
|
||||
int sourceDim[NX_MAXRANK], targetDim[NX_MAXRANK];
|
||||
int64_t newDim[NX_MAXRANK], i;
|
||||
int64_t sourceDim[NX_MAXRANK], targetDim[NX_MAXRANK];
|
||||
|
||||
for (i = 0; i < source->rank; i++) {
|
||||
if (start[i] < 0 || end[i] > source->dim[i]) {
|
||||
@ -399,8 +373,8 @@ pNXDS cutNXDataset(pNXDS source, int start[], int end[])
|
||||
This recurses through all dimensions, thereby skipping the summed one.
|
||||
At the end of the recursion the actual summing is performed.
|
||||
----------------------------------------------------------------------*/
|
||||
static void sumData(pNXDS source, pNXDS target, int sourceDim[],
|
||||
int targetDim[], int targetDimCount, int dimNo,
|
||||
static void sumData(pNXDS source, pNXDS target, int64_t sourceDim[],
|
||||
int64_t targetDim[], int targetDimCount, int dimNo,
|
||||
int start, int end, int currentDim)
|
||||
{
|
||||
int i, length;
|
||||
@ -454,7 +428,7 @@ static void sumData(pNXDS source, pNXDS target, int sourceDim[],
|
||||
/*-----------------------------------------------------------------------*/
|
||||
pNXDS sumNXDataset(pNXDS source, int dimNo, int start, int end)
|
||||
{
|
||||
int newDim[NX_MAXRANK], targetDim[NX_MAXRANK], sourceDim[NX_MAXRANK];
|
||||
int64_t newDim[NX_MAXRANK], targetDim[NX_MAXRANK], sourceDim[NX_MAXRANK];
|
||||
pNXDS result = NULL;
|
||||
int i, count;
|
||||
|
||||
@ -480,3 +454,5 @@ pNXDS sumNXDataset(pNXDS source, int dimNo, int start, int end)
|
||||
sumData(source, result, sourceDim, targetDim, 0, dimNo, start, end, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
62
nxdataset.h
62
nxdataset.h
@ -10,26 +10,26 @@
|
||||
#define NXDATASET
|
||||
|
||||
|
||||
#define MAGIC 7776622
|
||||
#define MAGIC 7776622
|
||||
|
||||
#include "napiconfig.h"
|
||||
|
||||
typedef struct {
|
||||
int magic;
|
||||
int rank;
|
||||
int type;
|
||||
int *dim;
|
||||
char *format;
|
||||
union {
|
||||
void *ptr;
|
||||
float *fPtr;
|
||||
double *dPtr;
|
||||
int *iPtr;
|
||||
short int *sPtr;
|
||||
char *cPtr;
|
||||
int64_t *lPtr;
|
||||
} u;
|
||||
} *pNXDS, NXDS;
|
||||
int magic;
|
||||
int rank;
|
||||
int type;
|
||||
int64_t *dim;
|
||||
char *format;
|
||||
union {
|
||||
void *ptr;
|
||||
float *fPtr;
|
||||
double *dPtr;
|
||||
int *iPtr;
|
||||
short int *sPtr;
|
||||
char *cPtr;
|
||||
int64_t *lPtr;
|
||||
} u;
|
||||
}*pNXDS, NXDS;
|
||||
|
||||
/*
|
||||
include NeXus type codes if not already defined
|
||||
@ -38,9 +38,9 @@ typedef struct {
|
||||
|
||||
#define NX_FLOAT32 5
|
||||
#define NX_FLOAT64 6
|
||||
#define NX_INT8 20
|
||||
#define NX_INT8 20
|
||||
#define NX_UINT8 21
|
||||
#define NX_INT16 22
|
||||
#define NX_INT16 22
|
||||
#define NX_UINT16 23
|
||||
#define NX_INT32 24
|
||||
#define NX_UINT32 25
|
||||
@ -53,25 +53,25 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
|
||||
pNXDS createNXDataset(int rank, int typecode, int dim[]);
|
||||
pNXDS createNXDataset(int rank, int typecode, int64_t dim[]);
|
||||
pNXDS createTextNXDataset(char *name);
|
||||
|
||||
void dropNXDataset(pNXDS dataset);
|
||||
void dropNXDataset(pNXDS dataset);
|
||||
|
||||
int getNXDatasetRank(pNXDS dataset);
|
||||
int getNXDatasetDim(pNXDS dataset, int which);
|
||||
int getNXDatasetType(pNXDS dataset);
|
||||
int getNXDatasetLength(pNXDS dataset);
|
||||
int getNXDatasetByteLength(pNXDS dataset);
|
||||
int getNXDatasetRank(pNXDS dataset);
|
||||
int getNXDatasetDim(pNXDS dataset, int which);
|
||||
int getNXDatasetType(pNXDS dataset);
|
||||
int getNXDatasetLength(pNXDS dataset);
|
||||
int getNXDatasetByteLength(pNXDS dataset);
|
||||
|
||||
double getNXDatasetValue(pNXDS dataset, int pos[]);
|
||||
double getNXDatasetValueAt(pNXDS dataset, int address);
|
||||
char *getNXDatasetText(pNXDS dataset);
|
||||
double getNXDatasetValue(pNXDS dataset, int64_t pos[]);
|
||||
double getNXDatasetValueAt(pNXDS dataset, int64_t address);
|
||||
char *getNXDatasetText(pNXDS dataset);
|
||||
|
||||
int putNXDatasetValue(pNXDS dataset, int pos[], double value);
|
||||
int putNXDatasetValueAt(pNXDS dataset, int address, double value);
|
||||
int putNXDatasetValue(pNXDS dataset, int64_t pos[], double value);
|
||||
int putNXDatasetValueAt(pNXDS dataset, int64_t address, double value);
|
||||
|
||||
pNXDS cutNXDataset(pNXDS source, int start[], int end[]);
|
||||
pNXDS cutNXDataset(pNXDS source, int64_t start[], int64_t end[]);
|
||||
pNXDS sumNXDataset(pNXDS source, int dimNo, int start, int end);
|
||||
|
||||
#endif
|
||||
|
109
nxdict.c
109
nxdict.c
@ -47,8 +47,7 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
Things defined in napi.c for error reporting
|
||||
---------------------------------------------------------------------------*/
|
||||
extern void *NXpData;
|
||||
extern void (*NXIReportError) (void *pData, char *pBuffer);
|
||||
static void *NXpData = NULL;
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* #define DEFDEBUG 1 */
|
||||
/* define DEFDEBUG when you wish to print your definition strings before
|
||||
@ -95,7 +94,7 @@ static char *NXDIReadFile(FILE * fd)
|
||||
|
||||
/* check for existence of the NXDICT string in the file */
|
||||
if (strncmp(pNew, "##NXDICT-1.0", 12) != 0) {
|
||||
NXIReportError(NXpData, "ERROR: This is NO NXdict file");
|
||||
NXReportError("ERROR: This is NO NXdict file");
|
||||
free(pNew);
|
||||
return NULL;
|
||||
}
|
||||
@ -256,11 +255,11 @@ NXstatus NXDinitfromfile(char *filename, NXdict * pData)
|
||||
|
||||
/* allocate a new NXdict structure */
|
||||
if (iVerbosity == NXalot) {
|
||||
NXIReportError(NXpData, "Allocating new NXdict structure ");
|
||||
NXReportError("Allocating new NXdict structure ");
|
||||
}
|
||||
pNew = (NXdict) malloc(sizeof(sNXdict));
|
||||
if (!pNew) {
|
||||
NXIReportError(NXpData, "Insufficient memory for creation of NXdict");
|
||||
NXReportError("Insufficient memory for creation of NXdict");
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -268,7 +267,7 @@ NXstatus NXDinitfromfile(char *filename, NXdict * pData)
|
||||
pNew->iID = NXDMAGIC;
|
||||
pNew->pDictionary = CreateStringDict();
|
||||
if (!pNew->pDictionary) {
|
||||
NXIReportError(NXpData, "Insufficient memory for creation of NXdict");
|
||||
NXReportError("Insufficient memory for creation of NXdict");
|
||||
free(pNew);
|
||||
return NX_ERROR;
|
||||
}
|
||||
@ -278,7 +277,7 @@ NXstatus NXDinitfromfile(char *filename, NXdict * pData)
|
||||
/* is there a file name argument */
|
||||
if (filename == NULL) {
|
||||
if (iVerbosity == NXalot) {
|
||||
NXIReportError(NXpData, "NXDinitfrom file finished without data");
|
||||
NXReportError("NXDinitfrom file finished without data");
|
||||
}
|
||||
*pData = pNew;
|
||||
return NX_OK;
|
||||
@ -288,8 +287,8 @@ NXstatus NXDinitfromfile(char *filename, NXdict * pData)
|
||||
fd = fopen(filename, "rb");
|
||||
if (!fd) {
|
||||
sprintf(pError, "ERROR: file %s NOT found ", filename);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXIReportError(NXpData, "NXDinitfrom file finished without data");
|
||||
NXReportError(pError);
|
||||
NXReportError("NXDinitfrom file finished without data");
|
||||
*pData = pNew;
|
||||
return NX_ERROR;
|
||||
}
|
||||
@ -297,27 +296,27 @@ NXstatus NXDinitfromfile(char *filename, NXdict * pData)
|
||||
|
||||
/* read the file contents */
|
||||
if (iVerbosity == NXalot) {
|
||||
NXIReportError(NXpData, "NXDinitfrom: reading file");
|
||||
NXReportError("NXDinitfrom: reading file");
|
||||
}
|
||||
pBuffer = NXDIReadFile(fd);
|
||||
fclose(fd); /* we are done with it then */
|
||||
if (!pBuffer) {
|
||||
sprintf(pError, "ERROR: reading file %s or no memory", filename);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXIReportError(NXpData, "NXDinitfrom file finished without data");
|
||||
NXReportError(pError);
|
||||
NXReportError("NXDinitfrom file finished without data");
|
||||
*pData = pNew;
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
/* parse it */
|
||||
if (iVerbosity == NXalot) {
|
||||
NXIReportError(NXpData, "NXDinitfrom: parsing dictionary definitions");
|
||||
NXReportError("NXDinitfrom: parsing dictionary definitions");
|
||||
}
|
||||
NXDIParse(pBuffer, pNew->pDictionary);
|
||||
|
||||
|
||||
if (iVerbosity == NXalot) {
|
||||
NXIReportError(NXpData, "NXDinitfrom: performed successfully");
|
||||
NXReportError("NXDinitfrom: performed successfully");
|
||||
}
|
||||
free(pBuffer);
|
||||
*pData = pNew;
|
||||
@ -350,12 +349,12 @@ NXstatus NXDclose(NXdict handle, char *filename)
|
||||
if (filename) { /* we must write a file */
|
||||
if (iVerbosity == NXalot) {
|
||||
sprintf(pValue, "Writing file %s", filename);
|
||||
NXIReportError(NXpData, pValue);
|
||||
NXReportError(pValue);
|
||||
}
|
||||
fd = fopen(filename, "w");
|
||||
if (!fd) {
|
||||
sprintf(pValue, "ERROR: opening file %s for write", filename);
|
||||
NXIReportError(NXpData, pValue);
|
||||
NXReportError(pValue);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -371,7 +370,7 @@ NXstatus NXDclose(NXdict handle, char *filename)
|
||||
fclose(fd);
|
||||
if (iVerbosity == NXalot) {
|
||||
sprintf(pValue, "File %s written", filename);
|
||||
NXIReportError(NXpData, pValue);
|
||||
NXReportError(pValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -445,7 +444,7 @@ pDynString NXDItextreplace(NXdict handle, char *pDefString)
|
||||
/* create a dynamic string */
|
||||
pReplaced = CreateDynString(strlen(pDefString), 512);
|
||||
if (!pReplaced) {
|
||||
NXIReportError(NXpData, "ERROR: out of memory in NXDtextreplace");
|
||||
NXReportError("ERROR: out of memory in NXDtextreplace");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -479,8 +478,7 @@ pDynString NXDItextreplace(NXdict handle, char *pDefString)
|
||||
pBueffel[iPos] = *pPtr;
|
||||
iPos++;
|
||||
if (iPos >= 1024) {
|
||||
NXIReportError(NXpData,
|
||||
"ERROR: buffer overrun in NXDItextreplace");
|
||||
NXReportError("ERROR: buffer overrun in NXDItextreplace");
|
||||
DeleteDynString(pReplaced);
|
||||
return NULL;
|
||||
}
|
||||
@ -737,7 +735,7 @@ int NXDIParsePath(NXhandle hfil, ParDat * pParse)
|
||||
if (pParse->iToken != DWORD) {
|
||||
sprintf(pError, "ERROR: parse error at %s, expected vGroup name",
|
||||
pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
strcpy(pName, pParse->pToken);
|
||||
@ -747,7 +745,7 @@ int NXDIParsePath(NXhandle hfil, ParDat * pParse)
|
||||
if (pParse->iToken != DKOMMA) {
|
||||
sprintf(pError, "ERROR: parse error at %s, expected komma",
|
||||
pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -756,18 +754,18 @@ int NXDIParsePath(NXhandle hfil, ParDat * pParse)
|
||||
if (pParse->iToken != DWORD) {
|
||||
sprintf(pError, "ERROR: parse error at %s, expected vGroup class",
|
||||
pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
strcpy(pClass, pParse->pToken);
|
||||
|
||||
/* done reading, ACTION, first install dummy error handler */
|
||||
ErrFunc = NXIReportError;
|
||||
NXMSetError(NXpData, DummyError);
|
||||
NXMSetError(NXpData,DummyError);
|
||||
|
||||
/* try opening vGroup */
|
||||
iRet = NXopengroup(hfil, pName, pClass);
|
||||
NXMSetError(NXpData, ErrFunc);
|
||||
NXMSetError(NXpData,ErrFunc);
|
||||
if (iRet == NX_OK) {
|
||||
pParse->iDepth++;
|
||||
return NX_OK;
|
||||
@ -789,7 +787,7 @@ int NXDIParsePath(NXhandle hfil, ParDat * pParse)
|
||||
} else {
|
||||
/* this is an error */
|
||||
sprintf(pError, "ERROR: vGroup %s, %s NOT found", pName, pClass);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
}
|
||||
@ -809,7 +807,7 @@ static int NXDIParseAttr(ParDat * pParse, int iList)
|
||||
NXDIDefToken(pParse);
|
||||
if (pParse->iToken != DOPEN) {
|
||||
sprintf(pError, "ERROR: expected {, got %s", pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -818,7 +816,7 @@ static int NXDIParseAttr(ParDat * pParse, int iList)
|
||||
if (pParse->iToken != DWORD) {
|
||||
sprintf(pError, "ERROR: expected attribute name, got %s",
|
||||
pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
strcpy(sAtt.name, pParse->pToken);
|
||||
@ -827,7 +825,7 @@ static int NXDIParseAttr(ParDat * pParse, int iList)
|
||||
NXDIDefToken(pParse);
|
||||
if (pParse->iToken != DKOMMA) {
|
||||
sprintf(pError, "ERROR: expected , , got %s", pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -836,7 +834,7 @@ static int NXDIParseAttr(ParDat * pParse, int iList)
|
||||
if (pParse->iToken != DWORD) {
|
||||
sprintf(pError, "ERROR: expected attribute value, got %s",
|
||||
pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
strcpy(sAtt.value, pParse->pToken);
|
||||
@ -845,7 +843,7 @@ static int NXDIParseAttr(ParDat * pParse, int iList)
|
||||
NXDIDefToken(pParse);
|
||||
if (pParse->iToken != DCLOSE) {
|
||||
sprintf(pError, "ERROR: expected }, got %s", pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -868,7 +866,7 @@ static int NXDIParseDim(ParDat * pParse, int *iDim)
|
||||
NXDIDefToken(pParse);
|
||||
if (pParse->iToken != DOPEN) {
|
||||
sprintf(pError, "ERROR: expected {, got %s", pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -878,7 +876,7 @@ static int NXDIParseDim(ParDat * pParse, int *iDim)
|
||||
NXDIDefToken(pParse);
|
||||
if (pParse->iToken != DWORD) {
|
||||
sprintf(pError, "ERROR: expected number, got %s", pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
iDim[i] = atoi(pParse->pToken);
|
||||
@ -887,7 +885,7 @@ static int NXDIParseDim(ParDat * pParse, int *iDim)
|
||||
NXDIDefToken(pParse);
|
||||
if ((pParse->iToken != DKOMMA) && (pParse->iToken != DCLOSE)) {
|
||||
sprintf(pError, "ERROR: expected , or }, got %s", pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError( pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
if (pParse->iToken == DCLOSE) {
|
||||
@ -930,7 +928,7 @@ static int NXDIParseType(ParDat * pParse, int *iType)
|
||||
NXDIDefToken(pParse);
|
||||
if (pParse->iToken != DWORD) {
|
||||
sprintf(pError, "ERROR: expected data type, got %s", pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -947,7 +945,7 @@ static int NXDIParseType(ParDat * pParse, int *iType)
|
||||
*/
|
||||
sprintf(pError, "ERROR: %s not recognized as valid data type",
|
||||
pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -972,7 +970,7 @@ static int NXDIParseSDS(NXhandle hfil, ParDat * pParse)
|
||||
if (pParse->iToken != DWORD) {
|
||||
sprintf(pError, "ERROR: parsing, expected name, got %s",
|
||||
pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
strcpy(pName, pParse->pToken);
|
||||
@ -980,7 +978,7 @@ static int NXDIParseSDS(NXhandle hfil, ParDat * pParse)
|
||||
/* create the attribute list */
|
||||
iList = LLDcreate(sizeof(AttItem));
|
||||
if (iList < 0) {
|
||||
NXIReportError(NXpData, "ERROR: cannot create list in NXDIParseSDS");
|
||||
NXReportError("ERROR: cannot create list in NXDIParseSDS");
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -991,7 +989,7 @@ static int NXDIParseSDS(NXhandle hfil, ParDat * pParse)
|
||||
NXDIDefToken(pParse); /* advance */
|
||||
if (pParse->iToken != DWORD) {
|
||||
sprintf(pError, "ERROR: expected int, got %s", pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
LLDdelete(iList);
|
||||
return NX_ERROR;
|
||||
}
|
||||
@ -1039,7 +1037,7 @@ static int NXDIParseSDS(NXhandle hfil, ParDat * pParse)
|
||||
break;
|
||||
default:
|
||||
sprintf(pError, "ERROR: cannot identify token %s", pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
LLDdelete(iList);
|
||||
return NX_ERROR;
|
||||
|
||||
@ -1107,7 +1105,7 @@ static int NXDIParseSDS(NXhandle hfil, ParDat * pParse)
|
||||
} else {
|
||||
/* this is an error */
|
||||
sprintf(pError, "ERROR: SDS %s NOT found", pName);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
LLDdelete(iList);
|
||||
return NX_ERROR;
|
||||
}
|
||||
@ -1125,7 +1123,7 @@ static int NXDIParseLink(NXhandle hfil, NXdict pDict, ParDat * pParse)
|
||||
NXDIDefToken(pParse);
|
||||
if (pParse->iToken != DCLOSE) {
|
||||
sprintf(pError, "ERROR: expected alias , got %s", pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -1181,7 +1179,7 @@ int NXDIDefParse(NXhandle hFil, NXdict pDict, ParDat * pParse)
|
||||
sprintf(pError,
|
||||
"ERROR: Definition String parse error: %s not permitted here",
|
||||
pParse->pToken);
|
||||
NXIReportError(NXpData, pError);
|
||||
NXReportError(pError);
|
||||
return NX_ERROR;
|
||||
break;
|
||||
}
|
||||
@ -1240,7 +1238,7 @@ NXstatus NXDopenalias(NXhandle hfil, NXdict dict, char *pAlias)
|
||||
iRet = NXDget(pDict, pAlias, pDefinition, 2047);
|
||||
if (iRet != NX_OK) {
|
||||
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
||||
NXIReportError(NXpData, pDefinition);
|
||||
NXReportError(pDefinition);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -1281,7 +1279,7 @@ NXstatus NXDputdef(NXhandle hFil, NXdict dict, char *pDef, void *pData)
|
||||
|
||||
/* only SDS can be written */
|
||||
if (pParse.iTerminal != TERMSDS) {
|
||||
NXIReportError(NXpData, "ERROR: can only write to an SDS!");
|
||||
NXReportError("ERROR: can only write to an SDS!");
|
||||
iStat = NX_ERROR;
|
||||
} else {
|
||||
/* the SDS should be open by now, write it */
|
||||
@ -1312,7 +1310,7 @@ NXstatus NXDputalias(NXhandle hFil, NXdict dict, char *pAlias, void *pData)
|
||||
iRet = NXDget(pDict, pAlias, pDefinition, 2047);
|
||||
if (iRet != NX_OK) {
|
||||
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
||||
NXIReportError(NXpData, pDefinition);
|
||||
NXReportError( pDefinition);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -1354,7 +1352,7 @@ NXstatus NXDgetdef(NXhandle hFil, NXdict dict, char *pDef, void *pData)
|
||||
|
||||
/* only SDS can be written */
|
||||
if (pParse.iTerminal != TERMSDS) {
|
||||
NXIReportError(NXpData, "ERROR: can only write to an SDS!");
|
||||
NXReportError("ERROR: can only write to an SDS!");
|
||||
iStat = NX_ERROR;
|
||||
} else {
|
||||
/* the SDS should be open by now, read it */
|
||||
@ -1385,7 +1383,7 @@ NXstatus NXDgetalias(NXhandle hFil, NXdict dict, char *pAlias, void *pData)
|
||||
iRet = NXDget(pDict, pAlias, pDefinition, 2047);
|
||||
if (iRet != NX_OK) {
|
||||
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
||||
NXIReportError(NXpData, pDefinition);
|
||||
NXReportError(pDefinition);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -1429,7 +1427,7 @@ NXstatus NXDinfodef(NXhandle hFil, NXdict dict, char *pDef, int *rank,
|
||||
|
||||
/* only SDS can be written */
|
||||
if (pParse.iTerminal != TERMSDS) {
|
||||
NXIReportError(NXpData, "ERROR: can only write to an SDS!");
|
||||
NXReportError("ERROR: can only write to an SDS!");
|
||||
iStat = NX_ERROR;
|
||||
} else {
|
||||
/* the SDS should be open by now, read it */
|
||||
@ -1462,7 +1460,7 @@ NXstatus NXDinfoalias(NXhandle hFil, NXdict dict, char *pAlias, int *rank,
|
||||
iRet = NXDget(pDict, pAlias, pDefinition, 2047);
|
||||
if (iRet != NX_OK) {
|
||||
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
||||
NXIReportError(NXpData, pDefinition);
|
||||
NXReportError(pDefinition);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -1540,7 +1538,7 @@ NXstatus NXDdeflink(NXhandle hFil, NXdict dict,
|
||||
}
|
||||
/* check it being a vGroup! */
|
||||
if (pParseT.iTerminal != TERMVG) {
|
||||
NXIReportError(NXpData, "ERROR: can link only into a vGroup");
|
||||
NXReportError("ERROR: can link only into a vGroup");
|
||||
NXDIUnwind(hFil, pParseT.iDepth);
|
||||
return NX_ERROR;
|
||||
}
|
||||
@ -1570,7 +1568,7 @@ NXstatus NXDaliaslink(NXhandle hFil, NXdict dict,
|
||||
iRet = NXDget(pDict, pTarget, pTargetDef, 2047);
|
||||
if (iRet != NX_OK) {
|
||||
sprintf(pTargetDef, "ERROR: alias %s not recognized", pTarget);
|
||||
NXIReportError(NXpData, pTargetDef);
|
||||
NXReportError(pTargetDef);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -1578,7 +1576,7 @@ NXstatus NXDaliaslink(NXhandle hFil, NXdict dict,
|
||||
iRet = NXDget(pDict, pVictim, pVictimDef, 2047);
|
||||
if (iRet != NX_OK) {
|
||||
sprintf(pTargetDef, "ERROR: alias %s not recognized", pTarget);
|
||||
NXIReportError(NXpData, pTargetDef);
|
||||
NXReportError(pTargetDef);
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -1800,8 +1798,7 @@ NXstatus NXUallocSDS(NXhandle hFil, void **pData)
|
||||
lLength *= sizeof(int);
|
||||
break;
|
||||
default:
|
||||
NXIReportError(NXpData,
|
||||
"ERROR: Internal: number type not recoginized");
|
||||
NXReportError("ERROR: Internal: number type not recoginized");
|
||||
return NX_ERROR;
|
||||
}
|
||||
|
||||
@ -1809,7 +1806,7 @@ NXstatus NXUallocSDS(NXhandle hFil, void **pData)
|
||||
*pData = NULL;
|
||||
*pData = malloc(lLength);
|
||||
if (*pData == NULL) {
|
||||
NXIReportError(NXpData, "ERROR: memory exhausted in NXUallocSDS");
|
||||
NXReportError("ERROR: memory exhausted in NXUallocSDS");
|
||||
return NX_ERROR;
|
||||
}
|
||||
memset(*pData, 0, lLength);
|
||||
|
@ -1741,7 +1741,7 @@ SWIGINTERNINLINE Tcl_Obj *SWIG_From_int(int value)
|
||||
void *create_nxds(int rank, int type, int dim0, int dim1, int dim2,
|
||||
int dim3, int dim4, int dim5, int dim6)
|
||||
{
|
||||
int dim[MAXDIM], i;
|
||||
int64_t dim[MAXDIM], i;
|
||||
|
||||
dim[0] = dim0;
|
||||
dim[1] = dim1;
|
||||
@ -1781,7 +1781,7 @@ int get_nxds_dim(void *ptr, int which)
|
||||
double get_nxds_value(void *ptr, int dim0, int dim1, int dim2,
|
||||
int dim3, int dim4, int dim5, int dim6)
|
||||
{
|
||||
int dim[MAXDIM];
|
||||
int64_t dim[MAXDIM];
|
||||
|
||||
dim[0] = dim0;
|
||||
dim[1] = dim1;
|
||||
@ -1802,7 +1802,7 @@ char *get_nxds_text(void *ptr)
|
||||
int put_nxds_value(void *ptr, double value, int dim0, int dim1, int dim2,
|
||||
int dim3, int dim4, int dim5, int dim6)
|
||||
{
|
||||
int dim[MAXDIM];
|
||||
int64_t dim[MAXDIM];
|
||||
|
||||
dim[0] = dim0;
|
||||
dim[1] = dim1;
|
||||
|
@ -314,6 +314,7 @@ void *nx_getslab(void *handle, void *startdim, void *sizedim)
|
||||
pNXDS resultdata;
|
||||
pNXDS start, size;
|
||||
int status, rank, type, dim[NX_MAXRANK];
|
||||
int64_t cdim[NX_MAXRANK], i;
|
||||
NXhandle hfil;
|
||||
|
||||
hfil = (NXhandle) handle;
|
||||
@ -328,7 +329,10 @@ void *nx_getslab(void *handle, void *startdim, void *sizedim)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
resultdata = createNXDataset(rank, type, size->u.iPtr);
|
||||
for(i = 0; i < rank; i++){
|
||||
cdim[i] = size->u.iPtr[i];
|
||||
}
|
||||
resultdata = createNXDataset(rank, type, cdim);
|
||||
if (resultdata == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -346,7 +350,8 @@ void *nx_getslab(void *handle, void *startdim, void *sizedim)
|
||||
void *nx_getds(void *handle, char *name)
|
||||
{
|
||||
pNXDS result = NULL;
|
||||
int rank, type, dim[NX_MAXRANK], status;
|
||||
int rank, type,status;
|
||||
int64_t dim[NX_MAXRANK];
|
||||
NXhandle hfil;
|
||||
|
||||
hfil = (NXhandle) handle;
|
||||
@ -355,7 +360,7 @@ void *nx_getds(void *handle, char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = NXgetinfo(hfil, &rank, dim, &type);
|
||||
status = NXgetinfo64(hfil, &rank, dim, &type);
|
||||
if (status != NX_OK) {
|
||||
return NULL;
|
||||
}
|
||||
@ -388,7 +393,7 @@ int nx_putds(void *handle, char *name, void *dataset)
|
||||
|
||||
status = NXopendata(hfil, name);
|
||||
if (status != NX_OK) {
|
||||
status = NXmakedata(hfil, name, data->type, data->rank, data->dim);
|
||||
status = NXmakedata64(hfil, name, data->type, data->rank, data->dim);
|
||||
if (status != NX_OK) {
|
||||
return 0;
|
||||
}
|
||||
@ -408,12 +413,13 @@ int nx_putds(void *handle, char *name, void *dataset)
|
||||
void *nx_getdata(void *handle)
|
||||
{
|
||||
pNXDS result = NULL;
|
||||
int rank, type, dim[NX_MAXRANK], status;
|
||||
int rank, type, status;
|
||||
int64_t dim[NX_MAXRANK];
|
||||
NXhandle hfil;
|
||||
|
||||
|
||||
hfil = (NXhandle) handle;
|
||||
status = NXgetinfo(hfil, &rank, dim, &type);
|
||||
status = NXgetinfo64(hfil, &rank, dim, &type);
|
||||
if (status != NX_OK) {
|
||||
return NULL;
|
||||
}
|
||||
@ -459,7 +465,8 @@ int nx_putdata(void *handle, void *dataset)
|
||||
void *nx_getinfo(void *handle)
|
||||
{
|
||||
NXhandle hfil;
|
||||
int status, type, rank, dim[NX_MAXRANK], rdim[1], i;
|
||||
int status, type, rank, dim[NX_MAXRANK], i;
|
||||
int64_t rdim[1];
|
||||
pNXDS data = NULL;
|
||||
|
||||
hfil = (NXhandle) handle;
|
||||
@ -550,7 +557,8 @@ int nx_putattr(void *handle, char *name, void *ds)
|
||||
void *nx_getattr(void *handle, char *name, int type, int length)
|
||||
{
|
||||
NXhandle hfil;
|
||||
int status, tp, ll, dim[1];
|
||||
int status, tp, ll;
|
||||
int64_t dim[1];
|
||||
pNXDS data = NULL;
|
||||
|
||||
|
||||
|
651
nxio.c
651
nxio.c
@ -21,9 +21,12 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* For further information, see <http://www.neutron.anl.gov/NeXus/>
|
||||
* For further information, see <http://www.nexusformat.org>
|
||||
*/
|
||||
#include <mxml.h>
|
||||
|
||||
#ifdef NXXML
|
||||
|
||||
#include <mxml.h>
|
||||
#include <assert.h>
|
||||
#include "napi.h"
|
||||
#include "nxio.h"
|
||||
@ -35,181 +38,188 @@
|
||||
#define MXML_WRAP 79
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* #define TESTMAIN 1 */
|
||||
/*=================== type code handling ================================= */
|
||||
typedef struct {
|
||||
char name[30];
|
||||
char format[30];
|
||||
int nx_type;
|
||||
} type_code;
|
||||
int nx_type;
|
||||
}type_code;
|
||||
|
||||
#define NTYPECODE 11
|
||||
static type_code typecode[NTYPECODE];
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void initializeNumberFormats()
|
||||
{
|
||||
void initializeNumberFormats(){
|
||||
type_code myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_FLOAT32");
|
||||
strcpy(myCode.format, "%12.4f");
|
||||
strcpy(myCode.name,"NX_FLOAT32");
|
||||
strcpy(myCode.format,"%12.4f");
|
||||
myCode.nx_type = NX_FLOAT32;
|
||||
typecode[0] = myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_FLOAT64");
|
||||
strcpy(myCode.format, "%16.5f");
|
||||
strcpy(myCode.name,"NX_FLOAT64");
|
||||
strcpy(myCode.format,"%16.5f");
|
||||
myCode.nx_type = NX_FLOAT64;
|
||||
typecode[1] = myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_INT8");
|
||||
strcpy(myCode.format, "%5d");
|
||||
strcpy(myCode.name,"NX_INT8");
|
||||
strcpy(myCode.format,"%5d");
|
||||
myCode.nx_type = NX_INT8;
|
||||
typecode[2] = myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_UINT8");
|
||||
strcpy(myCode.format, "%5d");
|
||||
strcpy(myCode.name,"NX_UINT8");
|
||||
strcpy(myCode.format,"%5d");
|
||||
myCode.nx_type = NX_UINT8;
|
||||
typecode[3] = myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_INT16");
|
||||
strcpy(myCode.format, "%8d");
|
||||
strcpy(myCode.name,"NX_INT16");
|
||||
strcpy(myCode.format,"%8d");
|
||||
myCode.nx_type = NX_INT16;
|
||||
typecode[4] = myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_UINT16");
|
||||
strcpy(myCode.format, "%8d");
|
||||
strcpy(myCode.name,"NX_UINT16");
|
||||
strcpy(myCode.format,"%8d");
|
||||
myCode.nx_type = NX_UINT16;
|
||||
typecode[5] = myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_INT32");
|
||||
strcpy(myCode.format, "%12d");
|
||||
strcpy(myCode.name,"NX_INT32");
|
||||
strcpy(myCode.format,"%12d");
|
||||
myCode.nx_type = NX_INT32;
|
||||
typecode[6] = myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_UINT32");
|
||||
strcpy(myCode.format, "%12d");
|
||||
strcpy(myCode.name,"NX_UINT32");
|
||||
strcpy(myCode.format,"%12d");
|
||||
myCode.nx_type = NX_UINT32;
|
||||
typecode[7] = myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_INT64");
|
||||
strcpy(myCode.format, "%24" PRINTF_INT64);
|
||||
strcpy(myCode.name,"NX_INT64");
|
||||
strcpy(myCode.format,"%24lld");
|
||||
myCode.nx_type = NX_INT64;
|
||||
typecode[8] = myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_UINT64");
|
||||
strcpy(myCode.format, "%24" PRINTF_UINT64);
|
||||
strcpy(myCode.name,"NX_UINT64");
|
||||
strcpy(myCode.format,"%24llu");
|
||||
myCode.nx_type = NX_UINT64;
|
||||
typecode[9] = myCode;
|
||||
|
||||
strcpy(myCode.name, "NX_CHAR");
|
||||
strcpy(myCode.format, "%c");
|
||||
strcpy(myCode.name,"NX_CHAR");
|
||||
strcpy(myCode.format,"%c");
|
||||
myCode.nx_type = NX_CHAR;
|
||||
typecode[10] = myCode;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void setNumberFormat(int nx_type, char *format)
|
||||
{
|
||||
void setNumberFormat(int nx_type, char *format){
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NTYPECODE; i++) {
|
||||
if (typecode[i].nx_type == nx_type) {
|
||||
strncpy(typecode[i].format, format, 29);
|
||||
for(i = 0; i < NTYPECODE; i++){
|
||||
if(typecode[i].nx_type == nx_type){
|
||||
strncpy(typecode[i].format,format,29);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
static void getNumberFormat(int nx_type, char format[30])
|
||||
{
|
||||
static void getNumberFormat(int nx_type, char format[30]){
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NTYPECODE; i++) {
|
||||
if (typecode[i].nx_type == nx_type) {
|
||||
strncpy(format, typecode[i].format, 29);
|
||||
for(i = 0; i < NTYPECODE; i++){
|
||||
if(typecode[i].nx_type == nx_type){
|
||||
strncpy(format,typecode[i].format,29);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
void getNumberText(int nx_type, char *typestring, int typeLen)
|
||||
{
|
||||
void getNumberText(int nx_type, char *typestring, int typeLen){
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NTYPECODE; i++) {
|
||||
if (typecode[i].nx_type == nx_type) {
|
||||
strncpy(typestring, typecode[i].name, typeLen);
|
||||
for(i = 0; i < NTYPECODE; i++){
|
||||
if(typecode[i].nx_type == nx_type){
|
||||
strncpy(typestring,typecode[i].name,typeLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 'mxml_add_char()' - Add a character to a buffer, expanding as needed.
|
||||
* copied here from mxml-file.c to achieve compatibility with mxml-2.1
|
||||
* standard
|
||||
*/
|
||||
|
||||
static int /* O - 0 on success, -1 on error */ myxml_add_char(int ch, /* I - Character to add */
|
||||
char **bufptr, /* IO - Current position in buffer */
|
||||
char **buffer, /* IO - Current buffer */
|
||||
int
|
||||
*bufsize)
|
||||
{ /* IO - Current buffer size */
|
||||
char *newbuffer; /* New buffer value */
|
||||
static int /* O - 0 on success, -1 on error */
|
||||
myxml_add_char(int ch, /* I - Character to add */
|
||||
char **bufptr, /* IO - Current position in buffer */
|
||||
char **buffer, /* IO - Current buffer */
|
||||
size_t *bufsize) /* IO - Current buffer size */
|
||||
{
|
||||
char *newbuffer; /* New buffer value */
|
||||
|
||||
|
||||
if (*bufptr >= (*buffer + *bufsize - 4)) {
|
||||
/*
|
||||
* Increase the size of the buffer...
|
||||
*/
|
||||
if (*bufptr >= (*buffer + *bufsize - 4))
|
||||
{
|
||||
/*
|
||||
* Increase the size of the buffer...
|
||||
*/
|
||||
|
||||
if (*bufsize < 1024) {
|
||||
if (*bufsize < 1024)
|
||||
{
|
||||
(*bufsize) *= 2;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
(*bufsize) *= 3;
|
||||
(*bufsize) /= 2;
|
||||
}
|
||||
|
||||
newbuffer = (char *) malloc(*bufsize * sizeof(char));
|
||||
if (!newbuffer) {
|
||||
newbuffer = (char *)malloc(*bufsize*sizeof(char));
|
||||
if(!newbuffer){
|
||||
free(*buffer);
|
||||
|
||||
mxml_error("Unable to expand string buffer to %d bytes!", *bufsize);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
memset(newbuffer, 0, *bufsize * sizeof(char));
|
||||
memcpy(newbuffer, *buffer, *bufptr - *buffer);
|
||||
memset(newbuffer,0,*bufsize*sizeof(char));
|
||||
memcpy(newbuffer,*buffer,*bufptr - *buffer);
|
||||
free(*buffer);
|
||||
|
||||
*bufptr = newbuffer + (*bufptr - *buffer);
|
||||
*buffer = newbuffer;
|
||||
}
|
||||
|
||||
if (ch < 128) {
|
||||
/*
|
||||
* Single byte ASCII...
|
||||
*/
|
||||
if (ch < 128)
|
||||
{
|
||||
/*
|
||||
* Single byte ASCII...
|
||||
*/
|
||||
|
||||
*(*bufptr)++ = ch;
|
||||
} else if (ch < 2048) {
|
||||
/*
|
||||
* Two-byte UTF-8...
|
||||
*/
|
||||
}
|
||||
else if (ch < 2048)
|
||||
{
|
||||
/*
|
||||
* Two-byte UTF-8...
|
||||
*/
|
||||
|
||||
*(*bufptr)++ = 0xc0 | (ch >> 6);
|
||||
*(*bufptr)++ = 0x80 | (ch & 0x3f);
|
||||
} else if (ch < 65536) {
|
||||
/*
|
||||
* Three-byte UTF-8...
|
||||
*/
|
||||
}
|
||||
else if (ch < 65536)
|
||||
{
|
||||
/*
|
||||
* Three-byte UTF-8...
|
||||
*/
|
||||
|
||||
*(*bufptr)++ = 0xe0 | (ch >> 12);
|
||||
*(*bufptr)++ = 0x80 | ((ch >> 6) & 0x3f);
|
||||
*(*bufptr)++ = 0x80 | (ch & 0x3f);
|
||||
} else {
|
||||
/*
|
||||
* Four-byte UTF-8...
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Four-byte UTF-8...
|
||||
*/
|
||||
|
||||
*(*bufptr)++ = 0xf0 | (ch >> 18);
|
||||
*(*bufptr)++ = 0x80 | ((ch >> 12) & 0x3f);
|
||||
@ -219,21 +229,27 @@ static int /* O - 0 on success, -1 on error */ myxml_add_char(int ch, /* I -
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
extern char *stptok(char *s, char *tok, size_t toklen, char *brk);
|
||||
/*=====================================================================
|
||||
actual stuff for implementing the callback functions
|
||||
=====================================================================*/
|
||||
void analyzeDim(const char *typeString, int *rank, int *iDim, int *type)
|
||||
{
|
||||
|
||||
/*
|
||||
* if passed NX_CHAR, then returns dimension of -1 and the caller
|
||||
* needs to do a strlen() or equivalent
|
||||
*/
|
||||
void analyzeDim(const char *typeString, int *rank,
|
||||
int64_t *iDim, int *type){
|
||||
char dimString[132];
|
||||
char dim[20];
|
||||
char *dimStart, *dimEnd;
|
||||
const char *dimStart, *dimEnd;
|
||||
char* dimTemp;
|
||||
int myRank;
|
||||
|
||||
if (strchr(typeString, (int) '[') == NULL) {
|
||||
switch (*type) {
|
||||
if(strchr(typeString,(int)'[') == NULL){
|
||||
*rank = 1;
|
||||
switch(*type){
|
||||
case NX_INT8:
|
||||
case NX_UINT8:
|
||||
case NX_INT16:
|
||||
@ -247,44 +263,45 @@ void analyzeDim(const char *typeString, int *rank, int *iDim, int *type)
|
||||
iDim[0] = 1;
|
||||
break;
|
||||
case NX_CHAR:
|
||||
iDim[0] = -1;
|
||||
iDim[0] = -1; /* length unknown, caller needs to determine later */
|
||||
break;
|
||||
default:
|
||||
mxml_error("ERROR: (analyzeDim) unknown type code %d for typeString %s", *type, typeString);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
we have to determine rank and the dims.
|
||||
Start by extracting the dimension string.
|
||||
*/
|
||||
dimStart = strchr(typeString, (int) '[') + 1;
|
||||
dimEnd = strchr(typeString, (int) ']');
|
||||
if (!dimStart || !dimEnd) {
|
||||
mxml_error("ERROR: malformed dimension string in %s", typeString);
|
||||
we have to determine rank and the dims.
|
||||
Start by extracting the dimension string.
|
||||
*/
|
||||
dimStart = strchr(typeString,(int)'[') + 1;
|
||||
dimEnd = strchr(typeString,(int)']');
|
||||
if(!dimStart || !dimEnd) {
|
||||
mxml_error("ERROR: malformed dimension string in %s",typeString);
|
||||
return;
|
||||
}
|
||||
if ((dimEnd - dimStart) > 131) {
|
||||
mxml_error("ERROR: run away dimension definition in %s", typeString);
|
||||
if((dimEnd - dimStart) > 131){
|
||||
mxml_error("ERROR: run away dimension definition in %s",typeString);
|
||||
return;
|
||||
}
|
||||
memset(dimString, 0, 132);
|
||||
memcpy(dimString, dimStart, (dimEnd - dimStart) * sizeof(char));
|
||||
dimStart = stptok(dimString, dim, 19, ",");
|
||||
memset(dimString,0,132);
|
||||
memcpy(dimString,dimStart,(dimEnd-dimStart)*sizeof(char));
|
||||
dimTemp = stptok(dimString,dim,19,",");
|
||||
myRank = 0;
|
||||
while (dimStart != NULL) {
|
||||
while(dimTemp != NULL){
|
||||
iDim[myRank] = atoi(dim);
|
||||
dimStart = stptok(dimStart, dim, 19, ",");
|
||||
dimTemp = stptok(dimTemp,dim,19,",");
|
||||
myRank++;
|
||||
}
|
||||
*rank = myRank;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
int translateTypeCode(char *code)
|
||||
{
|
||||
int translateTypeCode(const char *code){
|
||||
int i, result = -1;
|
||||
|
||||
for (i = 0; i < NTYPECODE; i++) {
|
||||
if (strstr(code, typecode[i].name) != NULL) {
|
||||
|
||||
for(i = 0; i < NTYPECODE; i++){
|
||||
if(strstr(code,typecode[i].name) != NULL){
|
||||
result = typecode[i].nx_type;
|
||||
break;
|
||||
}
|
||||
@ -292,68 +309,95 @@ int translateTypeCode(char *code)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
static void analyzeDataType(mxml_node_t * parent, int *rank, int *type,
|
||||
int *iDim)
|
||||
/*
|
||||
* This is used to locate an Idims node from the new style table data layout
|
||||
*/
|
||||
static mxml_node_t* findDimsNode(mxml_node_t *node)
|
||||
{
|
||||
mxml_node_t *tnode = NULL;
|
||||
const char* name = node->value.element.name;
|
||||
if ( (node->parent != NULL) && !strcmp(node->parent->value.element.name, DATA_NODE_NAME) )
|
||||
{
|
||||
tnode = mxmlFindElement(node->parent->parent, node->parent->parent, DIMS_NODE_NAME, NULL, NULL, MXML_DESCEND_FIRST);
|
||||
if (tnode != NULL)
|
||||
{
|
||||
tnode = mxmlFindElement(tnode,tnode,name,NULL,NULL,MXML_DESCEND_FIRST);
|
||||
}
|
||||
}
|
||||
return tnode;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/*return 1 if in table mode , 0 if not */
|
||||
static void analyzeDataType(mxml_node_t *parent, int *rank, int *type,
|
||||
int64_t *iDim){
|
||||
const char *typeString;
|
||||
mxml_type_t myType;
|
||||
int i, nx_type = -1;
|
||||
mxml_node_t* tnode;
|
||||
int nx_type = -1;
|
||||
int table_mode = 0;
|
||||
|
||||
*rank = 1;
|
||||
*type = NX_CHAR;
|
||||
iDim[0] = -1;
|
||||
|
||||
/*
|
||||
get the type attribute. No attribute means: plain text
|
||||
*/
|
||||
typeString = mxmlElementGetAttr(parent, TYPENAME);
|
||||
if (typeString == NULL) {
|
||||
get the type attribute. No attribute means: plain text
|
||||
*/
|
||||
tnode = findDimsNode(parent);
|
||||
if (tnode != NULL)
|
||||
{
|
||||
table_mode = 1;
|
||||
parent = tnode;
|
||||
}
|
||||
typeString = mxmlElementGetAttr(parent,TYPENAME);
|
||||
if(typeString == NULL){
|
||||
return;
|
||||
}
|
||||
|
||||
nx_type = translateTypeCode((char *) typeString);
|
||||
nx_type = translateTypeCode((char *)typeString);
|
||||
|
||||
/*
|
||||
assign type
|
||||
*/
|
||||
if (nx_type == -1) {
|
||||
mxml_error
|
||||
("ERROR: %s is an invalid NeXus type, I try to continue but may fail",
|
||||
typeString);
|
||||
*type = NX_CHAR;
|
||||
assign type
|
||||
*/
|
||||
if(nx_type == -1){
|
||||
mxml_error(
|
||||
"ERROR: %s is an invalid NeXus type, I try to continue but may fail",
|
||||
typeString);
|
||||
*type =NX_CHAR;
|
||||
return;
|
||||
}
|
||||
|
||||
*type = nx_type;
|
||||
|
||||
|
||||
analyzeDim(typeString, rank, iDim, type);
|
||||
if (table_mode)
|
||||
{
|
||||
*rank = 1;
|
||||
iDim[0] = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
void destroyDataset(void *data)
|
||||
{
|
||||
if (data != NULL) {
|
||||
dropNXDataset((pNXDS) data);
|
||||
void destroyDataset(void *data){
|
||||
if(data != NULL){
|
||||
dropNXDataset((pNXDS)data);
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
static char *getNextNumber(char *pStart, char pNumber[80])
|
||||
{
|
||||
static char *getNextNumber(char *pStart, char pNumber[80]){
|
||||
int charCount = 0;
|
||||
pNumber[0] = '\0';
|
||||
|
||||
/* advance to first digit */
|
||||
while (isspace(*pStart) && *pStart != '\0') {
|
||||
while(isspace(*pStart) && *pStart != '\0'){
|
||||
pStart++;
|
||||
}
|
||||
if (*pStart == '\0') {
|
||||
if(*pStart == '\0'){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* copy */
|
||||
while (!isspace(*pStart) && *pStart != '\0' && charCount < 78) {
|
||||
while(!isspace(*pStart) && *pStart != '\0' && charCount < 78){
|
||||
pNumber[charCount] = *pStart;
|
||||
pStart++;
|
||||
charCount++;
|
||||
@ -361,108 +405,111 @@ static char *getNextNumber(char *pStart, char pNumber[80])
|
||||
pNumber[charCount] = '\0';
|
||||
return pStart;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
mxml_type_t nexusTypeCallback(mxml_node_t * parent)
|
||||
{
|
||||
mxml_type_t nexusTypeCallback(mxml_node_t *parent){
|
||||
const char *typeString;
|
||||
|
||||
if (strstr(parent->value.element.name, "?xml") != NULL ||
|
||||
strstr(parent->value.element.name, "NX") != NULL) {
|
||||
if(strstr(parent->value.element.name,"?xml") != NULL ||
|
||||
!strncmp(parent->value.element.name,"NX",2) ||
|
||||
!strcmp(parent->value.element.name,DATA_NODE_NAME) ||
|
||||
!strcmp(parent->value.element.name,DIMS_NODE_NAME)){
|
||||
return MXML_ELEMENT;
|
||||
} else {
|
||||
typeString = mxmlElementGetAttr(parent, TYPENAME);
|
||||
if (typeString == NULL) {
|
||||
/* data nodes do not habe TYPENAME in table style but are always CUSTOM */
|
||||
if (parent->parent != NULL && !strcmp(parent->parent->value.element.name, DATA_NODE_NAME))
|
||||
{
|
||||
return MXML_CUSTOM;
|
||||
}
|
||||
if (parent->parent != NULL && !strcmp(parent->parent->value.element.name, DIMS_NODE_NAME))
|
||||
{
|
||||
return MXML_OPAQUE;
|
||||
}
|
||||
typeString = mxmlElementGetAttr(parent,TYPENAME);
|
||||
if(typeString == NULL){
|
||||
/*
|
||||
MXML_TEXT seems more appropriate here. But mxml hacks text into
|
||||
single words which is not what NeXus wants.
|
||||
*/
|
||||
MXML_TEXT seems more appropriate here. But mxml hacks text into
|
||||
single words which is not what NeXus wants.
|
||||
*/
|
||||
return MXML_OPAQUE;
|
||||
} else {
|
||||
if (strstr(typeString, "NX_CHAR") != NULL) {
|
||||
return MXML_OPAQUE;
|
||||
} else{
|
||||
if(strstr(typeString,"NX_CHAR") != NULL){
|
||||
return MXML_OPAQUE;
|
||||
} else {
|
||||
return MXML_CUSTOM;
|
||||
return MXML_CUSTOM;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
int nexusLoadCallback(mxml_node_t * node, const char *buffer)
|
||||
{
|
||||
int nexusLoadCallback(mxml_node_t *node, const char *buffer){
|
||||
mxml_node_t *parent = NULL;
|
||||
int rank, type, iDim[NX_MAXRANK];
|
||||
int rank, type;
|
||||
int64_t iDim[NX_MAXRANK];
|
||||
char pNumber[80], *pStart;
|
||||
long address, maxAddress;
|
||||
pNXDS dataset = NULL;
|
||||
int i;
|
||||
|
||||
parent = node->parent;
|
||||
analyzeDataType(parent, &rank, &type, iDim);
|
||||
if (iDim[0] == -1) {
|
||||
analyzeDataType(parent,&rank,&type,iDim);
|
||||
if(iDim[0] == -1 || !strcmp(parent->parent->value.element.name, DIMS_NODE_NAME)){
|
||||
iDim[0] = strlen(buffer);
|
||||
node->value.custom.data = strdup(buffer);
|
||||
node->value.custom.destroy = free;
|
||||
return 0;
|
||||
} else {
|
||||
node->value.custom.data = createNXDataset(rank, type, iDim);
|
||||
dataset = (pNXDS) node->value.custom.data;
|
||||
if (dataset == NULL) {
|
||||
node->value.custom.data = createNXDataset(rank,type,iDim);
|
||||
dataset = (pNXDS)node->value.custom.data;
|
||||
if(dataset == NULL){
|
||||
mxml_error("Failed to allocate custom dataset");
|
||||
return 1;
|
||||
}
|
||||
node->value.custom.destroy = destroyDataset;
|
||||
node->value.custom.destroy = destroyDataset;
|
||||
}
|
||||
|
||||
/*
|
||||
load data
|
||||
*/
|
||||
pStart = (char *) buffer;
|
||||
load data
|
||||
*/
|
||||
pStart = (char *)buffer;
|
||||
maxAddress = getNXDatasetLength(dataset);
|
||||
address = 0;
|
||||
while ((pStart = getNextNumber(pStart, pNumber)) != NULL &&
|
||||
address < maxAddress) {
|
||||
putNXDatasetValueAt(dataset, address, atof(pNumber));
|
||||
while( (pStart = getNextNumber(pStart,pNumber)) != NULL &&
|
||||
address < maxAddress){
|
||||
putNXDatasetValueAt(dataset,address,atof(pNumber));
|
||||
address++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
static void stringIntoBuffer(char **buffer, char **bufPtr, int *bufSize,
|
||||
char *string)
|
||||
{
|
||||
int i;
|
||||
static void stringIntoBuffer(char **buffer, char **bufPtr, size_t *bufSize,
|
||||
char *string){
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < strlen(string); i++) {
|
||||
myxml_add_char(string[i], bufPtr, buffer, bufSize);
|
||||
for(i = 0; i < strlen(string); i++){
|
||||
myxml_add_char(string[i],bufPtr,buffer,bufSize);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
static void formatNumber(double value, char *txt, int txtLen,
|
||||
char *format, int type)
|
||||
{
|
||||
switch (type) {
|
||||
char *format, int type){
|
||||
switch(type){
|
||||
case NX_INT8:
|
||||
case NX_UINT8:
|
||||
case NX_INT16:
|
||||
case NX_UINT16:
|
||||
case NX_INT32:
|
||||
case NX_UINT32:
|
||||
snprintf(txt, txtLen, format, (int) value);
|
||||
snprintf(txt,txtLen,format,(int)value);
|
||||
break;
|
||||
case NX_INT64:
|
||||
snprintf(txt, txtLen, format, (int64_t) value);
|
||||
snprintf(txt,txtLen,format,(int64_t)value);
|
||||
break;
|
||||
case NX_UINT64:
|
||||
snprintf(txt, txtLen, format, (uint64_t) value);
|
||||
snprintf(txt,txtLen,format,(uint64_t)value);
|
||||
break;
|
||||
case NX_FLOAT32:
|
||||
case NX_FLOAT64:
|
||||
snprintf(txt, txtLen, format, value);
|
||||
snprintf(txt,txtLen,format,value);
|
||||
break;
|
||||
default:
|
||||
/*assert(0); something is very wrong here */
|
||||
@ -470,205 +517,231 @@ static void formatNumber(double value, char *txt, int txtLen,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
static int countDepth(mxml_node_t * node)
|
||||
{
|
||||
static int countDepth(mxml_node_t *node){
|
||||
int count = 0;
|
||||
mxml_node_t *cur;
|
||||
|
||||
cur = node;
|
||||
while (cur != NULL) {
|
||||
while(cur != NULL){
|
||||
count++;
|
||||
cur = cur->parent;
|
||||
}
|
||||
count--;
|
||||
return count;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
char *nexusWriteCallback(mxml_node_t * node)
|
||||
{
|
||||
char *nexusWriteCallback(mxml_node_t *node){
|
||||
int type, col;
|
||||
char pNumber[80], indent[80], format[30];
|
||||
char *buffer, *bufPtr;
|
||||
pNXDS dataset;
|
||||
int bufsize, i, length, currentLen;
|
||||
int currentLen, table_style = 0;
|
||||
size_t i, bufsize, length;
|
||||
int is_definition = 0;
|
||||
/* this is set by nxconvert when making a definiton */
|
||||
is_definition = (getenv("NX_IS_DEFINITION") != NULL);
|
||||
|
||||
if (!strcmp(node->parent->parent->value.element.name, DATA_NODE_NAME))
|
||||
{
|
||||
table_style = 1;
|
||||
}
|
||||
/*
|
||||
allocate output buffer
|
||||
*/
|
||||
buffer = (char *) malloc(1024 * sizeof(char));
|
||||
if (buffer == NULL) {
|
||||
allocate output buffer
|
||||
*/
|
||||
buffer = (char *)malloc(1024*sizeof(char));
|
||||
if(buffer == NULL){
|
||||
mxml_error("Unable to allocate buffer");
|
||||
return NULL;
|
||||
}
|
||||
memset(buffer, 0, 1024);
|
||||
memset(buffer,0,1024);
|
||||
bufPtr = buffer;
|
||||
bufsize = 1024;
|
||||
|
||||
dataset = (pNXDS) node->value.custom.data;
|
||||
dataset = (pNXDS)node->value.custom.data;
|
||||
|
||||
/*
|
||||
prepare indentation level
|
||||
*/
|
||||
col = countDepth(node) * 2;
|
||||
memset(indent, 0, 80);
|
||||
for (i = 0; i < col; i++) {
|
||||
prepare indentation level
|
||||
*/
|
||||
col = countDepth(node)*2;
|
||||
memset(indent,0,80);
|
||||
for(i = 0; i < col; i++){
|
||||
indent[i] = ' ';
|
||||
}
|
||||
|
||||
/*
|
||||
get dataset info
|
||||
*/
|
||||
get dataset info
|
||||
*/
|
||||
type = getNXDatasetType(dataset);
|
||||
length = getNXDatasetLength(dataset);
|
||||
if (dataset->format != NULL) {
|
||||
strcpy(format, dataset->format);
|
||||
if (is_definition) {
|
||||
length = 1;
|
||||
} else {
|
||||
getNumberFormat(type, format);
|
||||
length = getNXDatasetLength(dataset);
|
||||
}
|
||||
if(dataset->format != NULL){
|
||||
strcpy(format,dataset->format);
|
||||
} else {
|
||||
getNumberFormat(type,format);
|
||||
}
|
||||
|
||||
/*
|
||||
actually get the data out
|
||||
*/
|
||||
currentLen = col;
|
||||
myxml_add_char('\n', &bufPtr, &buffer, &bufsize);
|
||||
stringIntoBuffer(&buffer, &bufPtr, &bufsize, indent);
|
||||
for (i = 0; i < length; i++) {
|
||||
formatNumber(getNXDatasetValueAt(dataset, i), pNumber, 79, format,
|
||||
type);
|
||||
if (currentLen + strlen(pNumber) > MXML_WRAP) {
|
||||
/*
|
||||
wrap line
|
||||
*/
|
||||
myxml_add_char('\n', &bufPtr, &buffer, &bufsize);
|
||||
stringIntoBuffer(&buffer, &bufPtr, &bufsize, indent);
|
||||
actually get the data out
|
||||
*/
|
||||
if (table_style)
|
||||
{
|
||||
for(i = 0; i < length; i++){
|
||||
formatNumber(getNXDatasetValueAt(dataset,i),pNumber,79,format,type);
|
||||
stringIntoBuffer(&buffer,&bufPtr,&bufsize,pNumber);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLen = col;
|
||||
}
|
||||
stringIntoBuffer(&buffer, &bufPtr, &bufsize, pNumber);
|
||||
myxml_add_char(' ', &bufPtr, &buffer, &bufsize);
|
||||
currentLen += strlen(pNumber) + 1;
|
||||
myxml_add_char('\n',&bufPtr,&buffer,&bufsize);
|
||||
stringIntoBuffer(&buffer,&bufPtr,&bufsize,indent);
|
||||
for(i = 0; i < length; i++){
|
||||
formatNumber(getNXDatasetValueAt(dataset,i),pNumber,79,format,type);
|
||||
if(currentLen + strlen(pNumber) > MXML_WRAP){
|
||||
/*
|
||||
wrap line
|
||||
*/
|
||||
myxml_add_char('\n',&bufPtr,&buffer,&bufsize);
|
||||
stringIntoBuffer(&buffer,&bufPtr,&bufsize,indent);
|
||||
currentLen = col;
|
||||
}
|
||||
stringIntoBuffer(&buffer,&bufPtr,&bufsize,pNumber);
|
||||
myxml_add_char(' ',&bufPtr,&buffer,&bufsize);
|
||||
currentLen += strlen(pNumber) + 1;
|
||||
}
|
||||
}
|
||||
myxml_add_char('\0', &bufPtr, &buffer, &bufsize);
|
||||
return (char *) buffer;
|
||||
myxml_add_char('\0',&bufPtr,&buffer,&bufsize);
|
||||
return (char *)buffer;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
int isDataNode(mxml_node_t * node)
|
||||
{
|
||||
if (mxmlElementGetAttr(node, "name") != NULL) {
|
||||
int isDataNode(mxml_node_t *node){
|
||||
if(mxmlElementGetAttr(node,"name") != NULL){
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(node->value.element.name, "NXroot") == 0) {
|
||||
if(strcmp(node->value.element.name,"NXroot") == 0){
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(node->value.element.name, "NAPIlink") == 0) {
|
||||
if(strcmp(node->value.element.name,DIMS_NODE_NAME) == 0){
|
||||
return 0;
|
||||
}
|
||||
if(strcmp(node->value.element.name,DATA_NODE_NAME) == 0){
|
||||
return 0;
|
||||
}
|
||||
if(strcmp(node->value.element.name,"NAPIlink") == 0){
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
static int isTextData(mxml_node_t * node)
|
||||
{
|
||||
static int isTextData(mxml_node_t *node){
|
||||
const char *attr = NULL;
|
||||
int rank, type = 0, iDim[NX_MAXRANK];
|
||||
|
||||
if (!isDataNode(node)) {
|
||||
if(!isDataNode(node)){
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
test datasets
|
||||
*/
|
||||
attr = mxmlElementGetAttr(node, TYPENAME);
|
||||
if (attr == NULL) {
|
||||
test datasets
|
||||
*/
|
||||
attr = mxmlElementGetAttr(node,TYPENAME);
|
||||
if(attr == NULL){
|
||||
return 1;
|
||||
}
|
||||
analyzeDim(attr, &rank, iDim, &type);
|
||||
if (type == NX_CHAR) {
|
||||
if(strstr(attr,"NX_CHAR") != NULL){
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* note: not reentrant or thead safe; returns pointer to static storage
|
||||
*/
|
||||
const char *NXwhitespaceCallback(mxml_node_t * node, int where)
|
||||
{
|
||||
const char *NXwhitespaceCallback(mxml_node_t *node, int where){
|
||||
static char *indent = NULL;
|
||||
int len;
|
||||
int len;
|
||||
|
||||
if (strstr(node->value.element.name, "?xml") != NULL) {
|
||||
if(strstr(node->value.element.name,"?xml") != NULL){
|
||||
return NULL;
|
||||
}
|
||||
if (node->parent != NULL && !strcmp(node->parent->value.element.name, DATA_NODE_NAME))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (where == MXML_WS_BEFORE_CLOSE && !strcmp(node->value.element.name, DATA_NODE_NAME))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (isTextData(node)) {
|
||||
if (where == MXML_WS_BEFORE_OPEN) {
|
||||
len = countDepth(node) * 2 + 2;
|
||||
if (indent != NULL) {
|
||||
free(indent);
|
||||
indent = NULL;
|
||||
if(isTextData(node)){
|
||||
if(where == MXML_WS_BEFORE_OPEN){
|
||||
len = countDepth(node)*2 + 2;
|
||||
if (indent != NULL)
|
||||
{
|
||||
free(indent);
|
||||
indent = NULL;
|
||||
}
|
||||
indent = (char *) malloc(len * sizeof(char));
|
||||
if (indent != NULL) {
|
||||
memset(indent, ' ', len);
|
||||
indent[0] = '\n';
|
||||
indent[len - 1] = '\0';
|
||||
return (const char *) indent;
|
||||
indent = (char *)malloc(len*sizeof(char));
|
||||
if(indent != NULL){
|
||||
memset(indent,' ',len);
|
||||
indent[0]= '\n';
|
||||
indent[len-1] = '\0';
|
||||
return (const char*)indent;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (where == MXML_WS_BEFORE_OPEN || where == MXML_WS_BEFORE_CLOSE) {
|
||||
len = countDepth(node) * 2 + 2;
|
||||
if (indent != NULL) {
|
||||
free(indent);
|
||||
indent = NULL;
|
||||
if(where == MXML_WS_BEFORE_OPEN || where == MXML_WS_BEFORE_CLOSE){
|
||||
len = countDepth(node)*2 + 2;
|
||||
if (indent != NULL)
|
||||
{
|
||||
free(indent);
|
||||
indent = NULL;
|
||||
}
|
||||
indent = (char *) malloc(len * sizeof(char));
|
||||
if (indent != NULL) {
|
||||
memset(indent, ' ', len);
|
||||
indent[0] = '\n';
|
||||
indent[len - 1] = '\0';
|
||||
return (const char *) indent;
|
||||
indent = (char *)malloc(len*sizeof(char));
|
||||
if(indent != NULL){
|
||||
memset(indent,' ',len);
|
||||
indent[0]= '\n';
|
||||
indent[len-1] = '\0';
|
||||
return (const char*)indent;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
#ifdef TESTMAIN
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
mxml_node_t *root = NULL;
|
||||
FILE *f;
|
||||
int main(int argc, char *argv[]){
|
||||
mxml_node_t *root = NULL;
|
||||
FILE *f;
|
||||
|
||||
mxmlSetCustomHandlers(nexusLoadCallback, nexusWriteCallback);
|
||||
initializeNumberFormats();
|
||||
mxmlSetCustomHandlers(nexusLoadCallback, nexusWriteCallback);
|
||||
initializeNumberFormats();
|
||||
|
||||
/*
|
||||
/*
|
||||
read test
|
||||
*/
|
||||
f = fopen("dmc.xml", "r");
|
||||
root = mxmlLoadFile(NULL, f, nexusTypeCallback);
|
||||
fclose(f);
|
||||
f = fopen("dmc.xml","r");
|
||||
root = mxmlLoadFile(NULL,f,nexusTypeCallback);
|
||||
fclose(f);
|
||||
|
||||
/*
|
||||
/*
|
||||
write test
|
||||
*/
|
||||
setNumberFormat(NX_INT32, "%8d");
|
||||
setNumberFormat(NX_FLOAT32, "%8.2f");
|
||||
f = fopen("dmc2.xml", "w");
|
||||
mxmlSaveFile(root, f, NXwhitespaceCallback);
|
||||
fclose(f);
|
||||
setNumberFormat(NX_INT32,"%8d");
|
||||
setNumberFormat(NX_FLOAT32,"%8.2f");
|
||||
f = fopen("dmc2.xml","w");
|
||||
mxmlSaveFile(root,f,NXwhitespaceCallback);
|
||||
fclose(f);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*NXXML*/
|
||||
|
20
nxio.h
20
nxio.h
@ -20,7 +20,7 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* For further information, see <http://www.neutron.anl.gov/NeXus/>
|
||||
* For further information, see <http://www.nexusformat.org>
|
||||
*/
|
||||
|
||||
#ifndef __NXIO
|
||||
@ -29,18 +29,22 @@
|
||||
|
||||
#define TYPENAME "NAPItype"
|
||||
|
||||
mxml_type_t nexusTypeCallback(mxml_node_t * parent);
|
||||
const char *NXwhitespaceCallback(mxml_node_t * node, int where);
|
||||
int nexusLoadCallback(mxml_node_t * node, const char *buffer);
|
||||
char *nexusWriteCallback(mxml_node_t * node);
|
||||
#define DIMS_NODE_NAME "columns"
|
||||
#define DATA_NODE_NAME "row"
|
||||
|
||||
mxml_type_t nexusTypeCallback(mxml_node_t *parent);
|
||||
const char *NXwhitespaceCallback(mxml_node_t *node, int where);
|
||||
int nexusLoadCallback(mxml_node_t *node, const char *buffer);
|
||||
char *nexusWriteCallback(mxml_node_t *node);
|
||||
|
||||
void setNumberFormat(int dataType, char *formatString);
|
||||
void initializeNumberFormats();
|
||||
void getNumberText(int nx_type, char *typestring, int typeLen);
|
||||
void destroyDataset(void *data);
|
||||
int translateTypeCode(char *code);
|
||||
int isDataNode(mxml_node_t * node);
|
||||
void analyzeDim(const char *typeString, int *rank, int *iDim, int *type);
|
||||
int translateTypeCode(const char *code);
|
||||
int isDataNode(mxml_node_t *node);
|
||||
void analyzeDim(const char *typeString, int *rank,
|
||||
int64_t *iDim, int *type);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -828,7 +828,7 @@ static void putHistogramMemoryChunked(SConnection * pCon,
|
||||
int status, start, length, i, noChunks, chunkDim[MAXDIM], rank;
|
||||
HistInt *iData = NULL;
|
||||
char buffer[256];
|
||||
int subset;
|
||||
int subset =0;
|
||||
|
||||
if (argc < 5) {
|
||||
SCWrite(pCon,
|
||||
|
113
nxstack.c
113
nxstack.c
@ -18,7 +18,10 @@
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information, see <http://www.neutron.anl.gov/NeXus/>
|
||||
For further information, see <http://www.nexusformat.org>
|
||||
|
||||
Added code to support the path stack for NXgetpath,
|
||||
Mark Koennecke, October 2009
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -33,88 +36,110 @@ typedef struct {
|
||||
pNexusFunction pDriver;
|
||||
NXlink closeID;
|
||||
char filename[1024];
|
||||
} fileStackEntry;
|
||||
}fileStackEntry;
|
||||
|
||||
|
||||
typedef struct __fileStack {
|
||||
int fileStackPointer;
|
||||
fileStackEntry fileStack[MAXEXTERNALDEPTH];
|
||||
} fileStack;
|
||||
int pathPointer;
|
||||
char pathStack[NXMAXSTACK][NX_MAXNAMELEN];
|
||||
}fileStack;
|
||||
/*---------------------------------------------------------------------*/
|
||||
pFileStack makeFileStack()
|
||||
{
|
||||
pFileStack makeFileStack(){
|
||||
pFileStack pNew = NULL;
|
||||
|
||||
pNew = malloc(sizeof(fileStack));
|
||||
if (pNew == NULL) {
|
||||
|
||||
pNew = (pFileStack)malloc(sizeof(fileStack));
|
||||
if(pNew == NULL){
|
||||
return NULL;
|
||||
}
|
||||
memset(pNew, 0, sizeof(fileStack));
|
||||
memset(pNew,0,sizeof(fileStack));
|
||||
pNew->fileStackPointer = -1;
|
||||
pNew->pathPointer = -1;
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
void killFileStack(pFileStack self)
|
||||
{
|
||||
if (self != NULL) {
|
||||
void killFileStack(pFileStack self){
|
||||
if(self != NULL){
|
||||
free(self);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
int getFileStackSize(){
|
||||
return sizeof(fileStack);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
void pushFileStack(pFileStack self, pNexusFunction pDriv, char *file)
|
||||
{
|
||||
int length;
|
||||
void pushFileStack(pFileStack self, pNexusFunction pDriv, char *file){
|
||||
size_t length;
|
||||
|
||||
self->fileStackPointer++;
|
||||
self->fileStack[self->fileStackPointer].pDriver = pDriv;
|
||||
memset(&self->fileStack[self->fileStackPointer].closeID, 0,
|
||||
sizeof(NXlink));
|
||||
memset(&self->fileStack[self->fileStackPointer].closeID,0,sizeof(NXlink));
|
||||
length = strlen(file);
|
||||
if (length >= 1024) {
|
||||
if(length >= 1024){
|
||||
length = 1023;
|
||||
}
|
||||
memcpy(&self->fileStack[self->fileStackPointer].filename, file, length);
|
||||
memcpy(&self->fileStack[self->fileStackPointer].filename,file,length);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void popFileStack(pFileStack self)
|
||||
{
|
||||
void popFileStack(pFileStack self){
|
||||
self->fileStackPointer--;
|
||||
if (self->fileStackPointer < -1) {
|
||||
if(self->fileStackPointer < -1){
|
||||
self->fileStackPointer = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
pNexusFunction peekFileOnStack(pFileStack self)
|
||||
{
|
||||
pNexusFunction peekFileOnStack(pFileStack self){
|
||||
return self->fileStack[self->fileStackPointer].pDriver;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
char *peekFilenameOnStack(pFileStack self)
|
||||
{
|
||||
char *peekFilenameOnStack(pFileStack self){
|
||||
return self->fileStack[self->fileStackPointer].filename;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void peekIDOnStack(pFileStack self, NXlink * id)
|
||||
{
|
||||
memcpy(id, &self->fileStack[self->fileStackPointer].closeID,
|
||||
sizeof(NXlink));
|
||||
void peekIDOnStack(pFileStack self, NXlink *id){
|
||||
memcpy(id, &self->fileStack[self->fileStackPointer].closeID, sizeof(NXlink));
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
void setCloseID(pFileStack self, NXlink id)
|
||||
{
|
||||
memcpy(&self->fileStack[self->fileStackPointer].closeID, &id,
|
||||
sizeof(NXlink));
|
||||
void setCloseID(pFileStack self, NXlink id){
|
||||
memcpy(&self->fileStack[self->fileStackPointer].closeID, &id, sizeof(NXlink));
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
int fileStackDepth(pFileStack self)
|
||||
{
|
||||
int fileStackDepth(pFileStack self){
|
||||
return self->fileStackPointer;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
void pushPath(pFileStack self, const char *name){
|
||||
self->pathPointer++;
|
||||
strncpy(self->pathStack[self->pathPointer],name,NX_MAXNAMELEN-1);
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void popPath(pFileStack self){
|
||||
self->pathPointer--;
|
||||
if(self->pathPointer < -1){
|
||||
self->pathPointer = -1;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
int buildPath(pFileStack self, char *path, int pathlen){
|
||||
int i;
|
||||
size_t totalPathLength;
|
||||
char *totalPath;
|
||||
|
||||
for(i = 0, totalPathLength = 5; i <= self->pathPointer; i++){
|
||||
totalPathLength += strlen(self->pathStack[i]) + 1;
|
||||
}
|
||||
totalPath = (char*)malloc(totalPathLength*sizeof(char));
|
||||
if(totalPath == NULL){
|
||||
return 0;
|
||||
}
|
||||
memset(totalPath,0,totalPathLength*sizeof(char));
|
||||
for(i = 0; i <= self->pathPointer; i++){
|
||||
strcat(totalPath,"/");
|
||||
strcat(totalPath,self->pathStack[i]);
|
||||
}
|
||||
|
||||
strncpy(path,totalPath,pathlen-1);
|
||||
free(totalPath);
|
||||
return 1;
|
||||
}
|
||||
|
16
nxstack.h
16
nxstack.h
@ -18,7 +18,11 @@
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information, see <http://www.neutron.anl.gov/NeXus/>
|
||||
For further information, see <http://www.nexusformat.org>
|
||||
|
||||
Added functions to deal with the path stack for NXgetpath
|
||||
Mark Koennecke, October 2009
|
||||
|
||||
*/
|
||||
#ifndef NEXUSFILESTACK
|
||||
#define NEXUSFILESTACK
|
||||
@ -28,15 +32,21 @@ typedef struct __fileStack *pFileStack;
|
||||
|
||||
pFileStack makeFileStack();
|
||||
void killFileStack(pFileStack self);
|
||||
int getFileStackSize();
|
||||
|
||||
void pushFileStack(pFileStack self, pNexusFunction pDriv, char *filename);
|
||||
void popFileStack(pFileStack self);
|
||||
|
||||
pNexusFunction peekFileOnStack(pFileStack self);
|
||||
char *peekFilenameOnStack(pFileStack self);
|
||||
void peekIDOnStack(pFileStack self, NXlink * id);
|
||||
void peekIDOnStack(pFileStack self, NXlink *id);
|
||||
void setCloseID(pFileStack self, NXlink id);
|
||||
|
||||
|
||||
int fileStackDepth(pFileStack self);
|
||||
|
||||
void pushPath(pFileStack self, const char *name);
|
||||
void popPath(pFileStack self);
|
||||
int buildPath(pFileStack self, char *path, int pathlen);
|
||||
|
||||
#endif
|
||||
|
||||
|
90
nxxml.h
90
nxxml.h
@ -17,56 +17,62 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* For further information, see <http://www.neutron.anl.gov/NeXus/>
|
||||
* For further information, see <http://www.nexusformat.org>
|
||||
*/
|
||||
#ifndef NEXUSXML
|
||||
#define NEXUSXML
|
||||
|
||||
extern NXstatus NXXopen(CONSTCHAR * filename,
|
||||
NXaccess access_method, NXhandle * pHandle);
|
||||
extern NXstatus NXXclose(NXhandle * pHandle);
|
||||
extern NXstatus NXXflush(NXhandle * pHandle);
|
||||
extern NXstatus NXXopen(CONSTCHAR *filename,
|
||||
NXaccess access_method,
|
||||
NXhandle* pHandle);
|
||||
extern NXstatus NXXclose(NXhandle* pHandle);
|
||||
extern NXstatus NXXflush(NXhandle* pHandle);
|
||||
|
||||
NXstatus NXXmakegroup(NXhandle fid, CONSTCHAR * name, CONSTCHAR * nxclass);
|
||||
NXstatus NXXopengroup(NXhandle fid, CONSTCHAR * name, CONSTCHAR * nxclass);
|
||||
NXstatus NXXclosegroup(NXhandle fid);
|
||||
NXstatus NXXmakegroup (NXhandle fid, CONSTCHAR *name,
|
||||
CONSTCHAR *nxclass);
|
||||
NXstatus NXXopengroup (NXhandle fid, CONSTCHAR *name,
|
||||
CONSTCHAR *nxclass);
|
||||
NXstatus NXXclosegroup (NXhandle fid);
|
||||
|
||||
NXstatus NXXcompmakedata(NXhandle fid, CONSTCHAR * name,
|
||||
int datatype,
|
||||
int rank,
|
||||
int dimensions[],
|
||||
int compress_type, int chunk_size[]);
|
||||
NXstatus NXXmakedata(NXhandle fid,
|
||||
CONSTCHAR * name, int datatype,
|
||||
int rank, int dimensions[]);
|
||||
NXstatus NXXopendata(NXhandle fid, CONSTCHAR * name);
|
||||
NXstatus NXXclosedata(NXhandle fid);
|
||||
NXstatus NXXputdata(NXhandle fid, void *data);
|
||||
NXstatus NXXgetdata(NXhandle fid, void *data);
|
||||
NXstatus NXXgetinfo(NXhandle fid, int *rank, int dimension[], int *iType);
|
||||
NXstatus NXXputslab(NXhandle fid, void *data, int iStart[], int iSize[]);
|
||||
NXstatus NXXgetslab(NXhandle fid, void *data, int iStart[], int iSize[]);
|
||||
NXstatus NXXputattr(NXhandle fid, CONSTCHAR * name, void *data,
|
||||
int datalen, int iType);
|
||||
NXstatus NXXgetattr(NXhandle fid, char *name,
|
||||
void *data, int *datalen, int *iType);
|
||||
NXstatus NXXcompmakedata64 (NXhandle fid, CONSTCHAR *name,
|
||||
int datatype,
|
||||
int rank,
|
||||
int64_t dimensions[],
|
||||
int compress_type, int64_t chunk_size[]);
|
||||
NXstatus NXXmakedata64 (NXhandle fid,
|
||||
CONSTCHAR *name, int datatype,
|
||||
int rank, int64_t dimensions[]);
|
||||
NXstatus NXXopendata (NXhandle fid, CONSTCHAR *name);
|
||||
NXstatus NXXclosedata (NXhandle fid);
|
||||
NXstatus NXXputdata (NXhandle fid, void *data);
|
||||
NXstatus NXXgetdata (NXhandle fid, void *data);
|
||||
NXstatus NXXgetinfo64 (NXhandle fid, int *rank,
|
||||
int64_t dimension[], int *iType);
|
||||
NXstatus NXXputslab64 (NXhandle fid, void *data,
|
||||
int64_t iStart[], int64_t iSize[]);
|
||||
NXstatus NXXgetslab64 (NXhandle fid, void *data,
|
||||
const int64_t iStart[], const int64_t iSize[]);
|
||||
NXstatus NXXputattr (NXhandle fid, CONSTCHAR *name, void *data,
|
||||
int datalen, int iType);
|
||||
NXstatus NXXgetattr (NXhandle fid, char *name,
|
||||
void *data, int* datalen, int* iType);
|
||||
|
||||
NXstatus NXXgetnextentry(NXhandle fid, NXname name,
|
||||
NXname nxclass, int *datatype);
|
||||
extern NXstatus NXXgetnextattr(NXhandle handle,
|
||||
NXname pName, int *iLength, int *iType);
|
||||
extern NXstatus NXXinitgroupdir(NXhandle handle);
|
||||
extern NXstatus NXXinitattrdir(NXhandle handle);
|
||||
extern NXstatus NXXgetattrinfo(NXhandle fid, int *iN);
|
||||
extern NXstatus NXXgetgroupinfo(NXhandle fid, int *iN,
|
||||
NXname pName, NXname pClass);
|
||||
NXstatus NXXgetnextentry (NXhandle fid,NXname name,
|
||||
NXname nxclass, int *datatype);
|
||||
extern NXstatus NXXgetnextattr(NXhandle handle,
|
||||
NXname pName, int *iLength, int *iType);
|
||||
extern NXstatus NXXinitgroupdir(NXhandle handle);
|
||||
extern NXstatus NXXinitattrdir(NXhandle handle);
|
||||
extern NXstatus NXXgetattrinfo (NXhandle fid, int *iN);
|
||||
extern NXstatus NXXgetgroupinfo (NXhandle fid, int *iN,
|
||||
NXname pName, NXname pClass);
|
||||
|
||||
extern NXstatus NXXgetdataID(NXhandle fid, NXlink * sRes);
|
||||
extern NXstatus NXXgetgroupID(NXhandle fid, NXlink * sRes);
|
||||
extern NXstatus NXXmakelink(NXhandle fid, NXlink * sLink);
|
||||
extern NXstatus NXXprintlink(NXhandle fid, NXlink * sLink);
|
||||
extern NXstatus NXXsameID(NXhandle fileid,
|
||||
NXlink * pFirstID, NXlink * pSecondID);
|
||||
extern NXstatus NXXgetdataID (NXhandle fid, NXlink* sRes);
|
||||
extern NXstatus NXXgetgroupID (NXhandle fid, NXlink* sRes);
|
||||
extern NXstatus NXXmakelink (NXhandle fid, NXlink* sLink);
|
||||
extern NXstatus NXXprintlink (NXhandle fid, NXlink* sLink);
|
||||
extern NXstatus NXXsameID (NXhandle fileid,
|
||||
NXlink* pFirstID, NXlink* pSecondID);
|
||||
|
||||
void NXXassignFunctions(pNexusFunction fHandle);
|
||||
#endif
|
||||
|
@ -715,7 +715,7 @@ int SCWriteJSON_String(SConnection * pCon, char *pBuffer, int iOut)
|
||||
/* print it to client if error message */
|
||||
if ((iOut == eError) || (iOut == eWarning)) {
|
||||
tmp_json = json_object_new_string(pBuffer);
|
||||
iRet = SCDoSockWrite(pCon, json_object_to_json_string(tmp_json));
|
||||
iRet = SCDoSockWrite(pCon, (char *)json_object_to_json_string(tmp_json));
|
||||
}
|
||||
} else {
|
||||
if ((my_object = mkJSON_Object(pCon, pBuffer, iOut)) == NULL) {
|
||||
@ -724,10 +724,10 @@ int SCWriteJSON_String(SConnection * pCon, char *pBuffer, int iOut)
|
||||
tmp_json = json_object_new_string(errBuff);
|
||||
my_object = json_object_new_object();
|
||||
json_object_object_add(my_object, "ERROR", tmp_json);
|
||||
SCDoSockWrite(pCon, json_object_to_json_string(my_object));
|
||||
SCDoSockWrite(pCon, (char *)json_object_to_json_string(my_object));
|
||||
iRet = 0;
|
||||
} else {
|
||||
iRet = SCDoSockWrite(pCon, json_object_to_json_string(my_object));
|
||||
iRet = SCDoSockWrite(pCon, (char *)json_object_to_json_string(my_object));
|
||||
}
|
||||
}
|
||||
if (tmp_json != NULL && !is_error(tmp_json))
|
||||
|
23
reflist.c
23
reflist.c
@ -240,6 +240,10 @@ static void AddRowIntern(pSICSOBJ refl, double hkl[], double ang[],
|
||||
if(child != NULL){
|
||||
UpdateHipadabaPar(child, MakeHdbFloat(ang[3]),NULL);
|
||||
}
|
||||
child = child->next;
|
||||
if(child != NULL){
|
||||
UpdateHipadabaPar(child, MakeHdbFloat(ang[4]),NULL);
|
||||
}
|
||||
runObjFunction(refl, pCon, node);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
@ -253,7 +257,7 @@ static int AddAnglesCmd(pSICSOBJ self, SConnection * pCon,
|
||||
pHdb commandNode, pHdb par[], int nPar)
|
||||
{
|
||||
int i;
|
||||
double hkl[3], ang[4];
|
||||
double hkl[3], ang[5];
|
||||
|
||||
memset(hkl,0,3*sizeof(double));
|
||||
memset(ang,0,4*sizeof(double));
|
||||
@ -314,6 +318,12 @@ static int AddIndexesAnglesCmd(pSICSOBJ self, SConnection * pCon,
|
||||
} else if(node!= NULL) {
|
||||
UpdateHipadabaPar(node, v, pCon);
|
||||
}
|
||||
node = node->next;
|
||||
if(node != NULL && nPar > 7){
|
||||
UpdateHipadabaPar(node, par[7]->value, pCon);
|
||||
} else if(node!= NULL) {
|
||||
UpdateHipadabaPar(node, v, pCon);
|
||||
}
|
||||
|
||||
return runObjFunction(self, pCon, addrowNode);
|
||||
}
|
||||
@ -427,7 +437,7 @@ static int SetAnglesCmd(pSICSOBJ self, SConnection * pCon,
|
||||
|
||||
/* do angles */
|
||||
v = MakeHdbFloat(.0);
|
||||
for(i = 0; i < 4 && child != NULL; i++, child = child->next){
|
||||
for(i = 0; i < 5 && child != NULL; i++, child = child->next){
|
||||
if(child != NULL){
|
||||
UpdateHipadabaPar(child, par[i+1]->value, pCon);
|
||||
}
|
||||
@ -497,6 +507,7 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics,
|
||||
AddSICSHdbPar(cmd, "om", usUser, MakeHdbFloat(.0));
|
||||
AddSICSHdbPar(cmd, "chi", usUser, MakeHdbFloat(.0));
|
||||
AddSICSHdbPar(cmd, "phi", usUser, MakeHdbFloat(.0));
|
||||
AddSICSHdbPar(cmd, "nu", usUser, MakeHdbFloat(.0));
|
||||
|
||||
cmd =
|
||||
AddSICSHdbPar(pNew->objectNode, "seta", usUser,
|
||||
@ -508,6 +519,7 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics,
|
||||
AddSICSHdbPar(cmd, "om", usUser, MakeHdbFloat(.0));
|
||||
AddSICSHdbPar(cmd, "chi", usUser, MakeHdbFloat(.0));
|
||||
AddSICSHdbPar(cmd, "phi", usUser, MakeHdbFloat(.0));
|
||||
AddSICSHdbPar(cmd, "nu", usUser, MakeHdbFloat(.0));
|
||||
|
||||
|
||||
cmd = AddSICSHdbPar(pNew->objectNode, "addax", usUser,
|
||||
@ -521,6 +533,7 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics,
|
||||
AddSICSHdbPar(cmd, "om", usUser, MakeHdbFloat(.0));
|
||||
AddSICSHdbPar(cmd, "chi", usUser, MakeHdbFloat(.0));
|
||||
AddSICSHdbPar(cmd, "phi", usUser, MakeHdbFloat(.0));
|
||||
AddSICSHdbPar(cmd, "nu", usUser, MakeHdbFloat(.0));
|
||||
|
||||
|
||||
cmd = AddSICSHdbPar(pNew->objectNode, "show", usUser,
|
||||
@ -620,7 +633,7 @@ int SetRefAngles(pSICSOBJ refl, int idx, double ang[])
|
||||
/* skip over hkl */
|
||||
for(i = 0; i < 3; i++, child = child->next){}
|
||||
/* set angles */
|
||||
for(i = 0; i < 4; i++, child = child->next){
|
||||
for(i = 0; i < 5; i++, child = child->next){
|
||||
if(child != NULL){
|
||||
UpdateHipadabaPar(child, MakeHdbFloat(ang[i]), NULL);
|
||||
}
|
||||
@ -681,7 +694,7 @@ int GetRefAngles(pSICSOBJ refl, int idx, double ang[])
|
||||
/* skip hkl */
|
||||
for(i = 0; i < 3; i++, child = child->next){}
|
||||
/* do angles */
|
||||
for(i = 0; i < 4 && child != NULL; i++, child = child->next){
|
||||
for(i = 0; i < 5 && child != NULL; i++, child = child->next){
|
||||
ang[i] = child->value.v.doubleValue;
|
||||
}
|
||||
return 1;
|
||||
@ -704,7 +717,7 @@ int GetRefAnglesID(pSICSOBJ refl, char *id, double ang[])
|
||||
/* skip hkl */
|
||||
for(i = 0; i < 3; i++, child = child->next){}
|
||||
/* do angles */
|
||||
for(i = 0; i < 4 && child != NULL; i++, child = child->next){
|
||||
for(i = 0; i < 5 && child != NULL; i++, child = child->next){
|
||||
ang[i] = child->value.v.doubleValue;
|
||||
}
|
||||
return 1;
|
||||
|
@ -430,7 +430,7 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
* Sometimes one wishes to call multiple scripts in succession
|
||||
* before returning into I/O. Such scripts then do not set the
|
||||
* send property. The loop is taking care of this. Not more
|
||||
* then 10 scripts can be changed in this way.
|
||||
* then 10 scripts can be chained in this way.
|
||||
*/
|
||||
for (i = 0; i < 10; i++) {
|
||||
/*
|
||||
|
@ -454,11 +454,17 @@ int formatNameValue(Protocol protocol, char *name, char *value,
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int sendZippedNodeData(pHdb node, hdbValue newValue, SConnection * pCon)
|
||||
{
|
||||
int i, *iData = NULL;
|
||||
int i, *iData = NULL, zip = 1;
|
||||
char *path = NULL;
|
||||
double sum = 0;
|
||||
char value[80];
|
||||
|
||||
path = GetHipadabaPath(node);
|
||||
if (GetHdbProperty(node, "transfer", value, 80) == 1) {
|
||||
if(strstr(value,"bin") != NULL) {
|
||||
zip = 0;
|
||||
}
|
||||
}
|
||||
switch (newValue.dataType) {
|
||||
case HIPINTAR:
|
||||
case HIPINTVARAR:
|
||||
@ -474,10 +480,14 @@ static int sendZippedNodeData(pHdb node, hdbValue newValue, SConnection * pCon)
|
||||
}
|
||||
memset(iData, 0, newValue.arrayLength * sizeof(int));
|
||||
for (i = 0; i < newValue.arrayLength; i++) {
|
||||
sum += (double)newValue.v.intArray[i];
|
||||
/* sum += (double)newValue.v.intArray[i]; */
|
||||
iData[i] = htonl(newValue.v.intArray[i]);
|
||||
}
|
||||
SCWriteZipped(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
||||
if(zip == 1){
|
||||
SCWriteZipped(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
||||
} else {
|
||||
SCWriteBinary(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
||||
}
|
||||
free(iData);
|
||||
/* printf("Wrote zipped data %s, sum %lf\n", path, sum); */
|
||||
break;
|
||||
@ -498,8 +508,12 @@ static int sendZippedNodeData(pHdb node, hdbValue newValue, SConnection * pCon)
|
||||
sum+= newValue.v.floatArray[i];
|
||||
iData[i] = htonl((int) (newValue.v.floatArray[i] * 65536.));
|
||||
}
|
||||
SCWriteZipped(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
||||
if(zip == 1) {
|
||||
SCWriteZipped(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
||||
/* printf("Wrote zipped data %s, sum %lf\n", path, sum); */
|
||||
} else {
|
||||
SCWriteBinary(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
||||
}
|
||||
free(iData);
|
||||
break;
|
||||
default:
|
||||
@ -600,7 +614,7 @@ static hdbCallbackReturn SICSNotifyCallback(pHdb node, void *userData,
|
||||
* if transfer = zip always transfer data in zipped form
|
||||
*/
|
||||
if (GetHdbProperty(node, "transfer", value, 80) == 1) {
|
||||
if (strstr(value, "zip") != NULL) {
|
||||
if (strstr(value, "zip") != NULL || strstr(value,"bin") != NULL) {
|
||||
status = sendZippedNodeData(node, *(mm->v), cbInfo->pCon);
|
||||
free(pPath);
|
||||
DeleteDynString(result);
|
||||
@ -672,9 +686,9 @@ static hdbCallbackReturn TreeChangeCallback(pHdb node, void *userData,
|
||||
char buffer[1024];
|
||||
pDynString result = NULL;
|
||||
Protocol protocol = normal_protocol;
|
||||
int outCode;
|
||||
pHdbIDMessage idm = NULL;
|
||||
pHdbPtrMessage cmm = NULL;
|
||||
int outCode;
|
||||
pHdbTreeChangeMessage tm = NULL;
|
||||
SConnection *tstCon = NULL;
|
||||
|
||||
@ -714,7 +728,7 @@ static hdbCallbackReturn TreeChangeCallback(pHdb node, void *userData,
|
||||
result = CreateDynString(128, 128);
|
||||
if (result == NULL) {
|
||||
SCWrite(cbInfo->pCon, "ERROR: out of memory in TreeChangeCallback",
|
||||
outCode);
|
||||
eError);
|
||||
return hdbAbort;
|
||||
}
|
||||
path = GetHipadabaPath(node);
|
||||
@ -2908,7 +2922,7 @@ static int AutoNotifyHdbNode(SConnection * pCon, SicsInterp * pSics,
|
||||
void *pData, int argc, char *argv[])
|
||||
{
|
||||
pHdb node = NULL;
|
||||
int id, status;
|
||||
int id, status, recurse = 1;
|
||||
|
||||
if (argc < 3) {
|
||||
SCWrite(pCon, "ERROR: need path and id in order to add notify",
|
||||
@ -2923,7 +2937,11 @@ static int AutoNotifyHdbNode(SConnection * pCon, SicsInterp * pSics,
|
||||
|
||||
id = atoi(argv[2]);
|
||||
|
||||
status = InstallSICSNotify(node, pCon, id, 1);
|
||||
if(argc > 3) {
|
||||
recurse = atoi(argv[3]);
|
||||
}
|
||||
|
||||
status = InstallSICSNotify(node, pCon, id, recurse);
|
||||
if (status == 1) {
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
|
33
simidx.c
33
simidx.c
@ -617,39 +617,6 @@ static int findSolutionsForTriplet(int triplet[3], int testRight)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------
|
||||
* If the system is right handed the determinat of the
|
||||
* matrix having the indices as columns must be positive.
|
||||
* As I have only two vectors, I simulate the third by
|
||||
* using the nromal on the other two.
|
||||
-------------------------------------------------------------*/
|
||||
static int testDuoRightHandedness(int r1, int r1idx, int r2, int r2idx)
|
||||
{
|
||||
MATRIX T;
|
||||
double vol;
|
||||
int r3, r3idx;
|
||||
|
||||
T = mat_creat(3, 3, ZERO_MATRIX);
|
||||
if (T == NULL) {
|
||||
return 0;
|
||||
}
|
||||
T[0][0] = reflections[r1].indices[r1idx].h;
|
||||
T[1][0] = reflections[r1].indices[r1idx].k;
|
||||
T[2][0] = reflections[r1].indices[r1idx].l;
|
||||
T[0][1] = reflections[r2].indices[r2idx].h;
|
||||
T[1][1] = reflections[r2].indices[r2idx].k;
|
||||
T[2][1] = reflections[r2].indices[r2idx].l;
|
||||
T[0][2] = reflections[r3].indices[r3idx].h;
|
||||
T[1][2] = reflections[r3].indices[r3idx].k;
|
||||
T[2][2] = reflections[r3].indices[r3idx].l;
|
||||
vol = mat_det(T);
|
||||
mat_free(T);
|
||||
if (vol > .0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
static int findSolutionsForDuett(int triplet[3])
|
||||
|
@ -112,7 +112,7 @@ static int RunIndexCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
int i, j, status, err;
|
||||
pSingleDiff diffi;
|
||||
pSICSOBJ reflist;
|
||||
double ang[4], z1[3];
|
||||
double ang[5], z1[3];
|
||||
IndexSolution is;
|
||||
MATRIX ub;
|
||||
pHdb nSol = NULL;
|
||||
@ -265,7 +265,7 @@ static int IndexCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
pHdb par[], int nPar)
|
||||
{
|
||||
int i, j;
|
||||
double ang[4], hkl[3];
|
||||
double ang[5], hkl[3];
|
||||
const double *ub;
|
||||
pSICSOBJ reflist = NULL;
|
||||
pSingleDiff diffi = NULL;
|
||||
|
@ -40,7 +40,7 @@ static int checkTheta(pSingleDiff self, double *stt)
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int checkNormalBeam(double om, double *gamma, double nu,
|
||||
int checkNormalBeam(double om, double *gamma, double nu,
|
||||
double fSet[4], pSingleDiff self)
|
||||
{
|
||||
int iTest;
|
||||
|
15
singlex.c
15
singlex.c
@ -25,6 +25,7 @@
|
||||
#include "singelbi.h"
|
||||
#include "singlenb.h"
|
||||
#include "singletas.h"
|
||||
#include "singlebinb.h"
|
||||
#include "lld.h"
|
||||
#include "fourlib.h"
|
||||
|
||||
@ -225,6 +226,7 @@ static int findModeIndex(char *mode)
|
||||
"bi",
|
||||
"nb",
|
||||
"tas",
|
||||
"binb",
|
||||
NULL
|
||||
};
|
||||
int count = 0;
|
||||
@ -292,6 +294,19 @@ static hdbCallbackReturn SetModeCB(pHdb node, void *userData,
|
||||
priv->mode = Tas;
|
||||
initializeSingleTas(priv->diffractometer);
|
||||
return hdbContinue;
|
||||
case BiNB:
|
||||
if (priv->stt == NULL || priv->nu == NULL || priv->om == NULL
|
||||
|| priv->chi == NULL || priv->phi == NULL) {
|
||||
if (pCon != NULL) {
|
||||
SCWrite(pCon, "ERROR: required motor for BINB not configured",
|
||||
eError);
|
||||
}
|
||||
return hdbAbort;
|
||||
}
|
||||
priv->mode = BiNB;
|
||||
initializeSingleBINB(priv->diffractometer);
|
||||
return hdbContinue;
|
||||
|
||||
default:
|
||||
if (set->callData != NULL) {
|
||||
pCon = set->callData;
|
||||
|
@ -35,7 +35,7 @@ double SXGetLambda();
|
||||
pSICSOBJ SXGetReflectionList();
|
||||
|
||||
typedef enum {
|
||||
Bisecting, NB, Tas
|
||||
Bisecting, NB, Tas, BiNB,
|
||||
} SingleXModes;
|
||||
|
||||
SingleXModes SXGetMode();
|
||||
|
@ -9,5 +9,5 @@
|
||||
|
||||
MFLAGS=-f makefile_linux$(DUMMY)
|
||||
|
||||
HDFROOT=/afs/psi.ch/project/sinq/sl5
|
||||
HDFROOT=/afs/psi.ch/project/sinq/sl6
|
||||
TCLINC=.
|
29
stdscan.c
29
stdscan.c
@ -558,16 +558,27 @@ int prepareDataFile(pScanData self)
|
||||
{
|
||||
char *pPtr = NULL;
|
||||
char pBueffel[512];
|
||||
Tcl_Interp *pTcl;
|
||||
const char *val = NULL;
|
||||
|
||||
/* allocate a new data file */
|
||||
pPtr = ScanMakeFileName(pServ->pSics, self->pCon);
|
||||
if (!pPtr) {
|
||||
SCWrite(self->pCon,
|
||||
"ERROR: cannot allocate new data filename, Scan aborted",
|
||||
eLogError);
|
||||
self->pCon = NULL;
|
||||
self->pSics = NULL;
|
||||
return 0;
|
||||
pTcl = InterpGetTcl(pServ->pSics);
|
||||
val = Tcl_GetVar(pTcl,"simMode",TCL_GLOBAL_ONLY);
|
||||
if(val != NULL){
|
||||
if(strstr(val,"2") != NULL){
|
||||
pPtr = strdup("sicssim.scn");
|
||||
}
|
||||
} else {
|
||||
|
||||
/* allocate a new data file */
|
||||
pPtr = ScanMakeFileName(pServ->pSics, self->pCon);
|
||||
if (!pPtr) {
|
||||
SCWrite(self->pCon,
|
||||
"ERROR: cannot allocate new data filename, Scan aborted",
|
||||
eLogError);
|
||||
self->pCon = NULL;
|
||||
self->pSics = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
snprintf(pBueffel, 511, "Writing data file: %s ...", pPtr);
|
||||
SCWrite(self->pCon, pBueffel, eLog);
|
||||
|
@ -563,6 +563,8 @@ static int checkMotors(ptasMot self, SConnection * pCon)
|
||||
if(status == HWIdle || status == OKOK || status == HWFault || status == HWPosFault){
|
||||
busy[i] = 0;
|
||||
}
|
||||
} else {
|
||||
busy[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
332
|
||||
340
|
||||
NEVER, EVER modify or delete this file
|
||||
You'll risk eternal damnation and a reincarnation as a cockroach!
|
||||
|
4
trace.c
4
trace.c
@ -192,7 +192,9 @@ void traceprint(char *sub, char *id, char *data)
|
||||
{
|
||||
if(log != NULL && filter(sub,id)){
|
||||
strrepc(data,'\n',':');
|
||||
fprintf(log,"%s:%s:%lf:%s\n", sub,id,DoubleTime(),data);
|
||||
strrepc(sub,':','@');
|
||||
strrepc(id,':','@');
|
||||
fprintf(log,"%s:%s:%lf:%s\n",sub,id,DoubleTime(),data);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------*/
|
||||
|
Reference in New Issue
Block a user