tecs_plot.f is now ext. f77

This commit is contained in:
cvs
2002-10-16 11:35:40 +00:00
parent f514cf51e9
commit a14b12b726
12 changed files with 860 additions and 756 deletions

View File

@ -288,12 +288,19 @@ char *CocReadVars(char *str, char stop){
if (cr==NULL) return strchr(str, '\0'); if (cr==NULL) return strchr(str, '\0');
str=cr+1; str=cr+1;
} else { } else {
str+=l;
eql=strchr(buf,'='); eql=strchr(buf,'=');
if (eql==NULL) ERR_MSG("syntax error"); if (eql==NULL) ERR_MSG("syntax error");
*eql='\0'; *eql='\0';
StrLink(&sbuf, eql+1); if (eql[1] == '\'' || eql[1]== '"') {
ERR_I(CocGetVar(buf, &sbuf, ' ')); eql=strchr(str, '=');
StrNLink(&sbuf, eql+1, 80);
ERR_I(CocGetVar(buf, &sbuf, StrNONE));
str = sbuf.buf + sbuf.rdpos;
} else {
str+=l;
StrLink(&sbuf, eql+1);
ERR_I(CocGetVar(buf, &sbuf, ' '));
}
} }
i=sscanf(str, "%79s%n", buf, &l); i=sscanf(str, "%79s%n", buf, &l);
} }

View File

