- Many fixes to tas code

- fixes to amor writing and status code
- edited ecbcounter to stop at no beam
- updated documentation
- fixed a bug in project code affecting SANS
This commit is contained in:
cvs
2003-05-05 07:49:26 +00:00
parent 4ca2fcff60
commit 4ebf207325
25 changed files with 271 additions and 102 deletions

11
A1931.c
View File

@ -12,6 +12,7 @@
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#include <assert.h> #include <assert.h>
#include <unistd.h>
#include "fortify.h" #include "fortify.h"
#include "sics.h" #include "sics.h"
#include "obpar.h" #include "obpar.h"
@ -20,13 +21,15 @@
#include "evdriver.i" #include "evdriver.i"
#include "gpibcontroller.h" #include "gpibcontroller.h"
#include "A1931.h" #include "A1931.h"
/*========================== private data structure ====================*/ /*========================== private data structure ====================*/
typedef struct { typedef struct {
int sensor; /* the control sensor */ int sensor; /* the control sensor */
pGPIB gpib; /* the GPIB interface to use in order to talk to the thing*/ pGPIB gpib; /* the GPIB interface to use in order to talk to the thing*/
int gpibAddress; /* address on bus */ int gpibAddress; /* address on bus */
int devID; /* deviceID of the controller on the GPIB */ int devID; /* deviceID of the controller on the GPIB */
char errorBuffer[132]; /* a buffer for error meesages from the thing*/ char errorBuffer[132]; /* a buffer for error messages from the thing*/
char commandLine[132]; /* buffer to keep the offending command line */
int errorCode; /* error indicator */ int errorCode; /* error indicator */
}A1931, *pA1931; }A1931, *pA1931;
/*============================ defines ================================*/ /*============================ defines ================================*/
@ -263,11 +266,13 @@ static int downloadFile(pA1931 self, FILE *fd){
pPtr = GPIBreadTillTerm(self->gpib,self->devID,10); pPtr = GPIBreadTillTerm(self->gpib,self->devID,10);
if(pPtr[0] == '#'){ if(pPtr[0] == '#'){
self->errorCode = A1931ERROR; self->errorCode = A1931ERROR;
strcpy(self->errorBuffer,pPtr); strncpy(self->errorBuffer,pPtr,131);
strncpy(self->commandLine,buffer,131);
free(pPtr); free(pPtr);
return 0; return 0;
} }
free(pPtr); free(pPtr);
usleep(50);
} }
return 1; return 1;
} }
@ -327,6 +332,8 @@ int A1931Action(SConnection *pCon, SicsInterp *pSics, void *pData,
A1931error(pEV->pDriv,&iCode,error,131); A1931error(pEV->pDriv,&iCode,error,131);
sprintf(buffer,"%s while transfering file", error); sprintf(buffer,"%s while transfering file", error);
SCWrite(pCon,buffer,eError); SCWrite(pCon,buffer,eError);
sprintf(buffer,"Offending command: %s",self->commandLine);
SCWrite(pCon,buffer,eError);
return 0; return 0;
} }
SCSendOK(pCon); SCSendOK(pCon);

View File

