- reintroducted MF/TEM
This commit is contained in:
@ -12,7 +12,7 @@ include ../sllinux_def
|
||||
CC = gcc
|
||||
CFLAGS = -I$(HDFROOT)/include -DHDF4 -DHDF5 $(NI) -Ihardsup \
|
||||
-I.. -DCYGNUS -DNONINTF -g $(DFORTIFY) \
|
||||
-Wall -Werror -Wno-unused -Wno-comment -Wno-switch
|
||||
-Wall -Wno-unused -Wno-comment -Wno-switch -Werror
|
||||
|
||||
EXTRA=nintf.o
|
||||
|
||||
|
29
ptasdrive.c
29
ptasdrive.c
@ -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
|
||||
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
|
||||
below:
|
||||
- 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];
|
||||
float newPositions[MAXMOT];
|
||||
pMotor pMot;
|
||||
|
||||
int qhPars;
|
||||
|
||||
|
||||
assert(pCon);
|
||||
@ -116,6 +118,7 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
varPointer = -1;
|
||||
motorPointer = -1;
|
||||
rStatus = 1;
|
||||
qhPars = 0;
|
||||
|
||||
/* parse loop */
|
||||
while(pPtr != NULL)
|
||||
@ -129,13 +132,9 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
if(lastToken == NUM)
|
||||
{
|
||||
/* handle storage order logic */
|
||||
if(motorPointer > -1)
|
||||
if(varPointer > -1 && qhPars > 1)
|
||||
{
|
||||
motorPointer++;
|
||||
}
|
||||
else if(varPointer > -1)
|
||||
{
|
||||
varPointer++;
|
||||
varPointer++; qhPars--;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -175,6 +174,9 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
iTAS = 1;
|
||||
motorPointer = -1;
|
||||
varPointer = status;
|
||||
if (EMIN + varPointer == QH) {
|
||||
qhPars = 4;
|
||||
}
|
||||
}
|
||||
else if( (status = isTASMotor(pToken)) > -1)
|
||||
{
|
||||
@ -190,6 +192,7 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
}
|
||||
}
|
||||
}/* end of parse loop */
|
||||
|
||||
if(rStatus != 1)
|
||||
return rStatus;
|
||||
|
||||
@ -208,13 +211,14 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
if(pMot)
|
||||
{
|
||||
MotorGetSoftPosition(pMot, pCon, &oldPos);
|
||||
sprintf(pBueffel,"Driving %s from %f to %f",
|
||||
tasMotorOrder[i],oldPos,newPositions[i]);
|
||||
}
|
||||
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);
|
||||
status = StartMotor(pServ->pExecutor,pSics,pCon,
|
||||
tasMotorOrder[i],newPositions[i]);
|
||||
@ -232,6 +236,11 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
*/
|
||||
if(iTAS > 0)
|
||||
{
|
||||
if (qhPars == 3) {
|
||||
SCWrite(pCon, "ERROR: QH cannot have 2 values", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
status = TASCalc(self,pCon,tasMask,tasTargets, tasTargetMask);
|
||||
if(status)
|
||||
{
|
||||
|
6
tas.h
6
tas.h
@ -36,6 +36,7 @@
|
||||
#define BX 22
|
||||
#define BY 23
|
||||
#define BZ 24
|
||||
|
||||
#define EI 25
|
||||
#define KI 26
|
||||
#define EF 27
|
||||
@ -153,7 +154,10 @@
|
||||
#define PFY 134
|
||||
#define PFZ 135
|
||||
|
||||
#define MAXPAR 136
|
||||
#define DMF 136
|
||||
#define DTEM 137
|
||||
|
||||
#define MAXPAR 138
|
||||
#define MAXADD 20
|
||||
#define MAXEVAR 12
|
||||
|
||||
|
12
tasinit.c
12
tasinit.c
@ -24,6 +24,7 @@
|
||||
#include <scan.h>
|
||||
#include <scan.i>
|
||||
#include "tas.h"
|
||||
#include "tasu.h"
|
||||
|
||||
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
|
||||
know the order of the motors
|
||||
*/
|
||||
char *tasMotorOrder[] = { "a1",
|
||||
char *tasMotorOrder[MAXMOT+1] = { "a1",
|
||||
"a2",
|
||||
"a3",
|
||||
"a4",
|
||||
@ -63,6 +64,8 @@ char *tasMotorOrder[] = { "a1",
|
||||
"i6",
|
||||
"i7",
|
||||
"i8",
|
||||
"mf",
|
||||
"tem",
|
||||
NULL };
|
||||
/*
|
||||
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
|
||||
quite weird things may happen at runtime.
|
||||
*/
|
||||
char *tasVariableOrder[] = {
|
||||
char *tasVariableOrder[MAXPAR+1] = {
|
||||
"wav",
|
||||
"dm",
|
||||
"da",
|
||||
@ -207,6 +210,8 @@ char *tasVariableOrder[] = {
|
||||
"pfx",
|
||||
"pfy",
|
||||
"pfz",
|
||||
"dmf",
|
||||
"dtem",
|
||||
NULL};
|
||||
/*-------------------------------------------------------------------
|
||||
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;
|
||||
}
|
||||
if (strcmp(name, "dr") != 0) { /* save only once (for dr, but not for sc,fs,updateqe) */
|
||||
return 1;
|
||||
}
|
||||
while(tasMotorOrder[i] != NULL)
|
||||
{
|
||||
pMot = FindMotor(pServ->pSics,tasMotorOrder[i]);
|
||||
|
184
tasscan.c
184
tasscan.c
@ -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
|
||||
*/
|
||||
fprintf(self->fd,"VARIA: ");
|
||||
iCount = 0;
|
||||
for(i = 0; i < MAXMOT-8;i++)
|
||||
for(i = 0; i < MAXMOT;i++)
|
||||
{
|
||||
fVal = readDrivable(tasMotorOrder[i],self->pCon);
|
||||
if(iCount == 3)
|
||||
{
|
||||
iCount = 0;
|
||||
fprintf(self->fd,"\nVARIA: ");
|
||||
if (pTAS->iPOL >= 0 || (tasMotorOrder[i][0] != 'i' && tasMotorOrder[i][0] != 'h')) {
|
||||
/* do not write currents (names starting with i or h) when not in pol. mode */
|
||||
fVal = readDrivable(tasMotorOrder[i],self->pCon);
|
||||
if(iCount == 3)
|
||||
{
|
||||
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");
|
||||
|
||||
@ -1002,6 +988,7 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
|
||||
char *myBuffer = NULL, pToken[20], *pPtr, pError[132];
|
||||
int iPtr, lastToken, lastVar;
|
||||
VarType vt;
|
||||
int qhPars;
|
||||
|
||||
/*
|
||||
set up our own buffer
|
||||
@ -1019,6 +1006,7 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
|
||||
*/
|
||||
lastToken = NONE;
|
||||
lastVar = -1;
|
||||
qhPars = 0;
|
||||
pPtr = stptok(pBueffel,pToken,20," ,="); /* step over sc */
|
||||
while(pPtr != NULL)
|
||||
{
|
||||
@ -1034,7 +1022,7 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
|
||||
"ERROR: parse error at %s, expected variable",
|
||||
pToken);
|
||||
SCWrite(pCon,pError,eError);
|
||||
return 0;
|
||||
goto error;
|
||||
}
|
||||
lastToken = TXT;
|
||||
if( (iPtr = isTASVar(pToken)) >= 0 )
|
||||
@ -1061,46 +1049,11 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
|
||||
if(tasNumeric(pToken))
|
||||
{
|
||||
lastToken = NUM;
|
||||
if(lastVar >= 0)
|
||||
{
|
||||
vt = GetVarType(pTAS->tasPar[lastVar]);
|
||||
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++;
|
||||
if (qhPars == 3) {
|
||||
SCWrite(pCon, "DQH cannot have 2 values", eError);
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
qhPars = 0;
|
||||
if(lastVar >= 0)
|
||||
{
|
||||
vt = GetVarType(pTAS->tasPar[lastVar]);
|
||||
@ -1130,6 +1083,53 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
|
||||
}
|
||||
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;
|
||||
if( (iPtr = isTASVar(pToken)) >= 0 )
|
||||
{
|
||||
@ -1154,9 +1154,16 @@ static int ParseVar(pTASdata pTAS, char *pBueffel, SConnection *pCon)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (qhPars == 3) {
|
||||
SCWrite(pCon, "DQH cannot have 2 values", eError);
|
||||
goto error;
|
||||
}
|
||||
strcpy(pBueffel, myBuffer);
|
||||
free(myBuffer);
|
||||
return 1;
|
||||
error:
|
||||
free(myBuffer);
|
||||
return 0;
|
||||
}
|
||||
/*-------------------------------------------------------------------
|
||||
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];
|
||||
int iPtr, lastToken, lastVar, lastMotor, status;
|
||||
VarType vt;
|
||||
int qhPars;
|
||||
|
||||
/*
|
||||
parse loop
|
||||
@ -1230,6 +1238,7 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
|
||||
lastToken = NONE;
|
||||
lastVar = lastMotor = -1;
|
||||
pPtr = pBueffel;
|
||||
qhPars = 0;
|
||||
while(pPtr != NULL)
|
||||
{
|
||||
pPtr = stptok(pPtr,pToken,20," ,=");
|
||||
@ -1269,6 +1278,11 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
|
||||
if(tasNumeric(pToken))
|
||||
{
|
||||
lastToken = NUM;
|
||||
if (qhPars == 3) {
|
||||
SCWrite(pCon, "QH cannot have 2 values", eError);
|
||||
return 0;
|
||||
}
|
||||
qhPars = 0;
|
||||
if(lastVar >= 0)
|
||||
{
|
||||
/*
|
||||
@ -1312,6 +1326,20 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
|
||||
lastToken = NUM;
|
||||
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
|
||||
*/
|
||||
@ -1322,25 +1350,17 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
|
||||
return status;
|
||||
lastVar++;
|
||||
}
|
||||
else if(lastMotor >= 0)
|
||||
{
|
||||
/*
|
||||
add motor
|
||||
*/
|
||||
status = EnterScanVar(pTAS,tasMotorOrder[lastMotor],
|
||||
atof(pToken),pCon);
|
||||
if(!status)
|
||||
return status;
|
||||
lastMotor++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* internal error */
|
||||
assert(0);
|
||||
assert(lastMotor >= 0);
|
||||
SCPrintf(pCon, eError, "ERROR: %s can have only one value",
|
||||
tasMotorOrder[lastMotor-1]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastToken = TXT;
|
||||
lastVar = lastMotor = -1;
|
||||
if( (iPtr = isTASEnergy(pToken)) >= 0)
|
||||
{
|
||||
@ -1363,6 +1383,10 @@ static int ParseScanVar(pTASdata pTAS, char *pBueffel, SConnection *pCon,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (qhPars == 3) {
|
||||
SCWrite(pCon, "QH cannot have 2 values", eError);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------
|
||||
|
4
tasu.h
4
tasu.h
@ -15,9 +15,9 @@ extern char *tasMotorOrder[];
|
||||
extern char *tasVariableOrder[];
|
||||
|
||||
/* maximum number of motors in the list */
|
||||
#define MAXMOT 32
|
||||
#define MAXMOT 34
|
||||
/* offset to the currents, if available */
|
||||
#define CURMOT (MAXMOT - 11)
|
||||
#define CURMOT 21
|
||||
|
||||
|
||||
/*
|
||||
|
@ -56,6 +56,7 @@ int isTASMotor(char *val)
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
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 test;
|
||||
|
Reference in New Issue
Block a user