@ -90,7 +90,7 @@ int CocRecv(int fd, StrBuf *buf, int timeout, int *flag) {
n=0; n=0;
ERR_SI(i=recv(fd, &n, 4, 0)); ERR_SI(i=recv(fd, &n, 4, 0));
if (i!=4) { if (i!=4) {
ERR_COD(ECONNRESET); ERR_COD(ECONNREFUSED);
} }
siz=ntohl(n); siz=ntohl(n);
if (siz > buf->dsize) if (siz > buf->dsize)

View File

@ -7,7 +7,6 @@
#------------ for DigitalUnix (add -DFORTIFY to CC_... for fortified version) #------------ for DigitalUnix (add -DFORTIFY to CC_... for fortified version)
CC_alpha_osf1=cc -std1 -g -warnprotos -I../ -I. -I../hardsup CC_alpha_osf1=cc -std1 -g -warnprotos -I../ -I. -I../hardsup
FOR_alpha_osf1=f77 -u -g FOR_alpha_osf1=f77 -u -g
TECS_PLOT_alpha_osf1=f90 -c -u -g -free tecs_plot.f
TECLI_LIB_alpha_osf1=-L/data/lnslib/lib -lpgplot -lX11 -lXm -so_archive TECLI_LIB_alpha_osf1=-L/data/lnslib/lib -lpgplot -lX11 -lXm -so_archive
SYS_FILE_alpha_osf1=sys_aunix SYS_FILE_alpha_osf1=sys_aunix
#CFLAGS_alpha_osf1= -std1 -g -warnprotos -I../ -I. -I../hardsup -DFORTIFY #CFLAGS_alpha_osf1= -std1 -g -warnprotos -I../ -I. -I../hardsup -DFORTIFY
@ -15,14 +14,12 @@ SYS_FILE_alpha_osf1=sys_aunix
#---------- for Redhat linux #---------- for Redhat linux
CC_i386_linux= gcc -I/usr/local/include -I. -I../ -I../hardsup -DLINUX -g CC_i386_linux= gcc -I/usr/local/include -I. -I../ -I../hardsup -DLINUX -g
FOR_i386_linux= g77 -u -fvxt -g FOR_i386_linux= g77 -u -fvxt -g
TECS_PLOT_i386_linux=g77 -c -u -g -ff90 -ffree-form tecs_plot.f
SYS_FILE_i386_linux=sys_linux SYS_FILE_i386_linux=sys_linux
TECLI_LIB_i386_linux=pgplot/libpgplot.a -L/usr/X11R6/lib -lX11 TECLI_LIB_i386_linux=pgplot/libpgplot.a -L/usr/X11R6/lib -lX11
#------------ #------------
CC=$(CC_$(MACHTYPE)_$(OSTYPE)) CC=$(CC_$(MACHTYPE)_$(OSTYPE))
FOR=$(FOR_$(MACHTYPE)_$(OSTYPE)) FOR=$(FOR_$(MACHTYPE)_$(OSTYPE))
TECS_PLOT=$(TECS_PLOT_$(MACHTYPE)_$(OSTYPE))
TECLI_LIB=$(TECLI_LIB_$(MACHTYPE)_$(OSTYPE)) TECLI_LIB=$(TECLI_LIB_$(MACHTYPE)_$(OSTYPE))
SYS_FILE=$(SYS_FILE_$(MACHTYPE)_$(OSTYPE)) SYS_FILE=$(SYS_FILE_$(MACHTYPE)_$(OSTYPE))
@ -46,8 +43,7 @@ libtecsl.a: $(CLI_OBJ)
all: libtecsl.a bin/TecsServer bin/TecsClient bin/keep_running all: libtecsl.a bin/TecsServer bin/TecsClient bin/keep_running
tecs_plot.o: tecs_plot.f six: bin/six
$(TECS_PLOT)
bin/TecsServer: $(SERV_OBJ) bin/TecsServer: $(SERV_OBJ)
- rm bin/TecsServer - rm bin/TecsServer
@ -60,12 +56,18 @@ bin/TecsClient: $(TECLI_OBJ)
bin/libtecs.so: tecs_c.c $(CLI_OBJ) bin/libtecs.so: tecs_c.c $(CLI_OBJ)
$(CC) -shared -o bin/libtecs.so tecs_c.c $(CLI_OBJ) $(CC) -shared -o bin/libtecs.so tecs_c.c $(CLI_OBJ)
six: six.c term.c sys_select.c libtecsl.a bin/six: six.c term.c sys_select.c libtecsl.a
$(CC) -o six six.c term.c sys_select.c libtecsl.a $(CC) -o bin/six six.c term.c sys_select.c libtecsl.a
rstart: rstart.c myc_str.o myc_err.o instr_hosts.o rstart: rstart.c myc_str.o myc_err.o instr_hosts.o
$(CC) -o rstart rstart.c myc_str.o myc_err.o instr_hosts.o $(CC) -o rstart rstart.c myc_str.o myc_err.o instr_hosts.o
serverd: serverd.c myc_str.o myc_err.o coc_util.o myc_buf.o
$(CC) -o serverd serverd.c myc_str.o myc_err.o coc_util.o myc_buf.o -lm
starts: starts.c myc_str.o myc_err.o coc_util.o myc_buf.o
$(CC) -o starts starts.c myc_str.o myc_err.o coc_util.o myc_buf.o -lm
bin/keep_running: keep_running.c bin/keep_running: keep_running.c
$(CC) -o bin/keep_running keep_running.c $(CC) -o bin/keep_running keep_running.c

View File

@ -22,13 +22,18 @@ char *StrNGet(StrBuf *buf, char *result, int reslen, int sep) {
if (f==NULL) if (f==NULL)
ERR_MSG("missing '""'"); ERR_MSG("missing '""'");
l=f-b; l=f-b;
e=strchr(f+1, sep); if (sep == StrNONE) {
if (e==NULL) { buf->rdpos=f - buf->buf + 1;
buf->rdpos = f - buf->buf + 1 + strlen(f+1); buf->seen = 0;
buf->seen=0;
} else { } else {
buf->rdpos = e - buf->buf + 1; e=strchr(f+1, sep);
buf->seen=1; if (e==NULL) {
buf->rdpos = f - buf->buf + 1 + strlen(f+1);
buf->seen=0;
} else {
buf->rdpos = e - buf->buf + 1;
buf->seen=1;
}
} }
} else { } else {
f=strchr(b, sep); f=strchr(b, sep);

View File

@ -25,7 +25,7 @@ int StrPutArray(StrBuf *buf, float val[], int size);
Read from the buffer until separator sep. Read from the buffer until separator sep.
Use the StrGet macro if the result is a fixed size. Use the StrGet macro if the result is a fixed size.
Special case sep=StrNONE: Special case sep=StrNONE:
- StrGet reads until the end of the buffer - StrGet reads until the end of the buffer or until the end of a quoted string
- StrGetInt and StrGetFloat read until the end of a legal number - StrGetInt and StrGetFloat read until the end of a legal number
*/ */
char *StrNGet(StrBuf *buf, char *result, int reslen, int sep); char *StrNGet(StrBuf *buf, char *result, int reslen, int sep);

View File

@ -25,6 +25,6 @@
#define NEW_STR(TO,FROM) {ERR_SP(TO=malloc(strlen(FROM)+1)); strcpy(TO,FROM); } #define NEW_STR(TO,FROM) {ERR_SP(TO=malloc(strlen(FROM)+1)); strcpy(TO,FROM); }
#define MALLOC(SIZE) malloc(SIZE) #define MALLOC(SIZE) malloc(SIZE)
#define FREE(PTR) free(PTR) #define FREE(PTR) { free(PTR); PTR=NULL; }
#endif /* _MEM_UTIL_H_ */ #endif /* _MEM_UTIL_H_ */

View File

@ -168,6 +168,8 @@ static char
heUnits[4], /* helium level units */ heUnits[4], /* helium level units */
alarmChannels[N_SENSORS], alarmChannels[N_SENSORS],
alarmHistory[N_SENSORS], alarmHistory[N_SENSORS],
dev[80],
devHelp[10000],
controlChannel[4]="A"; controlChannel[4]="A";
static char static char
@ -543,7 +545,7 @@ int PrepInput(char *label) {
if (i<1) ERR_MSG("missing chans"); if (i<1) ERR_MSG("missing chans");
t+=l; t+=l;
/* interprete settings until '+' appeares */ /* interprete settings until '+' appeares (after whitespace) */
ERR_P(CocReadVars(t, '+')); ERR_P(CocReadVars(t, '+'));
if (loop!=2) loop=1; if (loop!=2) loop=1;
@ -2076,6 +2078,50 @@ EndStatus:
return -1; return -1;
} }
int DevHelpHdl(int mode, void *base, int fd) {
char *t, *n, *d, *en, *ed;
char line[80], nbuf[256];
int l;
static int doit=1;
if (table!=NULL && tim>tableTime+60) { FREE(table); table=NULL; }; /* clear old table */
if (table==NULL) { /* read table */
str_copy(nbuf, binDir);
str_append(nbuf, TABLE_FILE);
ERR_P(table=str_read_file(nbuf));
tableTime=tim;
doit=1;
}
if (doit) {
doit=0;
t=table;
str_copy(devHelp,"\n");
while (t!=NULL) {
t++;
n=strchr(t, '\'');
d=strchr(t, '"');
t=strchr(t, '\n');
if (n!=NULL && d!=NULL && n < d && d < t) {
en=strchr(n+1, '\'');
ed=strchr(d+1, '"');
if (en != NULL && en<d && ed != NULL && ed<t) {
l=en-n;
if (l>12) l=12;
str_ncpy(line, n+1, l);
str_npad(line, line, 12);
l=ed-d;
if (l>77) l=77;
str_ncpy(line+12, d+1, l);
str_append(line, "\n");
str_append(devHelp, line);
}
}
}
}
return 0;
OnError: return -1;
}
int RemoteHdl(int mode, void *base, int fd) { int RemoteHdl(int mode, void *base, int fd) {
if (mode==COC_WR) { if (mode==COC_WR) {
return COC_DWR; return COC_DWR;
@ -2118,18 +2164,6 @@ int TmoHdl(int mode, void *base, int fd) {
OnError: return -1; OnError: return -1;
} }
int SerHdl(int mode, void *base, int fd) {
if (mode==COC_WR) {
return COC_DRD;
} else if (mode==COC_DRD) {
SerClose(ser);
noResp=1;
ERR_P(ser=SerOpen(host, msecTmo, IdleHdl));
}
return 0;
OnError: return -1;
}
int LogfileHdl(int mode, void *base, int fd) { int LogfileHdl(int mode, void *base, int fd) {
char buf[256]; char buf[256];
if (mode==COC_WR) { if (mode==COC_WR) {
@ -2237,7 +2271,7 @@ int main(int argc, char *argv[]) {
CocFltFld(SensorT, t0, RD); CocFltFld(SensorT, t0, RD);
CocFltFld(SensorT, t1, RD); CocFltFld(SensorT, t1, RD);
CocFltFld(SensorT, t2, RD); CocFltFld(SensorT, t2, RD);
CocFltFld(SensorT, lim, RD); CocFltFld(SensorT, lim, RW);
CocFltFld(SensorT, scale, RD); CocFltFld(SensorT, scale, RD);
CocFltFld(SensorT, alarm, RW); CocHdl(AlarmHdl); CocFltFld(SensorT, alarm, RW); CocHdl(AlarmHdl);
CocIntFld(SensorT, readStat, RD); CocIntFld(SensorT, readStat, RD);
@ -2297,6 +2331,8 @@ int main(int argc, char *argv[]) {
CocDefStr(status, RD); CocHdl(StatusHdl); CocDefStr(status, RD); CocHdl(StatusHdl);
CocDefStr(pid, RD); CocHdl(PidSumHdl); CocDefStr(pid, RD); CocHdl(PidSumHdl);
CocDefStr(config, RD); CocDefStr(config, RD);
CocDefStr(dev, RD);
CocDefStr(devHelp, RD); CocHdl(DevHelpHdl);
CocDefInt(cod1, RD); CocDefInt(cod1, RD);
CocDefInt(cod2, RD); CocDefInt(cod2, RD);
@ -2342,7 +2378,7 @@ int main(int argc, char *argv[]) {
CocAlias(int,integ); CocAlias(int,integ);
CocDefInt(msecTmo, RW); CocHdl(TmoHdl); CocDefInt(msecTmo, RW); CocHdl(TmoHdl);
CocDefStr(host, RW); CocHdl(SerHdl); CocDefStr(host, RW);
CocDefInt(port, RD); CocDefInt(port, RD);
CocDefInt(use_stdout, RW); CocHdl(LogfileHdl); CocDefInt(use_stdout, RW); CocHdl(LogfileHdl);
CocDefStr(serverId, RW); CocHdl(LogfileHdl); CocDefStr(serverId, RW); CocHdl(LogfileHdl);
@ -2395,7 +2431,7 @@ int main(int argc, char *argv[]) {
logfileOut(LOG_MAIN ,"?"); logfileOut(LOG_MAIN ,"?");
} else { } else {
CocReadVars(inistr, '\0'); CocReadVars(inistr, '\0');
free(inistr); FREE(inistr);
} }
} }
} }
@ -2451,6 +2487,11 @@ int main(int argc, char *argv[]) {
cntError=0; cntError=0;
while (!quit) { while (!quit) {
iret=MainBody(); iret=MainBody();
if (ser!=NULL && 0!=strcmp(host, ser->host)) {
SerClose(ser);
ser=NULL;
noResp=1;
}
if (iret<0 || ser==NULL) { if (iret<0 || ser==NULL) {
cntError++; cntError++;
ser=SerCheck(ser); ser=SerCheck(ser);

View File

@ -68,7 +68,7 @@ int TeccGet3(pTecsClient conn, float *tC, float *tX, float *tP) {
ERR_I(CocPutInt(conn, "readTemp", 1)); ERR_I(CocPutInt(conn, "readTemp", 1));
ERR_I(iret=CocDoIt(conn, response, sizeof(response))); ERR_I(iret=CocDoIt(conn, response, sizeof(response)));
if (iret) ERR_MSG(response); if (iret) ERR_MSG(response);
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }
@ -80,7 +80,7 @@ int TeccGet(pTecsClient conn, float *temp) {
ERR_I(CocPutInt(conn, "readTemp", 1)); ERR_I(CocPutInt(conn, "readTemp", 1));
ERR_I(iret=CocDoIt(conn, response, sizeof(response))); ERR_I(iret=CocDoIt(conn, response, sizeof(response)));
if (iret) ERR_MSG(response); if (iret) ERR_MSG(response);
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }
@ -91,7 +91,7 @@ int TeccSet(pTecsClient conn, float temp) {
ERR_I(CocPutFloat(conn, "set", temp)); ERR_I(CocPutFloat(conn, "set", temp));
ERR_I(iret=CocDoIt(conn, response, sizeof(response))); ERR_I(iret=CocDoIt(conn, response, sizeof(response)));
if (iret) ERR_MSG(response); if (iret) ERR_MSG(response);
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }
@ -153,7 +153,7 @@ int F_FUN(tecs_set_par)(F_CHAR(name), F_CHAR(par), int *show, int name_len, int
if (*show) { if (*show) {
printf("%s", response); printf("%s", response);
} }
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }
@ -202,7 +202,7 @@ int F_FUN(tecs_get_mult)(F_CHAR(names), int *time, int *nvalues, float values[],
} }
ERR_I(CocDoIt(conn, response, sizeof(response))); ERR_I(CocDoIt(conn, response, sizeof(response)));
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }
@ -211,7 +211,7 @@ int F_FUN(tecs_init)(F_CHAR(startcmd), int *port, int startcmd_len) {
STR_TO_C(sbuf, startcmd); STR_TO_C(sbuf, startcmd);
ERR_P(conn=TeccInit(sbuf, *port)); ERR_P(conn=TeccInit(sbuf, *port));
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }
@ -221,7 +221,8 @@ int F_FUN(tecs_start)(F_CHAR(startcmd), F_CHAR(host), int *port, int startcmd_le
STR_TO_C(sbuf, startcmd); STR_TO_C(sbuf, startcmd);
STR_TO_C(hbuf, host); STR_TO_C(hbuf, host);
ERR_P(conn=TeccStart(sbuf, hbuf, *port)); ERR_P(conn=TeccStart(sbuf, hbuf, *port));
return(0); if (conn->fd<0) return 1;
return 0;
OnError: return(-1); OnError: return(-1);
} }
@ -231,25 +232,25 @@ int F_FUN(tecs_rights)(int write) {
} else { } else {
ERR_I(CocSendMagic(conn, rdCode)); ERR_I(CocSendMagic(conn, rdCode));
} }
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }
int F_FUN(tecs_get)(float *temp) { int F_FUN(tecs_get)(float *temp) {
ERR_I(TeccGet(conn, temp)); ERR_I(TeccGet(conn, temp));
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }
int F_FUN(tecs_get3)(float *t1, float *t2, float *t3) { int F_FUN(tecs_get3)(float *t1, float *t2, float *t3) {
ERR_I(TeccGet3(conn, t1, t2, t3)); ERR_I(TeccGet3(conn, t1, t2, t3));
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }
int F_FUN(tecs_set)(float *temp) { int F_FUN(tecs_set)(float *temp) {
ERR_I(TeccSet(conn, *temp)); ERR_I(TeccSet(conn, *temp));
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }
@ -274,7 +275,7 @@ int F_FUN(tecs_watch_log)(F_CHAR(list), int list_len) {
char buf[16]; char buf[16];
STR_TO_C(buf, list); STR_TO_C(buf, list);
ERR_I(CocWatchLog(conn, buf)); ERR_I(CocWatchLog(conn, buf));
return(0); return 0;
OnError: return(-1); OnError: return(-1);
} }

View File

@ -56,8 +56,7 @@
else else
iret=tecs_start(start, ' ', 9753) iret=tecs_start(start, ' ', 9753)
endif endif
if (iret .ne. 0) goto 90
if (iret .lt. 0) goto 90
if (oneCommand) goto 11 if (oneCommand) goto 11

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@
#define EOT '\r' #define EOT '\r'
typedef struct { typedef struct {
char host[64];
int type; /* = ASYNSRV_TYPE */ int type; /* = ASYNSRV_TYPE */
struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */ struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */
struct RS__MsgStruct to_host; struct RS__MsgStruct to_host;
@ -27,6 +28,7 @@ typedef struct {
} AsynSrvChan; } AsynSrvChan;
typedef struct { typedef struct {
char host[64];
int type; /* = TERMSRV_TYPE */ int type; /* = TERMSRV_TYPE */
char res[SER_BUF_LEN]; char res[SER_BUF_LEN];
int fd, tmo; int fd, tmo;
@ -88,6 +90,7 @@ SerChannel *SerOpen(const char *hostPort, int msecTmo, int (*idleHdl)(int,int))
logfileOut(LOG_MAIN, "connection to %s:%d/%d opened (%d sec)\n", logfileOut(LOG_MAIN, "connection to %s:%d/%d opened (%d sec)\n",
aser->asyn_info.host, aser->asyn_info.port, aser->asyn_info.chan, aser->asyn_info.host, aser->asyn_info.port, aser->asyn_info.chan,
t2-t1); t2-t1);
str_copy(aser->host, hostPort);
return((SerChannel *)aser); return((SerChannel *)aser);
} else { } else {
NEW(tser, TermSrvChan); tser->type=TERMSRV_TYPE; NEW(tser, TermSrvChan); tser->type=TERMSRV_TYPE;
@ -103,6 +106,7 @@ SerChannel *SerOpen(const char *hostPort, int msecTmo, int (*idleHdl)(int,int))
time(&t2); time(&t2);
ecnt=0; ecnt=0;
logfileOut(LOG_MAIN, "connected to %s (%d sec)\n", hostPort, t2-t1); logfileOut(LOG_MAIN, "connected to %s (%d sec)\n", hostPort, t2-t1);
str_copy(tser->host, hostPort);
return ((SerChannel *)tser); return ((SerChannel *)tser);
} }
OnError: OnError:
@ -137,7 +141,7 @@ void SerClose(SerChannel *serch) {
if (serch->type==ASYNSRV_TYPE) { if (serch->type==ASYNSRV_TYPE) {
aser=(AsynSrvChan *)serch; aser=(AsynSrvChan *)serch;
AsynSrv_Close(&aser->asyn_info, 0); AsynSrv_Close(&aser->asyn_info, 1);
} else if (serch->type==TERMSRV_TYPE) { } else if (serch->type==TERMSRV_TYPE) {
tser=(TermSrvChan *)serch; tser=(TermSrvChan *)serch;
close(tser->fd); close(tser->fd);

View File

@ -4,6 +4,7 @@
#define SER_BUF_LEN 320 #define SER_BUF_LEN 320
typedef struct { typedef struct {
char host[64];
/* private */ /* private */
int type; int type;
} SerChannel; } SerChannel;