- marked amilevel lsc370driv lscsupprt as obsoloete and removed from make_gen

- enhancements in ease, fsm, ipsdriv ighdriv
This commit is contained in:
2016-05-13 16:33:46 +02:00
parent 24107e993b
commit 56f539a9e8
10 changed files with 134 additions and 16 deletions

116
ighdriv.c
View File

@ -43,8 +43,8 @@ Markus Zolliker, May 2005
static char *valves[] =
{ "V9", "V8", "V7", "V11A", "V13A", "V13B", "V11B", "V12B",
" He4", "V1", "V5", "V4", "V3", "V14", "V10", "V2",
" V2A", " V1A", "V5A", " V4A", " V3A", " Roots", " Aux", "He3",
"He4", "V1", "V5", "V4", "V3", "V14", "V10", "V2",
"V2A", "V1A", "V5A", "V4A", "V3A", "Roots", "Aux", "He3",
NULL
}; /* valves beginning with blank are not shown in list */
typedef enum { V9, V8, V7, V11A, V13A, V13B, V11B, V12B,
@ -81,6 +81,14 @@ typedef struct {
int s; /* moving valve state */
int remote;
long hrSync;
float closedelay; /* if > 0: next valve command is a pulsed opening */
int closevalve; /* number of valve to be closed */
double opentime; /* time when valve was opened */
/* extensions (ext_watchdog Arduino) */
int extVersion; /* 0 for no extension, else extension version */
int pumpoff; /* pump signal after overpressure switch */
float upperN2; /* LN2 trap sensor */
float lowerN2;
} Igh;
static ParClass ighClass = { "IGH", sizeof(Igh) };
@ -276,6 +284,30 @@ static void IghParDef(void *object)
ParPrintf(NULL, eValue, "open valves:%s", vList);
}
ParName("closedelay");
ParAccess(usUser);
ParSave(1);
ParFloat(&drv->closedelay, 0);
ParName("extVersion");
ParAccess(usUser);
ParSave(1);
ParInt(&drv->extVersion, PAR_LNAN);
ParName("pumpoff");
if (drv->extVersion != 0) ParTail("");
ParInt(&drv->pumpoff, PAR_LNAN);
ParName("upperN2");
ParFmt("%.1f");
if (drv->extVersion != 0) ParTail("K");
ParFloat(&drv->upperN2, PAR_NAN);
ParName("lowerN2");
ParFmt("%.1f");
if (drv->extVersion != 0) ParTail("K");
ParFloat(&drv->lowerN2, PAR_NAN);
EaseBasePar(drv);
EaseSendPar(drv);
if (eab->syntax != OLDIGH) {
@ -295,6 +327,13 @@ void IghStatus(Igh * drv)
if (drv->d.b.state != EASE_read)
return;
if (drv->opentime > 0 &&
DoubleTime() > drv->opentime + (double)drv->closedelay - 1) {
/* force a call to IghSet */
drv->d.b.todo = drv->d.b.doit;
}
ans = drv->d.b.ans;
code = &drv->d.b.errCode;
if (ans[0] != 'X' ||
@ -349,8 +388,10 @@ static long IghRead(long pc, void *object)
EaseBase *eab = object;
char *p;
int l;
int switched_off;
time_t now;
float delta;
int up10, lo10;
switch (pc) {
default: /* FSM BEGIN ****************************** */
@ -560,6 +601,47 @@ static long IghRead(long pc, void *object)
case __LINE__: /**********************************/
drv->press[P2] = OxiGet(eab, 1, NULL, drv->press[P2]);
if (EaseCheckDoit(eab) || drv->extVersion == 0)
goto quit;
EaseWrite(eab, "{r}");
return __LINE__;
case __LINE__: /**********************************/
/* analyze */
if (3 == sscanf(drv->d.b.ans, "?{%d,%d,%d}",
&l, &up10, &lo10)) {
switched_off = (drv->v[HE3] == 1 && l == 1);
drv->pumpoff = l;
drv->upperN2 = 0.1 * up10;
drv->lowerN2 = 0.1 * lo10;
} else {
drv->pumpoff = PAR_LNAN;
drv->upperN2 = PAR_NAN;
drv->lowerN2 = PAR_NAN;
}
if (!switched_off) goto quit;
/* veryfy pump control */
EaseWrite(eab, "X");
return __LINE__;
case __LINE__: /**********************************/
IghStatus(drv);
if (drv->v[HE3] == 0) goto quit; /* switched off intentionally */
/* overpressure switch activated: we switch pump control off */
EaseWrite(eab, "C3");
drv->remote = 2;
return __LINE__;
case __LINE__: /**********************************/
EaseWrite(eab, "P49");
return __LINE__;
case __LINE__: /**********************************/
EaseWrite(eab, "C0");
return __LINE__;
case __LINE__: /**********************************/
drv->remote = 0;
ParPrintf(eab, eLogError,
"ERROR: overpressure after 3He pump (switched off)");
eab->errCode = EASE_FAULT;
quit:
ParLog(drv);
fsm_quit:return 0;
@ -610,6 +692,7 @@ static long IghSet(long pc, void *object)
int upd;
int i;
float mp;
double now, deadline;
switch (pc) {
default: /* FSM BEGIN ****************************** */
@ -619,6 +702,12 @@ static long IghSet(long pc, void *object)
loop:
return __LINE__;
case __LINE__: /**********************************/
if (drv->opentime > 0) {
now = DoubleTime();
deadline = drv->opentime + (double)drv->closedelay;
if (now > deadline) goto close_valve;
if (now > deadline - 1) goto loop;
}
upd = EaseNextUpdate(drv);
if (upd >= VALVE_FLAGS)
goto set_valve;
@ -782,12 +871,34 @@ static long IghSet(long pc, void *object)
set_valve:
i = upd - VALVE_FLAGS;
if (drv->closedelay > 0) {
if (drv->v[i]) {
if (drv->opentime == 0) {
drv->opentime = DoubleTime();
drv->closevalve = i;
}
} else if (drv->closevalve == i) {
/* early close by command */
drv->opentime = 0;
drv->closedelay = 0;
}
}
snprintf(buf, sizeof buf, "P%d", i * 2 + 3 - drv->v[i]);
EaseWrite(eab, buf);
return __LINE__;
case __LINE__: /**********************************/
goto loop;
close_valve:
drv->opentime = 0;
drv->closedelay = 0;
drv->v[drv->closevalve] = 0;
snprintf(buf, sizeof buf, "P%d", drv->closevalve * 2 + 3); /* close cmd */
EaseWrite(eab, buf);
return __LINE__;
case __LINE__: /**********************************/
goto loop;
set_mot:
i = upd - MOT_FLAGS;
if (drv->mv[i] > 99.9) {
@ -824,6 +935,7 @@ static int IghInit(SConnection * con, int argc, char *argv[], int dynamic)
IghSet);
if (drv == NULL)
return 0;
drv->opentime = 0;
return 1;
}