- Fixed prolem wit core dump from commandlog

- Added fulltransact which sends a TRANSACTIONSTART meesage in addition to
  TRANSASCTIONFINISHED
- Added parameter to motor which allows to ignore positioning faults
- ADDED POLAN support to tasscan
This commit is contained in:
cvs
2003-10-17 10:07:04 +00:00
parent d63a4a4128
commit 501d336adb
5 changed files with 135 additions and 59 deletions

View File

@ -38,11 +38,16 @@ typedef struct __VelSelDriv *pVelSelDriv;
#define VSACCEL -7 #define VSACCEL -7
#define VSFAIL -2 #define VSFAIL -2
/* start speed */
#define STARTSPEED 3100
/*--------- special Dornier conditions*/ /*--------- special Dornier conditions*/
#define STARTED -88 #define STARTED -88
#define HALTREQ -77 #define HALTREQ -77
#define INVALIDSTATUS -7000 #define INVALIDSTATUS -7000
#define TARGETREJECTED -7001 #define TARGETREJECTED -7001
#define NOSTATUS -7002
/*---------- DORNIER status modes */ /*---------- DORNIER status modes */
#define STATSEND 1 #define STATSEND 1
@ -61,6 +66,10 @@ typedef struct __VelSelDriv *pVelSelDriv;
int minRPM; /* the minimum control speed of the thing*/ int minRPM; /* the minimum control speed of the thing*/
int haltCount; int haltCount;
int rejectCount; int rejectCount;
int noStatus; /* flag which indicates that no valid status
has yet been read. Solves a starting
problem
*/
} Dornier, *pDornier; } Dornier, *pDornier;
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
static int requestDornierStatus(pDornier pDorn){ static int requestDornierStatus(pDornier pDorn){
@ -91,6 +100,9 @@ static int readAndInterpretStatus(pDornier pDorn, DornierStatus *DStatus){
} }
DecodeNewDornierStatus(reply,DStatus); DecodeNewDornierStatus(reply,DStatus);
if(pDorn->noStatus == 1){
pDorn->noStatus = 0;
}
return 1; return 1;
} }
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
@ -99,7 +111,7 @@ static int takeControl(pDornier pDorn){
char pError[80]; char pError[80];
setRS232ReplyTerminator(pDorn->controller,"\\"); setRS232ReplyTerminator(pDorn->controller,"\\");
iRet = transactRS232(pDorn->controller,"REM\n",4,pError,79); iRet = transactRS232(pDorn->controller,"REM\n",4,pError,79);
setRS232ReplyTerminator(pDorn->controller,"\r\n"); setRS232ReplyTerminator(pDorn->controller,"\n");
return iRet; return iRet;
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
@ -148,19 +160,83 @@ static int takeControl(pDornier pDorn){
} }
return 1; return 1;
} }
/*----------------------------------------------------------------------*/
static int DornierText(pVelSelDriv self, char *pText, int iTextLen)
{
pDornier pDorn = NULL;
int iRet, iErrStat;
DornierStatus sStatus;
char pBueffel[1024];
char pHelp[80];
assert(self);
pDorn = (pDornier)self->pPrivate;
/*
use cached status while waiting for reply during drive
*/
if(pDorn->statusMode == STATSEND){
if(!requestDornierStatus(pDorn)){
return 0;
}
if(!readAndInterpretStatus(pDorn,&sStatus)){
return 0;
}
pDorn->lastStatus = sStatus;
} else {
sStatus = pDorn->lastStatus;
}
/* format it to a string */
sprintf(pHelp,"RPM: %d , should %d\n",sStatus.cur_rpm,sStatus.nom_rpm);
strcpy(pBueffel,pHelp);
sprintf(pHelp,"State: %s\n",sStatus.rm);
strcat(pBueffel,pHelp);
sprintf(pHelp,"Current: %d\n",sStatus.pwr);
strcat(pBueffel,pHelp);
sprintf(pHelp,"Rotor T: %d, Housing T: %d\n",sStatus.rot_temp,
sStatus.cont_temp);
strcat(pBueffel,pHelp);
sprintf(pHelp,"Cooling: In-T: %d, Out-T: %d, Flow: %f\n",
sStatus.inl_temp,sStatus.outl_temp,sStatus.cool_wat);
strcat(pBueffel,pHelp);
sprintf(pHelp,"Vaccum: %f, Accel: %f",sStatus.vacuum, sStatus.accel);
strcat(pBueffel,pHelp);
strncpy(pText,pBueffel, iTextLen);
return 1;
}
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static int DornierRun(pVelSelDriv self, float fVal) static int DornierRun(pVelSelDriv self, float fVal)
{ {
int iRet; int iRet;
char pCommand[50], pAnswer[50]; char pCommand[50], pAnswer[50], pText[132];
pDornier pDorn = NULL; pDornier pDorn = NULL;
int startFlag = 0; int startFlag = 0;
int i;
assert(self); assert(self);
pDorn = (pDornier)self->pPrivate; pDorn = (pDornier)self->pPrivate;
/* /*
less then minRPM, means halt in this case. make sure that a status was read before we do anything here,
otherwise we may be in deep trouble
*/
if(pDorn->noStatus == 1){
for(i = 0; i < 3; i++){
DornierText(self,pText,131);
if(pDorn->noStatus == 0){
break;
}
}
if(pDorn->noStatus == 1){
pDorn->iLastError = NOSTATUS;
return 0;
}
}
/*
less then STARTSPEED, 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 < 0){ if(fVal < 0){
@ -168,29 +244,33 @@ static int takeControl(pDornier pDorn){
} }
memset(pCommand,0,50); memset(pCommand,0,50);
pDorn->rejectCount = 0; pDorn->rejectCount = 0;
if(fVal < pDorn->minRPM - 3*self->fTolerance)
if(fVal < STARTSPEED - 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,"\\"); setRS232ReplyTerminator(pDorn->controller,"\r");
pDorn->haltCount = 0;
pDorn->fTarget = fVal;
} else { } else {
if(pDorn->lastStatus.cur_rpm < pDorn->minRPM){ if(pDorn->lastStatus.cur_rpm < STARTSPEED - 3 * self->fTolerance){
strcpy(pCommand,"SST\n"); strcpy(pCommand,"SST\n");
setRS232ReplyTerminator(pDorn->controller,"\\");
startFlag = 1; startFlag = 1;
pDorn->fTarget = pDorn->minRPM; pDorn->fTarget = STARTSPEED;
setRS232ReplyTerminator(pDorn->controller,"\r");
} else { } else {
setRS232ReplyTerminator(pDorn->controller,"\r");
sprintf(pCommand,"SDR %d\n",(int)fVal); sprintf(pCommand,"SDR %d\n",(int)fVal);
pDorn->fTarget = fVal;
} }
} }
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,"\n");
if(iRet != 1) if(iRet != 1)
{ {
if(iRet != INCOMPLETE){ if(iRet != INCOMPLETE){
@ -233,6 +313,10 @@ static int DornierError(pVelSelDriv self, int *iCode,
case TARGETREJECTED: case TARGETREJECTED:
strncpy(error,"VS in local mode or target out of range", iErrLen); strncpy(error,"VS in local mode or target out of range", iErrLen);
break; break;
case NOSTATUS:
strncpy(error,"No successfull status request after 3 tries",
iErrLen);
break;
default: default:
getRS232Error(pDorn->iLastError,error,iErrLen); getRS232Error(pDorn->iLastError,error,iErrLen);
break; break;
@ -262,7 +346,7 @@ static int DornierFixIt(pVelSelDriv self, int iCode){
return VELOREDO; return VELOREDO;
break; break;
case TARGETREJECTED: case TARGETREJECTED:
if(pDorn->rejectCount >= 1){ if(pDorn->rejectCount >= 3){
pDorn->rejectCount = 0; pDorn->rejectCount = 0;
return VELOFAIL; return VELOFAIL;
} }
@ -326,7 +410,7 @@ static int evaluateStatus(pVelSelDriv self, int *iCode){
/* /*
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 speed and actual speed
below difference below difference
*/ */
pDorn->fLastRPM = sStatus.cur_rpm; pDorn->fLastRPM = sStatus.cur_rpm;
@ -387,52 +471,6 @@ static int DornierStatNew(pVelSelDriv self, int *iCode, float *fCur){
return status; return status;
} }
} }
/*----------------------------------------------------------------------*/
static int DornierText(pVelSelDriv self, char *pText, int iTextLen)
{
pDornier pDorn = NULL;
int iRet, iErrStat;
DornierStatus sStatus;
char pBueffel[1024];
char pHelp[80];
assert(self);
pDorn = (pDornier)self->pPrivate;
/*
use cached status while waiting for reply during drive
*/
if(pDorn->statusMode == STATSEND){
if(!requestDornierStatus(pDorn)){
return 0;
}
if(!readAndInterpretStatus(pDorn,&sStatus)){
return 0;
}
pDorn->lastStatus = sStatus;
} else {
sStatus = pDorn->lastStatus;
}
/* format it to a string */
sprintf(pHelp,"RPM: %d , should %d\n",sStatus.cur_rpm,sStatus.nom_rpm);
strcpy(pBueffel,pHelp);
sprintf(pHelp,"State: %s\n",sStatus.rm);
strcat(pBueffel,pHelp);
sprintf(pHelp,"Current: %d\n",sStatus.pwr);
strcat(pBueffel,pHelp);
sprintf(pHelp,"Rotor T: %d, Housing T: %d\n",sStatus.rot_temp,
sStatus.cont_temp);
strcat(pBueffel,pHelp);
sprintf(pHelp,"Cooling: In-T: %d, Out-T: %d, Flow: %f\n",
sStatus.inl_temp,sStatus.outl_temp,sStatus.cool_wat);
strcat(pBueffel,pHelp);
sprintf(pHelp,"Vaccum: %f, Accel: %f",sStatus.vacuum, sStatus.accel);
strcat(pBueffel,pHelp);
strncpy(pText,pBueffel, iTextLen);
return 1;
}
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static int DornierLoss(pVelSelDriv self, float *fLoss) static int DornierLoss(pVelSelDriv self, float *fLoss)
{ {
@ -639,6 +677,7 @@ static int DornierStatNew(pVelSelDriv self, int *iCode, float *fCur){
free(pNew); free(pNew);
return NULL; return NULL;
} }
pDorn->noStatus = 1;
/* initialise function pointers */ /* initialise function pointers */
pNew->DeletePrivate = DornierKill; pNew->DeletePrivate = DornierKill;

View File

@ -318,6 +318,7 @@ static int EL734Fix(void *pData, int iCode, float fValue){
initRS232(self->controller); initRS232(self->controller);
return MOTREDO; return MOTREDO;
case RUNFAULT: case RUNFAULT:
case POSFAULT:
return MOTREDO; return MOTREDO;
} }
return MOTFAIL; return MOTFAIL;

