New TECS Version Sept. 2001 M.Z.
This commit is contained in:
@ -7,7 +7,7 @@ LIBR_OBJ= coc_util.o myc_err.o myc_str.o myc_buf.o myc_time.o
|
|||||||
SERV_OBJ= tecs.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o tecs_data.o $(LIBR_OBJ)
|
SERV_OBJ= tecs.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o tecs_data.o $(LIBR_OBJ)
|
||||||
CLI_OBJ= tecs_cli.o coc_client.o $(LIBR_OBJ)
|
CLI_OBJ= tecs_cli.o coc_client.o $(LIBR_OBJ)
|
||||||
TCLI_OBJ= sys_aunix.o sys_aunix_c.o $(CLI_OBJ)
|
TCLI_OBJ= sys_aunix.o sys_aunix_c.o $(CLI_OBJ)
|
||||||
TECLI_OBJ= tecs_client.o tecs_plot.o tecs_for.o sys_util.o str.o $(TCLI_OBJ)
|
TECLI_OBJ= tecs_client.o tecs_plot.o tecs_for.o sys_util.o str.o instr_hosts.o $(TCLI_OBJ)
|
||||||
|
|
||||||
#------------ for DigitalUnix (add -DFORTIFY to CFLAGS for fortified version)
|
#------------ for DigitalUnix (add -DFORTIFY to CFLAGS for fortified version)
|
||||||
CC=cc
|
CC=cc
|
||||||
@ -26,7 +26,7 @@ libtecsl.a: $(CLI_OBJ)
|
|||||||
ar cr libtecsl.a $(CLI_OBJ)
|
ar cr libtecsl.a $(CLI_OBJ)
|
||||||
ranlib libtecsl.a
|
ranlib libtecsl.a
|
||||||
|
|
||||||
all: libtecsl.a bin/TecsServer bin/TecsClient rstart keep_running
|
all: libtecsl.a bin/TecsServer bin/TecsClient rstart bin/keep_running
|
||||||
|
|
||||||
tecs_plot.o: tecs_plot.f90
|
tecs_plot.o: tecs_plot.f90
|
||||||
f90 -c -u -g tecs_plot.f90
|
f90 -c -u -g tecs_plot.f90
|
||||||
@ -44,11 +44,17 @@ six: six.c term.c sys_select.c $(LIBR_OBJ)
|
|||||||
$(CC) $(CFLAGS) -o six six.c term.c sys_select.c $(LIBR_OBJ) \
|
$(CC) $(CFLAGS) -o six six.c term.c sys_select.c $(LIBR_OBJ) \
|
||||||
-L/data/lnslib/lib -so_archive -lreadline -ltermcap -lX11 -lXm
|
-L/data/lnslib/lib -so_archive -lreadline -ltermcap -lX11 -lXm
|
||||||
|
|
||||||
rstart: $(LIBR_OBJ) rstart.c myc_str.o myc_err.o
|
rstart: rstart.c myc_str.o myc_err.o instr_hosts.o
|
||||||
$(CC) $(CFLAGS) -o rstart rstart.c myc_str.o myc_err.o
|
$(CC) $(CFLAGS) -o rstart rstart.c myc_str.o myc_err.o instr_hosts.o
|
||||||
|
|
||||||
keep_running: keep_running.c
|
serverd: serverd.c $(LIBR_OBJ)
|
||||||
$(CC) $(CFLAGS) -o keep_running keep_running.c
|
$(CC) $(CFLAGS) -o serverd serverd.c $(LIBR_OBJ)
|
||||||
|
|
||||||
|
starts: starts.c $(LIBR_OBJ)
|
||||||
|
$(CC) $(CFLAGS) -o starts starts.c $(LIBR_OBJ)
|
||||||
|
|
||||||
|
bin/keep_running: keep_running.c
|
||||||
|
$(CC) $(CFLAGS) -o bin/keep_running keep_running.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
- rm *.o
|
- rm *.o
|
||||||
|
@ -24,16 +24,22 @@ int main(int argc, char *argv[]) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
if (status==0) {
|
if (status==512) { /* kill */
|
||||||
printf("Regular exit\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (status==256) { /* restart */
|
||||||
|
cnt = MAX_CNT;
|
||||||
|
}
|
||||||
time(&tim2);
|
time(&tim2);
|
||||||
dif = (int) difftime(tim2, tim1);
|
dif = (int) difftime(tim2, tim1);
|
||||||
cnt += dif / MIN_PERIOD;
|
cnt += dif / MIN_PERIOD;
|
||||||
if (cnt > MAX_CNT) cnt = MAX_CNT;
|
if (cnt > MAX_CNT) cnt = MAX_CNT;
|
||||||
cnt--;
|
cnt--;
|
||||||
|
if (dif < MIN_PERIOD) {
|
||||||
printf("Status=%d. Died after %d sec", status, dif);
|
printf("Status=%d. Died after %d sec", status, dif);
|
||||||
|
} else {
|
||||||
|
printf("Status=%d. Died after %f hours", status, dif/3600.);
|
||||||
|
}
|
||||||
if (cnt > 0) {
|
if (cnt > 0) {
|
||||||
printf(" - %d tries left - retry ...\n", cnt);
|
printf(" - %d tries left - retry ...\n", cnt);
|
||||||
}
|
}
|
||||||
|
102
tecs/rstart.c
102
tecs/rstart.c
@ -5,54 +5,17 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include "myc_str.h"
|
#include "myc_str.h"
|
||||||
|
#include "instr_hosts.h"
|
||||||
|
|
||||||
int rexec(char **host, int port, char *user, char *passwd, char *command, int *err_file_desc);
|
int rexec(char **host, int port, char *user, char *passwd, char *command, int *err_file_desc);
|
||||||
|
|
||||||
int wrtRd(int fd, char *cmd, char *res, int res_len) {
|
|
||||||
int i, p, l, cnt;
|
|
||||||
char buf[8192];
|
|
||||||
struct timeval tmo;
|
|
||||||
fd_set rmask;
|
|
||||||
|
|
||||||
if (cmd[0]!='\0') {
|
|
||||||
l=send(fd, cmd, strlen(cmd), 0);
|
|
||||||
if (l<0) return -1;
|
|
||||||
}
|
|
||||||
tmo.tv_sec=2;
|
|
||||||
i=1;
|
|
||||||
p=0;
|
|
||||||
while (i>0 && p<sizeof(buf)-1) {
|
|
||||||
FD_ZERO(&rmask);
|
|
||||||
FD_SET(fd, &rmask);
|
|
||||||
tmo.tv_usec=500000;
|
|
||||||
i=select(fd+1, &rmask, NULL, NULL, &tmo);
|
|
||||||
tmo.tv_sec=0;
|
|
||||||
if (i>0) {
|
|
||||||
l=recv(fd, buf+p, sizeof(buf)-p-1, 0);
|
|
||||||
if (l<0) return -1;
|
|
||||||
p=p+l;
|
|
||||||
if (l==0) i=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (p >= res_len) p=res_len-1;
|
|
||||||
buf[p]='\0';
|
|
||||||
strcpy(res, buf);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int port, i, j, l, fd;
|
int port, i, j, l, fd;
|
||||||
char *host, inst[32], cmd[256], buf[256], path[256];
|
char inst[32], cmd[256], host[256], user[64], pcod[64];
|
||||||
char *instrHosts[]={
|
char *hostp;
|
||||||
"DMC","lnsa05.psi.ch",
|
struct tm tim;
|
||||||
"TOPSI","lnsa07.psi.ch",
|
time_t t;
|
||||||
"SANS","lnsa10.psi.ch",
|
|
||||||
"HRPT","lnsa11.psi.ch",
|
|
||||||
"TRICS","lnsa13.psi.ch",
|
|
||||||
"AMOR","lnsa14.psi.ch",
|
|
||||||
"FOCUS","lnsa16.psi.ch",
|
|
||||||
"ZOLLIKER","lnsa15.psi.ch"
|
|
||||||
};
|
|
||||||
struct servent s;
|
struct servent s;
|
||||||
|
|
||||||
s=*getservbyname("exec", "tcp");
|
s=*getservbyname("exec", "tcp");
|
||||||
@ -61,61 +24,28 @@ int main(int argc, char *argv[]) {
|
|||||||
printf("not enough arguments\n");
|
printf("not enough arguments\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
str_upcase(inst, argv[1]);
|
i=InstrHost(argv[1], inst, host, user, pcod, sizeof(inst), sizeof(host), sizeof(user), sizeof(pcod));
|
||||||
str_copy(cmd, "\n");
|
if (i==0) {
|
||||||
|
printf("unknown host/instrument\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
str_copy(cmd, "");
|
||||||
for (i=2; i<argc; i++) {
|
for (i=2; i<argc; i++) {
|
||||||
if (0==strcmp(argv[i], "sics")) {
|
if (0==strcmp(argv[i], "sics")) {
|
||||||
str_append(cmd, "startsics\n");
|
str_append(cmd, "bin/startsics\n");
|
||||||
} else if (0==strcmp(argv[i], "tecs")) {
|
} else if (0==strcmp(argv[i], "tecs")) {
|
||||||
str_append(cmd, "startecs\n");
|
str_append(cmd, "bin/startecs\n");
|
||||||
} else {
|
} else {
|
||||||
printf("unknown server %s\n", argv[i]);
|
printf("unknown server %s\n", argv[i]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf[0]='\0';
|
|
||||||
host=NULL;
|
|
||||||
for (i=0; i<sizeof(instrHosts)/sizeof(instrHosts[0]); i+=2) {
|
|
||||||
if (0==strcmp(instrHosts[i], inst)) {
|
|
||||||
host=instrHosts[i+1];
|
|
||||||
} else if (0==strcmp(instrHosts[i+1], argv[1])) {
|
|
||||||
host=argv[1];
|
|
||||||
str_copy(inst,instrHosts[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (0==strcmp(inst, "ZOLLIKER")) {
|
|
||||||
str_copy(buf, "69kilo");
|
|
||||||
str_copy(inst, "zolliker");
|
|
||||||
} else if (host==NULL) {
|
|
||||||
printf("unknown instrument: %s\n", argv[1]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
printf("login to %s\n", host);
|
printf("login to %s\n", host);
|
||||||
if (buf[0]=='\0') {
|
hostp=host;
|
||||||
str_copy(buf, inst);
|
fd=rexec(&hostp, s.s_port, user, pcod, cmd, &i);
|
||||||
str_append(buf, "LNS");
|
|
||||||
}
|
|
||||||
fd=rexec(&host, s.s_port, inst, buf, "rlogin 0", &i);
|
|
||||||
if (fd<0) {
|
if (fd<0) {
|
||||||
perror("rexec"); return -1;
|
perror("rexec"); return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wrtRd(fd, "\n", buf, sizeof(buf)) < 0) goto Error;
|
|
||||||
if (wrtRd(fd, "\n", buf, sizeof(buf)) < 0) goto Error;
|
|
||||||
if (wrtRd(fd, "\n", buf, sizeof(buf)) < 0) goto Error;
|
|
||||||
if (wrtRd(fd, cmd, buf, sizeof(buf)) < 0) goto Error;
|
|
||||||
printf("%s\n", buf);
|
|
||||||
l=1;
|
|
||||||
while (l>0) {
|
|
||||||
if (l=wrtRd(fd, "", buf, sizeof(buf)) < 0) goto Error;
|
|
||||||
printf("%s", buf);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
i=10;
|
|
||||||
while (i>0 && wrtRd(fd, "logout\n", buf, sizeof(buf)) >= 0) {
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
Error: perror("error in wrtRd"); return 0;
|
|
||||||
}
|
}
|
||||||
|
396
tecs/tecs.c
396
tecs/tecs.c
@ -48,6 +48,7 @@ static SensorT
|
|||||||
*ctlSens=NULL, /* control sensor */
|
*ctlSens=NULL, /* control sensor */
|
||||||
*heliumSens=NULL,
|
*heliumSens=NULL,
|
||||||
*auxSens=NULL,
|
*auxSens=NULL,
|
||||||
|
*testSens=NULL,
|
||||||
*sens=&sensA;
|
*sens=&sensA;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -89,6 +90,7 @@ static float
|
|||||||
tm=DATA_UNDEF, /* main temperature */
|
tm=DATA_UNDEF, /* main temperature */
|
||||||
ts=DATA_UNDEF, /* sample temperature */
|
ts=DATA_UNDEF, /* sample temperature */
|
||||||
tr=DATA_UNDEF, /* set temperature (read back) */
|
tr=DATA_UNDEF, /* set temperature (read back) */
|
||||||
|
te=DATA_UNDEF, /* test temperature */
|
||||||
he=DATA_UNDEF, /* helium level value */
|
he=DATA_UNDEF, /* helium level value */
|
||||||
aux=DATA_UNDEF, /* auxiliary value */
|
aux=DATA_UNDEF, /* auxiliary value */
|
||||||
ramp=0,
|
ramp=0,
|
||||||
@ -103,7 +105,7 @@ static int
|
|||||||
logTime, /* next logging time */
|
logTime, /* next logging time */
|
||||||
settingsFlag, /* settings to be done */
|
settingsFlag, /* settings to be done */
|
||||||
saveTime, /* time for a CRVSAV command */
|
saveTime, /* time for a CRVSAV command */
|
||||||
noResp=2, /* no response */
|
noResp=1, /* no response */
|
||||||
quit, /* quit server */
|
quit, /* quit server */
|
||||||
controlMode=2, /* 0: control on heater, 1: control on sample, 3: 2nd loop for difference heater-sample */
|
controlMode=2, /* 0: control on heater, 1: control on sample, 3: 2nd loop for difference heater-sample */
|
||||||
int2=30, /* inegration time for controlMode 2 */
|
int2=30, /* inegration time for controlMode 2 */
|
||||||
@ -125,6 +127,7 @@ static int
|
|||||||
tim0, /* msec Time */
|
tim0, /* msec Time */
|
||||||
per, /* effective period */
|
per, /* effective period */
|
||||||
mmInt, mmTime, /* interval and time for next min-max logging */
|
mmInt, mmTime, /* interval and time for next min-max logging */
|
||||||
|
cntError,
|
||||||
tableTime; /* last time when table was read */
|
tableTime; /* last time when table was read */
|
||||||
|
|
||||||
int tim, rdTim; /* actual time, read Time */
|
int tim, rdTim; /* actual time, read Time */
|
||||||
@ -142,8 +145,9 @@ static char
|
|||||||
alarms[20], /* alarm status */
|
alarms[20], /* alarm status */
|
||||||
alarmChannels[4]=" ",
|
alarmChannels[4]=" ",
|
||||||
alarmList[4], /* alarm list */
|
alarmList[4], /* alarm list */
|
||||||
|
config[256], /* special configuration commands */
|
||||||
helium[80], /* helium level status */
|
helium[80], /* helium level status */
|
||||||
/* send[256], */
|
heUnits[4], /* helium level units */
|
||||||
controlChannel[2]="A";
|
controlChannel[2]="A";
|
||||||
|
|
||||||
static char
|
static char
|
||||||
@ -177,7 +181,7 @@ int IdleHdl(int tmo, int fd) {
|
|||||||
|
|
||||||
iRet=CocHandleRequests(tmo, fd);
|
iRet=CocHandleRequests(tmo, fd);
|
||||||
if (iRet<0) logfileShowErr("CocHandleRequests");
|
if (iRet<0) logfileShowErr("CocHandleRequests");
|
||||||
return(iRet);
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *SetClientData(void *data) {
|
void *SetClientData(void *data) {
|
||||||
@ -198,6 +202,7 @@ void ConcatDevice(void) {
|
|||||||
str_append(device, "/");
|
str_append(device, "/");
|
||||||
str_append(device, plug1.device);
|
str_append(device, plug1.device);
|
||||||
}
|
}
|
||||||
|
if (device[0]=='\0') return;
|
||||||
if (plug0.manual) {
|
if (plug0.manual) {
|
||||||
str_append(device, " (manual");
|
str_append(device, " (manual");
|
||||||
} else {
|
} else {
|
||||||
@ -228,8 +233,8 @@ int PutPermanentData(FILE *fil) {
|
|||||||
}
|
}
|
||||||
sprintf(buf, "%s%s/%s%s/%d/%d\n", d1, plug0.device, d2, plug1.device, plug0.code, plug1.code);
|
sprintf(buf, "%s%s/%s%s/%d/%d\n", d1, plug0.device, d2, plug1.device, plug0.code, plug1.code);
|
||||||
ERR_SI(fputs(buf, fil));
|
ERR_SI(fputs(buf, fil));
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstalCurve(SensorT *sensor, char *dev) {
|
int InstalCurve(SensorT *sensor, char *dev) {
|
||||||
@ -254,11 +259,9 @@ int InstalCurve(SensorT *sensor, char *dev) {
|
|||||||
} else {
|
} else {
|
||||||
ERR_P(LscCmd(ser, "INTYPE [chan]:0,1,2,1,12;MNMX [chan]:1,3")); /* 5 V Range */
|
ERR_P(LscCmd(ser, "INTYPE [chan]:0,1,2,1,12;MNMX [chan]:1,3")); /* 5 V Range */
|
||||||
}
|
}
|
||||||
if (sens->type=='h') {
|
ERR_P(LscCmd(ser, "INCRV [chan]:0"));
|
||||||
/* helium */
|
|
||||||
}
|
|
||||||
if (settingsFlag==0) sens->present=1;
|
if (settingsFlag==0) sens->present=1;
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fil=NULL;
|
fil=NULL;
|
||||||
@ -401,7 +404,7 @@ int InstalCurve(SensorT *sensor, char *dev) {
|
|||||||
|
|
||||||
if (settingsFlag==0) sens->present=1;
|
if (settingsFlag==0) sens->present=1;
|
||||||
/*
|
/*
|
||||||
if (num<=20) return(0);
|
if (num<=20) return 0;
|
||||||
*/
|
*/
|
||||||
/* standard curve, do not touch cache */
|
/* standard curve, do not touch cache */
|
||||||
|
|
||||||
@ -431,7 +434,6 @@ int InstalCurve(SensorT *sensor, char *dev) {
|
|||||||
sprintf(lbuf, "lsc.%d", serialNo);
|
sprintf(lbuf, "lsc.%d", serialNo);
|
||||||
str_append(buf, lbuf);
|
str_append(buf, lbuf);
|
||||||
rename(nbuf, buf); /* rename to permanent version */
|
rename(nbuf, buf); /* rename to permanent version */
|
||||||
logfileOut(LOG_MAIN, buf);
|
|
||||||
fil=NULL;
|
fil=NULL;
|
||||||
FREE(cache);
|
FREE(cache);
|
||||||
/* re-read it */
|
/* re-read it */
|
||||||
@ -443,12 +445,12 @@ int InstalCurve(SensorT *sensor, char *dev) {
|
|||||||
buf[strlen(buf)-2]='\0'; /* strip off "-1" */
|
buf[strlen(buf)-2]='\0'; /* strip off "-1" */
|
||||||
rename(buf, buf); /* lower version number */
|
rename(buf, buf); /* lower version number */
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
|
|
||||||
OnError:
|
OnError:
|
||||||
if (crv!=NULL) FREE(crv);
|
if (crv!=NULL) FREE(crv);
|
||||||
if (fil!=NULL) fclose(fil);
|
if (fil!=NULL) fclose(fil);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PrepInput(char *label) {
|
int PrepInput(char *label) {
|
||||||
@ -478,6 +480,7 @@ int PrepInput(char *label) {
|
|||||||
sensA.lim=0;
|
sensA.lim=0;
|
||||||
sensB.lim=0;
|
sensB.lim=0;
|
||||||
controlMode=0;
|
controlMode=0;
|
||||||
|
config[0]='\0';
|
||||||
} else {
|
} else {
|
||||||
sensC.present=0;
|
sensC.present=0;
|
||||||
sensD.present=0;
|
sensD.present=0;
|
||||||
@ -488,6 +491,7 @@ int PrepInput(char *label) {
|
|||||||
}
|
}
|
||||||
loop=1;
|
loop=1;
|
||||||
resist=10;
|
resist=10;
|
||||||
|
str_copy(heUnits, "%");
|
||||||
|
|
||||||
i=sscanf(t, "%12s%n", nam, &l);
|
i=sscanf(t, "%12s%n", nam, &l);
|
||||||
if (i<1) ERR_MSG("missing device name");
|
if (i<1) ERR_MSG("missing device name");
|
||||||
@ -520,7 +524,7 @@ int PrepInput(char *label) {
|
|||||||
s=sensors[i];
|
s=sensors[i];
|
||||||
typ=chans[i];
|
typ=chans[i];
|
||||||
if (typ=='_') typ='\0';
|
if (typ=='_') typ='\0';
|
||||||
if (NULL==strchr("mnslhx", typ)) ERR_MSG("unknown channel type code");
|
if (NULL==strchr("mnslhxt", typ)) ERR_MSG("unknown channel type code");
|
||||||
if (typ!='\0') {
|
if (typ!='\0') {
|
||||||
s->present=-1;
|
s->present=-1;
|
||||||
}
|
}
|
||||||
@ -533,8 +537,8 @@ int PrepInput(char *label) {
|
|||||||
str_copy(plug->device, nam);
|
str_copy(plug->device, nam);
|
||||||
ConcatDevice();
|
ConcatDevice();
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadCache(void) {
|
int LoadCache(void) {
|
||||||
@ -570,10 +574,10 @@ int LoadCache(void) {
|
|||||||
ERR_SI(fclose(fil));
|
ERR_SI(fclose(fil));
|
||||||
/* re-read cache */
|
/* re-read cache */
|
||||||
ERR_P(cache=str_read_file(nbuf));
|
ERR_P(cache=str_read_file(nbuf));
|
||||||
return(0);
|
return 0;
|
||||||
OnError:
|
OnError:
|
||||||
if (fil!=NULL) fclose(fil);
|
if (fil!=NULL) fclose(fil);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
float WeightedAverage(float tH, float tL, Testpoint *t) {
|
float WeightedAverage(float tH, float tL, Testpoint *t) {
|
||||||
@ -589,19 +593,19 @@ float WeightedAverage(float tH, float tL, Testpoint *t) {
|
|||||||
tLow=s1->lim;
|
tLow=s1->lim;
|
||||||
tHigh=s2->lim;
|
tHigh=s2->lim;
|
||||||
if (tL<=tLow) {
|
if (tL<=tLow) {
|
||||||
return(tL);
|
return tL;
|
||||||
} else if (tH<tHigh) {
|
} else if (tH<tHigh) {
|
||||||
p=tHigh-tH;
|
p=tHigh-tH;
|
||||||
q=tL-tLow;
|
q=tL-tLow;
|
||||||
if (p==0.0 && q==0.0) { p=1; q=1; } /* should not be the case */
|
if (p==0.0 && q==0.0) { p=1; q=1; } /* should not be the case */
|
||||||
return((tL*p*p+tH*q*q)/(p*p+q*q));
|
return (tL*p*p+tH*q*q)/(p*p+q*q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(tH);
|
return tH ;
|
||||||
} else if (tL!=0.0) {
|
} else if (tL!=0.0) {
|
||||||
return(tL);
|
return tL ;
|
||||||
}
|
}
|
||||||
return(0.0);
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogMinMax(int new) {
|
void LogMinMax(int new) {
|
||||||
@ -638,6 +642,10 @@ void LogMinMax(int new) {
|
|||||||
sprintf(buf1, " Tr %.5g", tr);
|
sprintf(buf1, " Tr %.5g", tr);
|
||||||
str_append(buf, buf1);
|
str_append(buf, buf1);
|
||||||
}
|
}
|
||||||
|
if (te!=DATA_UNDEF) {
|
||||||
|
sprintf(buf1, " Te %.5g", te);
|
||||||
|
str_append(buf, buf1);
|
||||||
|
}
|
||||||
if (power!=DATA_UNDEF) {
|
if (power!=DATA_UNDEF) {
|
||||||
sprintf(buf1, " P %.4g", power);
|
sprintf(buf1, " P %.4g", power);
|
||||||
str_append(buf, buf1);
|
str_append(buf, buf1);
|
||||||
@ -669,6 +677,42 @@ void LogMinMax(int new) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CtlScale(void) {
|
||||||
|
if (ctlSens==NULL) ctlSens=cryo.sensor1;
|
||||||
|
if (controlMode==1) {
|
||||||
|
tShift=0;
|
||||||
|
if (ctlSens==samp.sensor1) {
|
||||||
|
if (set < ctlSens->lim) {
|
||||||
|
ctlSens=samp.sensor2;
|
||||||
|
}
|
||||||
|
} else if (ctlSens==samp.sensor2) {
|
||||||
|
if (set > ctlSens->lim) {
|
||||||
|
ctlSens=samp.sensor1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ctlSens=samp.sensor1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (controlMode!=2) tShift=0;
|
||||||
|
if (ctlSens==cryo.sensor1) {
|
||||||
|
if (set < ctlSens->lim) {
|
||||||
|
ctlSens=cryo.sensor2;
|
||||||
|
}
|
||||||
|
} else if (ctlSens==cryo.sensor2) {
|
||||||
|
if (set > ctlSens->lim) {
|
||||||
|
ctlSens=cryo.sensor1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ctlSens=cryo.sensor1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ctlSens==NULL) {
|
||||||
|
return 1.0;
|
||||||
|
} else {
|
||||||
|
return ctlSens->scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int ReadTemp(void) {
|
int ReadTemp(void) {
|
||||||
char buf[256], typ, *err;
|
char buf[256], typ, *err;
|
||||||
int i, doit, stat;
|
int i, doit, stat;
|
||||||
@ -700,12 +744,13 @@ int ReadTemp(void) {
|
|||||||
if (doit) {
|
if (doit) {
|
||||||
if (ramp!=0) {
|
if (ramp!=0) {
|
||||||
str_append(buf, ";SETP?[loop]>tr");
|
str_append(buf, ";SETP?[loop]>tr");
|
||||||
|
tr=tr*CtlScale();
|
||||||
} else {
|
} else {
|
||||||
tr=set;
|
tr=set;
|
||||||
if (tr==0) tr=DATA_UNDEF;
|
|
||||||
}
|
}
|
||||||
str_append(buf, ";MNMXRST");
|
str_append(buf, ";MNMXRST");
|
||||||
ERR_P(LscCmd(ser, buf));
|
ERR_P(LscCmd(ser, buf));
|
||||||
|
if (tr==0) tr=DATA_UNDEF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for reading errors */
|
/* check for reading errors */
|
||||||
@ -738,7 +783,7 @@ int ReadTemp(void) {
|
|||||||
s->t=he;
|
s->t=he;
|
||||||
tfill = tim % (24*3600) / 60; /* min since midnight */
|
tfill = tim % (24*3600) / 60; /* min since midnight */
|
||||||
dfill = mycDate(tim) % 10000; /* fill date without year */
|
dfill = mycDate(tim) % 10000; /* fill date without year */
|
||||||
sprintf(helium, "%5.1f %% (%02d.%02d., %02d:%02d)", he
|
sprintf(helium, "%.3g %s (%02d.%02d., %02d:%02d)", he, heUnits
|
||||||
, dfill % 100, dfill / 100, tfill / 60, tfill % 60);
|
, dfill % 100, dfill / 100, tfill / 60, tfill % 60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -781,17 +826,25 @@ int ReadTemp(void) {
|
|||||||
if (samp.temp==0.0) {
|
if (samp.temp==0.0) {
|
||||||
samp.temp=cryo.temp;
|
samp.temp=cryo.temp;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tm=(rdTim % 3600) * 1.0e-4;
|
||||||
|
ts=(rdTim % 60) * 60.0e-4+0.5;
|
||||||
}
|
}
|
||||||
if (auxSens != NULL) {
|
if (auxSens != NULL) {
|
||||||
aux=auxSens->t * auxSens->scale;
|
aux=auxSens->t * auxSens->scale;
|
||||||
} else {
|
} else {
|
||||||
aux=DATA_UNDEF;
|
aux=DATA_UNDEF;
|
||||||
}
|
}
|
||||||
|
if (testSens != NULL) {
|
||||||
|
te=testSens->t * testSens->scale;
|
||||||
|
} else {
|
||||||
|
te=DATA_UNDEF;
|
||||||
|
}
|
||||||
if (heliumSens == NULL) {
|
if (heliumSens == NULL) {
|
||||||
he=DATA_UNDEF;
|
he=DATA_UNDEF;
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ReadHeater(void) {
|
int ReadHeater(void) {
|
||||||
@ -807,11 +860,12 @@ int ReadHeater(void) {
|
|||||||
power=htr*htr*maxPower*1e-4;
|
power=htr*htr*maxPower*1e-4;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetTemp(int switchOn) {
|
int SetTemp(int switchOn) {
|
||||||
int showSet;
|
int showSet;
|
||||||
|
float scale;
|
||||||
|
|
||||||
if (set<0 || set>tLimit) {
|
if (set<0 || set>tLimit) {
|
||||||
set=0;
|
set=0;
|
||||||
@ -821,7 +875,9 @@ int SetTemp(int switchOn) {
|
|||||||
ERR_I(ReadTemp());
|
ERR_I(ReadTemp());
|
||||||
LogMinMax(switchOn);
|
LogMinMax(switchOn);
|
||||||
}
|
}
|
||||||
if (cryo.sensor1==NULL) return(0);
|
if (cryo.sensor1==NULL) return 0;
|
||||||
|
scale=CtlScale();
|
||||||
|
|
||||||
if (ctlSens==NULL) ctlSens=cryo.sensor1;
|
if (ctlSens==NULL) ctlSens=cryo.sensor1;
|
||||||
if (controlMode==1) {
|
if (controlMode==1) {
|
||||||
tShift=0;
|
tShift=0;
|
||||||
@ -856,14 +912,25 @@ int SetTemp(int switchOn) {
|
|||||||
} else if (tShift<-maxShift) {
|
} else if (tShift<-maxShift) {
|
||||||
tShift=-maxShift;
|
tShift=-maxShift;
|
||||||
}
|
}
|
||||||
setH=(set+tShift)/ctlSens->scale;
|
setH=(set+tShift)/scale;
|
||||||
if (setH>tLimit) setH=tLimit;
|
if (setH>tLimit/scale) setH=tLimit/scale;
|
||||||
if (switchOn) { /* switch off other loop */
|
if (switchOn) {
|
||||||
|
/* switch off other loop */
|
||||||
if (loop==1) {
|
if (loop==1) {
|
||||||
ERR_P(LscCmd(ser, "CSET 2:[chan],1,0,0"));
|
ERR_P(LscCmd(ser, "CSET 2:[chan],1,0,0"));
|
||||||
} else {
|
} else {
|
||||||
ERR_P(LscCmd(ser, "CSET 1:[chan],1,0,0"));
|
ERR_P(LscCmd(ser, "CSET 1:[chan],1,0,0"));
|
||||||
}
|
}
|
||||||
|
if (ramp > 0 && set != 0) {
|
||||||
|
/* take ramp from actual temperature if more than 1 % deviation */
|
||||||
|
ERR_P(LscCmd(ser, "CSET?[loop]>,,cod1;SETP?[loop]>tr"));
|
||||||
|
tr=tr*scale;
|
||||||
|
if (cod1 == 0 || fabsf(ctlSens->t - tr) >= 0.01 * ctlSens->t) {
|
||||||
|
fbuf = ctlSens->t;
|
||||||
|
tr = fbuf * scale;
|
||||||
|
ERR_P(LscCmd(ser, "SETP [loop],[fbuf];RAMP [loop],0,0;SETP [loop],[fbuf]"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (set==0) {
|
if (set==0) {
|
||||||
ERR_P(LscCmd(ser, "CSET [loop]:[chan],1,1,0"));
|
ERR_P(LscCmd(ser, "CSET [loop]:[chan],1,1,0"));
|
||||||
@ -873,8 +940,6 @@ int SetTemp(int switchOn) {
|
|||||||
ERR_P(LscCmd(ser, "ANALOG 2:0,0"));
|
ERR_P(LscCmd(ser, "ANALOG 2:0,0"));
|
||||||
}
|
}
|
||||||
setH=0;
|
setH=0;
|
||||||
} else if (remoteMode==1) {
|
|
||||||
/* in local mode: do not switch on heater */
|
|
||||||
} else if (switchOn) { /* switch on also when bad heater message and no alarms: || (htrst>=5 && relay==0)) */
|
} else if (switchOn) { /* switch on also when bad heater message and no alarms: || (htrst>=5 && relay==0)) */
|
||||||
ERR_P(LscCmd(ser, "CSET [loop]:[chan],1,1,0"));
|
ERR_P(LscCmd(ser, "CSET [loop]:[chan],1,1,0"));
|
||||||
if (loop==1) {
|
if (loop==1) {
|
||||||
@ -886,8 +951,9 @@ int SetTemp(int switchOn) {
|
|||||||
ERR_P(LscCmd(ser, "CSET [loop]:[chan],1"));
|
ERR_P(LscCmd(ser, "CSET [loop]:[chan],1"));
|
||||||
}
|
}
|
||||||
showSet=(0!=strcmp(ctlSens->ch, controlChannel) || switchOn);
|
showSet=(0!=strcmp(ctlSens->ch, controlChannel) || switchOn);
|
||||||
if (ramp==0) {
|
str_copy(controlChannel, ctlSens->ch);
|
||||||
ERR_P(LscCmd(ser, "RAMP [loop],0,0;SETP?[loop]>fbuf"));
|
if (ramp==0 || set==0) {
|
||||||
|
ERR_P(LscCmd(ser, "RAMP [loop],0,[ramp];SETP?[loop]>fbuf"));
|
||||||
if (fabsf(setH-fbuf) >= (fbuf+setH)*1.0e-5) {
|
if (fabsf(setH-fbuf) >= (fbuf+setH)*1.0e-5) {
|
||||||
ERR_P(LscCmd(ser, "SETP [loop]:[setH]"));
|
ERR_P(LscCmd(ser, "SETP [loop]:[setH]"));
|
||||||
if (controlMode!=2 && !showSet) {
|
if (controlMode!=2 && !showSet) {
|
||||||
@ -896,23 +962,26 @@ int SetTemp(int switchOn) {
|
|||||||
} else {
|
} else {
|
||||||
setH=fbuf;
|
setH=fbuf;
|
||||||
}
|
}
|
||||||
|
tr=setH*scale;
|
||||||
|
if (showSet) {
|
||||||
|
logfileOut(LOG_MAIN, "set %g (on %s)\n", set, ctlSens->ch);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ramp < 0) ramp=-ramp;
|
if (ramp < 0) ramp=-ramp;
|
||||||
if (ramp < 0.1) ramp=0.1;
|
if (ramp < 0.1) ramp=0.1;
|
||||||
ERR_P(LscCmd(ser, "RAMP [loop]:1,[ramp];SETP [loop],[setH];SETP?[loop]>tr"));
|
ERR_P(LscCmd(ser, "RAMP [loop]:1,[ramp];SETP [loop],[setH];SETP?[loop]>tr"));
|
||||||
}
|
tr=tr*scale;
|
||||||
if (showSet) {
|
if (showSet) {
|
||||||
str_copy(controlChannel, ctlSens->ch);
|
logfileOut(LOG_MAIN, "set %g (on %s) %g K/min, starting from %g\n", set, ctlSens->ch, ramp, tr);
|
||||||
if (ramp==0) {
|
|
||||||
logfileOut(LOG_MAIN, "set %g (on %s)\n", set, ctlSens->ch);
|
|
||||||
} else {
|
|
||||||
logfileOut(LOG_MAIN, "set %g (on %s) %g K/min\n", set, ctlSens->ch, ramp);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (tr==0) tr=DATA_UNDEF;
|
||||||
|
if (showSet) {
|
||||||
relay=0;
|
relay=0;
|
||||||
ERR_I(ReadHeater());
|
ERR_I(ReadHeater());
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetMaxPower(void) {
|
int SetMaxPower(void) {
|
||||||
@ -943,13 +1012,14 @@ int SetMaxPower(void) {
|
|||||||
ERR_P(LscCmd(ser, "CDISP 1:[loop],[resist],1;MOUT [loop]:0;CMODE [loop]:1"));
|
ERR_P(LscCmd(ser, "CDISP 1:[loop],[resist],1;MOUT [loop]:0;CMODE [loop]:1"));
|
||||||
if (slope<0) slope=-slope;
|
if (slope<0) slope=-slope;
|
||||||
if (slope!=0 && slope<0.1) slope=0.1;
|
if (slope!=0 && slope<0.1) slope=0.1;
|
||||||
|
fbuf=tLimit/CtlScale();
|
||||||
if (loop==1) {
|
if (loop==1) {
|
||||||
ERR_P(LscCmd(ser, "CLIMIT 1:[tLimit],[slope],0,[iAmp],[iRange]"));
|
ERR_P(LscCmd(ser, "CLIMIT 1:[fbuf],[slope],0,[iAmp],[iRange]"));
|
||||||
} else {
|
} else {
|
||||||
ERR_P(LscCmd(ser, "CLIMIT 2:[tLimit],[slope],0"));
|
ERR_P(LscCmd(ser, "CLIMIT 2:[fbuf],[slope],0"));
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char DisplayFmt(SensorT *s) {
|
char DisplayFmt(SensorT *s) {
|
||||||
@ -966,19 +1036,21 @@ char DisplayFmt(SensorT *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Settings(void) {
|
int Settings(void) {
|
||||||
char nbuf[256], buf[256], typ;
|
char buf[256], typ;
|
||||||
char flds[6], fmt[6];
|
char flds[6], fmt[6];
|
||||||
|
char *cfg, *p;
|
||||||
int i,k,l;
|
int i,k,l;
|
||||||
SensorT *s;
|
SensorT *s;
|
||||||
|
|
||||||
remoteMode=2; /* set to remote mode */
|
remoteMode=2; /* set to remote mode */
|
||||||
ERR_P(LscCmd(ser, "MODE:[remoteMode]"));
|
ERR_P(LscCmd(ser, "MODE:[remoteMode]"));
|
||||||
ERR_P(LscCmd(ser, "PID?[loop]>prop,integ,deriv"));
|
ERR_P(LscCmd(ser, "PID?[loop]>prop,integ,deriv"));
|
||||||
|
ERR_P(LscCmd(ser, "RAMP?[loop]>,ramp"));
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
s=sensors[i];
|
s=sensors[i];
|
||||||
plug=plugs[i/2];
|
plug=plugs[i/2];
|
||||||
if (s->present < 0) {
|
if (s->present < 0) {
|
||||||
if (settingsFlag) return(0);
|
if (settingsFlag) return 0;
|
||||||
ERR_I(InstalCurve(s, plug->device));
|
ERR_I(InstalCurve(s, plug->device));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -989,6 +1061,7 @@ int Settings(void) {
|
|||||||
samp.sensor2=NULL;
|
samp.sensor2=NULL;
|
||||||
heliumSens=NULL;
|
heliumSens=NULL;
|
||||||
auxSens=NULL;
|
auxSens=NULL;
|
||||||
|
testSens=NULL;
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
s=sensors[i];
|
s=sensors[i];
|
||||||
if (s->present==1) {
|
if (s->present==1) {
|
||||||
@ -1009,6 +1082,8 @@ int Settings(void) {
|
|||||||
heliumSens=s;
|
heliumSens=s;
|
||||||
} else if ('x'==typ) {
|
} else if ('x'==typ) {
|
||||||
auxSens=s;
|
auxSens=s;
|
||||||
|
} else if ('t'==typ) {
|
||||||
|
testSens=s;
|
||||||
}
|
}
|
||||||
s->band=10;
|
s->band=10;
|
||||||
}
|
}
|
||||||
@ -1021,7 +1096,7 @@ int Settings(void) {
|
|||||||
samp.sensor2=cryo.sensor2;
|
samp.sensor2=cryo.sensor2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settingsFlag) return(0);
|
if (settingsFlag) return 0;
|
||||||
str_copy(statusBuf, "alarms");
|
str_copy(statusBuf, "alarms");
|
||||||
|
|
||||||
/* alarms */
|
/* alarms */
|
||||||
@ -1053,7 +1128,7 @@ int Settings(void) {
|
|||||||
if (NULL==strchr(alarmList, '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 */
|
||||||
|
|
||||||
if (settingsFlag) return(0);
|
if (settingsFlag) return 0;
|
||||||
str_copy(statusBuf, "display");
|
str_copy(statusBuf, "display");
|
||||||
|
|
||||||
/* display */
|
/* display */
|
||||||
@ -1064,11 +1139,13 @@ int Settings(void) {
|
|||||||
flds[k]=cryo.sensor1->ch[0];
|
flds[k]=cryo.sensor1->ch[0];
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
if (samp.sensor1 != cryo.sensor1) {
|
||||||
fmt[k]=DisplayFmt(samp.sensor1);
|
fmt[k]=DisplayFmt(samp.sensor1);
|
||||||
if (fmt[k]!='\0') {
|
if (fmt[k]!='\0') {
|
||||||
flds[k]=samp.sensor1->ch[0];
|
flds[k]=samp.sensor1->ch[0];
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (cryo.sensor2 != cryo.sensor1) {
|
if (cryo.sensor2 != cryo.sensor1) {
|
||||||
fmt[k]=DisplayFmt(cryo.sensor2);
|
fmt[k]=DisplayFmt(cryo.sensor2);
|
||||||
if (fmt[k]!='\0') {
|
if (fmt[k]!='\0') {
|
||||||
@ -1076,13 +1153,18 @@ int Settings(void) {
|
|||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (samp.sensor2 != samp.sensor1) {
|
if (samp.sensor2 != samp.sensor1 && samp.sensor2 != cryo.sensor2) {
|
||||||
fmt[k]=DisplayFmt(samp.sensor2);
|
fmt[k]=DisplayFmt(samp.sensor2);
|
||||||
if (fmt[k]!='\0') {
|
if (fmt[k]!='\0') {
|
||||||
flds[k]=samp.sensor2->ch[0];
|
flds[k]=samp.sensor2->ch[0];
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fmt[k]=DisplayFmt(testSens);
|
||||||
|
if (fmt[k]!='\0' && k<=4) {
|
||||||
|
flds[k]=testSens->ch[0];
|
||||||
|
k++;
|
||||||
|
}
|
||||||
fmt[k]=DisplayFmt(auxSens);
|
fmt[k]=DisplayFmt(auxSens);
|
||||||
if (fmt[k]!='\0' && k<=4) {
|
if (fmt[k]!='\0' && k<=4) {
|
||||||
flds[k]=auxSens->ch[0];
|
flds[k]=auxSens->ch[0];
|
||||||
@ -1104,8 +1186,22 @@ int Settings(void) {
|
|||||||
str_append(buf, "DISPLAY:[maxfld]");
|
str_append(buf, "DISPLAY:[maxfld]");
|
||||||
ERR_P(LscCmd(ser, buf));
|
ERR_P(LscCmd(ser, buf));
|
||||||
}
|
}
|
||||||
|
if (config[0] != '\0') {
|
||||||
|
str_copy(buf, binDir);
|
||||||
|
str_append(buf, config);
|
||||||
|
cfg=str_read_file(buf);
|
||||||
|
if (cfg != NULL) {
|
||||||
|
logfileOut(LOG_MAIN, "load %s\n", config);
|
||||||
|
p=cfg;
|
||||||
|
while (p!=NULL) {
|
||||||
|
str_split(buf, p, '\n');
|
||||||
|
ERR_P(LscCmd(ser, buf));
|
||||||
|
}
|
||||||
|
FREE(cfg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (settingsFlag) return(0);
|
if (settingsFlag) return 0;
|
||||||
str_copy(statusBuf, "reading temperatures");
|
str_copy(statusBuf, "reading temperatures");
|
||||||
|
|
||||||
if (cryo.sensor1!=NULL) {
|
if (cryo.sensor1!=NULL) {
|
||||||
@ -1113,10 +1209,10 @@ int Settings(void) {
|
|||||||
} else {
|
} else {
|
||||||
ERR_I(ReadTemp());
|
ERR_I(ReadTemp());
|
||||||
}
|
}
|
||||||
return(0);
|
|
||||||
logTime=(rdTim / logPeriod + 2) * logPeriod; /* wait before logging "dirty" temperatures */
|
logTime=(rdTim / logPeriod + 2) * logPeriod; /* wait before logging "dirty" temperatures */
|
||||||
|
return 0;
|
||||||
OnError:
|
OnError:
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConfigByCode(int plugNr) {
|
int ConfigByCode(int plugNr) {
|
||||||
@ -1136,8 +1232,8 @@ int ConfigByCode(int plugNr) {
|
|||||||
ERR_I(PrepInput(buf));
|
ERR_I(PrepInput(buf));
|
||||||
}
|
}
|
||||||
settingsFlag=1;
|
settingsFlag=1;
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConfigByName(int plugNr) {
|
int ConfigByName(int plugNr) {
|
||||||
@ -1153,11 +1249,11 @@ int ConfigByName(int plugNr) {
|
|||||||
ERR_I(PrepInput(buf));
|
ERR_I(PrepInput(buf));
|
||||||
}
|
}
|
||||||
settingsFlag=1;
|
settingsFlag=1;
|
||||||
return(0);
|
return 0;
|
||||||
OnError:
|
OnError:
|
||||||
plug->device[0]='\0';
|
plug->device[0]='\0';
|
||||||
ConcatDevice();
|
ConcatDevice();
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PeriodicTask(void) {
|
int PeriodicTask(void) {
|
||||||
@ -1174,11 +1270,11 @@ int PeriodicTask(void) {
|
|||||||
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 */
|
||||||
k=serialNo; /* check serial number */
|
k=serialNo; /* check serial number */
|
||||||
ERR_P(LscCmd(ser, "*IDN?>buf1,buf2,serialNo,"));
|
ERR_P(LscCmd(ser, "*IDN?>buf1,buf2,serialNo,"));
|
||||||
if (0!=strcmp(buf1, "LSCI") || 0!=strcmp(buf2, "MODEL340") || serialNo==0) return(0);
|
if (0!=strcmp(buf1, "LSCI") || 0!=strcmp(buf2, "MODEL340") || serialNo==0) return 0;
|
||||||
if (k!=serialNo) { /* controller exchanged or we are initializing */
|
if (k!=serialNo) { /* controller exchanged or we are initializing */
|
||||||
/*
|
if (k!=0) {
|
||||||
logfileOut(LOG_MAIN, "controller connected\n");
|
logfileOut(LOG_MAIN, "controller connected\n");
|
||||||
*/
|
}
|
||||||
set=0;
|
set=0;
|
||||||
|
|
||||||
/* reload curve cache: */
|
/* reload curve cache: */
|
||||||
@ -1200,16 +1296,17 @@ int PeriodicTask(void) {
|
|||||||
if (next!=NULL) {
|
if (next!=NULL) {
|
||||||
next=str_split(buf3, next, '/');
|
next=str_split(buf3, next, '/');
|
||||||
plug0.code=atoi(buf3);
|
plug0.code=atoi(buf3);
|
||||||
plug0.codChanged=plug0.code != 0;
|
plug0.codChanged=1;
|
||||||
if (next!=NULL) {
|
if (next!=NULL) {
|
||||||
next=str_split(buf3, next, '\n');
|
next=str_split(buf3, next, '\n');
|
||||||
plug1.code=atoi(buf3);
|
plug1.code=atoi(buf3);
|
||||||
plug1.codChanged=plug1.code != 0;
|
plug1.codChanged=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (buf1[0]=='*') {
|
if (buf1[0]=='*') {
|
||||||
str_copy(plug0.device, buf1+1);
|
str_copy(plug0.device, buf1+1);
|
||||||
|
plug0.codChanged=0;
|
||||||
ConfigByName(0);
|
ConfigByName(0);
|
||||||
} else {
|
} else {
|
||||||
if (plug0.code!=0) str_copy(plug0.device, buf1);
|
if (plug0.code!=0) str_copy(plug0.device, buf1);
|
||||||
@ -1217,6 +1314,7 @@ int PeriodicTask(void) {
|
|||||||
}
|
}
|
||||||
if (buf2[0]=='*') {
|
if (buf2[0]=='*') {
|
||||||
str_copy(plug1.device, buf2+1);
|
str_copy(plug1.device, buf2+1);
|
||||||
|
plug1.codChanged=0;
|
||||||
ConfigByName(1);
|
ConfigByName(1);
|
||||||
} else {
|
} else {
|
||||||
if (plug1.code!=0) str_copy(plug1.device, buf2);
|
if (plug1.code!=0) str_copy(plug1.device, buf2);
|
||||||
@ -1287,12 +1385,12 @@ int PeriodicTask(void) {
|
|||||||
htrst0=htrst;
|
htrst0=htrst;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tim>=logTime && cryo.sensor1!=NULL) {
|
if (rdTim>=logTime) {
|
||||||
ERR_I(DataPutAll(NULL, rdTim));
|
ERR_I(DataPutAll(NULL, rdTim));
|
||||||
logTime=(rdTim / logPeriod + 1) * logPeriod;
|
logTime=(rdTim / logPeriod + 1) * logPeriod;
|
||||||
if (tim>mmTime) LogMinMax(0);
|
if (rdTim>mmTime && cryo.sensor1 != NULL) LogMinMax(0);
|
||||||
}
|
}
|
||||||
if (set!=0) {
|
if (set!=0 && remoteMode==2) {
|
||||||
if (cryo.sensor1!=samp.sensor1 && controlMode==2) {
|
if (cryo.sensor1!=samp.sensor1 && controlMode==2) {
|
||||||
t=ctlSens->t;
|
t=ctlSens->t;
|
||||||
d=(setH-t)/t-1.0; /* relative difference */
|
d=(setH-t)/t-1.0; /* relative difference */
|
||||||
@ -1307,7 +1405,7 @@ int PeriodicTask(void) {
|
|||||||
}
|
}
|
||||||
tShift=tShift*(1.0-p)+p*(cryo.temp-samp.temp);
|
tShift=tShift*(1.0-p)+p*(cryo.temp-samp.temp);
|
||||||
ERR_I(SetTemp(0));
|
ERR_I(SetTemp(0));
|
||||||
} else if (remoteMode==2) {
|
} else {
|
||||||
ERR_I(SetTemp(0));
|
ERR_I(SetTemp(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1369,8 +1467,7 @@ int PeriodicTask(void) {
|
|||||||
ERR_P(LscCmd(ser, "RANGE?>iRange"));
|
ERR_P(LscCmd(ser, "RANGE?>iRange"));
|
||||||
if (iRange==0) set=0;
|
if (iRange==0) set=0;
|
||||||
} else {
|
} else {
|
||||||
ERR_P(LscCmd(ser, "RAMP?[loop]>fbuf,ramp"));
|
ERR_P(LscCmd(ser, "RAMP?[loop]>,ramp"));
|
||||||
if (fbuf==0.0) ramp=0.0;
|
|
||||||
ERR_P(LscCmd(ser, "RANGE?>iRange;CSET?[loop]>,cod1,;SETP?[loop]>set"));
|
ERR_P(LscCmd(ser, "RANGE?>iRange;CSET?[loop]>,cod1,;SETP?[loop]>set"));
|
||||||
if (cod1!=1) {
|
if (cod1!=1) {
|
||||||
set=0;
|
set=0;
|
||||||
@ -1389,8 +1486,8 @@ int PeriodicTask(void) {
|
|||||||
}
|
}
|
||||||
saveTime=0;
|
saveTime=0;
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DeviceHdl(int mode, void *base) {
|
int DeviceHdl(int mode, void *base) {
|
||||||
@ -1402,7 +1499,6 @@ int DeviceHdl(int mode, void *base) {
|
|||||||
t=strchr(device, '/');
|
t=strchr(device, '/');
|
||||||
if (t==NULL) {
|
if (t==NULL) {
|
||||||
if (0==strcmp(device, "0") || 0==strcasecmp(device, "auto")) {
|
if (0==strcmp(device, "0") || 0==strcasecmp(device, "auto")) {
|
||||||
settingsFlag=1;
|
|
||||||
ERR_I(ConfigByCode(0));
|
ERR_I(ConfigByCode(0));
|
||||||
ERR_I(ConfigByCode(1));
|
ERR_I(ConfigByCode(1));
|
||||||
} else {
|
} else {
|
||||||
@ -1430,48 +1526,54 @@ int DeviceHdl(int mode, void *base) {
|
|||||||
}
|
}
|
||||||
ConcatDevice();
|
ConcatDevice();
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetHdl(int mode, void *base) {
|
int SetHdl(int mode, void *base) {
|
||||||
if (mode==COC_WR) {
|
if (mode==COC_WR) {
|
||||||
if (set<0) {
|
if (remoteMode!=2) {
|
||||||
|
ERR_MSG("controller is in local mode, set to remote first");
|
||||||
|
} else if (set<0) {
|
||||||
set=0;
|
set=0;
|
||||||
} else if (set>tLimit) {
|
} else if (set>tLimit) {
|
||||||
set=0;
|
set=0;
|
||||||
ERR_MSG("set point too high");
|
ERR_MSG("set point too high");
|
||||||
}
|
}
|
||||||
return(COC_DWR);
|
return COC_DWR;
|
||||||
} else if (mode==COC_DWR) {
|
} else if (mode==COC_DWR) {
|
||||||
if (cryo.sensor1!=NULL) {
|
if (cryo.sensor1!=NULL && remoteMode==2) {
|
||||||
tInt=0; /* reset integral time */
|
tInt=0; /* reset integral time */
|
||||||
ERR_I(SetTemp(1));
|
ERR_I(SetTemp(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PidHdl(int mode, void *base) {
|
int PidHdl(int mode, void *base) {
|
||||||
if (mode==COC_WR) {
|
if (mode==COC_WR) {
|
||||||
return(COC_DWR);
|
return COC_DWR;
|
||||||
} else if (mode==COC_DWR) {
|
} else if (mode==COC_DWR) {
|
||||||
ERR_P(LscCmd(ser,"PID [loop]:[prop],[integ],[deriv]"));
|
ERR_P(LscCmd(ser,"PID [loop]:[prop],[integ],[deriv]"));
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MaxPowerHdl(int mode, void *base) {
|
int MaxPowerHdl(int mode, void *base) {
|
||||||
if (mode==COC_WR) {
|
if (mode==COC_WR) {
|
||||||
return(COC_DWR);
|
if (remoteMode==2) {
|
||||||
} else if (mode==COC_DWR) {
|
return COC_DWR;
|
||||||
|
}
|
||||||
|
ERR_MSG("controller is in local mode, set to remote first");
|
||||||
|
return 0;
|
||||||
|
} else if (mode==COC_DWR && remoteMode!=2) {
|
||||||
ERR_I(SetMaxPower());
|
ERR_I(SetMaxPower());
|
||||||
ERR_I(SetTemp(1));
|
ERR_I(SetTemp(1));
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SendHdl(int mode, void *base) {
|
int SendHdl(int mode, void *base) {
|
||||||
@ -1479,7 +1581,7 @@ int SendHdl(int mode, void *base) {
|
|||||||
ClientData *data;
|
ClientData *data;
|
||||||
|
|
||||||
if (mode==COC_WR) {
|
if (mode==COC_WR) {
|
||||||
return(COC_DRD);
|
return COC_DRD;
|
||||||
} else if (mode==COC_DRD) {
|
} else if (mode==COC_DRD) {
|
||||||
data=base;
|
data=base;
|
||||||
if (NULL!=strchr(data->cmd, '>') || NULL!=strchr(data->cmd, '['))
|
if (NULL!=strchr(data->cmd, '>') || NULL!=strchr(data->cmd, '['))
|
||||||
@ -1487,8 +1589,8 @@ int SendHdl(int mode, void *base) {
|
|||||||
ERR_P(res=LscCmd(ser, data->cmd));
|
ERR_P(res=LscCmd(ser, data->cmd));
|
||||||
str_copy(data->cmd, res);
|
str_copy(data->cmd, res);
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LogHdl(int mode, void *base) {
|
int LogHdl(int mode, void *base) {
|
||||||
@ -1502,8 +1604,8 @@ int LogHdl(int mode, void *base) {
|
|||||||
}
|
}
|
||||||
data->logpos=logfileGetLines(data->logpos, 25, data->logline, sizeof(data->logline));
|
data->logpos=logfileGetLines(data->logpos, 25, data->logline, sizeof(data->logline));
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PltHdl(int mode, void *base) {
|
int PltHdl(int mode, void *base) {
|
||||||
@ -1518,8 +1620,8 @@ int PltHdl(int mode, void *base) {
|
|||||||
str_copy(names, data->pltdata+l);
|
str_copy(names, data->pltdata+l);
|
||||||
ERR_I(l=DataGetCoded(names, startTime, endTime, step, 30, data->pltdata, sizeof(data->pltdata)));
|
ERR_I(l=DataGetCoded(names, startTime, endTime, step, 30, data->pltdata, sizeof(data->pltdata)));
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PutFloat(StrBuf *buf, int prec, float f) {
|
int PutFloat(StrBuf *buf, int prec, float f) {
|
||||||
@ -1527,17 +1629,17 @@ int PutFloat(StrBuf *buf, int prec, float f) {
|
|||||||
int l;
|
int l;
|
||||||
|
|
||||||
if (f == DATA_UNDEF) {
|
if (f == DATA_UNDEF) {
|
||||||
return(StrPut(buf, "NaN", StrNONE));
|
return StrPut(buf, "NaN", StrNONE);
|
||||||
} else {
|
} else {
|
||||||
sprintf(fmt, "%%.%dg", prec);
|
sprintf(fmt, "%%.%dg", prec);
|
||||||
sprintf(num, fmt, f);
|
sprintf(num, fmt, f);
|
||||||
return(StrPut(buf, num, StrNONE));
|
return StrPut(buf, num, StrNONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ShowSensor(StrBuf *buf, SensorT *s, char *name, char *units, char lim) {
|
int ShowSensor(StrBuf *buf, SensorT *s, char *name, char *units, char lim) {
|
||||||
|
|
||||||
if (s->present!=1) return(0);
|
if (s->present!=1) return 0;
|
||||||
ERR_I(StrPut(buf, "\n ", ' '));
|
ERR_I(StrPut(buf, "\n ", ' '));
|
||||||
ERR_I(StrPut(buf, s->ch, ':'));
|
ERR_I(StrPut(buf, s->ch, ':'));
|
||||||
ERR_I(StrPut(buf, "", ' '));
|
ERR_I(StrPut(buf, "", ' '));
|
||||||
@ -1547,6 +1649,7 @@ int ShowSensor(StrBuf *buf, SensorT *s, char *name, char *units, char lim) {
|
|||||||
} else {
|
} else {
|
||||||
ERR_I(StrPut(buf, name, '='));
|
ERR_I(StrPut(buf, name, '='));
|
||||||
ERR_I(PutFloat(buf, 5, s->t * s->scale));
|
ERR_I(PutFloat(buf, 5, s->t * s->scale));
|
||||||
|
ERR_I(StrPut(buf, " ", StrNONE));
|
||||||
ERR_I(StrPut(buf, units, StrNONE));
|
ERR_I(StrPut(buf, units, StrNONE));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1555,14 +1658,15 @@ int ShowSensor(StrBuf *buf, SensorT *s, char *name, char *units, char lim) {
|
|||||||
if (s==ctlSens && tr!=DATA_UNDEF) {
|
if (s==ctlSens && tr!=DATA_UNDEF) {
|
||||||
ERR_I(StrPut(buf, ", setpoint", '='));
|
ERR_I(StrPut(buf, ", setpoint", '='));
|
||||||
ERR_I(PutFloat(buf, 5, tr));
|
ERR_I(PutFloat(buf, 5, tr));
|
||||||
|
ERR_I(StrPut(buf, " ", StrNONE));
|
||||||
ERR_I(StrPut(buf, units, StrNONE));
|
ERR_I(StrPut(buf, units, StrNONE));
|
||||||
}
|
}
|
||||||
if (s->lim > 0 && lim!=0) {
|
if (s->lim > 0 && lim!=0) {
|
||||||
ERR_I(StrPut(buf, ", for T", lim));
|
ERR_I(StrPut(buf, ", for T", lim));
|
||||||
ERR_I(PutFloat(buf, 5, s->lim));
|
ERR_I(PutFloat(buf, 5, s->lim));
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
OnError: return(-1);
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StatusHdl(int mode, void *base) {
|
int StatusHdl(int mode, void *base) {
|
||||||
@ -1572,8 +1676,14 @@ int StatusHdl(int mode, void *base) {
|
|||||||
SensorT *s;
|
SensorT *s;
|
||||||
char pendAct[256];
|
char pendAct[256];
|
||||||
|
|
||||||
|
readTemp=1;
|
||||||
StrLink(&buf, status);
|
StrLink(&buf, status);
|
||||||
StrClear(&buf);
|
StrClear(&buf);
|
||||||
|
ERR_I(StrPut(&buf, "\n", StrNONE));
|
||||||
|
if (noResp==3) {
|
||||||
|
ERR_I(StrPut(&buf, "no connection or controller switched off", StrNONE));
|
||||||
|
goto EndStatus;
|
||||||
|
}
|
||||||
if (statusBuf[0]!='\0') {
|
if (statusBuf[0]!='\0') {
|
||||||
ERR_I(StrPut(&buf, "configuring:", ' '));
|
ERR_I(StrPut(&buf, "configuring:", ' '));
|
||||||
ERR_I(StrPut(&buf, statusBuf, StrNONE));
|
ERR_I(StrPut(&buf, statusBuf, StrNONE));
|
||||||
@ -1582,23 +1692,24 @@ int StatusHdl(int mode, void *base) {
|
|||||||
CocShowHandlers(pendAct, sizeof(pendAct));
|
CocShowHandlers(pendAct, sizeof(pendAct));
|
||||||
if (pendAct[0]!='\0') {
|
if (pendAct[0]!='\0') {
|
||||||
if (mode==COC_RD) {
|
if (mode==COC_RD) {
|
||||||
return (COC_DRD);
|
return COC_DRD;
|
||||||
} else {
|
} else {
|
||||||
ERR_I(StrPut(&buf, "pending action(s):", ' '));
|
ERR_I(StrPut(&buf, "pending action(s):", ' '));
|
||||||
ERR_I(StrPut(&buf, pendAct, StrNONE));
|
ERR_I(StrPut(&buf, pendAct, StrNONE));
|
||||||
goto EndStatus;
|
goto EndStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (noResp==3) {
|
if (device[0]=='\0') {
|
||||||
ERR_I(StrPut(&buf, "\nno connection or controller switched off", StrNONE));
|
ERR_I(StrPut(&buf, "no device selected", ' '));
|
||||||
goto EndStatus;
|
goto EndStatus;
|
||||||
}
|
}
|
||||||
if (device[0]!='\0') {
|
if (remoteMode==1) {
|
||||||
ERR_I(StrPut(&buf, "\ndevice:", ' '));
|
ERR_I(StrPut(&buf, "LOCAL mode, use command 'remote' to enable remote control", '\n'));
|
||||||
ERR_I(StrPut(&buf, device, StrNONE));
|
|
||||||
}
|
}
|
||||||
|
ERR_I(StrPut(&buf, "device:", ' '));
|
||||||
|
ERR_I(StrPut(&buf, device, StrNONE));
|
||||||
if (set==0) {
|
if (set==0) {
|
||||||
ERR_I(StrPut(&buf, "\ntemperature control is off", StrNONE));
|
ERR_I(StrPut(&buf, "\nheater off (set=0)", StrNONE));
|
||||||
} else {
|
} else {
|
||||||
ERR_I(StrPut(&buf, "\ntarget", '='));
|
ERR_I(StrPut(&buf, "\ntarget", '='));
|
||||||
ERR_I(PutFloat(&buf, 5, set));
|
ERR_I(PutFloat(&buf, 5, set));
|
||||||
@ -1615,8 +1726,9 @@ int StatusHdl(int mode, void *base) {
|
|||||||
ERR_I(StrPut(&buf, ",", ' '));
|
ERR_I(StrPut(&buf, ",", ' '));
|
||||||
ERR_I(StrPut(&buf, LscHtrStat(htrst), StrNONE));
|
ERR_I(StrPut(&buf, LscHtrStat(htrst), StrNONE));
|
||||||
} else {
|
} else {
|
||||||
|
if (power!=DATA_UNDEF) {
|
||||||
ERR_I(StrPut(&buf, ", htr power", '='));
|
ERR_I(StrPut(&buf, ", htr power", '='));
|
||||||
if (power>=0.5 || power==DATA_UNDEF) {
|
if (power>=0.5) {
|
||||||
ERR_I(PutFloat(&buf, 3, power));
|
ERR_I(PutFloat(&buf, 3, power));
|
||||||
ERR_I(StrPut(&buf, " W, htr current", '='));
|
ERR_I(StrPut(&buf, " W, htr current", '='));
|
||||||
} else {
|
} else {
|
||||||
@ -1627,6 +1739,7 @@ int StatusHdl(int mode, void *base) {
|
|||||||
ERR_I(StrPut(&buf, " ", '%'));
|
ERR_I(StrPut(&buf, " ", '%'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (0!=strcmp(alarmChannels," ")) {
|
if (0!=strcmp(alarmChannels," ")) {
|
||||||
ERR_I(StrPut(&buf, "\nalarm on channel",' '));
|
ERR_I(StrPut(&buf, "\nalarm on channel",' '));
|
||||||
ERR_I(StrPut(&buf, alarmChannels, StrNONE));
|
ERR_I(StrPut(&buf, alarmChannels, StrNONE));
|
||||||
@ -1652,19 +1765,33 @@ int StatusHdl(int mode, void *base) {
|
|||||||
}
|
}
|
||||||
ERR_I(ShowSensor(&buf, samp.sensor2, "T", "K", '<'));
|
ERR_I(ShowSensor(&buf, samp.sensor2, "T", "K", '<'));
|
||||||
}
|
}
|
||||||
if (heliumSens!=NULL) {
|
if (testSens!=NULL) {
|
||||||
ERR_I(StrPut(&buf, "\nhelium", ':'));
|
ERR_I(StrPut(&buf, "\ntest", ':'));
|
||||||
ERR_I(ShowSensor(&buf, heliumSens, "level", " %", 0));
|
ERR_I(ShowSensor(&buf, testSens, "T", "K", 0));
|
||||||
}
|
}
|
||||||
if (auxSens!=NULL) {
|
if (auxSens!=NULL) {
|
||||||
ERR_I(StrPut(&buf, "\nauxilliary", ':'));
|
ERR_I(StrPut(&buf, "\nauxilliary", ':'));
|
||||||
ERR_I(ShowSensor(&buf, auxSens, "U", "V", 0));
|
ERR_I(ShowSensor(&buf, auxSens, "U", "V", 0));
|
||||||
}
|
}
|
||||||
|
if (heliumSens!=NULL) {
|
||||||
|
ERR_I(StrPut(&buf, "\nhelium:", ' '));
|
||||||
|
ERR_I(StrPut(&buf, helium, StrNONE));
|
||||||
|
}
|
||||||
EndStatus:
|
EndStatus:
|
||||||
ERR_I(StrPut(&buf, "", '\0'));
|
ERR_I(StrPut(&buf, "", '\0'));
|
||||||
return(0);
|
return 0;
|
||||||
OnError:
|
OnError:
|
||||||
return(-1);
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int RemoteHdl(int mode, void *base) {
|
||||||
|
if (mode==COC_WR) {
|
||||||
|
return COC_DRD;
|
||||||
|
} else if (mode==COC_DRD) {
|
||||||
|
ERR_P(LscCmd(ser, "MODE:[remoteMode]"));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ExecuteRequest(void) {
|
int ExecuteRequest(void) {
|
||||||
@ -1676,9 +1803,9 @@ int ExecuteRequest(void) {
|
|||||||
ERR_I(Settings());
|
ERR_I(Settings());
|
||||||
}
|
}
|
||||||
statusBuf[0]='\0';
|
statusBuf[0]='\0';
|
||||||
return(0);
|
return 0;
|
||||||
OnError:
|
OnError:
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MainBody(void) {
|
int MainBody(void) {
|
||||||
@ -1700,7 +1827,7 @@ int MainBody(void) {
|
|||||||
logfileWrite(logMask);
|
logfileWrite(logMask);
|
||||||
}
|
}
|
||||||
tdif = mycMsecSince(tim0);
|
tdif = mycMsecSince(tim0);
|
||||||
if (tdif>60000) {
|
if (tdif>60000 && cntError < 2) {
|
||||||
logfileOut(LOG_MAIN ,"%d seconds lost\n", tdif/1000);
|
logfileOut(LOG_MAIN ,"%d seconds lost\n", tdif/1000);
|
||||||
}
|
}
|
||||||
tim0 = mycMsecSince(0)/period*period;
|
tim0 = mycMsecSince(0)/period*period;
|
||||||
@ -1710,28 +1837,28 @@ int MainBody(void) {
|
|||||||
ERR_I(ExecuteRequest());
|
ERR_I(ExecuteRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
OnError:
|
OnError:
|
||||||
if (0==strcmp(ErrMessage, "timeout")) {
|
if (0==strcmp(ErrMessage, "timeout")) {
|
||||||
if (noResp==1) { /* this is the second time we have no response */
|
if (noResp==2) { /* this is the second time we have no response */
|
||||||
per=period+15000; /* long period if no response */
|
per=1000; /* 1 sec */
|
||||||
cryo.temp=0;
|
cryo.temp=0;
|
||||||
samp.temp=0;
|
samp.temp=0;
|
||||||
remoteMode=1;
|
remoteMode=1;
|
||||||
noResp=3;
|
noResp=3;
|
||||||
} else {
|
} else if (noResp < 2) {
|
||||||
logfileOut(LOG_ALL ,"no response\n");
|
logfileOut(LOG_ALL ,"no response\n");
|
||||||
noResp=1;
|
noResp=2;
|
||||||
per=100; /* try again soon */
|
per=100; /* try again soon */
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) {
|
||||||
{ int logIt=0;
|
int logIt=0;
|
||||||
int i, iret, cntError, use_stdout=0;
|
int i, iret, use_stdout=0;
|
||||||
char *host;
|
char *host;
|
||||||
char buf[256], opt;
|
char buf[256], opt;
|
||||||
int port, msecTmo;
|
int port, msecTmo;
|
||||||
@ -1787,7 +1914,7 @@ int main(int argc, char *argv[])
|
|||||||
logfileOut(LOG_MAIN ,"%s ", argv[i]);
|
logfileOut(LOG_MAIN ,"%s ", argv[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (port==0) port=9757;
|
if (port==0) port=9753;
|
||||||
if (msecTmo==0) msecTmo=5000;
|
if (msecTmo==0) msecTmo=5000;
|
||||||
if (logPeriod==0) logPeriod=5;
|
if (logPeriod==0) logPeriod=5;
|
||||||
|
|
||||||
@ -1847,6 +1974,7 @@ int main(int argc, char *argv[])
|
|||||||
CocDefFlt(tm, RD);
|
CocDefFlt(tm, RD);
|
||||||
CocDefFlt(ts, RD);
|
CocDefFlt(ts, RD);
|
||||||
CocDefFlt(tr, RD);
|
CocDefFlt(tr, RD);
|
||||||
|
CocDefFlt(te, RD);
|
||||||
CocDefFlt(aux, RD);
|
CocDefFlt(aux, RD);
|
||||||
CocDefFlt(he, RD);
|
CocDefFlt(he, RD);
|
||||||
CocDefFlt(fbuf, RD);
|
CocDefFlt(fbuf, RD);
|
||||||
@ -1872,9 +2000,11 @@ int main(int argc, char *argv[])
|
|||||||
CocDefStr(head, RD);
|
CocDefStr(head, RD);
|
||||||
CocDefStr(chan, RD);
|
CocDefStr(chan, RD);
|
||||||
CocDefStr(helium, RD);
|
CocDefStr(helium, RD);
|
||||||
|
CocDefStr(heUnits, RD);
|
||||||
CocDefStr(intype, RD);
|
CocDefStr(intype, RD);
|
||||||
CocDefStr(status, RD); CocHdl(StatusHdl);
|
CocDefStr(status, RD); CocHdl(StatusHdl);
|
||||||
CocDefStr(logfile, RD);
|
CocDefStr(logfile, RD);
|
||||||
|
CocDefStr(config, RD);
|
||||||
|
|
||||||
CocDefInt(cod1, RD);
|
CocDefInt(cod1, RD);
|
||||||
CocDefInt(cod2, RD);
|
CocDefInt(cod2, RD);
|
||||||
@ -1886,7 +2016,7 @@ int main(int argc, char *argv[])
|
|||||||
CocDefInt(resist, RD);
|
CocDefInt(resist, RD);
|
||||||
CocDefInt(iAmp, RD);
|
CocDefInt(iAmp, RD);
|
||||||
CocDefInt(iRange, RD);
|
CocDefInt(iRange, RD);
|
||||||
CocDefInt(remoteMode, RD);
|
CocDefInt(remoteMode, RW); CocHdl(RemoteHdl);
|
||||||
CocDefInt(htrst, RD);
|
CocDefInt(htrst, RD);
|
||||||
CocDefInt(loop, RD);
|
CocDefInt(loop, RD);
|
||||||
CocDefInt(rdTim, RD);
|
CocDefInt(rdTim, RD);
|
||||||
@ -1922,6 +2052,7 @@ int main(int argc, char *argv[])
|
|||||||
ERR_P(DataCreateSet(NULL, "Tm", &tm, 5, LOGLIFETIME, tim));
|
ERR_P(DataCreateSet(NULL, "Tm", &tm, 5, LOGLIFETIME, tim));
|
||||||
ERR_P(DataCreateSet(NULL, "Ts", &ts, 5, LOGLIFETIME, tim));
|
ERR_P(DataCreateSet(NULL, "Ts", &ts, 5, LOGLIFETIME, tim));
|
||||||
ERR_P(DataCreateSet(NULL, "Tr", &tr, 5, LOGLIFETIME, tim));
|
ERR_P(DataCreateSet(NULL, "Tr", &tr, 5, LOGLIFETIME, tim));
|
||||||
|
ERR_P(DataCreateSet(NULL, "Te", &te, 5, LOGLIFETIME, tim));
|
||||||
ERR_P(DataCreateSet(NULL, "He", &he, 5, LOGLIFETIME, tim));
|
ERR_P(DataCreateSet(NULL, "He", &he, 5, LOGLIFETIME, tim));
|
||||||
ERR_P(DataCreateSet(NULL, "Aux", &aux, 5, LOGLIFETIME, tim));
|
ERR_P(DataCreateSet(NULL, "Aux", &aux, 5, LOGLIFETIME, tim));
|
||||||
ERR_P(DataCreateSet(NULL, "P", &power, 5, LOGLIFETIME, tim));
|
ERR_P(DataCreateSet(NULL, "P", &power, 5, LOGLIFETIME, tim));
|
||||||
@ -1973,13 +2104,16 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
LogMinMax(0);
|
LogMinMax(0);
|
||||||
logfileWrite(logMask);
|
logfileWrite(logMask);
|
||||||
ERR_MSG("got quit command");
|
if (quit==1) {
|
||||||
|
ERR_MSG("restart by quit command");
|
||||||
|
} else {
|
||||||
|
ERR_MSG("killed by quit command");
|
||||||
|
}
|
||||||
OnError:
|
OnError:
|
||||||
printf("TecsServer exited: %s\n", ErrMessage);
|
printf("TecsServer exited: %s\n", ErrMessage);
|
||||||
logfileShowErr("exit TecsServer");
|
logfileShowErr("exit TecsServer");
|
||||||
if (ser!=NULL) SerClose(ser);
|
if (ser!=NULL) SerClose(ser);
|
||||||
CocCloseServer();
|
CocCloseServer();
|
||||||
logfileClose();
|
logfileClose();
|
||||||
if (quit) return 0;
|
return quit;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
#include "tecs_data.h"
|
#include "tecs_data.h"
|
||||||
|
|
||||||
static char response[COC_RES_LEN];
|
static char response[COC_RES_LEN];
|
||||||
|
static char *rwCode="rwacs";
|
||||||
|
static char *rdCode="rdacs";
|
||||||
|
|
||||||
pTecsClient TeccInit(char *startcmd, int port) {
|
pTecsClient TeccInit(char *startcmd, int port) {
|
||||||
CocConn *conn;
|
CocConn *conn;
|
||||||
static char *rwCode="rwacs";
|
|
||||||
static char *rdCode="rdacs";
|
|
||||||
|
|
||||||
NEW(conn, CocConn);
|
NEW(conn, CocConn);
|
||||||
if (startcmd[0]=='#') {
|
if (startcmd[0]=='#') {
|
||||||
@ -64,22 +64,23 @@ int TeccSet(pTecsClient conn, float temp) {
|
|||||||
OnError: return(-1);
|
OnError: return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TeccQuitServer(pTecsClient conn) {
|
int TeccQuitServer(pTecsClient conn, int kill) {
|
||||||
int iret, cnt;
|
int iret, cnt;
|
||||||
|
|
||||||
ERR_I(iret=CocCheck(conn));
|
ERR_I(iret=CocCheck(conn));
|
||||||
if (iret==0) {
|
if (iret>0) return iret;
|
||||||
CocReset(conn);
|
CocReset(conn);
|
||||||
ERR_I(CocPutInt(conn, "quit", 1));
|
ERR_I(CocPutInt(conn, "quit", 1+kill));
|
||||||
ERR_I(CocDoIt(conn, response, sizeof(response)));
|
ERR_I(iret=CocDoIt(conn, response, sizeof(response)));
|
||||||
|
if (iret) ERR_MSG(response);
|
||||||
cnt=50;
|
cnt=50;
|
||||||
while (iret==0 && cnt>0) {
|
while (iret==0 && cnt>0) {
|
||||||
CocDelay(100);
|
CocDelay(100);
|
||||||
ERR_I(iret=CocCheck(conn));
|
ERR_I(iret=CocCheck(conn));
|
||||||
cnt--;
|
cnt--;
|
||||||
}
|
}
|
||||||
}
|
if (iret==0) ERR_MSG("Does not quit within 5 seconds");
|
||||||
ERR_MSG("Does not quit within 5 seconds");
|
return 0;
|
||||||
OnError:
|
OnError:
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -121,6 +122,7 @@ void TeccClose(pTecsClient conn) {
|
|||||||
#define tecs_get_data_ tecs_get_data
|
#define tecs_get_data_ tecs_get_data
|
||||||
#define tecs_date_ tecs_date
|
#define tecs_date_ tecs_date
|
||||||
#define tecs_time_ tecs_time
|
#define tecs_time_ tecs_time
|
||||||
|
#define tecs_rights_ tecs_rights
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static pTecsClient conn=NULL;
|
static pTecsClient conn=NULL;
|
||||||
@ -200,6 +202,16 @@ int tecs_init_(F_CHAR(startcmd), int *port, int startcmd_len) {
|
|||||||
OnError: return(-1);
|
OnError: return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tecs_rights_(int write) {
|
||||||
|
if (write) {
|
||||||
|
ERR_I(CocSendMagic(conn, rwCode));
|
||||||
|
} else {
|
||||||
|
ERR_I(CocSendMagic(conn, rdCode));
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
OnError: return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
int tecs_get_(float *temp) {
|
int tecs_get_(float *temp) {
|
||||||
ERR_I(TeccGet(conn, temp));
|
ERR_I(TeccGet(conn, temp));
|
||||||
return(0);
|
return(0);
|
||||||
@ -227,9 +239,11 @@ void tecs_close_(void) {
|
|||||||
conn=NULL;
|
conn=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tecs_quit_server_(void) {
|
int tecs_quit_server_(int *kill) {
|
||||||
ERR_I(TeccQuitServer(conn));
|
int iret;
|
||||||
return(0);
|
|
||||||
|
ERR_I(iret=TeccQuitServer(conn, *kill));
|
||||||
|
return(iret);
|
||||||
OnError: return(-1);
|
OnError: return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +288,11 @@ int DataDecode(float *data, int dataSize, char *coded, int *retSize) {
|
|||||||
dig1=decode[ch];
|
dig1=decode[ch];
|
||||||
if (dig1 < 0) { /* code is no 64-digit */
|
if (dig1 < 0) { /* code is no 64-digit */
|
||||||
if (ch=='\0' || ch==',') break;
|
if (ch=='\0' || ch==',') break;
|
||||||
if (ch=='/') { data[i++] = DATA_UNDEF; }
|
if (ch=='/') {
|
||||||
|
data[i++] = DATA_UNDEF;
|
||||||
|
} else if (ch=='.') {
|
||||||
|
data[i++] = DATA_GAP;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ch=coded[p++];
|
ch=coded[p++];
|
||||||
dig2=decode[ch];
|
dig2=decode[ch];
|
||||||
@ -304,13 +322,15 @@ int DataDecode(float *data, int dataSize, char *coded, int *retSize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int tecs_get_data_(F_CHAR(names), int *startTime, int *endTime, int *step, float data[], int *maxLen, int *width
|
int tecs_get_data_(F_CHAR(names), int *startTime, int *endTime, int *step, int *tbase
|
||||||
|
, float xdata[], float ydata[], int *maxLen, int *width
|
||||||
, int retLen[], int names_len) {
|
, int retLen[], int names_len) {
|
||||||
char nam[64];
|
char nam[64];
|
||||||
char str[128];
|
char str[128];
|
||||||
char res[COC_RES_LEN];
|
char res[COC_RES_LEN];
|
||||||
char *cod;
|
char *cod;
|
||||||
int i, l, iret, retSize;
|
float offset, fact, *py;
|
||||||
|
int i, j, k, l, iret, retSize;
|
||||||
|
|
||||||
if (*endTime - *startTime > *step * (*maxLen-1)) {
|
if (*endTime - *startTime > *step * (*maxLen-1)) {
|
||||||
printf("maxLen too small\n");
|
printf("maxLen too small\n");
|
||||||
@ -328,7 +348,21 @@ int tecs_get_data_(F_CHAR(names), int *startTime, int *endTime, int *step, float
|
|||||||
if (iret) ERR_MSG(response);
|
if (iret) ERR_MSG(response);
|
||||||
cod=res;
|
cod=res;
|
||||||
for (i=0; i < *width; i++) {
|
for (i=0; i < *width; i++) {
|
||||||
ERR_I(l=DataDecode(data + i * *maxLen, *maxLen, cod, retLen+i));
|
py = ydata + i * *maxLen;
|
||||||
|
ERR_I(l=DataDecode(py, *maxLen, cod, retLen+i));
|
||||||
|
if (retLen[i]>0) {
|
||||||
|
fact = (float)(*endTime - *startTime) / retLen[i];
|
||||||
|
}
|
||||||
|
offset = *startTime - *tbase;
|
||||||
|
k = i * *maxLen;
|
||||||
|
for (j=0; j<retLen[i]; j++) {
|
||||||
|
if (py[j] != DATA_GAP) {
|
||||||
|
ydata[k] = py[j];
|
||||||
|
xdata[k] = offset + j * fact;
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
retLen[i] = k - i * *maxLen;
|
||||||
cod+=l;
|
cod+=l;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -27,8 +27,8 @@ int TeccSend(pTecsClient conn, char *cmd, char *reply, int replyLen);
|
|||||||
void TeccClose(pTecsClient conn);
|
void TeccClose(pTecsClient conn);
|
||||||
/* close connection and free ressources */
|
/* close connection and free ressources */
|
||||||
|
|
||||||
int TeccQuitServer(pTecsClient conn);
|
int TeccQuitServer(pTecsClient conn, int kill);
|
||||||
/* quit the server process */
|
/* quit the server process, kill = 0: restart if possible */
|
||||||
|
|
||||||
/* Fortran interface:
|
/* Fortran interface:
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
real temp
|
real temp
|
||||||
character device*32, init*80, line*80, cmd*16, par*80, response*1024
|
character device*32, init*80, line*80, cmd*16, par*80, response*1024
|
||||||
|
character inst*64, host*64, user*1, pcod*1
|
||||||
integer i,j,k,iret,l
|
integer i,j,k,iret,l
|
||||||
character cmdpar*128
|
character cmdpar*128
|
||||||
character prompt*32/'tecs>'/
|
character prompt*32/'tecs>'/
|
||||||
@ -12,20 +13,38 @@
|
|||||||
|
|
||||||
! functions
|
! functions
|
||||||
integer tecs_get_par, tecs_quit_server, tecs_set_par, tecs_watch_log
|
integer tecs_get_par, tecs_quit_server, tecs_set_par, tecs_watch_log
|
||||||
integer tecs_get, show_log
|
integer tecs_get, tecs_rights, show_log, instr_host
|
||||||
|
|
||||||
|
call sys_load_env('cho')
|
||||||
|
call sys_getenv('CHOOSER_GDEV', line)
|
||||||
|
if (line .ne. ' ') then
|
||||||
|
call sys_setenv('PGPLOT_DEV', '/'//line)
|
||||||
|
endif
|
||||||
|
|
||||||
call sys_getenv('TECS_INIT', init)
|
call sys_getenv('TECS_INIT', init)
|
||||||
|
|
||||||
call sys_get_cmdpar(line, l)
|
call sys_get_cmdpar(line, l)
|
||||||
|
|
||||||
if (l .ne. 0) then
|
if (l .ne. 0) then
|
||||||
|
if (line(1:l) .eq. 'off' .or. line(1:l) .eq. 'OFF') then
|
||||||
|
call tecs_open(0, ' ', iret)
|
||||||
|
if (iret .lt. 0) goto 91
|
||||||
|
iret=tecs_quit_server()
|
||||||
|
if (iret .lt. 0) goto 91
|
||||||
|
goto 99
|
||||||
|
endif
|
||||||
oneCommand=.true.
|
oneCommand=.true.
|
||||||
|
i=instr_host(line, inst, host, user, pcod)
|
||||||
else
|
else
|
||||||
oneCommand=.false.
|
oneCommand=.false.
|
||||||
|
i=0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (oneCommand .and. line(1:1) .eq. '#') then
|
if (i .ne. 0) then
|
||||||
call tecs_open(0, line, iret)
|
call tecs_open(0, '#'//host, iret)
|
||||||
oneCommand=.false.
|
oneCommand=.false.
|
||||||
|
prompt='tecs/'//inst(1:i)//'> '
|
||||||
|
promptlen=i+7
|
||||||
else if (init .eq. ' ') then
|
else if (init .eq. ' ') then
|
||||||
call tecs_open(0, line, iret)
|
call tecs_open(0, line, iret)
|
||||||
else
|
else
|
||||||
@ -48,8 +67,10 @@
|
|||||||
print *,'plot <var> chart for temperature and <var>'
|
print *,'plot <var> chart for temperature and <var>'
|
||||||
1 ,' var = P (default), He, Aux'
|
1 ,' var = P (default), He, Aux'
|
||||||
print *,'log <n> show last n lines of logfile'
|
print *,'log <n> show last n lines of logfile'
|
||||||
print *,'kill close TecsServer and exit'
|
print *,'remote set to remote mode'
|
||||||
print *,'exit,quit exit, but do not close TecsServer'
|
print *,'kill shut down TecsServer'
|
||||||
|
print *,'restart restart TecsServer'
|
||||||
|
print *,'exit,quit exit tecs client'
|
||||||
print *,'help show list of parameters and cryo devices'
|
print *,'help show list of parameters and cryo devices'
|
||||||
print *
|
print *
|
||||||
|
|
||||||
@ -93,20 +114,31 @@
|
|||||||
|
|
||||||
defcmd='status'
|
defcmd='status'
|
||||||
|
|
||||||
if (cmd(1:1) .eq. '#') then
|
i=instr_host(line, inst, host, user, pcod)
|
||||||
|
if (i .ne. 0) then
|
||||||
call tecs_close
|
call tecs_close
|
||||||
call tecs_open(0, cmd, iret)
|
call tecs_open(0, '#'//host, iret)
|
||||||
if (iret .lt. 0) goto 91
|
if (iret .lt. 0) goto 91
|
||||||
prompt='tecs/'//cmd(2:)
|
prompt='tecs/'//inst(1:i)//'> '
|
||||||
promptlen=1
|
promptlen=i+7
|
||||||
do i=1,len(prompt)-2
|
|
||||||
if (prompt(i:i) .ne. ' ') promptlen=i
|
|
||||||
enddo
|
|
||||||
promptlen=promptlen+1
|
|
||||||
prompt(promptlen:promptlen)='>'
|
|
||||||
promptlen=promptlen+1
|
|
||||||
else if (cmd .eq. 'kill') then
|
else if (cmd .eq. 'kill') then
|
||||||
iret=tecs_quit_server()
|
iret=tecs_quit_server(1)
|
||||||
|
if (iret .lt. 0) goto 19
|
||||||
|
if (iret .gt. 0) then
|
||||||
|
print *,'tecs server is not running'
|
||||||
|
endif
|
||||||
|
else if (cmd .eq. 'restart') then
|
||||||
|
iret=tecs_quit_server(0)
|
||||||
|
if (iret .lt. 0) goto 19
|
||||||
|
if (iret .gt. 0) then
|
||||||
|
print *,'tecs server is not running'
|
||||||
|
endif
|
||||||
|
else if (cmd .eq. 'remote') then
|
||||||
|
iret=tecs_set_par('remoteMode', '2', 2)
|
||||||
|
if (iret .lt. 0) goto 19
|
||||||
|
elseif (cmd .eq. 'rwacs') then
|
||||||
|
iret=tecs_rights(1)
|
||||||
|
if (iret .lt. 0) goto 19
|
||||||
elseif (cmd .eq. 'exit' .or. cmd .eq. 'quit') then
|
elseif (cmd .eq. 'exit' .or. cmd .eq. 'quit') then
|
||||||
goto 99
|
goto 99
|
||||||
elseif (cmd .eq. 'status') then
|
elseif (cmd .eq. 'status') then
|
||||||
@ -116,7 +148,7 @@
|
|||||||
l=0
|
l=0
|
||||||
goto 11
|
goto 11
|
||||||
elseif (cmd .eq. 'plot') then
|
elseif (cmd .eq. 'plot') then
|
||||||
call tecs_plot('Tm Ts Tr P', 1)
|
call tecs_plot(' ')
|
||||||
elseif (cmd .eq. 'help') then
|
elseif (cmd .eq. 'help') then
|
||||||
print *
|
print *
|
||||||
print *,'Writeable parameters:'
|
print *,'Writeable parameters:'
|
||||||
@ -131,18 +163,18 @@
|
|||||||
print *,'deriv PID derivation term'
|
print *,'deriv PID derivation term'
|
||||||
print *,'maxShift maximum (set-tempH) for controlMode=2'
|
print *,'maxShift maximum (set-tempH) for controlMode=2'
|
||||||
print *,'int2 integration time (sec) for controlMode=2'
|
print *,'int2 integration time (sec) for controlMode=2'
|
||||||
|
print *,'remoteMode 1: local, 2: remote'
|
||||||
print *
|
print *
|
||||||
print *,'Read only parameters:'
|
print *,'Read only parameters:'
|
||||||
print *
|
print *
|
||||||
print *,'Tm main temperature'
|
print *,'Tm main temperature'
|
||||||
print *,'Ts sample temperature'
|
print *,'Ts sample temperature'
|
||||||
print *,'setH set-point on regulation'
|
print *,'Tr set-point on regulation'
|
||||||
print *,'tLimit temperature limit'
|
print *,'tLimit temperature limit'
|
||||||
|
print *,'helium helium level'
|
||||||
print *,'htr heater current percentage'
|
print *,'htr heater current percentage'
|
||||||
print *,'resist heater resistance'
|
print *,'resist heater resistance'
|
||||||
print *,'logfile name of the logfile'
|
print *,'logfile name of the logfile'
|
||||||
print *,'remoteMode 1: local, 2: remote '
|
|
||||||
1 ,'(switch on with device command)'
|
|
||||||
print *
|
print *
|
||||||
print *,'Ta,Tb,Tc,Td values of channels A,B,C,D'
|
print *,'Ta,Tb,Tc,Td values of channels A,B,C,D'
|
||||||
print *
|
print *
|
||||||
@ -152,7 +184,7 @@
|
|||||||
1 ,'ill5 (maxi)'
|
1 ,'ill5 (maxi)'
|
||||||
print *,'cti1, cti2, cti3, cti4, cti5 (maxi), cti6 (focus), apd'
|
print *,'cti1, cti2, cti3, cti4, cti5 (maxi), cti6 (focus), apd'
|
||||||
print *,'ccr4k (4K closed cycle), hef4c (TriCS 4circle cryo)'
|
print *,'ccr4k (4K closed cycle), hef4c (TriCS 4circle cryo)'
|
||||||
print *,'sup4t (supra.magnet 4T)'
|
print *,'sup4t (supra.magnet 4T), ft (tantalum furnace)'
|
||||||
print *,'rdr11, rdr12 (LTF dilution 1 & 2, 20kOhm)'
|
print *,'rdr11, rdr12 (LTF dilution 1 & 2, 20kOhm)'
|
||||||
print *
|
print *
|
||||||
elseif (cmd .eq. 'log') then
|
elseif (cmd .eq. 'log') then
|
||||||
@ -184,7 +216,9 @@
|
|||||||
endif
|
endif
|
||||||
logarg=' '
|
logarg=' '
|
||||||
elseif (cmd .eq. 'plot') then
|
elseif (cmd .eq. 'plot') then
|
||||||
call tecs_plot('Tm Ts Tr '//par, 1)
|
call str_lowcase(par, par)
|
||||||
|
call str_upcase(par(1:1), par(1:1))
|
||||||
|
call tecs_plot(par)
|
||||||
elseif (cmd .eq. 'watch') then
|
elseif (cmd .eq. 'watch') then
|
||||||
iret=tecs_watch_log(par)
|
iret=tecs_watch_log(par)
|
||||||
if (iret .lt. 0) goto 19
|
if (iret .lt. 0) goto 19
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <string.h>
|
#include <strings.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "myc_mem.h"
|
#include "myc_mem.h"
|
||||||
#include "myc_str.h"
|
#include "myc_str.h"
|
||||||
@ -102,7 +102,7 @@ Set *FindSet(Base *base, char *name) {
|
|||||||
|
|
||||||
total=0;
|
total=0;
|
||||||
s = base->head;
|
s = base->head;
|
||||||
while (s!=NULL && 0!=strcmp(name, s->set.name)) {
|
while (s!=NULL && 0!=strcasecmp(name, s->set.name)) {
|
||||||
s = s->next;
|
s = s->next;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
@ -245,7 +245,7 @@ int Put(Set *set, int time, float value) {
|
|||||||
if (t % 2) {
|
if (t % 2) {
|
||||||
r->data[size]=value; size++; /* put a provisory value */
|
r->data[size]=value; size++; /* put a provisory value */
|
||||||
r->endTime += r->step;
|
r->endTime += r->step;
|
||||||
} else {
|
} else if (t == 2) {
|
||||||
PutSum(&set->sum, r->data+size); size+=2;
|
PutSum(&set->sum, r->data+size); size+=2;
|
||||||
r->endTime += r->step * 2;
|
r->endTime += r->step * 2;
|
||||||
}
|
}
|
||||||
@ -469,6 +469,8 @@ int DataEncode(float *data, int dataSize, char *coded, int codedLen) {
|
|||||||
for (i=0; i<dataSize; i++) {
|
for (i=0; i<dataSize; i++) {
|
||||||
if ( data[i] == DATA_UNDEF ) {
|
if ( data[i] == DATA_UNDEF ) {
|
||||||
coded[p++]='/';
|
coded[p++]='/';
|
||||||
|
} else if ( data[i] == DATA_GAP ) {
|
||||||
|
coded[p++]='.';
|
||||||
} else {
|
} else {
|
||||||
n=( (data[i] - minD) * 4095 ) / range + 0.5;
|
n=( (data[i] - minD) * 4095 ) / range + 0.5;
|
||||||
assert(n>=0 && n <4096);
|
assert(n>=0 && n <4096);
|
||||||
@ -514,7 +516,7 @@ int DataGetCoded(char *names, int startTime, int endTime, int step, int stdStep,
|
|||||||
}
|
}
|
||||||
if (set == NULL || start > startTime) {
|
if (set == NULL || start > startTime) {
|
||||||
set=CreateSet(&base, nam, NULL, stp, period, startTime);
|
set=CreateSet(&base, nam, NULL, stp, period, startTime);
|
||||||
set->end = start;
|
if (set != NULL) set->end = start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -567,8 +569,20 @@ int DataGetCoded(char *names, int startTime, int endTime, int step, int stdStep,
|
|||||||
siz2 = halfsiz * 2 - siz1;
|
siz2 = halfsiz * 2 - siz1;
|
||||||
s1 = startTime + (siz1 * period + halfsiz) / halfsiz / 2;
|
s1 = startTime + (siz1 * period + halfsiz) / halfsiz / 2;
|
||||||
if (siz1 > 0) {
|
if (siz1 > 0) {
|
||||||
|
halfsiz = (s1 - startTime) / set->step / 2;
|
||||||
|
if (halfsiz * 2 < siz1 && halfsiz > 0) {
|
||||||
|
ERR_I(GetSet(set, startTime, s1, halfsiz*2, data));
|
||||||
|
j = siz1 - 1;
|
||||||
|
for (i = halfsiz * 2-1; i >= 0; i--) { /* expand data */
|
||||||
|
while (j > siz1 / 2 * i / halfsiz) {
|
||||||
|
data[j]=DATA_GAP; j--;
|
||||||
|
}
|
||||||
|
data[j]=data[i]; j--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
ERR_I(GetSet(set, startTime, s1, siz1, data));
|
ERR_I(GetSet(set, startTime, s1, siz1, data));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (siz2 > 0) {
|
if (siz2 > 0) {
|
||||||
ERR_I(GetSet(s, s1, endTime, siz2, data+siz1));
|
ERR_I(GetSet(s, s1, endTime, siz2, data+siz1));
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ int DataGetCoded(char *names, int startTime, int endTime, int step, int stdStep,
|
|||||||
define DATA_UNDEF as a binary and decimal well defined, hopefully rarely used number
|
define DATA_UNDEF as a binary and decimal well defined, hopefully rarely used number
|
||||||
*/
|
*/
|
||||||
#define DATA_UNDEF MYC_NAN
|
#define DATA_UNDEF MYC_NAN
|
||||||
|
#define DATA_GAP (MYC_NAN*2)
|
||||||
#define DATA_CODE "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz"
|
#define DATA_CODE "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz"
|
||||||
|
|
||||||
#endif /* TECS_DATA_H_ */
|
#endif /* TECS_DATA_H_ */
|
||||||
|
@ -1,45 +1,67 @@
|
|||||||
subroutine tecs_plot(pars, naux)
|
subroutine tecs_plot(auxpar)
|
||||||
|
|
||||||
character(len=*) pars ! parameters to plot
|
character(len=*) auxpar
|
||||||
integer naux ! number of auxiliary, non-T parameters
|
|
||||||
|
|
||||||
integer, parameter :: dmax=1000, nmax=5, nmenu=11, chartfreq=1
|
integer, parameter :: dmax=800, nmax=5, tmax=4, amax=3, nmenu=13, chartperiod=5, naux=1
|
||||||
integer, parameter :: minRange=60, maxRange=7*24*3600
|
integer, parameter :: minRange=60, maxRange=7*24*3600
|
||||||
integer, parameter :: oneDay = 24*3600
|
integer, parameter :: oneDay = 24*3600
|
||||||
|
integer, parameter :: zoom=1, right=2, live=3
|
||||||
real, parameter :: winmin=60., undef=-1.125/1024./1024./1024.
|
real, parameter :: winmin=60., undef=-1.125/1024./1024./1024.
|
||||||
|
|
||||||
real*4 x1,x2,xmin,xmax,ymin(2),ymax(2),window
|
real*4 x1,x2,xmin,xmax,ymin(2),ymax(2),window
|
||||||
real*4 xd(dmax, nmax),yd(dmax,nmax), yy0(nmax), yy1(nmax)
|
real*4 xd(dmax, nmax),yd(dmax,nmax), yy0(nmax), yy1(nmax)
|
||||||
real*4 ylast1,ylast2,y1,y2
|
real*4 ylast1,ylast2,y1,y2
|
||||||
real*4 ex,ey,fx,fy,row,ticks,tim0,tim1
|
real*4 ex,ey,fx,fy,row,ticks,tim0,tim1,menuwid
|
||||||
integer l,j,i,n,t,leng,i1,i2,rl,startday,thisday
|
integer l,j,i,n,t,leng,i1,i2,rl,startday,thisday
|
||||||
integer nset
|
integer ncol, nset, mode
|
||||||
integer first,last,step,tbase,lastj
|
integer first,last,step,tbase,lastj
|
||||||
|
integer colorList(nmax)/5,3,2,4,8/
|
||||||
integer color(nmax)
|
integer color(nmax)
|
||||||
integer retLen(nmax)
|
integer retLen(nmax)
|
||||||
|
integer sel/0/, sel1, sel2, auxsel/1/
|
||||||
character key*1
|
character key*1
|
||||||
character text(nmenu)*12/ &
|
character text(2,nmenu)*16/ &
|
||||||
'live off','sel. zoom','zoom in','zoom out','show all','n days','n hours','n min','date','file','quit'/
|
'L' ,'live off' &
|
||||||
character keys*(nmenu)/'LZ+-XDHMTFQ'/
|
,'z' ,'sel. zoom' &
|
||||||
|
,'+' ,'zoom in' &
|
||||||
|
,'-' ,'zoom out' &
|
||||||
|
,'x' ,'show all' &
|
||||||
|
,'2d' ,'2 days' &
|
||||||
|
,'1h' ,'1 hour' &
|
||||||
|
,'15m' ,'15 min' &
|
||||||
|
,'31.7t','goto date' &
|
||||||
|
,'c' ,'show P/He/Aux' &
|
||||||
|
,'s' ,'select T' &
|
||||||
|
,'f' ,'write file' &
|
||||||
|
,'q' ,'quit'/
|
||||||
character weekdays(7)*4/'Mon','Tue','Wed','Thu','Fri','Sat','Sun'/
|
character weekdays(7)*4/'Mon','Tue','Wed','Thu','Fri','Sat','Sun'/
|
||||||
character buf*8, device*8, name*40, filnam*128, numb*16
|
character buf*8, device*8, name*40, filnam*128, numb*16, title*64, pars*64
|
||||||
|
character(len=4) tpar(tmax)/'Te', 'Tr', 'Tm', 'Ts'/
|
||||||
|
character(len=4) apar(amax)/'P', 'He', 'Aux'/
|
||||||
character(len=16) parnam(nmax)
|
character(len=16) parnam(nmax)
|
||||||
external tplot_close
|
|
||||||
logical gap, done
|
logical gap, done
|
||||||
logical live, xwin, zoom, right, saveit
|
logical saveit
|
||||||
integer iret, lund, numl, mon, day
|
integer iret, lund, numl, mon, day
|
||||||
|
|
||||||
! functions
|
! functions
|
||||||
integer sys_gmt_off, myc_now, myc_time, myc_date, tecs_get_data, tecs_get_mult
|
integer sys_gmt_off, myc_now, myc_time, myc_date, tecs_get_data, tecs_get_mult, tecs_get_par
|
||||||
|
|
||||||
data window/0./
|
data window/0./
|
||||||
|
|
||||||
if (window==0) window=1800.
|
if (window==0) window=1800.
|
||||||
saveit=.false.
|
saveit=.false.
|
||||||
zoom=.false.
|
mode=live
|
||||||
right=.true.
|
|
||||||
call pgopen(" ")
|
call pgopen(" ")
|
||||||
|
|
||||||
|
call pgqinf('TYPE', device, l)
|
||||||
|
if (device=='NULL') then
|
||||||
|
print *,'No PGPLOT-Device defined'
|
||||||
|
goto 9
|
||||||
|
endif
|
||||||
|
|
||||||
|
call pgqcol(i,ncol)
|
||||||
|
! print *,i,ncol,' colors ',device
|
||||||
|
if (ncol>=8 .and. device /= 'VT125') then
|
||||||
call pgscr(0, 1.0, 1.0, 1.0)
|
call pgscr(0, 1.0, 1.0, 1.0)
|
||||||
call pgscr(1, 0.0, 0.0, 0.0)
|
call pgscr(1, 0.0, 0.0, 0.0)
|
||||||
call pgscr(2, 1.0, 0.0, 0.0)
|
call pgscr(2, 1.0, 0.0, 0.0)
|
||||||
@ -49,53 +71,44 @@ subroutine tecs_plot(pars, naux)
|
|||||||
call pgscr(6, 1.0, 0.0, 1.0)
|
call pgscr(6, 1.0, 0.0, 1.0)
|
||||||
call pgscr(7, 1.0, 1.0, 0.0)
|
call pgscr(7, 1.0, 1.0, 0.0)
|
||||||
call pgscr(8, 1.0, 0.5, 0.0)
|
call pgscr(8, 1.0, 0.5, 0.0)
|
||||||
|
|
||||||
call pgqinf('TYPE', device, l)
|
|
||||||
if (device=='NULL') then
|
|
||||||
print *,'No PGPLOT-Device defined'
|
|
||||||
goto 9
|
|
||||||
endif
|
endif
|
||||||
live=device(1:1)/='X' ! live switched off by default on X-Windows
|
|
||||||
|
|
||||||
nset=1
|
|
||||||
l=1
|
|
||||||
i=1
|
|
||||||
do while (i <= nmax)
|
|
||||||
do while (l < len(pars) .and. pars(l:l) <= ' ')
|
|
||||||
l=l+1
|
|
||||||
enddo
|
|
||||||
if (pars(l:l) > ' ') then
|
|
||||||
j=l
|
|
||||||
do while (l < len(pars) .and. pars(l:l) > ' ')
|
|
||||||
l=l+1
|
|
||||||
enddo
|
|
||||||
parnam(i)=pars(j:l)
|
|
||||||
nset=i
|
|
||||||
if (l == len(pars)) i=nmax
|
|
||||||
else
|
|
||||||
i=nmax
|
|
||||||
endif
|
|
||||||
i=i+1
|
|
||||||
enddo
|
|
||||||
|
|
||||||
call pgask(.false.)
|
call pgask(.false.)
|
||||||
l=0
|
l=0
|
||||||
x1=0
|
x1=0
|
||||||
step=0
|
step=0
|
||||||
|
do i=1,amax
|
||||||
|
if (auxpar == apar(i)) then
|
||||||
|
auxsel=i
|
||||||
|
endif
|
||||||
|
enddo
|
||||||
|
|
||||||
1 iret=tecs_get_mult(pars, t, nset, yy0)
|
1 pars=' '
|
||||||
|
nset=0
|
||||||
|
do i=1,tmax
|
||||||
|
nset=nset+1
|
||||||
|
color(nset)=colorList(i)
|
||||||
|
parnam(nset)=tpar(i)
|
||||||
|
pars=trim(pars)//' '//parnam(nset)
|
||||||
|
enddo
|
||||||
|
nset=nset+1
|
||||||
|
color(nset)=colorList(5)
|
||||||
|
parnam(nset)=apar(auxsel)
|
||||||
|
pars=trim(pars)//' '//parnam(nset)
|
||||||
|
|
||||||
|
iret=tecs_get_mult(pars, t, nset, yy0)
|
||||||
if (iret < 0) goto 99
|
if (iret < 0) goto 99
|
||||||
if (window == 0) then
|
if (window == 0) then
|
||||||
last=t
|
last=t
|
||||||
step=maxRange/dmax
|
step=maxRange/dmax
|
||||||
window=maxRange
|
window=maxRange
|
||||||
first=t-min(dmax*step-1,maxRange-step)
|
first=t-min(dmax*step-1,maxRange-step)
|
||||||
else if (right .or. live) then
|
else if (mode >= right) then
|
||||||
step=window/(dmax-1)+0.99
|
step=window/(dmax-1)+0.99
|
||||||
last=t
|
last=t
|
||||||
first=t-min(dmax*step-1,nint(window)-step)
|
first=t-min(dmax*step-1,nint(window)-step)
|
||||||
else
|
else
|
||||||
if (.not. zoom) then
|
if (mode==zoom) then
|
||||||
x2=(x1+x2+window)/2
|
x2=(x1+x2+window)/2
|
||||||
x1=x2-window
|
x1=x2-window
|
||||||
endif
|
endif
|
||||||
@ -106,42 +119,37 @@ subroutine tecs_plot(pars, naux)
|
|||||||
endif
|
endif
|
||||||
if (step == 0) step=1
|
if (step == 0) step=1
|
||||||
|
|
||||||
iret=tecs_get_data(pars, first, last, step, yd, dmax, nmax, retLen)
|
tbase=first-mod(first,7*oneDay)
|
||||||
|
iret=tecs_get_data(pars, first, last, step, tbase, xd, yd, dmax, nmax, retLen)
|
||||||
if (iret < 0) goto 99
|
if (iret < 0) goto 99
|
||||||
! do i=1,nmax
|
|
||||||
! if (retLen(i) > 0) nset=i
|
|
||||||
! enddo
|
|
||||||
! if (nset == 0) then
|
|
||||||
! retLen(1)=0
|
|
||||||
! nset=1
|
|
||||||
! endif
|
|
||||||
color(1)=2
|
|
||||||
color(2)=4
|
|
||||||
color(3)=3
|
|
||||||
color(4)=5
|
|
||||||
color(5)=8
|
|
||||||
if (naux > 0) color(nset)=8
|
|
||||||
|
|
||||||
tbase=first-mod(first,7*oneDay);
|
x2 = last - tbase
|
||||||
x2 = last - tbase;
|
if (mode >= right) then
|
||||||
if (right .or. live) then
|
|
||||||
x1=x2-window
|
x1=x2-window
|
||||||
else
|
else
|
||||||
x1 = first - tbase;
|
x1 = first - tbase
|
||||||
endif
|
endif
|
||||||
tim0=t-tbase
|
tim0=t-tbase
|
||||||
do j=1,nset
|
do i=1,nset
|
||||||
leng=retLen(j)
|
leng=retLen(i)
|
||||||
do i=1,leng
|
do while (leng > 1 .and. yd(leng,i) == undef)
|
||||||
xd(i,j)=(float(i-1)*(last-tbase)+float(leng-i)*(first-tbase))/(leng-1)
|
leng=leng-1
|
||||||
enddo
|
enddo
|
||||||
if (live .and. leng>0) then
|
if (leng == 1) leng=0
|
||||||
xd(leng,j)=tim0
|
retLen(i)=leng
|
||||||
yd(leng,j)=yy0(j)
|
if (mode==live .and. leng>0) then
|
||||||
|
xd(leng,i)=tim0
|
||||||
|
yd(leng,i)=yy0(i)
|
||||||
endif
|
endif
|
||||||
enddo
|
enddo
|
||||||
|
if (sel /= 0) then
|
||||||
|
do while (sel < nset .and. retLen(sel) == 0)
|
||||||
|
sel=sel+1
|
||||||
|
enddo
|
||||||
|
if (sel >= nset) sel = 0
|
||||||
|
endif
|
||||||
if (saveit) goto 9
|
if (saveit) goto 9
|
||||||
if (live) then
|
if (mode==live) then
|
||||||
x2=max(tim0,x2)+min(1800., window*0.5)
|
x2=max(tim0,x2)+min(1800., window*0.5)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -155,8 +163,15 @@ subroutine tecs_plot(pars, naux)
|
|||||||
|
|
||||||
i1=1
|
i1=1
|
||||||
i2=nset-naux
|
i2=nset-naux
|
||||||
|
if (sel==0) then
|
||||||
|
sel1=i1
|
||||||
|
sel2=i2
|
||||||
|
else
|
||||||
|
sel1=sel
|
||||||
|
sel2=sel
|
||||||
|
endif
|
||||||
do rl=1,2
|
do rl=1,2
|
||||||
if (zoom) then
|
if (mode==zoom) then
|
||||||
ymin(1)=y1
|
ymin(1)=y1
|
||||||
ymax(1)=y2
|
ymax(1)=y2
|
||||||
else
|
else
|
||||||
@ -164,7 +179,7 @@ subroutine tecs_plot(pars, naux)
|
|||||||
ymax(rl)=-1e30
|
ymax(rl)=-1e30
|
||||||
ylast1=ymin(rl)
|
ylast1=ymin(rl)
|
||||||
ylast2=ymax(rl)
|
ylast2=ymax(rl)
|
||||||
do i=i1,i2
|
do i=sel1,sel2
|
||||||
do j=1,retLen(i)
|
do j=1,retLen(i)
|
||||||
if (yd(j,i)/=undef) then
|
if (yd(j,i)/=undef) then
|
||||||
ymin(rl)=min(ymin(rl),yd(j,i))
|
ymin(rl)=min(ymin(rl),yd(j,i))
|
||||||
@ -183,7 +198,7 @@ subroutine tecs_plot(pars, naux)
|
|||||||
fy=abs(ymax(rl))
|
fy=abs(ymax(rl))
|
||||||
ymax(rl)=ymax(rl)+max(fy*0.0075,ey*0.01)
|
ymax(rl)=ymax(rl)+max(fy*0.0075,ey*0.01)
|
||||||
ymin(rl)=ymin(rl)-max(fy*0.005,ey*0.01)
|
ymin(rl)=ymin(rl)-max(fy*0.005,ey*0.01)
|
||||||
if (live) then
|
if (mode==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))
|
||||||
ymax(rl)=max(ymax(rl),ylast2+ey*0.4)
|
ymax(rl)=max(ymax(rl),ylast2+ey*0.4)
|
||||||
endif
|
endif
|
||||||
@ -196,11 +211,10 @@ subroutine tecs_plot(pars, naux)
|
|||||||
ymax(rl)=ymin(rl)*1.00001+1.0
|
ymax(rl)=ymin(rl)*1.00001+1.0
|
||||||
ymin(rl)=-1.0e-3
|
ymin(rl)=-1.0e-3
|
||||||
endif
|
endif
|
||||||
zoom=.false.
|
|
||||||
|
|
||||||
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
|
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
|
||||||
|
|
||||||
do i=i2,i1,-1
|
do i=i1,i2
|
||||||
call pgsci(color(i))
|
call pgsci(color(i))
|
||||||
lastj=1
|
lastj=1
|
||||||
do j=1,retLen(i)
|
do j=1,retLen(i)
|
||||||
@ -220,6 +234,7 @@ subroutine tecs_plot(pars, naux)
|
|||||||
call pgtbox('C', 0.0, 0, ' ', 0.0, 0)
|
call pgtbox('C', 0.0, 0, ' ', 0.0, 0)
|
||||||
ey=0.0
|
ey=0.0
|
||||||
do i=i1,i2
|
do i=i1,i2
|
||||||
|
if (retLen(i) > 0) then
|
||||||
name=parnam(i)
|
name=parnam(i)
|
||||||
if (name=="Tm") then
|
if (name=="Tm") then
|
||||||
name="Main Sensor"
|
name="Main Sensor"
|
||||||
@ -228,14 +243,16 @@ subroutine tecs_plot(pars, naux)
|
|||||||
elseif (name=="Tr") then
|
elseif (name=="Tr") then
|
||||||
name="SetPoint"
|
name="SetPoint"
|
||||||
endif
|
endif
|
||||||
|
if (sel == i) name=trim(name)//'*'
|
||||||
call pglen(5, trim(name), fx, fy)
|
call pglen(5, trim(name), fx, fy)
|
||||||
call pgsci(color(i))
|
call pgsci(color(i))
|
||||||
call pgmtxt ('L', 2.5, ey, 0.0, trim(name))
|
call pgmtxt ('L', 2.5, ey, 0.0, trim(name))
|
||||||
ey=ey+fy+0.04
|
ey=ey+fy+0.04
|
||||||
|
endif
|
||||||
enddo
|
enddo
|
||||||
call pgsci(1)
|
call pgsci(1)
|
||||||
call pgmtxt ('L', 2.5, ey, 0.0, 'T [K]')
|
call pgmtxt ('L', 2.5, ey, 0.0, 'T [K]')
|
||||||
else if (naux > 0) then
|
else
|
||||||
call pgsch(0.7)
|
call pgsch(0.7)
|
||||||
call pgtbox('ZCIST', ticks, 0, 'BCVINMST', 0.0, 0)
|
call pgtbox('ZCIST', ticks, 0, 'BCVINMST', 0.0, 0)
|
||||||
call pgtbox('B', 0.0, 0, ' ', 0.0, 0)
|
call pgtbox('B', 0.0, 0, ' ', 0.0, 0)
|
||||||
@ -243,39 +260,46 @@ subroutine tecs_plot(pars, naux)
|
|||||||
call pgsch(1.0)
|
call pgsch(1.0)
|
||||||
if (parnam(nset) == 'P' .or. parnam(nset) == 'p') then
|
if (parnam(nset) == 'P' .or. parnam(nset) == 'p') then
|
||||||
call pgmtxt ('L', 2.5, 0.5, 0.5, 'Power [W]')
|
call pgmtxt ('L', 2.5, 0.5, 0.5, 'Power [W]')
|
||||||
|
elseif (parnam(nset) == 'He') then
|
||||||
|
title='%'
|
||||||
|
iret=tecs_get_par('heUnits', title, 0)
|
||||||
|
call pgmtxt ('L', 2.5, 0.5, 0.5, 'Helium ['//trim(title)//']')
|
||||||
else
|
else
|
||||||
call pgmtxt ('L', 2.5, 0.5, 0.5, parnam(nset))
|
call pgmtxt ('L', 2.5, 0.5, 0.5, parnam(nset))
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
i1=nset-naux+1
|
i1=nset-naux+1
|
||||||
i2=nset
|
i2=nset
|
||||||
|
sel1=i1
|
||||||
|
sel2=i2
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
call pgsch(0.8)
|
call pgsch(0.7)
|
||||||
rl=1
|
rl=1
|
||||||
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
|
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
|
||||||
|
|
||||||
call pgsci(1)
|
call pgsci(1)
|
||||||
call pgsclp(0)
|
call pgsclp(0)
|
||||||
if (live) then
|
if (mode==live) then
|
||||||
text(1)='live off'
|
text(2,1)='live off'
|
||||||
else
|
else
|
||||||
text(1)='live on'
|
text(2,1)='live on'
|
||||||
endif
|
endif
|
||||||
ex=0.0
|
text(2,10)='show '//apar(mod(auxsel,3)+1)
|
||||||
|
menuwid=0.0
|
||||||
do i=1,nmenu
|
do i=1,nmenu
|
||||||
call pglen(5, trim(text(i)), fx, fy)
|
call pglen(5, trim(text(2,i)), fx, fy)
|
||||||
call pgmtxt('T', 3.0, ex, 0.0, '|'//keys(i:i))
|
call pgmtxt('T', 3.0, menuwid, 0.0, '|'//text(1,i))
|
||||||
call pgmtxt('T', 2.5, ex, 0.0, '|')
|
call pgmtxt('T', 2.5, menuwid, 0.0, '|')
|
||||||
call pgmtxt('T', 2.0, ex, 0.0, '|'//text(i))
|
call pgmtxt('T', 2.0, menuwid, 0.0, '|'//text(2,i))
|
||||||
ex=ex+fx+0.01
|
menuwid=menuwid+fx+0.01
|
||||||
enddo
|
enddo
|
||||||
call pgmtxt('T', 3.0, ex, 0.0, '|')
|
call pgmtxt('T', 3.0, menuwid, 0.0, '|')
|
||||||
call pgmtxt('T', 2.5, ex, 0.0, '|')
|
call pgmtxt('T', 2.5, menuwid, 0.0, '|')
|
||||||
call pgmtxt('T', 2.0, ex, 0.0, '|')
|
call pgmtxt('T', 2.0, menuwid, 0.0, '|')
|
||||||
call pgmtxt('T', 3.0, 0.8, 0.0, 'any digit to enter n')
|
menuwid=menuwid+0.01
|
||||||
call pgmtxt('T', 2.0, 0.8, 0.0, 'n=')
|
|
||||||
|
|
||||||
|
call pgsch(0.8)
|
||||||
done=.false.
|
done=.false.
|
||||||
row=(ymax(rl)-ymin(rl))/30.
|
row=(ymax(rl)-ymin(rl))/30.
|
||||||
ey=ymin(rl)-row*3.5
|
ey=ymin(rl)-row*3.5
|
||||||
@ -300,7 +324,7 @@ subroutine tecs_plot(pars, naux)
|
|||||||
i=i+1
|
i=i+1
|
||||||
enddo
|
enddo
|
||||||
if (.not. done) then
|
if (.not. done) then
|
||||||
n=nint(x2)/oneDay*oneDay;
|
n=nint(x2)/oneDay*oneDay
|
||||||
i=nint(x1)-n
|
i=nint(x1)-n
|
||||||
j=nint(x2)-n
|
j=nint(x2)-n
|
||||||
if (i < 0) then
|
if (i < 0) then
|
||||||
@ -321,17 +345,29 @@ subroutine tecs_plot(pars, naux)
|
|||||||
call pgmtxt('B', 3.5, ex, ex, weekdays(thisday)//buf(7:8)//'.'//buf(5:6))
|
call pgmtxt('B', 3.5, ex, ex, weekdays(thisday)//buf(7:8)//'.'//buf(5:6))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
iret=tecs_get_par('device', title, 0)
|
||||||
|
if (iret < 0) goto 99
|
||||||
|
i=index(title, '(')
|
||||||
|
if (i > 2 ) then
|
||||||
|
title=title(1:i-1)
|
||||||
|
else
|
||||||
|
title='test - no device'
|
||||||
|
endif
|
||||||
|
|
||||||
|
call pgmtxt('T', -1.5, 0.02, 0.0, title)
|
||||||
call pgsclp(1)
|
call pgsclp(1)
|
||||||
|
|
||||||
call get_key(key, 0, 0) ! purge buffer
|
call purge_keys ! purge buffer
|
||||||
|
|
||||||
numl=0
|
numl=0
|
||||||
numb=' '
|
numb=' '
|
||||||
7 if (live) then
|
7 if (mode==live) then
|
||||||
if (device(1:1)=='X') then
|
! if (device(1:1)=='X') then
|
||||||
call pgmtxt('T', 0.5, 0.0, 0.0, 'LIVE MODE (click on text window before pressing any further key)')
|
! call pgmtxt('T', 0.5, 0.0, 0.0, 'LIVE MODE (click on text window before pressing any further key)')
|
||||||
endif
|
! endif
|
||||||
call get_key(key, 0, chartfreq)
|
! call get_key(key, 0, chartperiod)
|
||||||
|
i=chartperiod-mod(myc_now(), chartperiod)
|
||||||
|
call get_cursor(ex, ey, key, -i)
|
||||||
|
|
||||||
do while (key == char(0)) ! no key pressed
|
do while (key == char(0)) ! no key pressed
|
||||||
iret=tecs_get_mult(pars, t, nset, yy1)
|
iret=tecs_get_mult(pars, t, nset, yy1)
|
||||||
@ -347,9 +383,9 @@ subroutine tecs_plot(pars, naux)
|
|||||||
i2=nset-naux
|
i2=nset-naux
|
||||||
do rl=1,2
|
do rl=1,2
|
||||||
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
|
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
|
||||||
do i=i2,i1,-1
|
do i=i1,i2
|
||||||
if (yy0(i) .ne. undef .and. yy1(i) .ne. undef) then
|
if (yy0(i) /= undef .and. yy1(i) /= undef) then
|
||||||
if (yy1(i) < ymin(rl) .or. yy1(i) > ymax(rl)) then
|
if ((sel==0 .or. sel==i) .and. (yy1(i) < ymin(rl) .or. yy1(i) > ymax(rl))) then
|
||||||
call pgpage
|
call pgpage
|
||||||
window=x2-x1
|
window=x2-x1
|
||||||
goto 1
|
goto 1
|
||||||
@ -366,11 +402,11 @@ subroutine tecs_plot(pars, naux)
|
|||||||
tim0=tim1
|
tim0=tim1
|
||||||
|
|
||||||
endif
|
endif
|
||||||
call get_key(key, 0, chartfreq)
|
i=chartperiod-mod(myc_now(), chartperiod)
|
||||||
|
call get_cursor(ex, ey, key, -i)
|
||||||
enddo
|
enddo
|
||||||
else
|
else
|
||||||
call pgcurs(ex, ey, key)
|
call get_cursor(ex, ey, key, 0)
|
||||||
call must_purge
|
|
||||||
endif
|
endif
|
||||||
rl=1
|
rl=1
|
||||||
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
|
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
|
||||||
@ -378,28 +414,51 @@ subroutine tecs_plot(pars, naux)
|
|||||||
8 if (key>='a') key=char(ichar(key)-32)
|
8 if (key>='a') key=char(ichar(key)-32)
|
||||||
if (key=='-') then
|
if (key=='-') then
|
||||||
window=min(window*2, 8.0*oneDay)
|
window=min(window*2, 8.0*oneDay)
|
||||||
|
if (mode==zoom) then
|
||||||
|
x1=x1-(x2-x1)/2
|
||||||
|
x2=x2+(x2-x1)/3
|
||||||
|
y1=y1-(y2-y1)/2
|
||||||
|
y2=y2+(y2-y1)/3
|
||||||
|
endif
|
||||||
elseif (key=='X') then
|
elseif (key=='X') then
|
||||||
window=0
|
window=0
|
||||||
live=.false.
|
mode=0
|
||||||
elseif (key=='+' .or. key==',') then
|
elseif (key=='+' .or. key==',') then
|
||||||
window=max(winmin,window/2)
|
window=max(winmin,window/2)
|
||||||
|
if (mode==zoom) then
|
||||||
|
if (ex==undef) then
|
||||||
|
ex=(x1+x2)/2
|
||||||
|
ey=(min(y1,ymax(1))+max(y1,ymin(1)))/2
|
||||||
|
end if
|
||||||
|
fx=max(winmin,x2-x1)
|
||||||
|
fy=max(y2-y1,1e-3,y2*1e-5)
|
||||||
|
x1=ex-fx/4
|
||||||
|
x2=ex+fx/4
|
||||||
|
y1=ey-fy/4
|
||||||
|
y2=ey+fy/4
|
||||||
|
endif
|
||||||
elseif (key=='Z') then
|
elseif (key=='Z') then
|
||||||
call pgsci(1)
|
call pgsci(1)
|
||||||
if (live) then
|
if (ex==undef) then
|
||||||
call pgmtxt('T', 0.5, 0.0, 0.0, 'click on two opposite corners of a selection rectangle')
|
call pgmtxt('T', 0.5, 0.0, 0.0, 'click on two opposite corners of a selection rectangle')
|
||||||
call pgcurs(ex, ey, key)
|
call get_cursor(ex, ey, key, 0)
|
||||||
else
|
else
|
||||||
call pgmtxt('T', 0.5, 0.0, 0.0, 'click on second corner of selection rectangle')
|
call pgmtxt('T', 0.5, 0.0, 0.0, 'click on second corner of selection rectangle')
|
||||||
endif
|
endif
|
||||||
call pgsci(5)
|
call pgsci(6)
|
||||||
xmin=x1
|
xmin=x1
|
||||||
xmax=x2
|
xmax=x2
|
||||||
call pgmove(xmin, ey)
|
call pgmove(xmin, ey)
|
||||||
call pgdraw(xmax, ey)
|
call pgdraw(xmax, ey)
|
||||||
call pgmove(ex, ymin(rl))
|
call pgmove(ex, ymin(rl))
|
||||||
call pgdraw(ex, ymax(rl))
|
call pgdraw(ex, ymax(rl))
|
||||||
call pgcurs(fx, fy, key)
|
if (device(1:1) .eq. 'X') then
|
||||||
call must_purge
|
fx=ex
|
||||||
|
fy=ey
|
||||||
|
call get_cursor(fx, fy, key, 2)
|
||||||
|
else
|
||||||
|
call get_cursor(fx, fy, key, 0)
|
||||||
|
endif
|
||||||
x1=max(xmin,min(ex,fx))
|
x1=max(xmin,min(ex,fx))
|
||||||
x2=min(xmax,max(ex,fx))
|
x2=min(xmax,max(ex,fx))
|
||||||
if (x1>=x2) then
|
if (x1>=x2) then
|
||||||
@ -413,42 +472,36 @@ subroutine tecs_plot(pars, naux)
|
|||||||
y1=ymin(1)
|
y1=ymin(1)
|
||||||
y2=ymax(1)
|
y2=ymax(1)
|
||||||
endif
|
endif
|
||||||
zoom=.true.
|
mode=zoom
|
||||||
live=.false.
|
|
||||||
right=.false.
|
|
||||||
elseif (key >= '0' .and. key <= '9' .or. key == '.') then ! number
|
elseif (key >= '0' .and. key <= '9' .or. key == '.') then ! number
|
||||||
if (numl .lt. len(numb)) then
|
if (numl .lt. len(numb)) then
|
||||||
numl=numl+1
|
numl=numl+1
|
||||||
numb(numl:numl)=key
|
numb(numl:numl)=key
|
||||||
call pgsci(1)
|
call pgsci(1)
|
||||||
call pgsch(0.8)
|
call pgsch(0.8)
|
||||||
call pgmtxt('T', 2.0, 0.825, 0.0, numb(1:numl))
|
call pgmtxt('T', 2.0, menuwid, 0.0, numb(1:numl))
|
||||||
endif
|
endif
|
||||||
if (device(1:1)=='X' .and. .not. live) then
|
! call get_cursor(ex, ey, key, -chartperiod)
|
||||||
call pgcurs(ex, ey, key)
|
! if (key/=char(0)) goto 8
|
||||||
call must_purge
|
if (mode==zoom) mode=0
|
||||||
else
|
|
||||||
call get_key(key, 2, 10)
|
|
||||||
endif
|
|
||||||
if (key/=char(0)) goto 8
|
|
||||||
goto 7
|
goto 7
|
||||||
elseif (key == 'D') then
|
elseif (key == 'D') then
|
||||||
ex=1
|
ex=1
|
||||||
read(numb, *, iostat=i) ex
|
read(numb, *, iostat=i) ex
|
||||||
window=min(maxRange,max(minRange, nint(oneDay*ex)))
|
window=min(maxRange,max(minRange, nint(oneDay*ex)))
|
||||||
right=.true.
|
if (mode < right) mode=right
|
||||||
x1=0
|
x1=0
|
||||||
elseif (key == 'H') then
|
elseif (key == 'H') then
|
||||||
ex=1
|
ex=1
|
||||||
read(numb, *, iostat=i) ex
|
read(numb, *, iostat=i) ex
|
||||||
window=min(maxRange,max(minRange, nint(3600*ex)))
|
window=min(maxRange,max(minRange, nint(3600*ex)))
|
||||||
right=.true.
|
if (mode < right) mode=right
|
||||||
x1=0
|
x1=0
|
||||||
elseif (key == 'M') then
|
elseif (key == 'M') then
|
||||||
ex=1
|
ex=1
|
||||||
read(numb, *, iostat=i) ex
|
read(numb, *, iostat=i) ex
|
||||||
window=min(maxRange,max(minRange, nint(60*ex)))
|
window=min(maxRange,max(minRange, nint(60*ex)))
|
||||||
right=.true.
|
if (mode < right) mode=right
|
||||||
x1=0
|
x1=0
|
||||||
elseif (key == 'T' .or. numl>0 .and. (key==char(13) .or. key==char(10))) then
|
elseif (key == 'T' .or. numl>0 .and. (key==char(13) .or. key==char(10))) then
|
||||||
j=index(numb,'.')
|
j=index(numb,'.')
|
||||||
@ -457,27 +510,32 @@ subroutine tecs_plot(pars, naux)
|
|||||||
read(numb(1:j-1), *, iostat=i) day
|
read(numb(1:j-1), *, iostat=i) day
|
||||||
mon=0
|
mon=0
|
||||||
read(numb(j+1:numl), *, iostat=i) mon
|
read(numb(j+1:numl), *, iostat=i) mon
|
||||||
tbase = myc_time(day+mon*100);
|
tbase = myc_time(day+mon*100)
|
||||||
else
|
else
|
||||||
read(numb, *, iostat=i) day
|
read(numb, *, iostat=i) day
|
||||||
tbase = myc_time(day);
|
tbase = myc_time(day)
|
||||||
endif
|
endif
|
||||||
x1=0
|
x1=0
|
||||||
x2=oneDay
|
x2=oneDay
|
||||||
window=x2
|
window=x2
|
||||||
live=.false.
|
mode=0
|
||||||
right=.false.
|
|
||||||
elseif (key == 'L') then
|
elseif (key == 'L') then
|
||||||
live=.not. live
|
if (mode == live) then
|
||||||
if (live) then
|
mode=right
|
||||||
right=.true.
|
else
|
||||||
|
mode=live
|
||||||
endif
|
endif
|
||||||
elseif (key == 'F') then
|
elseif (key == 'F') then
|
||||||
saveit=.true.
|
saveit=.true.
|
||||||
elseif (key=='Q' .or. key==char(13) .or. key==char(10)) then
|
elseif (key=='Q' .or. key==char(13) .or. key==char(10)) then
|
||||||
goto 9
|
goto 9
|
||||||
elseif (key == 'R') then
|
elseif (key == 'S') then
|
||||||
elseif (live) then
|
sel=sel+1
|
||||||
|
if (sel > tmax) sel=0
|
||||||
|
elseif (key == 'C') then
|
||||||
|
auxsel=auxsel+1
|
||||||
|
if (auxsel > amax) auxsel=1
|
||||||
|
elseif (mode==live) then
|
||||||
goto 7
|
goto 7
|
||||||
endif
|
endif
|
||||||
numl=0
|
numl=0
|
||||||
@ -486,8 +544,8 @@ subroutine tecs_plot(pars, naux)
|
|||||||
goto 1
|
goto 1
|
||||||
99 call tecs_write_msg(6)
|
99 call tecs_write_msg(6)
|
||||||
9 continue
|
9 continue
|
||||||
call tplot_close
|
call pgclos
|
||||||
call get_key(key, 0, 0) ! purge type-ahead-buffer
|
call purge_keys
|
||||||
print *
|
print *
|
||||||
if (saveit) then
|
if (saveit) then
|
||||||
lund=41
|
lund=41
|
||||||
@ -525,22 +583,37 @@ subroutine tecs_plot(pars, naux)
|
|||||||
|
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
subroutine get_key(key, tmo1, tmo2)
|
subroutine get_cursor(x, y, key, mode)
|
||||||
integer tmo1, tmo2
|
character*1 key
|
||||||
character key*1
|
real*4 x, y
|
||||||
logical purge/.false./
|
integer mode
|
||||||
|
integer with_timeout/-1/
|
||||||
|
integer l
|
||||||
|
character res*32
|
||||||
|
|
||||||
key=char(0)
|
if (with_timeout<0) then
|
||||||
if (purge) then
|
with_timeout=0
|
||||||
purge=.false.
|
call pgqinf('VERSION', res, l)
|
||||||
call sys_get_key(key, tmo1)
|
if (res(l:l)=='+') then
|
||||||
if (key/=char(0) .and. key/=char(13)) return
|
call pgqinf('TYPE', res, l)
|
||||||
|
if (res(1:1)=='X') then
|
||||||
|
with_timeout=1
|
||||||
end if
|
end if
|
||||||
if (tmo2>0) call sys_get_key(key, tmo2)
|
end if
|
||||||
return
|
end if
|
||||||
|
if (with_timeout>0 .or. mode>=0) then
|
||||||
|
call pgband(mode, 0, x, y, x, y, key)
|
||||||
|
else
|
||||||
|
call sys_get_key(key, -mode)
|
||||||
|
endif
|
||||||
|
end subroutine
|
||||||
|
|
||||||
entry must_purge
|
subroutine purge_keys
|
||||||
purge=.true.
|
character key*1
|
||||||
|
key=' '
|
||||||
|
do while (key/=char(0))
|
||||||
|
call sys_get_key(key, 0)
|
||||||
|
end do
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
subroutine set_win(rl, x1, x2, y1, y2)
|
subroutine set_win(rl, x1, x2, y1, y2)
|
||||||
@ -555,8 +628,3 @@ subroutine set_win(rl, x1, x2, y1, y2)
|
|||||||
|
|
||||||
call pgswin(x1,x2,y1,y2)
|
call pgswin(x1,x2,y1,y2)
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
subroutine tplot_close
|
|
||||||
call pgclos
|
|
||||||
! call dlog_close_r
|
|
||||||
end subroutine
|
|
||||||
|
102
tecsdriv.c
102
tecsdriv.c
@ -38,6 +38,7 @@
|
|||||||
MODIFICATIONS.
|
MODIFICATIONS.
|
||||||
----------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -57,8 +58,8 @@
|
|||||||
#include "sicsvar.h"
|
#include "sicsvar.h"
|
||||||
#include "tecs/coc_util.h"
|
#include "tecs/coc_util.h"
|
||||||
#include "tecs/tecs_cli.h"
|
#include "tecs/tecs_cli.h"
|
||||||
#include "tecs/str_util.h"
|
#include "tecs/myc_str.h"
|
||||||
#include "tecs/err_handling.h"
|
#include "tecs/myc_err.h"
|
||||||
extern pServer pServ;
|
extern pServer pServ;
|
||||||
|
|
||||||
#include "evdriver.i"
|
#include "evdriver.i"
|
||||||
@ -83,7 +84,6 @@
|
|||||||
int iRet;
|
int iRet;
|
||||||
pEVDriver pD;
|
pEVDriver pD;
|
||||||
pTecsDriv pMe;
|
pTecsDriv pMe;
|
||||||
double fNum;
|
|
||||||
float fVal;
|
float fVal;
|
||||||
|
|
||||||
self = (pEVControl)pData;
|
self = (pEVControl)pData;
|
||||||
@ -96,23 +96,66 @@
|
|||||||
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pD=self->pDriv; assert(pD);
|
||||||
|
pMe=pD->pPrivate; assert(pMe);
|
||||||
strcpy(pBueffel, " ");
|
strcpy(pBueffel, " ");
|
||||||
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 interest ", pBueffel)
|
if (0==strcmp(pBueffel," targetvalue ")) {
|
||||||
&& NULL==strstr(" upperlimit lowerlimit safevalue currentvalue targetvalue ", pBueffel)
|
if (argc == 2) {
|
||||||
) {
|
iRet=CocGet(pMe->pData,"set",result); /* get parameter */
|
||||||
|
if (iRet<0) goto Error;
|
||||||
pD=self->pDriv; assert(pD);
|
self->fTarget = atof(result);
|
||||||
pMe=pD->pPrivate; assert(pMe);
|
}
|
||||||
if(argc > 2) { /* set case */
|
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||||
iRet=CocSet(pMe->pData,argv[1],argv[2]);
|
} else if (0==strcmp(pBueffel," list ")) {
|
||||||
if (iRet<0) {
|
iRet=CocGet(pMe->pData,"set",result); /* get parameter */
|
||||||
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
if (iRet<0) goto Error;
|
||||||
|
self->fTarget = atof(result);
|
||||||
|
iRet = EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||||
|
if (iRet != 0) {
|
||||||
|
iRet=CocGet(pMe->pData,"tlimit",result); /* get parameter */
|
||||||
|
if (iRet<0) goto Error;
|
||||||
|
fVal = atof(result);
|
||||||
|
if (fVal != 0 && ObVal(self->pParam,UPLIMIT) > fVal) {
|
||||||
|
sprintf(pBueffel,"WARNING: upper limit is above %g, (limit of the device)", fVal);
|
||||||
|
SCWrite(pCon,pBueffel,eValue);
|
||||||
|
}
|
||||||
|
iRet=CocGet(pMe->pData,"status",result); /* get parameter */
|
||||||
|
if (iRet<0) goto Error;
|
||||||
|
SCWrite(pCon,result,eValue);
|
||||||
|
}
|
||||||
|
return iRet;
|
||||||
|
} else if (0==strcmp(pBueffel," upperlimit ")) {
|
||||||
|
if (argc > 2) {
|
||||||
|
iRet=CocGet(pMe->pData,"tlimit",result); /* get parameter */
|
||||||
|
if (iRet<0) goto Error;
|
||||||
|
fVal=atof(result);
|
||||||
|
if (atof(argv[2]) > fVal) {
|
||||||
|
sprintf(pBueffel,"ERROR: upper limit must not be higher than %g", fVal);
|
||||||
SCWrite(pCon,pBueffel,eError);
|
SCWrite(pCon,pBueffel,eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||||
|
} else if (0==strcmp(pBueffel," lowerlimit ")) {
|
||||||
|
if (argc > 2) {
|
||||||
|
if (atof(argv[2]) > ObVal(self->pParam,UPLIMIT)) {
|
||||||
|
SCWrite(pCon,"ERROR: lower limit must not be higher than upperlimit",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||||
|
} else if (NULL!=strstr(
|
||||||
|
" log send tolerance access errorhandler interrupt interest safevalue currentvalue "
|
||||||
|
, pBueffel)) {
|
||||||
|
/* forward to standard handler */
|
||||||
|
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||||
|
}
|
||||||
|
if(argc > 2) { /* set case */
|
||||||
|
iRet=CocSet(pMe->pData,argv[1],argv[2]);
|
||||||
|
if (iRet<0) goto Error;
|
||||||
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")) {
|
||||||
@ -121,20 +164,16 @@
|
|||||||
} else {
|
} else {
|
||||||
iRet=CocGet(pMe->pData,argv[1],result); /* get parameter */
|
iRet=CocGet(pMe->pData,argv[1],result); /* get parameter */
|
||||||
}
|
}
|
||||||
if (iRet<0) {
|
if (iRet<0) goto Error;
|
||||||
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
|
||||||
SCWrite(pCon,pBueffel,eError);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
sprintf(pBueffel,"%s.%s = %s\n",self->pName,
|
sprintf(pBueffel,"%s.%s = %s\n",self->pName,
|
||||||
argv[1],result);
|
argv[1],result);
|
||||||
SCWrite(pCon,pBueffel,eValue);
|
SCWrite(pCon,pBueffel,eValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
|
||||||
}
|
|
||||||
/* not reached */
|
/* not reached */
|
||||||
|
Error:
|
||||||
|
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
||||||
|
SCWrite(pCon,pBueffel,eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +331,9 @@
|
|||||||
pEVDriver pNew = NULL;
|
pEVDriver pNew = NULL;
|
||||||
pTecsDriv pMe = NULL;
|
pTecsDriv pMe = NULL;
|
||||||
pSicsVariable pInst = NULL;
|
pSicsVariable pInst = NULL;
|
||||||
char *pPort=NULL;
|
char *pPort=NULL, *pPath=NULL;
|
||||||
|
FILE *fil;
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
pNew = CreateEVDriver(argc,argv);
|
pNew = CreateEVDriver(argc,argv);
|
||||||
pMe = (pTecsDriv)malloc(sizeof(TecsDriv));
|
pMe = (pTecsDriv)malloc(sizeof(TecsDriv));
|
||||||
@ -307,10 +348,24 @@
|
|||||||
/* initalise pTecsDriver */
|
/* initalise pTecsDriver */
|
||||||
pMe->lastError = NULL;
|
pMe->lastError = NULL;
|
||||||
|
|
||||||
|
pMe->port=0;
|
||||||
pMe->server[0]='\0';
|
pMe->server[0]='\0';
|
||||||
|
|
||||||
|
pPath = IFindOption(pSICSOptions, "TecsInit");
|
||||||
|
if (pPath != NULL) {
|
||||||
|
fil=fopen(pPath, "r");
|
||||||
|
if (fil!=NULL) {
|
||||||
|
pPort=fgets(buf, sizeof(buf), fil);
|
||||||
|
if (pPort != NULL) {
|
||||||
|
pMe->port=atoi(pPort);
|
||||||
|
}
|
||||||
|
fgets(buf, sizeof(buf), fil);
|
||||||
|
fgets(pMe->server, sizeof(pMe->server), fil);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMe->port==0) {
|
||||||
/* get the port number for tecs */
|
/* get the port number for tecs */
|
||||||
pMe->port=0;
|
|
||||||
pPort = IFindOption(pSICSOptions, "TecsPort");
|
pPort = IFindOption(pSICSOptions, "TecsPort");
|
||||||
if (pPort!=NULL) {
|
if (pPort!=NULL) {
|
||||||
pMe->port=atoi(pPort);
|
pMe->port=atoi(pPort);
|
||||||
@ -318,6 +373,7 @@
|
|||||||
if (pMe->port==0) {
|
if (pMe->port==0) {
|
||||||
pMe->port=9753;
|
pMe->port=9753;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* initialise function pointers */
|
/* initialise function pointers */
|
||||||
pNew->SetValue = TecsRun;
|
pNew->SetValue = TecsRun;
|
||||||
|
Reference in New Issue
Block a user