From 82097034d5abddd1893f05401c6fa17678ba98b9 Mon Sep 17 00:00:00 2001 From: cvs Date: Fri, 2 Jun 2000 07:27:19 +0000 Subject: [PATCH] revision of TecsServer / treat "interest" correctly --- tecs/Makefile | 36 +++-- tecs/coc_client.c | 18 +-- tecs/coc_server.c | 2 +- tecs/coc_util.c | 5 +- tecs/err_handling.c | 15 +- tecs/err_handling.h | 3 +- tecs/sys_aunix_c.c | 11 +- tecs/tecs.c | 326 +++++++++++++++++++++++++------------------- tecs/tecs_cli.c | 11 +- tecs/tecs_client.f | 10 +- tecs/tecs_for.f | 18 ++- tecs/tecs_plot.f90 | 30 +++- tecsdriv.c | 6 +- 13 files changed, 309 insertions(+), 182 deletions(-) diff --git a/tecs/Makefile b/tecs/Makefile index 6fa25d5a..ecbf8524 100644 --- a/tecs/Makefile +++ b/tecs/Makefile @@ -1,11 +1,12 @@ #--------------------------------------------------------------------------- -# Makefile for the TECS Client library +# Makefile for the TECS Client library and TecsServer # # Markus Zolliker, March 2000 #-------------------------------------------------------------------------- -OBJ= tecs_cli.o coc_client.o coc_util.o err_handling.o \ - str_util.o str_buf.o coc_server.o tecs_lsc.o tecs_serial.o \ - coc_logfile.o tecs_dlog.o sys_util.o +LIBR_OBJ= coc_util.o err_handling.o str_util.o str_buf.o sys_util.o tecs_dlog.o +CLI_OBJ= tecs_cli.o coc_client.o +SERV_OBJ= tecs.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o +TCLI_OBJ= tecs_client.o tecs_plot.o tecs_for.o sys_aunix.o sys_aunix_c.o #------------ for DigitalUnix (add -DFORTIFY to CFLAGS for fortified version) CC=cc @@ -19,12 +20,27 @@ CFLAGS= -std1 -g -warnprotos -I../ -I. -I../hardsup .c.o: $(CC) $(CFLAGS) -c $*.c -tecs: $(OBJ) +libtecsl.a: $(LIBR_OBJ) $(CLI_OBJ) - rm libtecsl.a - ar cr libtecsl.a $(OBJ) + ar cr libtecsl.a $(LIBR_OBJ) $(CLI_OBJ) ranlib libtecsl.a - - rm TecsServer - $(CC) $(CFLAGS) -o TecsServer -g tecs.c fortify1.c -lm -L. -ltecsl -L../hardsup -lhlib -lfor + +all: libtecsl.a bin/TecsServer tecs + +tecs_plot.o: tecs_plot.f90 + f90 -c -g tecs_plot.f90 + +bin/TecsServer: $(LIBR_OBJ) $(SERV_OBJ) + - rm bin/TecsServer + $(CC) $(CFLAGS) -o bin/TecsServer -g $(LIBR_OBJ) $(SERV_OBJ) fortify1.c \ + -lm -L../hardsup -lhlib -lfor + +tecs: $(TCLI_OBJ) $(CLI_OBJ) $(LIBR_OBJ) + f77 -o tecs -g $(TCLI_OBJ) $(CLI_OBJ) $(LIBR_OBJ) \ + -L/data/lnslib/lib -lpgplot -so_archive -lreadline -ltermcap -lX11 -lXm + clean: - rm *.o - rm *.a + - rm *.o + - rm *.a + - rm bin/TecsServer + - rm tecs diff --git a/tecs/coc_client.c b/tecs/coc_client.c index 4533e418..8495eb70 100644 --- a/tecs/coc_client.c +++ b/tecs/coc_client.c @@ -137,7 +137,7 @@ int CocCmdWithRetry(CocConn *conn) { ErrShow("try again, error was"); } ERR_P(err=str_get_str(conn->resbuf, NULL)); - if (*err!='\0') { ErrMsg(err); ErrTxt(": (response from server)",0 ); goto OnError; } + if (*err!='\0') { ErrMsg(err); ErrTxt(": (response from server)",0 ); return(-2); } return(0); OnError: return(-1); } @@ -145,6 +145,7 @@ int CocCmdWithRetry(CocConn *conn) { /*-------------------------------------------------------------------------*/ int CocSet(CocConn *conn, const char *name, const char *value) { + int iret=-1; assert(conn!=NULL); str_put_start(conn->cmdbuf); @@ -153,35 +154,36 @@ int CocSet(CocConn *conn, const char *name, const char *value) { ERR_I(str_put_str(conn->cmdbuf, value)); ERR_I(str_put_str(conn->cmdbuf, "]")); - ERR_I(CocCmdWithRetry(conn)); + ERR_I(iret=CocCmdWithRetry(conn)); ERR_I(str_get_end(conn->resbuf)); return(0); - OnError: return(-1); + OnError: return(iret); } /*-------------------------------------------------------------------------*/ int CocGetN(CocConn *conn, const char *name, char *value, int reslen) { + int iret=-1; assert(conn!=NULL); str_put_start(conn->cmdbuf); ERR_I(str_put_str(conn->cmdbuf, name)); - ERR_I(CocCmdWithRetry(conn)); + ERR_I(iret=CocCmdWithRetry(conn)); ERR_P(str_nget_str(conn->resbuf, value, reslen)); ERR_I(str_get_end(conn->resbuf)); return(0); - OnError: return(-1); + OnError: return(iret); } /*-------------------------------------------------------------------------*/ int CocCmd(CocConn *conn, const char *rwList) -{ int setmode, i; +{ int setmode, i, iret=-1; const char *t, *s; char nam[32]; CocVar *var; @@ -215,7 +217,7 @@ int CocCmd(CocConn *conn, const char *rwList) s=t+1; } while (*t!='\0'); - ERR_I(CocCmdWithRetry(conn)); + ERR_I(iret=CocCmdWithRetry(conn)); /* read values */ s=rwList; @@ -239,7 +241,7 @@ int CocCmd(CocConn *conn, const char *rwList) ERR_I(str_get_end(conn->resbuf)); return(0); - OnError: return(-1); + OnError: return(iret); } void CocCloseClient(CocConn *conn) { diff --git a/tecs/coc_server.c b/tecs/coc_server.c index 0de7ba74..1092bff5 100644 --- a/tecs/coc_server.c +++ b/tecs/coc_server.c @@ -169,7 +169,7 @@ int CocHandle1Request(int tmo_msec, int fd) { str_put_start(bufo); /* reset output */ str_put_str(bufo, err); /* put error message */ logfileOut(LOG_NET, " (%s)\n", err); - logfileMask(LOG_NET); + /* logfileMask(LOG_NET); */ } ERR_SI(send(cl->fd, bufo->buf, bufo->wrpos, 0)); } diff --git a/tecs/coc_util.c b/tecs/coc_util.c index 6b873ea6..7ff8f693 100644 --- a/tecs/coc_util.c +++ b/tecs/coc_util.c @@ -85,9 +85,10 @@ void CocList() { p=*varListHdl; while (p!=NULL) { - printf("%s %d\n", p->name, p->type); + printf("%s %d ", p->name, p->type); p=p->next; } + printf("\n"); } CocVar *CocFindVar1(CocVar *varList, const char *name) { @@ -216,7 +217,7 @@ int CocPutVar(CocVar *varList, Str_Buf *buf, const char *name, int secure) { } else { adr=(char *)adr + (int)var->var; } - if (secure) { /* check acces */ + if (secure) { /* check access */ if (var->flag==&CocRD) ERR_MSG("variable is read only"); } /* printf("put %s %d\n", name, (int)adr); */ diff --git a/tecs/err_handling.c b/tecs/err_handling.c index 1e8e0f80..86e75f7d 100644 --- a/tecs/err_handling.c +++ b/tecs/err_handling.c @@ -69,6 +69,14 @@ void ErrShow(char *text) outrtn(outarg, ""); } +void ErrShort(void) { + if (outrtn==NULL) { + outrtn=ErrOutFil; + outarg=stdout; + } + outrtn(outarg, ErrMessage); +} + void ErrSetOutRtn(void (*rtn)(), void *arg) { outrtn=rtn; outarg=arg; @@ -89,6 +97,8 @@ void ERR_EXIT(char *text) { #define err_show_ err_show #define err_txt_ err_txt #define err_msg_ err_msg +#define err_set_outrtn_ err_set_outrtn +#define err_short_ err_short #endif void err_show_(F_CHAR(text), int text_len) { @@ -112,6 +122,9 @@ void err_msg_(F_CHAR(text), int text_len) { ErrMsg(buf); } -void errsetoutrtn_(void (*rtn)(), void *arg) { +void err_set_outrtn_(void (*rtn)(), void *arg) { ErrSetOutRtn(rtn, arg); } +void err_short_(void) { + ErrShort(); +} diff --git a/tecs/err_handling.h b/tecs/err_handling.h index 671a84cd..04645e6b 100644 --- a/tecs/err_handling.h +++ b/tecs/err_handling.h @@ -73,7 +73,8 @@ Global Variables (read only) void ErrTxt(char *text, int systemError); void ErrMsg(char *msg); void ErrCod(int code); -void ErrShow(char *text); +void ErrShow(char *text); /* write out error message with stack info */ +void ErrShort(void); /* write out short error message */ void ERR_EXIT(char *text); void ErrLog(char *text); void ErrSetOutRtn(void (*rtn)(), void *arg); diff --git a/tecs/sys_aunix_c.c b/tecs/sys_aunix_c.c index 29df694b..2b82975e 100644 --- a/tecs/sys_aunix_c.c +++ b/tecs/sys_aunix_c.c @@ -11,7 +11,10 @@ static char *last_line = NULL; -char *readline (char *prompt); +int lnblnk_(char *c, int c_len); +char *readline(char *prompt); +void add_history(char *line_read); +int usleep(time_t delay); void sys_rd_line_(char *cmd, int *retlen, char *prompt, int clen, int plen) { @@ -42,7 +45,7 @@ void sys_rd_line_(char *cmd, int *retlen, char *prompt, int clen, int plen) void intcatch(int sig) -{ printf("\nuse quit (normally ctrl-\) to interrupt\n"); +{ printf("\nuse quit (normally ctrl-\\) to interrupt\n"); } int called=0; /* env is valid only if called==1 */ @@ -56,10 +59,10 @@ void sighdl(int sig) } void sys_err_hdl_(void errhdl0()) -{ errhdl=errhdl0; }; +{ errhdl=errhdl0; } void sys_int_hdl_(void inthdl0(int sig)) -{ inthdl=inthdl0; }; +{ inthdl=inthdl0; } void sys_try_(void proc()) { int sig, status; diff --git a/tecs/tecs.c b/tecs/tecs.c index f5d965f1..bd1963d2 100644 --- a/tecs/tecs.c +++ b/tecs/tecs.c @@ -25,8 +25,8 @@ static char *binDir=NULL; static char *logDir=NULL; typedef struct { - float t, min, max; /* temperatures */ - int sMin, sMax; /* reading status summary */ + float t, t1, t2, min, max; /* temperatures */ + int stat1, stat2; /* reading status summary */ int present; /* sensor is present */ int readStat; /* reading status */ char ch[2]; /* channels */ @@ -61,8 +61,8 @@ Testpoint /* C standard guarantees initialization to zero */ static float tempC, /* set T (for sample) */ tempH, /* set T on heat exchanger */ - htr, /* heat power percentage */ - tLimit, power, /* heater parameters */ + htr, /* heater current percentage */ + tLimit, maxPower, /* heater parameters */ tLow=0, tHigh=0, /* lower limit of high-T sensor, upper limit of low-T sensor */ tShift=0, /* setpoint shift */ prop, integ, deriv, /* pid */ @@ -74,7 +74,7 @@ static int period=5000, /* default read interval (msec.) */ logTime, /* next logging time */ setFlag, /* temperature to be set */ - powerFlag, /* power to be set */ + maxPowerFlag, /* maxPower to be set */ pidFlag, /* pid's to be set */ saveTime, /* time for a CRVSAV command */ noResp=2, /* no response */ @@ -84,6 +84,7 @@ static int remoteMode, /* 1: local, 2: remote */ maxfld, /* last used display field */ busy, /* busy after CRVSAV */ + relay, relay0, /* relay status */ deviceFlag, /* device given via net */ num, /* curve number */ fld, /* field number */ @@ -112,6 +113,8 @@ static char head[64], /* curve header */ intype[64], /* input configuration */ chan[2], /* actual channel */ + alarms[20], /* alarm status */ + alarmList[4], /* alarm list */ dlogfile[128]; static char @@ -364,7 +367,7 @@ int instCurve(char *nam, char *channel, int dispFld) { int configInput(void) { char *t; - char buf[80], nam[16], nbuf[256]; + char buf[80], nam[16], nbuf[256], ch0[4], ch[4]; int i, n, nn, dispFld; int retstat; char *ext; @@ -390,12 +393,13 @@ int configInput(void) { t=strchr(buf, '\''); if (t==NULL) ERR_MSG("missing ' in table file"); t++; - n=1; if (tpoint==&samp) { sens3.present=0; sens4.present=0; - i=sscanf(t, "%12s%d%d", nam, &nn, &n); + str_copy(ch, "C"); + i=sscanf(t, "%12s %7s %7s", nam, ch0, ch); if (i<1) ERR_MSG("missing sensor name"); + str_copy(ch0, "CD"); ext=".s"; dispFld=2; } else { @@ -403,23 +407,46 @@ int configInput(void) { sens2.present=0; tLow=0; tHigh=0; controlMode=0; - i=sscanf(t, "%12s%d%d%d%f%d%f%f%f", nam, &n, &nn, &controlMode, &tLimit, &resist, &power, &tLow, &tHigh); + str_copy(ch, "A"); + i=sscanf(t, "%12s %s %s %d %f %d %f %f %f", nam, ch, ch0, &controlMode, &tLimit, &resist, &maxPower, &tLow, &tHigh); if (i<7) ERR_MSG("missing some sensor parameters"); + if (!samp.manual && (NULL!=strchr(ch0,'A') || NULL!=strchr(ch0,'B'))) { + samp.dirty=1; /* sample and heat exchanger are on main plug */ + samp.code=cryo.code; + } + str_copy(ch0, "AB"); ext=".x"; dispFld=1; } - if (n<0 || n>2) ERR_MSG("illegal value for nsensor"); + n=strlen(ch); + if (n==1) { + if (ch[0]=='0') { + n=0; + } else if (ch[0]=='1') { + ch[0]=ch0[0]; + } else if (ch[0]=='2') { + str_copy(ch, ch0); n=2; + } + } else if (n>2) { + ERR_MSG("no more than 2 channels per plug allowed"); + } if (n==0) return(0); + nam[strlen(nam)-1]='\0'; /* strip off quote */ if (!tpoint->manual) { /* set device name */ str_copy(tpoint->device, nam); concatDevice(); } str_append(nam, ext); - + if (ch[0]<'A' || ch[0]>'D') ERR_MSG("illegal channel"); + tpoint->sensor1->ch[0]=ch[0]; + tpoint->sensor1->ch[1]='\0'; ERR_I(retstat=instCurve(nam, tpoint->sensor1->ch, dispFld)); tpoint->sensor1->present=1; if (n==2) { + if (ch[1]<'A' || ch[1]>'D') ERR_MSG("illegal channel"); + tpoint->sensor2->ch[0]=ch[1]; + tpoint->sensor2->ch[1]='\0'; str_append(nam, "l"); ERR_I(retstat=instCurve(nam, tpoint->sensor2->ch, dispFld+2)); tpoint->sensor2->present=1; @@ -468,11 +495,11 @@ int loadCache(void) { return(-1); } -float WeightedAverage(int presentH, int presentL, float tH, float tL) { +float WeightedAverage(float tH, float tL) { float p,q; - if (presentH) { - if (presentL) { + if (tH!=0.0) { + if (tL!=0.0) { if (tLsensor1; + s2=tpoint->sensor2; + tpoint->tMin = WeightedAverage(s1->min, s2->min) * tpoint->scale; + tpoint->tMax = WeightedAverage(s1->max, s2->max) * tpoint->scale; + s1->min=0; + s1->max=0; + s2->min=0; + s2->max=0; + } + sprintf(buf, "@%.3f < T < %.3f K", cryo.tMin, cryo.tMax); + if (samp.tMax>0.0) { + sprintf(buf1, " (reg), %.3f < T < %.3f K (samp)", samp.tMin, samp.tMax); + str_append(buf, buf1); + } + logfileOut(LOG_MAIN, "%s\n", buf); + if (new) { + mmInt=60; + } else if (mmInt<600) { + mmInt=mmInt+60; + } + mmTime=tim+mmInt; +} + +int ReadTemp(void) { + char buf[256], bufs[256]; + int i, l, ls, stat; + + readTemp=0; l=0; ls=0; for (i=1; i<=4; i++) { sensor=sensors[i]; - sensor->sMin=0; - sensor->sMax=0; + sensor->stat1=0; + sensor->stat2=0; if (sensor->present) { assert(l<128); - sprintf(buf+l, "MDAT?[sens%d.ch]>sens%d.min,sens%d.max;", i, i, i); + sprintf(buf+l, "MDAT?[sens%d.ch]>sens%d.t1,sens%d.t2;", i, i, i); l=strlen(buf); assert(ls<128); - sprintf(bufs+ls, "MDATST?[sens%d.ch]>sens%d.sMin,sens%d.sMax;", i, i, i); + sprintf(bufs+ls, "MDATST?[sens%d.ch]>sens%d.stat1,sens%d.stat2;", i, i, i); ls=strlen(bufs); } } @@ -522,40 +577,42 @@ int LogMinMax(int new) { /* check for reading errors */ for (i=1; i<=4; i++) { sensor=sensors[i]; - stat=sensor->sMin | sensor->sMax; - if (stat != sensor->readStat) { - sensor->readStat=stat; - if (stat & 1) logfileOut(LOG_MAIN, "invalid reading %s\n", sensor->ch); - if (stat & 2) logfileOut(LOG_MAIN, "old reading %s\n", sensor->ch); - if (stat & 12) logfileOut(LOG_MAIN, "unknown reading status %s\n", sensor->ch); - if (stat & 16) logfileOut(LOG_MAIN, "temp underrange %s\n", sensor->ch); - if (stat & 32) logfileOut(LOG_MAIN, "temp overrange %s\n", sensor->ch); - if (stat & 64) logfileOut(LOG_MAIN, "units zero %s\n", sensor->ch); - if (stat &128) logfileOut(LOG_MAIN, "units overrange %s\n", sensor->ch); - if (stat==0) logfileOut(LOG_MAIN, "reading o.k. %s\n", sensor->ch); + if (sensor->present) { + stat=sensor->stat1 | sensor->stat2; + if (stat != sensor->readStat) { + sensor->readStat=stat; + if (stat & 1) logfileOut(LOG_MAIN, "invalid reading %s\n", sensor->ch); + if (stat & 2) logfileOut(LOG_MAIN, "old reading %s\n", sensor->ch); + if (stat & 12) logfileOut(LOG_MAIN, "unknown reading status %s\n", sensor->ch); + if (stat & 16) logfileOut(LOG_MAIN, "temp underrange %s\n", sensor->ch); + if (stat & 32) logfileOut(LOG_MAIN, "temp overrange %s\n", sensor->ch); + if (stat & 64) logfileOut(LOG_MAIN, "units zero %s\n", sensor->ch); + if (stat &128) logfileOut(LOG_MAIN, "units overrange %s\n", sensor->ch); + if (stat==0) logfileOut(LOG_MAIN, "reading o.k. %s\n", sensor->ch); + } + if (stat==0) { + sensor->t = (sensor->t1 + sensor->t2) * 0.5; /* mean of min and max */ + if (sensor->t1 < sensor->min || sensor->min==0.0) sensor->min = sensor->t1; + if (sensor->t2 > sensor->max) sensor->max = sensor->t2; + } else { + sensor->t=0; + } + } else { + sensor->t=0; } } - - logIt=0; - for (i=0; i<2; i++) { - tpoint=tpoints[i]; - s1=tpoint->sensor1; - s2=tpoint->sensor2; - tpoint->tMin = WeightedAverage(s1->present, s2->present, s1->min, s2->min) * tpoint->scale; - tpoint->tMax = WeightedAverage(s1->present, s2->present, s1->max, s2->max) * tpoint->scale; + + cryo.temp=WeightedAverage(sens1.t, sens2.t)*cryo.scale; + samp.temp=WeightedAverage(sens3.t, sens4.t)*samp.scale; + if (samp.temp==0.0) samp.temp=cryo.temp; + if (!deviceFlag + && !samp.dirty && samp.codDefined && !samp.codChanged + && !cryo.dirty && cryo.codDefined && !cryo.codChanged) { + configuring=0; + } else if (configuring==0 && remoteMode==2) { + str_copy(status, "configuring"); + configuring=1; } - sprintf(buf, "@%.3f < T < %.3f K", cryo.tMin, cryo.tMax); - if (samp.tMax>0.0) { - sprintf(buf1, "(reg), %.3f < T < %.3f K (samp)", samp.tMin, samp.tMax); - str_append(buf, buf1); - } - logfileOut(LOG_MAIN, "%s\n", buf); - if (new) { - mmInt=60; - } else if (mmInt<600) { - mmInt=mmInt+60; - } - mmTime=tim+mmInt; return(0); OnError: return(-1); } @@ -565,7 +622,8 @@ int SetTemp(int switchOn) { float scale; if (switchOn) { - ERR_I(LogMinMax(1)); + ERR_I(ReadTemp()); + LogMinMax(1); logfileOut(LOG_MAIN, "set %.3f\n", tempC); } scale=cryo.scale; @@ -606,67 +664,19 @@ int SetTemp(int switchOn) { OnError: return(-1); } -int ReadTemp(void) { - char buf[256]; - int i, l; - SensorT *sensor; - - readTemp=0; - - l=0; - for (i=1; i<=4; i++) { - sensor=sensors[i]; - if (sensor->present) { - assert(l<128); - sprintf(buf+l, "KRDG?[sens%d.ch]>sens%d.t;", i, i); - l=strlen(buf); - } else { - sensor->t=0.0; - } - } - if (l>0) { - buf[l-1]='\0'; /* strip off ';' */ - ERR_P(LscCmd(ser, buf)); - } - - cryo.temp=WeightedAverage(sens1.present, sens2.present, sens1.t, sens2.t)*cryo.scale; - samp.temp=WeightedAverage(sens3.present, sens4.present, sens3.t, sens4.t)*samp.scale; - if (samp.temp==0.0) samp.temp=cryo.temp; - if (!deviceFlag - && !samp.dirty && samp.codDefined && !samp.codChanged - && !cryo.dirty && cryo.codDefined && !cryo.codChanged) { - configuring=0; - } else if (configuring==0 && remoteMode==2) { - str_copy(status, "configuring"); - configuring=1; - } - return(0); - OnError: return(-1); -} - int PeriodicTask(void) { char buf[256], lbuf[16]; - char *next; + char *next, *alms; int i, k; time_t putTim; float t3[3], p, d, w, t; - ERR_P(LscCmd(ser, "DIOST?>cod1,out1;DOUT 3,29;HTR?>htr;HTRST?>htrst;BUSY?>busy")); + ERR_P(LscCmd(ser, "DIOST?>cod1,out1;DOUT 3,29;HTR?>htr;HTRST?>htrst;RELAYST?1>relay;BUSY?>busy")); if (cryo.codDefined && samp.codDefined) { per=period; /* no timeout on above command and codes are defined: normal period */ if (per>logPeriod*1000) per=logPeriod*1000; } - if (htrst!=htrst0) { - ERR_I(LogMinMax(0)); - if (htrst<0 || htrst>6) { - sprintf(buf, "heater status %d\n", htrst); - logfileOut(LOG_MAIN, buf); - } else { - logfileOut(LOG_MAIN, heaterStatus[htrst]); - } - htrst0=htrst; - } if (noResp) { /* there was no response on an earlier command, or we are initializing */ if (!configuring) remoteMode=2; LscCmd(ser, "MODE:[remoteMode]"); @@ -726,8 +736,50 @@ int PeriodicTask(void) { noResp=0; } + if (relay) { + if (alarmList[0]!='\0') { + str_copy(buf, "ALARMST?*"); + buf[8]=alarmList[0]; + if (alarmList[1]!='\0') { + str_append(buf,";ALARMST?*"); + buf[18]=alarmList[1]; + } + str_append(buf, ";ALMRST"); + ERR_P(alms=LscCmd(ser, buf)); + if (0!=strcmp(alarms, alms)) { + str_copy(buf, " "); + if (alms[ 0]!='0' || alms[ 2]!='0') buf[0]=alarmList[0]; + if (alms[ 4]!='0' || alms[ 6]!='0') buf[1]=alarmList[1]; + if (0==strcmp(buf," ")) { + logfileOut(LOG_MAIN, "No more alarms, but relay is on!\n"); + } else { + logfileOut(LOG_MAIN, "Alarm on channel %s\n", buf); + } + str_copy(alarms, alms); + } + } else { + if (!relay0) logfileOut(LOG_MAIN, "Relay is on!\n"); + alarms[0]='\0'; + } + } else { + if (relay0) logfileOut(LOG_MAIN, "No more alarms, relay is off\n"); + alarms[0]='\0'; + } + relay0=relay; + ERR_I(ReadTemp()); + if (htrst!=htrst0) { + LogMinMax(0); + if (htrst<0 || htrst>6) { + sprintf(buf, "heater status %d\n", htrst); + logfileOut(LOG_MAIN, buf); + } else { + logfileOut(LOG_MAIN, heaterStatus[htrst]); + } + htrst0=htrst; + } + if (tim>=logTime) { i=0; if (sens1.present) { @@ -748,7 +800,7 @@ int PeriodicTask(void) { } } if (tempC!=0 || htr!=0) { - t3[2]=htr*htr*power*1e-4; + t3[2]=htr*htr*maxPower*1e-4; i=3; } else { t3[2]=undef; @@ -756,7 +808,7 @@ int PeriodicTask(void) { time(&putTim); if (i>0) ERR_I(dlog_put_(&putTim, &i, t3)); logTime=(putTim/logPeriod+1)*logPeriod; - if (tim>mmTime) ERR_I(LogMinMax(0)); + if (tim>mmTime) LogMinMax(0); } if (sens1.present && sens3.present && controlMode==2 && tempC!=0) { t=sens1.t; @@ -884,29 +936,29 @@ int inputSettings(Testpoint *this) { OnError: return(-1); } -int SetPower(void) { +int SetMaxPower(void) { int i, j; float pa, pr, pw, dif; iAmp=1; iRange=0; - if (power>0) { - pa=resist*4; /* max. power */ + if (maxPower>0) { + pa=resist*4; /* max. maxPower */ pw=0; dif=1.0e6; for (i=4; i>0; i--) { pr=pa; for (j=5; j>0; j--) { - if (pr>power) { - if (pr/powermaxPower) { + if (pr/maxPowerpData,"quit","1"); /* send quit flag */ strcpy(result, "1"); @@ -334,7 +334,7 @@ pMe->port=atoi(pPort); } if (pMe->port==0) { - pPort="9750"; + pPort="9753"; pMe->port=atoi(pPort); } str_append(pMe->server, " -p ");