improved tecs driver M.Z.

This commit is contained in:
cvs
2004-03-09 15:18:01 +00:00
parent 7422a261ea
commit 55848218a4
23 changed files with 1372 additions and 713 deletions

View File

@ -1,7 +1,5 @@
# this makefile delegates to a version specific makefile # this makefile delegates to a version specific makefile
# where this subdirectory is (relative to the sics root)
S_DOWN=psi/hardsup
# where root is (from here) # where root is (from here)
S_UP=../.. S_UP=../..

View File

@ -1,7 +1,5 @@
# this makefile delegates to a version specific makefile # this makefile delegates to a version specific makefile
# where this subdirectory is (relative to root)
S_DOWN=psi
# where root is # where root is
S_UP=.. S_UP=..

4
psi.c
View File

@ -309,7 +309,9 @@ static void ConfigureController(char *name, pEVControl pNew,
SConnection *pCon){ SConnection *pCon){
EVCSetPar(pNew,"upperlimit",300.0,pCon); EVCSetPar(pNew,"upperlimit",300.0,pCon);
EVCSetPar(pNew,"lowerlimit",1.0,pCon); EVCSetPar(pNew,"lowerlimit",1.0,pCon);
if(strcmp(name,"euro") == 0){ if(strcmp(name,"tecs") == 0){
TecsCustomize(pCon, pNew);
} else if(strcmp(name,"euro") == 0){
EVCSetPar(pNew,"upperlimit",750.0,pCon); EVCSetPar(pNew,"upperlimit",750.0,pCon);
EVCSetPar(pNew,"lowerlimit",15.0,pCon); EVCSetPar(pNew,"lowerlimit",15.0,pCon);
} else if(strcmp(name,"el755") == 0){ } else if(strcmp(name,"el755") == 0){

View File

@ -35,6 +35,8 @@ int CocConnect(CocConn *conn) { /* connect, but do not start */
ERR_SI(setsockopt(conn->fd,SOL_SOCKET,SO_REUSEADDR,&i,sizeof(int))); /* allow quick port reuse */ ERR_SI(setsockopt(conn->fd,SOL_SOCKET,SO_REUSEADDR,&i,sizeof(int))); /* allow quick port reuse */
i=connect(conn->fd, (struct sockaddr *)&sadr, sizeof(sadr)); i=connect(conn->fd, (struct sockaddr *)&sadr, sizeof(sadr));
if (i<0) { if (i<0) {
close(conn->fd);
conn->fd=-1;
if (errno==ECONNREFUSED) return(1); if (errno==ECONNREFUSED) return(1);
ERR_COD(errno); ERR_COD(errno);
} }
@ -132,7 +134,7 @@ int CocCheck(CocConn *conn) {
int CocTryCmd(CocConn *conn) { int CocTryCmd(CocConn *conn) {
int iret=-1, siz; int iret=-1, siz;
int j;
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
if (conn->fd<0) { if (conn->fd<0) {
ERR_I(iret=CocConnect(conn)); /* was CocOpen earlier */ ERR_I(iret=CocConnect(conn)); /* was CocOpen earlier */
@ -290,9 +292,11 @@ int CocGetArray(CocConn *conn, const char *name, float *value, int value_size) {
int CocDoIt(CocConn *conn, char *res, int res_len) { int CocDoIt(CocConn *conn, char *res, int res_len) {
StrBuf *buf; StrBuf *buf;
int i, pending; int i, pending;
float *arr;
CocArg *a; CocArg *a;
char *resp, *t, tag; char *resp, *t, tag;
int iret=0; int iret=0;
int siz;
assert(conn!=NULL); assert(conn!=NULL);
ERR_I(CocCmdWithRetry(conn)); ERR_I(CocCmdWithRetry(conn));
@ -341,7 +345,11 @@ int CocDoIt(CocConn *conn, char *res, int res_len) {
} else if (a->type==ARG_FLT) { } else if (a->type==ARG_FLT) {
ERR_I(StrGetFloat(buf, (float *)a->adr, COC_SEP)); ERR_I(StrGetFloat(buf, (float *)a->adr, COC_SEP));
} else if (a->type==ARG_ARR) { } else if (a->type==ARG_ARR) {
ERR_I(StrGetArray(buf, (float *)a->adr, a->size)); arr=(float *)a->adr;
ERR_I(siz=StrGetArray(buf, arr, a->size));
while (siz < a->size) { /* fill with zeroes */
arr[siz++]=0.0;
}
resp="<array>"; resp="<array>";
} else if (a->type==ARG_CHAR) { } else if (a->type==ARG_CHAR) {
ERR_P(StrNGet(buf, (char *)a->adr, a->size, COC_SEP)); ERR_P(StrNGet(buf, (char *)a->adr, a->size, COC_SEP));

View File

@ -5,7 +5,8 @@
#include "myc_buf.h" #include "myc_buf.h"
#define COC_CMD_LEN 256 #define COC_CMD_LEN 256
#define COC_RES_LEN 16384 /* the follwing should be larger than 4x(largest array)+length of additional parameters */
#define COC_RES_LEN 50000
int CocCreateSockAdr( int CocCreateSockAdr(
struct sockaddr_in *sockaddrPtr, /* Socket address */ struct sockaddr_in *sockaddrPtr, /* Socket address */

View File

@ -1,10 +1,15 @@
#!/bin/tcsh #!/bin/tcsh
set what="$1"
set where="$2"
set destlist=( type@osf1 \ set destlist=( type@osf1 \
AMOR@lnsa14:bin/ DMC@lnsa05:bin/ FOCUS@lnsa16:bin/ \ AMOR@lnsa14:bin/ DMC@lnsa05:bin/ FOCUS@lnsa16:bin/ \
HRPT@lnsa11:bin/ TASP@lnsa12:bin/ TRICS@lnsa18:bin/ \ HRPT@lnsa11:bin/ TRICS@lnsa18:bin/ \
lnslib@lnsa15:bin/ \ lnslib@lnsa15:bin/ \
type@linux \ type@linux \
zolliker@llc3:/afs/psi.ch/project/sinq/linux/bin/ \
TASP@pc4478:tasp_sics/ \
TOPSI@pc4120:topsi_sics/ SANS@pc3965:sans_sics/ SANS2@sans2:sans2_sics/ \ TOPSI@pc4120:topsi_sics/ SANS@pc3965:sans_sics/ SANS2@sans2:sans2_sics/ \
) )
@ -33,7 +38,9 @@ set items=(TecsServer TecsClient six keep_running cfg)
echo "" echo ""
echo " all $items" echo " all $items"
echo -n "distribute what: " echo -n "distribute what: "
if ("$what" == "") then
set what=$< set what=$<
endif
if ($what == all) then if ($what == all) then
set what=($items) set what=($items)
endif endif
@ -41,7 +48,9 @@ endif
echo "" echo ""
echo " all $dests" echo " all $dests"
echo "distribute where: " echo "distribute where: "
if ("$where" == "") then
set where=$< set where=$<
endif
if ($where == all) then if ($where == all) then
set where=($dests) set where=($dests)
endif endif

View File

@ -16,11 +16,11 @@ static Instrument list[]={
{ "TRICS", "lnsa18.psi.ch", 9753, "TRICS" , 1}, { "TRICS", "lnsa18.psi.ch", 9753, "TRICS" , 1},
{ "AMOR", "lnsa14.psi.ch", 9753, "AMOR" , 1}, { "AMOR", "lnsa14.psi.ch", 9753, "AMOR" , 1},
{ "FOCUS", "lnsa16.psi.ch", 9753, "FOCUS" , 1}, { "FOCUS", "lnsa16.psi.ch", 9753, "FOCUS" , 1},
{ "TASP", "lnsa12.psi.ch", 9753, "TASP", 1}, { "TASP", "pc4478.psi.ch", 9753, "TASP", 1},
{ "TASP0", "lnsa09.psi.ch", 9753, NULL , 0},
{ "RITA", "pc4345.psi.ch", 9753, NULL , 0}, { "RITA", "pc4345.psi.ch", 9753, NULL , 0},
{ "PREP", "lnsa15.psi.ch", 9753, "lnsg" , 2}, { "PREP", "lnsa15.psi.ch", 9751, "lnsg" , 2},
{ "AREA", "lnsa15.psi.ch", 9751, "lnsg" , 2}, { "PREP2", "lnsa15.psi.ch", 9756, "lnsg" , 2},
{ "AREA", "lnsa15.psi.ch", 9757, "lnsg" , 2},
{ "TEST", "lnsa15.psi.ch", 9755, "lnslib", 2} { "TEST", "lnsa15.psi.ch", 9755, "lnslib", 2}
}; };
@ -61,6 +61,8 @@ int InstrHost(char *input, char *instr, char *host, char *user, char *pcod
lnscode=getenv("LNSCODE"); lnscode=getenv("LNSCODE");
if (lnscode == NULL) { if (lnscode == NULL) {
sprintf(pcod, "%02dlns%d", tim.tm_year % 100, tim.tm_mon/6+1); sprintf(pcod, "%02dlns%d", tim.tm_year % 100, tim.tm_mon/6+1);
} else if (strlen(lnscode)==3) {
sprintf(pcod, "%c%clns%c", lnscode[0], lnscode[1], lnscode[2]);
} else { } else {
sprintf(pcod, "%02dlns%s", tim.tm_year % 100, lnscode); sprintf(pcod, "%02dlns%s", tim.tm_year % 100, lnscode);
} }

View File

@ -24,12 +24,6 @@ TECLI_OBJ =tecs_client.o tecs_plot.o str.o instr_hosts.o \
HARDSUPLIB = ../hardsup/libhlib.a HARDSUPLIB = ../hardsup/libhlib.a
#.f.o:
# $(FC) $(FFLAGS) -c $F
#
#.c.o:
# $(CC) $(CFLAGS) -c $C
libtecsl.a: $(CLI_OBJ) libtecsl.a: $(CLI_OBJ)
rm -f $@ rm -f $@
$(AR) $(ARFLAGS) $@ $Q $(AR) $(ARFLAGS) $@ $Q
@ -43,6 +37,10 @@ test: tecs_cli.c
TecsServer: $(SERV_OBJ) $(HARDSUPLIB) $(FORTIFYOBJ) TecsServer: $(SERV_OBJ) $(HARDSUPLIB) $(FORTIFYOBJ)
$(CC) $(CFLAGS) -o $@ $Q -lm $(CC) $(CFLAGS) -o $@ $Q -lm
lsc331: lsc331.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o \
$(LIBR_OBJ) $(HARDSUPLIB) $(FORTIFYOBJ)
$(CC) $(CFLAGS) -o $@ $Q -lm
TecsClient: $(TECLI_OBJ) $(FORTIFYOBJ) TecsClient: $(TECLI_OBJ) $(FORTIFYOBJ)
$(FC) -o $@ $Q $(PGLIB) $(RDLIB) $(FC) -o $@ $Q $(PGLIB) $(RDLIB)
@ -79,12 +77,6 @@ six: six.c term.o sys_select.o libtecsl.a
rexstart: rstart.c myc_str.o myc_err.o instr_hosts.o rexstart: rstart.c myc_str.o myc_err.o instr_hosts.o
$(CC) $(CFLAGS) -o $@ $Q $(FORTIFYOBJ) $(CC) $(CFLAGS) -o $@ $Q $(FORTIFYOBJ)
@ echo "$(PWD)/rstart" @ echo "$(PWD)/rstart"
#
#serverd: serverd.c myc_str.o myc_err.o coc_util.o myc_buf.o
# $(CC) $(CFLAGS) -o $@ $Q $(FORTIFYOBJ)
#
#starts: starts.c myc_str.o myc_err.o coc_util.o myc_buf.o
# $(CC) $(CFLAGS) -o $@ $Q $(FORTIFYOBJ)
clean: clean:
rm -f *.o *.a six keep_running TecsServer TecsClient rm -f *.o *.a six keep_running TecsServer TecsClient

View File

@ -1,8 +1,6 @@
# this makefile delegates to a version specific makefile # this makefile delegates to a version specific makefile
# where this subdirectory is (relative to the sics root)
S_DOWN=psi/tecs
# where root is (from here) # where root is (from here)
S_UP=../.. S_UP=../..
include $(S_UP)/make_forward include ../../make_forward

View File

@ -5,7 +5,7 @@
# Markus Zolliker, March 2003 # Markus Zolliker, March 2003
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
include ../../linux_def include $(SRC)../../linux_def
SICST=.. SICST=..
SICS=$(SRC).. SICS=$(SRC)..

View File

@ -25,7 +25,8 @@ int mycDate(int time);
int mycTime(int date); int mycTime(int date);
/* /*
does the inverse of MycDate. Chooses the last possible date not later than today does the inverse of MycDate. Chooses the last possible date not later than today,
if day, month or year is undefined (zero)
*/ */
/* the following subroutines are to be called from FORTRAN /* the following subroutines are to be called from FORTRAN

View File

@ -22,7 +22,8 @@ static char pswd1[32]="";
static char user2[32]=""; static char user2[32]="";
static char pswd2[32]=""; static char pswd2[32]="";
void Usage(void) { void Usage(int cmds_only) {
if (!cmds_only) {
printf("\n"); printf("\n");
printf(" six commandline options:\n"); printf(" six commandline options:\n");
printf(" - login as spy\n"); printf(" - login as spy\n");
@ -36,13 +37,17 @@ void Usage(void) {
printf(" -s or s simulation mode (on some instruments)\n"); printf(" -s or s simulation mode (on some instruments)\n");
printf(" -w or w do not skip welcome message\n"); printf(" -w or w do not skip welcome message\n");
printf(" -h \"host\" connect to a SICServer on a different host\n"); printf(" -h \"host\" connect to a SICServer on a different host\n");
printf(" -p \"port\" connect to a SICServer on a different port\n");
printf(" -n do not login\n");
printf(" no option login with default privilege\n"); printf(" no option login with default privilege\n");
}
printf("\n"); printf("\n");
printf(" Special commands treated by six (these are no SICS commands!)\n"); printf(" Special commands treated by six (these are no SICS commands!)\n");
printf("\n"); printf("\n");
printf(" quit exit six\n"); printf(" quit exit six\n");
printf(" exit exit six\n"); printf(" exit exit six\n");
printf(" stop interrupt SICS\n"); printf(" stop interrupt SICS\n");
printf(" help show this help text\n");
printf(" + increase privilege\n"); printf(" + increase privilege\n");
printf(" - decrease privilege\n"); printf(" - decrease privilege\n");
printf("\n"); printf("\n");
@ -350,7 +355,7 @@ int setrights(int gotolevel) {
level=gotolevel; level=gotolevel;
ERR_I(sendCmd(fd, "config list")); ERR_I(sendCmd(fd, "config list"));
ERR_P(p=readWrite(fd,10000,1,"UserRights = ")); ERR_P(p=readWrite(fd,10000,1,"UserRights = "));
if (p!=NULL) { if (*p!='\0') {
level=*p-'0'; level=*p-'0';
} }
if (level==3) { if (level==3) {
@ -393,11 +398,11 @@ int setrights(int gotolevel) {
int main (int argc, char *argv[]) { int main (int argc, char *argv[]) {
int iret, pos; int iret, pos;
fd_set mask; fd_set mask;
int l, i, j, port, skip, gotolevel; int l, i, j, port, skip, gotolevel, sicslogin;
char buf[128], lbuf[16], ilow[64]; char buf[128], lbuf[16], ilow[64];
char stdPrompt[128], prompt[256]; char stdPrompt[128], prompt[256];
char *sim=""; char *sim="";
char *p, *statusMatch; char *p, *statusMatch=NULL;
char *pnam[4]={"0", "MANAGER", "user", "spy"}; char *pnam[4]={"0", "MANAGER", "user", "spy"};
struct sockaddr_in sadr; struct sockaddr_in sadr;
@ -407,6 +412,7 @@ int main (int argc, char *argv[]) {
printf("---------------------------------------------------\n"); printf("---------------------------------------------------\n");
port=1301; port=1301;
skip=1; skip=1;
sicslogin=1;
j=0; j=0;
deflevel=0; deflevel=0;
gotolevel=0; gotolevel=0;
@ -434,27 +440,40 @@ int main (int argc, char *argv[]) {
gotolevel=2; gotolevel=2;
deflevel=2; deflevel=2;
} else if (0==strcmp(argv[i], "help")) { } else if (0==strcmp(argv[i], "help")) {
Usage(); Usage(0);
return 0; return 0;
} else if (0==strcmp(argv[i], "-h")) { } else if (0==strcmp(argv[i], "-h")) {
i++; i++;
if (i>=argc) { if (i>=argc) {
printf("missing host\n"); printf("missing host\n");
Usage(); return 0; Usage(0); return 0;
} }
host=argv[i]; host=argv[i];
} else if (0==strcmp(argv[i], "-p")) {
i++;
if (i>=argc) {
printf("missing port\n");
Usage(0); return 0;
}
port=atoi(argv[i]);
if (port == 0) {
printf("illegal port\n");
Usage(0); return 0;
}
} else if (0==strcmp(argv[i], "-n")) {
sicslogin=0;
} else { } else {
if (strlen(argv[i])>=32) { if (strlen(argv[i])>=32) {
printf("argument too long\n"); printf("argument too long\n");
Usage(); return 0; Usage(0); return 0;
} else if (argv[i][0]!='-') { } else if (argv[i][0]!='-') {
if (j==0) { if (j==0) {
printf("syntax has changed, username can not be given as argument\n"); printf("syntax has changed, username can not be given as argument\n");
Usage(); j=1; Usage(0); j=1;
} }
} else { } else {
printf("unknown option: %s\n", argv[i]); printf("unknown option: %s\n", argv[i]);
Usage(); return 0; Usage(0); return 0;
} }
} }
} }
@ -462,6 +481,7 @@ int main (int argc, char *argv[]) {
ERR_SI(fd=socket(AF_INET, SOCK_STREAM, 0)); ERR_SI(fd=socket(AF_INET, SOCK_STREAM, 0));
term_reg_socket(fd); term_reg_socket(fd);
ERR_SI(connect(fd, (struct sockaddr *)&sadr, sizeof(sadr))); ERR_SI(connect(fd, (struct sockaddr *)&sadr, sizeof(sadr)));
if (sicslogin) {
ERR_I(sendCmd(fd, "sicslogin Spy 007")); ERR_I(sendCmd(fd, "sicslogin Spy 007"));
ERR_P(p=readWrite(fd,10000,skip,"SICS")); ERR_P(p=readWrite(fd,10000,skip,"SICS"));
if (*p=='\0') { if (*p=='\0') {
@ -495,6 +515,11 @@ int main (int argc, char *argv[]) {
ERR_I(sendCmd(fd, "status")); ERR_I(sendCmd(fd, "status"));
ERR_P(p=readWrite(fd,10000,0,"status = ")); ERR_P(p=readWrite(fd,10000,0,"status = "));
} else {
sprintf(stdPrompt, "six[%s] ", host);
p="E";
}
iret=1; iret=1;
buf[0]='\0'; buf[0]='\0';
pos=0; pos=0;
@ -514,7 +539,7 @@ int main (int argc, char *argv[]) {
str_lowcase(lbuf, buf); str_lowcase(lbuf, buf);
if (0==strcmp(lbuf,"quit")) break; if (0==strcmp(lbuf,"quit")) break;
if (0==strcmp(lbuf,"exit")) break; if (0==strcmp(lbuf,"exit")) break;
statusMatch="status = "; if (sicslogin) statusMatch="status = ";
skip=0; skip=0;
printf("\n"); printf("\n");
if (0==strcmp(lbuf,"stop")) { if (0==strcmp(lbuf,"stop")) {
@ -542,14 +567,16 @@ int main (int argc, char *argv[]) {
} }
skip=1; skip=1;
strcpy(buf, "status"); strcpy(buf, "status");
} else if (0==strcmp(buf, "help")) {
Usage(1);
strcpy(buf, "status");
} else if (0==strcmp(buf, "six help")) { } else if (0==strcmp(buf, "six help")) {
Usage(); Usage(0);
strcpy(buf, "status"); strcpy(buf, "status");
} else if (0==strcmp(buf, "")) { } else if (0==strcmp(buf, "")) {
strcpy(buf, "status"); strcpy(buf, "status");
statusMatch=NULL; statusMatch=NULL;
} }
ERR_I(sendCmd(fd, buf)); ERR_I(sendCmd(fd, buf));
ERR_P(p=readWrite(fd,1000,skip,statusMatch)); ERR_P(p=readWrite(fd,1000,skip,statusMatch));
buf[0]='\0'; buf[0]='\0';
@ -559,12 +586,14 @@ int main (int argc, char *argv[]) {
} else { /* socket iret ready to read */ } else { /* socket iret ready to read */
assert(fd==iret); assert(fd==iret);
ERR_P(p=readWrite(fd,1000,0,"status = ")); ERR_P(p=readWrite(fd,1000,0,"status = "));
if (strcmp(p, "0") == 0) {
printf("\nconnection lost\n");
break;
}
} }
} }
fputs("\n", stdout); fputs("\n", stdout);
term_save_hist(1); /* save history wihtout last line */ term_save_hist(1); /* save history without last line */
return 0;
Usage:
return 0; return 0;
OnError: OnError:
ErrShow("end"); ErrShow("end");

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@ pTecsClient TeccStart(char *startcmd, char *host, int port) {
gethostname(thishost, sizeof(thishost)); gethostname(thishost, sizeof(thishost));
th=getenv(thishost); th=getenv(thishost);
if (th==NULL) th=thishost; if (th==NULL) th=thishost;
if (0!=strcmp(th, host)) { if (0!=strcmp(th, host) && host!=strstr(host, th)) {
code=rdCode; code=rdCode;
cmd=""; cmd="";
} }
@ -36,7 +36,9 @@ pTecsClient TeccStart(char *startcmd, char *host, int port) {
ERR_I(iret=CocInitClient(conn, host, port, code, 0, cmd)); ERR_I(iret=CocInitClient(conn, host, port, code, 0, cmd));
if (iret==1) ErrShort("TECS_INIT: can not connect to TecsServer"); if (iret==1) ErrShort("TECS_INIT: can not connect to TecsServer");
return((pTecsClient)conn); return((pTecsClient)conn);
OnError: return(NULL); OnError:
if (conn!=NULL) FREE(conn);
return NULL;
} }
pTecsClient TeccInit(char *startcmd, int port) { pTecsClient TeccInit(char *startcmd, int port) {
@ -215,7 +217,8 @@ int F_FUN(tecs_get_mult)(F_CHAR(names), int *time, int *nvalues, float values[],
while (nams!=NULL && i < *nvalues) { while (nams!=NULL && i < *nvalues) {
nams=str_split(nam, nams, ' '); nams=str_split(nam, nams, ' ');
if (nam[0]!='\0') { if (nam[0]!='\0') {
ERR_I(CocGetFloat(conn, nam, values+i)); values[i]=DATA_UNDEF;
CocGetFloat(conn, nam, values+i);
i++; i++;
} }
} }
@ -303,7 +306,7 @@ int F_FUN(tecs_get_data)(F_CHAR(names), int *startTime, int *endTime, int *step,
, int retLen[], int names_len) { , int retLen[], int names_len) {
char nam[64]; char nam[64];
char str[128]; char str[128];
float offset, fact, *py, data[8192]; float offset, fact, *py, data[COC_RES_LEN/4-100];
int i, j, k, l, iret; int i, j, k, l, iret;
if (*endTime - *startTime > *step * (*maxLen-1)) { if (*endTime - *startTime > *step * (*maxLen-1)) {

View File

@ -37,10 +37,12 @@
oneCommand=.true. oneCommand=.true.
port=instr_host(line, inst, host, user, pcod) port=instr_host(line, inst, host, user, pcod)
else else
call sys_getenv('HOST', line)
port=instr_host(line, inst, host, user, pcod)
oneCommand=.false. oneCommand=.false.
port=0
endif endif
call sys_getenv('TECS_START', start) call sys_getenv('TECS_START', start)
if (port .gt. 0) then if (port .gt. 0) then
if (port .eq. 1) port=9753 if (port .eq. 1) port=9753
@ -60,26 +62,12 @@
if (oneCommand) goto 11 if (oneCommand) goto 11
print * line='tecs'
print *,'Tecs Client' line(52-i:64)='connected to '//inst(1:i)
print *,'-----------' print '(x,64(''-''))'
print * print '(x,a)',line(1:64)
print *,'set <temp> set temperature' print '(x,64(''-''))'
print *,'send <command> direct command to LSC340' print '(33x,a)','type help for a list of commands'
print *,'device <device> set cryo device'
print *,'<parameter> show parameter'
print *,'<parameter> <value> set parameter'
print *
print *,'<empty line> show summary'
print *,'plot <var> chart for temperature and <var>'
1 ,' var = P (default), He, Aux'
print *,'log <n> show last n lines of logfile'
print *,'remote set to remote mode'
print *,'reset reset alarms'
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 * print *
l=0 l=0
@ -180,7 +168,26 @@
call tecs_plot(' ') call tecs_plot(' ')
elseif (cmd .eq. 'help') then elseif (cmd .eq. 'help') then
print * print *
print *,'Writeable parameters:' print *,'tecs client commands (can not be used from SICS)'
print *
print *,'<empty line> show summary'
print *,'plot chart for temperature'
print *,'log <n> show last n lines of logfile'
print *,'remote set to remote mode'
print *,'reset reset alarms'
print *,'kill shut down TecsServer'
print *,'restart restart TecsServer'
print *,'exit, quit exit tecs client'
print *
print *,'commands/parameters:'
print *
print *,' From tecs: <parameter> show parameter'
print *,' <parameter> <value> set parameter'
print *
print *,' From SICS: tt <parameter> show parameter'
print *,' tt <parameter> <value> set parameter'
print *
print *,'changeable parameters:'
print * print *
print *,'set temperature set-point' print *,'set temperature set-point'
print *,'device temperature device' print *,'device temperature device'
@ -193,14 +200,15 @@
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 *,'tLimit temperature limit'
! print *,'remoteMode 1: local, 2: remote' ! print *,'remoteMode 1: local, 2: remote'
print *,'send direct command to LSC340'
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 *,'Tr set-point on regulation' print *,'Tr set-point on regulation'
print *,'tLimit temperature limit'
print *,'helium helium level' print *,'helium helium level'
print *,'htr heater current percentage' print *,'htr heater current percentage'
print *,'resist heater resistance' print *,'resist heater resistance'

View File

@ -204,6 +204,7 @@ int Put(Set *set, int time, float value) {
int t, try = 1; int t, try = 1;
int size; int size;
float last; float last;
static int errcnt=0;
ERR_P(set); ERR_P(set);
if (value == DATA_UNDEF) return 0; if (value == DATA_UNDEF) return 0;
@ -221,9 +222,13 @@ int Put(Set *set, int time, float value) {
} }
if (t<0) { if (t<0) {
if (t<-1) { if (t<-1) {
if (errcnt<4) {
errcnt++;
logfileOut(LOG_MAIN, "%s %d <? %d\n", set->set.name, time, r->endTime); logfileOut(LOG_MAIN, "%s %d <? %d\n", set->set.name, time, r->endTime);
}
ERR_MSG("back in time not possible"); ERR_MSG("back in time not possible");
} }
if (errcnt>0) errcnt--;
t=0; t=0;
} }
if (t == 0) { if (t == 0) {

View File

@ -1,10 +1,11 @@
subroutine tecs_plot(auxpar) subroutine tecs_plot(reserved)
character*(*) auxpar character*(*) reserved
integer dmax, nmax, tmax, amax, nmenu, chartperiod, naux integer dmax, nmax, nmenu, chartperiod, naux, nwin
parameter (dmax=400, nmax=10, tmax=9, amax=3, nmenu=13 parameter (dmax=1024, nmax=12, nmenu=13, nwin=4
1 , chartperiod=5, naux=1) 1 , chartperiod=5, naux=1)
! dmax*nmax*4 should be less than COC_RES_LEN in coc_util.h
integer minRange, maxRange, oneDay integer minRange, maxRange, oneDay
parameter (minRange=60, maxRange=7*24*3600, oneDay=24*3600) parameter (minRange=60, maxRange=7*24*3600, oneDay=24*3600)
integer zoom, right, live integer zoom, right, live
@ -12,74 +13,95 @@
real winmin, undef real winmin, undef
parameter (winmin=60., undef=-1.125/1024./1024./1024.) 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(nwin),ymax(nwin),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,menuwid real*4 ex,ey,fx,fy,row,ticks,tim0,tim1,menuwid
real*4 dx,dy real*4 dx,dy
integer l,j,i,n,t,leng,i1,i2,rl,startday,thisday real*4 ylim(nmax) ! limits of sensor label text
integer ncol, nset, mode integer l,j,n,t,leng,i1,i2,rl,startday,thisday
integer iostat
integer nset
integer ncol, mode
integer is ! 1...nset
integer im ! 1...nmax
integer first,last,step,tbase,lastj integer first,last,step,tbase,lastj
integer colorList(nmax)/5,3,2,4,6,8,14,15,9,8/
integer color(nmax)
integer retLen(nmax) integer retLen(nmax)
integer sel/0/, sel1, sel2, auxsel/1/ logical focus(nmax)/3*.true.,9*.false./
logical omit(nmax)/12*.false./
logical fixleft/.false./
integer winconf(nwin) ! number of windows below actual
integer showsets
real winh
integer nticks
character key*1 character key*1
character text(2,nmenu)*16/ character text(2,nmenu)*16/
1 'L' ,'live off' 1 'L' ,'live off'
1 ,'z' ,'sel. zoom' 1 ,'z' ,'sel. zoom'
1 ,'+' ,'zoom in' 1 ,'+' ,'zoom in'
1 ,'-' ,'zoom out' 1 ,'-' ,'zoom out'
1 ,'x' ,'show all'
1 ,'2d' ,'2 days' 1 ,'2d' ,'2 days'
1 ,'1h' ,'1 hour' 1 ,'1h' ,'1 hour'
1 ,'15m' ,'15 min' 1 ,'15m' ,'15 min'
1 ,'31.7t','goto date' 1 ,'31.7t','goto date'
1 ,'c' ,'show P/He/Aux' 1 ,'a' ,'all chan'
1 ,'s' ,'select T' 1 ,'c' ,'clear chan'
1 ,'s' ,'focus'
1 ,'f' ,'write file' 1 ,'f' ,'write file'
1 ,'q' ,'quit'/ 1 ,'q' ,'quit'/
character weekdays(7)*4/ character weekdays(7)*4/
1 'Mon','Tue','Wed','Thu','Fri','Sat','Sun'/ 1 '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
character title*64, pars*64 character title*64, pars*64, allpars*64
character*4 tpar(tmax)/'Te','Tr','Tm','Ts','Tk','T1','T2','T3','T4'/ character*4 parnam(nmax)
character*4 apar(amax)/'P', 'He', 'Aux'/ 1 /'Tm','Ts','Tr','Te','Tk','T1','T2','T3','T4','P','He','Aux'/
character*16 parnam(nmax) integer unit(nmax)
1 / 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4/ ! 1: Kelvin, 2: Watt, 3: %, 4: other
integer color(nmax)
1 / 2, 4, 3, 5, 6, 8, 14, 15, 13, 2, 2, 2/
integer isx(nmax)/12*1/ ! at begin all channels selected
integer imx(nmax)
save imx
integer idx(nmax)
logical gap, done logical gap, done
logical saveit logical saveit
integer iret, lund, numl, mon, day integer iret, lund, numl, mon, day
integer pars_len, title_len, text_len, name_len integer pars_len, title_len, text_len, name_len
integer idx(nmax)
character line*132 character line*132
real x0 real x0
logical loop logical loop
integer tdif
integer fact
! functions ! functions
integer myc_now, myc_time, myc_date, get_data integer myc_now, myc_time, myc_date, get_data
integer tecs_get_mult, tecs_get_par integer tecs_get_mult, tecs_get_par
integer pgopen
data window/0./ data window/0./
fact=1
read(reserved, *, iostat=iostat) fact
if (fact .lt. 1) fact=1
if (window .eq. 0) window=1800. if (window .eq. 0) window=1800.
saveit=.false. saveit=.false.
mode=live mode=live
call pgopen(' ') iret=pgopen(' ')
call pgqinf('TYPE', device, l) call pgqinf('TYPE', device, l)
if (device .eq. 'NULL') then if (device .eq. 'NULL' .or. iret .le. 0) then
call pgclos call pgclos
call pgopen('?') iret=pgopen('?')
call pgqinf('TYPE', device, l) call pgqinf('TYPE', device, l)
if (device .eq. 'NULL') then if (device .eq. 'NULL' .or. iret .le. 0) then
print *,'No PGPLOT-Device defined' print *,'No PGPLOT-Device defined'
goto 9 goto 9
endif endif
call sys_setenv('PGPLOT_DEV', '/'//device) call sys_setenv('PGPLOT_DEV', '/'//device)
endif endif
call pgqcol(i,ncol) call pgqcol(j,ncol)
! print *,i,ncol,' colors ',device ! print *,j,ncol,' colors ',device
if (ncol .ge. 8 .and. device .ne. 'VT125') then if (ncol .ge. 8 .and. device .ne. '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)
@ -97,38 +119,67 @@
l=0 l=0
x1=0 x1=0
step=0 step=0
do i=1,amax allpars=' '
if (auxpar .eq. apar(i)) then do im=1,nmax
auxsel=i call str_trim(allpars, allpars, l)
allpars=allpars(1:l)//' '//parnam(im)
enddo
showsets=1
1 continue
iret=tecs_get_mult(allpars, t, nmax, yy1)
if (iret .lt. 0) goto 99
tdif=myc_now()-t
tdif=tdif-mod(tdif+1800*25, 3600)+1800 ! round to next full hour
if (tdif .ne. 0) then
print *,'time difference ',tdif
endif
t=t+tdif
if (showsets .eq. 1) then ! select only channels which have NOW a signal
do im=1,nmax
if (isx(im) .eq. 0 .and. yy1(im) .ne. undef) then
isx(im)=1
endif endif
enddo enddo
else if (showsets .eq. 2) then ! select all channels
1 pars=' ' do im=1,nmax
nset=0 isx(im)=1
do i=1,tmax
nset=nset+1
color(nset)=colorList(i)
parnam(nset)=tpar(i)
call str_trim(pars, pars, pars_len)
pars=pars(1:pars_len)//' '//parnam(nset)
enddo enddo
nset=nset+1 endif
color(nset)=colorList(3) is=0
parnam(nset)=apar(auxsel) pars=' '
do im=1,nmax
if (omit(im)) then
isx(im)=0
omit(im)=.false.
else if (isx(im) .ne. 0) then
is=is+1
isx(im)=is
imx(is)=im
call str_trim(pars, pars, pars_len) call str_trim(pars, pars, pars_len)
pars=pars(1:pars_len)//' '//parnam(nset) pars=pars(1:pars_len)//' '//parnam(im)
endif
enddo
nset=is
iret=tecs_get_mult(pars, t, nset, yy0)
if (iret .lt. 0) goto 99
if (window .eq. 0) then if (window .eq. 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 (mode .ge. right) then else if (mode .ge. right) then
last=t
if (fixleft) then
window=last-tbase-x1
fixleft=.false.
endif
step=window/(dmax-2)+0.99 step=window/(dmax-2)+0.99
last=t last=t
first=t-min(dmax*step-1,nint(window)) first=t-min(dmax*step-1,nint(window))
if (first .ne. t-nint(window)) then
print *,'t-shift',first-(t-nint(window))
endif
else else
if (mode .eq. zoom) then if (mode .eq. zoom) then
x2=(x1+x2+window)/2 x2=(x1+x2+window)/2
@ -153,7 +204,7 @@
first=last-(last-first+step-1)/step*step ! round first first=last-(last-first+step-1)/step*step ! round first
! print *,step,last-first ! print *,step,last-first
tbase=first-mod(first,7*oneDay) tbase=first-mod(first,7*oneDay)
iret=get_data(pars, first, last, step, tbase iret=get_data(pars, first-tdif, last-tdif, step*fact, tbase-tdif
1 , xd, yd, dmax, nmax, retLen) 1 , xd, yd, dmax, nmax, retLen)
if (iret .lt. 0) goto 99 if (iret .lt. 0) goto 99
@ -164,47 +215,112 @@
x1 = first - tbase x1 = first - tbase
endif endif
tim0=t-tbase tim0=t-tbase
do i=1,nset
leng=retLen(i) do is=1,nset
do while (leng .gt. 1 .and. yd(leng,i) .eq. undef) im=imx(is)
leng=retLen(is)
do while (leng .gt. 1 .and. yd(leng,is) .eq. undef)
leng=leng-1 leng=leng-1
enddo enddo
if (leng .eq. 1) leng=0 if (leng .eq. 1) leng=0
retLen(i)=leng retLen(is)=leng
if (mode .eq. live .and. leng .gt. 0) then yy0(is)=yy1(im)
xd(leng,i)=tim0 if (leng .gt. 0) then
yd(leng,i)=yy0(i) if (mode .eq. live) then
xd(leng,is)=tim0
yd(leng,is)=yy0(is)
endif
omit(im)=.false.
! else if (showsets .eq. 2) then ! next time omit unused channels
! omit(im)=.true.
endif endif
enddo enddo
if (sel .ne. 0) then
do while (sel .lt. nset .and. retLen(sel) .eq. 0) showsets=0
sel=sel+1
j=0
do im=1,nmax
is=isx(im)
if (focus(im)) then
if (is .ne. 0 .and. unit(im) .eq. 1) then
if (retLen(is) .gt. 0) then
j=j+1 ! focus o.k.
goto 2
endif
endif
focus(im)=.false.
if (j .eq. 0 .and. im .lt. nmax) focus(im+1)=.true.
2 continue
endif
enddo
if (j .eq. 0) then ! no T-channel in focus: select all
do is=1,nset
im=imx(is)
if (retLen(is) .gt. 0 .and. unit(im) .eq. 1) focus(im)=.true.
enddo enddo
if (sel .ge. nset) sel = 0
endif endif
if (saveit) goto 9 if (saveit) goto 9
if (mode .eq. live) then if (mode .eq. live) then
x2=max(tim0,x2)+min(1800., window*0.5) x2=max(tim0,x2)+min(1800., window*0.5)
endif endif
if (window .gt. 50*3600) then if (window .gt. 36*3600) then
ticks=8*3600 ticks=12*3600
elseif (window .gt. 25*3600) then if (window .lt. 60*3600) then
ticks=4*3600 nticks=6
else else
ticks=0.0 ! automatic nticks=2
endif
elseif (window .gt. 18*3600) then
ticks=6*3600
if (window .lt. 30*3600) then
nticks=6
else
nticks=3
endif
elseif (window .gt. 10*3600) then
ticks=2*3600
nticks=2
elseif (window .gt. 3*3600) then
ticks=3600
if (window .lt. 5*3600) then
nticks=6
else
nticks=2
endif
elseif (window .gt. 6000) then
ticks=1200
nticks=2
elseif (window .gt. 1800) then
ticks=600
if (window .lt. 3600) then
nticks=5
else
nticks=2
endif
elseif (window .gt. 900) then
ticks=300
nticks=5
elseif (window .gt. 600) then
ticks=120
nticks=2
elseif (window .gt. 120) then
ticks=60
if (window .lt. 300) then
nticks=6
else
nticks=2
endif
else
ticks=30
nticks=3
endif endif
i1=1 do rl=1,nwin
i2=nset-naux winconf(rl)=nwin-rl ! number of windows to follow
if (sel .eq. 0) then enddo
sel1=i1
sel2=i2 do rl=1,nwin
else
sel1=sel
sel2=sel
endif
do rl=1,2
if (mode .eq. zoom .and. rl .eq. 1) then if (mode .eq. zoom .and. rl .eq. 1) then
ymin(1)=y1 ymin(1)=y1
ymax(1)=y2 ymax(1)=y2
@ -213,19 +329,22 @@
ymax(rl)=-1e30 ymax(rl)=-1e30
ylast1=ymin(rl) ylast1=ymin(rl)
ylast2=ymax(rl) ylast2=ymax(rl)
do i=sel1,sel2 do is=1,nset
do j=1,retLen(i) im=imx(is)
if (yd(j,i) .ne. undef) then if (unit(im) .eq. rl .and. (focus(im) .or. rl .gt. 1)) then
ymin(rl)=min(ymin(rl),yd(j,i)) do j=1,retLen(is)
ymax(rl)=max(ymax(rl),yd(j,i)) if (yd(j,is) .ne. undef) then
ymin(rl)=min(ymin(rl),yd(j,is))
ymax(rl)=max(ymax(rl),yd(j,is))
endif endif
enddo enddo
do j=max(1,retLen(i)-4),retLen(i) do j=max(1,retLen(is)-4),retLen(is)
if (yd(j, i) .ne. undef) then if (yd(j,is) .ne. undef) then
ylast1=min(ylast1,yd(j, i)) ylast1=min(ylast1,yd(j, is))
ylast2=max(ylast2,yd(j, i)) ylast2=max(ylast2,yd(j, is))
endif endif
enddo enddo
endif
enddo enddo
ey=(ymax(rl)-ymin(rl)) ey=(ymax(rl)-ymin(rl))
@ -239,89 +358,109 @@
endif endif
if (ymax(rl) .lt. ymin(rl)) then if (ymax(rl) .lt. ymin(rl)) then
do j=1,rl-1
winconf(j)=winconf(j)-1
enddo
ymax(rl)=1.0 ymax(rl)=1.0
ymin(rl)=0 ymin(rl)=0
elseif (ymax(rl) .eq. ymin(rl)) then elseif (ymax(rl) .eq. ymin(rl)) then
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
enddo
call set_win(rl,x1,x2,ymin(rl),ymax(rl)) winh=0.9/(winconf(1)+3.5)
do i=i1,i2 do rl=1,nwin
call pgsci(color(i))
if (rl .gt. 1) then
if (winconf(rl) .eq. winconf(rl-1)) goto 6 ! window empty
endif
call set_win(rl,winh,winconf,x1,x2,ymin(rl),ymax(rl))
do is=nset,1,-1
im=imx(is)
if (unit(im) .eq. rl) then
call pgsci(color(im))
l=0 l=0
lastj=1 lastj=1
do j=1,retLen(i) do j=1,retLen(is)
if (yd(j,i) .eq. undef) then if (yd(j,is) .eq. undef) then
if (j .gt. lastj) then if (j .gt. lastj) then
call pgline(j-lastj, xd(lastj,i), yd(lastj,i)) call pgline(j-lastj, xd(lastj,is), yd(lastj,is))
endif endif
lastj=j+1 lastj=j+1
else else
l=j l=j
endif endif
enddo enddo
if (retLen(i) .gt. lastj) if (retLen(is) .gt. lastj)
1 call pgline(retLen(i)+1-lastj, xd(lastj,i), yd(lastj,i)) 1 call pgline(retLen(is)+1-lastj, xd(lastj,is), yd(lastj,is))
retLen(i)=l retLen(is)=l
endif
enddo enddo
call pgsci(1) call pgsci(1)
if (rl .eq. 1) then if (rl .eq. 1) then
call pgsch(1.0) call pgsch(1.0)
call pgtbox('ZHXYBINST', ticks, 0, 'BCINMST', 0.0, 0) call pgtbox('ZHXYBINST', ticks, nticks, 'BCINMST1', 0.0, 0)
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 is=1,nset
if (retLen(i) .gt. 0) then im=imx(is)
name=parnam(i) if (unit(im) .eq. rl .and. retLen(is) .gt. 0) then
name=parnam(im)
if (name .eq. 'Tm') then if (name .eq. 'Tm') then
name='Main Sensor' name='Main'
elseif (name .eq. 'Ts') then elseif (name .eq. 'Ts') then
name='Sample Sensor' name='Sample'
elseif (name .eq. 'Tr') then elseif (name .eq. 'Tr') then
name='SetPoint' name='Set'
endif endif
call str_trim(name, name, name_len) call str_trim(name, name, name_len)
if (sel .eq. i) then if (focus(im)) then
name=name(1:name_len)//'*' name=name(1:name_len)//'*'
call str_trim(name, name, name_len) call str_trim(name, name, name_len)
endif endif
call pglen(5, name(1:name_len), fx, fy) call pglen(5, name(1:name_len), fx, fy)
call pgsci(color(i)) call pgsci(color(im))
call pgmtxt ('L', 2.5, ey, 0.0, name(1:name_len)) call pgmtxt ('L', 2.5, ey, 0.0, name(1:name_len))
ey=ey+fy+0.04 ey=ey+fy+0.04
endif endif
ylim(is)=ymin(1)+(ey-0.02)*(ymax(1)-ymin(1))
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 else
call pgsch(0.7) do is=1,nset
call pgtbox('ZCIST', ticks, 0, 'BCVINMST', 0.0, 0) im=imx(is)
call pgtbox('B', 0.0, 0, ' ', 0.0, 0) if (unit(im) .eq. rl) goto 5
call pgsci(color(nset)) enddo
im=0
5 if (im .ne. 0) then
call pgsch(4*winh)
call pgtbox('ZCIST', ticks, nticks, 'BINST1', 0.0, 0)
call pgtbox('B', 0.0, 0, 'CIVMST', 0.0, 0)
call pgsci(color(im))
call pgsch(1.0) call pgsch(1.0)
if (parnam(nset) .eq. 'P' .or. parnam(nset) .eq. 'p') then if (parnam(im) .eq. 'P' .or. parnam(im) .eq. '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) .eq. 'He') then elseif (parnam(im) .eq. 'He') then
title='%' title='%'
iret=tecs_get_par('heUnits', title, 0) iret=tecs_get_par('heUnits', title, 0)
call str_trim(title, title, title_len) call str_trim(title, title, title_len)
call pgmtxt ('L', 2.5, 0.5, 0.5, call pgmtxt ('L', 2.5, 0.5, 0.5,
1 'Helium ['//title(1:title_len)//']') 1 'Helium ['//title(1:title_len)//']')
else else
call pgmtxt ('L', 2.5, 0.5, 0.5, parnam(nset)) call pgmtxt ('L', 2.5, 0.5, 0.5, parnam(im))
endif endif
endif endif
i1=nset-naux+1 endif
i2=nset 6 continue
sel1=i1
sel2=i2
enddo enddo
call pgsch(0.7) call pgsch(0.7)
rl=1 rl=1
call set_win(rl,x1,x2,ymin(rl),ymax(rl)) call set_win(rl,winh,winconf,x1,x2,ymin(rl),ymax(rl))
call pgsci(1) call pgsci(1)
call pgsclp(0) call pgsclp(0)
@ -330,14 +469,13 @@
else else
text(2,1)='live on' text(2,1)='live on'
endif endif
text(2,10)='show '//apar(mod(auxsel,3)+1)
menuwid=0.0 menuwid=0.0
do i=1,nmenu do j=1,nmenu
call str_trim(text(2,i), text(2,i), text_len) call str_trim(text(2,j), text(2,j), text_len)
call pglen(5, text(2,i)(1:text_len), fx, fy) call pglen(5, text(2,j)(1:text_len), fx, fy)
call pgmtxt('T', 3.0, menuwid, 0.0, '|'//text(1,i)) call pgmtxt('T', 3.0, menuwid, 0.0, '|'//text(1,j))
call pgmtxt('T', 2.5, menuwid, 0.0, '|') call pgmtxt('T', 2.5, menuwid, 0.0, '|')
call pgmtxt('T', 2.0, menuwid, 0.0, '|'//text(2,i)) call pgmtxt('T', 2.0, menuwid, 0.0, '|'//text(2,j))
menuwid=menuwid+fx+0.01 menuwid=menuwid+fx+0.01
enddo enddo
call pgmtxt('T', 3.0, menuwid, 0.0, '|') call pgmtxt('T', 3.0, menuwid, 0.0, '|')
@ -349,14 +487,14 @@
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
i=max(0,int((x1+oneDay/2)/oneDay)) j=max(0,int((x1+oneDay/2)/oneDay))
ex=(i+0.5)*oneDay ex=(j+0.5)*oneDay
do while (ex .le. x2) do while (ex .le. x2)
done=.true. done=.true.
write(buf,'(i8.8)') myc_date(nint(ex)+tbase) write(buf,'(i8.8)') myc_date(nint(ex)+tbase)
call pgptxt(ex, ey, 0.0, 0.5, call pgptxt(ex, ey, 0.0, 0.5,
1 weekdays(mod(i,7)+1)//buf(7:8)//'.'//buf(5:6)) 1 weekdays(mod(j,7)+1)//buf(7:8)//'.'//buf(5:6))
ex=ex-12*3600 ex=ex-12*3600
if (ex .gt. x1) then if (ex .gt. x1) then
call pgmove(ex, ey) call pgmove(ex, ey)
@ -367,41 +505,43 @@
call pgmove(ex, ey) call pgmove(ex, ey)
call pgdraw(ex, ey+row) call pgdraw(ex, ey+row)
endif endif
i=i+1 j=j+1
ex=(i+0.5)*oneDay ex=(j+0.5)*oneDay
enddo enddo
if (.not. done) then if (.not. done) then
n=nint(x2)/oneDay*oneDay n=nint(x2)/oneDay*oneDay
i=nint(x1)-n l=nint(x1)-n
j=nint(x2)-n j=nint(x2)-n
if (i .lt. 0) then if (l .lt. 0) then
if (-i .gt. j) then if (-l .gt. j) then
ex=0.0 ex=0.0
i=nint(x1)+tbase l=nint(x1)+tbase
else else
ex=1.0 ex=1.0
i=nint(x2)+tbase l=nint(x2)+tbase
endif endif
else else
ex=0.5 ex=0.5
i=nint(x2)+tbase l=nint(x2)+tbase
endif endif
thisday=mod(i/oneDay,7)+1 thisday=mod(l/oneDay,7)+1
write(buf,'(i8.8)') myc_date(i) write(buf,'(i8.8)') myc_date(l)
call pgmtxt('B', 3.5, ex, ex, call pgmtxt('B', 3.5, ex, ex,
1 weekdays(thisday)//buf(7:8)//'.'//buf(5:6)) 1 weekdays(thisday)//buf(7:8)//'.'//buf(5:6))
endif endif
iret=tecs_get_par('device', title, 0) iret=tecs_get_par('device', title, 0)
if (iret .lt. 0) goto 99 if (iret .lt. 0) goto 99
i=index(title, '(') j=index(title, '(')
if (i .gt. 2 ) then if (j .gt. 2 ) then
title=title(1:i-1) title=title(1:j-1)
else else if (title .eq. ' ') then
title='test - no device' title='test - no device'
endif endif
if (mode .eq. live) then
call pgmtxt('T', -1.5, 0.02, 0.0, title) call pgmtxt('T', -1.5, 0.02, 0.0, title)
endif
call pgsclp(1) call pgsclp(1)
call purge_keys ! purge buffer call purge_keys ! purge buffer
@ -414,52 +554,52 @@
! 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, chartperiod) ! call get_key(key, 0, chartperiod)
i=chartperiod-mod(myc_now(), chartperiod) j=chartperiod-mod(myc_now(), chartperiod)
call get_cursor(ex, ey, key, -i) call get_cursor(ex, ey, key, -j)
do while (key .eq. char(0) .or. key .eq. ' ') ! no key or space key pressed do while (key .eq. char(0) .or. key .eq. ' ') ! no key or space key pressed
iret=tecs_get_mult(pars, t, nset, yy1) iret=tecs_get_mult(pars, t, nset, yy1)
if (iret .lt. 0) goto 99 if (iret .lt. 0) goto 99
t=t+tdif
tim1=t-tbase tim1=t-tbase
if (tim1 .gt. x2) then if (tim1 .gt. x2) then
call pgpage call pgpage
window=x2-x1 fixleft=.true.
goto 1 goto 1
endif endif
if (tim1 .gt. tim0) then if (tim1 .gt. tim0) then
i1=1 do rl=1,nwin
i2=nset-naux call set_win(rl,winh,winconf,x1,x2,ymin(rl),ymax(rl))
do rl=1,2 do is=nset,1,-1
call set_win(rl,x1,x2,ymin(rl),ymax(rl)) im=imx(is)
do i=i1,i2 if (unit(im) .eq. rl) then
if (yy0(i) .ne. undef .and. yy1(i) .ne. undef) then if (yy0(is) .ne. undef .and. yy1(is) .ne. undef) then
if ((sel .eq. 0 .or. sel .eq. i) .and. if ((focus(im) .or. unit(im) .gt. 1) .and.
1 (yy1(i) .lt. ymin(rl) .or. 1 (yy1(is) .lt. ymin(rl) .or.
1 yy1(i) .gt. ymax(rl))) then 1 yy1(is) .gt. ymax(rl))) then
call pgpage call pgpage
window=x2-x1 fixleft=.true.
goto 1 goto 1
endif endif
call pgsci(color(i)) call pgsci(color(im))
call pgmove(tim0, yy0(i)) call pgmove(tim0, yy0(is))
call pgdraw(tim1, yy1(i)) call pgdraw(tim1, yy1(is))
endif
yy0(is)=yy1(is)
endif endif
yy0(i)=yy1(i)
enddo enddo
i1=nset-naux+1
i2=nset
enddo enddo
tim0=tim1 tim0=tim1
endif endif
i=chartperiod-mod(myc_now(), chartperiod) j=chartperiod-mod(myc_now(), chartperiod)
call get_cursor(ex, ey, key, -i) call get_cursor(ex, ey, key, -j)
enddo enddo
else else
call get_cursor(ex, ey, key, 0) call get_cursor(ex, ey, key, 0)
endif endif
rl=1 rl=1
call set_win(rl,x1,x2,ymin(rl),ymax(rl)) call set_win(rl,winh,winconf,x1,x2,ymin(rl),ymax(rl))
8 if (key .ge. 'a') key=char(ichar(key)-32) 8 if (key .ge. 'a') key=char(ichar(key)-32)
if (key .eq. '-') then if (key .eq. '-') then
@ -547,19 +687,19 @@
goto 7 goto 7
elseif (key .eq. 'D') then elseif (key .eq. 'D') then
ex=1 ex=1
read(numb, *, iostat=i) ex read(numb, *, iostat=iostat) ex
window=min(maxRange,max(minRange, nint(oneDay*ex))) window=min(maxRange,max(minRange, nint(oneDay*ex)))
if (mode .lt. right) mode=right if (mode .lt. right) mode=right
x1=0 x1=0
elseif (key .eq. 'H') then elseif (key .eq. 'H') then
ex=1 ex=1
read(numb, *, iostat=i) ex read(numb, *, iostat=iostat) ex
window=min(maxRange,max(minRange, nint(3600*ex))) window=min(maxRange,max(minRange, nint(3600*ex)))
if (mode .lt. right) mode=right if (mode .lt. right) mode=right
x1=0 x1=0
elseif (key .eq. 'M') then elseif (key .eq. 'M') then
ex=1 ex=1
read(numb, *, iostat=i) ex read(numb, *, iostat=iostat) ex
window=min(maxRange,max(minRange, nint(60*ex))) window=min(maxRange,max(minRange, nint(60*ex)))
if (mode .lt. right) mode=right if (mode .lt. right) mode=right
x1=0 x1=0
@ -568,12 +708,12 @@
j=index(numb,'.') j=index(numb,'.')
day=0 day=0
if (j .gt. 1 .and. j .lt. numl) then if (j .gt. 1 .and. j .lt. numl) then
read(numb(1:j-1), *, iostat=i) day read(numb(1:j-1), *, iostat=iostat) day
mon=0 mon=0
read(numb(j+1:numl), *, iostat=i) mon read(numb(j+1:numl), *, iostat=iostat) mon
tbase = myc_time(day+mon*100) tbase = myc_time(day+mon*100)
else else
read(numb, *, iostat=i) day read(numb, *, iostat=iostat) day
tbase = myc_time(day) tbase = myc_time(day)
endif endif
x1=0 x1=0
@ -591,13 +731,67 @@
elseif (key .eq. 'Q' .or. key .eq. char(13) elseif (key .eq. 'Q' .or. key .eq. char(13)
1 .or. key .eq. char(10)) then 1 .or. key .eq. char(10)) then
goto 9 goto 9
elseif (key .eq. 'S') then elseif (key .eq. 'A') then
sel=sel+1 showsets=2
if (sel .gt. tmax) sel=0 elseif (key .eq. 'C') then ! clear set
if (mode .eq. zoom) mode=0 if (ex .lt. x1) then
elseif (key .eq. 'C') then if (ey .ge. ymin(1) .and.
auxsel=auxsel+1 1 ey .le. ymax(1)) then
if (auxsel .gt. amax) auxsel=1 do is=1,nset
if (ey .lt. ylim(is)) then
im=imx(is)
omit(im)=.true.
goto 7
endif
enddo
else
ey=(ymin(1)-ey)/(ymax(1)-ymin(1))*3.0+0.5
if (ey .gt. 1.0) then
do im=1,nmax
j=unit(im)
if (winconf(1)-winconf(j) .eq. int(ey)) then
omit(im)=.true.
endif
enddo
endif
endif
endif
elseif (key .eq. 'S') then ! toggle focus
if (ex .lt. x1) then
if (ey .ge. ymin(1) .and.
1 ey .le. ymax(1)) then
do is=1,nset
if (ey .lt. ylim(is)) then
im=imx(is)
focus(im)=.not. focus(im)
goto 89
endif
enddo
endif
endif
j=nset
n=0
do is=1,nset
im=imx(is)
if (focus(im)) then
focus(im)=.false.
j=is
n=n+1
endif
enddo
if (n .gt. 1) then
if (j .gt. 4) then ! was "all", set to "default"
focus(1)=.true.
focus(2)=.true.
focus(3)=.true.
else ! was "default" select 1
focus(1)=.true.
endif
else if (j .lt. nset) then ! select next
im=imx(j)
focus(im)=.true.
endif ! else select none -> will be all
89 if (mode .eq. zoom) mode=0
elseif (mode .eq. live) then elseif (mode .eq. live) then
goto 7 goto 7
endif endif
@ -616,16 +810,17 @@
read(*,'(a)') filnam read(*,'(a)') filnam
open(lund, file=filnam, status='unknown') open(lund, file=filnam, status='unknown')
line='time [h]' line='hour'
call str_trim(line, line, l) call str_trim(line, line, l)
do j=1,nset do is=1,nset
idx(j)=0 im=imx(is)
do i=1,retlen(j) idx(is)=0
if (yd(i,j) .ne. undef) then do j=1,retlen(is)
idx(j)=1 if (yd(j,is) .ne. undef) then
idx(is)=1
l=l+1 l=l+1
line(l:l)=char(9) line(l:l)=char(9)
call str_trim(line(l+1:), parnam(j), text_len) call str_trim(line(l+1:), parnam(im), text_len)
l=l+max(9,text_len) l=l+max(9,text_len)
goto 109 goto 109
endif endif
@ -638,24 +833,24 @@
x0=0 x0=0
do while (x0 .lt. 3e7) do while (x0 .lt. 3e7)
x0=4e7 x0=4e7
do j=1,nmax ! find next x do is=1,nmax ! find next x
if (idx(j) .gt. 0 .and. idx(j) .lt. retlen(j)) then if (idx(is) .gt. 0 .and. idx(is) .lt. retlen(is)) then
x0=min(x0,xd(idx(j),j)) x0=min(x0,xd(idx(is),is))
endif endif
enddo enddo
if (x0 .lt. 3e7) then if (x0 .lt. 3e7) then
write(line,'(f9.4)') x0/3600. write(line,'(f9.4)') x0/3600.
l=9 l=9
do j=1,nmax do is=1,nmax
if (idx(j) .gt. 0) then if (idx(is) .gt. 0) then
l=l+1 l=l+1
line(l:l)=char(9) line(l:l)=char(9)
if (idx(j) .le. retlen(j)) then if (idx(is) .le. retlen(is)) then
if (xd(idx(j),j) .lt. x0+1) then if (xd(idx(is),is) .lt. x0+1) then
write(line(l+1:), '(f9.4)') write(line(l+1:), '(f9.4)')
1 max(-999.,min(9999.,yd(idx(j),j))) 1 max(-999.,min(9999.,yd(idx(is),is)))
l=l+9 l=l+9
idx(j)=idx(j)+1 idx(is)=idx(is)+1
endif endif
endif endif
endif endif
@ -706,14 +901,19 @@
end end
subroutine set_win(rl, x1, x2, y1, y2) subroutine set_win(rl, winh, winconf, x1, x2, y1, y2)
integer rl integer rl
real winh
integer winconf(*)
real x1, x2, y1, y2 real x1, x2, y1, y2
real b
if (rl .eq. 1) then if (rl .eq. 1) then
call pgsvp(0.07,0.93,0.3,0.9) call pgsvp(0.07,0.93,0.9-3*winh,0.9)
else else
call pgsvp(0.07,0.93,0.01,0.20) b=winconf(rl)*winh
call pgsvp(0.07,0.93,b+0.01,b+winh-0.01)
endif endif
call pgswin(x1,x2,y1,y2) call pgswin(x1,x2,y1,y2)
@ -728,7 +928,7 @@
real*4 xd(dmax,nmax), yd(dmax,nmax) real*4 xd(dmax,nmax), yd(dmax,nmax)
integer oneDay, maxn integer oneDay, maxn
parameter (oneDay = 24*3600, maxn=10) parameter (oneDay = 24*3600, maxn=12)
integer tecs_get_data integer tecs_get_data
integer i,j,rl(maxn),m,k,n,mm integer i,j,rl(maxn),m,k,n,mm
@ -758,7 +958,9 @@
retlen(j)=n retlen(j)=n
mm=max(mm,n) mm=max(mm,n)
enddo enddo
! print *,mm-m,' points read' if (m .gt. 0) then
print '(a,$)',' .'
endif
m=mm m=mm
enddo enddo
endif endif

View File

@ -161,6 +161,7 @@ char *SerCmd(SerChannel *serch, char *cmnd) {
AsynSrvChan *aser; AsynSrvChan *aser;
TermSrvChan *tser; TermSrvChan *tser;
char *result, *pos, *trm; char *result, *pos, *trm;
char junk[256];
int iret, incomplete; int iret, incomplete;
l=strlen(cmnd); l=strlen(cmnd);
@ -181,6 +182,18 @@ char *SerCmd(SerChannel *serch, char *cmnd) {
if (result==NULL) ERR_MSG("empty result"); if (result==NULL) ERR_MSG("empty result");
} else if (serch->type==TERMSRV_TYPE) { } else if (serch->type==TERMSRV_TYPE) {
tser=(TermSrvChan *)serch; tser=(TermSrvChan *)serch;
ERR_I(iret=SerWait(0, tser->fd));
while (iret>0) { /* skip contents in type-ahead buffer */
ERR_SI(l=recv(tser->fd, junk, sizeof(junk)-1, 0));
if (l==0) {
ErrMsg("disconnected");
SerClose(serch);
goto OnError;
}
junk[l]='\0';
logfileOut(LOG_MAIN, "skipped: '%s'\n", junk);
ERR_I(iret=SerWait(0, tser->fd));
}
iret=send(tser->fd, cmnd, l, 0); iret=send(tser->fd, cmnd, l, 0);
if (iret<0) { if (iret<0) {
ErrMsg("disconnected"); ErrMsg("disconnected");

View File

@ -1,3 +1,4 @@
#include <limits.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/socket.h> #include <sys/socket.h>

View File

@ -3,7 +3,7 @@
This is the implementation for TECS object derived from an more general This is the implementation for TECS object derived from an more general
environment controller. At present, TECS is used for driving the environment controller. At present, TECS is used for driving the
LakeShore 340 Temperutre Controller. LakeShore 340 Temperature Controller.
Markus Zolliker, March 2000 Markus Zolliker, March 2000
@ -68,6 +68,7 @@
char *lastError; char *lastError;
time_t lastGet; time_t lastGet;
int iLastError, port; int iLastError, port;
int (*EVLimits)(void *, float , char *, int);
char server[256]; char server[256];
} TecsDriv, *pTecsDriv; } TecsDriv, *pTecsDriv;
@ -78,7 +79,7 @@
int argc, char *argv[]) int argc, char *argv[])
{ {
pEVControl self = NULL; pEVControl self = NULL;
char pBueffel[256], result[1024]; char pBueffel[256], result[1024], *res;
int iRet; int iRet;
pEVDriver pD; pEVDriver pD;
pTecsDriv pMe; pTecsDriv pMe;
@ -111,32 +112,40 @@
iRet=CocGet(pMe->pData,"set",result); /* get parameter */ iRet=CocGet(pMe->pData,"set",result); /* get parameter */
if (iRet<0) goto Error; if (iRet<0) goto Error;
self->fTarget = atof(result); self->fTarget = atof(result);
iRet = EVControlWrapper(pCon,pSics,pData,argc,argv);
if (iRet != 0) {
iRet=CocGet(pMe->pData,"tlimit",result); /* get parameter */ iRet=CocGet(pMe->pData,"tlimit",result); /* get parameter */
if (iRet<0) goto Error; if (iRet<0) goto Error;
fVal = atof(result); fVal = atof(result);
if (fVal != 0 && ObVal(self->pParam,UPLIMIT) > fVal) { iRet = EVCSetPar(self, "upperlimit", fVal,pCon);
sprintf(pBueffel,"WARNING: upper limit is above %g, (limit of the device)", fVal); iRet = EVControlWrapper(pCon,pSics,pData,argc,argv);
SCWrite(pCon,pBueffel,eValue); if (iRet != 0) {
} iRet=CocGet(pMe->pData,"status",result); /* show status */
iRet=CocGet(pMe->pData,"status",result); /* get parameter */
if (iRet<0) goto Error; if (iRet<0) goto Error;
SCWrite(pCon,result,eValue); SCWrite(pCon,result,eValue);
} }
return iRet; return iRet;
} else if (0==strcmp(pBueffel," upperlimit ")) { } else if (0==strcmp(pBueffel," upperlimit ")) {
if (argc > 2) { if (argc == 3) {
iRet=CocGet(pMe->pData,"tlimit",result); /* get parameter */ iRet=CocSetGet(pMe->pData,"tLimit",argv[2],result); /* set and get parameter */
res=strchr(result, '=');
if (res != NULL) {
str_copy(result, res+1);
}
} else if (argc == 2) {
iRet=CocGet(pMe->pData,"tLimit",result); /* get parameter */
}
if (iRet<0) goto Error; if (iRet<0) goto Error;
fVal=atof(result); fVal=atof(result);
if (atof(argv[2]) > fVal) { if (argc==3 && atof(argv[2]) > fVal) {
sprintf(pBueffel,"ERROR: upper limit must not be higher than %g", fVal); sprintf(pBueffel,"WARNING: upper limit reduced to maximal allowed value: %g", fVal);
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eWarning);
return 0;
} }
iRet = EVCSetPar(self, "upperlimit", fVal,pCon);
if (iRet) {
sprintf(pBueffel,"%s.%s = %s\n",self->pName,
argv[1],result);
SCWrite(pCon,pBueffel,eValue);
} }
return EVControlWrapper(pCon,pSics,pData,argc,argv); return iRet;
} else if (0==strcmp(pBueffel," lowerlimit ")) { } else if (0==strcmp(pBueffel," lowerlimit ")) {
if (argc > 2) { if (argc > 2) {
if (atof(argv[2]) > ObVal(self->pParam,UPLIMIT)) { if (atof(argv[2]) > ObVal(self->pParam,UPLIMIT)) {
@ -146,7 +155,7 @@
} }
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
} else if (NULL!=strstr( } else if (NULL!=strstr(
" log send tolerance access errorhandler interrupt interest safevalue currentvalue maxwait settle " " log send tolerance access errorhandler interrupt interest safevalue currentvalue maxwait settle errorscript driver "
, pBueffel)) { , pBueffel)) {
/* forward to standard handler */ /* forward to standard handler */
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
@ -415,3 +424,37 @@
return pNew; return pNew;
} }
/*------------------------------------------------------------------------*/
static int TecsLimits(void *pData, float fVal, char *pError, int iErrLen) {
/* wrapper for EVILimits */
pEVControl pEvc;
pTecsDriv pMe;
int iRet;
float f;
char result[64];
pEvc = (pEVControl)pData;
assert(pEvc);
pMe=pEvc->pDriv->pPrivate;
assert(pMe);
iRet=CocGet(pMe->pData,"tLimit",result); /* get parameter */
if (iRet>=0) {
f=0.0;
f=atof(result);
if (f>0.0) pEvc->pParam[UPLIMIT].fVal=f;
}
return pMe->EVLimits(pData, fVal, pError, iErrLen);
}
/*------------------------------------------------------------------------*/
void TecsCustomize(SConnection *pCon, pEVControl pEvc) {
/* customize tecs driver */
pTecsDriv pMe;
pMe=pEvc->pDriv->pPrivate;
assert(pMe);
assert(pMe->EVLimits != pEvc->pDrivInt->CheckLimits);
pMe->EVLimits=pEvc->pDrivInt->CheckLimits; /* save original CheckLimits function */
pEvc->pDrivInt->CheckLimits=TecsLimits;
EVCSetPar(pEvc,"upperlimit",1800.0,pCon);
EVCSetPar(pEvc,"lowerlimit",0.01,pCon);
}

View File

@ -24,4 +24,6 @@
int TecsError(pEVDriver self, int *iCode, char *error, int iErrLen); int TecsError(pEVDriver self, int *iCode, char *error, int iErrLen);
void TecsCustomize(SConnection *pCon, pEVControl pEvc);
#endif #endif

View File

@ -1,7 +1,5 @@
# this makefile delegates to a version specific makefile # this makefile delegates to a version specific makefile
# where this subdirectory is (relative to the sics root)
S_DOWN=psi/utils
# where root is (from here) # where root is (from here)
S_UP=../.. S_UP=../..