- bug fixes
This commit is contained in:
2
arrobj.c
2
arrobj.c
@ -295,7 +295,7 @@ static void ArrayObjParDef(void *object)
|
||||
ParName("items");
|
||||
ParAccess(usSpy);
|
||||
ParCmd(ArrayItems, NULL);
|
||||
ParName("saveFile");
|
||||
ParName("saveFile"); ParLogAs(NULL);
|
||||
ParAccess(usUser);
|
||||
ParStr(&arr->saveFile, "");
|
||||
ParStdDef();
|
||||
|
93
linadriv.c
93
linadriv.c
@ -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__: /**********************************/
|
||||
|
31
pardef.c
31
pardef.c
@ -18,6 +18,7 @@ Markus Zolliker, March 2005
|
||||
#include "pardef.h"
|
||||
#include "sugar.h"
|
||||
#include "commandlog.h"
|
||||
#include "dynstring.h"
|
||||
|
||||
#define ILLNUM -2
|
||||
#define ILLARGC -3
|
||||
@ -458,7 +459,30 @@ static int ParExecute(SConnection * con, SicsInterp * sics, void *object,
|
||||
int iret, logIt = 0;
|
||||
ParData *o = ParCheck(&parClass, object);
|
||||
char *setArgv[2];
|
||||
|
||||
ParInfo *info;
|
||||
|
||||
/* debugging
|
||||
int i;
|
||||
printf("ParExecute");
|
||||
for (i=0;i<argc;i++) {
|
||||
printf(" %s", argv[i]);
|
||||
}
|
||||
printf("\n");
|
||||
*/
|
||||
if (argc >= 2 && 0 == strcasecmp(argv[1], "loggeditems")) {
|
||||
pDynString dyn = CreateDynString(124,128);
|
||||
for (info = o->infoList; info != NULL; info = info->next) {
|
||||
if (info->log) {
|
||||
DynStringConcat(dyn, " ");
|
||||
DynStringConcat(dyn, argv[0]);
|
||||
DynStringConcat(dyn, ".");
|
||||
DynStringConcat(dyn, info->name);
|
||||
}
|
||||
}
|
||||
SCWrite(con, GetCharArray(dyn) + 1, eValue);
|
||||
DeleteDynString(dyn);
|
||||
return 1;
|
||||
}
|
||||
ParBegin();
|
||||
ctx->callName = argv[0];
|
||||
ParSaveConn(o, con);
|
||||
@ -658,7 +682,7 @@ void ParFind(void)
|
||||
p = calloc(1, sizeof *p);
|
||||
if (p == NULL)
|
||||
return;
|
||||
p->name = ctx->parName;
|
||||
p->name = strdup(ctx->parName);
|
||||
p->log = NULL;
|
||||
p->saveIt = 0;
|
||||
p->saveLog = 0;
|
||||
@ -1436,6 +1460,9 @@ void ParKill(void *object)
|
||||
q = p->next;
|
||||
p->next = NULL;
|
||||
KillLogger(p);
|
||||
if (p->name) {
|
||||
free(p->name);
|
||||
}
|
||||
free(p);
|
||||
p = q;
|
||||
}
|
||||
|
Reference in New Issue
Block a user