diff --git a/amilevel.c b/amilevel.c new file mode 100644 index 0000000..527c7fe --- /dev/null +++ b/amilevel.c @@ -0,0 +1,100 @@ +/*--------------------------------------------------------------------------- +amilevel.c + +Driver for the AMI 135/136 level meter + +Markus Zolliker, May 2007 +----------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lscsupport.h" +#include "fsm.h" +#include "initializer.h" + +#define PID_FLAG 1 +#define RDGRNG_FLAG 2 +#define HTRRNG_FLAG 3 + +typedef struct { + EaseBase b; + float level; +} Ami; + +static ParClass amiClass = { "AMILEVEL", sizeof(Ami) }; + +/*----------------------------------------------------------------------------*/ +static void AmiParDef(void *object) { + Ami *drv = ParCast(&amiClass, object); + EaseBase *eab = object; + + ParName(""); ParTail("cm"); + ParFloat(&drv->level, PAR_NAN); + + EaseBasePar(drv); + EaseSendPar(drv); + ParStdDef(); + EaseMsgPar(drv); +} +/*----------------------------------------------------------------------------*/ +static long AmiRead(long pc, void *object) { + Ami *drv = ParCast(&amiClass, object); + EaseBase *eab = object; + + switch (pc) { default: /* FSM BEGIN *******************************/ + EaseWrite(eab, "level"); + return __LINE__; case __LINE__: /**********************************/ + drv->level = atof(eab->ans); + ParLog(drv); + fsm_quit: return 0; } /* FSM END *********************************/ +} +/*----------------------------------------------------------------------------*/ +static long AmiStart(long pc, void *object) { + Ami *drv = ParCast(&amiClass, object); + EaseBase *eab = object; + + switch (pc) { default: /* FSM BEGIN *******************************/ + EaseWrite(eab, "cm"); + return __LINE__; case __LINE__: /**********************************/ + + quit: + return 0; } /* FSM END ********************************************/ +} +/*----------------------------------------------------------------------------*/ +static int AmiInit(SConnection *con, int argc, char *argv[], int dynamic) { + /* args: + MakeObject objectname ami + MakeObject objectname ami + */ + Ami *drv; + + drv = EaseMakeBase(con, &amiClass, argc, argv, dynamic, 7, + AmiParDef, LscHandler, AmiStart, NULL, AmiRead); + if (drv == NULL) return 0; + setRS232ReplyTerminator(drv->b.ser,"\n"); + setRS232SendTerminator(drv->b.ser,"\n"); + return 1; +} +/*----------------------------------------------------------------------------*/ +void AmiStartup(void) { + ParMakeClass(&amiClass, EaseBaseClass()); + MakeDriver("AMILEVEL", AmiInit, 0, "Ami 135/136 level meter"); +} diff --git a/ease.c b/ease.c index 7683301..414251b 100644 --- a/ease.c +++ b/ease.c @@ -568,6 +568,50 @@ static int EaseCheckLimits(void *obj, float fVal, char *error, int errLen) { return 1; } /*----------------------------------------------------------------------------*/ +static int EaseStdHandler(void *object) { + int iret, l; + EaseBase *eab = EaseBaseCast(object); + char *corr; + + assert(eab); + if (eab->state < EASE_idle) goto quit; + if (availableNetRS232(eab->ser) || availableRS232(eab->ser)) { + eab->msg[0] = '\0'; + l = sizeof(eab->ans); + iret = readRS232TillTerm(eab->ser, eab->ans, &l); + if (eab->state != EASE_expect && eab->state != EASE_lost) { + if (iret == 1) { + ParPrintf(eab, eError, "unexpected answer: %s", eab->ans); + } + goto quit; + } + if (iret == 1) { + ParPrintf(eab, -2, "ans: %s", eab->ans); + if (eab->state == EASE_lost) { + goto quit; + } else { + eab->tmo = 120; + } + } + if (iret != 1) { + eab->errCode = iret; + eab->state = EASE_idle; + goto error; + } + eab->state = EASE_read; + } else if (eab->state == EASE_expect) { + if (time(NULL) > eab->cmdtime + eab->tmo) { + eab->state = EASE_lost; + } + } else if (eab->state == EASE_lost) { + } + goto quit; +error: + /* EaseWriteError(eab); */ +quit: + return EaseHandler(eab); +} +/*----------------------------------------------------------------------------*/ static int EaseInit(SConnection *pCon, EaseBase *eab, int argc, char *argv[], int maxflag, FsmHandler handler, @@ -585,7 +629,10 @@ static int EaseInit(SConnection *pCon, EaseBase *eab, int argc, char *argv[], char *colon, *host; char buf[64]; - assert(eab); assert(handler); assert(start); assert(read || idle); + if (handler == NULL) { + handler = EaseStdHandler; + } + assert(eab); assert(start); assert(read || idle); eab->handler = handler; eab->start = start; eab->read = read; @@ -820,9 +867,10 @@ int EaseSend(void *object, void *userarg, int argc, char *argv[]) { iret = EaseWaitRead(eab); if (iret >= 0) { eab->sendCmd = ParArg2Str(argc, argv, NULL, 0); - +/* ParPrintf(eab, -2, "ans: %s", ans); ParPrintf(eab, eValue, "%s", ans); +*/ } if (iret < 0) { eab->errCode = iret; diff --git a/euro2kdriv.c b/euro2kdriv.c index 2768d00..43317e0 100644 --- a/euro2kdriv.c +++ b/euro2kdriv.c @@ -172,7 +172,7 @@ void Euro2kParDef(void *object) { ParName("output"); ParTail("%"); ParFloat(&drv->output, PAR_NAN); - ParName("position"); ParTail("%"); + ParName("position"); ParTail("%"); ParAccess(usUser); ParFloat(&drv->position, 50.0); ParName("asymmetry"); ParAccess(usUser); diff --git a/ighdriv.c b/ighdriv.c index b57418a..73e1b54 100644 --- a/ighdriv.c +++ b/ighdriv.c @@ -56,9 +56,6 @@ static char *motorCommands[]={"G", "H", "N"}; static char *gauges[]={"G1", "G2", "G3", "", "", "", "P1", "P2", NULL}; typedef enum {G1,G2,G3,G4,G5,G6,P1,P2,n_PRESS} PressureGauges; -static char *closedOrOpen[]={"closed", "open", NULL}; - - typedef struct { EaseDriv d; float setT; @@ -90,14 +87,14 @@ static int IghPower2Range(float p) { int e; if (p <= 0) return 0; for (e = 1; e < 5; e++) { - if (p < 1.9994) break; + if (p < 1.9994e-3) break; p /= 10; } return e; } /*----------------------------------------------------------------------------*/ static float IghRange2Max(int e) { - static float elist[]={0,2,20,200,2000,20000}; + static float elist[]={0,0.002,0.02,0.2,2.0,20.0}; if (e < 0) { e = 0; } else if (e > 5) { @@ -112,15 +109,24 @@ static void IghParDef(void *object) { int i, flag, l, changed; char *vPos, *val; char fmt[8], vList[80]; + static char *na=NULL; float maxP; + static char *heaterList[]={"off", "2uW", "20uW", "200uW", "2mW", "20mW", NULL}; + static char *closedOrOpen[]={"closed", "open", NULL}; ParName(""); ParTail("K"); ParFmt("%.4f"); ParFloat(&drv->mixT, PAR_NAN); ParName("Tset"); ParTail("K"); ParFmt("%.4f"); - if (eab->syntax == OLDIGH) ParList("all"); - ParFloat(&drv->setT, PAR_NAN); - + if (eab->syntax == OLDIGH) { + ParList("all"); + drv->setT = -1; + ParFloat(&drv->setT, -1); + } else { + if (drv->setT < 0) drv->setT = 0; + ParFloat(&drv->setT, PAR_NAN); + } + ParName("TsorbSet"); EaseUpdate(SORBS_FLAG); ParTail("K"); ParFmt("%.1f"); ParFloat(&drv->sorbS, PAR_NAN); @@ -138,28 +144,27 @@ static void IghParDef(void *object) { ParFloat(&drv->sorbT, PAR_NAN); ParName("Pmix"); - if (drv->e >= 5 || drv->e < 1) { - strcpy(fmt, "%.0f"); - } else { - snprintf(fmt, sizeof fmt, "%%.%df", 4 - drv->e); - } - EaseUpdate(MIXP_FLAG); ParTail("uW"); ParFmt(fmt); + EaseUpdate(MIXP_FLAG); ParTail("mW"); ParFmt("%.5g"); ParFloat(&drv->mixP, PAR_NAN); ParName("Pmax"); - EaseUpdate(MAXP_FLAG); ParTail("uW"); ParFmt("%g"); - if ((val = ParGetValueArg())) { - drv->e = IghPower2Range(atof(val) * 0.9); - } + ParTail("mW"); ParFmt("%.5g"); maxP = IghRange2Max(drv->e); ParFloat(&maxP, PAR_NAN); + ParName("HtrRange"); + EaseUpdate(MAXP_FLAG); ParEnum(heaterList); ParList(NULL); + ParInt(&drv->e, PAR_NAN); + if (ParActionIs(PAR_SET) > 0) { + drv->mixP = 0; + } + ParName("Pstill"); EaseUpdate(STILL_FLAG); ParTail("mW"); ParFmt("%.3f"); ParFloat(&drv->stillP, PAR_NAN); ParName("Psorb"); - EaseUpdate(SORBP_FLAG); ParTail("W"); ParFmt("%.1f"); + EaseUpdate(SORBP_FLAG); ParTail("W"); ParFmt("%.3f"); ParFloat(&drv->sorbP, PAR_NAN); for (i=0; imixP = 0; goto skip4; } - if (EaseGetUpdate(drv, MIXP_FLAG)) goto skip4; + if (EaseGetUpdate(drv, MIXP_FLAG) || EaseGetUpdate(drv, MAXP_FLAG)) goto skip4; EaseWrite(eab, "R4"); return __LINE__; case __LINE__: /**********************************/ - if (EaseGetUpdate(drv, MIXP_FLAG)) goto skip4; - drv->mixP = OxiGet(eab, 5 - drv->e, NULL, drv->mixP/10) * 10; + if (EaseGetUpdate(drv, MIXP_FLAG) || EaseGetUpdate(drv, MAXP_FLAG)) goto skip4; + drv->mixP = OxiGet(eab, 5 - drv->e, NULL, drv->mixP*100) * 0.01; skip4: if (EaseCheckDoit(eab)) goto quit; @@ -576,15 +581,25 @@ static long IghSet(long pc, void *object) { } OxiSet(eab, "M", mp, 0); return __LINE__; case __LINE__: /**********************************/ - if (drv->e == 0) goto loop; + if (drv->e == 0) goto seta0; + snprintf(buf, sizeof buf, "E%d", drv->e); + EaseWrite(eab, buf); + return __LINE__; case __LINE__: /**********************************/ + EaseWrite(eab, "A1"); + return __LINE__; case __LINE__: /**********************************/ + goto loop; EaseWrite(eab, "A1"); return __LINE__; case __LINE__: /**********************************/ - + set_max_pow: if (drv->e == 0) goto seta0; snprintf(buf, sizeof buf, "E%d", drv->e); EaseWrite(eab, buf); + return __LINE__; case __LINE__: /**********************************/ + EaseWrite(eab, "M0"); + return __LINE__; case __LINE__: /**********************************/ + EaseWrite(eab, "A1"); return __LINE__; case __LINE__: /**********************************/ goto loop; diff --git a/logger.c b/logger.c index b3fc2c9..f2f7733 100644 --- a/logger.c +++ b/logger.c @@ -300,13 +300,6 @@ time_t LoggerLastTime(Logger *log) { return 0; } /*--------------------------------------------------------------------------*/ -int LoggerGetValue(void *data, char *value, int size) { - Logger *log = data; - value[0]='\0'; - strncat(value, log->old, size - 1); - return 1; -} -/*--------------------------------------------------------------------------*/ void LoggerKill(Logger *log) { /* we do not really free the logger, it might be reused for the same variable later. We set the value to undefined */ diff --git a/logger.h b/logger.h index 061a733..96222f6 100644 --- a/logger.h +++ b/logger.h @@ -20,8 +20,6 @@ void LoggerSetNumeric(Logger *log, int numeric); void LoggerSetDir(char *dirarg); void LoggerWriteOld(Logger *log, time_t now); time_t LoggerLastTime(Logger *log); -int LoggerGetStatus(Logger *log); -void LoggerSetStatus(Logger *log, int status); int LoggerVarPath(char *dir, char *path, int pathLen, char *name); void LoggerFreeAll(void); diff --git a/lsc370driv.c b/lsc370driv.c index d41b3a6..a415bca 100644 --- a/lsc370driv.c +++ b/lsc370driv.c @@ -30,21 +30,80 @@ Markus Zolliker, July 2006 #include "fsm.h" #include "initializer.h" +#define PID_FLAG 1 +#define RDGRNG_FLAG 2 +#define HTRRNG_FLAG 3 + typedef struct { EaseDriv d; float t; float htr; float set; float res; + float prop; + float integ; + float deriv; + float resist; /* Ohm */ + int ighHeater; /* IGH heater range (-1 if output is direct) */ + int htrRange; + int currentEx; + int voltageEx; + int range; + int autoRange; } Lsc370; static ParClass lsc370Class = { "LSC370", sizeof(Lsc370) }; +/*----------------------------------------------------------------------------*/ +static float Lsc370Power(Lsc370 *drv, float percent) { + float power; /* mW */ + float current; /* A */ + float voltage; /* V */ + + if (drv->htrRange == 0 || drv->ighHeater == 0) { + power = 0; + } else if (drv->ighHeater > 0) { + current = pow(10, drv->htrRange * 0.5 - 5) * percent / 100; + voltage = current * 500; + if (voltage > 10) voltage = 10; + power = pow(10, drv->ighHeater) * 0.0002 * voltage / 10; + } else { + current = pow(10, drv->htrRange * 0.5 - 5) * percent / 100; + voltage = current * drv->resist; + if (voltage > 10) { + power = 10 * 10 / drv->resist * 1e3; + } else { + power = current * voltage * 1e3; + } + } + return power; +} + /*----------------------------------------------------------------------------*/ static void Lsc370ParDef(void *object) { Lsc370 *drv = ParCast(&lsc370Class, object); EaseBase *eab = object; - + float power, maxPower; + int iRng; + static char *heaterList[]={"off", + "30uA", "100uA", "300uA", + "1mA", "3mA", "10mA", "30mA", "100mA", NULL }; + static char *currentList[]={"off", + "1pA", "3pA", "10pA", "30pA", "100pA", "300pA", + "1nA", "3nA", "10nA", "30nA", "100nA", "300nA", + "1uA", "3uA", "10uA", "30uA", "100uA", "300uA", + "1mA", "3mA", "10mA", "30mA", NULL }; + static char *voltageList[]={"off", + "2uV", "6uV", "20uV", "60uV", "200uV", "600uV", + "2mV", "6mV", "20mV", "60mV", "200mV", "600mV", + NULL }; + static char *rangeList[]={"auto", + "2mOhm", "6mOhm", "20mOhm", "60mOhm", "200mOhm", "600mOhm", + "2Ohm", "6Ohm", "20Ohm", "60Ohm", "200Ohm", " 600Ohm", + "2kOhm", "6kOhm", "20kOhm", "60kOhm", "200kOhm", "600kOhm", + "2MegaOhm", "6MegaOhm", "20MegaOhm", "60MegaOhm", NULL }; + static char *offOn[]={"off", "on", NULL}; + ParName(""); ParTail("K"); ParFloat(&drv->t, PAR_NAN); @@ -57,6 +116,95 @@ static void Lsc370ParDef(void *object) { ParName("res"); ParTail("Ohm"); ParFloat(&drv->res, PAR_NAN); + ParName("prop"); ParTail("(gain)"); + EaseUpdate(PID_FLAG); ParFmt("%.3f"); + ParFloat(&drv->prop, PAR_NAN); + + ParName("integ"); ParTail("sec"); + EaseUpdate(PID_FLAG); ParFmt("%.0f"); + ParFloat(&drv->integ, PAR_NAN); + + ParName("deriv"); ParTail("sec"); + EaseUpdate(PID_FLAG); ParFmt("%.0f"); + ParFloat(&drv->deriv, PAR_NAN); + + ParName("resist"); ParTail("Ohm"); ParAccess(usUser); + ParFloat(&drv->resist, 500.0); + + ParName("ighHeater"); ParAccess(usUser); + ParInt(&drv->ighHeater, -1); + + ParName("currentEx"); + EaseUpdate(RDGRNG_FLAG); ParEnum(currentList); + if (drv->currentEx > 0) ParList(NULL); + ParInt(&drv->currentEx, PAR_NAN); + if (ParActionIs(PAR_SET) > 0) { + if (drv->currentEx > 22) { + drv->currentEx = 22; + } else if (drv->currentEx <= 0) { + drv->currentEx = 0; + } else { + drv->voltageEx = 0; + } + } + + ParName("voltageEx"); + EaseUpdate(RDGRNG_FLAG); ParEnum(voltageList); + if (drv->voltageEx > 0) ParList(NULL); + ParInt(&drv->voltageEx, PAR_NAN); + if (ParActionIs(PAR_SET) > 0) { + if (drv->voltageEx > 12) { + drv->voltageEx = 12; + } else if (drv->voltageEx <= 0) { + drv->voltageEx = 0; + } else { + drv->currentEx = 0; + } + } + + ParName("range"); + EaseUpdate(RDGRNG_FLAG); ParEnum(rangeList); + if (drv->autoRange == 0) ParList(NULL); + ParInt(&drv->range, PAR_NAN); + if (ParActionIs(PAR_SET) > 0) { + if (drv->range > 22) { + drv->range = 22; + drv->autoRange = 0; + } else if (drv->range <= 0) { + drv->autoRange = 1; + drv->range = 0; + } + } + + ParName("autoRange"); + EaseUpdate(RDGRNG_FLAG); ParEnum(offOn); + ParList(NULL); + ParInt(&drv->autoRange, PAR_NAN); + if (ParActionIs(PAR_SET) > 0) { + if (drv->autoRange) { + drv->autoRange = 1; + } + } + + ParName("htrRange"); + EaseUpdate(HTRRNG_FLAG); ParEnum(heaterList); ParList(NULL); + ParInt(&drv->htrRange, PAR_NAN); + if (ParActionIs(PAR_SET) > 0) { + if (drv->htrRange > 8) { + drv->htrRange = 8; + } else if (drv->htrRange <= 0) { + drv->htrRange = 0; + } + } + + ParName("maxPower"); ParTail("mW"); + power = Lsc370Power(drv, 100.0); + ParFloat(&power, 0.0); + + ParName("power"); ParTail("mW"); + power = Lsc370Power(drv, drv->htr); + ParFloat(&power, 0.0); + EaseBasePar(drv); EaseSendPar(drv); EaseDrivPar(drv, "%.5g", "K"); @@ -67,22 +215,75 @@ static void Lsc370ParDef(void *object) { static long Lsc370Read(long pc, void *object) { Lsc370 *drv = ParCast(&lsc370Class, object); EaseBase *eab = object; + int mode, exi, rng, autoR, eoff; + float x, y, z; switch (pc) { default: /* FSM BEGIN *******************************/ EaseWrite(eab, "RDGK?1"); return __LINE__; case __LINE__: /**********************************/ - drv->t = atof(eab->ans); + + if (1 == sscanf(eab->ans, "%f", &x)) { + drv->t = x; + } EaseWrite(eab, "RDGR?1"); return __LINE__; case __LINE__: /**********************************/ - drv->res = atof(eab->ans); + if (1 == sscanf(eab->ans, "%f", &x)) { + drv->res = x; + } EaseWrite(eab, "HTR?"); return __LINE__; case __LINE__: /**********************************/ - drv->htr = atof(eab->ans); + if (1 == sscanf(eab->ans, "%f", &x)) { + drv->htr = x; + } EaseWrite(eab, "SETP?"); return __LINE__; case __LINE__: /**********************************/ - drv->set = atof(eab->ans); - - skipGetSet: + if (1 == sscanf(eab->ans, "%f", &x)) { + if (drv->set != x && !EaseGetUpdate(drv, EASE_RUN)) { + drv->d.targetValue = x; + } + drv->set = x; + } + if (EaseGetUpdate(drv, PID_FLAG)) goto skipPid; + EaseWrite(eab, "PID?"); + return __LINE__; case __LINE__: /**********************************/ + if (EaseGetUpdate(drv, PID_FLAG)) goto skipPid; + if (3 == sscanf(eab->ans, "%f,%f,%f", &x, &y, &z)) { + drv->prop = x; + drv->integ = y; + drv->deriv = z; + } + skipPid: + + if (EaseGetUpdate(drv, HTRRNG_FLAG)) goto skipHtrRng; + EaseWrite(eab, "HTRRNG?"); + return __LINE__; case __LINE__: /**********************************/ + if (EaseGetUpdate(drv, HTRRNG_FLAG)) goto skipHtrRng; + if (1 == sscanf(eab->ans, "%d", &rng)) { + drv->htrRange = rng; + } + skipHtrRng: + + if (EaseGetUpdate(drv, RDGRNG_FLAG)) goto skipRdgRng; + EaseWrite(eab, "RDGRNG?1"); + return __LINE__; case __LINE__: /**********************************/ + if (EaseGetUpdate(drv, RDGRNG_FLAG)) goto skipRdgRng; + if (5 == sscanf(eab->ans, "%d,%d,%d,%d,%d", &mode, &exi, &rng, &autoR, &eoff)) { + if (eoff) { + drv->currentEx = 0; + drv->voltageEx = 0; + } else if (mode) { + drv->currentEx = exi; + drv->voltageEx = 0; + } else { + drv->voltageEx = exi; + drv->currentEx = 0; + } + drv->range = rng; + drv->autoRange = autoR; + } + skipRdgRng: + + ParLog(drv); fsm_quit: return 0; } /* FSM END *********************************/ } @@ -112,19 +313,76 @@ static long Lsc370Start(long pc, void *object) { static long Lsc370Set(long pc, void *object) { Lsc370 *drv = ParCast(&lsc370Class, object); EaseBase *eab = object; - char cmd[32]; - int upd; + char cmd[128]; + int upd, mode, exi, eoff; switch (pc) { default: /* FSM BEGIN *******************************/ - upd = EaseNextUpdate(drv); - if (upd != EASE_RUN) goto quit; EaseWrite(eab, "MODE 1;MODE?"); /* remote mode */ return __LINE__; case __LINE__: /**********************************/ + loop: + upd = EaseNextUpdate(drv); + if (upd == EASE_RUN) goto run; + if (upd == HTRRNG_FLAG) goto htrrng; + if (upd == PID_FLAG) goto pid; + if (upd == RDGRNG_FLAG) goto rdgrng; + goto finish; + + run: snprintf(cmd, sizeof cmd, "SETP %.5g;SETP?", drv->d.targetValue); EaseWrite(eab, cmd); return __LINE__; case __LINE__: /**********************************/ + /* fall through */ + + htrrng: + snprintf(cmd, sizeof cmd, "CSET 1,1,1,1,1,8,%g;CSET?", drv->resist); + EaseWrite(eab, cmd); + return __LINE__; case __LINE__: /**********************************/ + + snprintf(cmd, sizeof cmd, "HTRRNG %d;HTRRNG?", drv->htrRange); + EaseWrite(eab, cmd); + return __LINE__; case __LINE__: /**********************************/ + goto loop; + + pid: + snprintf(cmd, sizeof cmd, "PID %.5g,%.5g,%.5g;PID?", drv->prop, drv->integ, drv->deriv); + EaseWrite(eab, cmd); + return __LINE__; case __LINE__: /**********************************/ + goto loop; + + rdgrng: + if (drv->voltageEx > 0) { + mode = 0; + drv->currentEx = 0; + exi = drv->voltageEx; + eoff = 0; + } else if (drv->currentEx > 0) { + mode = 1; + drv->voltageEx = 0; + exi = drv->currentEx; + eoff = 0; + } else { + mode = 0; + exi = 5; + eoff = 1; + } + if (drv->range <= 0) { + if (drv->autoRange) { + drv->range = 13; + } else { + drv->range = 1; + } + } + if (drv->autoRange) drv->autoRange = 1; + snprintf(cmd, sizeof cmd, "RDGRNG 1,%d,%d,%d,%d,%d;RDGRNG?1", + mode, exi, drv->range, drv->autoRange, eoff); + EaseWrite(eab, cmd); + return __LINE__; case __LINE__: /**********************************/ + goto loop; + + finish: EaseWrite(eab, "MODE 0;MODE?"); /* local mode */ - quit: + return __LINE__; case __LINE__: /**********************************/ + return 0; } /* FSM END ********************************************/ } /*----------------------------------------------------------------------------*/ @@ -139,6 +397,7 @@ static int Lsc370Init(SConnection *con, int argc, char *argv[], int dynamic) { Lsc370ParDef, LscHandler, Lsc370Start, NULL, Lsc370Read, Lsc370Set); if (drv == NULL) return 0; + drv->htrRange = 0; setRS232ReplyTerminator(drv->d.b.ser,"\n"); setRS232SendTerminator(drv->d.b.ser,"\n"); return 1; diff --git a/make_gen b/make_gen index bffd092..f039acd 100644 --- a/make_gen +++ b/make_gen @@ -28,7 +28,7 @@ OBJ=psi.o buffer.o ruli.o dmc.o nxsans.o nextrics.o sps.o pimotor.o \ MZOBJ=fsm.o logger.o sugar.o pardef.o ease.o strobj.o oxinst.o logreader.o \ ipsdriv.o ilmdriv.o itcdriv.o ighdriv.o euro2kdriv.o modbus.o arrobj.o \ - lscsupport.o lsc370driv.o linadriv.o haakedriv.o + lscsupport.o lsc370driv.o linadriv.o haakedriv.o amilevel.o libpsi.a: $(OBJ) rm -f libpsi.a diff --git a/pardef.c b/pardef.c index 56e621d..cba9917 100644 --- a/pardef.c +++ b/pardef.c @@ -54,6 +54,7 @@ typedef struct Context { char *grpFmt; int exact; char *callName; /* the called name of the object (different from obj->name in case of an alias) */ + int enumText; /* show enum text */ } Context; static char *loggerDir = NULL; @@ -405,6 +406,7 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc return 1; } if (argc == 1) { /* no args */ + ctx->enumText = 0; ParDo(con, o, PAR_SHOW, ""); if (ctx->returnValue == 0) { SCSendOK(con); @@ -450,6 +452,11 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc ParListSugar(con, o); ParEnd(); return 1; + } else if (strcmp(argv[1],"enumText") == 0) { + if (argc == 3) { + ctx->enumText = 1; + ParDo(con, o, PAR_SHOW, argv[2]); + } } else { if (strcmp(argv[1], "=") == 0) { ctx->argc = argc - 2; @@ -459,6 +466,7 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc logIt = 1; } else { if (argc == 2) { + ctx->enumText = 0; ParDo(con, o, PAR_SHOW, argv[1]); } else { ctx->argc = argc - 2; @@ -792,7 +800,7 @@ ParOp ParWhat(int numeric) { if (ctx->access < 0) { ctx->access = usInternal; } - if (ctx->access < SCGetRights(ctx->con) && !RestoreMode()) { + if (!RestoreMode() && ctx->access < SCGetRights(ctx->con)) { ctx->returnValue = ILLPRIV; break; } @@ -895,6 +903,17 @@ void ParOut(char *buf) { ParPrintf(NULL, eWarning, "%s %*s%*s%s%s", buffer, l, p, m, ctx->listTail, logged, saved); break; case PAR_SHOW: + if (ctx->enumText) { + i = strtol(buf, &endp, 0); + if (endp != buf) { + p = ParInt2Text(i); + } else { + p == NULL; + } + if (p == NULL) p = "undefined"; + ParPrintf(NULL, eValue, "%s", p); + break; + } if (ctx->parName[0]) { p=" "; } else { p=""; } ParPrintf(NULL, eValue, "%s%s%s = %s", ctx->callName, p, ctx->parName, buf); break; @@ -1013,10 +1032,10 @@ void ParFloat(float *value, float defValue) { return; } if (ctx->valueArg) { - f = strtod(ctx->valueArg, &endp); - if (endp == ctx->valueArg) { - f = ParText2Int(ctx->valueArg); - if (f < 0) { + f = ParText2Int(ctx->valueArg); + if (f < 0) { + f = strtod(ctx->valueArg, &endp); + if (endp == ctx->valueArg) { ctx->returnValue = ILLNUM; break; } @@ -1061,10 +1080,10 @@ void ParInt(int *value, int defValue) { return; } if (ctx->valueArg) { - i = strtol(ctx->valueArg, &endp, 0); - if (endp == ctx->valueArg) { - i = ParText2Int(ctx->valueArg); - if (i < 0) { + i = ParText2Int(ctx->valueArg); + if (i < 0) { + i = strtol(ctx->valueArg, &endp, 0); + if (endp == ctx->valueArg) { ctx->returnValue = ILLNUM; break; } @@ -1081,6 +1100,10 @@ void ParInt(int *value, int defValue) { ParOut(buf); } break; + case GET_OP: + ctx->value = *value; + ctx->returnValue = 1; + break; case INIT_OP: *value = defValue; break; @@ -1145,7 +1168,7 @@ int ParCmd(ParCommand cmd, void *userarg) { if (ctx->action != PAR_SHOW && ctx->action != PAR_SET) return 0; if (ctx->access < 0) ctx->access=usUser; - if (ctx->access < SCGetRights(ctx->con) && !RestoreMode()) { + if (!RestoreMode() && ctx->access < SCGetRights(ctx->con)) { ctx->returnValue = ILLPRIV; ctx->action = PAR_NOOP; return 0; diff --git a/psi.c b/psi.c index 6888b66..333646b 100644 --- a/psi.c +++ b/psi.c @@ -90,6 +90,7 @@ void SiteInit(void) { INIT(Lsc370Startup); INIT(LinaStartup); INIT(HaakeStartup); + INIT(AmiStartup); } diff --git a/tas.h b/tas.h index 98075ed..e5d9cd6 100644 --- a/tas.h +++ b/tas.h @@ -74,7 +74,7 @@ #define DEF 58 #define DKF 59 #define DQH 60 -#define DQK 62 +#define DQK 61 #define DQL 62 #define DEN 63 #define DQM 64 diff --git a/tecs/inp/x10045m.inp b/tecs/inp/x10045m.inp new file mode 100644 index 0000000..4c303bb --- /dev/null +++ b/tecs/inp/x10045m.inp @@ -0,0 +1,89 @@ +sens=x10045m +unit=Ohm ! sensor format (mV,V,Ohm), log formats are choosen automatically +!tlim=325 ! setpoint limit (automatic if omitted) +type=cernox ! sensor type (Special,Si,GaAlAs,Pt250,Pt500,Pt2500,RhFe,C,Cernox,RuOx,Ge) (special if omitted) +!excit=300uA ! (off,30nA,100nA,300nA,1uA,3uA,10uA,30uA,100uA,300uA,1mA,10mV,1mV) (if omitted: default from sensor type) +!range=0 ! range in sensor units (if rang=0: determine range from table, if omitted: default from sensor type) +curv ! curve (sensor,temp/K) follows, must be ordered, but can be increasing or decreasing +14660.90306 1.049887785 +13754.24495 1.275855927 +12674.48887 1.550459363 +11894.1154 1.75557277 +11040.01571 1.987821044 +10422.80643 2.162412567 +9785.229203 2.35233857 +8788.251677 2.6713522 +7989.704459 2.954705632 +7286.655618 3.239907747 +6732.86304 3.495353785 +6251.098886 3.744333505 +5847.432327 3.975506155 +5191.478606 4.414432834 +4648.86278 4.854857074 +4096.7535 5.407680622 +3531.813507 6.147281193 +3061.567702 6.969085764 +2632.586667 7.985907803 +2308.809844 9.015178241 +2050.115691 10.08695457 +1856.065086 11.1032285 +1697.939632 12.11052242 +1566.241253 13.11988767 +1456.905801 14.09704534 +1361.213594 15.09293905 +1277.653195 16.08998776 +1205.321893 17.06507732 +1140.225621 18.05262353 +1082.497021 19.031083 +1029.299845 20.03345265 +978.7301404 21.09197235 +909.7052218 22.72586918 +853.6474417 24.24230862 +800.4013622 25.88646126 +754.2905397 27.49036598 +712.4078269 29.14169598 +670.7126389 30.97229099 +627.7691435 33.09676743 +575.1713405 36.13175392 +530.9271979 39.13507843 +493.6372768 42.07116508 +460.4204351 45.08211136 +431.344044 48.07953453 +413.5443388 50.11058044 +375.6941402 55.06404877 +343.7844255 60.05997467 +316.5557099 65.08597946 +293.3070433 70.08469391 +273.2720797 75.05005646 +255.8364317 79.95571518 +240.2177908 84.94446182 +226.3417365 89.90671921 +213.7399247 94.94441986 +202.290575 100.0309563 +182.836437 110.0102921 +166.6070332 120.016922 +152.8936908 130.0197296 +141.1122505 140.0428009 +130.9833926 150.0209808 +122.1217608 160.0074768 +114.3245474 170.0121689 +107.4602859 179.9772949 +101.3318808 189.9621048 +95.84227734 199.9853439 +90.91929929 209.9731979 +87.21012645 218.2335968 +82.43730345 229.9926758 +78.78173797 239.9560928 +75.43740052 249.9537582 +72.39056663 259.9496765 +69.58110202 269.9509277 +66.99775356 279.9595947 +64.61902665 289.9429169 +62.42460824 299.9438019 +60.37761496 309.9502869 +59.41308694 314.9428101 +58.49246424 319.9327393 +57.41458757 325.8934326 +56.75585142 329.7308502 + + diff --git a/tecs/inp/x33924.inp b/tecs/inp/x33924.inp new file mode 100644 index 0000000..683818d --- /dev/null +++ b/tecs/inp/x33924.inp @@ -0,0 +1,91 @@ +sens=x33924 ! S/N of sensor +unit=Ohm ! sensor format (mV,V,Ohm), log formats are choosen +!tlim=325 ! setpoint limit (automatic if omitted) +type=cernox ! sensor type (Special,Si,GaAlAs,Pt250,Pt500,Pt2500,RhFe,C,Cernox,RuOx,Ge) (special if omitted) +!excit=1mV ! (off,30nA,100nA,300nA,1uA,3uA,10uA,30uA,100uA,300uA,1mA,10mV,1mV) (if omitted: default from sensor type) +!rang=0 ! range in sensor units (if rang=0: determine range from table, if omitted: default from sensor type) +curv ! R Ohm vs temp K +24544.50448 1.204688484 +20388.98451 1.299816848 +17074.34169 1.402716142 +12826.18794 1.600292593 +10134.65956 1.800477834 +8327.779483 2.000302893 +7042.867666 2.200152591 +6093.097817 2.399365105 +5365.432085 2.598855046 +4794.564445 2.797898026 +4334.508815 2.997461714 +3950.656072 3.200609731 +3638.188824 3.39930838 +3374.47855 3.597334429 +3141.224597 3.80201604 +2946.424115 3.999938386 +2782.431438 4.189664734 +2456.690144 4.653569119 +2235.489455 5.053489456 +2014.643985 5.554126028 +1776.815597 6.254371891 +1572.348929 7.05721402 +1382.376483 8.060082443 +1238.884866 9.064627059 +1126.083215 10.07177161 +1034.091919 11.08939964 +958.4997243 12.10117282 +895.1242435 13.10619965 +840.9064124 14.10796478 +793.9165441 15.1070989 +752.9065661 16.09648317 +716.4383121 17.08526451 +683.8577333 18.07317657 +654.407636 19.06032305 +627.7206809 20.04571127 +601.0710634 21.12668511 +565.9196553 22.72932023 +534.5220205 24.35489871 +506.120047 26.01663076 +480.897947 27.66889609 +458.3291362 29.31363009 +435.5818783 31.15122583 +412.0720052 33.28204306 +382.9759833 36.30288379 +358.0205352 39.31175412 +336.3436344 42.31006008 +317.2806783 45.30545705 +300.3446311 48.30399399 +290.1143785 50.29774935 +267.3892167 55.29778277 +248.1675904 60.2838604 +231.6393583 65.27495072 +217.28002 70.26929896 +204.6474971 75.26288067 +193.4535226 80.25333613 +183.4691212 85.24771825 +174.4992708 90.23969149 +166.3845133 95.2314448 +158.9980449 100.2350258 +146.0817862 110.2414656 +135.1571407 120.2217655 +125.7709957 130.2102291 +117.6218968 140.1979516 +110.4749621 150.1922249 +104.1682428 160.1928584 +98.55714149 170.1932857 +93.54097433 180.1963612 +89.03712993 190.1964608 +84.96770359 200.1868646 +81.27001313 210.183685 +77.90967378 220.1878592 +74.84532819 230.1778095 +72.03259224 240.161126 +69.43976573 250.168513 +67.05870384 260.1610728 +64.85341513 270.167037 +62.81393608 280.160649 +60.91437964 290.1703537 +59.15551208 300.1590455 +57.51331019 310.1585222 +56.7314869 315.155938 +55.97810594 320.1542011 +55.10662662 326.1395035 +54.54366027 330.1323684 diff --git a/tecs/inp/x34525.inp b/tecs/inp/x34525.inp new file mode 100644 index 0000000..987c2e9 --- /dev/null +++ b/tecs/inp/x34525.inp @@ -0,0 +1,90 @@ +sens=x34525 +unit=Ohm ! sensor format (mV,V,Ohm), log formats are choosen automatically +type=Cernox ! sensor type (Special,Si,GaAlAs,Pt250,Pt500,Pt2500,RhFe,C,Cernox,RuOx,Ge) (special if omitted) +curv ! curve (sensor,temp/K) follows, must be ordered, but can be increasing or decreasing +99999 0.5 +40000 0.72 +12863.47731 1.20533226 +10977.69216 1.29971648 +9417.264444 1.402769013 +7356.88973 1.600060215 +5995.899896 1.800209773 +5053.600115 2.000027246 +4361.922657 2.200868582 +3845.644121 2.399027638 +3440.318215 2.597993293 +3116.786533 2.796772093 +2851.862884 2.995930484 +2626.724273 3.199845935 +2442.041232 3.39873864 +2283.819233 3.597672461 +2143.671768 3.801851519 +2024.881159 3.999995088 +1924.157975 4.189943914 +1722.293242 4.653004494 +1582.968966 5.053311288 +1442.164067 5.554047021 +1288.369889 6.254676798 +1153.984421 7.057685077 +1026.836916 8.064072126 +930.1130521 9.066937055 +852.8229116 10.0764522 +789.5862115 11.08914207 +736.7546525 12.10125298 +692.1855391 13.10782998 +653.8330198 14.10888184 +620.341151 15.10748286 +591.0012057 16.09588211 +564.7305496 17.08467918 +541.1125238 18.07217677 +519.5967243 19.06365092 +500.1814879 20.04563525 +480.5766976 21.12940609 +454.6842507 22.72881734 +431.377762 24.35528384 +410.1649911 26.01739864 +391.2576228 27.66889881 +374.247106 29.31371758 +357.0118762 31.15190546 +339.1328149 33.28074829 +316.8289359 36.30320089 +297.5953135 39.31156325 +280.7895809 42.31149349 +265.9437689 45.3074115 +252.6729754 48.30399119 +244.6424501 50.29917293 +226.7174619 55.29523346 +211.4199685 60.28958825 +198.2014926 65.27860768 +186.6591056 70.27141438 +176.4659796 75.26708282 +167.3893777 80.25886738 +159.252992 85.25596857 +151.9323384 90.24334893 +145.2718871 95.23947718 +139.1970801 100.2366261 +128.5028722 110.240012 +119.4070961 120.2297394 +111.5588655 130.214951 +104.706856 140.2028623 +98.67712719 150.1961873 +93.33310996 160.1969795 +88.55378668 170.1989567 +84.27616044 180.2008387 +80.4152437 190.2012209 +76.91949115 200.1906303 +73.74256477 210.1853396 +70.84047507 220.1871823 +68.18441602 230.1811406 +65.74732999 240.1638392 +63.49378993 250.1719691 +61.41835204 260.1632129 +59.49819527 270.168475 +57.71287252 280.1618879 +56.05436837 290.1723521 +54.50714254 300.1613929 +53.06716058 310.1635816 +52.38204022 315.1589924 +51.72183234 320.1562515 +50.95507814 326.1396526 +50.46042863 330.1326674 diff --git a/tecs/inp/x34526.inp b/tecs/inp/x34526.inp new file mode 100644 index 0000000..c711f7b --- /dev/null +++ b/tecs/inp/x34526.inp @@ -0,0 +1,90 @@ +sens=x34526 +unit=Ohm ! sensor format (mV,V,Ohm), log formats are choosen automatically +type=Cernox ! sensor type (Special,Si,GaAlAs,Pt250,Pt500,Pt2500,RhFe,C,Cernox,RuOx,Ge) (special if omitted) +curv ! curve (sensor,temp/K) follows, must be ordered, but can be increasing or decreasing +99999 0.8 +40000 1.08 +29936.76247 1.205352238 +24709.97232 1.299731653 +20527.66798 1.402780903 +15241.45373 1.600076119 +11927.73412 1.800229012 +9723.955117 1.999995964 +8162.040676 2.200865255 +7028.594633 2.398958125 +6161.119099 2.59796122 +5483.50624 2.796519769 +4939.839186 2.995724648 +4485.084947 3.19985058 +4118.312143 3.398660742 +3808.16989 3.597696376 +3537.249799 3.801824168 +3309.964308 3.999986096 +3120.030313 4.189713635 +2743.854737 4.653200231 +2489.477496 5.053361846 +2236.317928 5.554035262 +1964.765668 6.254960563 +1732.342776 7.05782143 +1516.845787 8.064144213 +1355.718769 9.066965968 +1229.090897 10.07675638 +1126.706168 11.08898074 +1042.259318 12.10202644 +971.8453664 13.10763431 +911.5732254 14.10858572 +859.4313605 15.10755675 +814.1128899 16.09592158 +773.8338241 17.08508741 +737.8404392 18.07225012 +705.2766109 19.06379328 +676.0274915 20.0456077 +646.7241762 21.12880968 +608.0862576 22.72984359 +573.7108365 24.35508048 +542.5856877 26.01631055 +515.0402449 27.66857719 +490.4176664 29.31354539 +465.5926866 31.15248681 +439.9677876 33.28114138 +408.3326049 36.30350091 +381.2333927 39.31152372 +357.7222034 42.31149297 +337.0855121 45.30789424 +318.8160799 48.30417339 +307.7122247 50.29930204 +283.2137476 55.2954785 +262.473556 60.28854211 +244.6980608 65.27868441 +229.2357451 70.27168093 +215.679746 75.26721388 +203.6772173 80.25883886 +192.9802804 85.25603888 +183.3908024 90.24342986 +174.7064575 95.23927432 +166.8183318 100.23624 +153.0313647 110.2402989 +141.3884697 120.22952 +131.4040699 130.2149238 +122.735783 140.2035618 +115.1541351 150.1964705 +108.4652414 160.1974156 +102.5223956 170.1990541 +97.21172384 180.2004362 +92.44082428 190.2000503 +88.14556508 200.1904155 +84.24421194 210.1862411 +80.69572542 220.1873893 +77.45606866 230.1809456 +74.49526177 240.1630708 +71.76287079 250.1723463 +69.25572618 260.1632497 +66.93237967 270.1691371 +64.78656798 280.1611951 +62.78799465 290.1734124 +60.93683899 300.1623427 +59.20808959 310.163499 +58.38871932 315.1606319 +57.59908444 320.1551948 +56.68320144 326.1390933 +56.09636496 330.1333497 diff --git a/tecs/make_crv b/tecs/make_crv index 84a7a1b..6fdf6c0 100644 --- a/tecs/make_crv +++ b/tecs/make_crv @@ -185,6 +185,9 @@ $(CFGDIR)x09941.crv: ccrv inp/x09941.inp $(CFGDIR)x10045.crv: ccrv inp/x10045.inp $Q -p$(CFGDIR) +$(CFGDIR)x10045m.crv: ccrv inp/x10045m.inp + $Q -p$(CFGDIR) + $(CFGDIR)x10409.crv: ccrv inp/x10409.inp $Q -p$(CFGDIR) @@ -269,12 +272,21 @@ $(CFGDIR)x31319.crv: ccrv inp/x31319.inp $(CFGDIR)x31320.crv: ccrv inp/x31320.inp $Q -p$(CFGDIR) +$(CFGDIR)x33924.crv: ccrv inp/x33924.inp + $Q -p$(CFGDIR) + $(CFGDIR)x34504.crv: ccrv inp/x34504.inp $Q -p$(CFGDIR) $(CFGDIR)x34524.crv: ccrv inp/x34524.inp $Q -p$(CFGDIR) +$(CFGDIR)x34525.crv: ccrv inp/x34525.inp + $Q -p$(CFGDIR) + +$(CFGDIR)x34526.crv: ccrv inp/x34526.inp + $Q -p$(CFGDIR) + $(CFGDIR)x37342.crv: ccrv inp/x37342.inp $Q -p$(CFGDIR) @@ -356,6 +368,7 @@ all_crv: dev.list \ $(CFGDIR)x09883.crv \ $(CFGDIR)x09941.crv \ $(CFGDIR)x10045.crv \ + $(CFGDIR)x10045m.crv \ $(CFGDIR)x10409.crv \ $(CFGDIR)x12532.crv \ $(CFGDIR)x12533.crv \ @@ -384,8 +397,11 @@ all_crv: dev.list \ $(CFGDIR)x31318.crv \ $(CFGDIR)x31319.crv \ $(CFGDIR)x31320.crv \ + $(CFGDIR)x33924.crv \ $(CFGDIR)x34504.crv \ $(CFGDIR)x34524.crv \ + $(CFGDIR)x34525.crv \ + $(CFGDIR)x34526.crv \ $(CFGDIR)x37342.crv \ $(CFGDIR)x37346.crv \ $(CFGDIR)x38604.crv \ @@ -456,6 +472,7 @@ inp/x09882.inp \ inp/x09883.inp \ inp/x09941.inp \ inp/x10045.inp \ +inp/x10045m.inp \ inp/x10409.inp \ inp/x12532.inp \ inp/x12533.inp \ @@ -484,8 +501,11 @@ inp/x31317.inp \ inp/x31318.inp \ inp/x31319.inp \ inp/x31320.inp \ +inp/x33924.inp \ inp/x34504.inp \ inp/x34524.inp \ +inp/x34525.inp \ +inp/x34526.inp \ inp/x37342.inp \ inp/x37346.inp \ inp/x38604.inp \ diff --git a/tecs/tecs.c b/tecs/tecs.c index eab6a83..8a68275 100644 --- a/tecs/tecs.c +++ b/tecs/tecs.c @@ -176,7 +176,7 @@ static int nScan=0, /* number of scanned channels */ alarmListSize=0, keepT=0, /* keep control over power-up */ - swRangeOn=60, /* when not happen several times with less than 60 sec. delay, + swRangeOn=60, /* when not happen several times within less than 60 sec. delay, switch heater range on when controller switched it off */ initMaxPower=0, /* set MaxPower for the first time */ lockAlarm, @@ -1903,6 +1903,8 @@ int ConfigByName(int plugNr) { if (0!=strcmp(plug->device, "none")) { sprintf(buf, "'%s'", plug->device); ERR_I(PrepInput(buf)); + } else { + plug->descr[0]='\0'; } settingsFlag=1; return 0; @@ -3573,6 +3575,9 @@ int main(int argc, char *argv[]) { ERR_P(DataCreateSet(NULL, "state", &state, logPeriod, LOGLIFETIME, tim)); DataUndef(DATA_UNDEF); ERR_P(DataCreateSet(NULL, "tShift", &tShift, logPeriod, LOGLIFETIME, tim)); + ERR_P(DataCreateSet(NULL, "prop", &prop, logPeriod, LOGLIFETIME, tim)); + ERR_P(DataCreateSet(NULL, "int", &integ, logPeriod, LOGLIFETIME, tim)); + ERR_P(DataCreateSet(NULL, "deriv", &deriv, logPeriod, LOGLIFETIME, tim)); remoteMode=2; local = 0;