- Added a protocol to spuuoprt the FOCUS Pfeiffer vacuum protocol
- Changed floor() to round() in sanslirebin - Some changes to accomodate the new run/drive behaviour - Added the the sps bipa command
This commit is contained in:
11
docho.c
11
docho.c
@ -117,7 +117,7 @@ static void SplitChopperReply(pCodri self, char *prefix, char *pBueffel)
|
||||
strcat(self->pParList, ",");
|
||||
}
|
||||
} else {
|
||||
/* this fixes a bug with oversized messages in dphas */
|
||||
/* 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);
|
||||
@ -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, ";");
|
||||
}
|
||||
|
2
make_gen
2
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
|
||||
|
||||
|
51
pfeifferprot.c
Normal file
51
pfeifferprot.c
Normal file
@ -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 <ENQ> == ASCII 5 to the device.
|
||||
*
|
||||
* copyright: see file COPYRIGHT
|
||||
*
|
||||
* Mark Koennecke, March 2009
|
||||
*/
|
||||
#include <ascon.h>
|
||||
#include <ascon.i>
|
||||
|
||||
static int PfeifferHandler(Ascon *a)
|
||||
{
|
||||
char c = (char)5;
|
||||
|
||||
switch(a->state){
|
||||
case AsconWriteStart:
|
||||
if(strstr(GetCharArray(a->wrBuffer),"<ENQ>") != 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);
|
||||
}
|
@ -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");
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
3
psi.c
3
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();
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
67
sps.c
67
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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user