View File

@ -114,6 +114,7 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
motorMask[i] = 0; motorMask[i] = 0;
} }
varPointer = -1; varPointer = -1;
motorPointer = -1;
rStatus = 1; rStatus = 1;
/* parse loop */ /* parse loop */

View File

@ -85,6 +85,33 @@ static void strcenter(char *str, char *target, int iLength)
} }
target[iLength-1] = '\0'; target[iLength-1] = '\0';
} }
/*-----------------------------------------------------------------------
helper function for TASHeader
------------------------------------------------------------------------*/
static void writePolFile(FILE *fd, pTASdata pTAS){
char pLine[132];
FILE *fpol = NULL;
assert(fd);
assert(pTAS);
fpol = fopen(pTAS->tasPar[POLFIL]->text,"r");
if(!fpol){
/*
error gets reported anyway later on
*/
return;
}
while(fgets(pLine,131,fpol) != NULL){
if(strstr(pLine,"\n") == NULL){
fprintf(fd,"POLAN: %s\n", pLine);
} else {
fprintf(fd,"POLAN: %s", pLine);
}
}
fclose(fpol);
}
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
TASHeader writes the header of a TAS data file. The format is an TASHeader writes the header of a TAS data file. The format is an
obscure format from ILL ( not ill but Institute Laue Langevin). No obscure format from ILL ( not ill but Institute Laue Langevin). No
@ -307,6 +334,10 @@ static int TASHeader(pScanData self)
} }
fprintf(self->fd,"\n"); fprintf(self->fd,"\n");
if(pTAS->iPOL >= 0){
writePolFile(self->fd,pTAS);
}
/* /*
write counter parameters write counter parameters
*/ */

View File

@ -186,6 +186,8 @@ static int clearTdc(pTdc self, unsigned char fill){
static int enableTdc(pTdc self){ static int enableTdc(pTdc self){
Z80_reg in, out; Z80_reg in, out;
return 1;
/* /*
range and n are obscure parameters range and n are obscure parameters
*/ */
@ -232,6 +234,8 @@ static int TDCStart(pHistDriver self, SConnection *pCon){
static int disableTdc(pTdc self){ static int disableTdc(pTdc self){
Z80_reg in, out; Z80_reg in, out;
return 1;
return ecbExecute(self->tdc,132,in,&out); return ecbExecute(self->tdc,132,in,&out);
} }
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/