revision of TecsServer / treat "interest" correctly
This commit is contained in:
@ -1,11 +1,12 @@
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Makefile for the TECS Client library
|
# Makefile for the TECS Client library and TecsServer
|
||||||
#
|
#
|
||||||
# Markus Zolliker, March 2000
|
# Markus Zolliker, March 2000
|
||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
OBJ= tecs_cli.o coc_client.o coc_util.o err_handling.o \
|
LIBR_OBJ= coc_util.o err_handling.o str_util.o str_buf.o sys_util.o tecs_dlog.o
|
||||||
str_util.o str_buf.o coc_server.o tecs_lsc.o tecs_serial.o \
|
CLI_OBJ= tecs_cli.o coc_client.o
|
||||||
coc_logfile.o tecs_dlog.o sys_util.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)
|
#------------ for DigitalUnix (add -DFORTIFY to CFLAGS for fortified version)
|
||||||
CC=cc
|
CC=cc
|
||||||
@ -19,12 +20,27 @@ CFLAGS= -std1 -g -warnprotos -I../ -I. -I../hardsup
|
|||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(CFLAGS) -c $*.c
|
$(CC) $(CFLAGS) -c $*.c
|
||||||
|
|
||||||
tecs: $(OBJ)
|
libtecsl.a: $(LIBR_OBJ) $(CLI_OBJ)
|
||||||
- rm libtecsl.a
|
- rm libtecsl.a
|
||||||
ar cr libtecsl.a $(OBJ)
|
ar cr libtecsl.a $(LIBR_OBJ) $(CLI_OBJ)
|
||||||
ranlib libtecsl.a
|
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:
|
clean:
|
||||||
rm *.o
|
- rm *.o
|
||||||
rm *.a
|
- rm *.a
|
||||||
|
- rm bin/TecsServer
|
||||||
|
- rm tecs
|
||||||
|
@ -137,7 +137,7 @@ int CocCmdWithRetry(CocConn *conn) {
|
|||||||
ErrShow("try again, error was");
|
ErrShow("try again, error was");
|
||||||
}
|
}
|
||||||
ERR_P(err=str_get_str(conn->resbuf, NULL));
|
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);
|
return(0);
|
||||||
OnError: return(-1);
|
OnError: return(-1);
|
||||||
}
|
}
|
||||||
@ -145,6 +145,7 @@ int CocCmdWithRetry(CocConn *conn) {
|
|||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
int CocSet(CocConn *conn, const char *name, const char *value) {
|
int CocSet(CocConn *conn, const char *name, const char *value) {
|
||||||
|
int iret=-1;
|
||||||
|
|
||||||
assert(conn!=NULL);
|
assert(conn!=NULL);
|
||||||
str_put_start(conn->cmdbuf);
|
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, value));
|
||||||
ERR_I(str_put_str(conn->cmdbuf, "]"));
|
ERR_I(str_put_str(conn->cmdbuf, "]"));
|
||||||
|
|
||||||
ERR_I(CocCmdWithRetry(conn));
|
ERR_I(iret=CocCmdWithRetry(conn));
|
||||||
|
|
||||||
ERR_I(str_get_end(conn->resbuf));
|
ERR_I(str_get_end(conn->resbuf));
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
OnError: return(-1);
|
OnError: return(iret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
int CocGetN(CocConn *conn, const char *name, char *value, int reslen) {
|
int CocGetN(CocConn *conn, const char *name, char *value, int reslen) {
|
||||||
|
int iret=-1;
|
||||||
|
|
||||||
assert(conn!=NULL);
|
assert(conn!=NULL);
|
||||||
str_put_start(conn->cmdbuf);
|
str_put_start(conn->cmdbuf);
|
||||||
ERR_I(str_put_str(conn->cmdbuf, name));
|
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_P(str_nget_str(conn->resbuf, value, reslen));
|
||||||
ERR_I(str_get_end(conn->resbuf));
|
ERR_I(str_get_end(conn->resbuf));
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
OnError: return(-1);
|
OnError: return(iret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
int CocCmd(CocConn *conn, const char *rwList)
|
int CocCmd(CocConn *conn, const char *rwList)
|
||||||
{ int setmode, i;
|
{ int setmode, i, iret=-1;
|
||||||
const char *t, *s;
|
const char *t, *s;
|
||||||
char nam[32];
|
char nam[32];
|
||||||
CocVar *var;
|
CocVar *var;
|
||||||
@ -215,7 +217,7 @@ int CocCmd(CocConn *conn, const char *rwList)
|
|||||||
s=t+1;
|
s=t+1;
|
||||||
} while (*t!='\0');
|
} while (*t!='\0');
|
||||||
|
|
||||||
ERR_I(CocCmdWithRetry(conn));
|
ERR_I(iret=CocCmdWithRetry(conn));
|
||||||
|
|
||||||
/* read values */
|
/* read values */
|
||||||
s=rwList;
|
s=rwList;
|
||||||
@ -239,7 +241,7 @@ int CocCmd(CocConn *conn, const char *rwList)
|
|||||||
ERR_I(str_get_end(conn->resbuf));
|
ERR_I(str_get_end(conn->resbuf));
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
OnError: return(-1);
|
OnError: return(iret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CocCloseClient(CocConn *conn) {
|
void CocCloseClient(CocConn *conn) {
|
||||||
|
@ -169,7 +169,7 @@ int CocHandle1Request(int tmo_msec, int fd) {
|
|||||||
str_put_start(bufo); /* reset output */
|
str_put_start(bufo); /* reset output */
|
||||||
str_put_str(bufo, err); /* put error message */
|
str_put_str(bufo, err); /* put error message */
|
||||||
logfileOut(LOG_NET, " (%s)\n", err);
|
logfileOut(LOG_NET, " (%s)\n", err);
|
||||||
logfileMask(LOG_NET);
|
/* logfileMask(LOG_NET); */
|
||||||
}
|
}
|
||||||
ERR_SI(send(cl->fd, bufo->buf, bufo->wrpos, 0));
|
ERR_SI(send(cl->fd, bufo->buf, bufo->wrpos, 0));
|
||||||
}
|
}
|
||||||
|
@ -85,9 +85,10 @@ void CocList() {
|
|||||||
|
|
||||||
p=*varListHdl;
|
p=*varListHdl;
|
||||||
while (p!=NULL) {
|
while (p!=NULL) {
|
||||||
printf("%s %d\n", p->name, p->type);
|
printf("%s %d ", p->name, p->type);
|
||||||
p=p->next;
|
p=p->next;
|
||||||
}
|
}
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
CocVar *CocFindVar1(CocVar *varList, const char *name) {
|
CocVar *CocFindVar1(CocVar *varList, const char *name) {
|
||||||
@ -216,7 +217,7 @@ int CocPutVar(CocVar *varList, Str_Buf *buf, const char *name, int secure) {
|
|||||||
} else {
|
} else {
|
||||||
adr=(char *)adr + (int)var->var;
|
adr=(char *)adr + (int)var->var;
|
||||||
}
|
}
|
||||||
if (secure) { /* check acces */
|
if (secure) { /* check access */
|
||||||
if (var->flag==&CocRD) ERR_MSG("variable is read only");
|
if (var->flag==&CocRD) ERR_MSG("variable is read only");
|
||||||
}
|
}
|
||||||
/* printf("put %s %d\n", name, (int)adr); */
|
/* printf("put %s %d\n", name, (int)adr); */
|
||||||
|
@ -69,6 +69,14 @@ void ErrShow(char *text)
|
|||||||
outrtn(outarg, "");
|
outrtn(outarg, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ErrShort(void) {
|
||||||
|
if (outrtn==NULL) {
|
||||||
|
outrtn=ErrOutFil;
|
||||||
|
outarg=stdout;
|
||||||
|
}
|
||||||
|
outrtn(outarg, ErrMessage);
|
||||||
|
}
|
||||||
|
|
||||||
void ErrSetOutRtn(void (*rtn)(), void *arg) {
|
void ErrSetOutRtn(void (*rtn)(), void *arg) {
|
||||||
outrtn=rtn;
|
outrtn=rtn;
|
||||||
outarg=arg;
|
outarg=arg;
|
||||||
@ -89,6 +97,8 @@ void ERR_EXIT(char *text) {
|
|||||||
#define err_show_ err_show
|
#define err_show_ err_show
|
||||||
#define err_txt_ err_txt
|
#define err_txt_ err_txt
|
||||||
#define err_msg_ err_msg
|
#define err_msg_ err_msg
|
||||||
|
#define err_set_outrtn_ err_set_outrtn
|
||||||
|
#define err_short_ err_short
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void err_show_(F_CHAR(text), int text_len) {
|
void err_show_(F_CHAR(text), int text_len) {
|
||||||
@ -112,6 +122,9 @@ void err_msg_(F_CHAR(text), int text_len) {
|
|||||||
ErrMsg(buf);
|
ErrMsg(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void errsetoutrtn_(void (*rtn)(), void *arg) {
|
void err_set_outrtn_(void (*rtn)(), void *arg) {
|
||||||
ErrSetOutRtn(rtn, arg);
|
ErrSetOutRtn(rtn, arg);
|
||||||
}
|
}
|
||||||
|
void err_short_(void) {
|
||||||
|
ErrShort();
|
||||||
|
}
|
||||||
|
@ -73,7 +73,8 @@ Global Variables (read only)
|
|||||||
void ErrTxt(char *text, int systemError);
|
void ErrTxt(char *text, int systemError);
|
||||||
void ErrMsg(char *msg);
|
void ErrMsg(char *msg);
|
||||||
void ErrCod(int code);
|
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 ERR_EXIT(char *text);
|
||||||
void ErrLog(char *text);
|
void ErrLog(char *text);
|
||||||
void ErrSetOutRtn(void (*rtn)(), void *arg);
|
void ErrSetOutRtn(void (*rtn)(), void *arg);
|
||||||
|
@ -11,7 +11,10 @@
|
|||||||
|
|
||||||
static char *last_line = NULL;
|
static char *last_line = NULL;
|
||||||
|
|
||||||
|
int lnblnk_(char *c, int c_len);
|
||||||
char *readline(char *prompt);
|
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)
|
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)
|
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 */
|
int called=0; /* env is valid only if called==1 */
|
||||||
@ -56,10 +59,10 @@ void sighdl(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sys_err_hdl_(void errhdl0())
|
void sys_err_hdl_(void errhdl0())
|
||||||
{ errhdl=errhdl0; };
|
{ errhdl=errhdl0; }
|
||||||
|
|
||||||
void sys_int_hdl_(void inthdl0(int sig))
|
void sys_int_hdl_(void inthdl0(int sig))
|
||||||
{ inthdl=inthdl0; };
|
{ inthdl=inthdl0; }
|
||||||
|
|
||||||
void sys_try_(void proc())
|
void sys_try_(void proc())
|
||||||
{ int sig, status;
|
{ int sig, status;
|
||||||
|
342
tecs/tecs.c
342
tecs/tecs.c
@ -25,8 +25,8 @@ static char *binDir=NULL;
|
|||||||
static char *logDir=NULL;
|
static char *logDir=NULL;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float t, min, max; /* temperatures */
|
float t, t1, t2, min, max; /* temperatures */
|
||||||
int sMin, sMax; /* reading status summary */
|
int stat1, stat2; /* reading status summary */
|
||||||
int present; /* sensor is present */
|
int present; /* sensor is present */
|
||||||
int readStat; /* reading status */
|
int readStat; /* reading status */
|
||||||
char ch[2]; /* channels */
|
char ch[2]; /* channels */
|
||||||
@ -61,8 +61,8 @@ Testpoint /* C standard guarantees initialization to zero */
|
|||||||
static float
|
static float
|
||||||
tempC, /* set T (for sample) */
|
tempC, /* set T (for sample) */
|
||||||
tempH, /* set T on heat exchanger */
|
tempH, /* set T on heat exchanger */
|
||||||
htr, /* heat power percentage */
|
htr, /* heater current percentage */
|
||||||
tLimit, power, /* heater parameters */
|
tLimit, maxPower, /* heater parameters */
|
||||||
tLow=0, tHigh=0, /* lower limit of high-T sensor, upper limit of low-T sensor */
|
tLow=0, tHigh=0, /* lower limit of high-T sensor, upper limit of low-T sensor */
|
||||||
tShift=0, /* setpoint shift */
|
tShift=0, /* setpoint shift */
|
||||||
prop, integ, deriv, /* pid */
|
prop, integ, deriv, /* pid */
|
||||||
@ -74,7 +74,7 @@ static int
|
|||||||
period=5000, /* default read interval (msec.) */
|
period=5000, /* default read interval (msec.) */
|
||||||
logTime, /* next logging time */
|
logTime, /* next logging time */
|
||||||
setFlag, /* temperature to be set */
|
setFlag, /* temperature to be set */
|
||||||
powerFlag, /* power to be set */
|
maxPowerFlag, /* maxPower to be set */
|
||||||
pidFlag, /* pid's to be set */
|
pidFlag, /* pid's to be set */
|
||||||
saveTime, /* time for a CRVSAV command */
|
saveTime, /* time for a CRVSAV command */
|
||||||
noResp=2, /* no response */
|
noResp=2, /* no response */
|
||||||
@ -84,6 +84,7 @@ static int
|
|||||||
remoteMode, /* 1: local, 2: remote */
|
remoteMode, /* 1: local, 2: remote */
|
||||||
maxfld, /* last used display field */
|
maxfld, /* last used display field */
|
||||||
busy, /* busy after CRVSAV */
|
busy, /* busy after CRVSAV */
|
||||||
|
relay, relay0, /* relay status */
|
||||||
deviceFlag, /* device given via net */
|
deviceFlag, /* device given via net */
|
||||||
num, /* curve number */
|
num, /* curve number */
|
||||||
fld, /* field number */
|
fld, /* field number */
|
||||||
@ -112,6 +113,8 @@ static char
|
|||||||
head[64], /* curve header */
|
head[64], /* curve header */
|
||||||
intype[64], /* input configuration */
|
intype[64], /* input configuration */
|
||||||
chan[2], /* actual channel */
|
chan[2], /* actual channel */
|
||||||
|
alarms[20], /* alarm status */
|
||||||
|
alarmList[4], /* alarm list */
|
||||||
dlogfile[128];
|
dlogfile[128];
|
||||||
|
|
||||||
static char
|
static char
|
||||||
@ -364,7 +367,7 @@ int instCurve(char *nam, char *channel, int dispFld) {
|
|||||||
|
|
||||||
int configInput(void) {
|
int configInput(void) {
|
||||||
char *t;
|
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 i, n, nn, dispFld;
|
||||||
int retstat;
|
int retstat;
|
||||||
char *ext;
|
char *ext;
|
||||||
@ -390,12 +393,13 @@ int configInput(void) {
|
|||||||
t=strchr(buf, '\'');
|
t=strchr(buf, '\'');
|
||||||
if (t==NULL) ERR_MSG("missing ' in table file");
|
if (t==NULL) ERR_MSG("missing ' in table file");
|
||||||
t++;
|
t++;
|
||||||
n=1;
|
|
||||||
if (tpoint==&samp) {
|
if (tpoint==&samp) {
|
||||||
sens3.present=0;
|
sens3.present=0;
|
||||||
sens4.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");
|
if (i<1) ERR_MSG("missing sensor name");
|
||||||
|
str_copy(ch0, "CD");
|
||||||
ext=".s";
|
ext=".s";
|
||||||
dispFld=2;
|
dispFld=2;
|
||||||
} else {
|
} else {
|
||||||
@ -403,23 +407,46 @@ int configInput(void) {
|
|||||||
sens2.present=0;
|
sens2.present=0;
|
||||||
tLow=0; tHigh=0;
|
tLow=0; tHigh=0;
|
||||||
controlMode=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 (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";
|
ext=".x";
|
||||||
dispFld=1;
|
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);
|
if (n==0) return(0);
|
||||||
|
|
||||||
nam[strlen(nam)-1]='\0'; /* strip off quote */
|
nam[strlen(nam)-1]='\0'; /* strip off quote */
|
||||||
if (!tpoint->manual) { /* set device name */
|
if (!tpoint->manual) { /* set device name */
|
||||||
str_copy(tpoint->device, nam);
|
str_copy(tpoint->device, nam);
|
||||||
concatDevice();
|
concatDevice();
|
||||||
}
|
}
|
||||||
str_append(nam, ext);
|
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));
|
ERR_I(retstat=instCurve(nam, tpoint->sensor1->ch, dispFld));
|
||||||
tpoint->sensor1->present=1;
|
tpoint->sensor1->present=1;
|
||||||
if (n==2) {
|
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");
|
str_append(nam, "l");
|
||||||
ERR_I(retstat=instCurve(nam, tpoint->sensor2->ch, dispFld+2));
|
ERR_I(retstat=instCurve(nam, tpoint->sensor2->ch, dispFld+2));
|
||||||
tpoint->sensor2->present=1;
|
tpoint->sensor2->present=1;
|
||||||
@ -468,11 +495,11 @@ int loadCache(void) {
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
float WeightedAverage(int presentH, int presentL, float tH, float tL) {
|
float WeightedAverage(float tH, float tL) {
|
||||||
float p,q;
|
float p,q;
|
||||||
|
|
||||||
if (presentH) {
|
if (tH!=0.0) {
|
||||||
if (presentL) {
|
if (tL!=0.0) {
|
||||||
if (tL<tLow) {
|
if (tL<tLow) {
|
||||||
return(tL);
|
return(tL);
|
||||||
} else if (tH<tHigh) {
|
} else if (tH<tHigh) {
|
||||||
@ -483,66 +510,27 @@ float WeightedAverage(int presentH, int presentL, float tH, float tL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(tH);
|
return(tH);
|
||||||
} else if (presentL) {
|
} else if (tL!=0.0) {
|
||||||
return(tL);
|
return(tL);
|
||||||
}
|
}
|
||||||
return(0.0);
|
return(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int LogMinMax(int new) {
|
void LogMinMax(int new) {
|
||||||
char buf[256], bufs[256];
|
char buf[256];
|
||||||
int i, j, l, ls, logIt, stat;
|
int i;
|
||||||
float tol, tmin[2], tmax[2];
|
|
||||||
SensorT *s1, *s2;
|
SensorT *s1, *s2;
|
||||||
|
|
||||||
buf[0]='\0';
|
|
||||||
|
|
||||||
l=0;
|
|
||||||
ls=0;
|
|
||||||
for (i=1; i<=4; i++) {
|
|
||||||
sensor=sensors[i];
|
|
||||||
sensor->sMin=0;
|
|
||||||
sensor->sMax=0;
|
|
||||||
if (sensor->present) {
|
|
||||||
assert(l<128);
|
|
||||||
sprintf(buf+l, "MDAT?[sens%d.ch]>sens%d.min,sens%d.max;", 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);
|
|
||||||
ls=strlen(bufs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ls>0) {
|
|
||||||
bufs[ls-1]='\0'; /* strip off ';' */
|
|
||||||
ERR_P(LscCmd(ser, bufs));
|
|
||||||
str_append(buf, "MNMXRST");
|
|
||||||
ERR_P(LscCmd(ser, buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logIt=0;
|
|
||||||
for (i=0; i<2; i++) {
|
for (i=0; i<2; i++) {
|
||||||
tpoint=tpoints[i];
|
tpoint=tpoints[i];
|
||||||
s1=tpoint->sensor1;
|
s1=tpoint->sensor1;
|
||||||
s2=tpoint->sensor2;
|
s2=tpoint->sensor2;
|
||||||
tpoint->tMin = WeightedAverage(s1->present, s2->present, s1->min, s2->min) * tpoint->scale;
|
tpoint->tMin = WeightedAverage(s1->min, s2->min) * tpoint->scale;
|
||||||
tpoint->tMax = WeightedAverage(s1->present, s2->present, s1->max, s2->max) * 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);
|
sprintf(buf, "@%.3f < T < %.3f K", cryo.tMin, cryo.tMax);
|
||||||
if (samp.tMax>0.0) {
|
if (samp.tMax>0.0) {
|
||||||
@ -556,6 +544,75 @@ int LogMinMax(int new) {
|
|||||||
mmInt=mmInt+60;
|
mmInt=mmInt+60;
|
||||||
}
|
}
|
||||||
mmTime=tim+mmInt;
|
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->stat1=0;
|
||||||
|
sensor->stat2=0;
|
||||||
|
if (sensor->present) {
|
||||||
|
assert(l<128);
|
||||||
|
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.stat1,sens%d.stat2;", i, i, i);
|
||||||
|
ls=strlen(bufs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ls>0) {
|
||||||
|
bufs[ls-1]='\0'; /* strip off ';' */
|
||||||
|
ERR_P(LscCmd(ser, bufs));
|
||||||
|
str_append(buf, "MNMXRST");
|
||||||
|
ERR_P(LscCmd(ser, buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for reading errors */
|
||||||
|
for (i=1; i<=4; i++) {
|
||||||
|
sensor=sensors[i];
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
return(0);
|
return(0);
|
||||||
OnError: return(-1);
|
OnError: return(-1);
|
||||||
}
|
}
|
||||||
@ -565,7 +622,8 @@ int SetTemp(int switchOn) {
|
|||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
if (switchOn) {
|
if (switchOn) {
|
||||||
ERR_I(LogMinMax(1));
|
ERR_I(ReadTemp());
|
||||||
|
LogMinMax(1);
|
||||||
logfileOut(LOG_MAIN, "set %.3f\n", tempC);
|
logfileOut(LOG_MAIN, "set %.3f\n", tempC);
|
||||||
}
|
}
|
||||||
scale=cryo.scale;
|
scale=cryo.scale;
|
||||||
@ -606,67 +664,19 @@ int SetTemp(int switchOn) {
|
|||||||
OnError: return(-1);
|
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) {
|
int PeriodicTask(void) {
|
||||||
char buf[256], lbuf[16];
|
char buf[256], lbuf[16];
|
||||||
char *next;
|
char *next, *alms;
|
||||||
int i, k;
|
int i, k;
|
||||||
time_t putTim;
|
time_t putTim;
|
||||||
float t3[3], p, d, w, t;
|
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) {
|
if (cryo.codDefined && samp.codDefined) {
|
||||||
per=period; /* no timeout on above command and codes are defined: normal period */
|
per=period; /* no timeout on above command and codes are defined: normal period */
|
||||||
if (per>logPeriod*1000) per=logPeriod*1000;
|
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 (noResp) { /* there was no response on an earlier command, or we are initializing */
|
||||||
if (!configuring) remoteMode=2;
|
if (!configuring) remoteMode=2;
|
||||||
LscCmd(ser, "MODE:[remoteMode]");
|
LscCmd(ser, "MODE:[remoteMode]");
|
||||||
@ -726,8 +736,50 @@ int PeriodicTask(void) {
|
|||||||
noResp=0;
|
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());
|
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) {
|
if (tim>=logTime) {
|
||||||
i=0;
|
i=0;
|
||||||
if (sens1.present) {
|
if (sens1.present) {
|
||||||
@ -748,7 +800,7 @@ int PeriodicTask(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tempC!=0 || htr!=0) {
|
if (tempC!=0 || htr!=0) {
|
||||||
t3[2]=htr*htr*power*1e-4;
|
t3[2]=htr*htr*maxPower*1e-4;
|
||||||
i=3;
|
i=3;
|
||||||
} else {
|
} else {
|
||||||
t3[2]=undef;
|
t3[2]=undef;
|
||||||
@ -756,7 +808,7 @@ int PeriodicTask(void) {
|
|||||||
time(&putTim);
|
time(&putTim);
|
||||||
if (i>0) ERR_I(dlog_put_(&putTim, &i, t3));
|
if (i>0) ERR_I(dlog_put_(&putTim, &i, t3));
|
||||||
logTime=(putTim/logPeriod+1)*logPeriod;
|
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) {
|
if (sens1.present && sens3.present && controlMode==2 && tempC!=0) {
|
||||||
t=sens1.t;
|
t=sens1.t;
|
||||||
@ -884,29 +936,29 @@ int inputSettings(Testpoint *this) {
|
|||||||
OnError: return(-1);
|
OnError: return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetPower(void) {
|
int SetMaxPower(void) {
|
||||||
int i, j;
|
int i, j;
|
||||||
float pa, pr, pw, dif;
|
float pa, pr, pw, dif;
|
||||||
|
|
||||||
iAmp=1; iRange=0;
|
iAmp=1; iRange=0;
|
||||||
if (power>0) {
|
if (maxPower>0) {
|
||||||
pa=resist*4; /* max. power */
|
pa=resist*4; /* max. maxPower */
|
||||||
pw=0; dif=1.0e6;
|
pw=0; dif=1.0e6;
|
||||||
for (i=4; i>0; i--) {
|
for (i=4; i>0; i--) {
|
||||||
pr=pa;
|
pr=pa;
|
||||||
for (j=5; j>0; j--) {
|
for (j=5; j>0; j--) {
|
||||||
if (pr>power) {
|
if (pr>maxPower) {
|
||||||
if (pr/power<dif) { dif=pr/power; pw=pr; iAmp=i; iRange=j; }
|
if (pr/maxPower<dif) { dif=pr/maxPower; pw=pr; iAmp=i; iRange=j; }
|
||||||
} else {
|
} else {
|
||||||
if (power/pr<dif) { dif=power/pr; pw=pr; iAmp=i; iRange=j; }
|
if (maxPower/pr<dif) { dif=maxPower/pr; pw=pr; iAmp=i; iRange=j; }
|
||||||
}
|
}
|
||||||
pr=pr/10;
|
pr=pr/10;
|
||||||
}
|
}
|
||||||
pa=pa/4;
|
pa=pa/4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
power=pw;
|
maxPower=pw;
|
||||||
logfileOut(LOG_MAIN, "power %f\n", power, iAmp, iRange);
|
logfileOut(LOG_MAIN, "maxPower %f\n", maxPower, iAmp, iRange);
|
||||||
ERR_P(LscCmd(ser, "CDISP 1:1,[resist],1;MOUT 1:0;CMODE 1:1"));
|
ERR_P(LscCmd(ser, "CDISP 1:1,[resist],1;MOUT 1:0;CMODE 1:1"));
|
||||||
ERR_P(LscCmd(ser, "CLIMIT 1:[tLimit],0,0,[iAmp],[iRange]"));
|
ERR_P(LscCmd(ser, "CLIMIT 1:[tLimit],0,0,[iAmp],[iRange]"));
|
||||||
ERR_I(SetTemp(1));
|
ERR_I(SetTemp(1));
|
||||||
@ -969,7 +1021,6 @@ int Display(void) {
|
|||||||
|
|
||||||
int Settings(void) {
|
int Settings(void) {
|
||||||
char nbuf[256], buf[256], *cfg, *p;
|
char nbuf[256], buf[256], *cfg, *p;
|
||||||
char alarms[3];
|
|
||||||
|
|
||||||
cfg=NULL;
|
cfg=NULL;
|
||||||
if (cryo.dirty && cryo.codDefined || samp.dirty && samp.codDefined) {
|
if (cryo.dirty && cryo.codDefined || samp.dirty && samp.codDefined) {
|
||||||
@ -979,26 +1030,26 @@ int Settings(void) {
|
|||||||
|
|
||||||
ERR_P(LscCmd(ser, "ALARM A:0;ALARM B:0;ALARM C:0;ALARM D:0"));
|
ERR_P(LscCmd(ser, "ALARM A:0;ALARM B:0;ALARM C:0;ALARM D:0"));
|
||||||
|
|
||||||
alarms[0]='\0';
|
alarmList[0]='\0';
|
||||||
alarms[1]='\0';
|
alarmList[1]='\0';
|
||||||
alarms[2]='\0';
|
alarmList[2]='\0';
|
||||||
if (sens1.present) {
|
if (sens1.present) {
|
||||||
ERR_I(SetPower());
|
ERR_I(SetMaxPower());
|
||||||
str_copy(buf, "ALARM [sens1.ch]:1,1,[tLimit],0,0,1;RELAY 1:1;BEEP:0");
|
str_copy(buf, "ALARM [sens1.ch]:1,1,[tLimit],0,1,1;RELAY 1:1;BEEP:0");
|
||||||
alarms[0]=sens1.ch[0];
|
alarmList[0]=sens1.ch[0];
|
||||||
if (sens3.present) {
|
if (sens3.present) {
|
||||||
str_append(buf, ";ALARM [sens3.ch]:1,1,[tLimit],0,0,1");
|
str_append(buf, ";ALARM [sens3.ch]:1,1,[tLimit],0,1,1");
|
||||||
alarms[1]=sens3.ch[0];
|
alarmList[1]=sens3.ch[0];
|
||||||
}
|
}
|
||||||
ERR_P(LscCmd(ser, buf));
|
ERR_P(LscCmd(ser, buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* switch of unused channels */
|
/* switch of unused channels */
|
||||||
buf[0]='\0';
|
buf[0]='\0';
|
||||||
if (NULL==strchr(alarms, 'A')) str_append(buf, ";ALARM A:0");
|
if (NULL==strchr(alarmList, 'A')) str_append(buf, ";ALARM A:0");
|
||||||
if (NULL==strchr(alarms, 'B')) str_append(buf, ";ALARM B:0");
|
if (NULL==strchr(alarmList, 'B')) str_append(buf, ";ALARM B:0");
|
||||||
if (NULL==strchr(alarms, 'C')) str_append(buf, ";ALARM C:0");
|
if (NULL==strchr(alarmList, 'C')) str_append(buf, ";ALARM C:0");
|
||||||
if (NULL==strchr(alarms, 'D')) str_append(buf, ";ALARM D:0");
|
if (NULL==strchr(alarmList, 'D')) str_append(buf, ";ALARM D:0");
|
||||||
if (buf[0]!='\0') ERR_P(LscCmd(ser, buf+1)); /* send without leading semicolon */
|
if (buf[0]!='\0') ERR_P(LscCmd(ser, buf+1)); /* send without leading semicolon */
|
||||||
|
|
||||||
ERR_I(Display());
|
ERR_I(Display());
|
||||||
@ -1033,9 +1084,9 @@ int ExecuteRequest(void) {
|
|||||||
|
|
||||||
if (readTemp) ERR_I(ReadTemp());
|
if (readTemp) ERR_I(ReadTemp());
|
||||||
if (remoteMode==2) ERR_I(Settings());
|
if (remoteMode==2) ERR_I(Settings());
|
||||||
if (powerFlag) {
|
if (maxPowerFlag) {
|
||||||
powerFlag=0;
|
maxPowerFlag=0;
|
||||||
ERR_I(SetPower());
|
ERR_I(SetMaxPower());
|
||||||
}
|
}
|
||||||
if (pidFlag) {
|
if (pidFlag) {
|
||||||
pidFlag=0;
|
pidFlag=0;
|
||||||
@ -1245,15 +1296,15 @@ int main(int argc, char *argv[])
|
|||||||
CocDefPtr(sensor, SensorT);
|
CocDefPtr(sensor, SensorT);
|
||||||
|
|
||||||
CocFltFld(SensorT, t, CocRD);
|
CocFltFld(SensorT, t, CocRD);
|
||||||
CocFltFld(SensorT, min, CocRD);
|
CocFltFld(SensorT, t1, CocRD);
|
||||||
CocFltFld(SensorT, max, CocRD);
|
CocFltFld(SensorT, t2, CocRD);
|
||||||
CocIntFld(SensorT, readStat, CocRD);
|
CocIntFld(SensorT, readStat, CocRD);
|
||||||
CocIntFld(SensorT, sMin, CocRD);
|
CocIntFld(SensorT, stat1, CocRD);
|
||||||
CocIntFld(SensorT, sMax, CocRD);
|
CocIntFld(SensorT, stat2, CocRD);
|
||||||
CocStrFld(SensorT, ch, CocRD);
|
CocStrFld(SensorT, ch, CocRD);
|
||||||
|
|
||||||
CocDefFlt(htr, CocRD);
|
CocDefFlt(htr, CocRD);
|
||||||
CocDefFlt(power, powerFlag);
|
CocDefFlt(maxPower, maxPowerFlag);
|
||||||
CocDefFlt(prop, pidFlag);
|
CocDefFlt(prop, pidFlag);
|
||||||
CocDefFlt(integ, pidFlag);
|
CocDefFlt(integ, pidFlag);
|
||||||
CocDefFlt(deriv, pidFlag);
|
CocDefFlt(deriv, pidFlag);
|
||||||
@ -1294,6 +1345,7 @@ int main(int argc, char *argv[])
|
|||||||
CocDefInt(controlMode, CocWR);
|
CocDefInt(controlMode, CocWR);
|
||||||
CocDefInt(int2, CocWR);
|
CocDefInt(int2, CocWR);
|
||||||
CocDefInt(busy, CocRD);
|
CocDefInt(busy, CocRD);
|
||||||
|
CocDefInt(relay, CocRD);
|
||||||
CocDefInt(serialNo, CocRD);
|
CocDefInt(serialNo, CocRD);
|
||||||
CocDefInt(configuring, CocRD);
|
CocDefInt(configuring, CocRD);
|
||||||
CocDefInt(quit, CocWR);
|
CocDefInt(quit, CocWR);
|
||||||
|
@ -46,6 +46,7 @@ int TeccGet(pTecsClient conn, float *temp) {
|
|||||||
|
|
||||||
int TeccWait(pTecsClient conn) {
|
int TeccWait(pTecsClient conn) {
|
||||||
int last, cnt;
|
int last, cnt;
|
||||||
|
|
||||||
last=0;
|
last=0;
|
||||||
cnt=0;
|
cnt=0;
|
||||||
do {
|
do {
|
||||||
@ -142,23 +143,25 @@ static pTecsClient conn=NULL;
|
|||||||
|
|
||||||
int tecs_set_par_(F_CHAR(name), F_CHAR(par), int name_len, int par_len) {
|
int tecs_set_par_(F_CHAR(name), F_CHAR(par), int name_len, int par_len) {
|
||||||
char nbuf[64], pbuf[256];
|
char nbuf[64], pbuf[256];
|
||||||
|
int iret=-1;
|
||||||
|
|
||||||
STR_TO_C(nbuf, name);
|
STR_TO_C(nbuf, name);
|
||||||
STR_TO_C(pbuf, par);
|
STR_TO_C(pbuf, par);
|
||||||
|
|
||||||
ERR_I(CocSet(conn, nbuf, pbuf));
|
ERR_I(iret=CocSet(conn, nbuf, pbuf));
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
OnError: return(-1);
|
OnError: return(iret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tecs_get_par_(F_CHAR(name), F_CHAR(par), int name_len, int par_len) {
|
int tecs_get_par_(F_CHAR(name), F_CHAR(par), int name_len, int par_len) {
|
||||||
char nbuf[64], pbuf[256];
|
char nbuf[64], pbuf[256];
|
||||||
|
int iret=-1;
|
||||||
|
|
||||||
STR_TO_C(nbuf, name);
|
STR_TO_C(nbuf, name);
|
||||||
ERR_I(CocGet(conn, nbuf, pbuf));
|
ERR_I(iret=CocGet(conn, nbuf, pbuf));
|
||||||
return(STR_TO_F(par, pbuf));
|
return(STR_TO_F(par, pbuf));
|
||||||
OnError: return(-1);
|
OnError: return(iret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tecs_send_(F_CHAR(cmd), F_CHAR(reply), int cmd_len, int reply_len) {
|
int tecs_send_(F_CHAR(cmd), F_CHAR(reply), int cmd_len, int reply_len) {
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
print *,'device temperature device'
|
print *,'device temperature device'
|
||||||
print *,'controlMode control on: 0: heat exchanger, '
|
print *,'controlMode control on: 0: heat exchanger, '
|
||||||
1 ,'1: sample, 2: second loop'
|
1 ,'1: sample, 2: second loop'
|
||||||
print *,'power heater max. power'
|
print *,'maxPower heater max. power'
|
||||||
print *,'prop PID gain'
|
print *,'prop PID gain'
|
||||||
print *,'int PID integration time: 1000/int sec'
|
print *,'int PID integration time: 1000/int sec'
|
||||||
print *,'deriv PID derivation term'
|
print *,'deriv PID derivation term'
|
||||||
@ -116,7 +116,7 @@
|
|||||||
print *,'Read only parameters:'
|
print *,'Read only parameters:'
|
||||||
print *
|
print *
|
||||||
print *,'tX heat exchanger temperature'
|
print *,'tX heat exchanger temperature'
|
||||||
print *,'tP sample temperature'
|
print *,'tS sample temperature'
|
||||||
print *,'tempH set-point on regulation'
|
print *,'tempH set-point on regulation'
|
||||||
print *,'tLimit temperature limit'
|
print *,'tLimit temperature limit'
|
||||||
print *,'htr heater current percentage'
|
print *,'htr heater current percentage'
|
||||||
@ -167,7 +167,11 @@
|
|||||||
endif
|
endif
|
||||||
goto 1
|
goto 1
|
||||||
|
|
||||||
19 call tecs_write_error(6)
|
19 if (iret .eq. -2) then
|
||||||
|
call tecs_write_msg(6)
|
||||||
|
else
|
||||||
|
call tecs_write_error(6)
|
||||||
|
endif
|
||||||
goto 1
|
goto 1
|
||||||
|
|
||||||
91 if (iret .lt. 0) then
|
91 if (iret .lt. 0) then
|
||||||
|
@ -179,11 +179,27 @@ c------------------------------------------------------------------------------
|
|||||||
|
|
||||||
external tecs_err_routine
|
external tecs_err_routine
|
||||||
|
|
||||||
call ErrSetOutRtn(tecs_err_routine, iolun)
|
call err_set_outrtn(tecs_err_routine, iolun)
|
||||||
call err_show('Error in TECS')
|
call err_show('Error in TECS')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
subroutine TECS_WRITE_MSG(IOLUN) !!
|
||||||
|
!! ================================
|
||||||
|
!!
|
||||||
|
!! write out error message of last error and stack info
|
||||||
|
!!
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
integer IOLUN !! logical unit for output
|
||||||
|
|
||||||
|
external tecs_err_routine
|
||||||
|
|
||||||
|
call err_set_outrtn(tecs_err_routine, iolun)
|
||||||
|
call err_short
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
SUBROUTINE TECS_ERR_ROUTINE (LUN, TEXT)
|
SUBROUTINE TECS_ERR_ROUTINE (LUN, TEXT)
|
||||||
! =======================================
|
! =======================================
|
||||||
!
|
!
|
||||||
|
@ -42,6 +42,7 @@ subroutine tecs_plot(file)
|
|||||||
goto 99
|
goto 99
|
||||||
endif
|
endif
|
||||||
xmax=0
|
xmax=0
|
||||||
|
x1=0
|
||||||
|
|
||||||
1 if (right .or. window==0 .or. live) then
|
1 if (right .or. window==0 .or. live) then
|
||||||
ntot=dlog_get(dmax, nset, tbase, -window*1.1, 0.0, undef, xd, yd)
|
ntot=dlog_get(dmax, nset, tbase, -window*1.1, 0.0, undef, xd, yd)
|
||||||
@ -55,7 +56,11 @@ subroutine tecs_plot(file)
|
|||||||
x2=maxval(xd(1:ntot))
|
x2=maxval(xd(1:ntot))
|
||||||
endif
|
endif
|
||||||
if (live) then
|
if (live) then
|
||||||
|
if (x1 .eq. 0) then
|
||||||
x1=max(x2-window,xd(1))
|
x1=max(x2-window,xd(1))
|
||||||
|
else
|
||||||
|
window=x2-x1
|
||||||
|
endif
|
||||||
x2=max(x1+window,x2+min(window*0.2,max(window*0.01,300.)))
|
x2=max(x1+window,x2+min(window*0.2,max(window*0.01,300.)))
|
||||||
elseif (window==0) then
|
elseif (window==0) then
|
||||||
x1=minval(xd(1:ntot))
|
x1=minval(xd(1:ntot))
|
||||||
@ -65,10 +70,12 @@ subroutine tecs_plot(file)
|
|||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if (.not. zoom) then
|
if (.not. zoom) then
|
||||||
x1=x2-window
|
|
||||||
if (window==0) then ! maximal
|
if (window==0) then ! maximal
|
||||||
x1=0
|
x1=0
|
||||||
x2=1e20
|
x2=1e20
|
||||||
|
else
|
||||||
|
x2=(x1+x2+window)/2
|
||||||
|
x1=x2-window
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ntot=dlog_get(dmax, nset, tbase, x1-window*0.1, x2+window*0.1, undef, xd, yd)
|
ntot=dlog_get(dmax, nset, tbase, x1-window*0.1, x2+window*0.1, undef, xd, yd)
|
||||||
@ -122,12 +129,13 @@ subroutine tecs_plot(file)
|
|||||||
enddo
|
enddo
|
||||||
|
|
||||||
ey=(ymax(rl)-ymin(rl))
|
ey=(ymax(rl)-ymin(rl))
|
||||||
|
fy=abs(ymax(rl))
|
||||||
if (rl==1) then
|
if (rl==1) then
|
||||||
ymax(rl)=ymax(rl)+ey*0.25
|
ymax(rl)=ymax(rl)+max(fy*0.0075,ey*0.25)
|
||||||
ymin(rl)=ymin(rl)-ey*0.01
|
ymin(rl)=ymin(rl)-max(fy*0.005,ey*0.01)
|
||||||
else
|
else
|
||||||
ymax(rl)=ymax(rl)+ey*0.01
|
ymax(rl)=ymax(rl)+max(fy*0.1,ey*0.01)
|
||||||
ymin(rl)=ymin(rl)-ey*4
|
ymin(rl)=ymin(rl)-max(fy,ey*4)
|
||||||
endif
|
endif
|
||||||
if (live) then
|
if (live) then
|
||||||
ymin(rl)=min(ymin(rl),max(0.0,ylast1-ey*0.4))
|
ymin(rl)=min(ymin(rl),max(0.0,ylast1-ey*0.4))
|
||||||
@ -346,18 +354,26 @@ subroutine tecs_plot(file)
|
|||||||
call pgsci(1)
|
call pgsci(1)
|
||||||
call pgmtxt('T', 2.0, 0.9, 0.0, buf(l:))
|
call pgmtxt('T', 2.0, 0.9, 0.0, buf(l:))
|
||||||
endif
|
endif
|
||||||
|
if (xwin .and. .not. live) then
|
||||||
|
call pgcurs(ex, ey, key)
|
||||||
|
call must_purge
|
||||||
|
else
|
||||||
call get_key(key, 2, 10)
|
call get_key(key, 2, 10)
|
||||||
|
endif
|
||||||
if (key/=char(0)) goto 8
|
if (key/=char(0)) goto 8
|
||||||
goto 7
|
goto 7
|
||||||
elseif (key .eq. 'D') then
|
elseif (key .eq. 'D') then
|
||||||
window=min(7*24*3600,24*3600*max(1,numb))
|
window=min(7*24*3600,24*3600*max(1,numb))
|
||||||
right=.true.
|
right=.true.
|
||||||
|
x1=0
|
||||||
elseif (key .eq. 'H') then
|
elseif (key .eq. 'H') then
|
||||||
window=min(7*24*3600,3600*max(1,numb))
|
window=min(7*24*3600,3600*max(1,numb))
|
||||||
right=.true.
|
right=.true.
|
||||||
|
x1=0
|
||||||
elseif (key .eq. 'M') then
|
elseif (key .eq. 'M') then
|
||||||
window=min(7*24*3600,60*max(1,numb))
|
window=min(7*24*3600,60*max(1,numb))
|
||||||
right=.true.
|
right=.true.
|
||||||
|
x1=0
|
||||||
elseif (key .eq. 'L') then
|
elseif (key .eq. 'L') then
|
||||||
live=.not. live
|
live=.not. live
|
||||||
if (live) then
|
if (live) then
|
||||||
|
@ -102,7 +102,7 @@
|
|||||||
strcat(pBueffel, argv[1]);
|
strcat(pBueffel, argv[1]);
|
||||||
strcat(pBueffel, " ");
|
strcat(pBueffel, " ");
|
||||||
strtolower(pBueffel);
|
strtolower(pBueffel);
|
||||||
if ( NULL==strstr(" log send list tolerance access errorhandler interrupt ", pBueffel)
|
if ( NULL==strstr(" log send list tolerance access errorhandler interrupt interest ", pBueffel)
|
||||||
&& NULL==strstr(" upperlimit lowerlimit safevalue currentvalue targetvalue ", pBueffel)
|
&& NULL==strstr(" upperlimit lowerlimit safevalue currentvalue targetvalue ", pBueffel)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@ -116,7 +116,7 @@
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
} else { /* get case or command without parameter */
|
} else { /* get case (or command without parameter) */
|
||||||
if (0==strcasecmp(argv[1], "kill")) {
|
if (0==strcasecmp(argv[1], "kill")) {
|
||||||
iRet=CocSet(pMe->pData,"quit","1"); /* send quit flag */
|
iRet=CocSet(pMe->pData,"quit","1"); /* send quit flag */
|
||||||
strcpy(result, "1");
|
strcpy(result, "1");
|
||||||
@ -334,7 +334,7 @@
|
|||||||
pMe->port=atoi(pPort);
|
pMe->port=atoi(pPort);
|
||||||
}
|
}
|
||||||
if (pMe->port==0) {
|
if (pMe->port==0) {
|
||||||
pPort="9750";
|
pPort="9753";
|
||||||
pMe->port=atoi(pPort);
|
pMe->port=atoi(pPort);
|
||||||
}
|
}
|
||||||
str_append(pMe->server, " -p ");
|
str_append(pMe->server, " -p ");
|
||||||
|
Reference in New Issue
Block a user