- reintroducted MF/TEM
This commit is contained in:
190
tasscan.c
190
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,7 +988,8 @@ 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;
|
||||
return 1;
|
||||
error:
|
||||
free(myBuffer);
|
||||
return 0;
|
||||
}
|
||||
/*-------------------------------------------------------------------
|
||||
EnterScanVar adds the scan variable given to the scan. Thereby it
|
||||
@ -1223,13 +1230,15 @@ 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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
/*-----------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user