diff --git a/amilevel.c b/amilevel.c index 4654212..22a90a0 100644 --- a/amilevel.c +++ b/amilevel.c @@ -4,6 +4,8 @@ amilevel.c Driver for the AMI 135/136 level meter Markus Zolliker, May 2007 + +OBSOLETE, replaced by scriptcontext driver, May 2016 ----------------------------------------------------------------------------*/ #include #include diff --git a/ease.c b/ease.c index a434723..48e0a6e 100644 --- a/ease.c +++ b/ease.c @@ -120,6 +120,7 @@ void EaseWrite(EaseBase * eab, char *cmd) int l; if (eab->errCode) { + FsmStop(eab->task, eab->idle); eab->state = EASE_abort; return; } @@ -396,6 +397,9 @@ static long EaseIdle(long pc, void *object) switch (pc) { default: /* FSM BEGIN ****************************** */ EasePchk(eab); + if (eab->state == EASE_abort) { + eab->state = EASE_idle; + } idle: if (!EaseCheckDoit(eab)) @@ -408,10 +412,8 @@ static long EaseIdle(long pc, void *object) case __LINE__: /**********************************/ eab->startOk = 1; - if (eab->state == EASE_abort) { - eab->state = EASE_idle; - } rd: + /* rd: */ /* if (eab->state == EASE_lost) { snprintf(eab->msg, sizeof eab->msg, "no response from %s", diff --git a/fsm.c b/fsm.c index 75e776b..15828f2 100644 --- a/fsm.c +++ b/fsm.c @@ -155,7 +155,11 @@ int FsmStop(Fsm * task, FsmFunc func) } if (i == task->sp) { /* not found on stack */ if (func != task->func) - return 0; /* is also not running function */ + return 0; /* is also not running function */\ + /* + task->sp = 0; + task->func = task->stack[0].func; */ /* pretty unsure about this */ + } else { task->sp = i; /* unwind stack to level i */ } diff --git a/ighdriv.c b/ighdriv.c index e0b2722..1a5033d 100644 --- a/ighdriv.c +++ b/ighdriv.c @@ -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; } diff --git a/ipsdriv.c b/ipsdriv.c index 1af592c..4e57349 100644 --- a/ipsdriv.c +++ b/ipsdriv.c @@ -322,7 +322,7 @@ static void IpsStatus(Ips * drv) switch (ans[1]) { case '0': if (ans[6] > '3') { - errmsg = "ERROR: auto-run-down (low He level)"; + errmsg = "ERROR: auto-run-down (He level is/was low - press SILENCE on ILM after filling)"; } else { errmsg = ""; } @@ -461,7 +461,7 @@ static long IpsRead(long pc, void *object) checktodo: if (eab->msg[0] != '\0') goto quit; /* no action when in error */ now = time(NULL); - if (drv->persmode == 2) { /* persistent mode off */ + if (drv->persmode >= 2) { /* persistent mode off */ drv->dothis = NOTHING; goto nothing; } else { diff --git a/lcdriv.c b/lcdriv.c index abf461c..5a08a1e 100644 --- a/lcdriv.c +++ b/lcdriv.c @@ -21,7 +21,6 @@ Markus Zolliker, Sept 2004 #include #include #include -#include #include #include #include diff --git a/lsc370driv.c b/lsc370driv.c index 71420e8..e144930 100644 --- a/lsc370driv.c +++ b/lsc370driv.c @@ -4,6 +4,8 @@ lsc370driv.c Driver for the LakeShore Model 370 AC Resistance Bridge Markus Zolliker, July 2006 + +OBSOLETE, scriptcontext driver in use May 2016 ----------------------------------------------------------------------------*/ #include #include diff --git a/lscsupport.c b/lscsupport.c index 9f6164b..563e1dc 100644 --- a/lscsupport.c +++ b/lscsupport.c @@ -6,6 +6,8 @@ Communication routines for LakeShore equipment Markus Zolliker, July 2006 ---------------------------------------------------------------------------- +OBSOLETE (scriptcontext driver in use) May 2016 + there is no error return value, eab->errCode is used. On success, eab->errCode is not changed, i.e. an existing errCode is not overwritten. */ diff --git a/make_gen b/make_gen index 5f9a9fa..ceb982d 100644 --- a/make_gen +++ b/make_gen @@ -12,7 +12,7 @@ OBJ=psi.o buffer.o ruli.o sps.o pimotor.o \ pipiezo.o sanswave.o faverage.o spss7.o\ amorstat.o tasinit.o ptasdrive.o tasutil.o tasscan.o swmotor.o \ - polterwrite.o ecb.o frame.o sqlitelog.o mongolog.o sicslogquery.o approxidate.o \ + polterwrite.o ecb.o frame.o \ el737driv.o sinqhmdriv.o tdchm.o \ sanscook.o itc4driv.o itc4.o\ bruker.o ltc11.o eurodriv.o \ @@ -32,8 +32,7 @@ OBJ=psi.o buffer.o ruli.o sps.o pimotor.o \ MZOBJ=fsm.o sugar.o pardef.o ease.o strobj.o oxinst.o \ ipsdriv.o ilmdriv.o itcdriv.o ighdriv.o euro2kdriv.o modbus.o arrobj.o \ - lscsupport.o lsc370driv.o linadriv.o haakedriv.o amilevel.o \ - seaclientprot.o dumprot.o + linadriv.o haakedriv.o seaclientprot.o dumprot.o libpsi.a: $(OBJ) rm -f libpsi.a diff --git a/psi.c b/psi.c index 31d742e..f0b84c4 100644 --- a/psi.c +++ b/psi.c @@ -50,12 +50,8 @@ void SiteInit(void) INIT(Euro2kStartup); INIT(StrObjStartup); INIT(ArrayObjStartup); - INIT(Lsc370Startup); INIT(LinaStartup); INIT(HaakeStartup); - INIT(AmiStartup); - INIT(SqliteLogInit); - INIT(MongoLogInit); /* * SICS specific Asynchronous I/O protocols