- modified and improved various env. drivers

- implemented string array object
This commit is contained in:
zolliker
2006-06-20 13:29:32 +00:00
parent 8b12033cb2
commit c1bbdb935e
19 changed files with 1495 additions and 499 deletions

73
ease.c
View File

@ -16,6 +16,7 @@ Markus Zolliker, March 2005
#include <ctype.h>
#include <math.h>
#include "sics.h"
#include "splitter.h"
#include "ease.h"
#define EASE_FLAGBITS (8*sizeof(long))
@ -149,6 +150,27 @@ void EaseSavePars(void) {
}
}
/*----------------------------------------------------------------------------*/
static int EaseRestart(EaseBase *eab) {
int iRet;
if (eab->task) {
FsmStop(eab->task, eab->idle);
FsmRestartTask(eab->task, eab->idle);
}
eab->startOk = 0;
eab->todo = eab->start;
eab->state = EASE_connecting;
iRet = initRS232WithFlags(eab->ser, 3);
if (iRet != 1) {
eab->errCode = iRet;
EaseWriteError(eab);
return -1;
}
snprintf(eab->msg, sizeof eab->msg,
"connecting to %s:%d", eab->ser->pHost, eab->ser->iPort);
return 0;
}
/*----------------------------------------------------------------------------*/
int EaseHandler(EaseBase *eab) {
EaseDriv *ead = EaseDrivCast(eab);;
int iret;
@ -192,6 +214,10 @@ int EaseHandler(EaseBase *eab) {
}
}
if (eab->errCode) {
if (eab->errCode == BADSEND) {
EaseRestart(eab);
return 0;
}
EaseWriteError(eab);
eab->errCode = 0;
if (ead) {
@ -284,7 +310,6 @@ static long EaseIdle(long pc, void *object) {
FsmCall(eab->read);
return __LINE__; case __LINE__: /**********************************/
ParLog(eab); /* just for the case ParLog was not included in the read function */
if (EaseCheckDoit(eab)) goto doit;
/*
gettimeofday(&tm, NULL);
@ -381,7 +406,7 @@ static long EaseRun(void *obj, SConnection *pCon, float fVal) {
assert(ead );
SCSave(&eab->p.conn, pCon);
ParSaveConn(eab, pCon);
if (! eab->doit) {
ParPrintf(ead, eError, "ERROR: missing run function %s", eab->p.name);
return 0;
@ -458,7 +483,7 @@ static int EaseCheckStatus(void *obj, SConnection *pCon) {
time_t now, t;
assert(ead);
SCSave(&ead->b.p.conn, pCon);
ParSaveConn(ead, pCon);
if (ead->stopped) {
return HWIdle;
}
@ -517,27 +542,6 @@ static int EaseCheckLimits(void *obj, float fVal, char *error, int errLen) {
return 1;
}
/*----------------------------------------------------------------------------*/
static int EaseRestart(EaseBase *eab) {
int iRet;
if (eab->task) {
FsmStop(eab->task, eab->idle);
FsmRestartTask(eab->task, eab->idle);
}
eab->startOk = 0;
eab->todo = eab->start;
eab->state = EASE_connecting;
iRet = initRS232WithFlags(eab->ser, 3);
if (iRet != 1) {
eab->errCode = iRet;
EaseWriteError(eab);
return -1;
}
snprintf(eab->msg, sizeof eab->msg,
"connecting to %s:%d", eab->ser->pHost, eab->ser->iPort);
return 0;
}
/*----------------------------------------------------------------------------*/
static int EaseInit(SConnection *pCon, EaseBase *eab, int argc, char *argv[],
int maxflag,
FsmHandler handler,
@ -663,7 +667,7 @@ void *EaseMakeBase(SConnection *con, void *class, int argc, char *argv[],
char *creationCmd = NULL;
if (dynamic) {
creationCmd = ParArg2Text(argc, argv, NULL, 0);
creationCmd = Arg2Tcl(argc, argv, NULL, 0);
}
eab = ParMake(con, argv[1], class, pardef, creationCmd);
if (!eab) return NULL;
@ -691,7 +695,7 @@ void *EaseMakeDriv(SConnection *con, void *class, int argc, char *argv[],
assert(run);
if (dynamic) {
creationCmd = ParArg2Text(argc, argv, NULL, 0);
creationCmd = Arg2Tcl(argc, argv, NULL, 0);
}
ead = ParMake(con, argv[1], class, pardef, creationCmd);
if (!ead) return NULL;
@ -781,7 +785,7 @@ int EaseSend(void *object, void *userarg, int argc, char *argv[]) {
iret = EaseWaitRead(eab);
if (iret >= 0) {
eab->sendCmd = ParArg2Text(argc, argv, NULL, 0);
eab->sendCmd = ParArg2Str(argc, argv, NULL, 0);
ParPrintf(eab, -2, "ans: %s", ans);
ParPrintf(eab, eValue, "%s", ans);
@ -798,6 +802,15 @@ void EaseSendPar(void *object) {
return;
}
/*----------------------------------------------------------------------------*/
void EaseKillDriv(EaseDriv *ead) {
if (ead->drivInt) {
free(ead->drivInt);
}
if (ead->evInt) {
free(ead->evInt);
}
}
/*----------------------------------------------------------------------------*/
void EaseDrivPar(void *object, char *fmt, char *unit) {
EaseDriv *ead;
@ -816,7 +829,7 @@ void EaseDrivPar(void *object, char *fmt, char *unit) {
ParName("tolerance");
ParFmt(fmt); ParTail(unit); ParAccess(usUser); ParSave(1);
ParFloat(&ead->tolerance, 0.0);
ParFloat(&ead->tolerance, 1.0);
ParName("maxwait");
if (ead->maxwait < 0) {
@ -835,8 +848,8 @@ void EaseDrivPar(void *object, char *fmt, char *unit) {
ParFmt(fmt); ParTail(unit);
ParFloat(&ead->targetValue, PAR_NAN);
if (ParActionIs(PAR_KILL) && ead->drivInt) {
free(ead->drivInt);
if (ParActionIs(PAR_KILL)) {
EaseKillDriv(ead);
}
return;
}