From a9d5607fea989146d6105f24117d19823b268b7a Mon Sep 17 00:00:00 2001 From: cvs Date: Fri, 8 Aug 2003 07:30:43 +0000 Subject: [PATCH] - Fixed a bug at the new counter driver --- el737hpdriv.c | 44 +++- el737hpv2driv.c | 534 ++++++++++++++++++++++++++++++++++++++++++++++++ make_gen | 5 +- psi.c | 4 + tas.c | 10 +- tasdrive.c | 14 +- tasinit.c | 14 +- tasscan.c | 47 +++-- tasutil.c | 12 +- 9 files changed, 629 insertions(+), 55 deletions(-) create mode 100644 el737hpv2driv.c diff --git a/el737hpdriv.c b/el737hpdriv.c index 0a0ad7d..a64f696 100644 --- a/el737hpdriv.c +++ b/el737hpdriv.c @@ -31,6 +31,10 @@ typedef struct { int errorCode; int finishCount; /* need RS = 0 2 times before really sure finished */ int statusMode; + time_t startRequest; + int lastStatus; /* need to remember last status, otherwise I get oscillating + NoBeam and Counting status if the beam goes off + */ } EL737hp, *pEL737hp; /*--------------------- ERROR CODES -------------------------------------*/ #define OFFLINE -1 @@ -42,6 +46,7 @@ typedef struct { #define SYSERROR -9 #define BADREPLY -10 #define SELECTFAIL -11 +#define TIMEOUT737 -12 /*----------------------------------------------------------------------- search errors in a reply from the EL737. Returns 1 on success or a negative error code in case of trouble. @@ -190,6 +195,7 @@ static int updateMonitors(struct __COUNTER *self){ status = sscanf(reply,"%d %d %d %d %f",&m1,&m2,&m3,&m4,&fTime); if(status != 5){ pPriv->errorCode = BADREPLY; + printf("Bad reply to EL737 RA command: %s\n", reply); return 0; } } @@ -224,18 +230,28 @@ static int EL737Status(struct __COUNTER *self, float *fControl){ if(pPriv->statusMode == STATSEND){ writeRS232(pPriv->controller,"RS\r",3); pPriv->statusMode = STATRECEIVE; + pPriv->startRequest = time(NULL); *fControl = pPriv->cachedControl; - return HWBusy; + return pPriv->lastStatus; } /* now we are dealing with STATRECEIVE mode. - Check for data availability first. + Check for timeout first. + */ + if(time(NULL) > pPriv->startRequest + 10){ + pPriv->statusMode = STATSEND; + pPriv->errorCode = TIMEOUT737; + return HWFault; + } + + /* + check availability of data */ status = availableNetRS232(pPriv->controller); if(status == 0){ *fControl = pPriv->cachedControl; - return HWBusy; + return pPriv->lastStatus; } else if(status < 0) { *fControl = pPriv->cachedControl; pPriv->statusMode = STATSEND; @@ -256,6 +272,7 @@ static int EL737Status(struct __COUNTER *self, float *fControl){ decode it */ returnValue = decodeRS(pPriv,RS); + pPriv->lastStatus = returnValue; /* check if we update the monitors and do it @@ -291,6 +308,7 @@ static int EL737Start(struct __COUNTER *self){ return 0; } pPriv->finishCount = 0; + pPriv->lastStatus = HWBusy; return 1; } /* --------------------------------------------------------------------*/ @@ -303,6 +321,7 @@ static int EL737Pause(struct __COUNTER *self){ pPriv = (pEL737hp)self->pData; fixMode(pPriv); + pPriv->lastStatus = HWPause; return EL737Command(pPriv,"PS\r",pReply,29); } /*----------------------------------------------------------------------*/ @@ -315,6 +334,7 @@ static int EL737Continue(struct __COUNTER *self){ pPriv = (pEL737hp)self->pData; fixMode(pPriv); + pPriv->lastStatus = HWBusy; return EL737Command(pPriv,"CO\r",pReply,29); } /*---------------------------------------------------------------------*/ @@ -327,6 +347,7 @@ static int EL737Halt(struct __COUNTER *self){ pPriv = (pEL737hp)self->pData; fixMode(pPriv); + pPriv->lastStatus = HWBusy; return EL737Command(pPriv,"S\r",pReply,29); } /*-------------------------------------------------------------------*/ @@ -373,6 +394,8 @@ static int EL737GetError(struct __COUNTER *self, int *iCode, break; case SELECTFAIL: strncpy(pError,"select system call failed, network trouble",errLen); + case TIMEOUT737: + strncpy(pError,"timeout waiting for status repsonse",errLen); default: getRS232Error(pPriv->errorCode,pError,errLen); } @@ -393,6 +416,7 @@ static int EL737FixIt(struct __COUNTER *self, int iCode){ case BADPARAM: case NOPARAM: case BADRANGE: + case TIMEOUT737: return COREDO; break; case OFFLINE: @@ -434,16 +458,16 @@ static int EL737Set(struct __COUNTER *self, char *name, int iCter, if(strcmp(name,"threshold") == 0){ sprintf(pCommand,"DL %1.1d %f\r",iCter, fVal); if(!EL737Command(pPriv,pCommand,pReply,49)){ - return HWFault; + return 0; } sprintf(pCommand,"DR %1.1d\r",iCter); if(!EL737Command(pPriv,pCommand,pReply,49)){ - return HWFault; + return 0; } - return OKOK; + return 1; } else { self->iErrorCode = UNKNOWNPAR; - return HWFault; + return 0; } } /*----------------------------------------------------------------------*/ @@ -460,13 +484,13 @@ static int EL737Get(struct __COUNTER *self, char *name, int iCter, if(strcmp(name,"threshold") == 0){ sprintf(pCommand,"DL %1.1d\r",iCter); if(!EL737Command(pPriv,pCommand,pReply,49)){ - return HWFault; + return 0; } sscanf(pReply,"%f", fVal); - return OKOK; + return 1; } else { self->iErrorCode = UNKNOWNPAR; - return HWFault; + return 0; } } /*--------------------------------------------------------------------*/ diff --git a/el737hpv2driv.c b/el737hpv2driv.c new file mode 100644 index 0000000..b940b6f --- /dev/null +++ b/el737hpv2driv.c @@ -0,0 +1,534 @@ +/*----------------------------------------------------------------------- + This is another driver for the EL737 counter box used at SINQ. The hp in + the name is for high performance, though this only a promise and not yet + proven. This version connects directly to the RS232 port of the counter + box on the terminal server rather then working with David Maden's + SerPortServer program. Other tweaks will be implemented as well, such as + reading the monitors only now and then and not on all calls. + + Mark Koennecke, July 2003 + -------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include +#include + + +#define STATSEND 0 +#define STATRECEIVE 2 +/*----------------------------------------------------------------------- + our own data struture + ------------------------------------------------------------------------*/ +typedef struct { + prs232 controller; + int monitorCount; /* read monitors if this is above MONTHRESH */ + float cachedControl; + int errorCode; + char savedStarMessage[20]; + int haveSavedStarMessage; + int lastStatus; + int monitorThreshold; +} EL737hp, *pEL737hp; +/*--------------------- ERROR CODES -------------------------------------*/ +#define OFFLINE -1 +#define BADRANGE -3 +#define BADCOMMAND -4 +#define BADPARAM -5 +#define NOPARAM -7 +#define TOMANYCOUNTS -8 +#define SYSERROR -9 +#define BADREPLY -10 +#define SELECTFAIL -11 +/*----------------------------------------------------------------------- + search errors in a reply from the EL737. Returns 1 on success or a + negative error code in case of trouble. + ------------------------------------------------------------------------*/ +static int checkEL737Error(pEL737hp self, char *pReply){ + /* + all error start with a ?, if no ? in reply, answer is OK! + */ + if(strstr(pReply,"?") == NULL){ + return 1; + } + + /* + Now there is an error and we have to identify it + */ + if(strstr(pReply,"?OF") != NULL){ + return OFFLINE; + } else if(strstr(pReply,"?OV") != NULL){ + return OVERFLOW; + } else if(strstr(pReply,"?1") != NULL){ + return BADRANGE; + } else if(strstr(pReply,"?2") != NULL){ + return BADCOMMAND; + } else if(strstr(pReply,"?3") != NULL){ + return BADPARAM; + } else if(strstr(pReply,"?4") != NULL){ + return BADCOUNTER; + } else if(strstr(pReply,"?5") != NULL){ + return NOPARAM; + } else if(strstr(pReply,"?6") != NULL){ + return TOMANYCOUNTS; + } else { + return SYSERROR; + } +} +/*---------------------------------------------------------------*/ +static int EL737Command(pEL737hp pPriv, char *pCommand, + char *pReply, int replylen){ + int status, savedLen; + + savedLen = replylen; + status = transactRS232(pPriv->controller,pCommand,strlen(pCommand), + pReply,replylen); + if(status < 0){ + pPriv->errorCode = status; + return 0; + } + + /* + save any * message which may have arrrived, and if so: read again + */ + if(strstr(pReply,"*") != NULL){ + memset(pPriv->savedStarMessage,0,20); + strncpy(pPriv->savedStarMessage,pReply,19); + pPriv->haveSavedStarMessage = 1; + status = readRS232TillTerm(pPriv->controller, pReply, &savedLen); + if(status < 0){ + pPriv->errorCode = status; + return 0; + } + } + + status = checkEL737Error(pPriv, pReply); + if(status < 0){ + pPriv->errorCode = status; + return 0; + } + return 1; +} +/*-----------------------------------------------------------------*/ +static int updateMonitors(struct __COUNTER *self){ + int status; + int m1,m2,m3,m4,m5,m6,m7,m8; + float fTime; + pEL737hp pPriv = NULL; + char reply[132]; + + pPriv = (pEL737hp)self->pData; + + if(!EL737Command(pPriv,"RA\r",reply,131)){ + return 0; + } + + /* + There are two forms of RA replys: new form with 8 monitors + */ + status = sscanf(reply,"%f %d %d %d %d %d %d %d %d", + &fTime,&m1,&m2,&m3,&m4,&m5,&m6,&m7,&m8); + if(status != 9){ + /* + old form with 4 monitors + */ + status = sscanf(reply,"%d %d %d %d %f",&m1,&m2,&m3,&m4,&fTime); + if(status != 5){ + printf("Bad reply: %s\n", reply); + pPriv->errorCode = BADREPLY; + return 0; + } + } + self->lCounts[0] = m2; + self->lCounts[1] = m1; + self->lCounts[2] = m3; + self->lCounts[3] = m4; + self->lCounts[4] = m5; + self->lCounts[5] = m6; + self->lCounts[6] = m7; + self->lCounts[7] = m8; + self->fTime = fTime; + + if(self->eMode == eTimer){ + pPriv->cachedControl = fTime; + } else { + pPriv->cachedControl = m2; + } + return 1; +} +/*-----------------------------------------------------------------*/ +static void decodeStarMessage(pEL737hp self, char *message){ + strtolower(message); + if(strstr(message,"*cf") != NULL){ + self->lastStatus = HWIdle; + } else if(strstr(message,"*lr") != NULL){ + self->lastStatus = HWNoBeam; + } else if(strstr(message,"*hr") != NULL){ + self->lastStatus = HWBusy; + } else { + printf("Bad star mesage: %s\n", message); + } +} +/*------------------------------------------------------------------*/ +static int EL737Status(struct __COUNTER *self, float *fControl){ + int status, returnValue, len; + pEL737hp pPriv = NULL; + char starMessage[10]; + + assert(self); + pPriv = (pEL737hp)self->pData; + + + /* + now we are dealing with STATRECEIVE mode. + Check for data availability first. + */ + status = availableNetRS232(pPriv->controller); + if(status == 0){ + *fControl = pPriv->cachedControl; + returnValue = pPriv->lastStatus; + } else if(status < 0) { + *fControl = pPriv->cachedControl; + pPriv->errorCode = SELECTFAIL; + return HWFault; + } else { + /* + we have data: read and decode the * message we are waiting fore + */ + len = 9; + status = readRS232TillTerm(pPriv->controller,starMessage,&len); + if(status < 0){ + pPriv->errorCode = status; + return HWFault; + } + decodeStarMessage(pPriv,starMessage); + returnValue = pPriv->lastStatus; + } + + /* + check if we update the monitors and do it + */ + pPriv->monitorCount++; + if(pPriv->monitorCount > pPriv->monitorThreshold){ + status = updateMonitors(self); + pPriv->monitorCount = 0; + if(!status){ + return HWFault; + } + } + + /* + check for a saved starMessage + */ + if(pPriv->haveSavedStarMessage != 0){ + decodeStarMessage(pPriv,pPriv->savedStarMessage); + pPriv->haveSavedStarMessage = 0; + returnValue = pPriv->lastStatus; + } + + *fControl = pPriv->cachedControl; + return returnValue; +} +/*-------------------------------------------------------------------*/ +static int EL737Start(struct __COUNTER *self){ + pEL737hp pPriv = NULL; + int status; + char pCommand[50], pReply[30]; + + assert(self); + pPriv = (pEL737hp)self->pData; + + if(self->eMode == ePreset){ + snprintf(pCommand,49,"MP %d\r",(int)self->fPreset); + } else { + snprintf(pCommand,49,"TP %.2f\r", self->fPreset); + } + if(EL737Command(pPriv,pCommand,pReply,29) != 1){ + return 0; + } + pPriv->lastStatus = HWBusy; + return 1; +} +/* --------------------------------------------------------------------*/ +static int EL737Pause(struct __COUNTER *self){ + pEL737hp pPriv = NULL; + int status; + char pCommand[50], pReply[30]; + + assert(self); + pPriv = (pEL737hp)self->pData; + + status = EL737Command(pPriv,"PS\r",pReply,29); + if(status > 0){ + pPriv->lastStatus= HWPause; + } + return status; +} +/*----------------------------------------------------------------------*/ +static int EL737Continue(struct __COUNTER *self){ + pEL737hp pPriv = NULL; + int status; + char pCommand[50], pReply[30]; + + assert(self); + pPriv = (pEL737hp)self->pData; + + status = EL737Command(pPriv,"CO\r",pReply,29); + if(status > 0){ + pPriv->lastStatus = HWBusy; + } + return status; +} +/*---------------------------------------------------------------------*/ +static int EL737Halt(struct __COUNTER *self){ + pEL737hp pPriv = NULL; + int status; + char pCommand[50], pReply[30]; + + assert(self); + pPriv = (pEL737hp)self->pData; + + return EL737Command(pPriv,"S\r",pReply,29); +} +/*-------------------------------------------------------------------*/ +static int EL737Transfer(struct __COUNTER *self){ + pEL737hp pPriv = NULL; + assert(self); + pPriv = (pEL737hp)self->pData; + + return updateMonitors(self); +} +/*--------------------------------------------------------------------*/ +static int EL737GetError(struct __COUNTER *self, int *iCode, + char *pError, int errLen){ + pEL737hp pPriv = NULL; + assert(self); + pPriv = (pEL737hp)self->pData; + + *iCode = pPriv->errorCode; + switch(pPriv->errorCode){ + case OFFLINE: + strncpy(pError,"EL737 is offline",errLen); + break; + case BADRANGE: + strncpy(pError,"EL737 parameter is out of range",errLen); + break; + case BADCOMMAND: + strncpy(pError,"EL737 received unknown command or is busy",errLen); + break; + case BADPARAM: + strncpy(pError,"EL737 parameter is awful",errLen); + break; + case NOPARAM: + strncpy(pError,"EL737 parameter missing",errLen); + break; + case TOMANYCOUNTS: + strncpy(pError,"EL737 counters overflowed",errLen); + break; + case SYSERROR: + strncpy(pError,"EL737 has an internal system error",errLen); + break; + case BADREPLY: + strncpy(pError,"EL737 sent an unexpected reply",errLen); + break; + case SELECTFAIL: + strncpy(pError,"select system call failed, network trouble",errLen); + default: + getRS232Error(pPriv->errorCode,pError,errLen); + } + return 1; +} +/*--------------------------------------------------------------------*/ +static int EL737FixIt(struct __COUNTER *self, int iCode){ + pEL737hp pPriv = NULL; + int status; + char pReply[50]; + + assert(self); + pPriv = (pEL737hp)self->pData; + + switch(iCode){ + case TIMEOUT: + case BADREPLY: + case BADPARAM: + case NOPARAM: + case BADRANGE: + return COREDO; + break; + case OFFLINE: + EL737Command(pPriv,"RMT 1\r",pReply,49); + EL737Command(pPriv,"echo 0\r",pReply,49); + return COREDO; + break; + case BADCOMMAND: /* can be busy, stop it and try again */ + EL737Command(pPriv,"S\r",pReply,49); + return COREDO; + break; + case TOMANYCOUNTS: + case SYSERROR: + return COTERM; + break; + default: + /* + network problem; try to reopen + */ + status = initRS232(pPriv->controller); + if(status != 1){ + return COTERM; + } else { + return COREDO; + } + } +} +/*------------------------------------------------------------------------*/ +static int EL737Set(struct __COUNTER *self, char *name, int iCter, + float fVal){ + pEL737hp pPriv = NULL; + int status; + char pCommand[80], pReply[50]; + + assert(self); + pPriv = (pEL737hp)self->pData; + + if(strcmp(name,"threshold") == 0){ + sprintf(pCommand,"DL %1.1d %f\r",iCter, fVal); + if(!EL737Command(pPriv,pCommand,pReply,49)){ + return 0; + } + sprintf(pCommand,"DR %1.1d\r",iCter); + if(!EL737Command(pPriv,pCommand,pReply,49)){ + return 0; + } + return 1; + } else if(strcmp(name,"monitorupdate") != 0){ + pPriv->monitorThreshold = (int)fVal; + return 1; + }else { + self->iErrorCode = UNKNOWNPAR; + return 0; + } +} +/*----------------------------------------------------------------------*/ +static int EL737Get(struct __COUNTER *self, char *name, int iCter, + float *fVal){ + pEL737hp pPriv = NULL; + int status; + char pCommand[80], pReply[50]; + + assert(self); + pPriv = (pEL737hp)self->pData; + + if(strcmp(name,"threshold") == 0){ + sprintf(pCommand,"DL %1.1d\r",iCter); + if(!EL737Command(pPriv,pCommand,pReply,49)){ + return 0; + } + sscanf(pReply,"%f", fVal); + return 1; + } else if(strcmp(name,"monitorupdate") == 0){ + *fVal = (float)pPriv->monitorThreshold; + return 1; + } else { + self->iErrorCode = UNKNOWNPAR; + return 0; + } +} +/*--------------------------------------------------------------------*/ +static int EL737Send(struct __COUNTER *self, char *pText, char *pReply, + int iReplyLen){ + pEL737hp pPriv = NULL; + + assert(self); + pPriv = (pEL737hp)self->pData; + + return EL737Command(pPriv,pText,pReply,iReplyLen); +} +/*---------------------------------------------------------------------*/ +static void KillHP(pCounterDriver self){ + pEL737hp pPriv = NULL; + + assert(self); + pPriv = (pEL737hp)self->pData; + + if(!pPriv){ + return; + } + if(pPriv->controller != NULL){ + KillRS232(pPriv->controller); + } + free(pPriv); +} +/*-------------------------------------------------------------------*/ +pCounterDriver MakeEL737HPV2(SConnection *pCon, char *name, + int argc, char *argv[]){ + pCounterDriver pNew = NULL; + pEL737hp pPriv = NULL; + char pHost[132]; + int port, status; + + /* + check arguments + */ + if(argc < 2) { + SCWrite(pCon,"ERROR: insufficient no af arguments to create EL737HP", + eError); + return NULL; + } + if(!isNumeric(argv[1])){ + SCWrite(pCon,"ERROR: expected numeric argument for port number", + eError); + return NULL; + } + port = atoi(argv[1]); + strncpy(pHost,argv[0],131); + + /* + allocate a bank worth of memory ........... + */ + pNew = CreateCounterDriver(name,"EL737HP"); + pPriv = (pEL737hp)malloc(sizeof(EL737hp)); + if(!pNew || !pPriv){ + return NULL; + } + memset(pPriv,0,sizeof(EL737hp)); + pPriv->controller = createRS232(pHost,port); + if(!pPriv->controller){ + DeleteCounterDriver(pNew); + return NULL; + } + + /* assign functions */ + pNew->GetStatus = EL737Status; + pNew->Start = EL737Start; + pNew->Halt = EL737Halt; + pNew->ReadValues = EL737Transfer; + pNew->GetError = EL737GetError; + pNew->TryAndFixIt = EL737FixIt; + pNew->Pause = EL737Pause; + pNew->Continue = EL737Continue; + pNew->Set = EL737Set; + pNew->Get = EL737Get; + pNew->Send = EL737Send; + pNew->KillPrivate = KillHP; + pNew->iNoOfMonitors = 7; + pNew->fTime = 0.; + pNew->pData = pPriv; + + /* + initialize connection + */ + setRS232Debug(pPriv->controller,0); + setRS232ReplyTerminator(pPriv->controller,"\r"); + status = initRS232(pPriv->controller); + status = EL737Command(pPriv,"RMT 1\r",pHost,131); + status = EL737Command(pPriv,"RMT 1\r",pHost,131); + status = EL737Command(pPriv,"ECHO 0\r",pHost,131); + + return pNew; +} + + + diff --git a/make_gen b/make_gen index 5f6fdaf..66df5ee 100644 --- a/make_gen +++ b/make_gen @@ -14,7 +14,8 @@ OBJ=psi.o buffer.o ruli.o dmc.o nxsans.o nextrics.o sps.o pimotor.o \ velodornier.o docho.o sanscook.o tecsdriv.o itc4driv.o itc4.o\ bruker.o ltc11.o A1931.o dilludriv.o eurodriv.o slsmagnet.o \ el755driv.o amorscan.o serial.o scontroller.o t_update.o \ - t_rlp.o t_conv.o el737hpdriv.o dornier2.o el734hp.o + t_rlp.o t_conv.o el737hpdriv.o dornier2.o el734hp.o \ + el737hpv2driv.o libpsi.a: $(OBJ) - rm libpsi.a @@ -23,4 +24,4 @@ libpsi.a: $(OBJ) clean: - rm *.a - - rm *.o \ No newline at end of file + - rm *.o diff --git a/psi.c b/psi.c index f90aa76..70bfd66 100644 --- a/psi.c +++ b/psi.c @@ -179,6 +179,8 @@ extern pCounterDriver CreateEL737Counter(SConnection *pCon, char *name, int argc, char *argv[]); extern pCounterDriver MakeEL737HP(SConnection *pCon, char *name, int argc, char *argv[]); +extern pCounterDriver MakeEL737HPV2(SConnection *pCon, char *name, + int argc, char *argv[]); /*-------------------------------------------------------------------*/ static pCounterDriver CreatePsiCounterDriver(SConnection *pCon, int argc, @@ -192,6 +194,8 @@ static pCounterDriver CreatePsiCounterDriver(SConnection *pCon, pNew = CreateEL737Counter(pCon,argv[1],argc-3,&argv[3]); } else if(strcmp(argv[2],"el737hp") == 0){ pNew = MakeEL737HP(pCon,argv[1],argc-3,&argv[3]); + } else if(strcmp(argv[2],"el737hpv2") == 0){ + pNew = MakeEL737HPV2(pCon,argv[1],argc-3,&argv[3]); } else if(strcmp(argv[2],"ecb") == 0){ if(argc < 4){ SCWrite(pCon, diff --git a/tas.c b/tas.c index ffcbf77..694f5ec 100644 --- a/tas.c +++ b/tas.c @@ -14,11 +14,11 @@ ---------------------------------------------------------------------------*/ #include #include -#include "fortify.h" -#include "sics.h" -#include "sicsvar.h" -#include "counter.h" -#include "motor.h" +#include +#include +#include +#include +#include #include "tas.h" /* diff --git a/tasdrive.c b/tasdrive.c index 603b0ee..0bd123a 100644 --- a/tasdrive.c +++ b/tasdrive.c @@ -20,13 +20,13 @@ ---------------------------------------------------------------------------*/ #include #include -#include "fortify.h" -#include "sics.h" -#include "sicsvar.h" -#include "counter.h" -#include "motor.h" -#include "scan.h" -#include "splitter.h" +#include +#include +#include +#include +#include +#include +#include #include "tas.h" #include "tasu.h" diff --git a/tasinit.c b/tasinit.c index f9c38f9..dc58681 100644 --- a/tasinit.c +++ b/tasinit.c @@ -16,13 +16,13 @@ ---------------------------------------------------------------------------*/ #include #include -#include "fortify.h" -#include "sics.h" -#include "sicsvar.h" -#include "counter.h" -#include "motor.h" -#include "scan.h" -#include "scan.i" +#include +#include +#include +#include +#include +#include +#include #include "tas.h" extern int getSRO(SConnection *pCon, float *fVal); /* tasutil.c */ diff --git a/tasscan.c b/tasscan.c index 953495b..ee868ad 100644 --- a/tasscan.c +++ b/tasscan.c @@ -21,18 +21,18 @@ #include #include #include -#include "fortify.h" -#include "sics.h" -#include "sicsvar.h" -#include "counter.h" -#include "motor.h" -#include "scan.h" -#include "scan.i" -#include "psi/tas.h" -#include "psi/tasu.h" -#include "evcontroller.h" -#include "splitter.h" -#include "status.h" +#include +#include +#include +#include +#include +#include +#include +#include "tas.h" +#include "tasu.h" +#include +#include +#include /*------------------------------------------------------------------------ a little local utility for making a line of characters @@ -201,8 +201,8 @@ static int TASHeader(pScanData self) pTAS->tasPar[SM]->iVal, pTAS->tasPar[SS]->iVal, pTAS->tasPar[SA]->iVal); - fprintf(self->fd,"PARAM: FX=%3f, KFIX=%8.4f\n", - pTAS->tasPar[FX]->fVal, + fprintf(self->fd,"PARAM: FX=%3d, KFIX=%8.4f\n", + pTAS->tasPar[FX]->iVal, pTAS->tasPar[KF]->fVal); fprintf(self->fd,"PARAM: ALF1=%8.4f, ALF2=%8.4f, ALF3=%8.4f, ALF4=%8.4f\n", pTAS->tasPar[ALF1]->fVal, @@ -371,7 +371,11 @@ static int TASHeader(pScanData self) */ for(i = 0; i < pTAS->addCount; i++) { - strcat(pBueffel,"F9.4,1X,"); + if(i == pTAS->addCount -1){ + strcat(pBueffel,"F9.4"); + } else { + strcat(pBueffel,"F9.4,1X,"); + } if(pTAS->addType[i] == 1) /* motor */ { strcpy(pWork2,tasMotorOrder[pTAS->addOutput[i]]); @@ -466,6 +470,13 @@ static int TASScanPoint(pScanData self, int iPoint) { fVal = -9999.77; } + } + else + { + if(pVar->pInter != NULL) + { + fVal = pVar->pInter->GetValue(pVar->pObject,self->pCon); + } } } else if((iPtr = isTASVar(pVar->Name)) >= 0 ) @@ -473,7 +484,7 @@ static int TASScanPoint(pScanData self, int iPoint) fVal = pTAS->tasPar[iPtr]->fVal; } } - sprintf(pWork,"%8.4f ", fVal); + sprintf(pWork,"%9.4f ", fVal); strcat(pBueffel,pWork); } @@ -485,7 +496,7 @@ static int TASScanPoint(pScanData self, int iPoint) m3 = GetMonitor(self->pCounterData,3,self->pCon); cnts = GetCounts(self->pCounterData,self->pCon); fVal = GetCountTime(self->pCounterData, self->pCon); - sprintf(pWork,"%8d %8d %9.4f %8d %8d ",m1,m2,fVal, cnts, m3); + sprintf(pWork,"%8d %8d %9.2f %8d %8d ",m1,m2,fVal, cnts, m3); strcat(pBueffel,pWork); /* @@ -855,7 +866,7 @@ static int AddTASScanVar(pScanData self, SicsInterp *pSics, SConnection *pCon, /* got everything, fill in the VarEntry structure */ strcpy(pVar.Name,name); - pVar.pInter = NULL; + pVar.pInter = GetDrivableInterface(pData); pVar.pObject = pData; pVar.fStart = fStart; pVar.fStep = fStep; diff --git a/tasutil.c b/tasutil.c index 52e6400..9460cd7 100644 --- a/tasutil.c +++ b/tasutil.c @@ -22,12 +22,12 @@ ---------------------------------------------------------------------------*/ #include #include -#include "fortify.h" -#include "sics.h" -#include "sicsvar.h" -#include "counter.h" -#include "motor.h" -#include "scan.h" +#include +#include +#include +#include +#include +#include #include "tas.h" #include "tasu.h"