bug fixes and enhancements related to evcontroller

This commit is contained in:
zolliker
2005-03-03 14:13:45 +00:00
parent 48da61421c
commit 0677ecfbe7
13 changed files with 474 additions and 204 deletions

105
itcdriv.c
View File

@ -34,15 +34,18 @@ typedef struct {
float t[4]; /* temperatures (0 unused) */
int dig[4]; /* format for these */
float htr;
float coldvalve;
float gas;
int sampleChan;
int controlChan;
int gas;
int gasMode;
int htrMode;
int remote;
int h; /* actual heater channel */
int a; /* actual auto mode */
} ItcDriv;
static long ItcSetGas(long pc, void *obj);
static long ItcSetHtr(long pc, void *obj);
/*----------------------------------------------------------------------------*/
#define A EVE_ACTPAR
#define L EVE_LOGPAR
@ -53,6 +56,7 @@ void ItcPars(ItcDriv *me, EveParArg *arg) {
int i;
int flag;
char *ti[4] = {"setp","t1","t2","t3"};
static char *modeList[]={"off", "manual", "auto", NULL };
EveStdPar(arg);
@ -67,13 +71,14 @@ void ItcPars(ItcDriv *me, EveParArg *arg) {
}
flag = me->controlChan != 0 || me->htr != 0;
EveFloatPar(arg, "htr", &me->htr, "%.1f\t%%", usInternal, flag*A + L);
flag = me->gas > 0;
EveFloatPar(arg, "coldvalve", &me->coldvalve, "%.1f\t%%", usInternal, flag*A + L);
EveEnumPar(arg, "htrMode", &me->htrMode, modeList, usUser, A+S);
EveFloatCmd(arg, "htr", &me->htr, "%.1f\t%%", ItcSetHtr, usUser, flag*A + L);
EveEnumPar(arg, "gasMode", &me->gasMode, modeList, usUser, A+S);
flag = me->gasMode > 0;
EveFloatCmd(arg, "gas", &me->gas, "%.1f\t%%", ItcSetGas, usUser, flag*A + L);
EveIntPar(arg, "dig1", &me->dig[1], usUser, S);
EveIntPar(arg, "dig2", &me->dig[2], usUser, S);
EveIntPar(arg, "dig3", &me->dig[3], usUser, S);
EveIntPar(arg, "gas", &me->gas, usUser, S);
EveIntPar(arg, "sampleChan", &me->sampleChan, usUser, A+S);
EveIntPar(arg, "controlChan", &me->controlChan, usUser, A+S);
sprintf(fmt, "%%.%df\tK", me->dig[me->sampleChan]);
@ -110,7 +115,7 @@ void ItcStatus(ItcDriv *me) {
}
}
/*----------------------------------------------------------------------------*/
static int ItcRead(long pc, ItcDriv *me) {
static long ItcRead(long pc, ItcDriv *me) {
Eve *eve=&me->eve;
char *p;
int l;
@ -152,21 +157,24 @@ static int ItcRead(long pc, ItcDriv *me) {
FSM_NEXT
me->t[0] = OiGetFlt(eve, me->dig[me->controlChan], NULL);
if (me->htrMode != 2 && me->a % 2 == 0) goto skiphtr;
skip0:
EveWrite(eve, "R5"); /* read heater */
FSM_NEXT
me->htr = OiGetFlt(eve, 1, NULL);
if (!me->gas < 0) goto skipgas;
skiphtr:
if (me->gasMode != 2 && me->a < 2) goto skipgas;
EveWrite(eve, "R7"); /* read gas flow */
FSM_NEXT
me->coldvalve = OiGetFlt(eve, 1, NULL);
me->gas = OiGetFlt(eve, 1, NULL);
skipgas:
me->eve.value = me->t[me->sampleChan];
EveLog(eve);
FSM_END
}
/*----------------------------------------------------------------------------*/
static int ItcStart(long pc, ItcDriv *me) {
static long ItcStart(long pc, ItcDriv *me) {
Eve *eve=&me->eve;
FSM_BEGIN
@ -190,7 +198,7 @@ static int ItcStart(long pc, ItcDriv *me) {
FSM_END
}
/*----------------------------------------------------------------------------*/
static int ItcSetTemp(long pc, ItcDriv *me) {
static long ItcSetTemp(long pc, ItcDriv *me) {
Eve *eve=&me->eve;
pEVControl evc=eve->evc;
float fld;
@ -219,9 +227,10 @@ static int ItcSetTemp(long pc, ItcDriv *me) {
OiSet(eve, "T", evc->fTarget, me->dig[me->controlChan]); /* set point */
FSM_NEXT
a = 1;
if (me->gas == 2) a = 3;
if (me->gasMode == 2) a = 3;
if (me->h == me->controlChan && me->a == a) goto skipa;
if (me->gas == 2) {
me->htrMode = 2; /* heater auto */
if (me->gasMode == 2) {
EveWrite(eve, "A3"); /* auto gas & heater */
} else {
EveWrite(eve, "A1"); /* auto heater */
@ -241,6 +250,74 @@ static int ItcSetTemp(long pc, ItcDriv *me) {
quit:
FSM_END
}
/*----------------------------------------------------------------------------*/
static long ItcSetGas(long pc, void *obj) {
ItcDriv *me = obj;
Eve *eve=&me->eve;
pEVControl evc=eve->evc;
float fld;
float step;
float ramp;
char buf[4];
SConnection *pCon;
int a;
FSM_BEGIN
EveWrite(eve, "C3");
FSM_NEXT
if (me->gasMode != 1) {
EvePrintf(eve, eError, "gasMode must be set to manual");
goto quit;
}
FSM_NEXT
if (me->a == 2) {
EveWrite(eve, "A0");
} else if (me->a == 3) {
EveWrite(eve, "A1");
} else {
goto skipmode;
}
FSM_NEXT
skipmode:
OiSet(eve, "G", me->gas, 1); /* cold valve setting */
FSM_NEXT
EveWrite(eve, "C0");
FSM_NEXT
me->remote = 0;
quit:
FSM_END
}
/*----------------------------------------------------------------------------*/
static long ItcSetHtr(long pc, void *obj) {
ItcDriv *me = obj;
Eve *eve=&me->eve;
pEVControl evc=eve->evc;
float fld;
float step;
float ramp;
char buf[4];
SConnection *pCon;
int a;
FSM_BEGIN
EveWrite(eve, "C3");
FSM_NEXT
if (me->htrMode != 1) {
EvePrintf(eve, eError, "htrMode must be set to manual");
goto quit;
}
if (me->a == 0) goto skipmode;
EveWrite(eve, "A0");
FSM_NEXT
skipmode:
OiSet(eve, "O", me->htr, 1); /* manual heater setting */
FSM_NEXT
EveWrite(eve, "C0");
FSM_NEXT
me->remote = 0;
quit:
FSM_END
}
/*------------------------------------------------------------------------*/
pEVControl ItcMakeEVC(SConnection *pCon, int argc, char *argv[]) {
/* args:
@ -256,6 +333,8 @@ pEVControl ItcMakeEVC(SConnection *pCon, int argc, char *argv[]) {
me = evc->pDriv->pPrivate;
me->sampleChan = 1;
me->gasMode = 1;
me->htrMode = 1;
eve=&me->eve;
eve->run = (FsmFunc)ItcSetTemp;