New TECS Version Sept. 2001 M.Z.

This commit is contained in:
cvs
2001-09-03 14:30:38 +00:00
parent db6c355f44
commit 33e7751176
12 changed files with 797 additions and 514 deletions

View File

@ -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)
CLI_OBJ= tecs_cli.o coc_client.o $(LIBR_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)
CC=cc
@ -26,7 +26,7 @@ libtecsl.a: $(CLI_OBJ)
ar cr libtecsl.a $(CLI_OBJ)
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
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) \
-L/data/lnslib/lib -so_archive -lreadline -ltermcap -lX11 -lXm
rstart: $(LIBR_OBJ) rstart.c myc_str.o myc_err.o
$(CC) $(CFLAGS) -o rstart 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 instr_hosts.o
keep_running: keep_running.c
$(CC) $(CFLAGS) -o keep_running keep_running.c
serverd: serverd.c $(LIBR_OBJ)
$(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:
- rm *.o

View File

@ -24,16 +24,22 @@ int main(int argc, char *argv[]) {
exit(1);
}
waitpid(pid, &status, 0);
if (status==0) {
printf("Regular exit\n");
if (status==512) { /* kill */
return 0;
}
if (status==256) { /* restart */
cnt = MAX_CNT;
}
time(&tim2);
dif = (int) difftime(tim2, tim1);
cnt += dif / MIN_PERIOD;
if (cnt > MAX_CNT) cnt = MAX_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) {
printf(" - %d tries left - retry ...\n", cnt);
}

View File

@ -5,54 +5,17 @@
#include <stdio.h>
#include <netdb.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 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 port, i, j, l, fd;
char *host, inst[32], cmd[256], buf[256], path[256];
char *instrHosts[]={
"DMC","lnsa05.psi.ch",
"TOPSI","lnsa07.psi.ch",
"SANS","lnsa10.psi.ch",
"HRPT","lnsa11.psi.ch",
"TRICS","lnsa13.psi.ch",
"AMOR","lnsa14.psi.ch",
"FOCUS","lnsa16.psi.ch",
"ZOLLIKER","lnsa15.psi.ch"
};
char inst[32], cmd[256], host[256], user[64], pcod[64];
char *hostp;
struct tm tim;
time_t t;
struct servent s;
s=*getservbyname("exec", "tcp");
@ -61,61 +24,28 @@ int main(int argc, char *argv[]) {
printf("not enough arguments\n");
return 0;
}
str_upcase(inst, argv[1]);
str_copy(cmd, "\n");
i=InstrHost(argv[1], inst, host, user, pcod, sizeof(inst), sizeof(host), sizeof(user), sizeof(pcod));
if (i==0) {
printf("unknown host/instrument\n");
return -1;
}
str_copy(cmd, "");
for (i=2; i<argc; i++) {
if (0==strcmp(argv[i], "sics")) {
str_append(cmd, "startsics\n");
str_append(cmd, "bin/startsics\n");
} else if (0==strcmp(argv[i], "tecs")) {
str_append(cmd, "startecs\n");
str_append(cmd, "bin/startecs\n");
} else {
printf("unknown server %s\n", argv[i]);
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);
if (buf[0]=='\0') {
str_copy(buf, inst);
str_append(buf, "LNS");
}
fd=rexec(&host, s.s_port, inst, buf, "rlogin 0", &i);
hostp=host;
fd=rexec(&hostp, s.s_port, user, pcod, cmd, &i);
if (fd<0) {
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);
return 0;
Error: perror("error in wrtRd"); return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -11,11 +11,11 @@
#include "tecs_data.h"
static char response[COC_RES_LEN];
static char *rwCode="rwacs";
static char *rdCode="rdacs";
pTecsClient TeccInit(char *startcmd, int port) {
CocConn *conn;
static char *rwCode="rwacs";
static char *rdCode="rdacs";
NEW(conn, CocConn);
if (startcmd[0]=='#') {
@ -64,22 +64,23 @@ int TeccSet(pTecsClient conn, float temp) {
OnError: return(-1);
}
int TeccQuitServer(pTecsClient conn) {
int TeccQuitServer(pTecsClient conn, int kill) {
int iret, cnt;
ERR_I(iret=CocCheck(conn));
if (iret==0) {
CocReset(conn);
ERR_I(CocPutInt(conn, "quit", 1));
ERR_I(CocDoIt(conn, response, sizeof(response)));
cnt=50;
while (iret==0 && cnt>0) {
CocDelay(100);
ERR_I(iret=CocCheck(conn));
cnt--;
}
if (iret>0) return iret;
CocReset(conn);
ERR_I(CocPutInt(conn, "quit", 1+kill));
ERR_I(iret=CocDoIt(conn, response, sizeof(response)));
if (iret) ERR_MSG(response);
cnt=50;
while (iret==0 && cnt>0) {
CocDelay(100);
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:
return(-1);
}
@ -121,6 +122,7 @@ void TeccClose(pTecsClient conn) {
#define tecs_get_data_ tecs_get_data
#define tecs_date_ tecs_date
#define tecs_time_ tecs_time
#define tecs_rights_ tecs_rights
#endif
static pTecsClient conn=NULL;
@ -200,6 +202,16 @@ int tecs_init_(F_CHAR(startcmd), int *port, int startcmd_len) {
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) {
ERR_I(TeccGet(conn, temp));
return(0);
@ -227,9 +239,11 @@ void tecs_close_(void) {
conn=NULL;
}
int tecs_quit_server_(void) {
ERR_I(TeccQuitServer(conn));
return(0);
int tecs_quit_server_(int *kill) {
int iret;
ERR_I(iret=TeccQuitServer(conn, *kill));
return(iret);
OnError: return(-1);
}
@ -274,7 +288,11 @@ int DataDecode(float *data, int dataSize, char *coded, int *retSize) {
dig1=decode[ch];
if (dig1 < 0) { /* code is no 64-digit */
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 {
ch=coded[p++];
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) {
char nam[64];
char str[128];
char res[COC_RES_LEN];
char *cod;
int i, l, iret, retSize;
float offset, fact, *py;
int i, j, k, l, iret, retSize;
if (*endTime - *startTime > *step * (*maxLen-1)) {
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);
cod=res;
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;
}
return 0;

View File

@ -27,8 +27,8 @@ int TeccSend(pTecsClient conn, char *cmd, char *reply, int replyLen);
void TeccClose(pTecsClient conn);
/* close connection and free ressources */
int TeccQuitServer(pTecsClient conn);
/* quit the server process */
int TeccQuitServer(pTecsClient conn, int kill);
/* quit the server process, kill = 0: restart if possible */
/* Fortran interface:

View File

@ -2,6 +2,7 @@
real temp
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
character cmdpar*128
character prompt*32/'tecs>'/
@ -12,20 +13,38 @@
! functions
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_get_cmdpar(line, l)
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.
i=instr_host(line, inst, host, user, pcod)
else
oneCommand=.false.
i=0
endif
if (oneCommand .and. line(1:1) .eq. '#') then
call tecs_open(0, line, iret)
if (i .ne. 0) then
call tecs_open(0, '#'//host, iret)
oneCommand=.false.
prompt='tecs/'//inst(1:i)//'> '
promptlen=i+7
else if (init .eq. ' ') then
call tecs_open(0, line, iret)
else
@ -48,8 +67,10 @@
print *,'plot <var> chart for temperature and <var>'
1 ,' var = P (default), He, Aux'
print *,'log <n> show last n lines of logfile'
print *,'kill close TecsServer and exit'
print *,'exit,quit exit, but do not close TecsServer'
print *,'remote set to remote mode'
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 *
@ -93,20 +114,31 @@
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_open(0, cmd, iret)
call tecs_open(0, '#'//host, iret)
if (iret .lt. 0) goto 91
prompt='tecs/'//cmd(2:)
promptlen=1
do i=1,len(prompt)-2
if (prompt(i:i) .ne. ' ') promptlen=i
enddo
promptlen=promptlen+1
prompt(promptlen:promptlen)='>'
promptlen=promptlen+1
prompt='tecs/'//inst(1:i)//'> '
promptlen=i+7
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
goto 99
elseif (cmd .eq. 'status') then
@ -116,7 +148,7 @@
l=0
goto 11
elseif (cmd .eq. 'plot') then
call tecs_plot('Tm Ts Tr P', 1)
call tecs_plot(' ')
elseif (cmd .eq. 'help') then
print *
print *,'Writeable parameters:'
@ -131,18 +163,18 @@
print *,'deriv PID derivation term'
print *,'maxShift maximum (set-tempH) for controlMode=2'
print *,'int2 integration time (sec) for controlMode=2'
print *,'remoteMode 1: local, 2: remote'
print *
print *,'Read only parameters:'
print *
print *,'Tm main temperature'
print *,'Ts sample temperature'
print *,'setH set-point on regulation'
print *,'Tr set-point on regulation'
print *,'tLimit temperature limit'
print *,'helium helium level'
print *,'htr heater current percentage'
print *,'resist heater resistance'
print *,'logfile name of the logfile'
print *,'remoteMode 1: local, 2: remote '
1 ,'(switch on with device command)'
print *
print *,'Ta,Tb,Tc,Td values of channels A,B,C,D'
print *
@ -152,7 +184,7 @@
1 ,'ill5 (maxi)'
print *,'cti1, cti2, cti3, cti4, cti5 (maxi), cti6 (focus), apd'
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 *
elseif (cmd .eq. 'log') then
@ -184,7 +216,9 @@
endif
logarg=' '
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
iret=tecs_watch_log(par)
if (iret .lt. 0) goto 19

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include <float.h>
#include <string.h>
#include <strings.h>
#include <assert.h>
#include "myc_mem.h"
#include "myc_str.h"
@ -102,7 +102,7 @@ Set *FindSet(Base *base, char *name) {
total=0;
s = base->head;
while (s!=NULL && 0!=strcmp(name, s->set.name)) {
while (s!=NULL && 0!=strcasecmp(name, s->set.name)) {
s = s->next;
}
return s;
@ -245,7 +245,7 @@ int Put(Set *set, int time, float value) {
if (t % 2) {
r->data[size]=value; size++; /* put a provisory value */
r->endTime += r->step;
} else {
} else if (t == 2) {
PutSum(&set->sum, r->data+size); size+=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++) {
if ( data[i] == DATA_UNDEF ) {
coded[p++]='/';
} else if ( data[i] == DATA_GAP ) {
coded[p++]='.';
} else {
n=( (data[i] - minD) * 4095 ) / range + 0.5;
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) {
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;
s1 = startTime + (siz1 * period + halfsiz) / halfsiz / 2;
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) {
ERR_I(GetSet(s, s1, endTime, siz2, data+siz1));

View File

@ -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 MYC_NAN
#define DATA_GAP (MYC_NAN*2)
#define DATA_CODE "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz"
#endif /* TECS_DATA_H_ */

View File

@ -1,101 +1,114 @@
subroutine tecs_plot(pars, naux)
subroutine tecs_plot(auxpar)
character(len=*) pars ! parameters to plot
integer naux ! number of auxiliary, non-T parameters
character(len=*) auxpar
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 :: oneDay = 24*3600
integer, parameter :: zoom=1, right=2, live=3
real, parameter :: winmin=60., undef=-1.125/1024./1024./1024.
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 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 nset
integer ncol, nset, mode
integer first,last,step,tbase,lastj
integer colorList(nmax)/5,3,2,4,8/
integer color(nmax)
integer retLen(nmax)
integer sel/0/, sel1, sel2, auxsel/1/
character key*1
character text(nmenu)*12/ &
'live off','sel. zoom','zoom in','zoom out','show all','n days','n hours','n min','date','file','quit'/
character keys*(nmenu)/'LZ+-XDHMTFQ'/
character text(2,nmenu)*16/ &
'L' ,'live off' &
,'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 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)
external tplot_close
logical gap, done
logical live, xwin, zoom, right, saveit
logical saveit
integer iret, lund, numl, mon, day
! 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./
if (window==0) window=1800.
saveit=.false.
zoom=.false.
right=.true.
mode=live
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)
if (device=='NULL') then
print *,'No PGPLOT-Device defined'
goto 9
endif
live=device(1:1)/='X' ! live switched off by default on X-Windows
nset=1
l=1
i=1
do while (i <= nmax)
do while (l < len(pars) .and. pars(l:l) <= ' ')
l=l+1
enddo
if (pars(l:l) > ' ') then
j=l
do while (l < len(pars) .and. pars(l:l) > ' ')
l=l+1
enddo
parnam(i)=pars(j:l)
nset=i
if (l == len(pars)) i=nmax
else
i=nmax
endif
i=i+1
enddo
call pgqcol(i,ncol)
! print *,i,ncol,' colors ',device
if (ncol>=8 .and. device /= 'VT125') then
call pgscr(0, 1.0, 1.0, 1.0)
call pgscr(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)
endif
call pgask(.false.)
l=0
x1=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 (window == 0) then
last=t
step=maxRange/dmax
window=maxRange
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
last=t
first=t-min(dmax*step-1,nint(window)-step)
else
if (.not. zoom) then
if (mode==zoom) then
x2=(x1+x2+window)/2
x1=x2-window
endif
@ -106,42 +119,37 @@ subroutine tecs_plot(pars, naux)
endif
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
! 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;
if (right .or. live) then
x2 = last - tbase
if (mode >= right) then
x1=x2-window
else
x1 = first - tbase;
x1 = first - tbase
endif
tim0=t-tbase
do j=1,nset
leng=retLen(j)
do i=1,leng
xd(i,j)=(float(i-1)*(last-tbase)+float(leng-i)*(first-tbase))/(leng-1)
do i=1,nset
leng=retLen(i)
do while (leng > 1 .and. yd(leng,i) == undef)
leng=leng-1
enddo
if (live .and. leng>0) then
xd(leng,j)=tim0
yd(leng,j)=yy0(j)
if (leng == 1) leng=0
retLen(i)=leng
if (mode==live .and. leng>0) then
xd(leng,i)=tim0
yd(leng,i)=yy0(i)
endif
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 (live) then
if (mode==live) then
x2=max(tim0,x2)+min(1800., window*0.5)
endif
@ -155,8 +163,15 @@ subroutine tecs_plot(pars, naux)
i1=1
i2=nset-naux
if (sel==0) then
sel1=i1
sel2=i2
else
sel1=sel
sel2=sel
endif
do rl=1,2
if (zoom) then
if (mode==zoom) then
ymin(1)=y1
ymax(1)=y2
else
@ -164,7 +179,7 @@ subroutine tecs_plot(pars, naux)
ymax(rl)=-1e30
ylast1=ymin(rl)
ylast2=ymax(rl)
do i=i1,i2
do i=sel1,sel2
do j=1,retLen(i)
if (yd(j,i)/=undef) then
ymin(rl)=min(ymin(rl),yd(j,i))
@ -183,7 +198,7 @@ subroutine tecs_plot(pars, naux)
fy=abs(ymax(rl))
ymax(rl)=ymax(rl)+max(fy*0.0075,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))
ymax(rl)=max(ymax(rl),ylast2+ey*0.4)
endif
@ -196,11 +211,10 @@ subroutine tecs_plot(pars, naux)
ymax(rl)=ymin(rl)*1.00001+1.0
ymin(rl)=-1.0e-3
endif
zoom=.false.
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
do i=i2,i1,-1
do i=i1,i2
call pgsci(color(i))
lastj=1
do j=1,retLen(i)
@ -220,22 +234,25 @@ subroutine tecs_plot(pars, naux)
call pgtbox('C', 0.0, 0, ' ', 0.0, 0)
ey=0.0
do i=i1,i2
name=parnam(i)
if (name=="Tm") then
name="Main Sensor"
elseif (name=="Ts") then
name="Sample Sensor"
elseif (name=="Tr") then
name="SetPoint"
if (retLen(i) > 0) then
name=parnam(i)
if (name=="Tm") then
name="Main Sensor"
elseif (name=="Ts") then
name="Sample Sensor"
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
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
call pgsci(1)
call pgmtxt ('L', 2.5, ey, 0.0, 'T [K]')
else if (naux > 0) then
else
call pgsch(0.7)
call pgtbox('ZCIST', ticks, 0, 'BCVINMST', 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)
if (parnam(nset) == 'P' .or. parnam(nset) == 'p') then
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
call pgmtxt ('L', 2.5, 0.5, 0.5, parnam(nset))
endif
endif
i1=nset-naux+1
i2=nset
sel1=i1
sel2=i2
enddo
call pgsch(0.8)
call pgsch(0.7)
rl=1
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
call pgsci(1)
call pgsclp(0)
if (live) then
text(1)='live off'
if (mode==live) then
text(2,1)='live off'
else
text(1)='live on'
text(2,1)='live on'
endif
ex=0.0
text(2,10)='show '//apar(mod(auxsel,3)+1)
menuwid=0.0
do i=1,nmenu
call pglen(5, trim(text(i)), fx, fy)
call pgmtxt('T', 3.0, ex, 0.0, '|'//keys(i:i))
call pgmtxt('T', 2.5, ex, 0.0, '|')
call pgmtxt('T', 2.0, ex, 0.0, '|'//text(i))
ex=ex+fx+0.01
call pglen(5, trim(text(2,i)), fx, fy)
call pgmtxt('T', 3.0, menuwid, 0.0, '|'//text(1,i))
call pgmtxt('T', 2.5, menuwid, 0.0, '|')
call pgmtxt('T', 2.0, menuwid, 0.0, '|'//text(2,i))
menuwid=menuwid+fx+0.01
enddo
call pgmtxt('T', 3.0, ex, 0.0, '|')
call pgmtxt('T', 2.5, ex, 0.0, '|')
call pgmtxt('T', 2.0, ex, 0.0, '|')
call pgmtxt('T', 3.0, 0.8, 0.0, 'any digit to enter n')
call pgmtxt('T', 2.0, 0.8, 0.0, 'n=')
call pgmtxt('T', 3.0, menuwid, 0.0, '|')
call pgmtxt('T', 2.5, menuwid, 0.0, '|')
call pgmtxt('T', 2.0, menuwid, 0.0, '|')
menuwid=menuwid+0.01
call pgsch(0.8)
done=.false.
row=(ymax(rl)-ymin(rl))/30.
ey=ymin(rl)-row*3.5
@ -300,7 +324,7 @@ subroutine tecs_plot(pars, naux)
i=i+1
enddo
if (.not. done) then
n=nint(x2)/oneDay*oneDay;
n=nint(x2)/oneDay*oneDay
i=nint(x1)-n
j=nint(x2)-n
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))
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 get_key(key, 0, 0) ! purge buffer
call purge_keys ! purge buffer
numl=0
numb=' '
7 if (live) 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)')
endif
call get_key(key, 0, chartfreq)
7 if (mode==live) 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)')
! endif
! 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
iret=tecs_get_mult(pars, t, nset, yy1)
@ -347,9 +383,9 @@ subroutine tecs_plot(pars, naux)
i2=nset-naux
do rl=1,2
call set_win(rl,x1,x2,ymin(rl),ymax(rl))
do i=i2,i1,-1
if (yy0(i) .ne. undef .and. yy1(i) .ne. undef) then
if (yy1(i) < ymin(rl) .or. yy1(i) > ymax(rl)) then
do i=i1,i2
if (yy0(i) /= undef .and. yy1(i) /= undef) then
if ((sel==0 .or. sel==i) .and. (yy1(i) < ymin(rl) .or. yy1(i) > ymax(rl))) then
call pgpage
window=x2-x1
goto 1
@ -366,11 +402,11 @@ subroutine tecs_plot(pars, naux)
tim0=tim1
endif
call get_key(key, 0, chartfreq)
i=chartperiod-mod(myc_now(), chartperiod)
call get_cursor(ex, ey, key, -i)
enddo
else
call pgcurs(ex, ey, key)
call must_purge
call get_cursor(ex, ey, key, 0)
endif
rl=1
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)
if (key=='-') then
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
window=0
live=.false.
mode=0
elseif (key=='+' .or. key==',') then
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
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 pgcurs(ex, ey, key)
call get_cursor(ex, ey, key, 0)
else
call pgmtxt('T', 0.5, 0.0, 0.0, 'click on second corner of selection rectangle')
endif
call pgsci(5)
call pgsci(6)
xmin=x1
xmax=x2
call pgmove(xmin, ey)
call pgdraw(xmax, ey)
call pgmove(ex, ymin(rl))
call pgdraw(ex, ymax(rl))
call pgcurs(fx, fy, key)
call must_purge
call pgmove(xmin, ey)
call pgdraw(xmax, ey)
call pgmove(ex, ymin(rl))
call pgdraw(ex, ymax(rl))
if (device(1:1) .eq. 'X') then
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))
x2=min(xmax,max(ex,fx))
if (x1>=x2) then
@ -413,42 +472,36 @@ subroutine tecs_plot(pars, naux)
y1=ymin(1)
y2=ymax(1)
endif
zoom=.true.
live=.false.
right=.false.
mode=zoom
elseif (key >= '0' .and. key <= '9' .or. key == '.') then ! number
if (numl .lt. len(numb)) then
numl=numl+1
numb(numl:numl)=key
call pgsci(1)
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
if (device(1:1)=='X' .and. .not. live) then
call pgcurs(ex, ey, key)
call must_purge
else
call get_key(key, 2, 10)
endif
if (key/=char(0)) goto 8
! call get_cursor(ex, ey, key, -chartperiod)
! if (key/=char(0)) goto 8
if (mode==zoom) mode=0
goto 7
elseif (key == 'D') then
ex=1
read(numb, *, iostat=i) ex
window=min(maxRange,max(minRange, nint(oneDay*ex)))
right=.true.
if (mode < right) mode=right
x1=0
elseif (key == 'H') then
ex=1
read(numb, *, iostat=i) ex
window=min(maxRange,max(minRange, nint(3600*ex)))
right=.true.
if (mode < right) mode=right
x1=0
elseif (key == 'M') then
ex=1
read(numb, *, iostat=i) ex
window=min(maxRange,max(minRange, nint(60*ex)))
right=.true.
if (mode < right) mode=right
x1=0
elseif (key == 'T' .or. numl>0 .and. (key==char(13) .or. key==char(10))) then
j=index(numb,'.')
@ -457,27 +510,32 @@ subroutine tecs_plot(pars, naux)
read(numb(1:j-1), *, iostat=i) day
mon=0
read(numb(j+1:numl), *, iostat=i) mon
tbase = myc_time(day+mon*100);
tbase = myc_time(day+mon*100)
else
read(numb, *, iostat=i) day
tbase = myc_time(day);
tbase = myc_time(day)
endif
x1=0
x2=oneDay
window=x2
live=.false.
right=.false.
mode=0
elseif (key == 'L') then
live=.not. live
if (live) then
right=.true.
if (mode == live) then
mode=right
else
mode=live
endif
elseif (key == 'F') then
saveit=.true.
elseif (key=='Q' .or. key==char(13) .or. key==char(10)) then
goto 9
elseif (key == 'R') then
elseif (live) then
goto 9
elseif (key == 'S') 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
endif
numl=0
@ -486,8 +544,8 @@ subroutine tecs_plot(pars, naux)
goto 1
99 call tecs_write_msg(6)
9 continue
call tplot_close
call get_key(key, 0, 0) ! purge type-ahead-buffer
call pgclos
call purge_keys
print *
if (saveit) then
lund=41
@ -525,22 +583,37 @@ subroutine tecs_plot(pars, naux)
end subroutine
subroutine get_key(key, tmo1, tmo2)
integer tmo1, tmo2
character key*1
logical purge/.false./
subroutine get_cursor(x, y, key, mode)
character*1 key
real*4 x, y
integer mode
integer with_timeout/-1/
integer l
character res*32
key=char(0)
if (purge) then
purge=.false.
call sys_get_key(key, tmo1)
if (key/=char(0) .and. key/=char(13)) return
if (with_timeout<0) then
with_timeout=0
call pgqinf('VERSION', res, l)
if (res(l:l)=='+') then
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
if (tmo2>0) call sys_get_key(key, tmo2)
return
end subroutine
entry must_purge
purge=.true.
subroutine purge_keys
character key*1
key=' '
do while (key/=char(0))
call sys_get_key(key, 0)
end do
end subroutine
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)
end subroutine
subroutine tplot_close
call pgclos
! call dlog_close_r
end subroutine

View File

@ -182,7 +182,7 @@ char *SerCmd(SerChannel *serch, char *cmnd) {
/* Wait for an event on tser->fd or a timeout tmo */
iret=tser->idleHdl(tser->tmo, tser->fd);
if (iret==0) {
if (result==NULL) ERR_MSG("time out");
if (result==NULL) ERR_MSG("timeout");
ERR_MSG("missing terminator");
}
ERR_SI(l=recv(tser->fd, pos, n, 0));

View File

@ -38,6 +38,7 @@
MODIFICATIONS.
----------------------------------------------------------------------------*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/time.h>
@ -57,8 +58,8 @@
#include "sicsvar.h"
#include "tecs/coc_util.h"
#include "tecs/tecs_cli.h"
#include "tecs/str_util.h"
#include "tecs/err_handling.h"
#include "tecs/myc_str.h"
#include "tecs/myc_err.h"
extern pServer pServ;
#include "evdriver.i"
@ -83,7 +84,6 @@
int iRet;
pEVDriver pD;
pTecsDriv pMe;
double fNum;
float fVal;
self = (pEVControl)pData;
@ -96,46 +96,85 @@
return EVControlWrapper(pCon,pSics,pData,argc,argv);
}
pD=self->pDriv; assert(pD);
pMe=pD->pPrivate; assert(pMe);
strcpy(pBueffel, " ");
strcat(pBueffel, argv[1]);
strcat(pBueffel, " ");
strtolower(pBueffel);
if ( NULL==strstr(" log send list tolerance access errorhandler interrupt interest ", pBueffel)
&& NULL==strstr(" upperlimit lowerlimit safevalue currentvalue targetvalue ", pBueffel)
) {
pD=self->pDriv; assert(pD);
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;
if (0==strcmp(pBueffel," targetvalue ")) {
if (argc == 2) {
iRet=CocGet(pMe->pData,"set",result); /* get parameter */
if (iRet<0) goto Error;
self->fTarget = atof(result);
}
} 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);
}
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 */
return 0;
Error:
sprintf(pBueffel,"ERROR: %s",ErrMessage);
SCWrite(pCon,pBueffel,eError);
return 0;
}
/*----------------------------------------------------------------------------*/
@ -292,8 +331,10 @@
pEVDriver pNew = NULL;
pTecsDriv pMe = NULL;
pSicsVariable pInst = NULL;
char *pPort=NULL;
char *pPort=NULL, *pPath=NULL;
FILE *fil;
char buf[256];
pNew = CreateEVDriver(argc,argv);
pMe = (pTecsDriv)malloc(sizeof(TecsDriv));
memset(pMe,0,sizeof(TecsDriv));
@ -307,16 +348,31 @@
/* initalise pTecsDriver */
pMe->lastError = NULL;
pMe->port=0;
pMe->server[0]='\0';
/* get the port number for tecs */
pMe->port=0;
pPort = IFindOption(pSICSOptions, "TecsPort");
if (pPort!=NULL) {
pMe->port=atoi(pPort);
pPath = IFindOption(pSICSOptions, "TecsInit");
if (pPath != NULL) {
fil=fopen(pPath, "r");
if (fil!=NULL) {
pPort=fgets(buf, sizeof(buf), fil);
if (pPort != NULL) {
pMe->port=atoi(pPort);
}
fgets(buf, sizeof(buf), fil);
fgets(pMe->server, sizeof(pMe->server), fil);
}
}
if (pMe->port==0) {
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 */