M.Z. 20.08.2003
This commit is contained in:
@ -9,7 +9,7 @@ typedef struct { char *instr; char *host; int port; char *user; int cod; } Instr
|
||||
static Instrument list[]={
|
||||
{ "DMC", "lnsa05.psi.ch", 9753, "DMC" , 1},
|
||||
{ "TOPSI", "pc4120.psi.ch", 9753, "TOPSI" , 1},
|
||||
{ "SANS", "lnsa10.psi.ch", 9753, "SANS" , 1},
|
||||
{ "SANS", "sans.psi.ch", 9753, "SANS" , 1},
|
||||
{ "HRPT", "lnsa11.psi.ch", 9753, "HRPT" , 1},
|
||||
{ "TRICS", "lnsa18.psi.ch", 9753, "TRICS" , 1},
|
||||
{ "AMOR", "lnsa14.psi.ch", 9753, "AMOR" , 1},
|
||||
|
@ -20,6 +20,7 @@ int main(int argc, char *argv[]) {
|
||||
pid=vfork();
|
||||
if (pid == 0) {
|
||||
execvp(argv[1], argv+1);
|
||||
printf("%s\n", argv[1]);
|
||||
perror("execvp");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -42,6 +42,19 @@ TecsClient: $(TECLI_OBJ)
|
||||
libtecs.so: tecs_c.c $(CLI_OBJ)
|
||||
$(CC) $(CFLAGS) -shared -o $@ $Q $(FORTIFYOBJ)
|
||||
|
||||
# -- for Tru64 Unix only
|
||||
conv: strings.f90 conv.f90 sys_cmdpar.o str.o
|
||||
f90 -o conv $Q
|
||||
|
||||
config: src/tecs src/tecs/tecs.cfg
|
||||
|
||||
src/tecs: conv src/cfg/*.inp
|
||||
conv all
|
||||
touch src/tecs
|
||||
|
||||
src/tecs/tecs.cfg: src/cfg/*.cfg
|
||||
cp src/cfg/*.cfg src/tecs/
|
||||
|
||||
# -- needs special include
|
||||
tecs_serial.o: tecs_serial.c
|
||||
$(CC) $(CFLAGS) -I$(SICS)/hardsup -c $Q
|
||||
|
42
tecs/six.c
42
tecs/six.c
@ -54,7 +54,7 @@ int readWrite(int fd, int skip) {
|
||||
* a timeout occured (1 or 5 sec.), or a <go ahead> message
|
||||
* received.
|
||||
* skip=0: timeout 1 sec (normal behaviour)
|
||||
* skip>0: timeout 5 sec.
|
||||
* skip>0: timeout 10 sec.
|
||||
* skip>1: swallow text
|
||||
* skip=1,2: return 0 if SICS not found in message text
|
||||
* skip=3: return 0 if not acknowledged
|
||||
@ -62,7 +62,7 @@ int readWrite(int fd, int skip) {
|
||||
n=0;
|
||||
go=0;
|
||||
ires=0;
|
||||
iret=term_wait_fd(fd, skip?5000:1000);
|
||||
iret=term_wait_fd(fd, skip?10000:1000);
|
||||
while (iret==1) {
|
||||
ERR_SI(l=recv(fd, msg, sizeof(msg)-1, 0));
|
||||
/* if (l==0) return(0); */
|
||||
@ -86,18 +86,25 @@ int readWrite(int fd, int skip) {
|
||||
n+=strlen(msg);
|
||||
}
|
||||
if (go) break;
|
||||
iret=term_wait_fd(fd, skip?5000:1000);
|
||||
iret=term_wait_fd(fd, skip?10000:1000);
|
||||
}
|
||||
if (n==0 && ires==1) return 1;
|
||||
return ires*n;
|
||||
OnError: return -1;
|
||||
}
|
||||
|
||||
void Usage(void) {
|
||||
printf(" Usage:\n\n");
|
||||
printf(" six [options] [\"username\" \"password\"]\n\n");
|
||||
printf(" Options: -s simulation mode (on some instruments)\n");
|
||||
printf(" -w do not skip welcome message\n\n");
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int iret, pos;
|
||||
fd_set mask;
|
||||
int fd, l, i, j, port, skip;
|
||||
char buf[128], lbuf[16], ibuf[64];
|
||||
char buf[128], lbuf[16], ibuf[64], ilow[64];
|
||||
char *rights, *instr, *sim="", *us, *ps;
|
||||
|
||||
struct sockaddr_in sadr;
|
||||
@ -113,6 +120,7 @@ int main (int argc, char *argv[]) {
|
||||
} else {
|
||||
if (strlen(argv[i])>=32) {
|
||||
printf("argument too long\n");
|
||||
Usage(); return 0;
|
||||
} else {
|
||||
if (j==0) {
|
||||
us=argv[i];
|
||||
@ -122,19 +130,19 @@ int main (int argc, char *argv[]) {
|
||||
j=2;
|
||||
} else {
|
||||
printf("too many arguments\n");
|
||||
return 0;
|
||||
Usage(); return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (j==1) {
|
||||
printf("missing password\n");
|
||||
return(0);
|
||||
Usage(); return 0;
|
||||
}
|
||||
instr=getenv("Instrument");
|
||||
if (instr==NULL || instr[0]=='\0') {
|
||||
printf("Instrument is undefined\n");
|
||||
return(0);
|
||||
Usage(); return 0;
|
||||
}
|
||||
ERR_I(CocCreateSockAdr(&sadr, "0", port));
|
||||
ERR_SI(fd=socket(AF_INET, SOCK_STREAM, 0));
|
||||
@ -163,7 +171,9 @@ int main (int argc, char *argv[]) {
|
||||
sprintf(buf, "config Rights %s %s\r\n", us, ps);
|
||||
ERR_SI(send(fd, buf, strlen(buf), 0));
|
||||
ERR_I(i=readWrite(fd,3));
|
||||
if (!i) {
|
||||
if (!i && 0 != strcmp(instr, "TASP")) {
|
||||
printf("password guess failed, logged in as Spy\n\n");
|
||||
Usage();
|
||||
us="Spy";
|
||||
}
|
||||
printf("\rlogged in to SICS as %s on %s%s\n", us, instr, sim);
|
||||
@ -171,14 +181,15 @@ int main (int argc, char *argv[]) {
|
||||
if (*sim!='\0') {
|
||||
strcpy(buf, "sync\r\n");
|
||||
ERR_SI(send(fd, buf, strlen(buf), 0));
|
||||
printf("\rsynchronize ...\n");
|
||||
ERR_I(i=readWrite(fd,1));
|
||||
}
|
||||
*/
|
||||
iret=1;
|
||||
buf[0]='\0';
|
||||
pos=0;
|
||||
str_lowcase(instr,instr);
|
||||
sprintf(ibuf, "six[%s%s] ", instr, sim);
|
||||
str_lowcase(ilow,instr);
|
||||
sprintf(ibuf, "six[%s%s] ", ilow, sim);
|
||||
while (1) {
|
||||
FD_ZERO(&mask);
|
||||
FD_SET(fd, &mask);
|
||||
@ -194,7 +205,10 @@ int main (int argc, char *argv[]) {
|
||||
}
|
||||
fputs("\n", stdout);
|
||||
skip=0;
|
||||
if (0==strcmp(lbuf,"sync")) skip=1;
|
||||
if (0==strcmp(lbuf,"sync")) {
|
||||
printf("\rsynchronize ...\n");
|
||||
skip=1;
|
||||
}
|
||||
l=strlen(buf);
|
||||
/*
|
||||
printf("sent> %s[%d chars]\n", buf, l);
|
||||
@ -213,8 +227,10 @@ int main (int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
fputs("\n", stdout);
|
||||
return(0);
|
||||
return 0;
|
||||
Usage:
|
||||
return 0;
|
||||
OnError:
|
||||
ErrShow("end");
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -6,8 +6,9 @@
|
||||
!!
|
||||
integer LUN !! out
|
||||
|
||||
logical*1 act(50:100)/51*.false./
|
||||
common /sys_lun/act
|
||||
logical*1 act(50:100)
|
||||
common/syslun/act
|
||||
data act/51*.false./
|
||||
|
||||
integer l
|
||||
|
||||
@ -29,8 +30,8 @@
|
||||
!!
|
||||
integer LUN !! in
|
||||
|
||||
logical*1 act(50:100)/51*.false./
|
||||
common /sys_lun/act
|
||||
logical*1 act(50:100)
|
||||
common/syslun/act
|
||||
|
||||
if (lun .lt. 50 .or. lun .gt. 99) then
|
||||
stop 'SYS_FREE_LUN: illegal lun'
|
||||
|
@ -5,13 +5,14 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
#include <utmp.h>
|
||||
#include "myc_tmp.h"
|
||||
#include "myc_str.h"
|
||||
#include "myc_fortran.h"
|
||||
|
||||
void F_FUN(usleep)(int *usec) { usleep(*usec); }
|
||||
void usleep_(int *usec) { usleep(*usec); }
|
||||
int F_FUN(getppid)(void) { return getppid(); }
|
||||
int lnblnk_(const char *str, int len);
|
||||
|
||||
|
105
tecs/tecs.c
105
tecs/tecs.c
@ -115,6 +115,7 @@ static float
|
||||
fbuf, /* float buffer */
|
||||
r1, r2, /* temporary values */
|
||||
still=0,
|
||||
mout,
|
||||
tInt=0; /* integral time (sec.) for setpoint shift */
|
||||
|
||||
static int
|
||||
@ -865,7 +866,8 @@ int ReadTemp(void) {
|
||||
s->t2 = s->t1;
|
||||
s->stat2 = s->stat1;
|
||||
}
|
||||
if (s->t1 == 63.0 || s->t2 == 63.0 || s->t0 == 63.0) {
|
||||
if (set != 63.0 &&
|
||||
(s->t1 == 63.0 || s->t2 == 63.0 || s->t0 == 63.0)) {
|
||||
/* probably noisy values */
|
||||
logfileOut(LOG_MAIN, "magic %s: %g %g %g\n", s->ch, s->t1, s->t2, s->t0);
|
||||
}
|
||||
@ -1098,7 +1100,7 @@ void CalcMaxPower(void) {
|
||||
float pa, pr, pw, quo, p, pl, plim;
|
||||
|
||||
iAmp=1; iRange=0;
|
||||
if (scalPower==0) scalPower=maxPower;
|
||||
/* if (scalPower==0) */ scalPower=maxPower;
|
||||
if (maxPower>0) {
|
||||
p=scalPower/powFact;
|
||||
plim=2500/resist;
|
||||
@ -1110,9 +1112,13 @@ void CalcMaxPower(void) {
|
||||
pr=pa;
|
||||
for (j=5; j>0; j--) {
|
||||
if (p<pr) {
|
||||
if (p/pr>quo) { quo=p/pr; pw=pr; iAmp=i; iRange=j; }
|
||||
if (p/pr>quo) {
|
||||
quo=p/pr; pw=pr; iAmp=i; iRange=j;
|
||||
}
|
||||
} else if (p<plim || pw==0) {
|
||||
if (pr/p>quo) { quo=pr/p; pw=pr; iAmp=i; iRange=j; }
|
||||
if (pr/p>quo) {
|
||||
quo=pr/p; pw=pr; iAmp=i; iRange=j;
|
||||
}
|
||||
}
|
||||
pr=pr/10;
|
||||
}
|
||||
@ -1188,6 +1194,7 @@ int SetMaxPower(void) {
|
||||
}
|
||||
logfileOut(LOG_MAIN, "maxPower changed from %g to %g\n", pold, maxPower);
|
||||
ERR_P(LscCmd(ser, "CDISP 1:[loop],[resist],1;MOUT [loop]:0;CMODE [loop]:1"));
|
||||
mout=0;
|
||||
if (slope<0) slope=-slope;
|
||||
if (slope!=0 && slope<0.1) slope=0.1;
|
||||
fbuf=tLimit/CtlScale();
|
||||
@ -1831,8 +1838,69 @@ int AlarmHdl(int mode, void *base, int fd) {
|
||||
OnError: return -1;
|
||||
}
|
||||
|
||||
int SetPower(float setpower) {
|
||||
float htr1, htr0, diff, dist;
|
||||
int cnt;
|
||||
|
||||
if (setpower<0) return 0;
|
||||
if (setpower>maxPower) setpower=maxPower;
|
||||
if (setpower<0) setpower=0;
|
||||
htr1=sqrt(setpower/scalPower*1e4);
|
||||
ERR_P(LscCmd(ser, "HTR?>htr"));
|
||||
diff=htr1-htr;
|
||||
if (abs(diff) <0.11) return 0;
|
||||
if (htr==0) {
|
||||
if (diff<10) diff=10;
|
||||
if (diff>50) diff=50;
|
||||
diff+=diff*0.5+10;
|
||||
while (htr==0) {
|
||||
mout+=diff;
|
||||
ERR_P(LscCmd(ser, "MOUT 1,[mout]"));
|
||||
ERR_P(LscCmd(ser, "HTR?>htr"));
|
||||
}
|
||||
}
|
||||
if (htr==100) {
|
||||
if (diff>-10) diff=-10;
|
||||
if (diff<-50) diff=-50;
|
||||
while (htr==100) {
|
||||
mout+=diff;
|
||||
ERR_P(LscCmd(ser, "MOUT 1,[mout]"));
|
||||
ERR_P(LscCmd(ser, "HTR?>htr"));
|
||||
}
|
||||
}
|
||||
diff=htr1-htr;
|
||||
if (abs(diff) >0.11) {
|
||||
cnt=20;
|
||||
if (mout+diff >= 100) {
|
||||
if (mout>99.89) cnt=0;
|
||||
mout=100;
|
||||
} else if (mout+diff <= -100) {
|
||||
if (mout<-99.89) cnt=0;
|
||||
mout=-100; cnt=0;
|
||||
} else {
|
||||
mout+=diff;
|
||||
}
|
||||
ERR_P(LscCmd(ser, "MOUT 1,[mout]"));
|
||||
htr0=htr;
|
||||
while (htr0 == htr && cnt>0) {
|
||||
ERR_P(LscCmd(ser, "HTR?>htr"));
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
if (abs(htr1-htr) > 0.11) {
|
||||
power=htr*htr*scalPower*1e-4;
|
||||
logfileOut(LOG_MAIN, "power: %f (tried %f)\n", power, setpower);
|
||||
} else {
|
||||
logfileOut(LOG_MAIN, "power: %f\n", setpower);
|
||||
}
|
||||
return 0;
|
||||
OnError: return -1;
|
||||
}
|
||||
|
||||
int MaxPowerHdl(int mode, void *base, int fd) {
|
||||
static float setpower;
|
||||
if (mode==COC_WR) {
|
||||
setpower=power;
|
||||
scalPower=maxPower;
|
||||
CalcMaxPower();
|
||||
if (remoteMode!=2) {
|
||||
@ -1847,7 +1915,31 @@ int MaxPowerHdl(int mode, void *base, int fd) {
|
||||
return COC_DWR;
|
||||
} else if (mode==COC_DWR && remoteMode==2) {
|
||||
ERR_I(SetMaxPower());
|
||||
ERR_I(SetTemp(1));
|
||||
ERR_I(SetPower(setpower));
|
||||
}
|
||||
return 0;
|
||||
OnError: return -1;
|
||||
}
|
||||
|
||||
int PowerHdl(int mode, void *base, int fd) {
|
||||
static float setpower=0;
|
||||
float htr1, diff;
|
||||
if (mode==COC_WR) {
|
||||
if (power>maxPower) power=maxPower;
|
||||
htr1=sqrt(power/scalPower*1e4);
|
||||
diff=htr1-htr;
|
||||
if (mout+diff>100) {
|
||||
diff=100-mout;
|
||||
power=(htr+diff)*(htr+diff)*scalPower/1e4;
|
||||
} else if (mout+diff<-100) {
|
||||
diff=-100-mout;
|
||||
power=(htr+diff)*(htr+diff)*scalPower/1e4;
|
||||
}
|
||||
if (power<0) power=0;
|
||||
setpower=power;
|
||||
return COC_DWR;
|
||||
} else if (mode==COC_DWR && scalPower>0) {
|
||||
ERR_I(SetPower(setpower));
|
||||
}
|
||||
return 0;
|
||||
OnError: return -1;
|
||||
@ -2293,12 +2385,13 @@ int main(int argc, char *argv[]) {
|
||||
CocDefFlt(set, RW); CocHdl(SetHdl);
|
||||
CocDefFlt(ramp, RW); CocHdl(SetHdl);
|
||||
CocDefFlt(still, RW); CocHdl(StillHdl);
|
||||
CocDefFlt(power, RW); CocHdl(PowerHdl);
|
||||
CocDefFlt(mout, RD);
|
||||
CocDefFlt(scalPower, RD);
|
||||
CocDefFlt(smooth, RW);
|
||||
CocDefFlt(powFact, RW);
|
||||
CocDefFlt(resist, RD);
|
||||
CocDefFlt(htr, RD);
|
||||
CocDefFlt(power, RD);
|
||||
CocDefFlt(setH, RD);
|
||||
CocDefFlt(full, RW);
|
||||
CocDefFlt(tLimit, RD);
|
||||
|
@ -16,6 +16,7 @@
|
||||
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,menuwid
|
||||
real*4 dx,dy
|
||||
integer l,j,i,n,t,leng,i1,i2,rl,startday,thisday
|
||||
integer ncol, nset, mode
|
||||
integer first,last,step,tbase,lastj
|
||||
@ -524,6 +525,14 @@
|
||||
y2=ymax(1)
|
||||
endif
|
||||
mode=zoom
|
||||
elseif (key .eq. 'J') then
|
||||
dx=ex-(xmax+xmin)*0.5
|
||||
dy=ey-(ymax(1)+ymin(1))*0.5
|
||||
x1=xmin+dx
|
||||
x2=xmax+dx
|
||||
y1=ymin(1)+dy
|
||||
y2=ymax(1)+dy
|
||||
mode=zoom
|
||||
elseif (key .ge. '0' .and. key .le. '9' .or. key .eq. '.') then ! number
|
||||
if (numl .lt. len(numb)) then
|
||||
numl=numl+1
|
||||
|
Reference in New Issue
Block a user