- bug fixes

This commit is contained in:
zolliker
2010-01-27 13:39:43 +00:00
parent b67bd76031
commit 835f5db90a
3 changed files with 114 additions and 12 deletions

View File

@@ -30,9 +30,14 @@ Markus Zolliker, Oct 2006
#include "ease.h"
#include "initializer.h"
#define LINA_AMP 1
#define LINA_FREQ 2
typedef struct {
EaseDriv d;
float x, y;
float amp, ampGet;
float freq, freqGet;
} Lina;
static ParClass linaClass = { "LINA", sizeof(Lina) };
@@ -80,6 +85,7 @@ int LinaHandler(void *object)
}
}
if (iret != 1) {
ParPrintf(eab, -2, "ans: %s?", eab->ans);
eab->errCode = iret;
eab->state = EASE_idle;
goto error;
@@ -92,7 +98,6 @@ int LinaHandler(void *object)
} else if (eab->state == EASE_lost) {
if (time(NULL) > eab->cmdtime) {
EaseWrite(eab, "RS");
eab->state = EASE_lost;
}
}
goto quit;
@@ -120,6 +125,24 @@ static void LinaParDef(void *object)
ParTail("");
ParFloat(&drv->y, PAR_NAN);
ParName("ampGet");
ParTail("");
ParFloat(&drv->ampGet, PAR_NAN);
ParName("freqGet");
ParTail("");
ParFloat(&drv->freqGet, PAR_NAN);
ParName("amp");
ParTail("V");
EaseUpdate(LINA_AMP);
ParFloat(&drv->amp, PAR_NAN);
ParName("freq");
ParTail("Hz");
EaseUpdate(LINA_FREQ);
ParFloat(&drv->freq, PAR_NAN);
EaseBasePar(drv);
EaseSendPar(drv);
/*
@@ -129,25 +152,76 @@ static void LinaParDef(void *object)
EaseMsgPar(drv);
}
/*----------------------------------------------------------------------------*/
static long LinaSetAmp(long pc, void *object) {
Lina *drv = ParCast(&linaClass, object);
EaseBase *eab = object;
char buf[64];
switch (pc) {
default:
snprintf(buf, sizeof buf, "OA.%g", drv->amp);
EaseWrite(eab, buf);
return __LINE__;
case __LINE__: /**********************************/
return 0;
}
}
/*----------------------------------------------------------------------------*/
static long LinaSetFreq(long pc, void *object) {
Lina *drv = ParCast(&linaClass, object);
EaseBase *eab = object;
char buf[64];
switch (pc) {
default:
snprintf(buf, sizeof buf, "OF.%g", drv->freq);
EaseWrite(eab, buf);
return __LINE__;
case __LINE__: /**********************************/
return 0;
}
}
/*----------------------------------------------------------------------------*/
static long LinaRead(long pc, void *object)
{
Lina *drv = ParCast(&linaClass, object);
EaseBase *eab = object;
char *p;
char *p, *q;
switch (pc) {
default: /* FSM BEGIN ****************************** */
EasePchk(drv);
EaseWrite(eab, "XY.");
EaseWrite(eab, "X.");
return __LINE__;
case __LINE__: /**********************************/
p = strchr(eab->ans, ',');
if (p) {
*p = '\0';
p++;
drv->x = atof(eab->ans);
drv->y = atof(p);
if (1 != sscanf(eab->ans, "%f", &drv->x)) {
ParPrintf(drv, eError, "illegal response %s", eab->ans);
}
EaseWrite(eab, "Y.");
return __LINE__;
case __LINE__: /**********************************/
if (1 != sscanf(eab->ans, "%f", &drv->y)) {
ParPrintf(drv, eError, "illegal response %s", eab->ans);
}
EaseWrite(eab, "OA.");
return __LINE__;
case __LINE__: /**********************************/
if (1 != sscanf(eab->ans, "%f", &drv->ampGet)) {
ParPrintf(drv, eError, "illegal response %s", eab->ans);
}
EaseWrite(eab, "OF.");
return __LINE__;
case __LINE__: /**********************************/
if (1 != sscanf(eab->ans, "%f", &drv->freqGet)) {
ParPrintf(drv, eError, "illegal response %s", eab->ans);
}
if (EaseGetUpdate(drv, LINA_FREQ)) {
EaseSetUpdate(drv, LINA_FREQ, 0);
FsmCall(LinaSetFreq);
} else if (EaseGetUpdate(drv, LINA_AMP)) {
EaseSetUpdate(drv, LINA_AMP, 0);
FsmCall(LinaSetAmp);
}
ParLog(drv);
fsm_quit:return 0;
@@ -174,6 +248,7 @@ static long LinaStart(long pc, void *object)
goto quit;
}
ParPrintf(drv, eLog, "connected to %s", eab->version);
eab->p.period = 1;
FsmCall(LinaRead);
return __LINE__;
case __LINE__: /**********************************/