- 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/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <strlutil.h>
|
#include <strlutil.h>
|
||||||
@ -43,7 +44,8 @@
|
|||||||
#define DATASOCKET 1
|
#define DATASOCKET 1
|
||||||
#define MAXCONNECTIONS 1024
|
#define MAXCONNECTIONS 1024
|
||||||
#define RBUFFERSIZE 262144 /* 256kb */
|
#define RBUFFERSIZE 262144 /* 256kb */
|
||||||
#define WBUFFERSIZE 20*262144 /* */
|
#define WBUFFERSIZE 20*262144
|
||||||
|
/* #define WBUFFERSIZE 100*262144 /*
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int socket;
|
int socket;
|
||||||
@ -198,6 +200,8 @@ int ANETregisterSocket(int socket)
|
|||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
return ANETSOCKERROR;
|
return ANETSOCKERROR;
|
||||||
}
|
}
|
||||||
|
flags =1;
|
||||||
|
setsockopt(socket,IPPROTO_TCP,TCP_NODELAY,(char *) &flags, sizeof(int));
|
||||||
socke.readBuffer = MakeRWPuffer(RBUFFERSIZE);
|
socke.readBuffer = MakeRWPuffer(RBUFFERSIZE);
|
||||||
socke.writeBuffer = MakeRWPuffer(WBUFFERSIZE);
|
socke.writeBuffer = MakeRWPuffer(WBUFFERSIZE);
|
||||||
if (socke.readBuffer == NULL || socke.writeBuffer == NULL) {
|
if (socke.readBuffer == NULL || socke.writeBuffer == NULL) {
|
||||||
|
@ -18,3 +18,4 @@ int MakeConfigurableVirtualMotor(SConnection * pCon, SicsInterp * pSics,
|
|||||||
int ConfigurableVirtualMotorAction(SConnection *pCon, SicsInterp *pSics,
|
int ConfigurableVirtualMotorAction(SConnection *pCon, SicsInterp *pSics,
|
||||||
void *data, int argc, char *argv[]);
|
void *data, int argc, char *argv[]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ typedef struct __CONFVIRTMOT {
|
|||||||
char *name;
|
char *name;
|
||||||
char *scriptName;
|
char *scriptName;
|
||||||
char *readScript;
|
char *readScript;
|
||||||
|
char *checkScript;
|
||||||
int motorList;
|
int motorList;
|
||||||
float targetValue;
|
float targetValue;
|
||||||
int targetReached;
|
int targetReached;
|
||||||
|
@ -289,7 +289,24 @@ static int InterestCallback(int iEvent, void *pEvent, void *pUser)
|
|||||||
}
|
}
|
||||||
return 1;
|
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)
|
static int ConfCheckStatus(void *pData, SConnection * pCon)
|
||||||
{
|
{
|
||||||
@ -327,6 +344,7 @@ static int ConfCheckStatus(void *pData, SConnection * pCon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result == HWIdle) {
|
if (result == HWIdle) {
|
||||||
|
invokeCheckScript(self,pCon);
|
||||||
event.pName = self->name;
|
event.pName = self->name;
|
||||||
event.fVal = self->pDriv->GetValue(self, pCon);
|
event.fVal = self->pDriv->GetValue(self, pCon);
|
||||||
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
||||||
@ -575,6 +593,26 @@ int ConfigurableVirtualMotorAction(SConnection * pCon, SicsInterp * pSics,
|
|||||||
return 1;
|
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) {
|
} else if (strcmp(argv[1], "interest") == 0) {
|
||||||
pRegInfo = (pRegisteredInfo) malloc(sizeof(RegisteredInfo));
|
pRegInfo = (pRegisteredInfo) malloc(sizeof(RegisteredInfo));
|
||||||
if (!pRegInfo) {
|
if (!pRegInfo) {
|
||||||
@ -584,7 +622,7 @@ int ConfigurableVirtualMotorAction(SConnection * pCon, SicsInterp * pSics,
|
|||||||
pRegInfo->pName = strdup(argv[0]);
|
pRegInfo->pName = strdup(argv[0]);
|
||||||
pRegInfo->pCon = SCCopyConnection(pCon);
|
pRegInfo->pCon = SCCopyConnection(pCon);
|
||||||
value = ConfGetValue(self, pCon);
|
value = ConfGetValue(self, pCon);
|
||||||
if (!iRet) {
|
if (value < -9990.) {
|
||||||
snprintf(pBueffel,511,
|
snprintf(pBueffel,511,
|
||||||
"Failed to register interest, Reason:Error obtaining current position for %s",
|
"Failed to register interest, Reason:Error obtaining current position for %s",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
|
@ -16,6 +16,7 @@ typedef struct __CONFVIRTMOT {
|
|||||||
char *name;
|
char *name;
|
||||||
char *scriptName;
|
char *scriptName;
|
||||||
char *readScript;
|
char *readScript;
|
||||||
|
char *checkScript;
|
||||||
int motorList;
|
int motorList;
|
||||||
float targetValue;
|
float targetValue;
|
||||||
int targetReached;
|
int targetReached;
|
||||||
@ -33,6 +34,7 @@ The fields are:
|
|||||||
\item[scriptName] The name of the program to calculate the new positions
|
\item[scriptName] The name of the program to calculate the new positions
|
||||||
of the real motors.
|
of the real motors.
|
||||||
\item[readScript] A script to read back the current value of the virtual motor.
|
\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[motorList] A list of the motors to start and control.
|
||||||
\item[targetValue] The target value we wanted to have.
|
\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.
|
\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
|
#define ZIPBUF 8192
|
||||||
int SCWriteZipped(SConnection * self, char *pName, void *pData,
|
int SCWriteZipped(SConnection * self, char *pName, void *pData,
|
||||||
int iDataLen)
|
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;
|
char outBuf[65546], *pBuf = NULL, noutBuf[ZIPBUF], *pHeader = NULL;
|
||||||
int compressedLength, iRet, iRet2, iCount, protocolID;
|
int compressedLength, iRet, iRet2, iCount, protocolID;
|
||||||
|
4
conman.h
4
conman.h
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
copyright: see copyright.h
|
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
|
Mark Koennecke, January 2009
|
||||||
----------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------*/
|
||||||
@ -100,6 +100,8 @@ int SCWriteUUencoded(SConnection * pCon, char *pName, void *iData,
|
|||||||
int iLen);
|
int iLen);
|
||||||
int SCWriteZipped(SConnection * pCon, char *pName, void *pData,
|
int SCWriteZipped(SConnection * pCon, char *pName, void *pData,
|
||||||
int iDataLen);
|
int iDataLen);
|
||||||
|
int SCWriteBinary(SConnection * pCon, char *pName, void *pData,
|
||||||
|
int iDataLen);
|
||||||
writeFunc SCGetWriteFunc(SConnection * pCon);
|
writeFunc SCGetWriteFunc(SConnection * pCon);
|
||||||
void SCSetWriteFunc(SConnection * pCon, writeFunc x);
|
void SCSetWriteFunc(SConnection * pCon, writeFunc x);
|
||||||
int SCOnlySockWrite(SConnection * self, char *buffer, int iOut);
|
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,
|
static int SortRefNew(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||||
pHdb par[], int nPar)
|
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;
|
const double *cell;
|
||||||
double *hklc;
|
double *hklc;
|
||||||
int nRefl, i, j, status, count;
|
int nRefl, i, j, status, count;
|
||||||
@ -916,6 +916,12 @@ static int SortRefNew(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
|||||||
* 10.
|
* 10.
|
||||||
*/
|
*/
|
||||||
hkl[3] = ang[2]+10 + 0.1 * ang[0];
|
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 {
|
} else {
|
||||||
hkl[3] = ang[0];
|
hkl[3] = ang[0];
|
||||||
}
|
}
|
||||||
@ -1007,7 +1013,7 @@ static int ReadTour(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
|||||||
{
|
{
|
||||||
FILE *fd = NULL;
|
FILE *fd = NULL;
|
||||||
char buffer[132];
|
char buffer[132];
|
||||||
double hkl[4], ang[4];
|
double hkl[4], ang[5];
|
||||||
int idx, tour;
|
int idx, tour;
|
||||||
pFourMess priv = self->pPrivate;
|
pFourMess priv = self->pPrivate;
|
||||||
pSingleDiff diffi = NULL;
|
pSingleDiff diffi = NULL;
|
||||||
|
@ -974,9 +974,12 @@ int copyHdbValue(hdbValue * source, hdbValue * target)
|
|||||||
target->arrayLength = source->arrayLength;
|
target->arrayLength = source->arrayLength;
|
||||||
}
|
}
|
||||||
if (source->v.intArray != NULL) {
|
if (source->v.intArray != NULL) {
|
||||||
|
/*
|
||||||
for (i = 0; i < source->arrayLength; i++) {
|
for (i = 0; i < source->arrayLength; i++) {
|
||||||
target->v.intArray[i] = source->v.intArray[i];
|
target->v.intArray[i] = source->v.intArray[i];
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
memcpy(target->v.intArray,source->v.intArray,source->arrayLength*sizeof(int));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HIPFLOATAR:
|
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.
|
often restricted due to the cryogenic garbage around the sample.
|
||||||
-------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------*/
|
||||||
int CalculateSettings(pHKL self, float fHKL[3], float fPsi, int iHamil,
|
int CalculateSettings(pHKL self, float fHKL[3], float fPsi, int iHamil,
|
||||||
float fSet[4], SConnection * pCon)
|
float fSet[5], SConnection * pCon)
|
||||||
{
|
{
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
double myPsi = fPsi;
|
double myPsi = fPsi;
|
||||||
int i, status;
|
int i, status;
|
||||||
pSingleDiff single = NULL;
|
pSingleDiff single = NULL;
|
||||||
double dHkl[4], dSet[4];
|
double dHkl[4], dSet[5];
|
||||||
|
|
||||||
/* catch shitty input */
|
/* catch shitty input */
|
||||||
if ((fHKL[0] == 0.) && (fHKL[1] == 0.) && (fHKL[2] == 0.)) {
|
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;
|
dHkl[3] = myPsi;
|
||||||
|
|
||||||
status = single->calculateSettings(single, dHkl, dSet);
|
status = single->calculateSettings(single, dHkl, dSet);
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
fSet[i] = dSet[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];
|
char pBueffel[512];
|
||||||
pSingleDiff single = NULL;
|
pSingleDiff single = NULL;
|
||||||
double dSet[4];
|
double dSet[5];
|
||||||
int i, status;
|
int i, status;
|
||||||
|
|
||||||
single = SXGetDiffractometer();
|
single = SXGetDiffractometer();
|
||||||
assert(single != NULL);
|
assert(single != NULL);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
dSet[i] = fSet[i];
|
dSet[i] = fSet[i];
|
||||||
}
|
}
|
||||||
single->settingsToList(single, dSet);
|
single->settingsToList(single, dSet);
|
||||||
@ -471,7 +471,7 @@ int startHKLMotors(pHKL self, SConnection * pCon, float fSet[4])
|
|||||||
int RunHKL(pHKL self, float fHKL[3],
|
int RunHKL(pHKL self, float fHKL[3],
|
||||||
float fPsi, int iHamil, SConnection * pCon)
|
float fPsi, int iHamil, SConnection * pCon)
|
||||||
{
|
{
|
||||||
float fSet[4];
|
float fSet[5];
|
||||||
int iRet, i;
|
int iRet, i;
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
pDummy pDum;
|
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;
|
int iRet;
|
||||||
|
|
||||||
@ -579,77 +579,6 @@ int DriveHKL(pHKL self, float fHKL[3],
|
|||||||
return iReturn;
|
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.
|
For the conversion from angles to HKL.
|
||||||
-------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------*/
|
||||||
@ -803,14 +732,15 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
int iRet, i, iHamil;
|
int iRet, i, iHamil;
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
float fUB[9], fPsi, fVal;
|
float fUB[9], fPsi, fVal;
|
||||||
float fHKL[3], fSet[4];
|
float fHKL[3], fSet[5];
|
||||||
double dHKL[3], dSet[4];
|
double dHKL[3], dSet[5];
|
||||||
double dVal, lambda, stt;
|
double dVal, lambda, stt;
|
||||||
const double *dUB;
|
const double *dUB;
|
||||||
pHKL self = NULL;
|
pHKL self = NULL;
|
||||||
CommandList *pCom = NULL;
|
CommandList *pCom = NULL;
|
||||||
pDummy pDum = NULL;
|
pDummy pDum = NULL;
|
||||||
pSingleDiff single = NULL;
|
pSingleDiff single = NULL;
|
||||||
|
int mode, nargs;
|
||||||
|
|
||||||
assert(pCon);
|
assert(pCon);
|
||||||
assert(pSics);
|
assert(pSics);
|
||||||
@ -857,13 +787,19 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
SCWrite(pCon, pBueffel, eValue);
|
SCWrite(pCon, pBueffel, eValue);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (strcmp(argv[1], "fromangles") == 0) {
|
} 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,
|
SCWrite(pCon,
|
||||||
"ERROR: need stt, om, chi,phi to calculate HKL from angles",
|
"ERROR: need stt, om, chi,phi to calculate HKL from angles",
|
||||||
eError);
|
eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < nargs-2; i++) {
|
||||||
iRet = Tcl_GetDouble(InterpGetTcl(pSics), argv[i + 2], &dVal);
|
iRet = Tcl_GetDouble(InterpGetTcl(pSics), argv[i + 2], &dVal);
|
||||||
if (iRet != TCL_OK) {
|
if (iRet != TCL_OK) {
|
||||||
snprintf(pBueffel, 511, "ERROR: failed to convert %s to number",
|
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",
|
snprintf(pBueffel,sizeof(pBueffel)-1, " gamma = %f, omega = %f, nu = %f",
|
||||||
fSet[0], fSet[1], fSet[2]);
|
fSet[0], fSet[1], fSet[2]);
|
||||||
SCWrite(pCon, pBueffel, eValue);
|
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 {
|
} else {
|
||||||
snprintf(pBueffel,sizeof(pBueffel)-1, " 2-theta = %f, omega = %f, chi = %f, phi = %f",
|
snprintf(pBueffel,sizeof(pBueffel)-1, " 2-theta = %f, omega = %f, chi = %f, phi = %f",
|
||||||
fSet[0], fSet[1], fSet[2], fSet[3]);
|
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,
|
static pNXDS subSampleCommand(pNXDS source, char *command,
|
||||||
char *error, int errLen)
|
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;
|
int dim = 0, start = 0, i;
|
||||||
char *pPtr = NULL, token[80];
|
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]) {
|
if (startDim[i] < 0 || startDim[i] >= source->dim[i]) {
|
||||||
snprintf(error, errLen,
|
snprintf(error, errLen,
|
||||||
"ERROR: invalid start value %d for dimension %d",
|
"ERROR: invalid start value %d for dimension %d",
|
||||||
startDim[1], i);
|
(int)startDim[1], i);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (endDim[i] < startDim[i] || endDim[i] >= source->dim[i]) {
|
if (endDim[i] < startDim[i] || endDim[i] >= source->dim[i]) {
|
||||||
snprintf(error, errLen,
|
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);
|
i);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
22
macro.c
22
macro.c
@ -119,6 +119,12 @@ int MacroPop(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
SConnection *MacroPeek(void)
|
||||||
|
{
|
||||||
|
assert(pUnbekannt);
|
||||||
|
return pUnbekannt->pCon[pUnbekannt->iStack];
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
static int SicsUnknownProc(ClientData pData, Tcl_Interp * pInter,
|
static int SicsUnknownProc(ClientData pData, Tcl_Interp * pInter,
|
||||||
int argc, char *argv[])
|
int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -269,11 +275,10 @@ static void KillExec(ClientData data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------*/
|
||||||
This is in the Tcl sources
|
/* static Tcl_ObjCmdProc oldExec = NULL; */
|
||||||
*/
|
static int (*oldExec)(ClientData clientData,Tcl_Interp *interp,
|
||||||
extern int Tcl_ExecObjCmd(ClientData data, Tcl_Interp * interp,
|
int objc,Tcl_Obj *const objv[] ) = NULL;
|
||||||
int objc, Tcl_Obj * CONST objv[]);
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
static int ProtectedExec(ClientData clientData, Tcl_Interp * interp,
|
static int ProtectedExec(ClientData clientData, Tcl_Interp * interp,
|
||||||
int objc, Tcl_Obj * CONST objv[])
|
int objc, Tcl_Obj * CONST objv[])
|
||||||
@ -281,13 +286,13 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp * interp,
|
|||||||
char *test = NULL;
|
char *test = NULL;
|
||||||
|
|
||||||
if (objc < 2) {
|
if (objc < 2) {
|
||||||
return Tcl_ExecObjCmd(clientData, interp, objc, objv);
|
return oldExec(clientData, interp, objc, objv);
|
||||||
}
|
}
|
||||||
|
|
||||||
test = Tcl_GetStringFromObj(objv[1], NULL);
|
test = Tcl_GetStringFromObj(objv[1], NULL);
|
||||||
if (allowedCommands != NULL) {
|
if (allowedCommands != NULL) {
|
||||||
if (StringDictExists(allowedCommands, test)) {
|
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;
|
FILE *fp = NULL;
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
int iRet;
|
int iRet;
|
||||||
|
Tcl_CmdInfo execInfo;
|
||||||
|
|
||||||
assert(pSics);
|
assert(pSics);
|
||||||
|
|
||||||
@ -338,6 +344,8 @@ Tcl_Interp *MacroInit(SicsInterp * pSics)
|
|||||||
Tcl_DeleteCommand(pInter, "exit");
|
Tcl_DeleteCommand(pInter, "exit");
|
||||||
Tcl_DeleteCommand(pInter, "socket");
|
Tcl_DeleteCommand(pInter, "socket");
|
||||||
Tcl_DeleteCommand(pInter, "vwait");
|
Tcl_DeleteCommand(pInter, "vwait");
|
||||||
|
Tcl_GetCommandInfo(pInter,"exec",&execInfo);
|
||||||
|
oldExec = execInfo.objProc;
|
||||||
Tcl_DeleteCommand(pInter, "exec");
|
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 MacroPush(SConnection * pCon);
|
||||||
int MacroPop(void);
|
int MacroPop(void);
|
||||||
|
SConnection *MacroPeek(void);
|
||||||
|
|
||||||
void KillSicsUnknown(void);
|
void KillSicsUnknown(void);
|
||||||
|
|
||||||
|
3
make_gen
3
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 \
|
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 \
|
singlenb.o simindex.o simidx.o uselect.o singletas.o motorsec.o \
|
||||||
rwpuffer.o asynnet.o background.o countersec.o hdbtable.o velosec.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
|
MOTOROBJ = motor.o simdriv.o
|
||||||
COUNTEROBJ = countdriv.o simcter.o counter.o
|
COUNTEROBJ = countdriv.o simcter.o counter.o
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
SINQDIR=/afs/psi.ch/project/sinq
|
SINQDIR=/afs/psi.ch/project/sinq
|
||||||
NI= -DHAVENI
|
NI= -DHAVENI
|
||||||
NIOBJ= nigpib.o
|
NIOBJ= nigpib.o
|
||||||
NILIB=$(SINQDIR)/sl5/lib/cib.o
|
NILIB=$(SINQDIR)/sl6/lib/cib.o
|
||||||
|
|
||||||
include sllinux_def
|
include sllinux_def
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -I$(HDFROOT)/include -DNXXML -DHDF4 -DHDF5 $(NI) \
|
CFLAGS = -I$(HDFROOT)/include -DNXXML -DHDF5 $(NI) \
|
||||||
-Ipsi/hardsup -I. -MMD \
|
-Ipsi/hardsup -I. -MMD \
|
||||||
-Werror -DCYGNUS -DNONINTF -g $(DFORTIFY) \
|
-Werror -DCYGNUS -DNONINTF -g $(DFORTIFY) \
|
||||||
-Wall -Wno-unused -Wunused-value -Wno-comment -Wno-switch
|
-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
|
psi/tecs/libtecsl.a
|
||||||
LIBS = -L$(HDFROOT)/lib $(SUBLIBS) $(NILIB)\
|
LIBS = -L$(HDFROOT)/lib $(SUBLIBS) $(NILIB)\
|
||||||
-ltcl $(HDFROOT)/lib/libhdf5.a \
|
-ltcl $(HDFROOT)/lib/libhdf5.a \
|
||||||
$(HDFROOT)/lib/libmfhdf.a $(HDFROOT)/lib/libdf.a \
|
$(HDFROOT)/lib/libsz.a \
|
||||||
$(HDFROOT)/lib/libjpeg.a $(HDFROOT)/lib/libsz.a \
|
|
||||||
$(HDFROOT)/lib/libjson.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
|
include make_gen
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ static int MOLICheckStatus(void *data, SConnection * pCon)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------
|
/*---------------------------------------------------------
|
||||||
A special version for EIGER. I am coutious: I have problems
|
A special version for EIGER. I am cautious: I have problems
|
||||||
with this at EIGER but I do not want to propogate the fix
|
with this at EIGER but I do not want to propagate the fix
|
||||||
elsewhere even if it may be the right thing to do.
|
elsewhere even if it may be the right thing to do.
|
||||||
-----------------------------------------------------------*/
|
-----------------------------------------------------------*/
|
||||||
int MOLIEigerStatus(void *data, SConnection * pCon)
|
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;
|
int iRet, iTest;
|
||||||
char pCurrCommand[1064], pTestCommand[1064];
|
char pCurrCommand[1064], pTestCommand[1064];
|
||||||
const char *pAlias;
|
const char *pAlias;
|
||||||
char *pName, *pVal;
|
char *pVal, *pName;
|
||||||
float f1, f2;
|
float f1, f2;
|
||||||
pMotor pMot = NULL;
|
pMotor pMot = NULL;
|
||||||
pStringDict motCache = NULL;
|
pStringDict motCache = NULL;
|
||||||
@ -481,7 +481,7 @@ const char *FindNamPos(pMulMot self, SConnection * pCon)
|
|||||||
iRet = MotorGetSoftPosition(pMot, pCon, &f1);
|
iRet = MotorGetSoftPosition(pMot, pCon, &f1);
|
||||||
if (!iRet) {
|
if (!iRet) {
|
||||||
snprintf(pTestCommand,sizeof(pTestCommand)-1,
|
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);
|
SCWrite(pCon, pTestCommand, eError);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
56
napi4.h
56
napi4.h
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef NAPI4_H
|
||||||
|
#define NAPI4_H
|
||||||
|
|
||||||
#define NXSIGNATURE 959697
|
#define NXSIGNATURE 959697
|
||||||
|
|
||||||
#include "mfhdf.h"
|
#include "mfhdf.h"
|
||||||
@ -7,50 +10,36 @@
|
|||||||
* HDF4 interface
|
* HDF4 interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern NXstatus NX4open(CONSTCHAR * filename, NXaccess access_method,
|
extern NXstatus NX4open(CONSTCHAR *filename, NXaccess access_method, NXhandle* pHandle);
|
||||||
NXhandle * pHandle);
|
|
||||||
extern NXstatus NX4close(NXhandle* pHandle);
|
extern NXstatus NX4close(NXhandle* pHandle);
|
||||||
extern NXstatus NX4flush(NXhandle* pHandle);
|
extern NXstatus NX4flush(NXhandle* pHandle);
|
||||||
|
|
||||||
extern NXstatus NX4makegroup(NXhandle handle, CONSTCHAR * Vgroup,
|
extern NXstatus NX4makegroup (NXhandle handle, CONSTCHAR* Vgroup, CONSTCHAR* NXclass);
|
||||||
CONSTCHAR * NXclass);
|
extern NXstatus NX4opengroup (NXhandle handle, CONSTCHAR* Vgroup, CONSTCHAR* NXclass);
|
||||||
extern NXstatus NX4opengroup(NXhandle handle, CONSTCHAR * Vgroup,
|
|
||||||
CONSTCHAR * NXclass);
|
|
||||||
extern NXstatus NX4closegroup(NXhandle handle);
|
extern NXstatus NX4closegroup(NXhandle handle);
|
||||||
|
|
||||||
extern NXstatus NX4makedata(NXhandle handle, CONSTCHAR * label,
|
extern NXstatus NX4makedata64 (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[]);
|
||||||
int datatype, int rank, int dim[]);
|
extern NXstatus NX4compmakedata64 (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[], int comp_typ, int64_t bufsize[]);
|
||||||
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 NX4compress (NXhandle handle, int compr_type);
|
||||||
extern NXstatus NX4opendata (NXhandle handle, CONSTCHAR* label);
|
extern NXstatus NX4opendata (NXhandle handle, CONSTCHAR* label);
|
||||||
|
|
||||||
extern NXstatus NX4closedata(NXhandle handle);
|
extern NXstatus NX4closedata(NXhandle handle);
|
||||||
|
|
||||||
extern NXstatus NX4getdata(NXhandle handle, void* data);
|
extern NXstatus NX4getdata(NXhandle handle, void* data);
|
||||||
extern NXstatus NX4getslab(NXhandle handle, void *data, int start[],
|
extern NXstatus NX4getslab64(NXhandle handle, void* data, const int64_t start[], const int64_t size[]);
|
||||||
int size[]);
|
extern NXstatus NX4getattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType);
|
||||||
extern NXstatus NX4getattr(NXhandle handle, char *name, void *data,
|
|
||||||
int *iDataLen, int *iType);
|
|
||||||
|
|
||||||
extern NXstatus NX4putdata(NXhandle handle, void *data);
|
extern NXstatus NX4putdata(NXhandle handle, const void* data);
|
||||||
extern NXstatus NX4putslab(NXhandle handle, void *data, int start[],
|
extern NXstatus NX4putslab64(NXhandle handle, const void* data, const int64_t start[], const int64_t size[]);
|
||||||
int size[]);
|
extern NXstatus NX4putattr(NXhandle handle, CONSTCHAR* name, const void* data, int iDataLen, int iType);
|
||||||
extern NXstatus NX4putattr(NXhandle handle, CONSTCHAR * name, void *data,
|
|
||||||
int iDataLen, int iType);
|
|
||||||
|
|
||||||
extern NXstatus NX4getinfo(NXhandle handle, int *rank, int dimension[],
|
extern NXstatus NX4getinfo64(NXhandle handle, int* rank, int64_t dimension[], int* datatype);
|
||||||
int *datatype);
|
extern NXstatus NX4getgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass);
|
||||||
extern NXstatus NX4getgroupinfo(NXhandle handle, int *no_items,
|
|
||||||
NXname name, NXname nxclass);
|
|
||||||
extern NXstatus NX4initgroupdir(NXhandle handle);
|
extern NXstatus NX4initgroupdir(NXhandle handle);
|
||||||
extern NXstatus NX4getnextentry(NXhandle handle, NXname name,
|
extern NXstatus NX4getnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype);
|
||||||
NXname nxclass, int *datatype);
|
|
||||||
extern NXstatus NX4getattrinfo(NXhandle handle, int* no_items);
|
extern NXstatus NX4getattrinfo(NXhandle handle, int* no_items);
|
||||||
extern NXstatus NX4initattrdir(NXhandle handle);
|
extern NXstatus NX4initattrdir(NXhandle handle);
|
||||||
extern NXstatus NX4getnextattr(NXhandle handle, NXname pName, int *iLength,
|
extern NXstatus NX4getnextattr(NXhandle handle, NXname pName, int *iLength, int *iType);
|
||||||
int *iType);
|
|
||||||
|
|
||||||
extern NXstatus NX4getgroupID(NXhandle handle, NXlink* pLink);
|
extern NXstatus NX4getgroupID(NXhandle handle, NXlink* pLink);
|
||||||
extern NXstatus NX4getdataID(NXhandle handle, NXlink* pLink);
|
extern NXstatus NX4getdataID(NXhandle handle, NXlink* pLink);
|
||||||
@ -58,3 +47,14 @@ extern NXstatus NX4makelink(NXhandle handle, NXlink * pLink);
|
|||||||
extern NXstatus NX4printlink(NXhandle handle, NXlink* pLink);
|
extern NXstatus NX4printlink(NXhandle handle, NXlink* pLink);
|
||||||
|
|
||||||
void NX4assignFunctions(pNexusFunction fHandle);
|
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 */
|
||||||
|
55
napi5.h
55
napi5.h
@ -1,61 +1,54 @@
|
|||||||
|
#ifndef NAPI5_H
|
||||||
|
#define NAPI5_H
|
||||||
|
|
||||||
#define NX5SIGNATURE 959695
|
#define NX5SIGNATURE 959695
|
||||||
|
|
||||||
#include <hdf5.h>
|
#include <hdf5.h>
|
||||||
|
|
||||||
/* HDF5 interface */
|
/* HDF5 interface */
|
||||||
|
|
||||||
extern NXstatus NX5open(CONSTCHAR * filename, NXaccess access_method,
|
extern NXstatus NX5open(CONSTCHAR *filename, NXaccess access_method, NXhandle* pHandle);
|
||||||
NXhandle * pHandle);
|
extern NXstatus NX5reopen(NXhandle pOrigHandle, NXhandle* pNewHandle);
|
||||||
|
|
||||||
extern NXstatus NX5close(NXhandle* pHandle);
|
extern NXstatus NX5close(NXhandle* pHandle);
|
||||||
extern NXstatus NX5flush(NXhandle* pHandle);
|
extern NXstatus NX5flush(NXhandle* pHandle);
|
||||||
|
|
||||||
extern NXstatus NX5makegroup(NXhandle handle, CONSTCHAR * name,
|
extern NXstatus NX5makegroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
|
||||||
CONSTCHAR * NXclass);
|
extern NXstatus NX5opengroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
|
||||||
extern NXstatus NX5opengroup(NXhandle handle, CONSTCHAR * name,
|
|
||||||
CONSTCHAR * NXclass);
|
|
||||||
extern NXstatus NX5closegroup(NXhandle handle);
|
extern NXstatus NX5closegroup(NXhandle handle);
|
||||||
|
|
||||||
extern NXstatus NX5makedata(NXhandle handle, CONSTCHAR * label,
|
extern NXstatus NX5makedata64 (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[]);
|
||||||
int datatype, int rank, int dim[]);
|
extern NXstatus NX5compmakedata64 (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[], int comp_typ, int64_t bufsize[]);
|
||||||
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 NX5compress (NXhandle handle, int compr_type);
|
||||||
extern NXstatus NX5opendata (NXhandle handle, CONSTCHAR* label);
|
extern NXstatus NX5opendata (NXhandle handle, CONSTCHAR* label);
|
||||||
extern NXstatus NX5closedata(NXhandle handle);
|
extern NXstatus NX5closedata(NXhandle handle);
|
||||||
extern NXstatus NX5putdata(NXhandle handle, void *data);
|
extern NXstatus NX5putdata(NXhandle handle, const void* data);
|
||||||
|
|
||||||
extern NXstatus NX5putattr(NXhandle handle, CONSTCHAR * name, void *data,
|
extern NXstatus NX5putattr(NXhandle handle, CONSTCHAR* name, const void* data, int iDataLen, int iType);
|
||||||
int iDataLen, int iType);
|
extern NXstatus NX5putslab64(NXhandle handle, const void* data, const int64_t start[], const int64_t size[]);
|
||||||
extern NXstatus NX5putslab(NXhandle handle, void *data, int start[],
|
|
||||||
int size[]);
|
|
||||||
|
|
||||||
extern NXstatus NX5getdataID(NXhandle handle, NXlink* pLink);
|
extern NXstatus NX5getdataID(NXhandle handle, NXlink* pLink);
|
||||||
extern NXstatus NX5makelink(NXhandle handle, NXlink* pLink);
|
extern NXstatus NX5makelink(NXhandle handle, NXlink* pLink);
|
||||||
extern NXstatus NX5printlink(NXhandle handle, NXlink* pLink);
|
extern NXstatus NX5printlink(NXhandle handle, NXlink* pLink);
|
||||||
|
|
||||||
extern NXstatus NX5getdata(NXhandle handle, void* data);
|
extern NXstatus NX5getdata(NXhandle handle, void* data);
|
||||||
extern NXstatus NX5getinfo(NXhandle handle, int *rank, int dimension[],
|
extern NXstatus NX5getinfo64(NXhandle handle, int* rank, int64_t dimension[], int* datatype);
|
||||||
int *datatype);
|
extern NXstatus NX5getnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype);
|
||||||
extern NXstatus NX5getnextentry(NXhandle handle, NXname name,
|
|
||||||
NXname nxclass, int *datatype);
|
|
||||||
|
|
||||||
extern NXstatus NX5getslab(NXhandle handle, void *data, int start[],
|
extern NXstatus NX5getslab64(NXhandle handle, void* data, const int64_t start[], const int64_t size[]);
|
||||||
int size[]);
|
extern NXstatus NX5getnextattr(NXhandle handle, NXname pName, int *iLength, int *iType);
|
||||||
extern NXstatus NX5getnextattr(NXhandle handle, NXname pName, int *iLength,
|
extern NXstatus NX5getattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType);
|
||||||
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 NX5getattrinfo(NXhandle handle, int* no_items);
|
||||||
extern NXstatus NX5getgroupID(NXhandle handle, NXlink* pLink);
|
extern NXstatus NX5getgroupID(NXhandle handle, NXlink* pLink);
|
||||||
extern NXstatus NX5getgroupinfo(NXhandle handle, int *no_items,
|
extern NXstatus NX5getgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass);
|
||||||
NXname name, NXname nxclass);
|
|
||||||
|
|
||||||
extern NXstatus NX5initgroupdir(NXhandle handle);
|
extern NXstatus NX5initgroupdir(NXhandle handle);
|
||||||
extern NXstatus NX5initattrdir(NXhandle handle);
|
extern NXstatus NX5initattrdir(NXhandle handle);
|
||||||
|
|
||||||
void NX5assignFunctions(pNexusFunction fHandle);
|
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, const H5A_info_t *unused, void *opdata);
|
||||||
herr_t attr_info(hid_t loc_id, const char *name, void *opdata);
|
herr_t group_info(hid_t loc_id, const char *name, const H5L_info_t *unused, void *opdata);
|
||||||
herr_t group_info(hid_t loc_id, const char *name, void *opdata);
|
herr_t nxgroup_info(hid_t loc_id, const char *name, const H5L_info_t *unused, void *op_data);
|
||||||
|
|
||||||
|
#endif /* NAPI5_H */
|
||||||
|
30
napiconfig.h
30
napiconfig.h
@ -1,22 +1,28 @@
|
|||||||
#ifndef NAPICONFIG_H
|
#ifndef NAPICONFIG_H
|
||||||
#define NAPICONFIG_H
|
#define NAPICONFIG_H
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#ifdef __VMS
|
||||||
|
#include <nxconfig_vms.h>
|
||||||
|
#else
|
||||||
#include <nxconfig.h>
|
#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>
|
#include <stdint.h>
|
||||||
#else
|
#elif HAVE_INTTYPES_H
|
||||||
typedef signed char int8_t;
|
#include <inttypes.h>
|
||||||
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;
|
|
||||||
|
|
||||||
#endif /* HAVE_STDINT_H */
|
#endif /* HAVE_STDINT_H */
|
||||||
|
|
||||||
|
|
||||||
#endif /* NAPICONFIG_H */
|
#endif /* NAPICONFIG_H */
|
||||||
|
62
napiu.c
62
napiu.c
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
For further information, see <http://www.nexus.anl.gov/>
|
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 <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -41,10 +41,7 @@ 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,
|
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)
|
||||||
const char *affiliation, const char *address,
|
|
||||||
const char *telephone_number,
|
|
||||||
const char *fax_number, const char *email)
|
|
||||||
{
|
{
|
||||||
DO_GLOBAL(user);
|
DO_GLOBAL(user);
|
||||||
DO_GLOBAL(affiliation);
|
DO_GLOBAL(affiliation);
|
||||||
@ -56,39 +53,33 @@ NXstatus NXUwriteglobals(NXhandle file_id, const char *user,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* NXUwritegroup creates and leaves open a group */
|
/* NXUwritegroup creates and leaves open a group */
|
||||||
NXstatus NXUwritegroup(NXhandle file_id, const char *group_name,
|
NXstatus NXUwritegroup(NXhandle file_id, const char* group_name, const char* group_class)
|
||||||
const char *group_class)
|
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
status = NXmakegroup(file_id, group_name, group_class);
|
status = NXmakegroup(file_id, group_name, group_class);
|
||||||
if (status == NX_OK) {
|
if (status == NX_OK)
|
||||||
|
{
|
||||||
status = NXopengroup(file_id, group_name, group_class);
|
status = NXopengroup(file_id, group_name, group_class);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
NXstatus NXUwritedata(NXhandle file_id, const char *data_name,
|
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[])
|
||||||
const void *data, int data_type, int rank,
|
|
||||||
const int dim[], const char *units,
|
|
||||||
const int start[], const int size[])
|
|
||||||
{
|
{
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NXstatus NXUreaddata(NXhandle file_id, const char *data_name, void *data,
|
NXstatus NXUreaddata(NXhandle file_id, const char* data_name, void* data, char* units, const int start[], const int size[])
|
||||||
char *units, const int start[], const int size[])
|
|
||||||
{
|
{
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NXstatus NXUwritehistogram(NXhandle file_id, const char *data_name,
|
NXstatus NXUwritehistogram(NXhandle file_id, const char* data_name, const void* data, const char* units)
|
||||||
const void *data, const char *units)
|
|
||||||
{
|
{
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NXstatus NXUreadhistogram(NXhandle file_id, const char *data_name,
|
NXstatus NXUreadhistogram(NXhandle file_id, const char* data_name, void* data, char* units)
|
||||||
void *data, char *units)
|
|
||||||
{
|
{
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
@ -101,34 +92,37 @@ NXstatus NXUsetcompress(NXhandle file_id, int comp_type, int comp_size)
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
if (comp_type == NX_COMP_LZW || comp_type == NX_COMP_HUF ||
|
if (comp_type == NX_COMP_LZW || comp_type == NX_COMP_HUF ||
|
||||||
comp_type == NX_COMP_RLE || comp_type == NX_COMP_NONE) {
|
comp_type == NX_COMP_RLE || comp_type == NX_COMP_NONE)
|
||||||
|
{
|
||||||
NXcompress_type = comp_type;
|
NXcompress_type = comp_type;
|
||||||
if (comp_size != 0) {
|
if (comp_size != 0)
|
||||||
|
{
|
||||||
NXcompress_size = comp_size;
|
NXcompress_size = comp_size;
|
||||||
}
|
}
|
||||||
status = NX_OK;
|
status = NX_OK;
|
||||||
} else {
|
}
|
||||||
NXIReportError(NXpData, "Invalid compression option");
|
else
|
||||||
|
{
|
||||||
|
NXReportError( "Invalid compression option");
|
||||||
status = NX_ERROR;
|
status = NX_ERROR;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* !NXUfindgroup finds if a NeXus group of the specified name exists */
|
/* !NXUfindgroup finds if a NeXus group of the specified name exists */
|
||||||
NXstatus NXUfindgroup(NXhandle file_id, const char *group_name,
|
NXstatus NXUfindgroup(NXhandle file_id, const char* group_name, char* group_class)
|
||||||
char *group_class)
|
|
||||||
{
|
{
|
||||||
int status, n;
|
int status, n;
|
||||||
NXname vname, vclass;
|
NXname vname, vclass;
|
||||||
status = NXgetgroupinfo(file_id, &n, vname, vclass);
|
status = NXgetgroupinfo(file_id, &n, vname, vclass);
|
||||||
if (status != NX_OK) {
|
if (status != NX_OK)
|
||||||
|
{
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NXstatus NXUfindclass(NXhandle file_id, const char *group_class,
|
NXstatus NXUfindclass(NXhandle file_id, const char* group_class, char* group_name, int find_index)
|
||||||
char *group_name, int find_index)
|
|
||||||
{
|
{
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
@ -144,22 +138,17 @@ NXstatus NXUfindattr(NXhandle file_id, const char *attr_name)
|
|||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NXstatus NXUfindsignal(NXhandle file_id, int signal, char *data_name,
|
NXstatus NXUfindsignal(NXhandle file_id, int signal, char* data_name, int* data_rank, int* data_type, int data_dimensions[])
|
||||||
int *data_rank, int *data_type,
|
|
||||||
int data_dimensions[])
|
|
||||||
{
|
{
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NXstatus NXUfindaxis(NXhandle file_id, int axis, int primary,
|
NXstatus NXUfindaxis(NXhandle file_id, int axis, int primary, char* data_name, int* data_rank, int* data_type, int data_dimensions[])
|
||||||
char *data_name, int *data_rank, int *data_type,
|
|
||||||
int data_dimensions[])
|
|
||||||
{
|
{
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NXstatus NXUfindlink(NXhandle file_id, NXlink * group_id,
|
NXstatus NXUfindlink(NXhandle file_id, NXlink* group_id, const char* group_class)
|
||||||
const char *group_class)
|
|
||||||
{
|
{
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
@ -168,3 +157,4 @@ NXstatus NXUresumelink(NXhandle file_id, NXlink group_id)
|
|||||||
{
|
{
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
nread.c
5
nread.c
@ -700,10 +700,13 @@ int NetReaderTask(void *pData)
|
|||||||
GetCharArray(self->conList));
|
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);
|
snprintf(num, sizeof num, "%d", conCount);
|
||||||
IFSetOption(pSICSOptions, "ConnectionCount", num);
|
IFSetOption(pSICSOptions, "ConnectionCount", num);
|
||||||
IFSetOption(pSICSOptions, "ConMask", GetCharArray(self->conList));
|
IFSetOption(pSICSOptions, "ConMask", GetCharArray(self->conList));
|
||||||
|
*/
|
||||||
|
|
||||||
/* the select itself */
|
/* the select itself */
|
||||||
tmo.tv_usec = self->iReadTimeout;
|
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 */
|
180
nxcopy.c
180
nxcopy.c
@ -13,6 +13,7 @@
|
|||||||
#include "sicsdata.h"
|
#include "sicsdata.h"
|
||||||
#include "nxcopy.h"
|
#include "nxcopy.h"
|
||||||
#include "HistMem.h"
|
#include "HistMem.h"
|
||||||
|
#include "macro.h"
|
||||||
/*-------------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------------
|
||||||
* decode a SWIG style pointer into the real pointer value.
|
* decode a SWIG style pointer into the real pointer value.
|
||||||
* Stolen from SWIG generated code.
|
* Stolen from SWIG generated code.
|
||||||
@ -239,7 +240,184 @@ static int NXDataToHdbNode(ClientData clientData, Tcl_Interp * interp,
|
|||||||
}
|
}
|
||||||
return TCL_OK;
|
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,
|
static int NXDataToHM(ClientData clientData, Tcl_Interp * interp,
|
||||||
int objc, Tcl_Obj * CONST objv[])
|
int objc, Tcl_Obj * CONST objv[])
|
||||||
@ -306,5 +484,7 @@ int NXcopy_Init(Tcl_Interp * pInter)
|
|||||||
NULL);
|
NULL);
|
||||||
Tcl_CreateObjCommand(pInter, "nxToHdb", NXDataToHdbNode, NULL, NULL);
|
Tcl_CreateObjCommand(pInter, "nxToHdb", NXDataToHdbNode, NULL, NULL);
|
||||||
Tcl_CreateObjCommand(pInter, "nxToHM", NXDataToHM, 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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
102
nxdataset.c
102
nxdataset.c
@ -12,8 +12,7 @@
|
|||||||
#include "nxdataset.h"
|
#include "nxdataset.h"
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
static int getTypeSize(int typecode)
|
static int getTypeSize(int typecode){
|
||||||
{
|
|
||||||
switch(typecode){
|
switch(typecode){
|
||||||
case NX_FLOAT32:
|
case NX_FLOAT32:
|
||||||
case NX_INT32:
|
case NX_INT32:
|
||||||
@ -34,23 +33,23 @@ static int getTypeSize(int typecode)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
pNXDS createNXDataset(int rank, int typecode, int dim[])
|
pNXDS createNXDataset(int rank, int typecode, int64_t dim[]){
|
||||||
{
|
|
||||||
pNXDS pNew = NULL;
|
pNXDS pNew = NULL;
|
||||||
int i, length;
|
int64_t length;
|
||||||
|
int i;
|
||||||
|
|
||||||
pNew = (pNXDS)malloc(sizeof(NXDS));
|
pNew = (pNXDS)malloc(sizeof(NXDS));
|
||||||
if(pNew == NULL){
|
if(pNew == NULL){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pNew->dim = (int *) malloc(rank * sizeof(int));
|
pNew->dim = (int64_t *)malloc(rank*sizeof(int64_t));
|
||||||
for(i = 0, length = 1; i < rank; i++){
|
for(i = 0, length = 1; i < rank; i++){
|
||||||
length *= dim[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);
|
free(pNew);
|
||||||
@ -63,20 +62,19 @@ pNXDS createNXDataset(int rank, int typecode, int dim[])
|
|||||||
pNew->dim[i] = dim[i];
|
pNew->dim[i] = dim[i];
|
||||||
}
|
}
|
||||||
pNew->magic = MAGIC;
|
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;
|
return pNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
pNXDS createTextNXDataset(char *name)
|
pNXDS createTextNXDataset(char *name){
|
||||||
{
|
|
||||||
pNXDS pNew = NULL;
|
pNXDS pNew = NULL;
|
||||||
|
|
||||||
pNew = (pNXDS)malloc(sizeof(NXDS));
|
pNew = (pNXDS)malloc(sizeof(NXDS));
|
||||||
if(pNew == NULL){
|
if(pNew == NULL){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pNew->dim = (int *) malloc(sizeof(int));
|
pNew->dim = (int64_t *)malloc(sizeof(int64_t));
|
||||||
pNew->u.cPtr = strdup(name);
|
pNew->u.cPtr = strdup(name);
|
||||||
if(pNew->dim == NULL || pNew->u.ptr == NULL){
|
if(pNew->dim == NULL || pNew->u.ptr == NULL){
|
||||||
free(pNew);
|
free(pNew);
|
||||||
@ -88,10 +86,8 @@ pNXDS createTextNXDataset(char *name)
|
|||||||
pNew->dim[0] = strlen(name);
|
pNew->dim[0] = strlen(name);
|
||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
void dropNXDataset(pNXDS dataset)
|
void dropNXDataset(pNXDS dataset){
|
||||||
{
|
|
||||||
if(dataset == NULL){
|
if(dataset == NULL){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,10 +105,8 @@ void dropNXDataset(pNXDS dataset)
|
|||||||
}
|
}
|
||||||
free(dataset);
|
free(dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
int getNXDatasetRank(pNXDS dataset)
|
int getNXDatasetRank(pNXDS dataset){
|
||||||
{
|
|
||||||
if(dataset == NULL){
|
if(dataset == NULL){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -121,10 +115,8 @@ int getNXDatasetRank(pNXDS dataset)
|
|||||||
}
|
}
|
||||||
return dataset->rank;
|
return dataset->rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
int getNXDatasetDim(pNXDS dataset, int which)
|
int getNXDatasetDim(pNXDS dataset, int which){
|
||||||
{
|
|
||||||
if(dataset == NULL){
|
if(dataset == NULL){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -136,10 +128,8 @@ int getNXDatasetDim(pNXDS dataset, int which)
|
|||||||
}
|
}
|
||||||
return dataset->dim[which];
|
return dataset->dim[which];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
int getNXDatasetType(pNXDS dataset)
|
int getNXDatasetType(pNXDS dataset){
|
||||||
{
|
|
||||||
if(dataset == NULL){
|
if(dataset == NULL){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -148,10 +138,8 @@ int getNXDatasetType(pNXDS dataset)
|
|||||||
}
|
}
|
||||||
return dataset->type;
|
return dataset->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
int getNXDatasetLength(pNXDS dataset)
|
int getNXDatasetLength(pNXDS dataset){
|
||||||
{
|
|
||||||
int length, i;
|
int length, i;
|
||||||
|
|
||||||
if(dataset == NULL){
|
if(dataset == NULL){
|
||||||
@ -166,19 +154,15 @@ int getNXDatasetLength(pNXDS dataset)
|
|||||||
}
|
}
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
int getNXDatasetByteLength(pNXDS dataset)
|
int getNXDatasetByteLength(pNXDS dataset){
|
||||||
{
|
|
||||||
return getNXDatasetLength(dataset)*getTypeSize(dataset->type);
|
return getNXDatasetLength(dataset)*getTypeSize(dataset->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
This calculates an arbitray address in C storage order
|
This calculates an arbitray address in C storage order
|
||||||
-----------------------------------------------------------------------*/
|
-----------------------------------------------------------------------*/
|
||||||
static int calculateAddress(pNXDS dataset, int pos[])
|
static int64_t calculateAddress(pNXDS dataset, int64_t pos[]){
|
||||||
{
|
int64_t result, mult;
|
||||||
int result, mult;
|
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
result = pos[dataset->rank - 1];
|
result = pos[dataset->rank - 1];
|
||||||
@ -193,12 +177,9 @@ static int calculateAddress(pNXDS dataset, int pos[])
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
double getNXDatasetValue(pNXDS dataset, int pos[])
|
double getNXDatasetValue(pNXDS dataset, int64_t pos[]){
|
||||||
{
|
int64_t address;
|
||||||
int address;
|
|
||||||
double value;
|
|
||||||
|
|
||||||
if(dataset == NULL){
|
if(dataset == NULL){
|
||||||
return 0;
|
return 0;
|
||||||
@ -210,10 +191,8 @@ double getNXDatasetValue(pNXDS dataset, int pos[])
|
|||||||
address = calculateAddress(dataset,pos);
|
address = calculateAddress(dataset,pos);
|
||||||
return getNXDatasetValueAt(dataset, address);
|
return getNXDatasetValueAt(dataset, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
double getNXDatasetValueAt(pNXDS dataset, int address)
|
double getNXDatasetValueAt(pNXDS dataset, int64_t address){
|
||||||
{
|
|
||||||
double value;
|
double value;
|
||||||
|
|
||||||
if(dataset == NULL){
|
if(dataset == NULL){
|
||||||
@ -248,12 +227,10 @@ double getNXDatasetValueAt(pNXDS dataset, int address)
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
char *getNXDatasetText(pNXDS dataset)
|
char *getNXDatasetText(pNXDS dataset){
|
||||||
{
|
|
||||||
char *resultBuffer = NULL;
|
char *resultBuffer = NULL;
|
||||||
int length, status = 1;
|
int status = 1;
|
||||||
|
|
||||||
if(dataset == NULL){
|
if(dataset == NULL){
|
||||||
return strdup("NULL");
|
return strdup("NULL");
|
||||||
@ -270,7 +247,8 @@ char *getNXDatasetText(pNXDS dataset)
|
|||||||
dataset->type == NX_UINT32 ||
|
dataset->type == NX_UINT32 ||
|
||||||
dataset->type == NX_INT64 ||
|
dataset->type == NX_INT64 ||
|
||||||
dataset->type == NX_UINT64 ||
|
dataset->type == NX_UINT64 ||
|
||||||
dataset->type == NX_INT16 || dataset->type == NX_UINT16) {
|
dataset->type == NX_INT16 ||
|
||||||
|
dataset->type == NX_UINT16 ) {
|
||||||
status = 0;
|
status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,11 +264,9 @@ char *getNXDatasetText(pNXDS dataset)
|
|||||||
}
|
}
|
||||||
return resultBuffer;
|
return resultBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
int putNXDatasetValue(pNXDS dataset, int pos[], double value)
|
int putNXDatasetValue(pNXDS dataset, int64_t pos[], double value){
|
||||||
{
|
int64_t address;
|
||||||
int address;
|
|
||||||
|
|
||||||
if(dataset == NULL){
|
if(dataset == NULL){
|
||||||
return 0;
|
return 0;
|
||||||
@ -302,10 +278,8 @@ int putNXDatasetValue(pNXDS dataset, int pos[], double value)
|
|||||||
address = calculateAddress(dataset,pos);
|
address = calculateAddress(dataset,pos);
|
||||||
return putNXDatasetValueAt(dataset,address,value);
|
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 code is dangerous, it casts without checking the data range.
|
||||||
This may cause trouble in some cases
|
This may cause trouble in some cases
|
||||||
@ -340,8 +314,8 @@ int putNXDatasetValueAt(pNXDS dataset, int address, double value)
|
|||||||
This is working recursively through the dimensions. When at the last:
|
This is working recursively through the dimensions. When at the last:
|
||||||
actual copying takes place.
|
actual copying takes place.
|
||||||
-----------------------------------------------------------------------*/
|
-----------------------------------------------------------------------*/
|
||||||
static void copyCutData(pNXDS source, pNXDS target, int sourceDim[],
|
static void copyCutData(pNXDS source, pNXDS target, int64_t sourceDim[],
|
||||||
int targetDim[], int start[], int end[], int dim)
|
int64_t targetDim[], int64_t start[], int64_t end[], int dim)
|
||||||
{
|
{
|
||||||
int i, length;
|
int i, length;
|
||||||
double val;
|
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;
|
pNXDS result = NULL;
|
||||||
int newDim[NX_MAXRANK], i;
|
int64_t newDim[NX_MAXRANK], i;
|
||||||
int sourceDim[NX_MAXRANK], targetDim[NX_MAXRANK];
|
int64_t sourceDim[NX_MAXRANK], targetDim[NX_MAXRANK];
|
||||||
|
|
||||||
for (i = 0; i < source->rank; i++) {
|
for (i = 0; i < source->rank; i++) {
|
||||||
if (start[i] < 0 || end[i] > source->dim[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.
|
This recurses through all dimensions, thereby skipping the summed one.
|
||||||
At the end of the recursion the actual summing is performed.
|
At the end of the recursion the actual summing is performed.
|
||||||
----------------------------------------------------------------------*/
|
----------------------------------------------------------------------*/
|
||||||
static void sumData(pNXDS source, pNXDS target, int sourceDim[],
|
static void sumData(pNXDS source, pNXDS target, int64_t sourceDim[],
|
||||||
int targetDim[], int targetDimCount, int dimNo,
|
int64_t targetDim[], int targetDimCount, int dimNo,
|
||||||
int start, int end, int currentDim)
|
int start, int end, int currentDim)
|
||||||
{
|
{
|
||||||
int i, length;
|
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)
|
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;
|
pNXDS result = NULL;
|
||||||
int i, count;
|
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);
|
sumData(source, result, sourceDim, targetDim, 0, dimNo, start, end, 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
14
nxdataset.h
14
nxdataset.h
@ -18,7 +18,7 @@ typedef struct {
|
|||||||
int magic;
|
int magic;
|
||||||
int rank;
|
int rank;
|
||||||
int type;
|
int type;
|
||||||
int *dim;
|
int64_t *dim;
|
||||||
char *format;
|
char *format;
|
||||||
union {
|
union {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
@ -53,7 +53,7 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
pNXDS createNXDataset(int rank, int typecode, int dim[]);
|
pNXDS createNXDataset(int rank, int typecode, int64_t dim[]);
|
||||||
pNXDS createTextNXDataset(char *name);
|
pNXDS createTextNXDataset(char *name);
|
||||||
|
|
||||||
void dropNXDataset(pNXDS dataset);
|
void dropNXDataset(pNXDS dataset);
|
||||||
@ -64,14 +64,14 @@ int getNXDatasetType(pNXDS dataset);
|
|||||||
int getNXDatasetLength(pNXDS dataset);
|
int getNXDatasetLength(pNXDS dataset);
|
||||||
int getNXDatasetByteLength(pNXDS dataset);
|
int getNXDatasetByteLength(pNXDS dataset);
|
||||||
|
|
||||||
double getNXDatasetValue(pNXDS dataset, int pos[]);
|
double getNXDatasetValue(pNXDS dataset, int64_t pos[]);
|
||||||
double getNXDatasetValueAt(pNXDS dataset, int address);
|
double getNXDatasetValueAt(pNXDS dataset, int64_t address);
|
||||||
char *getNXDatasetText(pNXDS dataset);
|
char *getNXDatasetText(pNXDS dataset);
|
||||||
|
|
||||||
int putNXDatasetValue(pNXDS dataset, int pos[], double value);
|
int putNXDatasetValue(pNXDS dataset, int64_t pos[], double value);
|
||||||
int putNXDatasetValueAt(pNXDS dataset, int address, 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);
|
pNXDS sumNXDataset(pNXDS source, int dimNo, int start, int end);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
105
nxdict.c
105
nxdict.c
@ -47,8 +47,7 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
Things defined in napi.c for error reporting
|
Things defined in napi.c for error reporting
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
extern void *NXpData;
|
static void *NXpData = NULL;
|
||||||
extern void (*NXIReportError) (void *pData, char *pBuffer);
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
/* #define DEFDEBUG 1 */
|
/* #define DEFDEBUG 1 */
|
||||||
/* define DEFDEBUG when you wish to print your definition strings before
|
/* 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 */
|
/* check for existence of the NXDICT string in the file */
|
||||||
if (strncmp(pNew, "##NXDICT-1.0", 12) != 0) {
|
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);
|
free(pNew);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -256,11 +255,11 @@ NXstatus NXDinitfromfile(char *filename, NXdict * pData)
|
|||||||
|
|
||||||
/* allocate a new NXdict structure */
|
/* allocate a new NXdict structure */
|
||||||
if (iVerbosity == NXalot) {
|
if (iVerbosity == NXalot) {
|
||||||
NXIReportError(NXpData, "Allocating new NXdict structure ");
|
NXReportError("Allocating new NXdict structure ");
|
||||||
}
|
}
|
||||||
pNew = (NXdict) malloc(sizeof(sNXdict));
|
pNew = (NXdict) malloc(sizeof(sNXdict));
|
||||||
if (!pNew) {
|
if (!pNew) {
|
||||||
NXIReportError(NXpData, "Insufficient memory for creation of NXdict");
|
NXReportError("Insufficient memory for creation of NXdict");
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +267,7 @@ NXstatus NXDinitfromfile(char *filename, NXdict * pData)
|
|||||||
pNew->iID = NXDMAGIC;
|
pNew->iID = NXDMAGIC;
|
||||||
pNew->pDictionary = CreateStringDict();
|
pNew->pDictionary = CreateStringDict();
|
||||||
if (!pNew->pDictionary) {
|
if (!pNew->pDictionary) {
|
||||||
NXIReportError(NXpData, "Insufficient memory for creation of NXdict");
|
NXReportError("Insufficient memory for creation of NXdict");
|
||||||
free(pNew);
|
free(pNew);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
@ -278,7 +277,7 @@ NXstatus NXDinitfromfile(char *filename, NXdict * pData)
|
|||||||
/* is there a file name argument */
|
/* is there a file name argument */
|
||||||
if (filename == NULL) {
|
if (filename == NULL) {
|
||||||
if (iVerbosity == NXalot) {
|
if (iVerbosity == NXalot) {
|
||||||
NXIReportError(NXpData, "NXDinitfrom file finished without data");
|
NXReportError("NXDinitfrom file finished without data");
|
||||||
}
|
}
|
||||||
*pData = pNew;
|
*pData = pNew;
|
||||||
return NX_OK;
|
return NX_OK;
|
||||||
@ -288,8 +287,8 @@ NXstatus NXDinitfromfile(char *filename, NXdict * pData)
|
|||||||
fd = fopen(filename, "rb");
|
fd = fopen(filename, "rb");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
sprintf(pError, "ERROR: file %s NOT found ", filename);
|
sprintf(pError, "ERROR: file %s NOT found ", filename);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
NXIReportError(NXpData, "NXDinitfrom file finished without data");
|
NXReportError("NXDinitfrom file finished without data");
|
||||||
*pData = pNew;
|
*pData = pNew;
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
@ -297,27 +296,27 @@ NXstatus NXDinitfromfile(char *filename, NXdict * pData)
|
|||||||
|
|
||||||
/* read the file contents */
|
/* read the file contents */
|
||||||
if (iVerbosity == NXalot) {
|
if (iVerbosity == NXalot) {
|
||||||
NXIReportError(NXpData, "NXDinitfrom: reading file");
|
NXReportError("NXDinitfrom: reading file");
|
||||||
}
|
}
|
||||||
pBuffer = NXDIReadFile(fd);
|
pBuffer = NXDIReadFile(fd);
|
||||||
fclose(fd); /* we are done with it then */
|
fclose(fd); /* we are done with it then */
|
||||||
if (!pBuffer) {
|
if (!pBuffer) {
|
||||||
sprintf(pError, "ERROR: reading file %s or no memory", filename);
|
sprintf(pError, "ERROR: reading file %s or no memory", filename);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
NXIReportError(NXpData, "NXDinitfrom file finished without data");
|
NXReportError("NXDinitfrom file finished without data");
|
||||||
*pData = pNew;
|
*pData = pNew;
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse it */
|
/* parse it */
|
||||||
if (iVerbosity == NXalot) {
|
if (iVerbosity == NXalot) {
|
||||||
NXIReportError(NXpData, "NXDinitfrom: parsing dictionary definitions");
|
NXReportError("NXDinitfrom: parsing dictionary definitions");
|
||||||
}
|
}
|
||||||
NXDIParse(pBuffer, pNew->pDictionary);
|
NXDIParse(pBuffer, pNew->pDictionary);
|
||||||
|
|
||||||
|
|
||||||
if (iVerbosity == NXalot) {
|
if (iVerbosity == NXalot) {
|
||||||
NXIReportError(NXpData, "NXDinitfrom: performed successfully");
|
NXReportError("NXDinitfrom: performed successfully");
|
||||||
}
|
}
|
||||||
free(pBuffer);
|
free(pBuffer);
|
||||||
*pData = pNew;
|
*pData = pNew;
|
||||||
@ -350,12 +349,12 @@ NXstatus NXDclose(NXdict handle, char *filename)
|
|||||||
if (filename) { /* we must write a file */
|
if (filename) { /* we must write a file */
|
||||||
if (iVerbosity == NXalot) {
|
if (iVerbosity == NXalot) {
|
||||||
sprintf(pValue, "Writing file %s", filename);
|
sprintf(pValue, "Writing file %s", filename);
|
||||||
NXIReportError(NXpData, pValue);
|
NXReportError(pValue);
|
||||||
}
|
}
|
||||||
fd = fopen(filename, "w");
|
fd = fopen(filename, "w");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
sprintf(pValue, "ERROR: opening file %s for write", filename);
|
sprintf(pValue, "ERROR: opening file %s for write", filename);
|
||||||
NXIReportError(NXpData, pValue);
|
NXReportError(pValue);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,7 +370,7 @@ NXstatus NXDclose(NXdict handle, char *filename)
|
|||||||
fclose(fd);
|
fclose(fd);
|
||||||
if (iVerbosity == NXalot) {
|
if (iVerbosity == NXalot) {
|
||||||
sprintf(pValue, "File %s written", filename);
|
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 */
|
/* create a dynamic string */
|
||||||
pReplaced = CreateDynString(strlen(pDefString), 512);
|
pReplaced = CreateDynString(strlen(pDefString), 512);
|
||||||
if (!pReplaced) {
|
if (!pReplaced) {
|
||||||
NXIReportError(NXpData, "ERROR: out of memory in NXDtextreplace");
|
NXReportError("ERROR: out of memory in NXDtextreplace");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,8 +478,7 @@ pDynString NXDItextreplace(NXdict handle, char *pDefString)
|
|||||||
pBueffel[iPos] = *pPtr;
|
pBueffel[iPos] = *pPtr;
|
||||||
iPos++;
|
iPos++;
|
||||||
if (iPos >= 1024) {
|
if (iPos >= 1024) {
|
||||||
NXIReportError(NXpData,
|
NXReportError("ERROR: buffer overrun in NXDItextreplace");
|
||||||
"ERROR: buffer overrun in NXDItextreplace");
|
|
||||||
DeleteDynString(pReplaced);
|
DeleteDynString(pReplaced);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -737,7 +735,7 @@ int NXDIParsePath(NXhandle hfil, ParDat * pParse)
|
|||||||
if (pParse->iToken != DWORD) {
|
if (pParse->iToken != DWORD) {
|
||||||
sprintf(pError, "ERROR: parse error at %s, expected vGroup name",
|
sprintf(pError, "ERROR: parse error at %s, expected vGroup name",
|
||||||
pParse->pToken);
|
pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
strcpy(pName, pParse->pToken);
|
strcpy(pName, pParse->pToken);
|
||||||
@ -747,7 +745,7 @@ int NXDIParsePath(NXhandle hfil, ParDat * pParse)
|
|||||||
if (pParse->iToken != DKOMMA) {
|
if (pParse->iToken != DKOMMA) {
|
||||||
sprintf(pError, "ERROR: parse error at %s, expected komma",
|
sprintf(pError, "ERROR: parse error at %s, expected komma",
|
||||||
pParse->pToken);
|
pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,7 +754,7 @@ int NXDIParsePath(NXhandle hfil, ParDat * pParse)
|
|||||||
if (pParse->iToken != DWORD) {
|
if (pParse->iToken != DWORD) {
|
||||||
sprintf(pError, "ERROR: parse error at %s, expected vGroup class",
|
sprintf(pError, "ERROR: parse error at %s, expected vGroup class",
|
||||||
pParse->pToken);
|
pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
strcpy(pClass, pParse->pToken);
|
strcpy(pClass, pParse->pToken);
|
||||||
@ -789,7 +787,7 @@ int NXDIParsePath(NXhandle hfil, ParDat * pParse)
|
|||||||
} else {
|
} else {
|
||||||
/* this is an error */
|
/* this is an error */
|
||||||
sprintf(pError, "ERROR: vGroup %s, %s NOT found", pName, pClass);
|
sprintf(pError, "ERROR: vGroup %s, %s NOT found", pName, pClass);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -809,7 +807,7 @@ static int NXDIParseAttr(ParDat * pParse, int iList)
|
|||||||
NXDIDefToken(pParse);
|
NXDIDefToken(pParse);
|
||||||
if (pParse->iToken != DOPEN) {
|
if (pParse->iToken != DOPEN) {
|
||||||
sprintf(pError, "ERROR: expected {, got %s", pParse->pToken);
|
sprintf(pError, "ERROR: expected {, got %s", pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,7 +816,7 @@ static int NXDIParseAttr(ParDat * pParse, int iList)
|
|||||||
if (pParse->iToken != DWORD) {
|
if (pParse->iToken != DWORD) {
|
||||||
sprintf(pError, "ERROR: expected attribute name, got %s",
|
sprintf(pError, "ERROR: expected attribute name, got %s",
|
||||||
pParse->pToken);
|
pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
strcpy(sAtt.name, pParse->pToken);
|
strcpy(sAtt.name, pParse->pToken);
|
||||||
@ -827,7 +825,7 @@ static int NXDIParseAttr(ParDat * pParse, int iList)
|
|||||||
NXDIDefToken(pParse);
|
NXDIDefToken(pParse);
|
||||||
if (pParse->iToken != DKOMMA) {
|
if (pParse->iToken != DKOMMA) {
|
||||||
sprintf(pError, "ERROR: expected , , got %s", pParse->pToken);
|
sprintf(pError, "ERROR: expected , , got %s", pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,7 +834,7 @@ static int NXDIParseAttr(ParDat * pParse, int iList)
|
|||||||
if (pParse->iToken != DWORD) {
|
if (pParse->iToken != DWORD) {
|
||||||
sprintf(pError, "ERROR: expected attribute value, got %s",
|
sprintf(pError, "ERROR: expected attribute value, got %s",
|
||||||
pParse->pToken);
|
pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
strcpy(sAtt.value, pParse->pToken);
|
strcpy(sAtt.value, pParse->pToken);
|
||||||
@ -845,7 +843,7 @@ static int NXDIParseAttr(ParDat * pParse, int iList)
|
|||||||
NXDIDefToken(pParse);
|
NXDIDefToken(pParse);
|
||||||
if (pParse->iToken != DCLOSE) {
|
if (pParse->iToken != DCLOSE) {
|
||||||
sprintf(pError, "ERROR: expected }, got %s", pParse->pToken);
|
sprintf(pError, "ERROR: expected }, got %s", pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -868,7 +866,7 @@ static int NXDIParseDim(ParDat * pParse, int *iDim)
|
|||||||
NXDIDefToken(pParse);
|
NXDIDefToken(pParse);
|
||||||
if (pParse->iToken != DOPEN) {
|
if (pParse->iToken != DOPEN) {
|
||||||
sprintf(pError, "ERROR: expected {, got %s", pParse->pToken);
|
sprintf(pError, "ERROR: expected {, got %s", pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -878,7 +876,7 @@ static int NXDIParseDim(ParDat * pParse, int *iDim)
|
|||||||
NXDIDefToken(pParse);
|
NXDIDefToken(pParse);
|
||||||
if (pParse->iToken != DWORD) {
|
if (pParse->iToken != DWORD) {
|
||||||
sprintf(pError, "ERROR: expected number, got %s", pParse->pToken);
|
sprintf(pError, "ERROR: expected number, got %s", pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
iDim[i] = atoi(pParse->pToken);
|
iDim[i] = atoi(pParse->pToken);
|
||||||
@ -887,7 +885,7 @@ static int NXDIParseDim(ParDat * pParse, int *iDim)
|
|||||||
NXDIDefToken(pParse);
|
NXDIDefToken(pParse);
|
||||||
if ((pParse->iToken != DKOMMA) && (pParse->iToken != DCLOSE)) {
|
if ((pParse->iToken != DKOMMA) && (pParse->iToken != DCLOSE)) {
|
||||||
sprintf(pError, "ERROR: expected , or }, got %s", pParse->pToken);
|
sprintf(pError, "ERROR: expected , or }, got %s", pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError( pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
if (pParse->iToken == DCLOSE) {
|
if (pParse->iToken == DCLOSE) {
|
||||||
@ -930,7 +928,7 @@ static int NXDIParseType(ParDat * pParse, int *iType)
|
|||||||
NXDIDefToken(pParse);
|
NXDIDefToken(pParse);
|
||||||
if (pParse->iToken != DWORD) {
|
if (pParse->iToken != DWORD) {
|
||||||
sprintf(pError, "ERROR: expected data type, got %s", pParse->pToken);
|
sprintf(pError, "ERROR: expected data type, got %s", pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -947,7 +945,7 @@ static int NXDIParseType(ParDat * pParse, int *iType)
|
|||||||
*/
|
*/
|
||||||
sprintf(pError, "ERROR: %s not recognized as valid data type",
|
sprintf(pError, "ERROR: %s not recognized as valid data type",
|
||||||
pParse->pToken);
|
pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -972,7 +970,7 @@ static int NXDIParseSDS(NXhandle hfil, ParDat * pParse)
|
|||||||
if (pParse->iToken != DWORD) {
|
if (pParse->iToken != DWORD) {
|
||||||
sprintf(pError, "ERROR: parsing, expected name, got %s",
|
sprintf(pError, "ERROR: parsing, expected name, got %s",
|
||||||
pParse->pToken);
|
pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
strcpy(pName, pParse->pToken);
|
strcpy(pName, pParse->pToken);
|
||||||
@ -980,7 +978,7 @@ static int NXDIParseSDS(NXhandle hfil, ParDat * pParse)
|
|||||||
/* create the attribute list */
|
/* create the attribute list */
|
||||||
iList = LLDcreate(sizeof(AttItem));
|
iList = LLDcreate(sizeof(AttItem));
|
||||||
if (iList < 0) {
|
if (iList < 0) {
|
||||||
NXIReportError(NXpData, "ERROR: cannot create list in NXDIParseSDS");
|
NXReportError("ERROR: cannot create list in NXDIParseSDS");
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -991,7 +989,7 @@ static int NXDIParseSDS(NXhandle hfil, ParDat * pParse)
|
|||||||
NXDIDefToken(pParse); /* advance */
|
NXDIDefToken(pParse); /* advance */
|
||||||
if (pParse->iToken != DWORD) {
|
if (pParse->iToken != DWORD) {
|
||||||
sprintf(pError, "ERROR: expected int, got %s", pParse->pToken);
|
sprintf(pError, "ERROR: expected int, got %s", pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
LLDdelete(iList);
|
LLDdelete(iList);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
@ -1039,7 +1037,7 @@ static int NXDIParseSDS(NXhandle hfil, ParDat * pParse)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(pError, "ERROR: cannot identify token %s", pParse->pToken);
|
sprintf(pError, "ERROR: cannot identify token %s", pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
LLDdelete(iList);
|
LLDdelete(iList);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
|
|
||||||
@ -1107,7 +1105,7 @@ static int NXDIParseSDS(NXhandle hfil, ParDat * pParse)
|
|||||||
} else {
|
} else {
|
||||||
/* this is an error */
|
/* this is an error */
|
||||||
sprintf(pError, "ERROR: SDS %s NOT found", pName);
|
sprintf(pError, "ERROR: SDS %s NOT found", pName);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
LLDdelete(iList);
|
LLDdelete(iList);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
@ -1125,7 +1123,7 @@ static int NXDIParseLink(NXhandle hfil, NXdict pDict, ParDat * pParse)
|
|||||||
NXDIDefToken(pParse);
|
NXDIDefToken(pParse);
|
||||||
if (pParse->iToken != DCLOSE) {
|
if (pParse->iToken != DCLOSE) {
|
||||||
sprintf(pError, "ERROR: expected alias , got %s", pParse->pToken);
|
sprintf(pError, "ERROR: expected alias , got %s", pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1181,7 +1179,7 @@ int NXDIDefParse(NXhandle hFil, NXdict pDict, ParDat * pParse)
|
|||||||
sprintf(pError,
|
sprintf(pError,
|
||||||
"ERROR: Definition String parse error: %s not permitted here",
|
"ERROR: Definition String parse error: %s not permitted here",
|
||||||
pParse->pToken);
|
pParse->pToken);
|
||||||
NXIReportError(NXpData, pError);
|
NXReportError(pError);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1240,7 +1238,7 @@ NXstatus NXDopenalias(NXhandle hfil, NXdict dict, char *pAlias)
|
|||||||
iRet = NXDget(pDict, pAlias, pDefinition, 2047);
|
iRet = NXDget(pDict, pAlias, pDefinition, 2047);
|
||||||
if (iRet != NX_OK) {
|
if (iRet != NX_OK) {
|
||||||
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
||||||
NXIReportError(NXpData, pDefinition);
|
NXReportError(pDefinition);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1281,7 +1279,7 @@ NXstatus NXDputdef(NXhandle hFil, NXdict dict, char *pDef, void *pData)
|
|||||||
|
|
||||||
/* only SDS can be written */
|
/* only SDS can be written */
|
||||||
if (pParse.iTerminal != TERMSDS) {
|
if (pParse.iTerminal != TERMSDS) {
|
||||||
NXIReportError(NXpData, "ERROR: can only write to an SDS!");
|
NXReportError("ERROR: can only write to an SDS!");
|
||||||
iStat = NX_ERROR;
|
iStat = NX_ERROR;
|
||||||
} else {
|
} else {
|
||||||
/* the SDS should be open by now, write it */
|
/* 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);
|
iRet = NXDget(pDict, pAlias, pDefinition, 2047);
|
||||||
if (iRet != NX_OK) {
|
if (iRet != NX_OK) {
|
||||||
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
||||||
NXIReportError(NXpData, pDefinition);
|
NXReportError( pDefinition);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1354,7 +1352,7 @@ NXstatus NXDgetdef(NXhandle hFil, NXdict dict, char *pDef, void *pData)
|
|||||||
|
|
||||||
/* only SDS can be written */
|
/* only SDS can be written */
|
||||||
if (pParse.iTerminal != TERMSDS) {
|
if (pParse.iTerminal != TERMSDS) {
|
||||||
NXIReportError(NXpData, "ERROR: can only write to an SDS!");
|
NXReportError("ERROR: can only write to an SDS!");
|
||||||
iStat = NX_ERROR;
|
iStat = NX_ERROR;
|
||||||
} else {
|
} else {
|
||||||
/* the SDS should be open by now, read it */
|
/* 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);
|
iRet = NXDget(pDict, pAlias, pDefinition, 2047);
|
||||||
if (iRet != NX_OK) {
|
if (iRet != NX_OK) {
|
||||||
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
||||||
NXIReportError(NXpData, pDefinition);
|
NXReportError(pDefinition);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1429,7 +1427,7 @@ NXstatus NXDinfodef(NXhandle hFil, NXdict dict, char *pDef, int *rank,
|
|||||||
|
|
||||||
/* only SDS can be written */
|
/* only SDS can be written */
|
||||||
if (pParse.iTerminal != TERMSDS) {
|
if (pParse.iTerminal != TERMSDS) {
|
||||||
NXIReportError(NXpData, "ERROR: can only write to an SDS!");
|
NXReportError("ERROR: can only write to an SDS!");
|
||||||
iStat = NX_ERROR;
|
iStat = NX_ERROR;
|
||||||
} else {
|
} else {
|
||||||
/* the SDS should be open by now, read it */
|
/* 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);
|
iRet = NXDget(pDict, pAlias, pDefinition, 2047);
|
||||||
if (iRet != NX_OK) {
|
if (iRet != NX_OK) {
|
||||||
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
sprintf(pDefinition, "ERROR: alias %s not recognized", pAlias);
|
||||||
NXIReportError(NXpData, pDefinition);
|
NXReportError(pDefinition);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1540,7 +1538,7 @@ NXstatus NXDdeflink(NXhandle hFil, NXdict dict,
|
|||||||
}
|
}
|
||||||
/* check it being a vGroup! */
|
/* check it being a vGroup! */
|
||||||
if (pParseT.iTerminal != TERMVG) {
|
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);
|
NXDIUnwind(hFil, pParseT.iDepth);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
@ -1570,7 +1568,7 @@ NXstatus NXDaliaslink(NXhandle hFil, NXdict dict,
|
|||||||
iRet = NXDget(pDict, pTarget, pTargetDef, 2047);
|
iRet = NXDget(pDict, pTarget, pTargetDef, 2047);
|
||||||
if (iRet != NX_OK) {
|
if (iRet != NX_OK) {
|
||||||
sprintf(pTargetDef, "ERROR: alias %s not recognized", pTarget);
|
sprintf(pTargetDef, "ERROR: alias %s not recognized", pTarget);
|
||||||
NXIReportError(NXpData, pTargetDef);
|
NXReportError(pTargetDef);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1578,7 +1576,7 @@ NXstatus NXDaliaslink(NXhandle hFil, NXdict dict,
|
|||||||
iRet = NXDget(pDict, pVictim, pVictimDef, 2047);
|
iRet = NXDget(pDict, pVictim, pVictimDef, 2047);
|
||||||
if (iRet != NX_OK) {
|
if (iRet != NX_OK) {
|
||||||
sprintf(pTargetDef, "ERROR: alias %s not recognized", pTarget);
|
sprintf(pTargetDef, "ERROR: alias %s not recognized", pTarget);
|
||||||
NXIReportError(NXpData, pTargetDef);
|
NXReportError(pTargetDef);
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1800,8 +1798,7 @@ NXstatus NXUallocSDS(NXhandle hFil, void **pData)
|
|||||||
lLength *= sizeof(int);
|
lLength *= sizeof(int);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
NXIReportError(NXpData,
|
NXReportError("ERROR: Internal: number type not recoginized");
|
||||||
"ERROR: Internal: number type not recoginized");
|
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1809,7 +1806,7 @@ NXstatus NXUallocSDS(NXhandle hFil, void **pData)
|
|||||||
*pData = NULL;
|
*pData = NULL;
|
||||||
*pData = malloc(lLength);
|
*pData = malloc(lLength);
|
||||||
if (*pData == NULL) {
|
if (*pData == NULL) {
|
||||||
NXIReportError(NXpData, "ERROR: memory exhausted in NXUallocSDS");
|
NXReportError("ERROR: memory exhausted in NXUallocSDS");
|
||||||
return NX_ERROR;
|
return NX_ERROR;
|
||||||
}
|
}
|
||||||
memset(*pData, 0, lLength);
|
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,
|
void *create_nxds(int rank, int type, int dim0, int dim1, int dim2,
|
||||||
int dim3, int dim4, int dim5, int dim6)
|
int dim3, int dim4, int dim5, int dim6)
|
||||||
{
|
{
|
||||||
int dim[MAXDIM], i;
|
int64_t dim[MAXDIM], i;
|
||||||
|
|
||||||
dim[0] = dim0;
|
dim[0] = dim0;
|
||||||
dim[1] = dim1;
|
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,
|
double get_nxds_value(void *ptr, int dim0, int dim1, int dim2,
|
||||||
int dim3, int dim4, int dim5, int dim6)
|
int dim3, int dim4, int dim5, int dim6)
|
||||||
{
|
{
|
||||||
int dim[MAXDIM];
|
int64_t dim[MAXDIM];
|
||||||
|
|
||||||
dim[0] = dim0;
|
dim[0] = dim0;
|
||||||
dim[1] = dim1;
|
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 put_nxds_value(void *ptr, double value, int dim0, int dim1, int dim2,
|
||||||
int dim3, int dim4, int dim5, int dim6)
|
int dim3, int dim4, int dim5, int dim6)
|
||||||
{
|
{
|
||||||
int dim[MAXDIM];
|
int64_t dim[MAXDIM];
|
||||||
|
|
||||||
dim[0] = dim0;
|
dim[0] = dim0;
|
||||||
dim[1] = dim1;
|
dim[1] = dim1;
|
||||||
|
@ -314,6 +314,7 @@ void *nx_getslab(void *handle, void *startdim, void *sizedim)
|
|||||||
pNXDS resultdata;
|
pNXDS resultdata;
|
||||||
pNXDS start, size;
|
pNXDS start, size;
|
||||||
int status, rank, type, dim[NX_MAXRANK];
|
int status, rank, type, dim[NX_MAXRANK];
|
||||||
|
int64_t cdim[NX_MAXRANK], i;
|
||||||
NXhandle hfil;
|
NXhandle hfil;
|
||||||
|
|
||||||
hfil = (NXhandle) handle;
|
hfil = (NXhandle) handle;
|
||||||
@ -328,7 +329,10 @@ void *nx_getslab(void *handle, void *startdim, void *sizedim)
|
|||||||
return NULL;
|
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) {
|
if (resultdata == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -346,7 +350,8 @@ void *nx_getslab(void *handle, void *startdim, void *sizedim)
|
|||||||
void *nx_getds(void *handle, char *name)
|
void *nx_getds(void *handle, char *name)
|
||||||
{
|
{
|
||||||
pNXDS result = NULL;
|
pNXDS result = NULL;
|
||||||
int rank, type, dim[NX_MAXRANK], status;
|
int rank, type,status;
|
||||||
|
int64_t dim[NX_MAXRANK];
|
||||||
NXhandle hfil;
|
NXhandle hfil;
|
||||||
|
|
||||||
hfil = (NXhandle) handle;
|
hfil = (NXhandle) handle;
|
||||||
@ -355,7 +360,7 @@ void *nx_getds(void *handle, char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = NXgetinfo(hfil, &rank, dim, &type);
|
status = NXgetinfo64(hfil, &rank, dim, &type);
|
||||||
if (status != NX_OK) {
|
if (status != NX_OK) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -388,7 +393,7 @@ int nx_putds(void *handle, char *name, void *dataset)
|
|||||||
|
|
||||||
status = NXopendata(hfil, name);
|
status = NXopendata(hfil, name);
|
||||||
if (status != NX_OK) {
|
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) {
|
if (status != NX_OK) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -408,12 +413,13 @@ int nx_putds(void *handle, char *name, void *dataset)
|
|||||||
void *nx_getdata(void *handle)
|
void *nx_getdata(void *handle)
|
||||||
{
|
{
|
||||||
pNXDS result = NULL;
|
pNXDS result = NULL;
|
||||||
int rank, type, dim[NX_MAXRANK], status;
|
int rank, type, status;
|
||||||
|
int64_t dim[NX_MAXRANK];
|
||||||
NXhandle hfil;
|
NXhandle hfil;
|
||||||
|
|
||||||
|
|
||||||
hfil = (NXhandle) handle;
|
hfil = (NXhandle) handle;
|
||||||
status = NXgetinfo(hfil, &rank, dim, &type);
|
status = NXgetinfo64(hfil, &rank, dim, &type);
|
||||||
if (status != NX_OK) {
|
if (status != NX_OK) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -459,7 +465,8 @@ int nx_putdata(void *handle, void *dataset)
|
|||||||
void *nx_getinfo(void *handle)
|
void *nx_getinfo(void *handle)
|
||||||
{
|
{
|
||||||
NXhandle hfil;
|
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;
|
pNXDS data = NULL;
|
||||||
|
|
||||||
hfil = (NXhandle) handle;
|
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)
|
void *nx_getattr(void *handle, char *name, int type, int length)
|
||||||
{
|
{
|
||||||
NXhandle hfil;
|
NXhandle hfil;
|
||||||
int status, tp, ll, dim[1];
|
int status, tp, ll;
|
||||||
|
int64_t dim[1];
|
||||||
pNXDS data = NULL;
|
pNXDS data = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
263
nxio.c
263
nxio.c
@ -21,8 +21,11 @@
|
|||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 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>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef NXXML
|
||||||
|
|
||||||
#include <mxml.h>
|
#include <mxml.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "napi.h"
|
#include "napi.h"
|
||||||
@ -35,6 +38,10 @@
|
|||||||
#define MXML_WRAP 79
|
#define MXML_WRAP 79
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define snprintf _snprintf
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
/* #define TESTMAIN 1 */
|
/* #define TESTMAIN 1 */
|
||||||
/*=================== type code handling ================================= */
|
/*=================== type code handling ================================= */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -46,8 +53,7 @@ typedef struct {
|
|||||||
#define NTYPECODE 11
|
#define NTYPECODE 11
|
||||||
static type_code typecode[NTYPECODE];
|
static type_code typecode[NTYPECODE];
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
void initializeNumberFormats()
|
void initializeNumberFormats(){
|
||||||
{
|
|
||||||
type_code myCode;
|
type_code myCode;
|
||||||
|
|
||||||
strcpy(myCode.name,"NX_FLOAT32");
|
strcpy(myCode.name,"NX_FLOAT32");
|
||||||
@ -91,12 +97,12 @@ void initializeNumberFormats()
|
|||||||
typecode[7] = myCode;
|
typecode[7] = myCode;
|
||||||
|
|
||||||
strcpy(myCode.name,"NX_INT64");
|
strcpy(myCode.name,"NX_INT64");
|
||||||
strcpy(myCode.format, "%24" PRINTF_INT64);
|
strcpy(myCode.format,"%24lld");
|
||||||
myCode.nx_type = NX_INT64;
|
myCode.nx_type = NX_INT64;
|
||||||
typecode[8] = myCode;
|
typecode[8] = myCode;
|
||||||
|
|
||||||
strcpy(myCode.name,"NX_UINT64");
|
strcpy(myCode.name,"NX_UINT64");
|
||||||
strcpy(myCode.format, "%24" PRINTF_UINT64);
|
strcpy(myCode.format,"%24llu");
|
||||||
myCode.nx_type = NX_UINT64;
|
myCode.nx_type = NX_UINT64;
|
||||||
typecode[9] = myCode;
|
typecode[9] = myCode;
|
||||||
|
|
||||||
@ -105,10 +111,8 @@ void initializeNumberFormats()
|
|||||||
myCode.nx_type = NX_CHAR;
|
myCode.nx_type = NX_CHAR;
|
||||||
typecode[10] = myCode;
|
typecode[10] = myCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
void setNumberFormat(int nx_type, char *format)
|
void setNumberFormat(int nx_type, char *format){
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < NTYPECODE; i++){
|
for(i = 0; i < NTYPECODE; i++){
|
||||||
@ -117,10 +121,8 @@ void setNumberFormat(int nx_type, char *format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
static void getNumberFormat(int nx_type, char format[30])
|
static void getNumberFormat(int nx_type, char format[30]){
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < NTYPECODE; i++){
|
for(i = 0; i < NTYPECODE; i++){
|
||||||
@ -129,10 +131,8 @@ static void getNumberFormat(int nx_type, char format[30])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
/*----------------------------------------------------------------*/
|
||||||
void getNumberText(int nx_type, char *typestring, int typeLen)
|
void getNumberText(int nx_type, char *typestring, int typeLen){
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < NTYPECODE; i++){
|
for(i = 0; i < NTYPECODE; i++){
|
||||||
@ -141,30 +141,33 @@ void getNumberText(int nx_type, char *typestring, int typeLen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 'mxml_add_char()' - Add a character to a buffer, expanding as needed.
|
* '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
|
* copied here from mxml-file.c to achieve compatibility with mxml-2.1
|
||||||
* standard
|
* standard
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int /* O - 0 on success, -1 on error */ myxml_add_char(int ch, /* I - Character to add */
|
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 **bufptr, /* IO - Current position in buffer */
|
||||||
char **buffer, /* IO - Current buffer */
|
char **buffer, /* IO - Current buffer */
|
||||||
int
|
size_t *bufsize) /* IO - Current buffer size */
|
||||||
*bufsize)
|
{
|
||||||
{ /* IO - Current buffer size */
|
|
||||||
char *newbuffer; /* New buffer value */
|
char *newbuffer; /* New buffer value */
|
||||||
|
|
||||||
|
|
||||||
if (*bufptr >= (*buffer + *bufsize - 4)) {
|
if (*bufptr >= (*buffer + *bufsize - 4))
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Increase the size of the buffer...
|
* Increase the size of the buffer...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (*bufsize < 1024) {
|
if (*bufsize < 1024)
|
||||||
|
{
|
||||||
(*bufsize) *= 2;
|
(*bufsize) *= 2;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
(*bufsize) *= 3;
|
(*bufsize) *= 3;
|
||||||
(*bufsize) /= 2;
|
(*bufsize) /= 2;
|
||||||
}
|
}
|
||||||
@ -185,20 +188,25 @@ static int /* O - 0 on success, -1 on error */ myxml_add_char(int ch, /* I -
|
|||||||
*buffer = newbuffer;
|
*buffer = newbuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch < 128) {
|
if (ch < 128)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Single byte ASCII...
|
* Single byte ASCII...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*(*bufptr)++ = ch;
|
*(*bufptr)++ = ch;
|
||||||
} else if (ch < 2048) {
|
}
|
||||||
|
else if (ch < 2048)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Two-byte UTF-8...
|
* Two-byte UTF-8...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*(*bufptr)++ = 0xc0 | (ch >> 6);
|
*(*bufptr)++ = 0xc0 | (ch >> 6);
|
||||||
*(*bufptr)++ = 0x80 | (ch & 0x3f);
|
*(*bufptr)++ = 0x80 | (ch & 0x3f);
|
||||||
} else if (ch < 65536) {
|
}
|
||||||
|
else if (ch < 65536)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Three-byte UTF-8...
|
* Three-byte UTF-8...
|
||||||
*/
|
*/
|
||||||
@ -206,7 +214,9 @@ static int /* O - 0 on success, -1 on error */ myxml_add_char(int ch, /* I -
|
|||||||
*(*bufptr)++ = 0xe0 | (ch >> 12);
|
*(*bufptr)++ = 0xe0 | (ch >> 12);
|
||||||
*(*bufptr)++ = 0x80 | ((ch >> 6) & 0x3f);
|
*(*bufptr)++ = 0x80 | ((ch >> 6) & 0x3f);
|
||||||
*(*bufptr)++ = 0x80 | (ch & 0x3f);
|
*(*bufptr)++ = 0x80 | (ch & 0x3f);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Four-byte UTF-8...
|
* Four-byte UTF-8...
|
||||||
*/
|
*/
|
||||||
@ -219,20 +229,26 @@ static int /* O - 0 on success, -1 on error */ myxml_add_char(int ch, /* I -
|
|||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
extern char *stptok(char *s, char *tok, size_t toklen, char *brk);
|
extern char *stptok(char *s, char *tok, size_t toklen, char *brk);
|
||||||
/*=====================================================================
|
/*=====================================================================
|
||||||
actual stuff for implementing the callback functions
|
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 dimString[132];
|
||||||
char dim[20];
|
char dim[20];
|
||||||
char *dimStart, *dimEnd;
|
const char *dimStart, *dimEnd;
|
||||||
|
char* dimTemp;
|
||||||
int myRank;
|
int myRank;
|
||||||
|
|
||||||
if(strchr(typeString,(int)'[') == NULL){
|
if(strchr(typeString,(int)'[') == NULL){
|
||||||
|
*rank = 1;
|
||||||
switch(*type){
|
switch(*type){
|
||||||
case NX_INT8:
|
case NX_INT8:
|
||||||
case NX_UINT8:
|
case NX_UINT8:
|
||||||
@ -247,7 +263,10 @@ void analyzeDim(const char *typeString, int *rank, int *iDim, int *type)
|
|||||||
iDim[0] = 1;
|
iDim[0] = 1;
|
||||||
break;
|
break;
|
||||||
case NX_CHAR:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -267,20 +286,18 @@ void analyzeDim(const char *typeString, int *rank, int *iDim, int *type)
|
|||||||
}
|
}
|
||||||
memset(dimString,0,132);
|
memset(dimString,0,132);
|
||||||
memcpy(dimString,dimStart,(dimEnd-dimStart)*sizeof(char));
|
memcpy(dimString,dimStart,(dimEnd-dimStart)*sizeof(char));
|
||||||
dimStart = stptok(dimString, dim, 19, ",");
|
dimTemp = stptok(dimString,dim,19,",");
|
||||||
myRank = 0;
|
myRank = 0;
|
||||||
while (dimStart != NULL) {
|
while(dimTemp != NULL){
|
||||||
iDim[myRank] = atoi(dim);
|
iDim[myRank] = atoi(dim);
|
||||||
dimStart = stptok(dimStart, dim, 19, ",");
|
dimTemp = stptok(dimTemp,dim,19,",");
|
||||||
myRank++;
|
myRank++;
|
||||||
}
|
}
|
||||||
*rank = myRank;
|
*rank = myRank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
int translateTypeCode(char *code)
|
int translateTypeCode(const char *code){
|
||||||
{
|
|
||||||
int i, result = -1;
|
int i, result = -1;
|
||||||
|
|
||||||
for(i = 0; i < NTYPECODE; i++){
|
for(i = 0; i < NTYPECODE; i++){
|
||||||
@ -292,13 +309,32 @@ int translateTypeCode(char *code)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*
|
||||||
static void analyzeDataType(mxml_node_t * parent, int *rank, int *type,
|
* This is used to locate an Idims node from the new style table data layout
|
||||||
int *iDim)
|
*/
|
||||||
|
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;
|
const char *typeString;
|
||||||
mxml_type_t myType;
|
mxml_node_t* tnode;
|
||||||
int i, nx_type = -1;
|
int nx_type = -1;
|
||||||
|
int table_mode = 0;
|
||||||
|
|
||||||
*rank = 1;
|
*rank = 1;
|
||||||
*type = NX_CHAR;
|
*type = NX_CHAR;
|
||||||
@ -307,6 +343,12 @@ static void analyzeDataType(mxml_node_t * parent, int *rank, int *type,
|
|||||||
/*
|
/*
|
||||||
get the type attribute. No attribute means: plain text
|
get the type attribute. No attribute means: plain text
|
||||||
*/
|
*/
|
||||||
|
tnode = findDimsNode(parent);
|
||||||
|
if (tnode != NULL)
|
||||||
|
{
|
||||||
|
table_mode = 1;
|
||||||
|
parent = tnode;
|
||||||
|
}
|
||||||
typeString = mxmlElementGetAttr(parent,TYPENAME);
|
typeString = mxmlElementGetAttr(parent,TYPENAME);
|
||||||
if(typeString == NULL){
|
if(typeString == NULL){
|
||||||
return;
|
return;
|
||||||
@ -318,8 +360,8 @@ static void analyzeDataType(mxml_node_t * parent, int *rank, int *type,
|
|||||||
assign type
|
assign type
|
||||||
*/
|
*/
|
||||||
if(nx_type == -1){
|
if(nx_type == -1){
|
||||||
mxml_error
|
mxml_error(
|
||||||
("ERROR: %s is an invalid NeXus type, I try to continue but may fail",
|
"ERROR: %s is an invalid NeXus type, I try to continue but may fail",
|
||||||
typeString);
|
typeString);
|
||||||
*type =NX_CHAR;
|
*type =NX_CHAR;
|
||||||
return;
|
return;
|
||||||
@ -328,19 +370,21 @@ static void analyzeDataType(mxml_node_t * parent, int *rank, int *type,
|
|||||||
*type = nx_type;
|
*type = nx_type;
|
||||||
|
|
||||||
analyzeDim(typeString, rank, iDim, type);
|
analyzeDim(typeString, rank, iDim, type);
|
||||||
}
|
if (table_mode)
|
||||||
|
|
||||||
/*-------------------------------------------------------------------*/
|
|
||||||
void destroyDataset(void *data)
|
|
||||||
{
|
{
|
||||||
|
*rank = 1;
|
||||||
|
iDim[0] = 1;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*-------------------------------------------------------------------*/
|
||||||
|
void destroyDataset(void *data){
|
||||||
if(data != NULL){
|
if(data != NULL){
|
||||||
dropNXDataset((pNXDS)data);
|
dropNXDataset((pNXDS)data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
static char *getNextNumber(char *pStart, char pNumber[80])
|
static char *getNextNumber(char *pStart, char pNumber[80]){
|
||||||
{
|
|
||||||
int charCount = 0;
|
int charCount = 0;
|
||||||
pNumber[0] = '\0';
|
pNumber[0] = '\0';
|
||||||
|
|
||||||
@ -361,16 +405,25 @@ static char *getNextNumber(char *pStart, char pNumber[80])
|
|||||||
pNumber[charCount] = '\0';
|
pNumber[charCount] = '\0';
|
||||||
return pStart;
|
return pStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
mxml_type_t nexusTypeCallback(mxml_node_t * parent)
|
mxml_type_t nexusTypeCallback(mxml_node_t *parent){
|
||||||
{
|
|
||||||
const char *typeString;
|
const char *typeString;
|
||||||
|
|
||||||
if(strstr(parent->value.element.name,"?xml") != NULL ||
|
if(strstr(parent->value.element.name,"?xml") != NULL ||
|
||||||
strstr(parent->value.element.name, "NX") != 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;
|
return MXML_ELEMENT;
|
||||||
} else {
|
} else {
|
||||||
|
/* 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);
|
typeString = mxmlElementGetAttr(parent,TYPENAME);
|
||||||
if(typeString == NULL){
|
if(typeString == NULL){
|
||||||
/*
|
/*
|
||||||
@ -387,20 +440,18 @@ mxml_type_t nexusTypeCallback(mxml_node_t * parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
int nexusLoadCallback(mxml_node_t * node, const char *buffer)
|
int nexusLoadCallback(mxml_node_t *node, const char *buffer){
|
||||||
{
|
|
||||||
mxml_node_t *parent = NULL;
|
mxml_node_t *parent = NULL;
|
||||||
int rank, type, iDim[NX_MAXRANK];
|
int rank, type;
|
||||||
|
int64_t iDim[NX_MAXRANK];
|
||||||
char pNumber[80], *pStart;
|
char pNumber[80], *pStart;
|
||||||
long address, maxAddress;
|
long address, maxAddress;
|
||||||
pNXDS dataset = NULL;
|
pNXDS dataset = NULL;
|
||||||
int i;
|
|
||||||
|
|
||||||
parent = node->parent;
|
parent = node->parent;
|
||||||
analyzeDataType(parent,&rank,&type,iDim);
|
analyzeDataType(parent,&rank,&type,iDim);
|
||||||
if (iDim[0] == -1) {
|
if(iDim[0] == -1 || !strcmp(parent->parent->value.element.name, DIMS_NODE_NAME)){
|
||||||
iDim[0] = strlen(buffer);
|
iDim[0] = strlen(buffer);
|
||||||
node->value.custom.data = strdup(buffer);
|
node->value.custom.data = strdup(buffer);
|
||||||
node->value.custom.destroy = free;
|
node->value.custom.destroy = free;
|
||||||
@ -429,22 +480,18 @@ int nexusLoadCallback(mxml_node_t * node, const char *buffer)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
static void stringIntoBuffer(char **buffer, char **bufPtr, int *bufSize,
|
static void stringIntoBuffer(char **buffer, char **bufPtr, size_t *bufSize,
|
||||||
char *string)
|
char *string){
|
||||||
{
|
size_t i;
|
||||||
int i;
|
|
||||||
|
|
||||||
for(i = 0; i < strlen(string); i++){
|
for(i = 0; i < strlen(string); i++){
|
||||||
myxml_add_char(string[i],bufPtr,buffer,bufSize);
|
myxml_add_char(string[i],bufPtr,buffer,bufSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
static void formatNumber(double value, char *txt, int txtLen,
|
static void formatNumber(double value, char *txt, int txtLen,
|
||||||
char *format, int type)
|
char *format, int type){
|
||||||
{
|
|
||||||
switch(type){
|
switch(type){
|
||||||
case NX_INT8:
|
case NX_INT8:
|
||||||
case NX_UINT8:
|
case NX_UINT8:
|
||||||
@ -470,10 +517,8 @@ static void formatNumber(double value, char *txt, int txtLen,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
static int countDepth(mxml_node_t * node)
|
static int countDepth(mxml_node_t *node){
|
||||||
{
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
mxml_node_t *cur;
|
mxml_node_t *cur;
|
||||||
|
|
||||||
@ -485,16 +530,22 @@ static int countDepth(mxml_node_t * node)
|
|||||||
count--;
|
count--;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
char *nexusWriteCallback(mxml_node_t * node)
|
char *nexusWriteCallback(mxml_node_t *node){
|
||||||
{
|
|
||||||
int type, col;
|
int type, col;
|
||||||
char pNumber[80], indent[80], format[30];
|
char pNumber[80], indent[80], format[30];
|
||||||
char *buffer, *bufPtr;
|
char *buffer, *bufPtr;
|
||||||
pNXDS dataset;
|
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
|
allocate output buffer
|
||||||
*/
|
*/
|
||||||
@ -522,7 +573,11 @@ char *nexusWriteCallback(mxml_node_t * node)
|
|||||||
get dataset info
|
get dataset info
|
||||||
*/
|
*/
|
||||||
type = getNXDatasetType(dataset);
|
type = getNXDatasetType(dataset);
|
||||||
|
if (is_definition) {
|
||||||
|
length = 1;
|
||||||
|
} else {
|
||||||
length = getNXDatasetLength(dataset);
|
length = getNXDatasetLength(dataset);
|
||||||
|
}
|
||||||
if(dataset->format != NULL){
|
if(dataset->format != NULL){
|
||||||
strcpy(format,dataset->format);
|
strcpy(format,dataset->format);
|
||||||
} else {
|
} else {
|
||||||
@ -532,12 +587,20 @@ char *nexusWriteCallback(mxml_node_t * node)
|
|||||||
/*
|
/*
|
||||||
actually get the data out
|
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;
|
currentLen = col;
|
||||||
myxml_add_char('\n',&bufPtr,&buffer,&bufsize);
|
myxml_add_char('\n',&bufPtr,&buffer,&bufsize);
|
||||||
stringIntoBuffer(&buffer,&bufPtr,&bufsize,indent);
|
stringIntoBuffer(&buffer,&bufPtr,&bufsize,indent);
|
||||||
for(i = 0; i < length; i++){
|
for(i = 0; i < length; i++){
|
||||||
formatNumber(getNXDatasetValueAt(dataset, i), pNumber, 79, format,
|
formatNumber(getNXDatasetValueAt(dataset,i),pNumber,79,format,type);
|
||||||
type);
|
|
||||||
if(currentLen + strlen(pNumber) > MXML_WRAP){
|
if(currentLen + strlen(pNumber) > MXML_WRAP){
|
||||||
/*
|
/*
|
||||||
wrap line
|
wrap line
|
||||||
@ -550,30 +613,32 @@ char *nexusWriteCallback(mxml_node_t * node)
|
|||||||
myxml_add_char(' ',&bufPtr,&buffer,&bufsize);
|
myxml_add_char(' ',&bufPtr,&buffer,&bufsize);
|
||||||
currentLen += strlen(pNumber) + 1;
|
currentLen += strlen(pNumber) + 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
myxml_add_char('\0',&bufPtr,&buffer,&bufsize);
|
myxml_add_char('\0',&bufPtr,&buffer,&bufsize);
|
||||||
return (char *)buffer;
|
return (char *)buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
int isDataNode(mxml_node_t * node)
|
int isDataNode(mxml_node_t *node){
|
||||||
{
|
|
||||||
if(mxmlElementGetAttr(node,"name") != NULL){
|
if(mxmlElementGetAttr(node,"name") != NULL){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(strcmp(node->value.element.name,"NXroot") == 0){
|
if(strcmp(node->value.element.name,"NXroot") == 0){
|
||||||
return 0;
|
return 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){
|
if(strcmp(node->value.element.name,"NAPIlink") == 0){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
static int isTextData(mxml_node_t * node)
|
static int isTextData(mxml_node_t *node){
|
||||||
{
|
|
||||||
const char *attr = NULL;
|
const char *attr = NULL;
|
||||||
int rank, type = 0, iDim[NX_MAXRANK];
|
|
||||||
|
|
||||||
if(!isDataNode(node)){
|
if(!isDataNode(node)){
|
||||||
return 0;
|
return 0;
|
||||||
@ -585,32 +650,38 @@ static int isTextData(mxml_node_t * node)
|
|||||||
if(attr == NULL){
|
if(attr == NULL){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
analyzeDim(attr, &rank, iDim, &type);
|
if(strstr(attr,"NX_CHAR") != NULL){
|
||||||
if (type == NX_CHAR) {
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* note: not reentrant or thead safe; returns pointer to static storage
|
* 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;
|
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;
|
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(isTextData(node)){
|
||||||
if(where == MXML_WS_BEFORE_OPEN){
|
if(where == MXML_WS_BEFORE_OPEN){
|
||||||
len = countDepth(node)*2 + 2;
|
len = countDepth(node)*2 + 2;
|
||||||
if (indent != NULL) {
|
if (indent != NULL)
|
||||||
|
{
|
||||||
free(indent);
|
free(indent);
|
||||||
indent = NULL;
|
indent = NULL;
|
||||||
}
|
}
|
||||||
@ -627,7 +698,8 @@ const char *NXwhitespaceCallback(mxml_node_t * node, int where)
|
|||||||
|
|
||||||
if(where == MXML_WS_BEFORE_OPEN || where == MXML_WS_BEFORE_CLOSE){
|
if(where == MXML_WS_BEFORE_OPEN || where == MXML_WS_BEFORE_CLOSE){
|
||||||
len = countDepth(node)*2 + 2;
|
len = countDepth(node)*2 + 2;
|
||||||
if (indent != NULL) {
|
if (indent != NULL)
|
||||||
|
{
|
||||||
free(indent);
|
free(indent);
|
||||||
indent = NULL;
|
indent = NULL;
|
||||||
}
|
}
|
||||||
@ -641,13 +713,11 @@ const char *NXwhitespaceCallback(mxml_node_t * node, int where)
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
#ifdef TESTMAIN
|
#ifdef TESTMAIN
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]){
|
||||||
{
|
|
||||||
mxml_node_t *root = NULL;
|
mxml_node_t *root = NULL;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
@ -672,3 +742,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*NXXML*/
|
||||||
|
10
nxio.h
10
nxio.h
@ -20,7 +20,7 @@
|
|||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 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
|
#ifndef __NXIO
|
||||||
@ -29,6 +29,9 @@
|
|||||||
|
|
||||||
#define TYPENAME "NAPItype"
|
#define TYPENAME "NAPItype"
|
||||||
|
|
||||||
|
#define DIMS_NODE_NAME "columns"
|
||||||
|
#define DATA_NODE_NAME "row"
|
||||||
|
|
||||||
mxml_type_t nexusTypeCallback(mxml_node_t *parent);
|
mxml_type_t nexusTypeCallback(mxml_node_t *parent);
|
||||||
const char *NXwhitespaceCallback(mxml_node_t *node, int where);
|
const char *NXwhitespaceCallback(mxml_node_t *node, int where);
|
||||||
int nexusLoadCallback(mxml_node_t *node, const char *buffer);
|
int nexusLoadCallback(mxml_node_t *node, const char *buffer);
|
||||||
@ -38,9 +41,10 @@ void setNumberFormat(int dataType, char *formatString);
|
|||||||
void initializeNumberFormats();
|
void initializeNumberFormats();
|
||||||
void getNumberText(int nx_type, char *typestring, int typeLen);
|
void getNumberText(int nx_type, char *typestring, int typeLen);
|
||||||
void destroyDataset(void *data);
|
void destroyDataset(void *data);
|
||||||
int translateTypeCode(char *code);
|
int translateTypeCode(const char *code);
|
||||||
int isDataNode(mxml_node_t *node);
|
int isDataNode(mxml_node_t *node);
|
||||||
void analyzeDim(const char *typeString, int *rank, int *iDim, int *type);
|
void analyzeDim(const char *typeString, int *rank,
|
||||||
|
int64_t *iDim, int *type);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -828,7 +828,7 @@ static void putHistogramMemoryChunked(SConnection * pCon,
|
|||||||
int status, start, length, i, noChunks, chunkDim[MAXDIM], rank;
|
int status, start, length, i, noChunks, chunkDim[MAXDIM], rank;
|
||||||
HistInt *iData = NULL;
|
HistInt *iData = NULL;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
int subset;
|
int subset =0;
|
||||||
|
|
||||||
if (argc < 5) {
|
if (argc < 5) {
|
||||||
SCWrite(pCon,
|
SCWrite(pCon,
|
||||||
|
95
nxstack.c
95
nxstack.c
@ -18,7 +18,10 @@
|
|||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
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 <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -39,82 +42,104 @@ typedef struct {
|
|||||||
typedef struct __fileStack {
|
typedef struct __fileStack {
|
||||||
int fileStackPointer;
|
int fileStackPointer;
|
||||||
fileStackEntry fileStack[MAXEXTERNALDEPTH];
|
fileStackEntry fileStack[MAXEXTERNALDEPTH];
|
||||||
|
int pathPointer;
|
||||||
|
char pathStack[NXMAXSTACK][NX_MAXNAMELEN];
|
||||||
}fileStack;
|
}fileStack;
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
pFileStack makeFileStack()
|
pFileStack makeFileStack(){
|
||||||
{
|
|
||||||
pFileStack pNew = NULL;
|
pFileStack pNew = NULL;
|
||||||
|
|
||||||
pNew = malloc(sizeof(fileStack));
|
pNew = (pFileStack)malloc(sizeof(fileStack));
|
||||||
if(pNew == NULL){
|
if(pNew == NULL){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(pNew,0,sizeof(fileStack));
|
memset(pNew,0,sizeof(fileStack));
|
||||||
pNew->fileStackPointer = -1;
|
pNew->fileStackPointer = -1;
|
||||||
|
pNew->pathPointer = -1;
|
||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
void killFileStack(pFileStack self)
|
void killFileStack(pFileStack self){
|
||||||
{
|
|
||||||
if(self != NULL){
|
if(self != NULL){
|
||||||
free(self);
|
free(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------*/
|
||||||
|
int getFileStackSize(){
|
||||||
|
return sizeof(fileStack);
|
||||||
|
}
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
void pushFileStack(pFileStack self, pNexusFunction pDriv, char *file)
|
void pushFileStack(pFileStack self, pNexusFunction pDriv, char *file){
|
||||||
{
|
size_t length;
|
||||||
int length;
|
|
||||||
|
|
||||||
self->fileStackPointer++;
|
self->fileStackPointer++;
|
||||||
self->fileStack[self->fileStackPointer].pDriver = pDriv;
|
self->fileStack[self->fileStackPointer].pDriver = pDriv;
|
||||||
memset(&self->fileStack[self->fileStackPointer].closeID, 0,
|
memset(&self->fileStack[self->fileStackPointer].closeID,0,sizeof(NXlink));
|
||||||
sizeof(NXlink));
|
|
||||||
length = strlen(file);
|
length = strlen(file);
|
||||||
if(length >= 1024){
|
if(length >= 1024){
|
||||||
length = 1023;
|
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--;
|
self->fileStackPointer--;
|
||||||
if(self->fileStackPointer < -1){
|
if(self->fileStackPointer < -1){
|
||||||
self->fileStackPointer = -1;
|
self->fileStackPointer = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
pNexusFunction peekFileOnStack(pFileStack self)
|
pNexusFunction peekFileOnStack(pFileStack self){
|
||||||
{
|
|
||||||
return self->fileStack[self->fileStackPointer].pDriver;
|
return self->fileStack[self->fileStackPointer].pDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
char *peekFilenameOnStack(pFileStack self)
|
char *peekFilenameOnStack(pFileStack self){
|
||||||
{
|
|
||||||
return self->fileStack[self->fileStackPointer].filename;
|
return self->fileStack[self->fileStackPointer].filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
void peekIDOnStack(pFileStack self, NXlink * id)
|
void peekIDOnStack(pFileStack self, NXlink *id){
|
||||||
{
|
memcpy(id, &self->fileStack[self->fileStackPointer].closeID, sizeof(NXlink));
|
||||||
memcpy(id, &self->fileStack[self->fileStackPointer].closeID,
|
|
||||||
sizeof(NXlink));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
void setCloseID(pFileStack self, NXlink id)
|
void setCloseID(pFileStack self, NXlink id){
|
||||||
{
|
memcpy(&self->fileStack[self->fileStackPointer].closeID, &id, sizeof(NXlink));
|
||||||
memcpy(&self->fileStack[self->fileStackPointer].closeID, &id,
|
|
||||||
sizeof(NXlink));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
int fileStackDepth(pFileStack self)
|
int fileStackDepth(pFileStack self){
|
||||||
{
|
|
||||||
return self->fileStackPointer;
|
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;
|
||||||
|
}
|
||||||
|
12
nxstack.h
12
nxstack.h
@ -18,7 +18,11 @@
|
|||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
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
|
#ifndef NEXUSFILESTACK
|
||||||
#define NEXUSFILESTACK
|
#define NEXUSFILESTACK
|
||||||
@ -28,6 +32,7 @@ typedef struct __fileStack *pFileStack;
|
|||||||
|
|
||||||
pFileStack makeFileStack();
|
pFileStack makeFileStack();
|
||||||
void killFileStack(pFileStack self);
|
void killFileStack(pFileStack self);
|
||||||
|
int getFileStackSize();
|
||||||
|
|
||||||
void pushFileStack(pFileStack self, pNexusFunction pDriv, char *filename);
|
void pushFileStack(pFileStack self, pNexusFunction pDriv, char *filename);
|
||||||
void popFileStack(pFileStack self);
|
void popFileStack(pFileStack self);
|
||||||
@ -39,4 +44,9 @@ void setCloseID(pFileStack self, NXlink id);
|
|||||||
|
|
||||||
int fileStackDepth(pFileStack self);
|
int fileStackDepth(pFileStack self);
|
||||||
|
|
||||||
|
void pushPath(pFileStack self, const char *name);
|
||||||
|
void popPath(pFileStack self);
|
||||||
|
int buildPath(pFileStack self, char *path, int pathlen);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
30
nxxml.h
30
nxxml.h
@ -17,35 +17,41 @@
|
|||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 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
|
#ifndef NEXUSXML
|
||||||
#define NEXUSXML
|
#define NEXUSXML
|
||||||
|
|
||||||
extern NXstatus NXXopen(CONSTCHAR *filename,
|
extern NXstatus NXXopen(CONSTCHAR *filename,
|
||||||
NXaccess access_method, NXhandle * pHandle);
|
NXaccess access_method,
|
||||||
|
NXhandle* pHandle);
|
||||||
extern NXstatus NXXclose(NXhandle* pHandle);
|
extern NXstatus NXXclose(NXhandle* pHandle);
|
||||||
extern NXstatus NXXflush(NXhandle* pHandle);
|
extern NXstatus NXXflush(NXhandle* pHandle);
|
||||||
|
|
||||||
NXstatus NXXmakegroup(NXhandle fid, CONSTCHAR * name, CONSTCHAR * nxclass);
|
NXstatus NXXmakegroup (NXhandle fid, CONSTCHAR *name,
|
||||||
NXstatus NXXopengroup(NXhandle fid, CONSTCHAR * name, CONSTCHAR * nxclass);
|
CONSTCHAR *nxclass);
|
||||||
|
NXstatus NXXopengroup (NXhandle fid, CONSTCHAR *name,
|
||||||
|
CONSTCHAR *nxclass);
|
||||||
NXstatus NXXclosegroup (NXhandle fid);
|
NXstatus NXXclosegroup (NXhandle fid);
|
||||||
|
|
||||||
NXstatus NXXcompmakedata(NXhandle fid, CONSTCHAR * name,
|
NXstatus NXXcompmakedata64 (NXhandle fid, CONSTCHAR *name,
|
||||||
int datatype,
|
int datatype,
|
||||||
int rank,
|
int rank,
|
||||||
int dimensions[],
|
int64_t dimensions[],
|
||||||
int compress_type, int chunk_size[]);
|
int compress_type, int64_t chunk_size[]);
|
||||||
NXstatus NXXmakedata(NXhandle fid,
|
NXstatus NXXmakedata64 (NXhandle fid,
|
||||||
CONSTCHAR *name, int datatype,
|
CONSTCHAR *name, int datatype,
|
||||||
int rank, int dimensions[]);
|
int rank, int64_t dimensions[]);
|
||||||
NXstatus NXXopendata (NXhandle fid, CONSTCHAR *name);
|
NXstatus NXXopendata (NXhandle fid, CONSTCHAR *name);
|
||||||
NXstatus NXXclosedata (NXhandle fid);
|
NXstatus NXXclosedata (NXhandle fid);
|
||||||
NXstatus NXXputdata (NXhandle fid, void *data);
|
NXstatus NXXputdata (NXhandle fid, void *data);
|
||||||
NXstatus NXXgetdata (NXhandle fid, void *data);
|
NXstatus NXXgetdata (NXhandle fid, void *data);
|
||||||
NXstatus NXXgetinfo(NXhandle fid, int *rank, int dimension[], int *iType);
|
NXstatus NXXgetinfo64 (NXhandle fid, int *rank,
|
||||||
NXstatus NXXputslab(NXhandle fid, void *data, int iStart[], int iSize[]);
|
int64_t dimension[], int *iType);
|
||||||
NXstatus NXXgetslab(NXhandle fid, void *data, int iStart[], int iSize[]);
|
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,
|
NXstatus NXXputattr (NXhandle fid, CONSTCHAR *name, void *data,
|
||||||
int datalen, int iType);
|
int datalen, int iType);
|
||||||
NXstatus NXXgetattr (NXhandle fid, char *name,
|
NXstatus NXXgetattr (NXhandle fid, char *name,
|
||||||
|
@ -715,7 +715,7 @@ int SCWriteJSON_String(SConnection * pCon, char *pBuffer, int iOut)
|
|||||||
/* print it to client if error message */
|
/* print it to client if error message */
|
||||||
if ((iOut == eError) || (iOut == eWarning)) {
|
if ((iOut == eError) || (iOut == eWarning)) {
|
||||||
tmp_json = json_object_new_string(pBuffer);
|
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 {
|
} else {
|
||||||
if ((my_object = mkJSON_Object(pCon, pBuffer, iOut)) == NULL) {
|
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);
|
tmp_json = json_object_new_string(errBuff);
|
||||||
my_object = json_object_new_object();
|
my_object = json_object_new_object();
|
||||||
json_object_object_add(my_object, "ERROR", tmp_json);
|
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;
|
iRet = 0;
|
||||||
} else {
|
} 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))
|
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){
|
if(child != NULL){
|
||||||
UpdateHipadabaPar(child, MakeHdbFloat(ang[3]),NULL);
|
UpdateHipadabaPar(child, MakeHdbFloat(ang[3]),NULL);
|
||||||
}
|
}
|
||||||
|
child = child->next;
|
||||||
|
if(child != NULL){
|
||||||
|
UpdateHipadabaPar(child, MakeHdbFloat(ang[4]),NULL);
|
||||||
|
}
|
||||||
runObjFunction(refl, pCon, node);
|
runObjFunction(refl, pCon, node);
|
||||||
}
|
}
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
@ -253,7 +257,7 @@ static int AddAnglesCmd(pSICSOBJ self, SConnection * pCon,
|
|||||||
pHdb commandNode, pHdb par[], int nPar)
|
pHdb commandNode, pHdb par[], int nPar)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double hkl[3], ang[4];
|
double hkl[3], ang[5];
|
||||||
|
|
||||||
memset(hkl,0,3*sizeof(double));
|
memset(hkl,0,3*sizeof(double));
|
||||||
memset(ang,0,4*sizeof(double));
|
memset(ang,0,4*sizeof(double));
|
||||||
@ -314,6 +318,12 @@ static int AddIndexesAnglesCmd(pSICSOBJ self, SConnection * pCon,
|
|||||||
} else if(node!= NULL) {
|
} else if(node!= NULL) {
|
||||||
UpdateHipadabaPar(node, v, pCon);
|
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);
|
return runObjFunction(self, pCon, addrowNode);
|
||||||
}
|
}
|
||||||
@ -427,7 +437,7 @@ static int SetAnglesCmd(pSICSOBJ self, SConnection * pCon,
|
|||||||
|
|
||||||
/* do angles */
|
/* do angles */
|
||||||
v = MakeHdbFloat(.0);
|
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){
|
if(child != NULL){
|
||||||
UpdateHipadabaPar(child, par[i+1]->value, pCon);
|
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, "om", usUser, MakeHdbFloat(.0));
|
||||||
AddSICSHdbPar(cmd, "chi", usUser, MakeHdbFloat(.0));
|
AddSICSHdbPar(cmd, "chi", usUser, MakeHdbFloat(.0));
|
||||||
AddSICSHdbPar(cmd, "phi", usUser, MakeHdbFloat(.0));
|
AddSICSHdbPar(cmd, "phi", usUser, MakeHdbFloat(.0));
|
||||||
|
AddSICSHdbPar(cmd, "nu", usUser, MakeHdbFloat(.0));
|
||||||
|
|
||||||
cmd =
|
cmd =
|
||||||
AddSICSHdbPar(pNew->objectNode, "seta", usUser,
|
AddSICSHdbPar(pNew->objectNode, "seta", usUser,
|
||||||
@ -508,6 +519,7 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics,
|
|||||||
AddSICSHdbPar(cmd, "om", usUser, MakeHdbFloat(.0));
|
AddSICSHdbPar(cmd, "om", usUser, MakeHdbFloat(.0));
|
||||||
AddSICSHdbPar(cmd, "chi", usUser, MakeHdbFloat(.0));
|
AddSICSHdbPar(cmd, "chi", usUser, MakeHdbFloat(.0));
|
||||||
AddSICSHdbPar(cmd, "phi", usUser, MakeHdbFloat(.0));
|
AddSICSHdbPar(cmd, "phi", usUser, MakeHdbFloat(.0));
|
||||||
|
AddSICSHdbPar(cmd, "nu", usUser, MakeHdbFloat(.0));
|
||||||
|
|
||||||
|
|
||||||
cmd = AddSICSHdbPar(pNew->objectNode, "addax", usUser,
|
cmd = AddSICSHdbPar(pNew->objectNode, "addax", usUser,
|
||||||
@ -521,6 +533,7 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics,
|
|||||||
AddSICSHdbPar(cmd, "om", usUser, MakeHdbFloat(.0));
|
AddSICSHdbPar(cmd, "om", usUser, MakeHdbFloat(.0));
|
||||||
AddSICSHdbPar(cmd, "chi", usUser, MakeHdbFloat(.0));
|
AddSICSHdbPar(cmd, "chi", usUser, MakeHdbFloat(.0));
|
||||||
AddSICSHdbPar(cmd, "phi", usUser, MakeHdbFloat(.0));
|
AddSICSHdbPar(cmd, "phi", usUser, MakeHdbFloat(.0));
|
||||||
|
AddSICSHdbPar(cmd, "nu", usUser, MakeHdbFloat(.0));
|
||||||
|
|
||||||
|
|
||||||
cmd = AddSICSHdbPar(pNew->objectNode, "show", usUser,
|
cmd = AddSICSHdbPar(pNew->objectNode, "show", usUser,
|
||||||
@ -620,7 +633,7 @@ int SetRefAngles(pSICSOBJ refl, int idx, double ang[])
|
|||||||
/* skip over hkl */
|
/* skip over hkl */
|
||||||
for(i = 0; i < 3; i++, child = child->next){}
|
for(i = 0; i < 3; i++, child = child->next){}
|
||||||
/* set angles */
|
/* set angles */
|
||||||
for(i = 0; i < 4; i++, child = child->next){
|
for(i = 0; i < 5; i++, child = child->next){
|
||||||
if(child != NULL){
|
if(child != NULL){
|
||||||
UpdateHipadabaPar(child, MakeHdbFloat(ang[i]), NULL);
|
UpdateHipadabaPar(child, MakeHdbFloat(ang[i]), NULL);
|
||||||
}
|
}
|
||||||
@ -681,7 +694,7 @@ int GetRefAngles(pSICSOBJ refl, int idx, double ang[])
|
|||||||
/* skip hkl */
|
/* skip hkl */
|
||||||
for(i = 0; i < 3; i++, child = child->next){}
|
for(i = 0; i < 3; i++, child = child->next){}
|
||||||
/* do angles */
|
/* 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;
|
ang[i] = child->value.v.doubleValue;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -704,7 +717,7 @@ int GetRefAnglesID(pSICSOBJ refl, char *id, double ang[])
|
|||||||
/* skip hkl */
|
/* skip hkl */
|
||||||
for(i = 0; i < 3; i++, child = child->next){}
|
for(i = 0; i < 3; i++, child = child->next){}
|
||||||
/* do angles */
|
/* 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;
|
ang[i] = child->value.v.doubleValue;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -430,7 +430,7 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
|||||||
* Sometimes one wishes to call multiple scripts in succession
|
* Sometimes one wishes to call multiple scripts in succession
|
||||||
* before returning into I/O. Such scripts then do not set the
|
* before returning into I/O. Such scripts then do not set the
|
||||||
* send property. The loop is taking care of this. Not more
|
* 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++) {
|
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)
|
static int sendZippedNodeData(pHdb node, hdbValue newValue, SConnection * pCon)
|
||||||
{
|
{
|
||||||
int i, *iData = NULL;
|
int i, *iData = NULL, zip = 1;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
|
char value[80];
|
||||||
|
|
||||||
path = GetHipadabaPath(node);
|
path = GetHipadabaPath(node);
|
||||||
|
if (GetHdbProperty(node, "transfer", value, 80) == 1) {
|
||||||
|
if(strstr(value,"bin") != NULL) {
|
||||||
|
zip = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
switch (newValue.dataType) {
|
switch (newValue.dataType) {
|
||||||
case HIPINTAR:
|
case HIPINTAR:
|
||||||
case HIPINTVARAR:
|
case HIPINTVARAR:
|
||||||
@ -474,10 +480,14 @@ static int sendZippedNodeData(pHdb node, hdbValue newValue, SConnection * pCon)
|
|||||||
}
|
}
|
||||||
memset(iData, 0, newValue.arrayLength * sizeof(int));
|
memset(iData, 0, newValue.arrayLength * sizeof(int));
|
||||||
for (i = 0; i < newValue.arrayLength; i++) {
|
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]);
|
iData[i] = htonl(newValue.v.intArray[i]);
|
||||||
}
|
}
|
||||||
|
if(zip == 1){
|
||||||
SCWriteZipped(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
SCWriteZipped(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
||||||
|
} else {
|
||||||
|
SCWriteBinary(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
||||||
|
}
|
||||||
free(iData);
|
free(iData);
|
||||||
/* printf("Wrote zipped data %s, sum %lf\n", path, sum); */
|
/* printf("Wrote zipped data %s, sum %lf\n", path, sum); */
|
||||||
break;
|
break;
|
||||||
@ -498,8 +508,12 @@ static int sendZippedNodeData(pHdb node, hdbValue newValue, SConnection * pCon)
|
|||||||
sum+= newValue.v.floatArray[i];
|
sum+= newValue.v.floatArray[i];
|
||||||
iData[i] = htonl((int) (newValue.v.floatArray[i] * 65536.));
|
iData[i] = htonl((int) (newValue.v.floatArray[i] * 65536.));
|
||||||
}
|
}
|
||||||
|
if(zip == 1) {
|
||||||
SCWriteZipped(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
SCWriteZipped(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
||||||
/* printf("Wrote zipped data %s, sum %lf\n", path, sum); */
|
/* printf("Wrote zipped data %s, sum %lf\n", path, sum); */
|
||||||
|
} else {
|
||||||
|
SCWriteBinary(pCon, path, iData, newValue.arrayLength * sizeof(int));
|
||||||
|
}
|
||||||
free(iData);
|
free(iData);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -600,7 +614,7 @@ static hdbCallbackReturn SICSNotifyCallback(pHdb node, void *userData,
|
|||||||
* if transfer = zip always transfer data in zipped form
|
* if transfer = zip always transfer data in zipped form
|
||||||
*/
|
*/
|
||||||
if (GetHdbProperty(node, "transfer", value, 80) == 1) {
|
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);
|
status = sendZippedNodeData(node, *(mm->v), cbInfo->pCon);
|
||||||
free(pPath);
|
free(pPath);
|
||||||
DeleteDynString(result);
|
DeleteDynString(result);
|
||||||
@ -672,9 +686,9 @@ static hdbCallbackReturn TreeChangeCallback(pHdb node, void *userData,
|
|||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
pDynString result = NULL;
|
pDynString result = NULL;
|
||||||
Protocol protocol = normal_protocol;
|
Protocol protocol = normal_protocol;
|
||||||
int outCode;
|
|
||||||
pHdbIDMessage idm = NULL;
|
pHdbIDMessage idm = NULL;
|
||||||
pHdbPtrMessage cmm = NULL;
|
pHdbPtrMessage cmm = NULL;
|
||||||
|
int outCode;
|
||||||
pHdbTreeChangeMessage tm = NULL;
|
pHdbTreeChangeMessage tm = NULL;
|
||||||
SConnection *tstCon = NULL;
|
SConnection *tstCon = NULL;
|
||||||
|
|
||||||
@ -714,7 +728,7 @@ static hdbCallbackReturn TreeChangeCallback(pHdb node, void *userData,
|
|||||||
result = CreateDynString(128, 128);
|
result = CreateDynString(128, 128);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
SCWrite(cbInfo->pCon, "ERROR: out of memory in TreeChangeCallback",
|
SCWrite(cbInfo->pCon, "ERROR: out of memory in TreeChangeCallback",
|
||||||
outCode);
|
eError);
|
||||||
return hdbAbort;
|
return hdbAbort;
|
||||||
}
|
}
|
||||||
path = GetHipadabaPath(node);
|
path = GetHipadabaPath(node);
|
||||||
@ -2908,7 +2922,7 @@ static int AutoNotifyHdbNode(SConnection * pCon, SicsInterp * pSics,
|
|||||||
void *pData, int argc, char *argv[])
|
void *pData, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
pHdb node = NULL;
|
pHdb node = NULL;
|
||||||
int id, status;
|
int id, status, recurse = 1;
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
SCWrite(pCon, "ERROR: need path and id in order to add notify",
|
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]);
|
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) {
|
if (status == 1) {
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
}
|
}
|
||||||
|
33
simidx.c
33
simidx.c
@ -617,39 +617,6 @@ static int findSolutionsForTriplet(int triplet[3], int testRight)
|
|||||||
return 1;
|
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])
|
static int findSolutionsForDuett(int triplet[3])
|
||||||
|
@ -112,7 +112,7 @@ static int RunIndexCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
|||||||
int i, j, status, err;
|
int i, j, status, err;
|
||||||
pSingleDiff diffi;
|
pSingleDiff diffi;
|
||||||
pSICSOBJ reflist;
|
pSICSOBJ reflist;
|
||||||
double ang[4], z1[3];
|
double ang[5], z1[3];
|
||||||
IndexSolution is;
|
IndexSolution is;
|
||||||
MATRIX ub;
|
MATRIX ub;
|
||||||
pHdb nSol = NULL;
|
pHdb nSol = NULL;
|
||||||
@ -265,7 +265,7 @@ static int IndexCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
|||||||
pHdb par[], int nPar)
|
pHdb par[], int nPar)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
double ang[4], hkl[3];
|
double ang[5], hkl[3];
|
||||||
const double *ub;
|
const double *ub;
|
||||||
pSICSOBJ reflist = NULL;
|
pSICSOBJ reflist = NULL;
|
||||||
pSingleDiff diffi = 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)
|
double fSet[4], pSingleDiff self)
|
||||||
{
|
{
|
||||||
int iTest;
|
int iTest;
|
||||||
|
15
singlex.c
15
singlex.c
@ -25,6 +25,7 @@
|
|||||||
#include "singelbi.h"
|
#include "singelbi.h"
|
||||||
#include "singlenb.h"
|
#include "singlenb.h"
|
||||||
#include "singletas.h"
|
#include "singletas.h"
|
||||||
|
#include "singlebinb.h"
|
||||||
#include "lld.h"
|
#include "lld.h"
|
||||||
#include "fourlib.h"
|
#include "fourlib.h"
|
||||||
|
|
||||||
@ -225,6 +226,7 @@ static int findModeIndex(char *mode)
|
|||||||
"bi",
|
"bi",
|
||||||
"nb",
|
"nb",
|
||||||
"tas",
|
"tas",
|
||||||
|
"binb",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -292,6 +294,19 @@ static hdbCallbackReturn SetModeCB(pHdb node, void *userData,
|
|||||||
priv->mode = Tas;
|
priv->mode = Tas;
|
||||||
initializeSingleTas(priv->diffractometer);
|
initializeSingleTas(priv->diffractometer);
|
||||||
return hdbContinue;
|
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:
|
default:
|
||||||
if (set->callData != NULL) {
|
if (set->callData != NULL) {
|
||||||
pCon = set->callData;
|
pCon = set->callData;
|
||||||
|
@ -35,7 +35,7 @@ double SXGetLambda();
|
|||||||
pSICSOBJ SXGetReflectionList();
|
pSICSOBJ SXGetReflectionList();
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
Bisecting, NB, Tas
|
Bisecting, NB, Tas, BiNB,
|
||||||
} SingleXModes;
|
} SingleXModes;
|
||||||
|
|
||||||
SingleXModes SXGetMode();
|
SingleXModes SXGetMode();
|
||||||
|
@ -9,5 +9,5 @@
|
|||||||
|
|
||||||
MFLAGS=-f makefile_linux$(DUMMY)
|
MFLAGS=-f makefile_linux$(DUMMY)
|
||||||
|
|
||||||
HDFROOT=/afs/psi.ch/project/sinq/sl5
|
HDFROOT=/afs/psi.ch/project/sinq/sl6
|
||||||
TCLINC=.
|
TCLINC=.
|
11
stdscan.c
11
stdscan.c
@ -558,6 +558,16 @@ int prepareDataFile(pScanData self)
|
|||||||
{
|
{
|
||||||
char *pPtr = NULL;
|
char *pPtr = NULL;
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
|
Tcl_Interp *pTcl;
|
||||||
|
const char *val = NULL;
|
||||||
|
|
||||||
|
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 */
|
/* allocate a new data file */
|
||||||
pPtr = ScanMakeFileName(pServ->pSics, self->pCon);
|
pPtr = ScanMakeFileName(pServ->pSics, self->pCon);
|
||||||
@ -569,6 +579,7 @@ int prepareDataFile(pScanData self)
|
|||||||
self->pSics = NULL;
|
self->pSics = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
snprintf(pBueffel, 511, "Writing data file: %s ...", pPtr);
|
snprintf(pBueffel, 511, "Writing data file: %s ...", pPtr);
|
||||||
SCWrite(self->pCon, pBueffel, eLog);
|
SCWrite(self->pCon, pBueffel, eLog);
|
||||||
strcpy(self->pFile, pPtr);
|
strcpy(self->pFile, pPtr);
|
||||||
|
@ -563,6 +563,8 @@ static int checkMotors(ptasMot self, SConnection * pCon)
|
|||||||
if(status == HWIdle || status == OKOK || status == HWFault || status == HWPosFault){
|
if(status == HWIdle || status == OKOK || status == HWFault || status == HWPosFault){
|
||||||
busy[i] = 0;
|
busy[i] = 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
busy[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
332
|
340
|
||||||
NEVER, EVER modify or delete this file
|
NEVER, EVER modify or delete this file
|
||||||
You'll risk eternal damnation and a reincarnation as a cockroach!
|
You'll risk eternal damnation and a reincarnation as a cockroach!
|
||||||
|
2
trace.c
2
trace.c
@ -192,6 +192,8 @@ void traceprint(char *sub, char *id, char *data)
|
|||||||
{
|
{
|
||||||
if(log != NULL && filter(sub,id)){
|
if(log != NULL && filter(sub,id)){
|
||||||
strrepc(data,'\n',':');
|
strrepc(data,'\n',':');
|
||||||
|
strrepc(sub,':','@');
|
||||||
|
strrepc(id,':','@');
|
||||||
fprintf(log,"%s:%s:%lf:%s\n",sub,id,DoubleTime(),data);
|
fprintf(log,"%s:%s:%lf:%s\n",sub,id,DoubleTime(),data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
ubcalc.c
2
ubcalc.c
@ -145,7 +145,7 @@ static int updateUBCALC(pUBCALC self, SConnection * pCon,
|
|||||||
char *id1, char *id2, char *id3)
|
char *id1, char *id2, char *id3)
|
||||||
{
|
{
|
||||||
const double *cell;
|
const double *cell;
|
||||||
double hkl[3], angles[4];
|
double hkl[3], angles[5];
|
||||||
pSICSOBJ refList;
|
pSICSOBJ refList;
|
||||||
|
|
||||||
cell = SXGetCell();
|
cell = SXGetCell();
|
||||||
|
Reference in New Issue
Block a user