- bug fixes
This commit is contained in:
2
arrobj.c
2
arrobj.c
@ -295,7 +295,7 @@ static void ArrayObjParDef(void *object)
|
|||||||
ParName("items");
|
ParName("items");
|
||||||
ParAccess(usSpy);
|
ParAccess(usSpy);
|
||||||
ParCmd(ArrayItems, NULL);
|
ParCmd(ArrayItems, NULL);
|
||||||
ParName("saveFile");
|
ParName("saveFile"); ParLogAs(NULL);
|
||||||
ParAccess(usUser);
|
ParAccess(usUser);
|
||||||
ParStr(&arr->saveFile, "");
|
ParStr(&arr->saveFile, "");
|
||||||
ParStdDef();
|
ParStdDef();
|
||||||
|
93
linadriv.c
93
linadriv.c
@ -30,9 +30,14 @@ Markus Zolliker, Oct 2006
|
|||||||
#include "ease.h"
|
#include "ease.h"
|
||||||
#include "initializer.h"
|
#include "initializer.h"
|
||||||
|
|
||||||
|
#define LINA_AMP 1
|
||||||
|
#define LINA_FREQ 2
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
EaseDriv d;
|
EaseDriv d;
|
||||||
float x, y;
|
float x, y;
|
||||||
|
float amp, ampGet;
|
||||||
|
float freq, freqGet;
|
||||||
} Lina;
|
} Lina;
|
||||||
|
|
||||||
static ParClass linaClass = { "LINA", sizeof(Lina) };
|
static ParClass linaClass = { "LINA", sizeof(Lina) };
|
||||||
@ -80,6 +85,7 @@ int LinaHandler(void *object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iret != 1) {
|
if (iret != 1) {
|
||||||
|
ParPrintf(eab, -2, "ans: %s?", eab->ans);
|
||||||
eab->errCode = iret;
|
eab->errCode = iret;
|
||||||
eab->state = EASE_idle;
|
eab->state = EASE_idle;
|
||||||
goto error;
|
goto error;
|
||||||
@ -92,7 +98,6 @@ int LinaHandler(void *object)
|
|||||||
} else if (eab->state == EASE_lost) {
|
} else if (eab->state == EASE_lost) {
|
||||||
if (time(NULL) > eab->cmdtime) {
|
if (time(NULL) > eab->cmdtime) {
|
||||||
EaseWrite(eab, "RS");
|
EaseWrite(eab, "RS");
|
||||||
eab->state = EASE_lost;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto quit;
|
goto quit;
|
||||||
@ -120,6 +125,24 @@ static void LinaParDef(void *object)
|
|||||||
ParTail("");
|
ParTail("");
|
||||||
ParFloat(&drv->y, PAR_NAN);
|
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);
|
EaseBasePar(drv);
|
||||||
EaseSendPar(drv);
|
EaseSendPar(drv);
|
||||||
/*
|
/*
|
||||||
@ -129,25 +152,76 @@ static void LinaParDef(void *object)
|
|||||||
EaseMsgPar(drv);
|
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)
|
static long LinaRead(long pc, void *object)
|
||||||
{
|
{
|
||||||
Lina *drv = ParCast(&linaClass, object);
|
Lina *drv = ParCast(&linaClass, object);
|
||||||
EaseBase *eab = object;
|
EaseBase *eab = object;
|
||||||
char *p;
|
char *p, *q;
|
||||||
|
|
||||||
switch (pc) {
|
switch (pc) {
|
||||||
default: /* FSM BEGIN ****************************** */
|
default: /* FSM BEGIN ****************************** */
|
||||||
EasePchk(drv);
|
EasePchk(drv);
|
||||||
EaseWrite(eab, "XY.");
|
EaseWrite(eab, "X.");
|
||||||
return __LINE__;
|
return __LINE__;
|
||||||
case __LINE__: /**********************************/
|
case __LINE__: /**********************************/
|
||||||
p = strchr(eab->ans, ',');
|
if (1 != sscanf(eab->ans, "%f", &drv->x)) {
|
||||||
if (p) {
|
ParPrintf(drv, eError, "illegal response %s", eab->ans);
|
||||||
*p = '\0';
|
}
|
||||||
p++;
|
EaseWrite(eab, "Y.");
|
||||||
drv->x = atof(eab->ans);
|
return __LINE__;
|
||||||
drv->y = atof(p);
|
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);
|
ParLog(drv);
|
||||||
fsm_quit:return 0;
|
fsm_quit:return 0;
|
||||||
@ -174,6 +248,7 @@ static long LinaStart(long pc, void *object)
|
|||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
ParPrintf(drv, eLog, "connected to %s", eab->version);
|
ParPrintf(drv, eLog, "connected to %s", eab->version);
|
||||||
|
eab->p.period = 1;
|
||||||
FsmCall(LinaRead);
|
FsmCall(LinaRead);
|
||||||
return __LINE__;
|
return __LINE__;
|
||||||
case __LINE__: /**********************************/
|
case __LINE__: /**********************************/
|
||||||
|
29
pardef.c
29
pardef.c
@ -18,6 +18,7 @@ Markus Zolliker, March 2005
|
|||||||
#include "pardef.h"
|
#include "pardef.h"
|
||||||
#include "sugar.h"
|
#include "sugar.h"
|
||||||
#include "commandlog.h"
|
#include "commandlog.h"
|
||||||
|
#include "dynstring.h"
|
||||||
|
|
||||||
#define ILLNUM -2
|
#define ILLNUM -2
|
||||||
#define ILLARGC -3
|
#define ILLARGC -3
|
||||||
@ -458,7 +459,30 @@ static int ParExecute(SConnection * con, SicsInterp * sics, void *object,
|
|||||||
int iret, logIt = 0;
|
int iret, logIt = 0;
|
||||||
ParData *o = ParCheck(&parClass, object);
|
ParData *o = ParCheck(&parClass, object);
|
||||||
char *setArgv[2];
|
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();
|
ParBegin();
|
||||||
ctx->callName = argv[0];
|
ctx->callName = argv[0];
|
||||||
ParSaveConn(o, con);
|
ParSaveConn(o, con);
|
||||||
@ -658,7 +682,7 @@ void ParFind(void)
|
|||||||
p = calloc(1, sizeof *p);
|
p = calloc(1, sizeof *p);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return;
|
return;
|
||||||
p->name = ctx->parName;
|
p->name = strdup(ctx->parName);
|
||||||
p->log = NULL;
|
p->log = NULL;
|
||||||
p->saveIt = 0;
|
p->saveIt = 0;
|
||||||
p->saveLog = 0;
|
p->saveLog = 0;
|
||||||
@ -1436,6 +1460,9 @@ void ParKill(void *object)
|
|||||||
q = p->next;
|
q = p->next;
|
||||||
p->next = NULL;
|
p->next = NULL;
|
||||||
KillLogger(p);
|
KillLogger(p);
|
||||||
|
if (p->name) {
|
||||||
|
free(p->name);
|
||||||
|
}
|
||||||
free(p);
|
free(p);
|
||||||
p = q;
|
p = q;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user