diff --git a/autowin.c b/autowin.c index 0b8ae94..ec8f92e 100644 --- a/autowin.c +++ b/autowin.c @@ -97,25 +97,30 @@ static float calcCOG(HistInt *data, int length, int startPos) static void printPeaks(SConnection *pCon, int peakList, HistInt *data, int length) { - int status, startPos, oldStartPos = 0; - float cog; - pDynString buf; - - SCStartBuffering(pCon); - status = LLDnodePtr2First(peakList); - while(status > 0){ - LLDnodeDataTo(peakList,&startPos); - cog = calcCOG(data, length, startPos); - startPos = (int)nintf(cog); - if((startPos - oldStartPos) > 2){ - SCPrintf(pCon,eValue,"%d,%d,%d", startPos - 5, startPos + 5, - startPos); - oldStartPos = startPos; - } - status = LLDnodePtr2Next(peakList); - } - buf = SCEndBuffering(pCon); - SCWrite(pCon,GetCharArray(buf), eValue); + int status, startPos, oldStartPos = 0; + float cog; + pDynString buf; + char buffer[512]; + + buf = CreateDynString(256,256); + if(buf == NULL){ + SCWrite(pCon,"ERROR: out of memory printing peaks", eError); + return; + } + status = LLDnodePtr2First(peakList); + while(status > 0){ + LLDnodeDataTo(peakList,&startPos); + cog = calcCOG(data, length, startPos); + startPos = (int)nintf(cog); + if((startPos - oldStartPos) > 2){ + snprintf(buffer,512,"%d,%d,%d",startPos - 5, startPos + 5, startPos); + DynStringConcatLine(buf,buffer); + oldStartPos = startPos; + } + status = LLDnodePtr2Next(peakList); + } + SCWrite(pCon,GetCharArray(buf), eValue); + DeleteDynString(buf); } /*------------------------------------------------------------------------*/ static int CalcCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, diff --git a/eigera2.c b/eigera2.c index 395247c..2a862b1 100644 --- a/eigera2.c +++ b/eigera2.c @@ -24,6 +24,7 @@ #define RUNNING 1 #define WAITSTOP 2 #define WAITSLIT 3 +#define WAITIDLE 4 /* ---------------------------- motor names --------------------*/ #define A2 "a2rot" #define A2R "d2r" @@ -153,8 +154,11 @@ static long eigera2SetValue(void *data, SConnection *pCon, float val){ self = (eigera2)data; if(self->state != IDLE){ - SCWrite(pCon,"ERROR: Eiger A2 still busy...", eLogError); - return HWFault; + SCWrite(pCon,"WARNING: stopping busy A2", eLogError); + self->a2Target = val; + eigera2Halt(data); + self->state = WAITIDLE; + return OKOK; } self->a2Target = val; setNewMotorTarget(self->motorList,A2,self->a2Target); @@ -204,6 +208,15 @@ static int eigera2CheckStatus(void *data, SConnection *pCon){ self = (eigera2)data; switch(self->state){ + case WAITIDLE: + status = self->listDriv->CheckStatus(&self->motorList,pCon); + if(status == HWFault || status == HWIdle){ + self->state = IDLE; + eigera2SetValue(data,pCon, self->a2Target); + } else { + return status; + } + break; case RUNNING: case WAITSLIT: status = self->listDriv->CheckStatus(&self->motorList,pCon); diff --git a/jvlprot.c b/jvlprot.c index 9131c13..c1ecb84 100644 --- a/jvlprot.c +++ b/jvlprot.c @@ -155,7 +155,7 @@ static int JVLHandler(Ascon *a) a->state = AsconWriteStart; return 1; } - if(time(NULL) > priv->start + 1){ + if(time(NULL) > priv->start + a->timeout){ a->state = AsconReadDone; DynStringConcat(a->rdBuffer,"timeout"); return 1; @@ -211,7 +211,7 @@ static int JVLInit(Ascon * a, SConnection * con, int argc, char *argv[]) if (argc > 2) { a->timeout = atof(argv[2]); } else { - a->timeout = 2.0; /* sec */ + a->timeout = 1.0; /* sec */ } a->private = priv; a->killPrivate = free; diff --git a/makefile_linux b/makefile_linux index 4a0097b..dbb606f 100644 --- a/makefile_linux +++ b/makefile_linux @@ -13,7 +13,7 @@ include ../sllinux_def CC = gcc CFLAGS = -I$(HDFROOT)/include -DHDF4 -DHDF5 $(NI) -I$(TCLINC) -Ihardsup \ - -I.. -I. -MMD -DCYGNUS -DNONINTF -g $(DFORTIFY) -p \ + -I.. -I. -MMD -DCYGNUS -DNONINTF -g $(DFORTIFY) \ -Wall -Wno-unused -Wunused-value -Wno-comment -Wno-switch -Werror EXTRA=nintf.o diff --git a/sinqhttpopt.c b/sinqhttpopt.c index a7b545f..5b78fa7 100644 --- a/sinqhttpopt.c +++ b/sinqhttpopt.c @@ -229,7 +229,7 @@ static void handleReply(Ascon * a) clearSICSData(pHttp->binData); dataPtr = getSICSDataPointer(pHttp->binData, 0, len); for (i = 0; i < len; i++) { - dataPtr[i] = htonl(hmData[i]); + dataPtr[i] = ntohl(hmData[i]); } assignSICSType(pHttp->binData, 0, len, INTTYPE); DynStringClear(a->rdBuffer); @@ -250,7 +250,7 @@ static void handleReply(Ascon * a) pHttp->node->value.arrayLength = len; } for(i = 0; i < len; i++){ - pHttp->node->value.v.intArray[i] = htonl(hmData[i]); + pHttp->node->value.v.intArray[i] = ntohl(hmData[i]); } NotifyHipadabaPar(pHttp->node,NULL); DynStringClear(a->rdBuffer); diff --git a/tasscan.c b/tasscan.c index f62ded4..60ac818 100644 --- a/tasscan.c +++ b/tasscan.c @@ -1315,6 +1315,7 @@ int TASScan(SConnection * pCon, SicsInterp * pSics, void *pData, int i, status, iPtr, iTas; time_t iDate; struct tm *psTime; + float ach; /* check authorization @@ -1456,6 +1457,14 @@ int TASScan(SConnection * pCon, SicsInterp * pSics, void *pData, SCWrite(pCon, pLine, eLog); } + /* + check ACH + */ + ach = readDrivable("ach",pCon); + if(ach < .05) { + SCWrite(pCon,"WARNING: Analyser is flat",eWarning); + } + /* set our scan functions */