- Improvements to the chooper driver for the SANS2 chopper
- Fixes to the new counter and motor drivers - Updated Linux makefiles to linux_def
This commit is contained in:
90
dornier2.c
90
dornier2.c
@ -41,6 +41,8 @@ typedef struct __VelSelDriv *pVelSelDriv;
|
|||||||
/*--------- special Dornier conditions*/
|
/*--------- special Dornier conditions*/
|
||||||
#define STARTED -88
|
#define STARTED -88
|
||||||
#define HALTREQ -77
|
#define HALTREQ -77
|
||||||
|
#define INVALIDSTATUS -7000
|
||||||
|
#define TARGETREJECTED -7001
|
||||||
|
|
||||||
/*---------- DORNIER status modes */
|
/*---------- DORNIER status modes */
|
||||||
#define STATSEND 1
|
#define STATSEND 1
|
||||||
@ -58,6 +60,7 @@ typedef struct __VelSelDriv *pVelSelDriv;
|
|||||||
DornierStatus lastStatus;
|
DornierStatus lastStatus;
|
||||||
int minRPM; /* the minimum control speed of the thing*/
|
int minRPM; /* the minimum control speed of the thing*/
|
||||||
int haltCount;
|
int haltCount;
|
||||||
|
int rejectCount;
|
||||||
} Dornier, *pDornier;
|
} Dornier, *pDornier;
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
static int requestDornierStatus(pDornier pDorn){
|
static int requestDornierStatus(pDornier pDorn){
|
||||||
@ -81,10 +84,24 @@ static int readAndInterpretStatus(pDornier pDorn, DornierStatus *DStatus){
|
|||||||
pDorn->iLastError = status;
|
pDorn->iLastError = status;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if(strlen(reply) < 80){
|
||||||
|
pDorn->iLastError = INVALIDSTATUS;
|
||||||
|
pDorn->statusMode = STATSEND;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
DecodeNewDornierStatus(reply,DStatus);
|
DecodeNewDornierStatus(reply,DStatus);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------------*/
|
||||||
|
static int takeControl(pDornier pDorn){
|
||||||
|
int iRet;
|
||||||
|
char pError[80];
|
||||||
|
setRS232ReplyTerminator(pDorn->controller,"\\");
|
||||||
|
iRet = transactRS232(pDorn->controller,"REM\n",4,pError,79);
|
||||||
|
setRS232ReplyTerminator(pDorn->controller,"\r\n");
|
||||||
|
return iRet;
|
||||||
|
}
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
static int GetDornierPos(pVelSelDriv self, float *fPos)
|
static int GetDornierPos(pVelSelDriv self, float *fPos)
|
||||||
{
|
{
|
||||||
@ -146,32 +163,41 @@ static int readAndInterpretStatus(pDornier pDorn, DornierStatus *DStatus){
|
|||||||
less then minRPM, means halt in this case.
|
less then minRPM, means halt in this case.
|
||||||
Accept this only after three times, see code in GetError as well.
|
Accept this only after three times, see code in GetError as well.
|
||||||
*/
|
*/
|
||||||
if(fVal < pDorn->minRPM - self->fTolerance)
|
if(fVal < 0){
|
||||||
|
fVal = - fVal;
|
||||||
|
}
|
||||||
|
memset(pCommand,0,50);
|
||||||
|
pDorn->rejectCount = 0;
|
||||||
|
if(fVal < pDorn->minRPM - 3*self->fTolerance)
|
||||||
{
|
{
|
||||||
if(pDorn->haltCount < 3){
|
if(pDorn->haltCount < 3){
|
||||||
pDorn->iLastError = HALTREQ;
|
pDorn->iLastError = HALTREQ;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
strcpy(pCommand,"HAL\n");
|
strcpy(pCommand,"HAL\n");
|
||||||
|
setRS232ReplyTerminator(pDorn->controller,"\\");
|
||||||
} else {
|
} else {
|
||||||
if(pDorn->lastStatus.cur_rpm < pDorn->minRPM){
|
if(pDorn->lastStatus.cur_rpm < pDorn->minRPM){
|
||||||
strcpy(pCommand,"SST\n");
|
strcpy(pCommand,"SST\n");
|
||||||
|
setRS232ReplyTerminator(pDorn->controller,"\\");
|
||||||
startFlag = 1;
|
startFlag = 1;
|
||||||
pDorn->fTarget = pDorn->minRPM;
|
pDorn->fTarget = pDorn->minRPM;
|
||||||
} else {
|
} else {
|
||||||
snprintf(pCommand,49,"SDR %5u\n",(int)nintf(fVal));
|
sprintf(pCommand,"SDR %d\n",(int)fVal);
|
||||||
pDorn->fTarget = fVal;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setRS232ReplyTerminator(pDorn->controller,"\\");
|
pDorn->fTarget = fVal;
|
||||||
iRet = transactRS232(pDorn->controller,pCommand,strlen(pCommand),
|
iRet = transactRS232(pDorn->controller,pCommand,strlen(pCommand),
|
||||||
pAnswer,49);
|
pAnswer,49);
|
||||||
setRS232ReplyTerminator(pDorn->controller,"\r\n");
|
setRS232ReplyTerminator(pDorn->controller,"\r\n");
|
||||||
if(iRet != 1)
|
if(iRet != 1)
|
||||||
{
|
{
|
||||||
pDorn->iLastError = iRet;
|
if(iRet != INCOMPLETE){
|
||||||
return 0;
|
|
||||||
|
pDorn->iLastError = iRet;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pDorn->statusMode = STATSEND;
|
pDorn->statusMode = STATSEND;
|
||||||
if(startFlag){
|
if(startFlag){
|
||||||
@ -201,6 +227,12 @@ static int DornierError(pVelSelDriv self, int *iCode,
|
|||||||
"Started selector, standby and check manually when ready",
|
"Started selector, standby and check manually when ready",
|
||||||
iErrLen);
|
iErrLen);
|
||||||
break;
|
break;
|
||||||
|
case INVALIDSTATUS:
|
||||||
|
strncpy(error,"Received invalid status reply",iErrLen);
|
||||||
|
break;
|
||||||
|
case TARGETREJECTED:
|
||||||
|
strncpy(error,"VS in local mode or target out of range", iErrLen);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
getRS232Error(pDorn->iLastError,error,iErrLen);
|
getRS232Error(pDorn->iLastError,error,iErrLen);
|
||||||
break;
|
break;
|
||||||
@ -210,7 +242,7 @@ static int DornierError(pVelSelDriv self, int *iCode,
|
|||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
static int DornierFixIt(pVelSelDriv self, int iCode){
|
static int DornierFixIt(pVelSelDriv self, int iCode){
|
||||||
pDornier pDorn = NULL;
|
pDornier pDorn = NULL;
|
||||||
int status;
|
int status, oldReject;
|
||||||
|
|
||||||
assert(self);
|
assert(self);
|
||||||
pDorn = (pDornier)self->pPrivate;
|
pDorn = (pDornier)self->pPrivate;
|
||||||
@ -226,8 +258,23 @@ static int DornierFixIt(pVelSelDriv self, int iCode){
|
|||||||
break;
|
break;
|
||||||
case TIMEOUT:
|
case TIMEOUT:
|
||||||
case INCOMPLETE:
|
case INCOMPLETE:
|
||||||
|
case INVALIDSTATUS:
|
||||||
return VELOREDO;
|
return VELOREDO;
|
||||||
break;
|
break;
|
||||||
|
case TARGETREJECTED:
|
||||||
|
if(pDorn->rejectCount >= 1){
|
||||||
|
pDorn->rejectCount = 0;
|
||||||
|
return VELOFAIL;
|
||||||
|
}
|
||||||
|
oldReject = pDorn->rejectCount;
|
||||||
|
status = takeControl(pDorn);
|
||||||
|
if(status == 1){
|
||||||
|
DornierRun(self,pDorn->fTarget);
|
||||||
|
pDorn->rejectCount = oldReject + 1;
|
||||||
|
return VELOREDO;
|
||||||
|
}
|
||||||
|
return VELOFAIL;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return VELOFAIL;
|
return VELOFAIL;
|
||||||
}
|
}
|
||||||
@ -262,6 +309,21 @@ static int evaluateStatus(pVelSelDriv self, int *iCode){
|
|||||||
}
|
}
|
||||||
|
|
||||||
*iCode = ROTMOVE;
|
*iCode = ROTMOVE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
sometimes the velocity selector does not accept a new target:
|
||||||
|
Two reasons: a) it is local, b) out of range
|
||||||
|
Check for this here as it is the only place appropriate.
|
||||||
|
*/
|
||||||
|
fDelta = sStatus.nom_rpm - pDorn->fTarget;
|
||||||
|
if(fDelta < 0){
|
||||||
|
fDelta = - fDelta;
|
||||||
|
}
|
||||||
|
if(fDelta > self->fTolerance){
|
||||||
|
pDorn->iLastError = TARGETREJECTED;
|
||||||
|
return VSFAIL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This code considers the velocity selector arrived if it reads
|
This code considers the velocity selector arrived if it reads
|
||||||
four times a difference between requested spped and actual speed
|
four times a difference between requested spped and actual speed
|
||||||
@ -433,12 +495,11 @@ static int DornierStatNew(pVelSelDriv self, int *iCode, float *fCur){
|
|||||||
static void DornierKill(void *pData)
|
static void DornierKill(void *pData)
|
||||||
{
|
{
|
||||||
pDornier pDorn = NULL;
|
pDornier pDorn = NULL;
|
||||||
char pAns[10];
|
|
||||||
|
|
||||||
pDorn = (pDornier)pData;
|
pDorn = (pDornier)pData;
|
||||||
assert(pDorn);
|
assert(pDorn);
|
||||||
|
|
||||||
transactRS232(pDorn->controller,"TTY\n",4,pAns,10);
|
writeRS232(pDorn->controller,"TTY\n",4);
|
||||||
KillRS232(pDorn->controller);
|
KillRS232(pDorn->controller);
|
||||||
free(pDorn);
|
free(pDorn);
|
||||||
}
|
}
|
||||||
@ -460,15 +521,13 @@ static int DornierStatNew(pVelSelDriv self, int *iCode, float *fCur){
|
|||||||
}
|
}
|
||||||
setRS232SendTerminator(pDorn->controller,"\n");
|
setRS232SendTerminator(pDorn->controller,"\n");
|
||||||
setRS232Timeout(pDorn->controller,pDorn->iTimeOut);
|
setRS232Timeout(pDorn->controller,pDorn->iTimeOut);
|
||||||
setRS232Debug(pDorn->controller,1);
|
setRS232Debug(pDorn->controller,0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
tell him that we want control.
|
tell him that we want control.
|
||||||
Funny enough no <cr> or <nl> is sent in the reply to this.
|
Funny enough no <cr> or <nl> is sent in the reply to this.
|
||||||
*/
|
*/
|
||||||
setRS232ReplyTerminator(pDorn->controller,"\\");
|
iRet = takeControl(pDorn);
|
||||||
iRet = transactRS232(pDorn->controller,"REM\n",4,pError,79);
|
|
||||||
setRS232ReplyTerminator(pDorn->controller,"\r\n");
|
|
||||||
if(iRet != 1)
|
if(iRet != 1)
|
||||||
{
|
{
|
||||||
sprintf(pBueffel,
|
sprintf(pBueffel,
|
||||||
@ -480,11 +539,6 @@ static int DornierStatNew(pVelSelDriv self, int *iCode, float *fCur){
|
|||||||
check which status the velo is in
|
check which status the velo is in
|
||||||
*/
|
*/
|
||||||
pDorn->statusMode = STATSEND;
|
pDorn->statusMode = STATSEND;
|
||||||
GetDornierPos(self,&fRot);
|
|
||||||
if(fRot < 0){
|
|
||||||
GetDornierPos(self,&fRot);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
@ -132,7 +132,7 @@ static int EL734Run(void *pData,float fValue){
|
|||||||
assert(self);
|
assert(self);
|
||||||
|
|
||||||
self->oredMsr = 0;
|
self->oredMsr = 0;
|
||||||
snprintf(pCommand,79,"p %d %3.f\r",self->iMotor,fValue);
|
snprintf(pCommand,79,"p %d %.3f\r",self->iMotor,fValue);
|
||||||
status = transactRS232(self->controller,pCommand,strlen(pCommand),
|
status = transactRS232(self->controller,pCommand,strlen(pCommand),
|
||||||
pReply,79);
|
pReply,79);
|
||||||
if(status != 1){
|
if(status != 1){
|
||||||
|
@ -283,7 +283,7 @@ static int EL737Start(struct __COUNTER *self){
|
|||||||
|
|
||||||
fixMode(pPriv);
|
fixMode(pPriv);
|
||||||
if(self->eMode == ePreset){
|
if(self->eMode == ePreset){
|
||||||
snprintf(pCommand,49,"MP %d\r",(int)nintf(self->fPreset));
|
snprintf(pCommand,49,"MP %d\r",(int)self->fPreset);
|
||||||
} else {
|
} else {
|
||||||
snprintf(pCommand,49,"TP %.2f\r", self->fPreset);
|
snprintf(pCommand,49,"TP %.2f\r", self->fPreset);
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
# Mark Koennecke, November 1996
|
# Mark Koennecke, November 1996
|
||||||
# Markus Zolliker, March 2003
|
# Markus Zolliker, March 2003
|
||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
# the following line only for fortified version
|
|
||||||
#DFORTIFY=-DFORTIFY
|
include ../../linux_def
|
||||||
#==========================================================================
|
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -g -DLINUX $(DFORTIFY) -I$(SRC). -I.. -I../..
|
CFLAGS = -g -DLINUX $(DFORTIFY) -I$(SRC). -I.. -I../..
|
||||||
|
@ -5,16 +5,13 @@
|
|||||||
# Mark Koennecke 1996-2001
|
# Mark Koennecke 1996-2001
|
||||||
# Markus Zolliker, March 2003
|
# Markus Zolliker, March 2003
|
||||||
#==========================================================================
|
#==========================================================================
|
||||||
# the following lines only for fortified version
|
|
||||||
#DFORTIFY=-DFORTIFY
|
include ../linux_def
|
||||||
#FORTIFYOBJ=strdup.o fortify.o
|
|
||||||
#==========================================================================
|
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -I$(HDFROOT)/include -DHDF4 -DHDF5 $(NI) -Ihardsup \
|
CFLAGS = -I$(HDFROOT)/include -DHDF4 -DHDF5 $(NI) -Ihardsup \
|
||||||
-I../ -fwritable-strings -DCYGNUS -DNONINTF -g $(DFORTIFY)
|
-I../ -fwritable-strings -DCYGNUS -DNONINTF -g $(DFORTIFY)
|
||||||
|
|
||||||
HDFROOT=/afs/psi.ch/project/sinq/linux
|
|
||||||
EXTRA=nintf.o
|
EXTRA=nintf.o
|
||||||
|
|
||||||
include make_gen
|
include make_gen
|
||||||
|
4
psi.c
4
psi.c
@ -160,7 +160,7 @@ static pMotor CreatePsiMotor(SConnection *pCon, int argc, char *argv[]){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else if(strcmp(argv[1],"ecb") == 0){
|
} else if(strcmp(argv[1],"ecb") == 0){
|
||||||
pDriver = (MotorDriver *)CreateECBMotor(pCon,argc-1,&argv[2]);
|
pDriver = (MotorDriver *)CreateECBMotor(pCon,argc-2,&argv[2]);
|
||||||
if(!pDriver){
|
if(!pDriver){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -198,8 +198,8 @@ static pCounterDriver CreatePsiCounterDriver(SConnection *pCon,
|
|||||||
"ERROR: insufficient no of arguments to create ECB counter",
|
"ERROR: insufficient no of arguments to create ECB counter",
|
||||||
eError);
|
eError);
|
||||||
return NULL;
|
return NULL;
|
||||||
pNew = MakeECBCounter(argv[3]);
|
|
||||||
}
|
}
|
||||||
|
pNew = MakeECBCounter(argv[3]);
|
||||||
}
|
}
|
||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,8 @@
|
|||||||
#
|
#
|
||||||
# Markus Zolliker, March 2003
|
# Markus Zolliker, March 2003
|
||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
# the following lines only for fortified version
|
|
||||||
DFORTIFY=-DFORTIFY -I$(SRC)..
|
include ../../linux_def
|
||||||
FORTIFYOBJ=../strdup.o ../fortify.o
|
|
||||||
#==========================================================================
|
|
||||||
|
|
||||||
SICST=..
|
SICST=..
|
||||||
SICS=$(SRC)..
|
SICS=$(SRC)..
|
||||||
|
Reference in New Issue
Block a user