Files called from SICServer should now compile under linux
This commit is contained in:
@ -3,10 +3,11 @@
|
||||
#
|
||||
# Markus Zolliker, March 2000
|
||||
#--------------------------------------------------------------------------
|
||||
LIBR_OBJ= coc_util.o err_handling.o str_util.o str_buf.o sys_util.o tecs_dlog.o
|
||||
CLI_OBJ= tecs_cli.o coc_client.o
|
||||
SERV_OBJ= tecs.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o
|
||||
TCLI_OBJ= tecs_client.o tecs_plot.o tecs_for.o sys_aunix.o sys_aunix_c.o
|
||||
LIBR_OBJ= coc_util.o err_handling.o str_util.o str_buf.o
|
||||
DLOG_OBJ= sys_util.o tecs_dlog.o
|
||||
SERV_OBJ= tecs.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o $(LIBR_OBJ) $(DLOG_OBJ)
|
||||
CLI_OBJ= tecs_cli.o coc_client.o $(LIBR_OBJ)
|
||||
TCLI_OBJ= tecs_client.o tecs_plot.o tecs_for.o sys_aunix.o sys_aunix_c.o str.o cho.o $(CLI_OBJ) $(DLOG_OBJ)
|
||||
|
||||
#------------ for DigitalUnix (add -DFORTIFY to CFLAGS for fortified version)
|
||||
CC=cc
|
||||
@ -20,9 +21,9 @@ CFLAGS= -std1 -g -warnprotos -I../ -I. -I../hardsup
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $*.c
|
||||
|
||||
libtecsl.a: $(LIBR_OBJ) $(CLI_OBJ)
|
||||
libtecsl.a: $(CLI_OBJ)
|
||||
- rm libtecsl.a
|
||||
ar cr libtecsl.a $(LIBR_OBJ) $(CLI_OBJ)
|
||||
ar cr libtecsl.a $(CLI_OBJ)
|
||||
ranlib libtecsl.a
|
||||
|
||||
all: libtecsl.a bin/TecsServer tecs
|
||||
@ -30,13 +31,13 @@ all: libtecsl.a bin/TecsServer tecs
|
||||
tecs_plot.o: tecs_plot.f90
|
||||
f90 -c -g tecs_plot.f90
|
||||
|
||||
bin/TecsServer: $(LIBR_OBJ) $(SERV_OBJ)
|
||||
bin/TecsServer: $(SERV_OBJ)
|
||||
- rm bin/TecsServer
|
||||
$(CC) $(CFLAGS) -o bin/TecsServer -g $(LIBR_OBJ) $(SERV_OBJ) fortify1.c \
|
||||
$(CC) $(CFLAGS) -o bin/TecsServer -g $(SERV_OBJ) fortify1.c \
|
||||
-lm -L../hardsup -lhlib -lfor
|
||||
|
||||
tecs: $(TCLI_OBJ) $(CLI_OBJ) $(LIBR_OBJ)
|
||||
f77 -o tecs -g $(TCLI_OBJ) $(CLI_OBJ) $(LIBR_OBJ) \
|
||||
tecs: $(TCLI_OBJ)
|
||||
f77 -o tecs -g $(TCLI_OBJ) \
|
||||
-L/data/lnslib/lib -lpgplot -so_archive -lreadline -ltermcap -lX11 -lXm
|
||||
|
||||
clean:
|
||||
|
@ -99,7 +99,7 @@ int CocHandle1Request(int tmo_msec, int fd) {
|
||||
close(cl->fd);
|
||||
FD_CLR(cl->fd, &mask);
|
||||
cl0->next=cl->next;
|
||||
my_free(cl);
|
||||
FREE(cl);
|
||||
cl=cl0;
|
||||
} else {
|
||||
|
||||
@ -237,9 +237,9 @@ void CocCloseServer() {
|
||||
close(cl->fd);
|
||||
cl0=cl;
|
||||
cl=cl->next;
|
||||
my_free(cl0);
|
||||
FREE(cl0);
|
||||
}
|
||||
my_free(cList);
|
||||
FREE(cList);
|
||||
close(mainFd);
|
||||
str_free_buf(buf); str_free_buf(bufo);
|
||||
logfileClose();
|
||||
|
@ -246,8 +246,7 @@ void CocFreeVarList(CocVar **varList) {
|
||||
p=v;
|
||||
v=p->next;
|
||||
p->next=NULL;
|
||||
/* printf("my_free %s\n", p->name); */
|
||||
my_free(p);
|
||||
FREE(p);
|
||||
}
|
||||
*varList=NULL;
|
||||
}
|
||||
|
@ -93,6 +93,9 @@ void ERR_EXIT(char *text) {
|
||||
|
||||
/* FORTRAN wrappers */
|
||||
|
||||
#ifdef F_CHAR
|
||||
/* compile only when fortran c interface stuff is defined */
|
||||
|
||||
#ifdef __VMS
|
||||
#define err_show_ err_show
|
||||
#define err_txt_ err_txt
|
||||
@ -129,3 +132,5 @@ void err_set_outrtn_(void (*rtn)(), void *arg) {
|
||||
void err_short_(void) {
|
||||
ErrShort(ErrMessage);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -160,7 +160,7 @@ Str_Buf *str_create_buf(size_t size, char separator)
|
||||
{ Str_Buf *buf;
|
||||
|
||||
NEW(buf);
|
||||
ERR_P(buf->buf=my_malloc(size, "buf"));
|
||||
ERR_P(buf->buf=MALLOC(size));
|
||||
buf->dsize=size;
|
||||
buf->sep=separator;
|
||||
buf->wrpos=0;
|
||||
@ -184,6 +184,6 @@ void str_link_buf(Str_Buf *buf, char *str, int size, char separator) {
|
||||
}
|
||||
|
||||
void str_free_buf(Str_Buf *buf)
|
||||
{ my_free(buf->buf);
|
||||
my_free(buf);
|
||||
{ FREE(buf->buf);
|
||||
FREE(buf);
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ char *str_read_file(char *file) {
|
||||
i=stat(file, &statbuf);
|
||||
if (i<0) ERR_MSG("file not found");
|
||||
size=statbuf.st_size+4;
|
||||
ERR_SP(str=my_malloc(size, file));
|
||||
ERR_SP(str=MALLOC(size));
|
||||
e=&str[size-1];
|
||||
ERR_SP(fil=fopen(file, "r"));
|
||||
s=str;
|
||||
|
115
tecs/sys_aunix.f
115
tecs/sys_aunix.f
@ -82,6 +82,120 @@
|
||||
endif
|
||||
end
|
||||
|
||||
!!-----------------------------------------------------------------------------
|
||||
!!
|
||||
subroutine SYS_TEMP_NAME(NAME, PATH) !!
|
||||
!! ====================================
|
||||
!! get a temporary file name
|
||||
!!
|
||||
character*(*) NAME !! (in) name
|
||||
character*(*) PATH !! (out) path
|
||||
|
||||
character line*64, pid*5
|
||||
integer i, l
|
||||
|
||||
integer getppid
|
||||
|
||||
call sys_getenv('USER', line)
|
||||
if (line .eq. ' ') then
|
||||
call str_trim(line, '/tmp/.'//name, l)
|
||||
else
|
||||
call str_trim(line, '/tmp/.'//name//'_'//line, l)
|
||||
endif
|
||||
|
||||
write(pid,'(i5)') getppid()
|
||||
i=1
|
||||
1 if (pid(i:i) .eq. ' ') then
|
||||
i=i+1
|
||||
goto 1
|
||||
endif
|
||||
path=line(1:l)//'.'//pid(i:5)
|
||||
end
|
||||
|
||||
!!-----------------------------------------------------------------------------
|
||||
!!
|
||||
subroutine SYS_LOAD_ENV(FILE) !!
|
||||
!! =============================
|
||||
!! load environment from temporary file
|
||||
!!
|
||||
character*(*) FILE !! filename
|
||||
|
||||
character path*128, line*128
|
||||
integer lun, i, l
|
||||
|
||||
integer getppid
|
||||
|
||||
call sys_temp_name(file, path)
|
||||
call sys_get_lun(lun)
|
||||
open(lun,file=path,status='old',readonly,err=9)
|
||||
5 read(lun,'(q,a)',end=8) l, line
|
||||
l=min(l,len(line))
|
||||
i=index(line,'=')
|
||||
if (i .eq. 0) then
|
||||
if (l .gt. 0) call sys_setenv(line(1:l), ' ')
|
||||
elseif (i .gt. 1 .and. i .lt. l) then
|
||||
call sys_setenv(line(1:i-1),line(i+1:l))
|
||||
endif
|
||||
goto 5
|
||||
8 close(lun)
|
||||
9 call sys_free_lun(lun)
|
||||
end
|
||||
|
||||
!!-----------------------------------------------------------------------------
|
||||
!!
|
||||
subroutine SYS_SAVE_ENV(FILE, NAMES, N_NAMES) !!
|
||||
!! =============================================
|
||||
!! save environment on temporary file
|
||||
!!
|
||||
character*(*) FILE !! filename
|
||||
integer N_NAMES !! number of names
|
||||
character*(*) NAMES(N_NAMES) !! names of variables to save
|
||||
|
||||
character path*128, line*128
|
||||
integer lun, i, j, l
|
||||
|
||||
call sys_temp_name(file, path)
|
||||
call sys_get_lun(lun)
|
||||
|
||||
open(lun,file=path,status='unknown',carriagecontrol='list'
|
||||
1,err=19)
|
||||
|
||||
do i=1,n_names
|
||||
call sys_getenv(names(i), line)
|
||||
call str_trim(names(i),names(i), j)
|
||||
call str_trim(line,line, l)
|
||||
write(lun,'(3a)') names(i)(1:j),'=',line(1:l)
|
||||
enddo
|
||||
|
||||
close(lun)
|
||||
9 call sys_free_lun(lun)
|
||||
return
|
||||
|
||||
19 type *,'SYS_SAVE_ENV: can not open tmp. file'
|
||||
goto 9
|
||||
end
|
||||
|
||||
!!-----------------------------------------------------------------------------
|
||||
!!
|
||||
subroutine SYS_WAIT(SECONDS) !!
|
||||
!! ============================
|
||||
!! wait for SECONDS
|
||||
real SECONDS !! resolution should be better than 0.1 sec.
|
||||
|
||||
real tim, del
|
||||
|
||||
tim=secnds(0.0)
|
||||
1 del=seconds-secnds(tim)
|
||||
if (del .ge. 0.999) then
|
||||
call sleep(int(del))
|
||||
goto 1
|
||||
endif
|
||||
if (del .gt. 0) then
|
||||
call usleep(int(del*1E6))
|
||||
goto 1
|
||||
endif
|
||||
end
|
||||
|
||||
!!-----------------------------------------------------------------------------
|
||||
!!
|
||||
subroutine SYS_GET_LUN(LUN) !!
|
||||
@ -242,4 +356,3 @@
|
||||
endif
|
||||
endif
|
||||
end
|
||||
|
||||
|
@ -52,7 +52,7 @@ int called=0; /* env is valid only if called==1 */
|
||||
jmp_buf env;
|
||||
|
||||
void (*inthdl)(int sig);
|
||||
void (*errhdl)();
|
||||
void (*errhdl)(void);
|
||||
|
||||
void sighdl(int sig)
|
||||
{ if (called) longjmp(env,sig);
|
||||
@ -128,3 +128,77 @@ void sys_get_raw_key_(char *key, int *tmo, int k_len)
|
||||
ires=tcsetattr(STDIN_FILENO,TCSANOW,&atts); /* restore term. attributes */
|
||||
if (ires!=0) {perror("***\n");};
|
||||
}
|
||||
|
||||
|
||||
void usleep_(int *usec) { usleep(*usec); }
|
||||
int getppid_(void) { return getppid(); }
|
||||
|
||||
int sys_setenv_(ename,evalue,ilen1,ilen2)
|
||||
char *ename, *evalue;
|
||||
int ilen1, ilen2;
|
||||
{
|
||||
int setenv(char *p1, char *p2, int ow), i1, i2, ow, rc;
|
||||
char *p1, *p2;
|
||||
|
||||
i1 = lnblnk_(ename,ilen1);
|
||||
i2 = lnblnk_(evalue,ilen2);
|
||||
|
||||
p1 = malloc((unsigned) i1+1); if( p1 == NULL ) return (-1);
|
||||
p2 = malloc((unsigned) i2+1); if( p2 == NULL ) { free(p1); return (-1); }
|
||||
|
||||
strncpy(p1,ename,i1); p1[i1] = '\0';
|
||||
strncpy(p2,evalue,i2); p2[i2] = '\0';
|
||||
|
||||
ow = 1;
|
||||
|
||||
rc = setenv(p1, p2, ow);
|
||||
free(p1); free(p2);
|
||||
return(rc);
|
||||
}
|
||||
|
||||
struct termios atts;
|
||||
|
||||
void sys_rd_tmo_(char *prompt, char *result, int *reslen, int p_len, int r_len)
|
||||
{
|
||||
struct termios attr;
|
||||
int ires, i, ntmo, chr;
|
||||
|
||||
ires=tcgetattr(STDIN_FILENO,&attr);
|
||||
atts=attr; /* save term. attr. */
|
||||
if (ires!=0) {perror("***\n");}
|
||||
attr.c_lflag &= ~(ICANON) & ~(ECHO); /* canonical mode off, echo off */
|
||||
attr.c_cc[VMIN]=0;
|
||||
ires= tcsetattr(STDIN_FILENO,TCSANOW,&attr);
|
||||
if (ires!=0) {perror("***\n");}
|
||||
|
||||
do { chr=fgetc(stdin); } while (chr!=EOF);
|
||||
|
||||
for (i=0; i<p_len; i++)
|
||||
{ fputc(prompt[i], stderr);
|
||||
};
|
||||
|
||||
ires=fflush(stdin);
|
||||
ires=fflush(stderr);
|
||||
|
||||
*reslen=0;
|
||||
if (prompt[0]=='\0') { ntmo=10; }
|
||||
else { ntmo=200; }; /* wait 2 sec. for the first char */
|
||||
while (*reslen<r_len)
|
||||
{ chr=fgetc(stdin);
|
||||
if (chr==EOF)
|
||||
{ while ((chr==EOF) & (ntmo>0))
|
||||
{ usleep(10000); /* wait 10 ms */
|
||||
chr=fgetc(stdin);
|
||||
ntmo--;
|
||||
};
|
||||
if (chr==EOF) break;
|
||||
if (chr==10) {ntmo=10;} else {ntmo=100;}; /* wait 0.1 sec after LF, 1 sec else */
|
||||
};
|
||||
result[(*reslen)++]=(char)chr;
|
||||
if (chr==24) {(*reslen)=0;}; /* ctrl-X purges buffer */
|
||||
};
|
||||
if (result[(*reslen)-1]=10) {(*reslen)--;}; /* strip trailing LF */
|
||||
|
||||
ires=tcsetattr(STDIN_FILENO,TCSANOW,&atts); /* restore term. attributes */
|
||||
if (ires!=0) {perror("***\n");};
|
||||
}
|
||||
|
@ -2,18 +2,6 @@
|
||||
#include "str_util.h"
|
||||
#include "sys_util.h"
|
||||
|
||||
void *my_malloc(size_t size, const char *text) {
|
||||
void *ptr;
|
||||
ptr=calloc(1,size);
|
||||
/* printf("new %s %X %d\n", text, ptr, size); */
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
void my_free(void *ptr) {
|
||||
/* printf("my_free %X\n", ptr); */
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
#if __VMS
|
||||
|
||||
#include <unixio.h>
|
||||
|
@ -5,12 +5,13 @@
|
||||
#include "fortify.h"
|
||||
#endif
|
||||
|
||||
/* secure allocation stuff ---------------------------------- */
|
||||
/* secure allocation stuff ----------------------------------
|
||||
change these macros if you want to log dynamic memory access
|
||||
*/
|
||||
|
||||
#define NEW(PTR) ERR_SP(PTR=my_malloc(sizeof(*PTR),#PTR))
|
||||
|
||||
void *my_malloc(size_t size, const char *text);
|
||||
void my_free(void *ptr);
|
||||
#define NEW(PTR) ERR_SP(PTR=calloc(1,sizeof(*PTR)))
|
||||
#define MALLOC(SIZ) calloc(1,SIZ)
|
||||
#define FREE(PTR) free(PTR)
|
||||
|
||||
/* fortran interface stuff ----------------------------------
|
||||
|
||||
@ -35,7 +36,9 @@ typedef struct { short size, dummy; char *text; } SysVmsChar;
|
||||
#define STR_TO_F(DST,SRC) str_npad(DST, SRC, DST##_len)
|
||||
|
||||
#else
|
||||
#error this machine is not supported
|
||||
|
||||
/* other machines are not yet supported */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_UTIL_H_ */
|
||||
|
228
tecs/tecs.c
228
tecs/tecs.c
@ -3,6 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "sys_util.h"
|
||||
@ -15,7 +16,7 @@
|
||||
|
||||
int ftime (struct timeb *__timeptr); /* for some reason not defined in timeb.h with flag -std1 */
|
||||
|
||||
#define TABLE_FILE "lsci.tab"
|
||||
#define TABLE_FILE "tecs.tab"
|
||||
#define Progress(I) if (configuring) { configuring+=I; }
|
||||
#define undef -65535.
|
||||
|
||||
@ -25,7 +26,7 @@ static char *binDir=NULL;
|
||||
static char *logDir=NULL;
|
||||
|
||||
typedef struct {
|
||||
float t, t1, t2, min, max; /* temperatures */
|
||||
float t, t1, t2, min, max, band; /* temperatures */
|
||||
int stat1, stat2; /* reading status summary */
|
||||
int present; /* sensor is present */
|
||||
int readStat; /* reading status */
|
||||
@ -65,6 +66,8 @@ static float
|
||||
tLimit, maxPower, /* heater parameters */
|
||||
tLow=0, tHigh=0, /* lower limit of high-T sensor, upper limit of low-T sensor */
|
||||
tShift=0, /* setpoint shift */
|
||||
aux, /* auxilliary value, i.e. helium level */
|
||||
full, /* full value for helium level */
|
||||
prop, integ, deriv, /* pid */
|
||||
maxShift=2, /* maximal shift in when controlMode=2 */
|
||||
tInt=0; /* integral time (sec.) for setpoint shift */
|
||||
@ -80,6 +83,7 @@ static int
|
||||
noResp=2, /* no response */
|
||||
quit, /* quit server */
|
||||
controlMode=2, /* 0: control on heater, 1: control on sample, 3: 2nd loop for difference heater-sample */
|
||||
heliumMode, /* 0: no level meter, 1: constant current, 2: pulsed */
|
||||
int2=30, /* inegration time for controlMode 2 */
|
||||
remoteMode, /* 1: local, 2: remote */
|
||||
maxfld, /* last used display field */
|
||||
@ -115,7 +119,10 @@ static char
|
||||
chan[2], /* actual channel */
|
||||
alarms[20], /* alarm status */
|
||||
alarmList[4], /* alarm list */
|
||||
dlogfile[128];
|
||||
chanS[4], chanM[4], /* channels in input routine */
|
||||
helium[80], /* helium level status */
|
||||
dlogfile[128],
|
||||
controlChannel[2]="A";
|
||||
|
||||
static char
|
||||
*table=NULL, /* environment devices table */
|
||||
@ -217,7 +224,7 @@ int instCurve(char *nam, char *channel, int dispFld) {
|
||||
points=str_split(intype, t, '\n');
|
||||
}
|
||||
if (points==NULL) ERR_MSG("illegal curve file");
|
||||
if (cache==NULL) { ERR_SP(cache=my_malloc(1,"one")); *cache='\0'; } /* create empty cache if undefined */
|
||||
if (cache==NULL) { ERR_SP(cache=MALLOC(1)); *cache='\0'; } /* create empty cache if undefined */
|
||||
|
||||
start=strchr(cache, '\n'); /* skip permanent data */
|
||||
if (start==NULL) { start=cache; } else { start++; }
|
||||
@ -327,7 +334,7 @@ int instCurve(char *nam, char *channel, int dispFld) {
|
||||
logfileOut(LOG_MAIN, "curve selected on channel %s\n", chan);
|
||||
saveTime=tim+30;
|
||||
}
|
||||
my_free(crv); crv=NULL;
|
||||
FREE(crv); crv=NULL;
|
||||
|
||||
if (num<=20) return(0); /* standard curve, do not touch cache */
|
||||
|
||||
@ -354,83 +361,95 @@ int instCurve(char *nam, char *channel, int dispFld) {
|
||||
ERR_SI(fputc('\0', fil));
|
||||
ERR_SI(fclose(fil));
|
||||
fil=NULL;
|
||||
my_free(cache);
|
||||
FREE(cache);
|
||||
/* re-read it */
|
||||
ERR_P(cache=str_read_file(nbuf));
|
||||
return(0);
|
||||
|
||||
OnError:
|
||||
if (crv!=NULL) my_free(crv);
|
||||
if (crv!=NULL) FREE(crv);
|
||||
if (fil!=NULL) fclose(fil);
|
||||
return(retstat);
|
||||
}
|
||||
|
||||
int configInput(void) {
|
||||
char *t;
|
||||
char buf[80], nam[16], nbuf[256], ch0[4], ch[4];
|
||||
int i, n, nn, dispFld;
|
||||
char *t, *e;
|
||||
char buf[80], nam[16], nbuf[256], ch[4];
|
||||
int i, l, n, nn, dispFld;
|
||||
int retstat;
|
||||
char *ext;
|
||||
Str_Buf sbuf;
|
||||
|
||||
retstat=-2; /* errors in following section are severe */
|
||||
if (tpoint->manual) {
|
||||
sprintf(buf, "'%s'", tpoint->device);
|
||||
} else {
|
||||
sprintf(buf, "%+d ", tpoint->code);
|
||||
sprintf(buf, "%+d,", tpoint->code);
|
||||
if (tpoint->code==0) return(0);
|
||||
}
|
||||
if (table!=NULL && tim>tableTime+60) { my_free(table); table=NULL; }; /* clear old table */
|
||||
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;
|
||||
str_replace_char(table, 9, ' '); /* replace TAB (9) by space in order to find codes terminated by tab */
|
||||
}
|
||||
t=strstr(table, buf);
|
||||
if (t==NULL) ERR_MSG("device not found");
|
||||
i=sscanf(t, "%79[^\n!]", buf); /* read line */
|
||||
t=strchr(buf, '\'');
|
||||
if (t==NULL) ERR_MSG("missing ' in table file");
|
||||
t++;
|
||||
e=strchr(t, '\'');
|
||||
if (e==NULL || e>strchr(t,'\n')) ERR_MSG("missing ' or device name in table file");
|
||||
t=e+1;
|
||||
if (tpoint==&samp) {
|
||||
sens3.present=0;
|
||||
sens4.present=0;
|
||||
str_copy(ch, "C");
|
||||
i=sscanf(t, "%12s %7s %7s", nam, ch0, ch);
|
||||
if (i<1) ERR_MSG("missing sensor name");
|
||||
str_copy(ch0, "CD");
|
||||
ext=".s";
|
||||
dispFld=2;
|
||||
} else {
|
||||
sens1.present=0;
|
||||
sens2.present=0;
|
||||
ext=".x";
|
||||
dispFld=1;
|
||||
tLow=0; tHigh=0;
|
||||
controlMode=0;
|
||||
str_copy(ch, "A");
|
||||
i=sscanf(t, "%12s %s %s %d %f %d %f %f %f", nam, ch, ch0, &controlMode, &tLimit, &resist, &maxPower, &tLow, &tHigh);
|
||||
if (i<7) ERR_MSG("missing some sensor parameters");
|
||||
if (!samp.manual && (NULL!=strchr(ch0,'A') || NULL!=strchr(ch0,'B'))) {
|
||||
heliumMode=0;
|
||||
}
|
||||
chanS[0]='\0';
|
||||
chanM[0]='\0';
|
||||
|
||||
i=sscanf(t, "%12s%n", nam, &l);
|
||||
if (i<1) ERR_MSG("missing device name");
|
||||
t+=l;
|
||||
|
||||
/* interprete settings until '+' appeares */
|
||||
i=sscanf(t, "%64s%n", buf, &l);
|
||||
while (i>0 && buf[0]!='+') {
|
||||
t+=l;
|
||||
e=strchr(buf,'=');
|
||||
if (e==NULL) ERR_MSG("syntax error");
|
||||
*e='\0';
|
||||
str_link_buf(&sbuf, e+1, 0, ',');
|
||||
ERR_I(CocGetVar(serverVarList, &sbuf, buf, 0));
|
||||
i=sscanf(t, "%64s%n", buf, &l);
|
||||
}
|
||||
|
||||
if (tpoint==&samp) {
|
||||
str_copy(ch, chanS);
|
||||
} else {
|
||||
if (!samp.manual && (NULL!=strchr(chanS,'A') || NULL!=strchr(chanS,'B'))) {
|
||||
samp.dirty=1; /* sample and heat exchanger are on main plug */
|
||||
samp.code=cryo.code;
|
||||
}
|
||||
str_copy(ch0, "AB");
|
||||
ext=".x";
|
||||
dispFld=1;
|
||||
}
|
||||
n=strlen(ch);
|
||||
if (n==1) {
|
||||
if (ch[0]=='0') {
|
||||
n=0;
|
||||
} else if (ch[0]=='1') {
|
||||
ch[0]=ch0[0];
|
||||
} else if (ch[0]=='2') {
|
||||
str_copy(ch, ch0); n=2;
|
||||
str_copy(ch, chanM);
|
||||
if (heliumMode==0) {
|
||||
sprintf(helium, "no He-level meter for '%s", nam);
|
||||
} else {
|
||||
sprintf(helium, "He-level meter not yet read", nam);
|
||||
}
|
||||
} else if (n>2) {
|
||||
ERR_MSG("no more than 2 channels per plug allowed");
|
||||
}
|
||||
|
||||
n=strlen(ch);
|
||||
if (n==0) return(0);
|
||||
if (n>2) ERR_MSG("no more than 2 channels per plug allowed");
|
||||
|
||||
nam[strlen(nam)-1]='\0'; /* strip off quote */
|
||||
if (!tpoint->manual) { /* set device name */
|
||||
@ -443,13 +462,28 @@ int configInput(void) {
|
||||
tpoint->sensor1->ch[1]='\0';
|
||||
ERR_I(retstat=instCurve(nam, tpoint->sensor1->ch, dispFld));
|
||||
tpoint->sensor1->present=1;
|
||||
tpoint->sensor1->band=10;
|
||||
if (n==2) {
|
||||
if (ch[1]<'A' || ch[1]>'D') ERR_MSG("illegal channel");
|
||||
tpoint->sensor2->ch[0]=ch[1];
|
||||
tpoint->sensor2->ch[1]='\0';
|
||||
str_append(nam, "l");
|
||||
ERR_I(retstat=instCurve(nam, tpoint->sensor2->ch, dispFld+2));
|
||||
tpoint->sensor2->present=1;
|
||||
if (ch[1]>='a' && ch[1]<='d') {
|
||||
tpoint->sensor2->ch[0]=ch[1];
|
||||
tpoint->sensor2->ch[1]='\0';
|
||||
str_copy(chan, ch+1);
|
||||
logfileOut(LOG_MAIN, "auxilliary input on channel %s\n", chan);
|
||||
if (ch[0]>'b') {
|
||||
ERR_P(LscCmd(ser, "INTYPE [chan]:0,1,2,1,13;MNMX [chan]:1,3"));
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "INTYPE [chan]:0,1,2,1,12;MNMX [chan]:1,3"));
|
||||
}
|
||||
tpoint->sensor2->present=2;
|
||||
} else {
|
||||
if (ch[1]<'A' || ch[1]>'D') ERR_MSG("illegal channel");
|
||||
tpoint->sensor2->ch[0]=ch[1];
|
||||
tpoint->sensor2->ch[1]='\0';
|
||||
str_append(nam, "l");
|
||||
ERR_I(retstat=instCurve(nam, tpoint->sensor2->ch, dispFld+2));
|
||||
tpoint->sensor2->present=1;
|
||||
}
|
||||
tpoint->sensor2->band=10;
|
||||
}
|
||||
return(0);
|
||||
OnError: return(retstat);
|
||||
@ -532,12 +566,14 @@ void LogMinMax(int new) {
|
||||
s2->min=0;
|
||||
s2->max=0;
|
||||
}
|
||||
sprintf(buf, "@%.3f < T < %.3f K", cryo.tMin, cryo.tMax);
|
||||
if (samp.tMax>0.0) {
|
||||
sprintf(buf1, " (reg), %.3f < T < %.3f K (samp)", samp.tMin, samp.tMax);
|
||||
str_append(buf, buf1);
|
||||
if (cryo.tMax>0.0) {
|
||||
sprintf(buf, "@%.3f < T < %.3f K", cryo.tMin, cryo.tMax);
|
||||
if (samp.tMax>0.0) {
|
||||
sprintf(buf1, " (reg), %.3f < T < %.3f K (samp)", samp.tMin, samp.tMax);
|
||||
str_append(buf, buf1);
|
||||
}
|
||||
logfileOut(LOG_MAIN, "%s\n", buf);
|
||||
}
|
||||
logfileOut(LOG_MAIN, "%s\n", buf);
|
||||
if (new) {
|
||||
mmInt=60;
|
||||
} else if (mmInt<600) {
|
||||
@ -549,6 +585,7 @@ void LogMinMax(int new) {
|
||||
int ReadTemp(void) {
|
||||
char buf[256], bufs[256];
|
||||
int i, l, ls, stat;
|
||||
struct tm *tb;
|
||||
|
||||
readTemp=0;
|
||||
|
||||
@ -568,17 +605,17 @@ int ReadTemp(void) {
|
||||
}
|
||||
}
|
||||
if (ls>0) {
|
||||
bufs[ls-1]='\0'; /* strip off ';' */
|
||||
ERR_P(LscCmd(ser, bufs));
|
||||
str_append(buf, "MNMXRST");
|
||||
buf[l-1]='\0'; /* strip off ';' */
|
||||
ERR_P(LscCmd(ser, buf));
|
||||
str_append(bufs, "MNMXRST");
|
||||
ERR_P(LscCmd(ser, bufs));
|
||||
}
|
||||
|
||||
/* check for reading errors */
|
||||
for (i=1; i<=4; i++) {
|
||||
sensor=sensors[i];
|
||||
if (sensor->present) {
|
||||
stat=sensor->stat1 | sensor->stat2;
|
||||
stat=(sensor->stat1 | sensor->stat2) & 255;
|
||||
if (stat != sensor->readStat) {
|
||||
sensor->readStat=stat;
|
||||
if (stat & 1) logfileOut(LOG_MAIN, "invalid reading %s\n", sensor->ch);
|
||||
@ -591,12 +628,39 @@ int ReadTemp(void) {
|
||||
if (stat==0) logfileOut(LOG_MAIN, "reading o.k. %s\n", sensor->ch);
|
||||
}
|
||||
if (stat==0) {
|
||||
if (sensor->t1 < 0.8*sensor->t2) {
|
||||
|
||||
if (sensor->present==2 && heliumMode==2) {
|
||||
sensor->t = sensor->t1; /* take minimum only */
|
||||
} else if (sensor->t2 - sensor->t1 <= sensor->band*2) { /* normal case */
|
||||
sensor->t = (sensor->t1 + sensor->t2) * 0.5; /* mean of min and max */
|
||||
sensor->band = sensor->band/2;
|
||||
} else { /* probably noisy values */
|
||||
logfileOut(LOG_MAIN, "min/max %s: %f %f\n", sensor->ch, sensor->t1, sensor->t2);
|
||||
if (fabs(sensor->t1 - sensor->t) < fabs(sensor->t2 - sensor->t) ) {
|
||||
sensor->t=sensor->t1;
|
||||
sensor->t2 = sensor->t1;
|
||||
} else {
|
||||
sensor->t=sensor->t2;
|
||||
sensor->t1 = sensor->t1;
|
||||
}
|
||||
sensor->t1 = sensor->t;
|
||||
sensor->t2 = sensor->t;
|
||||
}
|
||||
if (sensor->present==2) {
|
||||
aux=sensor->t; sensor->t=0;
|
||||
if (full>0 && heliumMode>0) {
|
||||
tb=localtime(&tim);
|
||||
if (aux<full && aux>0) {
|
||||
sprintf(helium, "%5.1f %% (%02d.%02d., %02d:%02d)", 100.0*aux/full
|
||||
, tb->tm_mday, tb->tm_mon+1, tb->tm_hour, tb->tm_min);
|
||||
}
|
||||
}
|
||||
}
|
||||
sensor->t = (sensor->t1 + sensor->t2) * 0.5; /* mean of min and max */
|
||||
if (sensor->t1 < sensor->min || sensor->min==0.0) sensor->min = sensor->t1;
|
||||
if (sensor->t2 > sensor->max) sensor->max = sensor->t2;
|
||||
if (sensor->max - sensor->min > sensor->band) {
|
||||
sensor->band = sensor->max - sensor->min;
|
||||
}
|
||||
} else {
|
||||
sensor->t=0;
|
||||
}
|
||||
@ -604,7 +668,7 @@ int ReadTemp(void) {
|
||||
sensor->t=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cryo.temp=WeightedAverage(sens1.t, sens2.t)*cryo.scale;
|
||||
samp.temp=WeightedAverage(sens3.t, sens4.t)*samp.scale;
|
||||
if (samp.temp==0.0) samp.temp=cryo.temp;
|
||||
@ -624,20 +688,22 @@ int SetTemp(int switchOn) {
|
||||
char *ch;
|
||||
float scale;
|
||||
|
||||
if (tempC>tLimit) tempC=tLimit;
|
||||
if (tempC>tLimit) {
|
||||
tempC=tLimit;
|
||||
logfileOut(LOG_MAIN, "set point too high, reset to %f\n", tempC);
|
||||
}
|
||||
if (switchOn) {
|
||||
ERR_I(ReadTemp());
|
||||
LogMinMax(1);
|
||||
logfileOut(LOG_MAIN, "set %.3f\n", tempC);
|
||||
}
|
||||
scale=cryo.scale;
|
||||
ch=sens1.ch;
|
||||
if (sens2.present && tempC<(tLow+tHigh)/2) ch=sens2.ch;
|
||||
if (sens2.present==1 && tempC<(tLow+tHigh)/2) ch=sens2.ch;
|
||||
if (sens3.present) {
|
||||
if (controlMode==1) { /* control directly on sample sensor */
|
||||
tShift=0;
|
||||
ch=sens3.ch;
|
||||
if (sens2.present && tempC<(tLow+tHigh)/2) ch=sens4.ch;
|
||||
if (sens3.t!=0) ch=sens3.ch;
|
||||
if (sens4.present==1 && tempC<(tLow+tHigh)/2 && sens4.t!=0) ch=sens4.ch;
|
||||
scale=samp.scale;
|
||||
} else if (controlMode!=2) {
|
||||
tShift=0;
|
||||
@ -660,11 +726,16 @@ int SetTemp(int switchOn) {
|
||||
ERR_P(LscCmd(ser, "CSET 1:[chan],1,1,0;RANGE:0;SETP 1:0"));
|
||||
} else if (remoteMode==1) { /* in local mode: do not switch on heater */
|
||||
ERR_P(LscCmd(ser, "SETP 1:[tempH]"));
|
||||
ch=controlChannel;
|
||||
} else if (switchOn || (htrst>=5 && relay==0)) { /* switch on also when bad heater message and no alarms */
|
||||
ERR_P(LscCmd(ser, "CSET 1:[chan],1,1,0;RANGE:[iRange];SETP 1:[tempH]"));
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "CSET 1:[chan],1;SETP 1:[tempH]"));
|
||||
}
|
||||
if (0!=strcmp(ch, controlChannel) || switchOn) {
|
||||
str_copy(controlChannel, ch);
|
||||
logfileOut(LOG_MAIN, "set %f (on %s)\n", tempC, ch);
|
||||
}
|
||||
return(0);
|
||||
OnError: return(-1);
|
||||
}
|
||||
@ -690,12 +761,12 @@ int PeriodicTask(void) {
|
||||
if (0!=strcmp(buf1, "LSCI") || 0!=strcmp(buf2, "MODEL340") || serialNo==0) return(0);
|
||||
if (k!=serialNo) { /* controller exchanged or we are initializing */
|
||||
if (!configuring) {
|
||||
str_copy(status, "controller connected");
|
||||
logfileOut(LOG_MAIN, "controller connected\n");
|
||||
}
|
||||
if (remoteMode==2) configuring++;
|
||||
tempC=0;
|
||||
/* reload curve cache: */
|
||||
if (cache!=NULL) my_free(cache);
|
||||
if (cache!=NULL) FREE(cache);
|
||||
sprintf(lbuf, "lsc.%d", serialNo);
|
||||
str_copy(buf, logDir);
|
||||
str_append(buf, lbuf);
|
||||
@ -797,7 +868,7 @@ int PeriodicTask(void) {
|
||||
t3[1]=samp.temp;
|
||||
i=2;
|
||||
} else {
|
||||
if (sens2.present) {
|
||||
if (sens2.present==1) {
|
||||
t3[1]=sens2.t;
|
||||
i=2;
|
||||
} else {
|
||||
@ -818,7 +889,7 @@ int PeriodicTask(void) {
|
||||
if (tempC!=0) {
|
||||
if (sens1.present && sens3.present && controlMode==2) {
|
||||
t=sens1.t;
|
||||
if (sens2.present && tempC<(tLow+tHigh)/2) t=sens2.t;
|
||||
if (sens2.present==1 && tempC<(tLow+tHigh)/2) t=sens2.t;
|
||||
d=(tempH-t)/t-1.0; /* relative difference */
|
||||
w=exp(-d*d*230); /* gaussian */
|
||||
if (w<0.1) tInt=0; /* reset when far from setpoint (more than 10 %) */
|
||||
@ -861,12 +932,12 @@ int PeriodicTask(void) {
|
||||
if (tpoint->codChanged) { /* code change confirmed */
|
||||
tpoint->codChanged=0;
|
||||
Progress(1);
|
||||
tpoint->manual=0;
|
||||
if (tpoint->code1==0) {
|
||||
logfileOut(LOG_MAIN, "%s unplugged\n", tpoint->tname);
|
||||
} else {
|
||||
logfileOut(LOG_MAIN, "plugged %d on %s\n", tpoint->code1, tpoint->tname);
|
||||
}
|
||||
tpoint->manual=0;
|
||||
tempC=0;
|
||||
remoteMode=2; /* set to remote mode */
|
||||
LscCmd(ser, "MODE:[remoteMode]");
|
||||
@ -893,7 +964,11 @@ int PeriodicTask(void) {
|
||||
ERR_P(LscCmd(ser, "RANGE?>iRange"));
|
||||
if (iRange==0) tempC=0;
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "RANGE?>iRange;SETP?1>tempC"));
|
||||
ERR_P(LscCmd(ser, "RANGE?>iRange;CSET?1>,cod1,;SETP?1>tempC"));
|
||||
if (cod1!=1) {
|
||||
tempC=0;
|
||||
logfileOut(LOG_MAIN, "set point was not in K, set to 0\n");
|
||||
}
|
||||
}
|
||||
setFlag=(iRange>0);
|
||||
}
|
||||
@ -921,6 +996,9 @@ int inputSettings(Testpoint *this) {
|
||||
} else {
|
||||
if (tpoint->code==0) {
|
||||
logfileOut(LOG_MAIN ,"reset %s inputs\n", tpoint->tname);
|
||||
if (cryo.code==0 && samp.code==0) {
|
||||
logfileOut(LOG_MAIN, "no more sensor connected\n");
|
||||
}
|
||||
} else {
|
||||
logfileOut(LOG_MAIN ,"configure %s inputs for code %+d\n", tpoint->tname, tpoint->code);
|
||||
}
|
||||
@ -988,7 +1066,7 @@ int Display(void) {
|
||||
s=sensors[i];
|
||||
if (s->present) {
|
||||
flds[k]=s->ch[0];
|
||||
fmt[k]='1';
|
||||
if (s->present==1) { fmt[k]='1'; } else { fmt[k]='3'; } /* special value */
|
||||
if (k>maxfld) maxfld=k;
|
||||
} else {
|
||||
flds[k]='\0';
|
||||
@ -1075,7 +1153,7 @@ int Settings(void) {
|
||||
p=str_split(buf, p, '\n');
|
||||
ERR_P(LscCmd(ser, buf));
|
||||
}
|
||||
my_free(cfg);
|
||||
FREE(cfg);
|
||||
} else {
|
||||
cryo.scale=1;
|
||||
samp.scale=1;
|
||||
@ -1085,7 +1163,7 @@ int Settings(void) {
|
||||
}
|
||||
return(0);
|
||||
OnError:
|
||||
if (cfg!=NULL) my_free(cfg);
|
||||
if (cfg!=NULL) FREE(cfg);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -1322,7 +1400,11 @@ int main(int argc, char *argv[])
|
||||
CocDefFlt(deriv, pidFlag);
|
||||
CocDefFlt(tempC, setFlag);
|
||||
CocDefFlt(tempH, CocRD);
|
||||
CocDefFlt(aux, CocRD);
|
||||
CocDefFlt(full, CocWR);
|
||||
CocDefFlt(tLimit, CocRD);
|
||||
CocDefFlt(tLow, CocRD);
|
||||
CocDefFlt(tHigh, CocRD);
|
||||
CocDefFlt(maxShift, CocWR);
|
||||
|
||||
CocDefStr(device, deviceFlag);
|
||||
@ -1333,6 +1415,9 @@ int main(int argc, char *argv[])
|
||||
CocDefStr(buf4, CocRD);
|
||||
CocDefStr(head, CocRD);
|
||||
CocDefStr(chan, CocRD);
|
||||
CocDefStr(chanS, CocRD);
|
||||
CocDefStr(chanM, CocRD);
|
||||
CocDefStr(helium, CocRD);
|
||||
CocDefStr(intype, CocRD);
|
||||
CocDefStr(status, CocRD);
|
||||
CocDefStr(dlogfile, CocRD);
|
||||
@ -1350,6 +1435,7 @@ int main(int argc, char *argv[])
|
||||
CocDefInt(iAmp, CocRD);
|
||||
CocDefInt(iRange, CocRD);
|
||||
CocDefInt(remoteMode, CocRD);
|
||||
CocDefInt(heliumMode, CocRD);
|
||||
CocDefInt(htrst, CocRD);
|
||||
|
||||
CocDefInt(logPeriod, CocWR);
|
||||
|
@ -13,7 +13,11 @@ pTecsClient TeccInit(char *startcmd, int port) {
|
||||
CocConn *conn;
|
||||
|
||||
NEW(conn);
|
||||
ERR_I(CocInitClient(conn, "", port, "#rwacs", 0, startcmd));
|
||||
if (startcmd[0]=='#') {
|
||||
ERR_I(CocInitClient(conn, startcmd+1, port, "#rwacs", 0, ""));
|
||||
} else {
|
||||
ERR_I(CocInitClient(conn, "", port, "#rwacs", 0, startcmd));
|
||||
}
|
||||
CocDefFlt(tempC, CocRD);
|
||||
CocDefFlt(tempP, CocRD);
|
||||
CocDefFlt(tempX, CocRD);
|
||||
@ -115,7 +119,7 @@ int TeccQuitServer(pTecsClient conn) {
|
||||
void TeccClose(pTecsClient conn) {
|
||||
if (conn!=NULL) {
|
||||
CocCloseClient(conn);
|
||||
my_free(conn);
|
||||
FREE(conn);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,6 +130,10 @@ void TeccClose(pTecsClient conn) {
|
||||
|
||||
*/
|
||||
|
||||
#ifdef F_CHAR
|
||||
/* compile only when fortran c interface stuff is defined */
|
||||
|
||||
|
||||
#ifdef __VMS
|
||||
#define tecs_get_par_ tecs_get_par
|
||||
#define tecs_set_par_ tecs_set_par
|
||||
@ -211,3 +219,4 @@ int tecs_quit_server_(void) {
|
||||
return(TeccQuitServer(conn));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -96,6 +96,7 @@
|
||||
l=0
|
||||
goto 11
|
||||
elseif (cmd .eq. 'plot') then
|
||||
call cho_choose('G')
|
||||
iret=tecs_get_par('dlogfile', file)
|
||||
if (iret .lt. 0) goto 19
|
||||
call tecs_plot(file)
|
||||
|
@ -1,6 +1,9 @@
|
||||
parameter version=106, recs=1024, mdat=4, recl=mdat*recs
|
||||
parameter step=5, size=8*24*3600/step, dirlen=size/recs+1
|
||||
parameter undef=-65535.0
|
||||
integer version, recs, mdat, recl
|
||||
parameter (version=106, recs=1024, mdat=4, recl=mdat*recs)
|
||||
integer step,size,dirlen
|
||||
parameter (step=5, size=8*24*3600/step, dirlen=size/recs+1)
|
||||
real undef
|
||||
parameter (undef=-65535.0)
|
||||
|
||||
integer lunw, lunr, wrec, rrec
|
||||
integer vers, stim, etim
|
||||
|
@ -31,6 +31,10 @@ subroutine tecs_plot(file)
|
||||
right=.true.
|
||||
call pgopen(" ")
|
||||
call pgqinf('TYPE', buf, l)
|
||||
if (buf=='NULL') then
|
||||
print *,'No PGPLOT-Device defined'
|
||||
goto 9
|
||||
endif
|
||||
xwin=(buf(1:1)=='X')
|
||||
live=.not. xwin ! live switched off by default on X-Windows
|
||||
|
||||
|
Reference in New Issue
Block a user