diff --git a/docho.c b/docho.c index c07da43..0915eae 100644 --- a/docho.c +++ b/docho.c @@ -117,8 +117,8 @@ static void SplitChopperReply(pCodri self, char *prefix, char *pBueffel) strcat(self->pParList, ","); } } else { - /* this fixes a bug with oversized messages in dphas */ - if (strstr(pPtr, "dphas") != NULL) { + /* this fixes a bug with oversized messages in dphas oder averl*/ + if (strstr(pPtr, "dphas") != NULL ) { sprintf(pEntry, "%s.dphas", prefix); iRet = StringDictUpdate(pPriv->pPar, pEntry, pPtr + 5); if (!iRet) { @@ -127,6 +127,15 @@ static void SplitChopperReply(pCodri self, char *prefix, char *pBueffel) strcat(self->pParList, ","); } } + if (strstr(pPtr, "averl") != NULL ) { + sprintf(pEntry, "%s.averl", prefix); + iRet = StringDictUpdate(pPriv->pPar, pEntry, pPtr + 5); + if (!iRet) { + StringDictAddPair(pPriv->pPar, pEntry, pPtr + 5); + strcat(self->pParList, pEntry); + strcat(self->pParList, ","); + } + } } pPtr = strtok(NULL, ";"); } diff --git a/make_gen b/make_gen index a5a892c..c480b99 100644 --- a/make_gen +++ b/make_gen @@ -23,7 +23,7 @@ OBJ=psi.o buffer.o ruli.o dmc.o nxsans.o nextrics.o sps.o pimotor.o \ dgrambroadcast.o sinq.o tabledrive.o tcpdocho.o julcho.o \ ritastorage.o poldizug.o audinelib.o delcam.o el737hpdrivsps.o \ rebin.o sanslirebin.o lmd200.o slsvme.o julprot.o sinqhttpprot.o \ - pmacprot.o + pmacprot.o pfeifferprot.o .SECONDARY.: sanslirebin.c diff --git a/pfeifferprot.c b/pfeifferprot.c new file mode 100644 index 0000000..4368fcd --- /dev/null +++ b/pfeifferprot.c @@ -0,0 +1,51 @@ +/** + * This is a protocol handler for the pfeiffer vacuum measurement device + * as used at FOCUS. It does not add very much, just the right terminators + * and the special feature to send a == ASCII 5 to the device. + * + * copyright: see file COPYRIGHT + * + * Mark Koennecke, March 2009 + */ +#include +#include + +static int PfeifferHandler(Ascon *a) +{ + char c = (char)5; + + switch(a->state){ + case AsconWriteStart: + if(strstr(GetCharArray(a->wrBuffer),"") != NULL) { + AsconWriteChars(a->fd,&c,1); + a->state = AsconWriteDone; + return 1; + } else { + return AsconStdHandler(a); + } + break; + default: + return AsconStdHandler(a); + } +} +/*=--------------------------------------------------------------------------*/ +static int PfeifferInit(Ascon *a, SConnection *con, int argc, char *argv[]) +{ + a->hostport = strdup(argv[1]); + a->sendTerminator = strdup("\n"); + a->timeout = 10; + a->replyTerminator = strdup("\n"); + return 1; +} + +/*-------------------------------------------------------------------------*/ +void AddPfeifferProtocoll() +{ + AsconProtocol *prot = NULL; + + prot = calloc(sizeof(AsconProtocol), 1); + prot->name = strdup("pfeiffer"); + prot->init = PfeifferInit; + prot->handler = PfeifferHandler; + AsconInsertProtocol(prot); +} diff --git a/polterwrite.c b/polterwrite.c index d67ef3c..3db6b1d 100644 --- a/polterwrite.c +++ b/polterwrite.c @@ -129,6 +129,7 @@ static void writeChopper(NXhandle hfil, NXdict hdict, SConnection * pCon) { SNXSPutVariable(pServ->pSics, pCon, hfil, hdict, "cname", "choppername"); SNXSPutDrivable(pServ->pSics, pCon, hfil, hdict, "chopperspeed", "crot"); + SNXSPutDrivable(pServ->pSics, pCon, hfil, hdict, "chopperphase", "cphase"); } /*-------------------------------------------------------------------*/ diff --git a/psi.c b/psi.c index 1b17d5b..107cf14 100644 --- a/psi.c +++ b/psi.c @@ -81,6 +81,8 @@ extern void AddJulChoProtocoll(); extern void AddHttpProtocoll(); /* from pmacprot.c */ extern void AddPMACProtocoll(); +/* from pfeifferprot.c */ +extern void AddPfeifferProtocoll(); /*--------------------------------------------------------------------------*/ void SiteInit(void) @@ -108,6 +110,7 @@ void SiteInit(void) AddJulChoProtocoll(); AddHttpProtocoll(); AddPMACProtocoll(); + AddPfeifferProtocoll(); } diff --git a/ptasdrive.c b/ptasdrive.c index 4df62ed..21b639e 100644 --- a/ptasdrive.c +++ b/ptasdrive.c @@ -198,7 +198,7 @@ int TASDrive(SConnection * pCon, SicsInterp * pSics, void *pData, } SCWrite(pCon, pBueffel, eWarning); status = StartMotor(pServ->pExecutor, pSics, pCon, - tasMotorOrder[i], newPositions[i]); + tasMotorOrder[i], RUNDRIVE, newPositions[i]); if (status == 0) { /* error should already have been reported by StartMotor */ rStatus = 0; diff --git a/sanslirebin.c b/sanslirebin.c index a7749af..e6da2a9 100644 --- a/sanslirebin.c +++ b/sanslirebin.c @@ -58,7 +58,19 @@ static int loadCorrectionData(SConnection * pCon, double *xPos, fclose(fd); return 1; } +/*---------------------------------------------------------------------------*/ +static double sansround(double d) +{ + double frac, low; + low = floor(d); + frac = d - low; + if(frac > .5){ + return low +1; + } else { + return low; + } +} /*---------------------------------------------------------------------------*/ int SansliRebin(SConnection * pCon, SicsInterp * pSics, void *pData, int argc, char *argv[]) @@ -146,7 +158,7 @@ int SansliRebin(SConnection * pCon, SicsInterp * pSics, void *pData, doubleCounts = (double) totalCounts; for (ix = 0; ix < 128 * 128; ix++, pos++) { if (corrSum > .01) { - val = floor(dataset->u.dPtr[ix] * doubleCounts / corrSum); + val = sansround(dataset->u.dPtr[ix] * doubleCounts / corrSum); } else { val = .0; } diff --git a/sinqhmdriv.c b/sinqhmdriv.c index ce196c8..f0ce9ee 100644 --- a/sinqhmdriv.c +++ b/sinqhmdriv.c @@ -502,6 +502,7 @@ static int SQStart(pHistDriver self, SConnection * pCon) pInternal->pCounter->pDes->GetInterface(pInternal->pCounter, COUNTID); if (pCountInt) { + ReleaseCountLock(pCountInt); return pCountInt->StartCount(pInternal->pCounter, pCon); } } @@ -635,6 +636,7 @@ static int SQStatus(pHistDriver self, SConnection * pCon) if (pCountInt) { status = pCountInt->CheckCountStatus(pInternal->pCounter, pCon); if ((status == HWFault)) { + ReleaseCountLock(pCountInt); return status; } } diff --git a/sinqhttp.c b/sinqhttp.c index d730dbe..ff4ed41 100644 --- a/sinqhttp.c +++ b/sinqhttp.c @@ -445,7 +445,7 @@ static int SinqHttpStatus(pHistDriver self, SConnection * pCon) return HWIdle; } else { pPriv->errorCode = BADSTATUS; - snprintf(pPriv->hmError, 511, "ERROR: invalid DAQ sttaus %s", + snprintf(pPriv->hmError, 511, "ERROR: invalid DAQ status %s", daqStatus); return HWFault; } diff --git a/sps.c b/sps.c index 03a61a8..348ebc4 100644 --- a/sps.c +++ b/sps.c @@ -232,7 +232,70 @@ int SPSGetStatus(pSPS self, int iStatus, int *iSet) } return 1; } +/*------------------------------------------------------------------------*/ +static void byteToString(unsigned char byte, char txt[9]) +{ + int i; + for(i = 0; i < 8; i++){ + if(byte & (1 << i) ){ + txt[i] = '1'; + } else { + txt[i] = '0'; + } + } +} +/*------------------------------------------------------------------------*/ +static int SPSBitPattern(pSPS self, SConnection *pCon) +{ + int iRet, i; + char pBueffel[256], *pPtr = NULL, pNum[10], pText[9]; + unsigned char byte; + pDynString result = NULL; + + /* send an R command down to the SPS */ + iRet = SPSCommand(self, "R", pBueffel, 255); + if (!iRet) { + SCWrite(pCon,"ERROR: communication error in SPSBitPattern", + eError); + return 0; + } + result = CreateDynString(128,128); + if(result == NULL){ + SCWrite(pCon,"ERROR: out of memory in SPSBitpattern", eError); + return 0; + } + /* decode the reply into the Byte array */ + pPtr = strchr(pBueffel, 'R'); + if (pPtr == NULL) { + return -2; + } + pPtr++; + for (i = 0; i < 16; i++) { + /* skip the whitespace */ + pPtr++; + pNum[0] = *pPtr; + pPtr++; + pNum[1] = *pPtr; + pPtr++; + pNum[2] = *pPtr; + pPtr++; + pNum[3] = '\0'; + byte = atoi(pNum); + memset(pText,0,9*sizeof(char)); + byteToString(byte, pText); + DynStringConcat(result, pText); + if(((i+1) % 4) == 0){ + DynStringConcatChar(result,'\n'); + } else { + DynStringConcatChar(result,' '); + } + } + SCWrite(pCon,GetCharArray(result), eValue); + DeleteDynString(result); + + return 1; +} /*------------------------------------------------------------------------- This is a special feature for SANS at SINQ. SANS has a collimator and the length of the collimator can only be deduced from the SPS status @@ -707,6 +770,10 @@ int SPSAction(SConnection * pCon, SicsInterp * pSics, void *pData, return 1; } } + /* -------- bit pattern*/ + else if (strcmp(argv[1], "bipa") == 0) { + return SPSBitPattern(self,pCon); + } sprintf(pBueffel, "ERROR: %s does not not understand subcommand %s", argv[0], argv[1]); SCWrite(pCon, pBueffel, eError); diff --git a/tasscan.c b/tasscan.c index 128038e..21b1a73 100644 --- a/tasscan.c +++ b/tasscan.c @@ -636,7 +636,7 @@ static int TASScanDrive(pScanData self, int iPoint) This is a motor, start it. */ StartMotor(pServ->pExecutor, self->pSics, self->pCon, pVar->Name, - pVar->fStart + iPoint * pVar->fStep); + RUNDRIVE, pVar->fStart + iPoint * pVar->fStep); /* Ignore errors. TAS scans continues when a motor runs into a limit. @@ -745,7 +745,7 @@ static int TASScanCount(pScanData self, int iPoint) */ fVal = GetCounterPreset(self->pCounterData); eOld = GetStatus(); - status = DoCount(self->pCounterData, fVal, self->pCon, 0); + status = DoCount(self->pCounterData, fVal, self->pCon, 1); iRet = Wait4Success(GetExecutor()); if (iRet == DEVINT) { SCWrite(self->pCon, "Counting aborted due to Interrupt", eLog); diff --git a/tasutil.c b/tasutil.c index 9035f65..18f8669 100644 --- a/tasutil.c +++ b/tasutil.c @@ -513,7 +513,7 @@ int TASStart(pTASdata self, SConnection * pCon, SicsInterp * pSics, for (i = 0; i < 6; i++) { if (motorMask[i] != 0) { status = StartMotor(pServ->pExecutor, pSics, pCon, - tasMotorOrder[i], motorTargets[i]); + tasMotorOrder[i], RUNDRIVE, motorTargets[i]); } } /* @@ -521,7 +521,7 @@ int TASStart(pTASdata self, SConnection * pCon, SicsInterp * pSics, */ if (motorMask[6]) { status = StartMotor(pServ->pExecutor, pSics, pCon, - "MCV", motorTargets[6]); + "MCV", RUNDRIVE, motorTargets[6]); if (status == 0) { /* the error will have been reported but must be ignored */ SCSetInterrupt(pCon, eContinue); @@ -530,7 +530,7 @@ int TASStart(pTASdata self, SConnection * pCon, SicsInterp * pSics, } if (motorMask[8]) { status = StartMotor(pServ->pExecutor, pSics, pCon, - "ACH", motorTargets[8]); + "ACH", RUNDRIVE, motorTargets[8]); if (status == 0) { /* the error will have been reported but must be ignored */ SCSetInterrupt(pCon, eContinue); @@ -788,7 +788,7 @@ float readDrivable(char *val, SConnection * pCon) -----------------------------------------------------------------------*/ void startCurrent(char *val, SConnection * pCon, float fVal) { - StartMotor(pServ->pExecutor, pServ->pSics, pCon, val, fVal); + StartMotor(pServ->pExecutor, pServ->pSics, pCon, val, RUNDRIVE,fVal); } /*-----------------------------------------------------------------------