diff --git a/euro2kdriv.c b/euro2kdriv.c index 43317e0..0979973 100644 --- a/euro2kdriv.c +++ b/euro2kdriv.c @@ -91,6 +91,7 @@ static int Euro2kMakePar(void *object, void *userarg, int argc, char *argv[]) *last = par; par->unit = NULL; par->fmt = NULL; + par->par = PAR_NAN; } else { if (par->unit) { free(par->unit); par->unit=NULL; diff --git a/ilmdriv.c b/ilmdriv.c index 1ac668a..9af6ec7 100644 --- a/ilmdriv.c +++ b/ilmdriv.c @@ -27,14 +27,18 @@ Markus Zolliker, April 2005 #include "fsm.h" #include "initializer.h" +/* typedef enum { ALWAYSNEW, NEW, MEASURING, NOTYETREAD, OLD } ReadState; +*/ typedef enum { UNUSED, N2, PULSED_HE, CONTINOUS_HE, CHANNEL_ERROR = 9 } Usage; typedef struct { EaseBase b; float lev[3]; Usage usage[3]; +/* ReadState readState[3]; +*/ } Ilm; static ParClass ilmClass = { "ILM", sizeof(Ilm) }; @@ -49,23 +53,21 @@ static void IlmParDef(void *object) { if (drv->usage[0]) { ParFmt("%.1f"); ParTail(tails[drv->usage[0]]); } - if (drv->readState[0] == NEW) { - ParLogReady(PAR_NOW_READY); - } + /* if (drv->readState[0] == NEW) ParLogReady(PAR_NOW_READY); */ ParFloat(&drv->lev[0], PAR_NAN); ParName("lev2"); if (drv->usage[1]) { ParFmt("%.1f"); ParTail(tails[drv->usage[1]]); }; - if (drv->readState[1] == NEW) ParLogReady(PAR_NOW_READY); + /* if (drv->readState[1] == NEW) ParLogReady(PAR_NOW_READY); */ ParFloat(&drv->lev[1], PAR_NAN); ParName("lev3"); if (drv->usage[2]) { ParFmt("%.1f"); ParTail(tails[drv->usage[2]]); } - if (drv->readState[2] == NEW) ParLogReady(PAR_NOW_READY); + /* if (drv->readState[2] == NEW) ParLogReady(PAR_NOW_READY); */ ParFloat(&drv->lev[2], PAR_NAN); EaseBasePar(drv); EaseSendPar(drv); @@ -93,14 +95,18 @@ static void IlmStatus(Ilm *drv) { } drv->usage[i] = ans[i+1] - '0'; if (drv->usage[i] == PULSED_HE) { + /* sscanf(ans+6+2*i, "%1x", &status); - if (status & 1) { /* measuring */ + if (status & 1) { // measuring drv->readState[i] = MEASURING; - } else if (drv->readState[i] == MEASURING) { /* new value */ + } else if (drv->readState[i] == MEASURING) { // new value drv->readState[i] = NOTYETREAD; } + */ } else { + /* drv->readState[i] = ALWAYSNEW; + */ } } return; @@ -117,37 +123,46 @@ static long IlmRead(long pc, void *object) { IlmStatus(drv); /* check for errors */ EaseWrite(eab, "R1"); /* read sensor 1 */ return __LINE__; case __LINE__: /**********************************/ - if (drv->readState[0] != MEASURING) { - drv->lev[0] = OxiGet(eab, 1, NULL, drv->lev[0]); - } + /* if (drv->readState[0] != MEASURING) */ + + drv->lev[0] = OxiGet(eab, 1, NULL, drv->lev[0]); + + /* if (drv->readState[0] == NOTYETREAD) { drv->readState[0] = NEW; } - + */ + if (drv->usage[1] == 0) goto skip2; EaseWrite(eab, "R2"); /* read sensor 2 */ return __LINE__; case __LINE__: /**********************************/ drv->lev[1] = OxiGet(eab, 1, NULL, drv->lev[1]); + /* if (drv->readState[1] == NOTYETREAD) { drv->readState[1] = NEW; } + */ skip2: if (drv->usage[2] == 0) goto skip3; EaseWrite(eab, "R3"); /* read sensor 3 */ return __LINE__; case __LINE__: /**********************************/ drv->lev[2] = OxiGet(eab, 1, NULL, drv->lev[2]); + /* if (drv->readState[2] == NOTYETREAD) { drv->readState[2] = NEW; } + */ skip3: - + if (ParLog(drv) >= 0) { /* logging was done */ + /* for (i=0; i<3; i++) { if (drv->readState[i] == NEW) { drv->readState[i] = OLD; } } + */ } return 0; } /* FSM END ********************************************/ diff --git a/pardef.c b/pardef.c index 3e5a043..27445a2 100644 --- a/pardef.c +++ b/pardef.c @@ -432,7 +432,7 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc ctx->argc = argc - 3; ctx->argv = argv + 3; ctx->doit = toupper(argv[1][0]) != 'U'; - ctx->exact = 1; + ctx->exact = 0; ParDo(con, o, PAR_LOGSWITCH, argv[2]); } } else if ((0 == strcasecmp(argv[1], "save") || 0 == strcasecmp(argv[1], "unsave"))) { @@ -603,7 +603,7 @@ void ParFind(void) { long ParText2Int(char *text) { long num = 0; - if (strcasecmp(text, "undefined") == 0) { + if (strcasecmp(text, "undefined") == 0 || text[0] == '\0') { return PAR_LNAN; } if (ctx->enumList) { @@ -622,7 +622,7 @@ char *ParInt2Text(int num) { static char buf[12]; if (num == PAR_LNAN) { - return "undefined"; + return ""; /* undefined */ } if (! ctx->enumList) return NULL; for (i = 0; i <= num; i++) { @@ -686,7 +686,7 @@ void ParName(char *name) { ctx->access = -1; ctx->doit = -1; ctx->logName = ""; /* log by default */ - ctx->exact = 1; /* exact by default */ + ctx->exact = 0; /* not exact by default */ return; case PAR_GET: if (0 != strcasecmp(name, ctx->thisPar)) { @@ -926,7 +926,7 @@ void ParOut(char *buf) { } else { p == NULL; } - if (p == NULL) p = "undefined"; + if (p == NULL) p = ""; /* undefined */ ParPrintf(NULL, eValue, "%s", p); break; } @@ -1063,7 +1063,7 @@ void ParFloat(float *value, float defValue) { case FMT_OP: if (*value == PAR_NAN) { ctx->fmt = NULL; - ParOut("undefined"); + ParOut(""); /* undefined */ } else { if (ctx->fmt == NULL) { ctx->fmt = "%#.5g"; @@ -1110,7 +1110,7 @@ void ParInt(int *value, int defValue) { /* fall through */ case FMT_OP: if (*value == PAR_LNAN) { - ParOut("undefined"); + ParOut(""); /* undefined */ } else { snprintf(buf, sizeof buf, "%d", *value); ParOut(buf); @@ -1145,6 +1145,7 @@ void ParStr(char **value, char *defValue) { ParOut(*value); break; case INIT_OP: + ctx->exact = 1; if (defValue != NULL) { *value = strdup(defValue); } @@ -1170,6 +1171,7 @@ void ParFixedStr(char *value, int maxsize, char *defValue) { ParOut(value); break; case INIT_OP: + ctx->exact = 1; if (defValue != NULL) { snprintf(value, maxsize, "%s", defValue); } diff --git a/tecs/tecs.c b/tecs/tecs.c index cf48b3f..29979a9 100644 --- a/tecs/tecs.c +++ b/tecs/tecs.c @@ -1399,8 +1399,8 @@ void CalcMaxPower(void) { maxCurrent = 1; /* must be 1 for Power2Percent */ h=Power2Percent(maxPowerFlt)/100; p=h*h*resist; /* power before amplifier */ - plim=2500/resist; - /* power limited by 50 V output. U*U/R=2500/R */ + plim=3025/resist; + /* power limited by 55 V output. U*U/R=55*55/R */ if (p>plim) p=plim; pa=resist*4; /* max. maxPower R*I*I (I=2 A) */ low.p = 0; @@ -1625,7 +1625,7 @@ int ConfigAlarms(float genLimit) { ERR_P(LscCmd(ser, "ALARM [buf1]:1,1,[r1],0,1,1")); alarmList[k]=s->ch; k++; - } else { + } else if (i != 4) { /* do not switch off A0 alarm */ ERR_P(LscCmd(ser, "ALARM [buf1]:0")); /* switch off unused alarms */ } } @@ -2630,12 +2630,18 @@ int DeviceHdl(int mode, void *base, int fd) { } int PidHdl(int mode, void *base, int fd) { + char oldpid[128]; + if (mode==COC_WR) { return COC_DWR; } else if (mode==COC_DWR) { - ERR_P(LscCmd(ser,"PID [loop]:[prop],[integ],[deriv]")); + assert(sizeof oldpid == sizeof pid); + strcpy(oldpid, pid); PidSumHdl(COC_RD, base, fd); - logfileOut(LOG_MAIN, "pid: %s\n", pid); + if (strcmp(oldpid, pid) != 0) { + ERR_P(LscCmd(ser,"PID [loop]:[prop],[integ],[deriv]")); + logfileOut(LOG_MAIN, "pid: %s\n", pid); + } } return 0; OnError: return -1; diff --git a/tecs/tecs_logger.c b/tecs/tecs_logger.c index 5cd77e4..527d0a6 100644 --- a/tecs/tecs_logger.c +++ b/tecs/tecs_logger.c @@ -1,2 +1,2 @@ #define TECS_LOG 1 -#include "../logger.c" +#include "../../logger.c" diff --git a/tecs/term.c b/tecs/term.c index 752d8d0..84c49bb 100644 --- a/tecs/term.c +++ b/tecs/term.c @@ -13,7 +13,7 @@ #include "sys_select.h" #define ESC_TMO 1000 -#define REF_TMO 100 +#define REF_TMO 50 #define HISTORY_LINES 256 #define L_ARROW 0200