minor changes in tecs (M.Z.)

This commit is contained in:
cvs
2001-04-27 08:48:58 +00:00
parent e5e594d3af
commit 87bea26315
5 changed files with 193 additions and 59 deletions

View File

@ -45,7 +45,7 @@ typedef struct {
int dirty; /* input config to be reloaded */
int try; /* trial count */
int manual; /* manual device */
int code, code1; /* device code, buffer for device code */
int code, code1, code2; /* device code, buffer for device code */
int codChanged; /* code has changed */
int codDefined; /* code is not yet confirmed */
float scale; /* scale for extreme ranges */
@ -70,6 +70,7 @@ static float
full, /* full value for helium level */
prop, integ, deriv, /* pid */
maxShift=2, /* maximal shift in when controlMode=2 */
fbuf, /* float buffer */
tInt=0; /* integral time (sec.) for setpoint shift */
static int
@ -97,10 +98,12 @@ static int
configuring=1,
stable, /* stable since 2 min. */
resist, /* heater resistance */
cmode=1, /* 1: manual PID, 5: auto PI */
readTemp, /* client requested readTemp */
cod1, cod2, out1, out2, /* codes read from digital input/output */
iRange, iAmp, /* max. range and max. current code */
htrst, htrst0, /* heater status */
tuning=0,
per; /* effective period */
static time_t
@ -111,7 +114,7 @@ static time_t
static int decod[8]={21,20,17,16,5,4,1,0}; /* for code conversion */
static char
status[132], /* status buffer */
status[160], /* status buffer */
device[64], /* concatenated device names */
buf1[256], buf2[256], buf3[256], buf4[256], /* buffers for temporary use */
head[64], /* curve header */
@ -287,8 +290,12 @@ int instCurve(char *nam, char *channel, int dispFld) {
if (head[0]!='\0' && LscEqPar(head, chead)) { /* header matches: select sensor type and curve */
retstat=-1; /* an error could be fixed */
ERR_P(LscCmd(ser, "RANGE:0;INTYPE [chan]:[intype];INCRV [chan]:[num]"));
ERR_P(LscCmd(ser, "MNMX [chan]:1,1;DISPFLD [fld],[chan],1;DISPLAY [maxfld]"));
ERR_P(LscCmd(ser, "RANGE:0"));
ERR_P(LscCmd(ser, "INTYPE [chan]:[intype]"));
ERR_P(LscCmd(ser, "INCRV [chan]:[num]"));
ERR_P(LscCmd(ser, "MNMX [chan]:1,1"));
ERR_P(LscCmd(ser, "DISPFLD [fld],[chan],1"));
ERR_P(LscCmd(ser, "DISPLAY [maxfld]"));
logfileOut(LOG_MAIN, "curve %d on channel %s selected\n", num, chan);
Progress(100);
@ -300,7 +307,9 @@ int instCurve(char *nam, char *channel, int dispFld) {
if (busy) ERR_MSG("busy");
logfileOut(LOG_MAIN, "download curve %d\n", num);
/* select sensor type first to display sensor units */
ERR_P(LscCmd(ser, "RANGE:0;INTYPE [chan]:[intype];DISPLAY:[maxfld]"));
ERR_P(LscCmd(ser, "RANGE:0"));
ERR_P(LscCmd(ser, "INTYPE [chan]:[intype]"));
ERR_P(LscCmd(ser, "DISPLAY:[maxfld]"));
Progress(1);
n=3;
@ -328,8 +337,11 @@ int instCurve(char *nam, char *channel, int dispFld) {
/* write header, select curve */
str_upcase(head, chead);
ERR_P(LscCmd(ser, "CRVHDR [num]:[head];INCRV [chan]:[num]"));
ERR_P(LscCmd(ser, "MNMX [chan]:1,1;DISPFLD [fld],[chan],1;DISPLAY [maxfld]"));
ERR_P(LscCmd(ser, "CRVHDR [num]:[head]"));
ERR_P(LscCmd(ser, "INCRV [chan]:[num]"));
ERR_P(LscCmd(ser, "MNMX [chan]:1,1"));
ERR_P(LscCmd(ser, "DISPFLD [fld],[chan],1"));
ERR_P(LscCmd(ser, "DISPLAY [maxfld]"));
Progress(1);
logfileOut(LOG_MAIN, "curve selected on channel %s\n", chan);
saveTime=tim+30;
@ -418,6 +430,7 @@ int configInput(void) {
i=sscanf(t, "%12s%n", nam, &l);
if (i<1) ERR_MSG("missing device name");
nam[strlen(nam)-1]='\0'; /* strip off quote */
t+=l;
/* interprete settings until '+' appeares */
@ -437,11 +450,12 @@ int configInput(void) {
} 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;
samp.manual=1;
str_copy(samp.device, nam);
}
str_copy(ch, chanM);
if (heliumMode==0) {
sprintf(helium, "no He-level meter for '%s", nam);
sprintf(helium, "no He-level meter for %s", nam);
} else {
sprintf(helium, "He-level meter not yet read", nam);
}
@ -451,7 +465,6 @@ int configInput(void) {
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 */
str_copy(tpoint->device, nam);
concatDevice();
@ -470,10 +483,11 @@ int configInput(void) {
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"));
ERR_P(LscCmd(ser, "INTYPE [chan]:0,1,2,1,13"));
} else {
ERR_P(LscCmd(ser, "INTYPE [chan]:0,1,2,1,12;MNMX [chan]:1,3"));
ERR_P(LscCmd(ser, "INTYPE [chan]:0,1,2,1,12"));
}
ERR_P(LscCmd(ser, "MNMX [chan]:1,3"));
tpoint->sensor2->present=2;
} else {
if (ch[1]<'A' || ch[1]>'D') ERR_MSG("illegal channel");
@ -615,17 +629,17 @@ int ReadTemp(void) {
for (i=1; i<=4; i++) {
sensor=sensors[i];
if (sensor->present) {
stat=(sensor->stat1 | sensor->stat2) & 255;
stat=(sensor->stat1 | sensor->stat2) & (255-2); /* ignore old reading */
if (stat != sensor->readStat) {
sensor->readStat=stat;
if (stat & 1) logfileOut(LOG_MAIN, "invalid reading %s\n", sensor->ch);
if (stat & 2) logfileOut(LOG_MAIN, "old reading %s\n", sensor->ch);
/* if (stat & 2) logfileOut(LOG_MAIN, "old reading %s\n", sensor->ch); */
if (stat & 12) logfileOut(LOG_MAIN, "unknown reading status %s\n", sensor->ch);
if (stat & 16) logfileOut(LOG_MAIN, "temp underrange %s\n", sensor->ch);
if (stat & 32) logfileOut(LOG_MAIN, "temp overrange %s\n", sensor->ch);
if (stat & 64) logfileOut(LOG_MAIN, "units zero %s\n", sensor->ch);
if (stat &128) logfileOut(LOG_MAIN, "units overrange %s\n", sensor->ch);
if (stat==0) logfileOut(LOG_MAIN, "reading o.k. %s\n", sensor->ch);
if (stat==0) logfileOut(LOG_MAIN, "reading o.k. %s\n", sensor->ch);
}
if (stat==0) {
@ -635,7 +649,7 @@ int ReadTemp(void) {
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);
/* 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;
@ -723,14 +737,29 @@ int SetTemp(int switchOn) {
tempH=(tempC+tShift)/scale;
if (tempH>tLimit) tempH=tLimit;
if (tempC==0) {
ERR_P(LscCmd(ser, "CSET 1:[chan],1,1,0;RANGE:0;SETP 1:0"));
ERR_P(LscCmd(ser, "CSET 1:[chan],1,1,0"));
ERR_P(LscCmd(ser, "RANGE:0"));
tempH=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 if (switchOn) { /* switch on also when bad heater message and no alarms: || (htrst>=5 && relay==0)) */
ERR_P(LscCmd(ser, "CSET 1:[chan],1,1,0"));
ERR_P(LscCmd(ser, "RANGE:[iRange]"));
ERR_P(LscCmd(ser, "CMODE 1:[cmode]"));
if (cmode>=4) {
ERR_P(LscCmd(ser, "PID?1>prop,integ,deriv"));
logfileOut(LOG_MAIN, "PID %f,%f,%f\n", prop, integ, deriv);
tuning=2;
}
} else {
ERR_P(LscCmd(ser, "CSET 1:[chan],1;SETP 1:[tempH]"));
ERR_P(LscCmd(ser, "CSET 1:[chan],1"));
}
ERR_P(LscCmd(ser, "SETP?1>fbuf"));
if (tempH==0 || fbuf/tempH<0.9999 || fbuf/tempH>1.0001) {
ERR_P(LscCmd(ser, "SETP 1:[tempH]"));
if (controlMode!=2 && !switchOn) {
logfileOut(LOG_MAIN, "set %f (on %s) (was changed)\n", tempC, ch);
}
}
if (0!=strcmp(ch, controlChannel) || switchOn) {
str_copy(controlChannel, ch);
@ -747,12 +776,17 @@ int PeriodicTask(void) {
time_t putTim;
float t3[3], p, d, w, t;
ERR_P(LscCmd(ser, "DIOST?>cod1,out1;DOUT 3,29;HTR?>htr;HTRST?>htrst;RELAYST?1>relay;BUSY?>busy"));
ERR_P(LscCmd(ser, "DIOST?>cod1,out1"));
if (cryo.codDefined && samp.codDefined) {
per=period; /* no timeout on above command and codes are defined: normal period */
if (per>logPeriod*1000) per=logPeriod*1000;
}
ERR_P(LscCmd(ser, "DOUT 3,29"));
ERR_P(LscCmd(ser, "HTR?>htr"));
ERR_P(LscCmd(ser, "HTRST?>htrst"));
ERR_P(LscCmd(ser, "RELAYST?1>relay;BUSY?>busy"));
if (noResp) { /* there was no response on an earlier command, or we are initializing */
if (!configuring) remoteMode=2;
LscCmd(ser, "MODE:[remoteMode]");
@ -798,7 +832,7 @@ int PeriodicTask(void) {
if (cryo.code!=0) str_copy(cryo.device, buf1);
cryo.manual=0;
}
if (buf2[0]=='*') {
if (buf2[0]=='*' && buf2[1]!='\0') {
str_copy(samp.device, buf2+1);
samp.manual=1;
} else {
@ -860,6 +894,11 @@ int PeriodicTask(void) {
i=0;
if (sens1.present) {
t3[0]=cryo.temp;
/*
if (cryo.temp==0) {
logfileOut(LOG_MAIN, "zero??\n");
}
*/
i=1;
} else {
t3[0]=undef;
@ -907,7 +946,9 @@ int PeriodicTask(void) {
}
}
ERR_P(LscCmd(ser, "KEYST?>key;DIOST?>cod2,out2;DOUT 3,30"));
ERR_P(LscCmd(ser, "KEYST?>key"));
ERR_P(LscCmd(ser, "DIOST?>cod2,out2"));
ERR_P(LscCmd(ser, "DOUT 3,30"));
if (busy==0) {
if (out1!=30) {
@ -916,7 +957,8 @@ int PeriodicTask(void) {
}
if (out2!=29) {
ERR_P(LscCmd(ser, "DOUT:3,29"));
ERR_P(LscCmd(ser, "DIOST?>cod2,out2;DOUT 3,30"));
ERR_P(LscCmd(ser, "DIOST?>cod2,out2"));
ERR_P(LscCmd(ser, "DOUT 3,30"));
}
if (out1==30 && out2==29) {
@ -926,15 +968,24 @@ int PeriodicTask(void) {
for (i=0; i<2; i++) {
tpoint=tpoints[i];
if (tpoint->code1!=tpoint->code) { /* code has changed -> wait for a confirmation */
tpoint->code=tpoint->code1;
tpoint->codChanged=1;
logfileOut(LOG_MAIN, "%s codes: %d,%d,%d\n", tpoint->tname, tpoint->code, tpoint->code1, tpoint->code2);
if (tpoint->code1==tpoint->code2) {
tpoint->code=tpoint->code1;
tpoint->codChanged=1;
} else {
tpoint->code2=tpoint->code1;
}
} else {
tpoint->code2=tpoint->code;
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);
if (tpoint==&cryo && samp.sensor1->ch[0]<='B') {
samp.manual=0; samp.dirty=1;
}
} else {
logfileOut(LOG_MAIN, "plugged %d on %s\n", tpoint->code1, tpoint->tname);
}
@ -964,7 +1015,9 @@ int PeriodicTask(void) {
ERR_P(LscCmd(ser, "RANGE?>iRange"));
if (iRange==0) tempC=0;
} else {
ERR_P(LscCmd(ser, "RANGE?>iRange;CSET?1>,cod1,;SETP?1>tempC"));
ERR_P(LscCmd(ser, "RANGE?>iRange"));
ERR_P(LscCmd(ser, "CSET?1>,cod1,"));
ERR_P(LscCmd(ser, "SETP?1>tempC"));
if (cod1!=1) {
tempC=0;
logfileOut(LOG_MAIN, "set point was not in K, set to 0\n");
@ -974,6 +1027,16 @@ int PeriodicTask(void) {
}
}
if (tuning==2) {
ERR_P(LscCmd(ser, "TUNEST?>tuning"));
if (tuning==0) tuning=2;
} else if (tuning==1) {
ERR_P(LscCmd(ser, "TUNEST?>tuning"));
if (tuning==0) {
ERR_P(LscCmd(ser, "PID?1>prop,integ,deriv"));
logfileOut(LOG_MAIN, "@tuned PID %f,%f,%f\n", prop, integ, deriv);
}
}
if (saveTime!=0 && tim>saveTime) {
ERR_P(LscCmd(ser, "CRVSAV;BUSY?>busy"));
while (!busy) {
@ -996,7 +1059,7 @@ 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) {
if (cryo.code==0 && samp.code==0 && cryo.manual==0 && samp.manual==0) {
logfileOut(LOG_MAIN, "no more sensor connected\n");
}
} else {
@ -1046,7 +1109,7 @@ int SetMaxPower(void) {
}
maxPower=pw;
logfileOut(LOG_MAIN, "maxPower %f\n", maxPower, iAmp, iRange);
ERR_P(LscCmd(ser, "CDISP 1:1,[resist],1;MOUT 1:0;CMODE 1:1"));
ERR_P(LscCmd(ser, "CDISP 1:1,[resist],1;MOUT 1:0"));
ERR_P(LscCmd(ser, "CLIMIT 1:[tLimit],0,0,[iAmp],[iRange]"));
ERR_I(SetTemp(1));
return(0);
@ -1253,7 +1316,9 @@ int mainBody(void)
ERR_I(iret=CocHandleRequests(tdif, 0));
if (iret==0) { time(&tim); break; } /* timeout */
tim=tim1.time;
ERR_I(ExecuteRequest());
if (ser!=NULL) {
ERR_I(ExecuteRequest());
}
logfileWrite(logMask);
}
ftime(&tim1);
@ -1265,7 +1330,9 @@ int mainBody(void)
logfileOut(LOG_MAIN ,"%d cycles lost\n", tdif-1);
}
ERR_I(PeriodicTask());
if (ser!=NULL) {
ERR_I(PeriodicTask());
}
if (remoteMode==2) ERR_I(Settings());
return(0);
@ -1278,6 +1345,7 @@ int mainBody(void)
remoteMode=1;
configuring=0;
} else {
/* logfileShowErr("error"); */
logfileOut(LOG_ALL ,"no response\n");
noResp=1;
per=100; /* try again soon */
@ -1356,7 +1424,7 @@ int main(int argc, char *argv[])
}
}
if (port==0) port=9753;
if (msecTmo==0) msecTmo=1000;
if (msecTmo==0) msecTmo=2000;
if (logPeriod==0) logPeriod=5;
str_copy(buf, logDir);
@ -1406,6 +1474,7 @@ int main(int argc, char *argv[])
CocDefFlt(tLow, CocRD);
CocDefFlt(tHigh, CocRD);
CocDefFlt(maxShift, CocWR);
CocDefFlt(fbuf, CocRD);
CocDefStr(device, deviceFlag);
@ -1437,10 +1506,12 @@ int main(int argc, char *argv[])
CocDefInt(remoteMode, CocRD);
CocDefInt(heliumMode, CocRD);
CocDefInt(htrst, CocRD);
CocDefInt(tuning, CocRD);
CocDefInt(logPeriod, CocWR);
CocDefInt(readTemp, CocWR);
CocDefInt(controlMode, CocWR);
CocDefInt(cmode, CocWR);
CocDefInt(int2, CocWR);
CocDefInt(busy, CocRD);
CocDefInt(relay, CocRD);
@ -1459,7 +1530,10 @@ int main(int argc, char *argv[])
CocAlias(set,tempC);
CocAlias(int,integ);
ERR_P(ser=SerOpen(host, msecTmo, idleHdl));
ser=SerOpen(host, msecTmo, idleHdl);
if (ser==NULL) {
logfileShowErr("error in SerOpen");
}
ERR_I(iret=CocHandleRequests(100, 0));
ftime(&tim0);
tim=tim0.time;
@ -1476,22 +1550,44 @@ int main(int argc, char *argv[])
logfileWrite(logMask);
remoteMode=2;
LscCmd(ser, "MODE?>remoteMode");
prop=50;
integ=20;
deriv=0;
LscCmd(ser, "PID?1>prop,integ,deriv");
if (ser!=NULL) {
LscCmd(ser, "MODE?>remoteMode");
LscCmd(ser, "PID?1>prop,integ,deriv");
}
if (remoteMode!=2) configuring=0;
per=1; /* advance fast when initializing */
cntError=0;
while (!quit) {
iret=mainBody();
if (iret<0) {
if (iret<0 || ser==NULL) {
cntError++;
if (cntError>10) ERR_MSG("too many errors - quit");
logfileShowErr("error in TecsServer/mainBody");
if (0==strcmp(ErrMessage, "asynsrv error")) {
if (ser!=NULL) SerClose(ser);
ser=NULL;
}
if (cntError<4) {
logfileShowErr("error in TecsServer/mainBody");
} else if (cntError==4) {
logfileOut(LOG_MAIN, "--- too many errors: skip messages ---\n");
}
if (ser==NULL) {
CocHandleRequests(msecTmo, 0);
ser=SerOpen(host, msecTmo, idleHdl);
if (ser!=NULL) {
LscCmd(ser, "MODE?>remoteMode");
LscCmd(ser, "PID?1>prop,integ,deriv");
}
}
} else {
if (cntError>0) cntError--;
if (cntError>0) {
if (cntError>4) {
cntError=4;
}
cntError--;
}
}
}
LogMinMax(0);

View File

@ -96,7 +96,6 @@
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)
@ -139,7 +138,8 @@
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 *,'rdrn (LTF dilution, 20kOhm), rdrn2 (2kOhm)'
print *,'rdr11, rdr12 (LTF dilution 1 & 2, 20kOhm)'
1 ,', rdrn11_2, rdr12_2 (2kOhm)'
print *
elseif (cmd .eq. 'log') then
iret=tecs_get_par('logfile', file)

View File

@ -3,7 +3,7 @@
#include <time.h>
/* implemented in fortran TECS_DLOG.FOR */
/* implemented in fortran TECS_DLOG.F */
int dlog_open_write_(char *file);
/* open dlog file */

View File

@ -2,7 +2,7 @@ subroutine tecs_plot(file)
character(len=*) file
integer, parameter :: dmax=500, nset=3, nmenu=9, chartfreq=2
integer, parameter :: dmax=500, nset=3, nmenu=10, chartfreq=2
real, parameter :: winmin=60., undef=-65535.0
real*4 x1,x2,xmin,xmax,ymin(2),ymax(2),window
@ -15,28 +15,28 @@ subroutine tecs_plot(file)
integer color(3)/2,4,3/
character key*1
character text(nmenu)*12/ &
'live off','sel. zoom','zoom in','zoom out','show all','n days','n hours','n min','quit'/
character keys*(nmenu)/'LZ+-XDHMQ'/
'live off','sel. zoom','zoom in','zoom out','show all','n days','n hours','n min','file','quit'/
character keys*(nmenu)/'LZ+-XDHMFQ'/
character weekdays(7)*3/'Mon','Tue','Wed','Thu','Fri','Sat','Sun'/
character buf*8
character buf*8, device*8, line*40, filnam*128
external tplot_close
logical live, xwin, zoom, right
integer iret, numb
logical live, xwin, zoom, right, saveit
integer iret, numb, lund
integer dlog_open_r, dlog_get, dlog_close_r
data window/1800./
saveit=.false.
zoom=.false.
right=.true.
call pgopen(" ")
call pgqinf('TYPE', buf, l)
if (buf=='NULL') then
call pgqinf('TYPE', device, l)
if (device=='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
live=device(1:1)/='X' ! live switched off by default on X-Windows
call pgask(.false.)
l=0
@ -83,6 +83,7 @@ subroutine tecs_plot(file)
call err_txt('dlog_get')
goto 99
endif
if (saveit) goto 9
if (ntot>0) then
xmin=minval(xd(1:ntot))
xmax=maxval(xd(1:ntot))
@ -153,6 +154,11 @@ subroutine tecs_plot(file)
zoom=.false.
call pgswin(x1,x2,ymin(rl),ymax(rl))
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, 0.7, 0.0)
call pgscr(4, 0.0, 0.0, 1.0)
do i=i1,i2
call pgsci(color(i))
@ -252,7 +258,7 @@ subroutine tecs_plot(file)
numb=0
7 if (live) then
if (xwin) then
if (device(1:1)=='X') then
call pgmtxt('T', 1.0, 1.0, 1.0, 'LIVE MODE (click on text window before pressing any further key)')
endif
call get_key(key, 0, chartfreq)
@ -354,7 +360,7 @@ subroutine tecs_plot(file)
call pgsci(1)
call pgmtxt('T', 2.0, 0.9, 0.0, buf(l:))
endif
if (xwin .and. .not. live) then
if (device(1:1)=='X' .and. .not. live) then
call pgcurs(ex, ey, key)
call must_purge
else
@ -380,6 +386,8 @@ subroutine tecs_plot(file)
right=.true.
x2=xmax
endif
elseif (key .eq. 'F') then
saveit=.true.
elseif (key=='Q' .or. key==char(13)) then
goto 9
elseif (live) then
@ -393,6 +401,24 @@ subroutine tecs_plot(file)
call tplot_close
call get_key(key, 0, 0) ! purge type-ahead-buffer
print *
if (saveit) then
lund=41
print '(x,a,$)', 'Filename: '
read(*,'(a)') filnam
open(lund, file=filnam, status='unknown', carriagecontrol='list')
write(lund, *) ' time [h]',char(9),' T1 [K]',char(9),' T2 [K]',char(9),'power [W]'
do i=1,ntot
write(line, '(4(f9.4,a))') xd(i)/3600., (char(9), max(-999.,min(9999.,yd(i,j))), j=1,3)
do j=1,3
if (yd(i,j)==undef) then
line(10*j+1:10*j+9)=' '
endif
enddo
write(lund, *) line(1:39)
enddo
close(lund)
print *, ntot+1, ' lines written to ',filnam(1:48)
endif
end subroutine
subroutine get_key(key, tmo1, tmo2)

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include <string.h>
#include <sys/timeb.h>
#include "rs232c_def.h"
#include "asynsrv_def.h"
#include "sinq_prototypes.h"
@ -12,6 +12,8 @@
#define A_CHK(R) if (1!=(R)) { SerA_error(); ErrTxt(#R,0); goto OnError; }
int ftime (struct timeb *__timeptr); /* for some reason not defined in timeb.h with flag -std1 */
void (*idleHandler)(int,int);
struct SerChan {
@ -33,7 +35,7 @@ SerChannel *SerOpen(const char *host, int msecTmo, void (*idleHdl)(int,int)) {
struct SerChan *ser;
char hbuf[64], cport[16];
char *p, *c;
int port, chan;
int port, chan, iRet;
idleHandler=idleHdl;
NEW(ser);
@ -48,12 +50,13 @@ SerChannel *SerOpen(const char *host, int msecTmo, void (*idleHdl)(int,int)) {
}
ser->asyn_info.port=port;
ser->asyn_info.chan=chan;
logfileOut(LOG_MAIN, "open connection to %s:%d/%d\n", ser->asyn_info.host, ser->asyn_info.port, ser->asyn_info.chan);
A_CHK(AsynSrv_Open(&ser->asyn_info));
if (msecTmo==0) msecTmo=5000;
A_CHK(AsynSrv_Config(&ser->asyn_info, "msecTmo", msecTmo, "idleHdl", idleHdl, NULL));
logfileOut(LOG_MAIN, "connection to %s:%d/%d opened\n", ser->asyn_info.host, ser->asyn_info.port, ser->asyn_info.chan);
return((SerChannel *)ser);
OnError: return(NULL);
OnError:
return(NULL);
}
int SerClose(SerChannel *serch) {
@ -80,6 +83,8 @@ char *SerCmd(SerChannel *serch, char *cmnd) {
int l;
struct SerChan *ser;
char *result;
struct timeb tim0, tim1;
int tdif;
l=strlen(cmnd);
if (l>=SER_BUF_LEN-1) ERR_COD(ENOBUFS);
@ -88,11 +93,18 @@ char *SerCmd(SerChannel *serch, char *cmnd) {
logfileOut(LOG_SER, ">%s\n", cmnd);
cmnd[l]=ser->asyn_info.eot[1];
cmnd[l+1]='\0';
ftime(&tim0);
A_CHK(AsynSrv_SendCmnds(&ser->asyn_info, &ser->to_host, &ser->from_host, cmnd, NULL));
result=AsynSrv_GetReply(&ser->asyn_info, &ser->from_host, NULL);
ftime(&tim1);
tdif=(tim1.time-tim0.time)*1000+tim1.millitm-tim0.millitm;
if (result==NULL) ERR_MSG("empty result");
/* if (idleHandler!=NULL) idleHandler(50,0); */
logfileOut(LOG_SER, "<%s\n", result);
if (tdif>1000) {
logfileOut(LOG_SER, "%d msec:\n >%s\n", tdif, cmnd);
logfileOut(LOG_SER, " <%s\n", result);
}
return(result);
OnError: return(NULL);
}