- extended evcontroller
- remote objects - new ev drivers for oxford IPS,ITC,ILM and LC M.Z.
This commit is contained in:
13
tecs/didi
13
tecs/didi
@@ -42,7 +42,7 @@ foreach dest ($destlist)
|
||||
endif
|
||||
end
|
||||
|
||||
set items=(TecsServer TecsClient six keep_running cfg)
|
||||
set items=(TecsServer TecsClient six keep_running)
|
||||
|
||||
echo ""
|
||||
echo " all $items"
|
||||
@@ -70,21 +70,12 @@ if ($this == $0) then
|
||||
endif
|
||||
cd $this
|
||||
|
||||
set makeit=1
|
||||
set obj=../../obj/$SICS_VERSION/psi/tecs
|
||||
foreach dest ($where)
|
||||
alias get 'set d=$'"d_$dest;"'set t=$'"t_$dest"
|
||||
get
|
||||
foreach item ($what)
|
||||
echo $item D $d T $t
|
||||
if ($item == cfg) then
|
||||
if ($makeit) then
|
||||
make config
|
||||
set makeit=0
|
||||
endif
|
||||
echo tecs $d
|
||||
rsync -e ssh -rCtv --delete-excluded $obj/cfg $d
|
||||
else if ("$t" == "$OSTYPE") then
|
||||
if ("$t" == "$OSTYPE") then
|
||||
echo $item to $d
|
||||
rsync -e ssh -vt $obj/$item $d
|
||||
endif
|
||||
|
||||
@@ -9,7 +9,7 @@ foreach file ($files)
|
||||
echo ' $Q -p$(CFGDIR)' >> src/make_crv
|
||||
echo '' >> src/make_crv
|
||||
end
|
||||
echo "all_crv: \" >> src/make_crv
|
||||
echo "all_crv: dev.list \" >> src/make_crv
|
||||
foreach file ($files)
|
||||
set sens=${file:t:s/.inp//}
|
||||
echo ' $(CFGDIR)'"$sens.crv \" >> src/make_crv
|
||||
|
||||
@@ -39,6 +39,10 @@ CFGDIR=/afs/psi.ch/project/sinq/common/lib/tecs/cfg/
|
||||
$(SRC)make_crv: make_crv.tcsh inp/lsc.codes $(ALLINP)
|
||||
$(SRC)make_crv.tcsh $(SRC)inp/lsc.codes
|
||||
|
||||
dev.list:
|
||||
$(SRC)make_list.tcsh $(CFGDIR)*.cfg > $@
|
||||
cp $@ $(CFGDIR)
|
||||
|
||||
# use target all_crv to make all curves in inp directory
|
||||
|
||||
TecsServer: $(SERV_OBJ) $(HARDSUPLIB) $(FORTIFYOBJ)
|
||||
|
||||
@@ -227,31 +227,38 @@ void StrNLink(StrBuf *buf, char *str, int length) {
|
||||
|
||||
void flt_to_char4(double f, char buf[4]) {
|
||||
double m;
|
||||
int e, res, ir;
|
||||
int e;
|
||||
long res;
|
||||
|
||||
m=frexp(f, &e);
|
||||
e=e+EXP_OFFS;
|
||||
if (e<0 || m==0) {
|
||||
res=0; m=0;
|
||||
m = frexp(f, &e);
|
||||
e += EXP_OFFS;
|
||||
if (e < 0 || m == 0) {
|
||||
res = 0; m = 0;
|
||||
} else {
|
||||
if (e>255) {
|
||||
res=255*TWO_23+(TWO_23-1); /* max. representable number */
|
||||
if (e > 255) {
|
||||
res = 255 * TWO_23 + (TWO_23 - 1); /* max. representable number */
|
||||
} else {
|
||||
res=e*TWO_23+(int)(0.5+(fabs(m*2)-1.0)*TWO_23);
|
||||
res = (long)(0.5 + (fabs(m * 2) - 1.0) * TWO_23);
|
||||
/* here we may think about the case, where m is just a little less than 1.0:
|
||||
the mantissa part overflows to bit23, but, the result would be o.k., since this
|
||||
just increases the exponent by one, and the mantissa bits get all zero.
|
||||
but what happens when e is already 255 ? the next line handles this */
|
||||
if (res == TWO_23 && e == 255) res--;
|
||||
res += e * TWO_23;
|
||||
}
|
||||
}
|
||||
buf[0]=res % 256; res=res/256;
|
||||
buf[1]=res % 256; res=res/256;
|
||||
buf[2]=res % 256; res=res/256;
|
||||
if (m<0) {
|
||||
buf[3]=res-128;
|
||||
buf[0] = res % 256; res = res / 256;
|
||||
buf[1] = res % 256; res = res / 256;
|
||||
buf[2] = res % 256; res = res / 256;
|
||||
if (m < 0) {
|
||||
buf[3] = res - 128;
|
||||
} else {
|
||||
buf[3]=res;
|
||||
buf[3] = res;
|
||||
}
|
||||
}
|
||||
|
||||
double flt_from_char4(char buf[4]) {
|
||||
int s, i, b0, b1, b2, b3;
|
||||
long i, b0, b1, b2, b3;
|
||||
|
||||
b0=buf[0]; if (b0<0) b0+=256;
|
||||
b1=buf[1]; if (b1<0) b1+=256;
|
||||
|
||||
@@ -2195,13 +2195,15 @@ static int xw_read_cursor(xw, mode, posn, ref, pos, key)
|
||||
/*
|
||||
* Discard un-handled ButtonPress, KeyPress and MotionNotify events.
|
||||
*/
|
||||
if (xw->nofocus) { /* M.Z. */
|
||||
/* removed M.Z.
|
||||
if (xw->nofocus) {
|
||||
while(xw_check_window_event(xw, xw->window, (long)
|
||||
(ButtonPressMask | PointerMotionMask), &event));
|
||||
} else {
|
||||
while(xw_check_window_event(xw, xw->window, (long)
|
||||
(ButtonPressMask | KeyPressMask | PointerMotionMask), &event));
|
||||
}
|
||||
*/
|
||||
if(xw->bad_device)
|
||||
return xw_end_cursor(xw, bc, 1);
|
||||
xw->nofocus=0; /* M.Z. */
|
||||
@@ -2326,9 +2328,10 @@ static int xw_read_cursor(xw, mode, posn, ref, pos, key)
|
||||
case MotionNotify:
|
||||
/*
|
||||
* Discard all but the last MotionNotify event.
|
||||
*/
|
||||
*/
|
||||
while(xw_check_window_event(xw, xw->window, (long)(PointerMotionMask),
|
||||
&event));
|
||||
|
||||
if(xw->bad_device || xw_erase_cursor(xw, bc))
|
||||
return xw_end_cursor(xw, bc, 1);
|
||||
last.x = event.xmotion.x;
|
||||
@@ -3548,7 +3551,7 @@ static int xw_next_event(xw, event)
|
||||
}
|
||||
|
||||
/*.......................................................................
|
||||
* like xw_next_event (see above), but with timeout in decisSecs (M.Z.)
|
||||
* like xw_next_event (see above), but with timeout in deciSecs (M.Z.)
|
||||
*/
|
||||
#ifdef __STDC__
|
||||
static int xw_next_event_tmo(XWdev *xw, XEvent *event, int tmo_10)
|
||||
|
||||
20
tecs/six.c
20
tecs/six.c
@@ -259,18 +259,6 @@ int setrights(int gotolevel) {
|
||||
} else {
|
||||
deflevel=2;
|
||||
}
|
||||
/*
|
||||
if (NULL != strstr(instr, "TASP")) {
|
||||
if (user1[0]=='\0') {
|
||||
str_copy(user1,"Spy");
|
||||
str_copy(pswd1,"007");
|
||||
}
|
||||
if (user2[0]=='\0') {
|
||||
str_copy(user2,"Spy");
|
||||
str_copy(pswd2,"007");
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (gotolevel==0) gotolevel=deflevel;
|
||||
if (gotolevel==1) {
|
||||
if (user1[0]=='\0') {
|
||||
@@ -401,6 +389,7 @@ int main (int argc, char *argv[]) {
|
||||
int iret, pos;
|
||||
fd_set mask;
|
||||
int l, i, j, port, skip, gotolevel, sicslogin;
|
||||
int savehist = 0;
|
||||
char buf[128], lbuf[16], ilow[64];
|
||||
char stdPrompt[128], prompt[256];
|
||||
char *sim="";
|
||||
@@ -527,6 +516,7 @@ int main (int argc, char *argv[]) {
|
||||
pos=0;
|
||||
|
||||
term_read_hist("six");
|
||||
savehist = 1;
|
||||
|
||||
while (1) {
|
||||
if (*p=='E') { /* Eager to ... */
|
||||
@@ -589,15 +579,17 @@ int main (int argc, char *argv[]) {
|
||||
assert(fd==iret);
|
||||
ERR_P(p=readWrite(fd,1000,0,"status = "));
|
||||
if (strcmp(p, "0") == 0) {
|
||||
printf("\nconnection lost\n");
|
||||
term_clear();
|
||||
printf("\nconnection lost");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fputs("\n", stdout);
|
||||
printf("\nexit %s\n", prompt);
|
||||
term_save_hist(1); /* save history without last line */
|
||||
return 0;
|
||||
OnError:
|
||||
if (savehist) term_save_hist(0); /* save history with last line */
|
||||
ErrShow("end");
|
||||
return 0;
|
||||
}
|
||||
|
||||
87
tecs/tecs.c
87
tecs/tecs.c
@@ -21,6 +21,7 @@
|
||||
#endif
|
||||
|
||||
#define TABLE_FILE "tecs.cfg"
|
||||
#define DEV_LIST "dev.list"
|
||||
#define LSC_CODES "lsc.codes"
|
||||
#define LOGLIFETIME 24*3600
|
||||
|
||||
@@ -168,8 +169,7 @@ static int
|
||||
swRangeOn=0, /* switch heater range on when controller switched it off */
|
||||
initMaxPower=0, /* set MaxPower for the first time */
|
||||
lockAlarm,
|
||||
cntError,
|
||||
tableTime; /* last time when table was read */
|
||||
cntError;
|
||||
|
||||
int tim, rdTim; /* actual time, read Time */
|
||||
|
||||
@@ -536,14 +536,12 @@ int InstalCurve(SensorT *sensor, char *devArg) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ReadTable(void) {
|
||||
int ReadTable(void) { /* obsolete */
|
||||
char nbuf[256];
|
||||
if (table!=NULL && tim>tableTime+60) { FREE(table); table=NULL; }; /* clear old table */
|
||||
if (table!=NULL) return 0;
|
||||
if (table!=NULL) { FREE(table); table=NULL; };
|
||||
str_copy(nbuf, binDir);
|
||||
str_append(nbuf, TABLE_FILE);
|
||||
ERR_P(table=str_read_file(nbuf));
|
||||
tableTime=tim;
|
||||
return 1;
|
||||
OnError: return -1;
|
||||
}
|
||||
@@ -574,11 +572,13 @@ int PrepInput(char *label) {
|
||||
} else {
|
||||
str_copy(nam, label);
|
||||
}
|
||||
again:
|
||||
str_copy(buf, binDir);
|
||||
str_append(buf, nam);
|
||||
str_append(buf, ".cfg");
|
||||
cfg=str_read_file(buf);
|
||||
if (cfg==NULL) { /* will be obsolete */
|
||||
logfileOut(LOG_MAIN, "%s not found, try tecs.cfg\n", buf);
|
||||
ERR_I(ReadTable());
|
||||
t=strstr(table, label);
|
||||
if (t==NULL) ERR_MSG("device not found");
|
||||
@@ -586,6 +586,14 @@ int PrepInput(char *label) {
|
||||
if (e==NULL || e>strchr(t,'\n')) ERR_MSG("missing ' or device name in table file");
|
||||
t=e+1;
|
||||
}
|
||||
if (cfg && *cfg=='@') { /* alias */
|
||||
t=strchr(cfg,'\n');
|
||||
if (t) *t='\0';
|
||||
str_copy(nam, cfg+1);
|
||||
str_copy(plug->device, nam);
|
||||
FREE(cfg);
|
||||
goto again;
|
||||
}
|
||||
if (plug==&plug0) {
|
||||
InitSensor(&sensA);
|
||||
InitSensor(&sensB);
|
||||
@@ -694,8 +702,15 @@ int PrepInput(char *label) {
|
||||
str_copy(plug->device, nam);
|
||||
ConcatDevice();
|
||||
}
|
||||
if (cfg) {
|
||||
FREE(cfg);
|
||||
}
|
||||
return 0;
|
||||
OnError: return -1;
|
||||
OnError:
|
||||
if (cfg) {
|
||||
FREE(cfg);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int LoadCache(void) {
|
||||
@@ -1708,12 +1723,17 @@ int ConfigByCode(int plugNr) {
|
||||
}
|
||||
p=fgets(buf, sizeof(buf), fil);
|
||||
}
|
||||
fclose(fil);
|
||||
logfileOut(LOG_MAIN+LOG_STAT ,"configure plug%d for %s (code %d)\n", plugNr, nam, plug->code);
|
||||
str_copy(buf, "'");
|
||||
str_append(buf, nam);
|
||||
str_append(buf, "'");
|
||||
ERR_I(PrepInput(buf));
|
||||
fclose(fil);
|
||||
if (plug->code != c1 && plug->code != c2) {
|
||||
logfileOut(LOG_MAIN+LOG_STAT ,"unknown code %d on plug%d\n", plug->code, plugNr);
|
||||
return 0;
|
||||
} else {
|
||||
logfileOut(LOG_MAIN+LOG_STAT ,"configure plug%d for %s (code %d)\n", plugNr, nam, plug->code);
|
||||
str_copy(buf, "'");
|
||||
str_append(buf, nam);
|
||||
str_append(buf, "'");
|
||||
ERR_I(PrepInput(buf));
|
||||
}
|
||||
}
|
||||
settingsFlag=1;
|
||||
return 0;
|
||||
@@ -2606,39 +2626,14 @@ EndStatus:
|
||||
}
|
||||
|
||||
int DevHelpHdl(int mode, void *base, int fd) {
|
||||
char *t, *n, *d, *en, *ed;
|
||||
char line[80], nbuf[256];
|
||||
int l, iret;
|
||||
static int doit=1;
|
||||
char nbuf[256];
|
||||
char *list;
|
||||
|
||||
ERR_I(iret=ReadTable());
|
||||
if (iret) doit=1;
|
||||
if (doit) {
|
||||
doit=0;
|
||||
t=table;
|
||||
str_copy(devHelp,"\n");
|
||||
while (t!=NULL) {
|
||||
t++;
|
||||
n=strchr(t, '\'');
|
||||
d=strstr(t, "dev=\"");
|
||||
t=strchr(t, '\n');
|
||||
if (n!=NULL && d!=NULL && n < d && d < t) {
|
||||
en=strchr(n+1, '\'');
|
||||
ed=strchr(d+5, '"');
|
||||
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+5, l);
|
||||
str_append(line, "\n");
|
||||
str_append(devHelp, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
str_copy(nbuf, binDir);
|
||||
str_append(nbuf, DEV_LIST);
|
||||
ERR_P(list=str_read_file(nbuf));
|
||||
str_copy(devHelp, list);
|
||||
FREE(list);
|
||||
return 0;
|
||||
OnError: return -1;
|
||||
}
|
||||
@@ -2901,7 +2896,7 @@ int main(int argc, char *argv[]) {
|
||||
CocDefInt(relay, RW); CocHdl(RelayHdl);
|
||||
CocDefInt(manual, RW); CocHdl(ManualHdl);
|
||||
CocDefInt(htrst, RD);
|
||||
CocDefInt(loop, RD);
|
||||
CocDefInt(loop, RW);
|
||||
CocDefInt(rdTim, RD);
|
||||
CocDefInt(tim0, RD);
|
||||
CocDefInt(ibuf, RD);
|
||||
|
||||
@@ -73,7 +73,8 @@
|
||||
l=0
|
||||
1 if (oneCommand) goto 99
|
||||
if (nfiles .gt. 0) then
|
||||
read(luns(idx), '(q,a)', err=22,end=22) l, line
|
||||
read(luns(idx), '(a)', err=22,end=22) line
|
||||
call str_trim(line, line, l)
|
||||
print '(x,2a)', prompt(1:promptlen),line(1:max(1,l))
|
||||
else
|
||||
call sys_rd_line(line, l, prompt(1:promptlen))
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
logical yzoom
|
||||
integer winconf(nwin) ! number of windows below actual
|
||||
integer showsets
|
||||
integer nextfocus
|
||||
real winh
|
||||
integer nticks
|
||||
character key*1
|
||||
@@ -128,6 +129,7 @@
|
||||
allpars=allpars(1:l)//' '//parnam(im)
|
||||
enddo
|
||||
showsets=1
|
||||
nextfocus=0
|
||||
|
||||
1 continue
|
||||
|
||||
@@ -135,6 +137,10 @@
|
||||
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 .gt. 7200 .or. tdif .lt. -7200) then ! a hack
|
||||
t=myc_now()
|
||||
tdif=0
|
||||
endif
|
||||
if (tdif .ne. 0) then
|
||||
print *,'time difference ',tdif/3600,' h'
|
||||
endif
|
||||
@@ -258,16 +264,18 @@
|
||||
endif
|
||||
enddo
|
||||
if (j .eq. 0) then
|
||||
if (.not. yzoom) then
|
||||
if (nextfocus .ne. 0) then
|
||||
do is=1,nset
|
||||
im=imx(is)
|
||||
if (retLen(is) .gt. 0 .and. unit(im) .eq. 1) focus(im)=.true.
|
||||
enddo
|
||||
else if (.not. yzoom) then
|
||||
y1=ymin(1)
|
||||
y2=ymax(1)
|
||||
yzoom=.true.
|
||||
endif
|
||||
! do is=1,nset
|
||||
! im=imx(is)
|
||||
! if (retLen(is) .gt. 0 .and. unit(im) .eq. 1) focus(im)=.true.
|
||||
! enddo
|
||||
endif
|
||||
nextfocus=0
|
||||
if (saveit) goto 9
|
||||
if (mode .eq. live) then
|
||||
x2=max(tim0,x2)+min(1800., window*0.5)
|
||||
@@ -360,8 +368,8 @@
|
||||
|
||||
ey=(ymax(rl)-ymin(rl))
|
||||
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)
|
||||
ymax(rl)=ymax(rl)+max(fy*0.02,ey*0.01)
|
||||
ymin(rl)=ymin(rl)-max(fy*0.02,ey*0.01)
|
||||
if (mode .eq. live) then
|
||||
ymin(rl)=min(ymin(rl),max(0.0,ylast1-ey*0.4))
|
||||
ymax(rl)=max(ymax(rl),ylast2+ey*0.4)
|
||||
@@ -628,7 +636,7 @@
|
||||
elseif (key .eq. 'X') then
|
||||
window=0
|
||||
mode=0
|
||||
yzoom=.true.
|
||||
yzoom=.false.
|
||||
elseif (key .eq. '+' .or. key .eq. ',') then
|
||||
window=max(winmin,window/2)
|
||||
if (ex .eq. undef) then
|
||||
@@ -759,6 +767,7 @@
|
||||
goto 9
|
||||
elseif (key .eq. 'A') then
|
||||
showsets=2
|
||||
yzoom=.false.
|
||||
elseif (key .eq. 'C') then ! clear set
|
||||
if (ex .lt. x1) then
|
||||
if (ey .ge. ymin(1) .and.
|
||||
@@ -806,17 +815,28 @@
|
||||
endif
|
||||
enddo
|
||||
if (n .gt. 1) then
|
||||
if (j .gt. 4) then ! was "all", set to "default"
|
||||
if (j .gt. 3) 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)
|
||||
goto 89
|
||||
endif
|
||||
nextfocus=1
|
||||
do is=1,nset
|
||||
im=imx(is)
|
||||
if (im .gt. j) then ! select next
|
||||
focus(im)=.true.
|
||||
goto 89
|
||||
endif
|
||||
enddo
|
||||
! select all
|
||||
do is=1,nset
|
||||
im=imx(is)
|
||||
focus(im)=.true.
|
||||
endif ! else select none -> will be all
|
||||
enddo
|
||||
89 yzoom=.false.
|
||||
elseif (mode .eq. live) then
|
||||
goto 7
|
||||
|
||||
@@ -201,8 +201,7 @@ char *term_fgets(char *buf, int size, FILE *fil) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void term_save_hist(int
|
||||
trimlast) {
|
||||
void term_save_hist(int trimlast) {
|
||||
FILE *fil;
|
||||
int i,n;
|
||||
if (filehead[0]=='\0') return;
|
||||
@@ -319,6 +318,11 @@ int term_get_line(char *buf, int size, int *pos, char *prompt, fd_set *mask) {
|
||||
}
|
||||
hist_pos=hist_end;
|
||||
term_save_hist(0);
|
||||
printf("\r\033[K\n");
|
||||
for (i = strlen(prompt) - 1; i > 0; i--) {
|
||||
printf("-");
|
||||
}
|
||||
printf(" %s", buf);
|
||||
return(STDIN_FILENO);
|
||||
|
||||
/* normal EXIT */
|
||||
|
||||
Reference in New Issue
Block a user