@ -583,7 +583,7 @@
static int SendSingleTOF(pAmorStat self, SConnection *pCon) static int SendSingleTOF(pAmorStat self, SConnection *pCon)
{ {
HistInt *lData = NULL; HistInt *lData = NULL;
int i, i2, i3, iDim[MAXDIM], iIdx, iSum, status, length; int i, i2, i3, iDim[MAXDIM], iIdx, iSum, status, length, nTime;
pSINQHM pHist; pSINQHM pHist;
SinqHMDriv *pTata; SinqHMDriv *pTata;
int iMax = -999999; int iMax = -999999;
@ -593,11 +593,14 @@
/* get size of our problem */ /* get size of our problem */
GetHistDim(self->pHM,iDim,&i3); GetHistDim(self->pHM,iDim,&i3);
assert(i3 == 3);
/* allocate some data */ /* allocate some data */
timebin = GetHistTimeBin(self->pHM, &i3); timebin = GetHistTimeBin(self->pHM, &nTime);
length = 1 + 2*i3; if(nTime < 2) {
return 1;
}
length = 1 + 2*nTime;
iData = (HistInt *)malloc(length*sizeof(HistInt)); iData = (HistInt *)malloc(length*sizeof(HistInt));
if(iData == NULL){ if(iData == NULL){
SCWrite(pCon,"ERROR: failed to allocate memory in SendSingleTOF", SCWrite(pCon,"ERROR: failed to allocate memory in SendSingleTOF",
@ -607,14 +610,14 @@
memset(iData,0,length*sizeof(int)); memset(iData,0,length*sizeof(int));
/* first number is the length of each single histogram */ /* first number is the length of each single histogram */
iData[0] = htonl(i3); iData[0] = htonl(nTime);
if(isSINQHMDriv(self->pHM->pDriv)) if(isSINQHMDriv(self->pHM->pDriv))
{ {
iStart = iDim[0]*iDim[1]*iDim[2]; iStart = iDim[0]*iDim[1]*nTime;
GetHistogramDirect(self->pHM,pCon,0,iStart, GetHistogramDirect(self->pHM,pCon,0,iStart,
iStart + 2*iDim[2],&iData[1],2*iDim[2]*sizeof(HistInt)); iStart + 2*nTime,&iData[1],2*nTime*sizeof(HistInt));
for(i = 1; i < length; i++) for(i = 1; i < length; i++)
{ {
iData[i] = htonl(iData[i]); iData[i] = htonl(iData[i]);
@ -635,10 +638,10 @@
send, with a little trick to do two histograms. send, with a little trick to do two histograms.
*/ */
SCWriteUUencoded(pCon,"SING1",iData, SCWriteUUencoded(pCon,"SING1",iData,
(iDim[2]+1)*sizeof(int)); (nTime+1)*sizeof(int));
iData[iDim[2]] = htonl(iDim[2]); iData[nTime] = htonl(nTime);
SCWriteUUencoded(pCon,"SING2",&iData[iDim[2]], SCWriteUUencoded(pCon,"SING2",&iData[nTime],
(iDim[2]+1)*sizeof(int)); (nTime+1)*sizeof(int));
free(iData); free(iData);
return 1; return 1;
} }
@ -651,13 +654,17 @@
{ {
int iDim[MAXDIM], i, i2, i3, *iSum = NULL, iLang, *iPtr; int iDim[MAXDIM], i, i2, i3, *iSum = NULL, iLang, *iPtr;
HistInt *lData = NULL; HistInt *lData = NULL;
int iLimit, status; int iLimit, status, nTime;
char pBueffel[132]; char pBueffel[132];
pSINQHM pHist; pSINQHM pHist;
SinqHMDriv *pTata; SinqHMDriv *pTata;
const float *fTime;
/* get histogram dimensions */ /* get histogram dimensions */
GetHistDim(self->pHM,iDim,&i3); GetHistDim(self->pHM,iDim,&i3);
fTime = GetHistTimeBin(self->pHM,&nTime);
iDim[i3] = nTime;
i3++;
assert(i3 == 3); assert(i3 == 3);
/* check limits */ /* check limits */

View File

@ -638,12 +638,13 @@ controller is connected to the computer systems through a GPIB bus and
controller. A A1931 temperature controller is configured into SICS controller. A A1931 temperature controller is configured into SICS
through the command: through the command:
<BLOCKQUOTE> <BLOCKQUOTE>
evfactory new temperature-name a1931 gpib-controller-name evfactory new temperature-name a1931 gpib-controller-name gpibaddress
</BLOCKQUOTE> </BLOCKQUOTE>
This creates a new command temperature-name. gpib-controller-name is This creates a new command temperature-name. gpib-controller-name is
the name of a GPIB controller within SICS. A GPIB controller is the name of a GPIB controller within SICS. A GPIB controller is
configured into SICS with the command MakeGPIB as described in the configured into SICS with the command MakeGPIB as described in the
SICS managers documentation. SICS managers documentation. gpibaddress is the address of the A1931 on the
GPIB bus.
</p> </p>
<p> <p>
A A1931 temperature device understands a couple of additional commands A A1931 temperature device understands a couple of additional commands

View File

@ -13,6 +13,7 @@
#include <unistd.h> #include <unistd.h>
#include "fortify.h" #include "fortify.h"
#include "sics.h" #include "sics.h"
#include "status.h"
#include "ecb.h" #include "ecb.h"
#include "countdriv.h" #include "countdriv.h"
@ -22,6 +23,7 @@ typedef struct {
unsigned char prescaler[8]; /* an array for the prescaler values */ unsigned char prescaler[8]; /* an array for the prescaler values */
int tfreq; /* timer frequency */ int tfreq; /* timer frequency */
unsigned char control; /* marks the control monitor */ unsigned char control; /* marks the control monitor */
int state; /* current counting state */
}ECBCounter, *pECBCounter; }ECBCounter, *pECBCounter;
/*----------------- private defines ------------------------------------*/ /*----------------- private defines ------------------------------------*/
@ -33,7 +35,13 @@ typedef struct {
#define STLOAD 156 #define STLOAD 156
#define STCPRE 133 #define STCPRE 133
#define STARTS 135 #define STARTS 135
#define SPCSTA 169
/*------------------ state codes --------------------------------------*/
#define IDLE 0
#define COUNT 2
#define NOBEAM 3
/*--------------------------------------------------------------------*/
#define MAX_COUNT 4294967295.0 #define MAX_COUNT 4294967295.0
/*------------------ error codes --------------------------------------*/ /*------------------ error codes --------------------------------------*/
#define COMMERROR -300 #define COMMERROR -300
@ -66,12 +74,79 @@ static int readScaler(pECBCounter pPriv, int scaler, int *count){
return 1; return 1;
} }
/*---------------------------------------------------------------------*/
static int check4Beam(struct __COUNTER *pCter, int *beam){
Z80_reg in, out;
pECBCounter self = NULL;
int status;
self = (pECBCounter)pCter->pData;
assert(self);
in.c = 1;
status = ecbExecute(self->ecb,SPCSTA,in,&out);
if(status != 1){
pCter->iErrorCode = COMMERROR;
return HWFault;
}
*beam = (int)out.d;
return 1;
}
/*----------------------------------------------------------------------*/
static int stopScalers(pECBCounter self){
int status;
Z80_reg in, out;
status = ecbExecute(self->ecb,STOPS,in,&out);
if(status != 1){
return COMMERROR;
}
return 1;
}
/*========================================================================
These two functions currently rely on the idea that the ECB stops
and starts without clearing counters in between. The sequence of
things necessary to start it, suggests this. If this is not the case then
this will not work.
===========================================================================*/
static int ECBPause(struct __COUNTER *self){
int status;
pECBCounter pPriv = NULL;
assert(self);
pPriv = (pECBCounter)self->pData;
assert(pPriv);
if((status = stopScalers(pPriv)) <= 0){
self->iErrorCode = status;
return HWFault;
}
return OKOK;
}
/*=======================================================================*/
static int ECBContinue(struct __COUNTER *self){
int status;
pECBCounter pPriv = NULL;
Z80_reg in, out;
assert(self);
pPriv = (pECBCounter)self->pData;
assert(pPriv);
status = ecbExecute(pPriv->ecb,STARTS,in,&out);
if(status != 1){
self->iErrorCode = status;
return HWFault;
}
return OKOK;
}
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
static int ECBGetStatus(struct __COUNTER *self, float *fControl){ static int ECBGetStatus(struct __COUNTER *self, float *fControl){
pECBCounter pPriv = (pECBCounter)self->pData; pECBCounter pPriv = (pECBCounter)self->pData;
int status, result, scaler; int status, result, scaler;
Z80_reg in, out; Z80_reg in, out;
int count; int count, beam;
assert(pPriv); assert(pPriv);
@ -81,14 +156,36 @@ static int ECBGetStatus(struct __COUNTER *self, float *fControl){
status = ecbExecute(pPriv->ecb,STFRD,in,&out); status = ecbExecute(pPriv->ecb,STFRD,in,&out);
if(status != 1){ if(status != 1){
self->iErrorCode = COMMERROR; self->iErrorCode = COMMERROR;
pPriv->state = IDLE;
return HWFault; return HWFault;
} }
if(out.d == 0){ if(out.d == 0){
result = HWIdle; result = HWIdle;
pPriv->state = IDLE;
} else { } else {
result = HWBusy; result = HWBusy;
} }
/*
check beam status
*/
status = check4Beam(self,&beam);
if(status != 1){
self->iErrorCode = COMMERROR;
return HWFault;
}
beam &= 1;
if(result == HWBusy && pPriv->state == COUNT && beam == 0){
ECBPause(self);
pPriv->state = NOBEAM;
SetStatus(eOutOfBeam);
}
if(result == HWBusy && pPriv->state == NOBEAM && beam == 1){
ECBContinue(self);
pPriv->state = COUNT;
SetStatus(eCounting);
}
/* /*
select which scaler to read select which scaler to read
*/ */
@ -106,18 +203,7 @@ static int ECBGetStatus(struct __COUNTER *self, float *fControl){
return result; return result;
} }
/*======================================================================*/ /*=====================================================================*/
static int stopScalers(pECBCounter self){
int status;
Z80_reg in, out;
status = ecbExecute(self->ecb,STOPS,in,&out);
if(status != 1){
return COMMERROR;
}
return 1;
}
/*----------------------------------------------------------------------*/
static int clearScalers(pECBCounter self){ static int clearScalers(pECBCounter self){
int status; int status;
Z80_reg in, out; Z80_reg in, out;
@ -225,44 +311,7 @@ static int ECBStart(struct __COUNTER *self){
return HWFault; return HWFault;
} }
return OKOK; pPriv->state = COUNT;
}
/*========================================================================
These two functions currently rely on the idea that the ECB stops
and starts without clearing counters in between. The sequence of
things necessary to start it, suggests this. If this is not the case then
this will not work.
===========================================================================*/
static int ECBPause(struct __COUNTER *self){
int status;
pECBCounter pPriv = NULL;
assert(self);
pPriv = (pECBCounter)self->pData;
assert(pPriv);
if((status = stopScalers(pPriv)) <= 0){
self->iErrorCode = status;
return HWFault;
}
return OKOK;
}
/*=======================================================================*/
static int ECBContinue(struct __COUNTER *self){
int status;
pECBCounter pPriv = NULL;
Z80_reg in, out;
assert(self);
pPriv = (pECBCounter)self->pData;
assert(pPriv);
status = ecbExecute(pPriv->ecb,STARTS,in,&out);
if(status != 1){
self->iErrorCode = status;
return HWFault;
}
return OKOK; return OKOK;
} }
/*=======================================================================*/ /*=======================================================================*/
@ -274,6 +323,7 @@ static int ECBHalt(struct __COUNTER *self){
pPriv = (pECBCounter)self->pData; pPriv = (pECBCounter)self->pData;
assert(pPriv); assert(pPriv);
pPriv->state = IDLE;
if((status = stopScalers(pPriv)) <= 0){ if((status = stopScalers(pPriv)) <= 0){
self->iErrorCode = status; self->iErrorCode = status;
return HWFault; return HWFault;

13
frame.c
View File

@ -26,14 +26,17 @@
/*======================================================================*/ /*======================================================================*/
static int readHMFrame(SConnection *pCon, pHistMem pHM, int nFrame){ static int readHMFrame(SConnection *pCon, pHistMem pHM, int nFrame){
HistInt *buffer = NULL; HistInt *buffer = NULL;
int iDim[MAXDIM], rank, length, status, i; int iDim[MAXDIM], rank, length, status, i, noTimeBins;
pSINQHM pHist; pSINQHM pHist;
SinqHMDriv *pTata; SinqHMDriv *pTata;
const float *timeBin;
/* /*
find dimensions and allocate data find dimensions and allocate data
*/ */
GetHistDim(pHM,iDim,&rank); GetHistDim(pHM,iDim,&rank);
timeBin = GetHistTimeBin(pHM,&noTimeBins);
if(rank < 2){ if(rank < 2){
SCWrite(pCon,"ERROR: no PSD data present, cannot send frame",eError); SCWrite(pCon,"ERROR: no PSD data present, cannot send frame",eError);
return 0; return 0;
@ -52,7 +55,7 @@ static int readHMFrame(SConnection *pCon, pHistMem pHM, int nFrame){
buffer[0] = htonl(iDim[0]); buffer[0] = htonl(iDim[0]);
buffer[1] = htonl(iDim[1]); buffer[1] = htonl(iDim[1]);
if(isSINQHMDriv(pHM->pDriv) && rank == 3) { if(isSINQHMDriv(pHM->pDriv) && noTimeBins > 2) {
/* /*
read from HM. The 5 is PROJECT__FRAME in Sinqhm_def.h read from HM. The 5 is PROJECT__FRAME in Sinqhm_def.h
Again: be friendly: fix out of range frames Again: be friendly: fix out of range frames
@ -60,12 +63,12 @@ static int readHMFrame(SConnection *pCon, pHistMem pHM, int nFrame){
if(nFrame < 0){ if(nFrame < 0){
nFrame = 0; nFrame = 0;
} }
if(nFrame >= iDim[2]){ if(nFrame >= noTimeBins){
nFrame = iDim[2]-1; nFrame = noTimeBins-1;
} }
pTata = (SinqHMDriv *)pHM->pDriv->pPriv; pTata = (SinqHMDriv *)pHM->pDriv->pPriv;
pHist = (pSINQHM)pTata->pMaster; pHist = (pSINQHM)pTata->pMaster;
status = SINQHMProject(pHist, 5, 0, nFrame, status = SINQHMProject(pHist, 0x0005, 0, nFrame,
0, iDim[1], buffer+2,length*sizeof(HistInt)); 0, iDim[1], buffer+2,length*sizeof(HistInt));
if(status != 1){ if(status != 1){
SCWrite(pCon,"ERROR: SINQHM refused to deliver frame",eError); SCWrite(pCon,"ERROR: SINQHM refused to deliver frame",eError);

View File

@ -6,7 +6,7 @@
# Markus Zolliker, March 2003 # Markus Zolliker, March 2003
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# the following line only for fortified version # the following line only for fortified version
#DFORTIFY=-DFORTIFY DFORTIFY=-DFORTIFY
#========================================================================== #==========================================================================
CC = cc CC = cc

View File

@ -1229,6 +1229,7 @@ extern int close(int fp);
} }
/* swap bytes if necessary */ /* swap bytes if necessary */
iNoBins = iDataLen/self->iBinWidth;
if ((self->iBinWidth > 0) && (Rply_buff.bigend != 0x12345678)) if ((self->iBinWidth > 0) && (Rply_buff.bigend != 0x12345678))
{ {
switch (self->iBinWidth) switch (self->iBinWidth)

View File

@ -1,6 +1,6 @@
/*----------------------------------------------------------------------- /*-----------------------------------------------------------------------
This is a data handling class for histogram memory data. This is a data handling class for histogram memory data.
For more information see hmdata.tex. For more information see hmdata.tex
copyright: see file COPYRIGHT copyright: see file COPYRIGHT

View File

@ -45,6 +45,9 @@ VELOOBJ = velo.o velosim.o velodorn.o velodornier.o
all: $(BINTARGET)/SICServer all: $(BINTARGET)/SICServer
full: matrix/libmatrix.a hardsup/libhlib.a tecs/libtecsl.a \
$(BINTARGET)/SICServer
$(BINTARGET)/SICServer: $(SOBJ) $(MOTOROBJ) $(COUNTEROBJ) \ $(BINTARGET)/SICServer: $(SOBJ) $(MOTOROBJ) $(COUNTEROBJ) \
$(DMCOBJ) $(VELOOBJ) $(DIFIL) $(EXTRA) \ $(DMCOBJ) $(VELOOBJ) $(DIFIL) $(EXTRA) \
$(SUBLIBS) $(SUBLIBS)
@ -73,3 +76,8 @@ Dbg.o: Dbg.c
Dbg_cmd.o: Dbg_cmd.c Dbg_cmd.o: Dbg_cmd.c

View File

@ -6,8 +6,8 @@
# Markus Zolliker, March 2003 # Markus Zolliker, March 2003
#========================================================================== #==========================================================================
# the following lines only for fortified version # the following lines only for fortified version
#DFORTIFY=-DFORTIFY DFORTIFY=-DFORTIFY
#FORTIFYOBJ=strdup.o fortify.o FORTIFYOBJ=strdup.o fortify.o
#========================================================================== #==========================================================================
# assign if the National Instrument GPIB driver is available # assign if the National Instrument GPIB driver is available
#NI= -DHAVENI #NI= -DHAVENI
@ -22,11 +22,15 @@
#DIFIL= difrac.o #DIFIL= difrac.o
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
#----------------select proper Makefile
MFLAGS= -f makefile_alpha
HDFROOT=/data/lnslib
CC = cc CC = cc
CFLAGS = -I$(HDFROOT)/include $(DFORTIFY) -DHDF4 -DHDF5 -I$(SRC)hardsup -g \ CFLAGS = -I$(HDFROOT)/include $(DFORTIFY) -DHDF4 -DHDF5 -I$(SRC)hardsup -g \
-std1 -warnprotos -std1 -warnprotos
BINTARGET = bin BINTARGET = bin
HDFROOT=/data/lnslib
EXTRA= EXTRA=
LIBS = -L$(HDFROOT)/lib -Lhardsup -lhlib -Lmatrix -lmatrix -Ltecs \ LIBS = -L$(HDFROOT)/lib -Lhardsup -lhlib -Lmatrix -lmatrix -Ltecs \
-ltecsl -ltcl8.0 -lfor $(HDFROOT)/lib/libhdf5.a \ -ltecsl -ltcl8.0 -lfor $(HDFROOT)/lib/libhdf5.a \
@ -34,3 +38,7 @@ LIBS = -L$(HDFROOT)/lib -Lhardsup -lhlib -Lmatrix -lmatrix -Ltecs \
$(HDFROOT)/lib/libjpeg.a -lz -lm -ll -lc $(HDFROOT)/lib/libjpeg.a -lz -lm -ll -lc
include make_gen include make_gen

View File

@ -584,6 +584,7 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim,
/* deal with time binning */ /* deal with time binning */
fTime = GetHistTimeBin(pHM,&iLength); fTime = GetHistTimeBin(pHM,&iLength);
iDim[2] = iLength;
fTime2 = (float *)malloc(iLength*sizeof(float)); fTime2 = (float *)malloc(iLength*sizeof(float));
if(fTime2) if(fTime2)
{ {

View File

@ -569,6 +569,17 @@ static int gummiFlag = 0; /* a flag indicating stroboscopic, or gummi mode */
ourselves now. And possibly write time binning information. ourselves now. And possibly write time binning information.
*/ */
GetHistDim(self, iDim,&nDim); GetHistDim(self, iDim,&nDim);
/*
handle time binning
*/
fTime = GetHistTimeBin(self,&iVal);
if(iVal > 2)
{
NXDputalias(Nfil,pDict,"ddtb",(void *)fTime);
nDim = 3;
iDim[2] = iVal;
}
histSize = 1; histSize = 1;
for(i = 0; i < nDim; i++) for(i = 0; i < nDim; i++)
{ {
@ -615,12 +626,7 @@ static int gummiFlag = 0; /* a flag indicating stroboscopic, or gummi mode */
} }
NXDputalias(Nfil,pDict,"ddcy",iAxis); NXDputalias(Nfil,pDict,"ddcy",iAxis);
/* write time binning if appropriate */
if(nDim == 3)
{
fTime = GetHistTimeBin(self,&iVal);
NXDputalias(Nfil,pDict,"ddtb",(void *)fTime);
}
/* /*
write gummi monitors when apropriate write gummi monitors when apropriate
@ -674,7 +680,6 @@ static int gummiFlag = 0; /* a flag indicating stroboscopic, or gummi mode */
iVal = NX_CHAR; iVal = NX_CHAR;
NXgetattr(Nfil,"file_name",pBueffel,&i,&iVal); NXgetattr(Nfil,"file_name",pBueffel,&i,&iVal);
SendQuieck(QUIECK,pBueffel); SendQuieck(QUIECK,pBueffel);
/* close this and go ............. */ /* close this and go ............. */
NXclose(&Nfil); NXclose(&Nfil);
return 1; return 1;

View File

@ -143,6 +143,11 @@ int readRS232(prs232 self, void *data, int *dataLen)
return NOTCONNECTED; return NOTCONNECTED;
} }
/*
clean our space in order to prevent corrupted stuff
*/
memset(data,0,*dataLen);
iRet = NETAvailable(self->pSock,self->timeout); iRet = NETAvailable(self->pSock,self->timeout);
if(iRet < 0) if(iRet < 0)
{ {
@ -395,7 +400,7 @@ int RS232Action(SConnection *pCon, SicsInterp *pSics,
char pError[256]; char pError[256];
char pBuffer[8192], pReply[8192]; char pBuffer[8192], pReply[8192];
char *pPtr = NULL; char *pPtr = NULL;
int iRet, iRead = 8191; int iRet, iRead = 8191, count, i;
self = (prs232)pData; self = (prs232)pData;
assert(self); assert(self);
@ -531,6 +536,30 @@ int RS232Action(SConnection *pCon, SicsInterp *pSics,
SCWrite(pCon,pReply,eValue); SCWrite(pCon,pReply,eValue);
return 1; return 1;
} }
else if(strcmp(argv[1],"binwrite") == 0)
{
count = argc - 2;
for(i = 0; i < count; i++)
{
pBuffer[i] = (char)atoi(argv[i+2]);
}
if(self->pSock)
{
iRet = NETWrite(self->pSock,pBuffer,count);
}
else
{
iRet = NOTCONNECTED;
}
if(iRet < 0)
{
getRS232Error(iRet,pError,255);
SCWrite(pCon,pError,eError);
return 0;
}
SCSendOK(pCon);
return 1;
}
else if(strcmp(argv[1],"init") == 0) else if(strcmp(argv[1],"init") == 0)
{ {
iRet = initRS232(self); iRet = initRS232(self);

5
scan.c
View File

@ -936,6 +936,11 @@ int StoreScanCounts(pScanData self, char *data)
{ {
sCount.lCount = atoi(pNumber); sCount.lCount = atoi(pNumber);
} }
else
{
SCWrite(self->pCon,"ERROR: No data in StoreScanCounts",eError);
return 0;
}
while((pPtr = stptok(pPtr,pNumber,19," \t")) != NULL) while((pPtr = stptok(pPtr,pNumber,19," \t")) != NULL)
{ {
sCount.Monitors[iCount] = atoi(pNumber); sCount.Monitors[iCount] = atoi(pNumber);

4
scan.h
View File

@ -78,3 +78,7 @@
#endif #endif

View File

@ -216,9 +216,9 @@ tilt Fixed -1.000000
tilt InterruptMode 0.000000 tilt InterruptMode 0.000000
tilt AccessCode 0.000000 tilt AccessCode 0.000000
#----- MultiMotor st #----- MultiMotor st
st recovernampos henry d1r 5. d1l -5. d1t 0. st recovernampos henry d1r 5. d1l -5. d1t 0.
#----- MultiMotor sampletable #----- MultiMotor sampletable
sampletable recovernampos henry d1r 5. d1l -5. d1t 0. sampletable recovernampos henry d1r 5. d1l -5. d1t 0.
# Motor detectorrotation # Motor detectorrotation
detectorrotation sign 1.000000 detectorrotation sign 1.000000
detectorrotation SoftZero 0.000000 detectorrotation SoftZero 0.000000

View File

@ -1005,7 +1005,10 @@
if(middl >= Tof_edges[0]->n_bins){ if(middl >= Tof_edges[0]->n_bins){
middl = Tof_edges[0]->n_bins-1; middl = Tof_edges[0]->n_bins-1;
printf("WARNING: Fixed bad time bin for single detector!\n"); if(Dbg_lev1){
printf("WARNING: Fixed bad time bin for single detector!\n");
}
continue;
} }
/* /*

View File

@ -2218,6 +2218,7 @@ static int project_frame(int rw_skt, int pkt_size, int nx){
usint *i2; usint *i2;
uint *i4; uint *i4;
} hm_pntr; } hm_pntr;
long sum;
printf("PROJECT: Trying to retrieve time frame: %d\n", nx); printf("PROJECT: Trying to retrieve time frame: %d\n", nx);
@ -2248,10 +2249,12 @@ static int project_frame(int rw_skt, int pkt_size, int nx){
FIX: This works only OK with 4 byte HM data. FIX: This works only OK with 4 byte HM data.
*/ */
hm_pntr.i4 = Hist_base_addr; hm_pntr.i4 = Hist_base_addr;
for(i = 0; i < N_hists;i++){ for(i = 0, sum = 0; i < N_hists;i++){
buffer[i] = htonl(*(hm_pntr.i4 + (i*N_bins) + nx)); buffer[i] = htonl(*(hm_pntr.i4 + (i*N_bins) + nx));
sum += *(hm_pntr.i4+(i*N_bins) +nx);
} }
printf("Frame %d contained %d counts \n",nx,sum);
/* /*
build reply and send data build reply and send data
*/ */
@ -2320,6 +2323,12 @@ static int project_frame(int rw_skt, int pkt_size, int nx){
** The SQHM_PROJECT command is histogram mode dependent. Switch ** The SQHM_PROJECT command is histogram mode dependent. Switch
** accordingly. ** accordingly.
*/ */
/*
printf("\nProject with hm-mode : %d, subcode = %d\n", Hm_mode, sub_code);
*/
switch (Hm_mode) { switch (Hm_mode) {
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
case SQHM__HM_DIG: /* SQHM__HM_DIG and SQHM__HRPT are handled the same. */ case SQHM__HM_DIG: /* SQHM__HM_DIG and SQHM__HRPT are handled the same. */
@ -2396,7 +2405,7 @@ static int project_frame(int rw_skt, int pkt_size, int nx){
break; break;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
case SQHM__TOF: /* Time-of-Flight Mode */ case SQHM__TOF: /* Time-of-Flight Mode */
if( (sub_code & PROJECT__FRAME) == 0){ if(sub_code == PROJECT__FRAME){
return project_frame(rw_skt,pkt_size,nx); return project_frame(rw_skt,pkt_size,nx);
} }

View File

@ -26,7 +26,7 @@ static mkChannel *connection = NULL;
static void syncLogin(void) static void syncLogin(void)
{ {
int test, i; int test, i;
char pBueffel[1024], pRead[80]; char pBueffel[2048], pRead[80];
/* /*
connect connect
@ -51,6 +51,7 @@ static void syncLogin(void)
pBueffel[0] = '\0'; pBueffel[0] = '\0';
for(i = 0; i < 10; i++) for(i = 0; i < 10; i++)
{ {
memset(pRead,0,80);
test = NETRead(connection,pRead,70,10*1000); test = NETRead(connection,pRead,70,10*1000);
if(test < 0) if(test < 0)
{ {
@ -69,6 +70,7 @@ static void syncLogin(void)
else else
{ {
test = 1; test = 1;
break;
} }
SicsWait(1); SicsWait(1);
} }
@ -174,14 +176,13 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
first tell the remote server to backup first tell the remote server to backup
*/ */
SetStatusFixed(eBatch); SetStatusFixed(eBatch);
strcpy(pBueffel,"transact backup"); strcpy(pBueffel,"transact syncbackup");
if(syncFile != NULL) if(syncFile != NULL)
{ {
strcat(pBueffel," "); strcat(pBueffel," ");
strcat(pBueffel,syncFile); strcat(pBueffel,syncFile);
} }
strcat(pBueffel,"\n"); strcat(pBueffel,"\n");
test = NETWrite(connection,pBueffel,strlen(pBueffel)); test = NETWrite(connection,pBueffel,strlen(pBueffel));
if(test != 1) if(test != 1)
{ {

View File

@ -50,6 +50,7 @@ extern char *tasMotorOrder[] = { "a1",
"sgl", "sgl",
"sgu", "sgu",
"agl", "agl",
"atl",
"tt", "tt",
"i1" , "i1" ,
"i2", "i2",
@ -229,13 +230,22 @@ static int TasSaveStatus(void *self, char *name, FILE *fd)
fprintf(fd,"%s hardupperlim %f\n",tasMotorOrder[i], value); fprintf(fd,"%s hardupperlim %f\n",tasMotorOrder[i], value);
MotorGetPar(pMot,"hardlowerlim",&value); MotorGetPar(pMot,"hardlowerlim",&value);
fprintf(fd,"%s hardlowerlim %f\n",tasMotorOrder[i], value); fprintf(fd,"%s hardlowerlim %f\n",tasMotorOrder[i], value);
/*
DISABLED: reading all the motors made to much of a delay during
normal operation of the instrument. This is mainly due to the
sloooooooooowwwwwwwww SINQ hardware
MotorGetSoftPosition(pMot,pCon,&value); MotorGetSoftPosition(pMot,pCon,&value);
fprintf(fd,"run %s %f\n",tasMotorOrder[i], value); fprintf(fd,"run %s %f\n",tasMotorOrder[i], value);
*/
} }
i++; i++;
} }
SCDeleteConnection(pCon); SCDeleteConnection(pCon);
/*
fprintf(fd,"success\n"); fprintf(fd,"success\n");
*/
fprintf(fd,"updateqe\n");
return 1; return 1;
} }
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------

View File

@ -1494,5 +1494,11 @@ int TASScan(SConnection *pCon, SicsInterp *pSics, void *pData,
*/ */
ResetScanFunctions(pTAS->pScan); ResetScanFunctions(pTAS->pScan);
/*
print a message for Severian Gvassilja
*/
sprintf(pLine,"Scan finished, data saved to %s", pTAS->pScan->pFile);
SCWrite(pCon,pLine,eWarning);
return status; return status;
} }

2
tasu.h
View File

@ -15,7 +15,7 @@ extern char *tasMotorOrder[];
extern char *tasVariableOrder[]; extern char *tasVariableOrder[];
/* maximum number of motors in the list */ /* maximum number of motors in the list */
#define MAXMOT 31 #define MAXMOT 32
/* offset to the currents, if available */ /* offset to the currents, if available */
#define CURMOT (MAXMOT - 11) #define CURMOT (MAXMOT - 11)

View File

@ -705,6 +705,7 @@ int TASUpdate(pTASdata self, SConnection *pCon)
now call t_update to do the calculation now call t_update to do the calculation
*/ */
ier = 0; ier = 0;
en = ef = ei = .0;
t_update__(amot, helmCurrent, convH, &lpa, &dm, &da, &isa, &helm, t_update__(amot, helmCurrent, convH, &lpa, &dm, &da, &isa, &helm,
&f1h, &f1v, &f2h, &f2v, &f, &ei, &aki, &ef, &akf, &f1h, &f1v, &f2h, &f2v, &f, &ei, &aki, &ef, &akf,
qhkl, &en, &hx, &hy, &hz, &if1, &if2, &qm, &ier); qhkl, &en, &hx, &hy, &hz, &if1, &if2, &qm, &ier);
@ -738,7 +739,10 @@ int TASUpdate(pTASdata self, SConnection *pCon)
self->tasPar[QH]->fVal = qhkl[0]; self->tasPar[QH]->fVal = qhkl[0];
self->tasPar[QK]->fVal = qhkl[1]; self->tasPar[QK]->fVal = qhkl[1];
self->tasPar[QL]->fVal = qhkl[2]; self->tasPar[QL]->fVal = qhkl[2];
/*
self->tasPar[EN]->fVal = en; self->tasPar[EN]->fVal = en;
*/
self->tasPar[EN]->fVal = ei - ef;
self->tasPar[HX]->fVal = hx; self->tasPar[HX]->fVal = hx;
self->tasPar[HY]->fVal = hy; self->tasPar[HY]->fVal = hy;
self->tasPar[HZ]->fVal = hz; self->tasPar[HZ]->fVal = hz;

View File

@ -5,8 +5,8 @@
# Markus Zolliker, March 2003 # Markus Zolliker, March 2003
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# the following lines only for fortified version # the following lines only for fortified version
#DFORTIFY=-DFORTIFY -I$(SRC).. DFORTIFY=-DFORTIFY -I$(SRC)..
#FORTIFYOBJ=../strdup.o ../fortify.o FORTIFYOBJ=../strdup.o ../fortify.o
#========================================================================== #==========================================================================

View File

@ -70,11 +70,11 @@ User "Daniel_the_Clementine"
# Motor a4 EL734 LNSP22 4000 5 6 # Motor a4 EL734 LNSP22 4000 5 6
# EL734 motor with parameters: hostname PortNumber Channel MotorID # EL734 motor with parameters: hostname PortNumber Channel MotorID
Motor A2 EL734 lnsp22.psi.ch 4000 5 2 # Monochromator 2Theta #Motor A2 EL734 lnsp22.psi.ch 4000 5 2 # Monochromator 2Theta
Motor A3 EL734 lnsp22.psi.ch 4000 5 3 # Sample Omega #Motor A3 EL734 lnsp22.psi.ch 4000 5 3 # Sample Omega
# C O U N T E R S # C O U N T E R S
MakeCounter counter EL737 lnsp22.psi.ch 4000 4 #MakeCounter counter EL737 lnsp22.psi.ch 4000 4
MakeDrive MakeDrive
@ -82,5 +82,12 @@ Publish scan User
Publish otUnknown User Publish otUnknown User
MakeRuenBuffer MakeRuenBuffer
MakeRS232Controller marcel psxtemp 3004 #MakeRS232Controller marcel psxtemp 3004
MakeRS232Controller pfiff psts227 3009
pfiff sendterminator 0x0
pfiff replyterminator 0x10
Publish pfiffread Spy
source pfiff.tcl