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--;
|
||||||
printf("Status=%d. Died after %d sec", status, dif);
|
if (dif < MIN_PERIOD) {
|
||||||
|
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;
|
|
||||||
}
|
}
|
||||||
|
434
tecs/tecs.c
434
tecs/tecs.c
File diff suppressed because it is too large
Load Diff
@ -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)));
|
||||||
cnt=50;
|
if (iret) ERR_MSG(response);
|
||||||
while (iret==0 && cnt>0) {
|
cnt=50;
|
||||||
CocDelay(100);
|
while (iret==0 && cnt>0) {
|
||||||
ERR_I(iret=CocCheck(conn));
|
CocDelay(100);
|
||||||
cnt--;
|
ERR_I(iret=CocCheck(conn));
|
||||||
}
|
cnt--;
|
||||||
}
|
}
|
||||||
ERR_MSG("Does not quit within 5 seconds");
|
if (iret==0) 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,7 +569,19 @@ 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) {
|
||||||
ERR_I(GetSet(set, startTime, s1, siz1, data));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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,101 +1,114 @@
|
|||||||
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 pgscr(0, 1.0, 1.0, 1.0)
|
|
||||||
call pgscr(1, 0.0, 0.0, 0.0)
|
|
||||||
call pgscr(2, 1.0, 0.0, 0.0)
|
|
||||||
call pgscr(3, 0.0, 1.0, 0.0)
|
|
||||||
call pgscr(4, 0.0, 0.0, 1.0)
|
|
||||||
call pgscr(5, 0.0, 1.0, 1.0)
|
|
||||||
call pgscr(6, 1.0, 0.0, 1.0)
|
|
||||||
call pgscr(7, 1.0, 1.0, 0.0)
|
|
||||||
call pgscr(8, 1.0, 0.5, 0.0)
|
|
||||||
|
|
||||||
call pgqinf('TYPE', device, l)
|
call pgqinf('TYPE', device, l)
|
||||||
if (device=='NULL') then
|
if (device=='NULL') then
|
||||||
print *,'No PGPLOT-Device defined'
|
print *,'No PGPLOT-Device defined'
|
||||||
goto 9
|
goto 9
|
||||||
endif
|
endif
|
||||||
live=device(1:1)/='X' ! live switched off by default on X-Windows
|
|
||||||
|
call pgqcol(i,ncol)
|
||||||
nset=1
|
! print *,i,ncol,' colors ',device
|
||||||
l=1
|
if (ncol>=8 .and. device /= 'VT125') then
|
||||||
i=1
|
call pgscr(0, 1.0, 1.0, 1.0)
|
||||||
do while (i <= nmax)
|
call pgscr(1, 0.0, 0.0, 0.0)
|
||||||
do while (l < len(pars) .and. pars(l:l) <= ' ')
|
call pgscr(2, 1.0, 0.0, 0.0)
|
||||||
l=l+1
|
call pgscr(3, 0.0, 1.0, 0.0)
|
||||||
enddo
|
call pgscr(4, 0.0, 0.0, 1.0)
|
||||||
if (pars(l:l) > ' ') then
|
call pgscr(5, 0.0, 1.0, 1.0)
|
||||||
j=l
|
call pgscr(6, 1.0, 0.0, 1.0)
|
||||||
do while (l < len(pars) .and. pars(l:l) > ' ')
|
call pgscr(7, 1.0, 1.0, 0.0)
|
||||||
l=l+1
|
call pgscr(8, 1.0, 0.5, 0.0)
|
||||||
enddo
|
endif
|
||||||
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,22 +234,25 @@ 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
|
||||||
name=parnam(i)
|
if (retLen(i) > 0) then
|
||||||
if (name=="Tm") then
|
name=parnam(i)
|
||||||
name="Main Sensor"
|
if (name=="Tm") then
|
||||||
elseif (name=="Ts") then
|
name="Main Sensor"
|
||||||
name="Sample Sensor"
|
elseif (name=="Ts") then
|
||||||
elseif (name=="Tr") then
|
name="Sample Sensor"
|
||||||
name="SetPoint"
|
elseif (name=="Tr") then
|
||||||
|
name="SetPoint"
|
||||||
|
endif
|
||||||
|
if (sel == i) name=trim(name)//'*'
|
||||||
|
call pglen(5, trim(name), fx, fy)
|
||||||
|
call pgsci(color(i))
|
||||||
|
call pgmtxt ('L', 2.5, ey, 0.0, trim(name))
|
||||||
|
ey=ey+fy+0.04
|
||||||
endif
|
endif
|
||||||
call pglen(5, trim(name), fx, fy)
|
|
||||||
call pgsci(color(i))
|
|
||||||
call pgmtxt ('L', 2.5, ey, 0.0, trim(name))
|
|
||||||
ey=ey+fy+0.04
|
|
||||||
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
|
||||||
|
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
|
endif
|
||||||
if (tmo2>0) call sys_get_key(key, tmo2)
|
end subroutine
|
||||||
return
|
|
||||||
|
|
||||||
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
|
|
||||||
|
@ -182,7 +182,7 @@ char *SerCmd(SerChannel *serch, char *cmnd) {
|
|||||||
/* Wait for an event on tser->fd or a timeout tmo */
|
/* Wait for an event on tser->fd or a timeout tmo */
|
||||||
iret=tser->idleHdl(tser->tmo, tser->fd);
|
iret=tser->idleHdl(tser->tmo, tser->fd);
|
||||||
if (iret==0) {
|
if (iret==0) {
|
||||||
if (result==NULL) ERR_MSG("time out");
|
if (result==NULL) ERR_MSG("timeout");
|
||||||
ERR_MSG("missing terminator");
|
ERR_MSG("missing terminator");
|
||||||
}
|
}
|
||||||
ERR_SI(l=recv(tser->fd, pos, n, 0));
|
ERR_SI(l=recv(tser->fd, pos, n, 0));
|
||||||
|
142
tecsdriv.c
142
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,46 +96,85 @@
|
|||||||
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 */
|
|
||||||
iRet=CocSet(pMe->pData,argv[1],argv[2]);
|
|
||||||
if (iRet<0) {
|
|
||||||
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
|
||||||
SCWrite(pCon,pBueffel,eError);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
} else { /* get case (or command without parameter) */
|
|
||||||
if (0==strcasecmp(argv[1], "kill")) {
|
|
||||||
iRet=CocSet(pMe->pData,"quit","1"); /* send quit flag */
|
|
||||||
strcpy(result, "1");
|
|
||||||
} else {
|
|
||||||
iRet=CocGet(pMe->pData,argv[1],result); /* get parameter */
|
|
||||||
}
|
|
||||||
if (iRet<0) {
|
|
||||||
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
|
||||||
SCWrite(pCon,pBueffel,eError);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
sprintf(pBueffel,"%s.%s = %s\n",self->pName,
|
|
||||||
argv[1],result);
|
|
||||||
SCWrite(pCon,pBueffel,eValue);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
} else {
|
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
||||||
|
} else if (0==strcmp(pBueffel," list ")) {
|
||||||
|
iRet=CocGet(pMe->pData,"set",result); /* get parameter */
|
||||||
|
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);
|
||||||
|
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);
|
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;
|
||||||
|
} else { /* get case (or command without parameter) */
|
||||||
|
if (0==strcasecmp(argv[1], "kill")) {
|
||||||
|
iRet=CocSet(pMe->pData,"quit","1"); /* send quit flag */
|
||||||
|
strcpy(result, "1");
|
||||||
|
} else {
|
||||||
|
iRet=CocGet(pMe->pData,argv[1],result); /* get parameter */
|
||||||
|
}
|
||||||
|
if (iRet<0) goto Error;
|
||||||
|
sprintf(pBueffel,"%s.%s = %s\n",self->pName,
|
||||||
|
argv[1],result);
|
||||||
|
SCWrite(pCon,pBueffel,eValue);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
/* not reached */
|
/* not reached */
|
||||||
return 0;
|
Error:
|
||||||
|
sprintf(pBueffel,"ERROR: %s",ErrMessage);
|
||||||
|
SCWrite(pCon,pBueffel,eError);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
@ -292,8 +331,10 @@
|
|||||||
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));
|
||||||
memset(pMe,0,sizeof(TecsDriv));
|
memset(pMe,0,sizeof(TecsDriv));
|
||||||
@ -307,16 +348,31 @@
|
|||||||
/* initalise pTecsDriver */
|
/* initalise pTecsDriver */
|
||||||
pMe->lastError = NULL;
|
pMe->lastError = NULL;
|
||||||
|
|
||||||
|
pMe->port=0;
|
||||||
pMe->server[0]='\0';
|
pMe->server[0]='\0';
|
||||||
|
|
||||||
/* get the port number for tecs */
|
pPath = IFindOption(pSICSOptions, "TecsInit");
|
||||||
pMe->port=0;
|
if (pPath != NULL) {
|
||||||
pPort = IFindOption(pSICSOptions, "TecsPort");
|
fil=fopen(pPath, "r");
|
||||||
if (pPort!=NULL) {
|
if (fil!=NULL) {
|
||||||
pMe->port=atoi(pPort);
|
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) {
|
if (pMe->port==0) {
|
||||||
pMe->port=9753;
|
/* get the port number for tecs */
|
||||||
|
pPort = IFindOption(pSICSOptions, "TecsPort");
|
||||||
|
if (pPort!=NULL) {
|
||||||
|
pMe->port=atoi(pPort);
|
||||||
|
}
|
||||||
|
if (pMe->port==0) {
|
||||||
|
pMe->port=9753;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialise function pointers */
|
/* initialise function pointers */
|
||||||
|
Reference in New Issue
Block a user