- reintroducted MF/TEM

This commit is contained in:
zolliker
2007-09-25 06:52:27 +00:00
parent e36dc843ed
commit c7c561b723
7 changed files with 147 additions and 101 deletions

View File

@ -12,7 +12,7 @@ include ../sllinux_def
CC = gcc CC = gcc
CFLAGS = -I$(HDFROOT)/include -DHDF4 -DHDF5 $(NI) -Ihardsup \ CFLAGS = -I$(HDFROOT)/include -DHDF4 -DHDF5 $(NI) -Ihardsup \
-I.. -DCYGNUS -DNONINTF -g $(DFORTIFY) \ -I.. -DCYGNUS -DNONINTF -g $(DFORTIFY) \
-Wall -Werror -Wno-unused -Wno-comment -Wno-switch -Wall -Wno-unused -Wno-comment -Wno-switch -Werror
EXTRA=nintf.o EXTRA=nintf.o

View File

@ -44,6 +44,8 @@ extern char *stptok(const char *s, char *tok, size_t toklen, char *brk);
driven. Additionally we have to check for special energy or Q variables driven. Additionally we have to check for special energy or Q variables
which require a triple axis calculation. which require a triple axis calculation.
M.Z. June 07: storage order mode only allowed for QH,QK,QL,EN.
It helps if one understands some fundamental things used in the code It helps if one understands some fundamental things used in the code
below: below:
- motorMask holds a value for each motor in the motor list. The - motorMask holds a value for each motor in the motor list. The
@ -77,7 +79,7 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
unsigned char motorMask[MAXMOT]; unsigned char motorMask[MAXMOT];
float newPositions[MAXMOT]; float newPositions[MAXMOT];
pMotor pMot; pMotor pMot;
int qhPars;
assert(pCon); assert(pCon);
@ -116,6 +118,7 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
varPointer = -1; varPointer = -1;
motorPointer = -1; motorPointer = -1;
rStatus = 1; rStatus = 1;
qhPars = 0;
/* parse loop */ /* parse loop */
while(pPtr != NULL) while(pPtr != NULL)
@ -129,13 +132,9 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
if(lastToken == NUM) if(lastToken == NUM)
{ {
/* handle storage order logic */ /* handle storage order logic */
if(motorPointer > -1) if(varPointer > -1 && qhPars > 1)
{ {
motorPointer++; varPointer++; qhPars--;
}
else if(varPointer > -1)
{
varPointer++;
} }
else else
{ {
@ -175,6 +174,9 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
iTAS = 1; iTAS = 1;
motorPointer = -1; motorPointer = -1;
varPointer = status; varPointer = status;
if (EMIN + varPointer == QH) {
qhPars = 4;
}
} }
else if( (status = isTASMotor(pToken)) > -1) else if( (status = isTASMotor(pToken)) > -1)
{ {
@ -190,6 +192,7 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
} }
} }
}/* end of parse loop */ }/* end of parse loop */
if(rStatus != 1) if(rStatus != 1)
return rStatus; return rStatus;
@ -208,13 +211,14 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
if(pMot) if(pMot)
{ {
MotorGetSoftPosition(pMot, pCon, &oldPos); MotorGetSoftPosition(pMot, pCon, &oldPos);
sprintf(pBueffel,"Driving %s from %f to %f",
tasMotorOrder[i],oldPos,newPositions[i]);
} }
else else
{ {
oldPos = -9999.; sprintf(pBueffel,"Driving %s to %f",
tasMotorOrder[i],newPositions[i]);
} }
sprintf(pBueffel,"Driving %s from %f to %f",
tasMotorOrder[i],oldPos,newPositions[i]);
SCWrite(pCon,pBueffel,eWarning); SCWrite(pCon,pBueffel,eWarning);
status = StartMotor(pServ->pExecutor,pSics,pCon, status = StartMotor(pServ->pExecutor,pSics,pCon,
tasMotorOrder[i],newPositions[i]); tasMotorOrder[i],newPositions[i]);
@ -232,6 +236,11 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
*/ */
if(iTAS > 0) if(iTAS > 0)
{ {
if (qhPars == 3) {
SCWrite(pCon, "ERROR: QH cannot have 2 values", eError);
return 0;
}
status = TASCalc(self,pCon,tasMask,tasTargets, tasTargetMask); status = TASCalc(self,pCon,tasMask,tasTargets, tasTargetMask);
if(status) if(status)
{ {

6
tas.h
View File

@ -36,6 +36,7 @@
#define BX 22 #define BX 22
#define BY 23 #define BY 23
#define BZ 24 #define BZ 24
#define EI 25 #define EI 25
#define KI 26 #define KI 26
#define EF 27 #define EF 27
@ -153,7 +154,10 @@
#define PFY 134 #define PFY 134
#define PFZ 135 #define PFZ 135
#define MAXPAR 136 #define DMF 136
#define DTEM 137
#define MAXPAR 138
#define MAXADD 20 #define MAXADD 20
#define MAXEVAR 12 #define MAXEVAR 12

View File

@ -24,6 +24,7 @@
#include <scan.h> #include <scan.h>
#include <scan.i> #include <scan.i>
#include "tas.h" #include "tas.h"
#include "tasu.h"
extern int getSRO(SConnection *pCon, float *fVal); /* tasutil.c */ extern int getSRO(SConnection *pCon, float *fVal); /* tasutil.c */
@ -31,7 +32,7 @@ extern int getSRO(SConnection *pCon, float *fVal); /* tasutil.c */
As variables may be accessed in storage order, it is necessary to As variables may be accessed in storage order, it is necessary to
know the order of the motors know the order of the motors
*/ */
char *tasMotorOrder[] = { "a1", char *tasMotorOrder[MAXMOT+1] = { "a1",
"a2", "a2",
"a3", "a3",
"a4", "a4",
@ -63,6 +64,8 @@ char *tasMotorOrder[] = { "a1",
"i6", "i6",
"i7", "i7",
"i8", "i8",
"mf",
"tem",
NULL }; NULL };
/* /*
In order to initialise the variable array in the TAS data structure we In order to initialise the variable array in the TAS data structure we
@ -70,7 +73,7 @@ char *tasMotorOrder[] = { "a1",
has to match the order defined in tas.h through the defines. Otherwise has to match the order defined in tas.h through the defines. Otherwise
quite weird things may happen at runtime. quite weird things may happen at runtime.
*/ */
char *tasVariableOrder[] = { char *tasVariableOrder[MAXPAR+1] = {
"wav", "wav",
"dm", "dm",
"da", "da",
@ -207,6 +210,8 @@ char *tasVariableOrder[] = {
"pfx", "pfx",
"pfy", "pfy",
"pfz", "pfz",
"dmf",
"dtem",
NULL}; NULL};
/*------------------------------------------------------------------- /*-------------------------------------------------------------------
Normally SICS does not store motor hardware limits into status files as Normally SICS does not store motor hardware limits into status files as
@ -227,6 +232,9 @@ static int TasSaveStatus(void *self, char *name, FILE *fd)
{ {
return 0; return 0;
} }
if (strcmp(name, "dr") != 0) { /* save only once (for dr, but not for sc,fs,updateqe) */
return 1;
}
while(tasMotorOrder[i] != NULL) while(tasMotorOrder[i] != NULL)
{ {
pMot = FindMotor(pServ->pSics,tasMotorOrder[i]); pMot = FindMotor(pServ->pSics,tasMotorOrder[i]);

184
tasscan.c
View File

@ -339,40 +339,26 @@ static int TASHeader(pScanData self)
} }
/*
write currents if in polarisation mode
*/
if(pTAS->iPOL >= 0){
fprintf(self->fd,"VARIA: ");
iCount = 0;
for(i = MAXMOT-8; i < MAXMOT;i++)
{
fVal = readDrivable(tasMotorOrder[i],self->pCon);
strcpy(pWork2,tasMotorOrder[i]);
strtoupper(pWork2);
fprintf(self->fd,"%-8s=%8.4f, ",pWork2,fVal);
iCount++;
}
fprintf(self->fd,"\n");
}
/* /*
write motors and currents write motors and currents
*/ */
fprintf(self->fd,"VARIA: "); fprintf(self->fd,"VARIA: ");
iCount = 0; iCount = 0;
for(i = 0; i < MAXMOT-8;i++) for(i = 0; i < MAXMOT;i++)
{ {
fVal = readDrivable(tasMotorOrder[i],self->pCon); if (pTAS->iPOL >= 0 || (tasMotorOrder[i][0] != 'i' && tasMotorOrder[i][0] != 'h')) {
if(iCount == 3) /* do not write currents (names starting with i or h) when not in pol. mode */
{ fVal = readDrivable(tasMotorOrder[i],self->pCon);
iCount = 0; if(iCount == 3)
fprintf(self->fd,"\nVARIA: "); {
iCount = 0;
fprintf(self->fd,"\nVARIA: ");
}
strcpy(pWork2,tasMotorOrder[i]);
strtoupper(pWork2);
fprintf(self->fd,"%-8s=%8.4f, ",pWork2,fVal);
iCount++;
} }
strcpy(pWork2,tasMotorOrder[i]);
strtoupper(pWork2);
fprintf(self->fd,"%-8s=%8.4f, ",pWork2,fVal);
iCount++;
} }
fprintf(self->fd,"\n"); fprintf(self->fd,"\n");
@ -1002,6 +988,7 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
char *myBuffer = NULL, pToken[20], *pPtr, pError[132]; char *myBuffer = NULL, pToken[20], *pPtr, pError[132];
int iPtr, lastToken, lastVar; int iPtr, lastToken, lastVar;
VarType vt; VarType vt;
int qhPars;
/* /*
set up our own buffer set up our own buffer
@ -1019,6 +1006,7 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
*/ */
lastToken = NONE; lastToken = NONE;
lastVar = -1; lastVar = -1;
qhPars = 0;
pPtr = stptok(pBueffel,pToken,20," ,="); /* step over sc */ pPtr = stptok(pBueffel,pToken,20," ,="); /* step over sc */
while(pPtr != NULL) while(pPtr != NULL)
{ {
@ -1034,7 +1022,7 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
"ERROR: parse error at %s, expected variable", "ERROR: parse error at %s, expected variable",
pToken); pToken);
SCWrite(pCon,pError,eError); SCWrite(pCon,pError,eError);
return 0; goto error;
} }
lastToken = TXT; lastToken = TXT;
if( (iPtr = isTASVar(pToken)) >= 0 ) if( (iPtr = isTASVar(pToken)) >= 0 )
@ -1061,46 +1049,11 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
if(tasNumeric(pToken)) if(tasNumeric(pToken))
{ {
lastToken = NUM; lastToken = NUM;
if(lastVar >= 0) if (qhPars == 3) {
{ SCWrite(pCon, "DQH cannot have 2 values", eError);
vt = GetVarType(pTAS->tasPar[lastVar]); goto error;
if(vt == veFloat)
{
VarSetFloat(pTAS->tasPar[lastVar],atof(pToken),
usInternal);
SCparChange(pCon);
}
else if(vt == veInt)
{
VarSetInt(pTAS->tasPar[lastVar],
(int)atof(pToken), usInternal);
SCparChange(pCon);
}
else
{
pTAS->tasPar[lastVar]->text = strdup(pToken);
SCparChange(pCon);
}
lastVar++;
} }
else qhPars = 0;
{
strcat(myBuffer,pToken);
strcat(myBuffer," ");
}
}
else
{
sprintf(pError,"ERROR: parse error at %s, expected number",
pToken);
SCWrite(pCon,pError,eError);
return 0;
}
break;
case NUM:
if(tasNumeric(pToken))
{
lastToken = NUM;
if(lastVar >= 0) if(lastVar >= 0)
{ {
vt = GetVarType(pTAS->tasPar[lastVar]); vt = GetVarType(pTAS->tasPar[lastVar]);
@ -1130,6 +1083,53 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
} }
else else
{ {
sprintf(pError,"ERROR: parse error at %s, expected number",
pToken);
SCWrite(pCon,pError,eError);
goto error;
}
break;
case NUM:
if(tasNumeric(pToken))
{
lastToken = NUM;
if(lastVar >= 0)
{
if (qhPars == 0) {
if (lastVar != DQK) {
SCPrintf(pCon, eError, "ERROR: %s can have only one value",
tasVariableOrder[lastVar-1]);
goto error;
}
qhPars = 3;
} else if (qhPars == 1) {
SCWrite(pCon, "ERROR: DQH can have only 4 values", eError);
goto error;
} else {
qhPars--;
}
vt = GetVarType(pTAS->tasPar[lastVar]);
if(vt != veFloat)
{
SCPrintf(pCon, eError, "ERROR: %s must be float (internal error)",
tasVariableOrder[lastVar]);
goto error;
}
VarSetFloat(pTAS->tasPar[lastVar],atof(pToken),
usInternal);
SCparChange(pCon);
lastVar++;
}
else
{
strcat(myBuffer,pToken);
strcat(myBuffer," ");
}
}
else
{
lastToken = TXT;
lastVar = -1; lastVar = -1;
if( (iPtr = isTASVar(pToken)) >= 0 ) if( (iPtr = isTASVar(pToken)) >= 0 )
{ {
@ -1154,9 +1154,16 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
break; break;
} }
} }
if (qhPars == 3) {
SCWrite(pCon, "DQH cannot have 2 values", eError);
goto error;
}
strcpy(pBueffel, myBuffer); strcpy(pBueffel, myBuffer);
free(myBuffer); free(myBuffer);
return 1; return 1;
error:
free(myBuffer);
return 0;
} }
/*------------------------------------------------------------------- /*-------------------------------------------------------------------
EnterScanVar adds the scan variable given to the scan. Thereby it EnterScanVar adds the scan variable given to the scan. Thereby it
@ -1223,6 +1230,7 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
char pToken[20], *pPtr, pError[132]; char pToken[20], *pPtr, pError[132];
int iPtr, lastToken, lastVar, lastMotor, status; int iPtr, lastToken, lastVar, lastMotor, status;
VarType vt; VarType vt;
int qhPars;
/* /*
parse loop parse loop
@ -1230,6 +1238,7 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
lastToken = NONE; lastToken = NONE;
lastVar = lastMotor = -1; lastVar = lastMotor = -1;
pPtr = pBueffel; pPtr = pBueffel;
qhPars = 0;
while(pPtr != NULL) while(pPtr != NULL)
{ {
pPtr = stptok(pPtr,pToken,20," ,="); pPtr = stptok(pPtr,pToken,20," ,=");
@ -1269,6 +1278,11 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
if(tasNumeric(pToken)) if(tasNumeric(pToken))
{ {
lastToken = NUM; lastToken = NUM;
if (qhPars == 3) {
SCWrite(pCon, "QH cannot have 2 values", eError);
return 0;
}
qhPars = 0;
if(lastVar >= 0) if(lastVar >= 0)
{ {
/* /*
@ -1312,6 +1326,20 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
lastToken = NUM; lastToken = NUM;
if(lastVar >= 0) if(lastVar >= 0)
{ {
if (qhPars == 0) {
if (EMIN + lastVar != QK) {
SCPrintf(pCon, eError, "ERROR: %s can have only one value",
tasVariableOrder[EMIN+lastVar-1]);
return 0;
}
qhPars = 3;
} else if (qhPars == 1) {
SCWrite(pCon, "ERROR: QH can have only 4 values", eError);
return 0;
} else {
qhPars--;
}
/* /*
add energy variable add energy variable
*/ */
@ -1322,25 +1350,17 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
return status; return status;
lastVar++; lastVar++;
} }
else if(lastMotor >= 0)
{
/*
add motor
*/
status = EnterScanVar(pTAS,tasMotorOrder[lastMotor],
atof(pToken),pCon);
if(!status)
return status;
lastMotor++;
}
else else
{ {
/* internal error */ assert(lastMotor >= 0);
assert(0); SCPrintf(pCon, eError, "ERROR: %s can have only one value",
tasMotorOrder[lastMotor-1]);
return 0;
} }
} }
else else
{ {
lastToken = TXT;
lastVar = lastMotor = -1; lastVar = lastMotor = -1;
if( (iPtr = isTASEnergy(pToken)) >= 0) if( (iPtr = isTASEnergy(pToken)) >= 0)
{ {
@ -1363,6 +1383,10 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
break; break;
} }
} }
if (qhPars == 3) {
SCWrite(pCon, "QH cannot have 2 values", eError);
return 0;
}
return 1; return 1;
} }
/*----------------------------------------------------------------------- /*-----------------------------------------------------------------------

4
tasu.h
View File

@ -15,9 +15,9 @@ extern char *tasMotorOrder[];
extern char *tasVariableOrder[]; extern char *tasVariableOrder[];
/* maximum number of motors in the list */ /* maximum number of motors in the list */
#define MAXMOT 32 #define MAXMOT 34
/* offset to the currents, if available */ /* offset to the currents, if available */
#define CURMOT (MAXMOT - 11) #define CURMOT 21
/* /*

View File

@ -56,6 +56,7 @@ int isTASMotor(char *val)
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
return number if val is a current variable, else -1 return number if val is a current variable, else -1
never used - and wrong (the number 18) M.Z. june 07
-----------------------------------------------------------------------*/ -----------------------------------------------------------------------*/
int isTASCurrent(char *val){ int isTASCurrent(char *val){
int test; int test;