hi!
This commit is contained in:
@ -5,21 +5,21 @@
|
||||
#--------------------------------------------------------------------------
|
||||
OBJ= tecs_cli.o coc_client.o coc_util.o err_handling.o \
|
||||
str_util.o str_buf.o coc_server.o tecs_lsc.o tecs_serial.o \
|
||||
coc_logfile.o tecs_dlog.o
|
||||
coc_logfile.o tecs_dlog.o
|
||||
|
||||
#------------ for DigitalUnix
|
||||
#------------ for DigitalUnix (add -DFORTIFY to CFLAGS for fortified version)
|
||||
CC=cc
|
||||
CFLAGS= -std1 -g -c -warnprotos -I../ -I. -I../hardsup
|
||||
CFLAGS= -std1 -g -warnprotos -I../ -I. -I../hardsup
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $*.c
|
||||
$(CC) $(CFLAGS) -c $*.c
|
||||
|
||||
tecs: $(OBJ)
|
||||
- rm libtecsl.a
|
||||
ar cr libtecsl.a $(OBJ)
|
||||
ranlib libtecsl.a
|
||||
- rm TecsServer
|
||||
$(CC) -o TecsServer -g -I../ tecs.c -lm -L. -ltecsl -L../hardsup -lhlib
|
||||
$(CC) $(CFLAGS) -o TecsServer -g tecs.c fortify1.c -lm -L. -ltecsl -L../hardsup -lhlib
|
||||
- rm test
|
||||
f77 -o test -g test.for tecs_tas.for get_lun.for -L. -ltecsl
|
||||
clean:
|
||||
|
@ -34,7 +34,7 @@ int CocOpen(CocConn *conn)
|
||||
ERR_I(i=CocConnect(conn, conn->startcmd[0]!='\0'));
|
||||
if (i==0) return(0);
|
||||
|
||||
printf("%s\n", conn->startcmd);
|
||||
printf("Starting TecsServer...\n\n%s\n", conn->startcmd);
|
||||
ERR_I(system(conn->startcmd));
|
||||
|
||||
try=15;
|
||||
@ -43,7 +43,10 @@ int CocOpen(CocConn *conn)
|
||||
try--;
|
||||
CocDelay(tmo); tmo=tmo*5/4;
|
||||
ERR_I(i=CocConnect(conn, try>0));
|
||||
if (i==0) return(0);
|
||||
if (i==0) {
|
||||
printf("\n... connected to TecsServer\n");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
ERR_MSG("error in CocConnect");
|
||||
OnError: return(-1);
|
||||
|
@ -93,7 +93,7 @@ CocVar *CocFindVar1(CocVar *varList, const char *name) {
|
||||
CocVar *p;
|
||||
|
||||
p=varList;
|
||||
while (p!=NULL && 0!=strcmp(p->name,name)) p=p->next;
|
||||
while (p!=NULL && 0!=strcasecmp(p->name,name)) p=p->next;
|
||||
return(p);
|
||||
}
|
||||
|
||||
@ -146,16 +146,20 @@ CocVar *CocDefVar(const char *name, void *var, int type, int *flag) {
|
||||
assert(varListHdl!=NULL);
|
||||
p=CocFindVar1(*varListHdl, name);
|
||||
if (p==NULL) {
|
||||
p=my_malloc(sizeof(*p), name);
|
||||
NEW(p);
|
||||
p->next=*varListHdl;
|
||||
*varListHdl=p;
|
||||
str_copy(p->name, name);
|
||||
p->type=type;
|
||||
} else {
|
||||
assert(p->type==type);
|
||||
}
|
||||
p->var=var;
|
||||
p->type=type;
|
||||
p->flag=flag;
|
||||
/* printf("define %s %d\n", name, (int)var); */
|
||||
return(p);
|
||||
OnError:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void CocDefVarS(const char *name, const char *tname, void *var, int type) {
|
||||
|
4
tecs/fortify1.c
Normal file
4
tecs/fortify1.c
Normal file
@ -0,0 +1,4 @@
|
||||
#include "fortify.c"
|
||||
#ifndef FORTIFY
|
||||
void null(void){};
|
||||
#endif
|
159
tecs/tecs.c
159
tecs/tecs.c
@ -12,8 +12,9 @@
|
||||
#include "tecs_lsc.h"
|
||||
#include "tecs_dlog.h"
|
||||
|
||||
int ftime (struct timeb *__timeptr); /* for some reason not defined in timeb.h with flag -std1 */
|
||||
|
||||
#define TABLE_FILE "lsci.tab"
|
||||
#define NO_CODE 999
|
||||
#define Progress(I) if (configuring) { configuring+=I; }
|
||||
|
||||
static SerChannel *ser=NULL;
|
||||
@ -40,13 +41,13 @@ typedef struct {
|
||||
Testpoint /* C standard guarantees initialization to zero */
|
||||
cryo, /* data for main sensors (on heat exchanger, or the only sensors) */
|
||||
samp, /* data for extra sensors of sample stick */
|
||||
*testpoints[2]={&cryo, &samp},
|
||||
*testpoint=&cryo;
|
||||
*tpoints[2]={&cryo, &samp},
|
||||
*tpoint=&cryo;
|
||||
|
||||
static float
|
||||
tempC, /* set T */
|
||||
tempH, /* set T on heater */
|
||||
htr, /* heat power */
|
||||
tempC, /* set T (for sample) */
|
||||
tempH, /* set T on heat exchanger */
|
||||
htr, /* heat power percentage */
|
||||
tLimit, power, /* heater parameters */
|
||||
tLow=0, tHigh=0, /* lower limit of high-T sensor, upper limit of low-T sensor */
|
||||
tShift=0, /* setpoint shift */
|
||||
@ -57,12 +58,11 @@ static int
|
||||
period=5000, /* default read interval (msec.) */
|
||||
logTime, /* next logging time */
|
||||
setFlag, /* temperature to be set */
|
||||
remoteFlag, /* to be set to remote mode */
|
||||
saveTime, /* time for a CRVSAV command */
|
||||
noResp=1, /* no response */
|
||||
quit, /* quit server */
|
||||
controlMode=2, /* 0: control on heater, 1: control on sample, 3: 2nd loop for difference heater-sample */
|
||||
mode, /* 0: local, 2: remote */
|
||||
mode=2, /* 0: local, 2: remote */
|
||||
maxfld, /* last used display field */
|
||||
busy, /* busy after CRVSAV */
|
||||
deviceFlag, /* device given via net */
|
||||
@ -106,7 +106,7 @@ void idleHdl(int tmo, int fd) {
|
||||
if (iRet<0) logfileShowErr("CocHandleRequests");
|
||||
}
|
||||
|
||||
void concatDevice() {
|
||||
void concatDevice(void) {
|
||||
str_copy(device, cryo.device);
|
||||
if (0!=strcmp(cryo.device, samp.device) && (samp.device[0]!='\0' || samp.manual)) {
|
||||
str_append(device, "/");
|
||||
@ -292,7 +292,7 @@ int instCurve(char *nam, char *channel) {
|
||||
return(retstat);
|
||||
}
|
||||
|
||||
int configInput() {
|
||||
int configInput(void) {
|
||||
char *t;
|
||||
char buf[80], nam[16], nbuf[256];
|
||||
int i, n, nn;
|
||||
@ -300,11 +300,11 @@ int configInput() {
|
||||
char *ext;
|
||||
|
||||
retstat=-2; /* errors in following section are severe */
|
||||
if (testpoint->manual) {
|
||||
sprintf(buf, "'%s'", testpoint->device);
|
||||
if (tpoint->manual) {
|
||||
sprintf(buf, "'%s'", tpoint->device);
|
||||
} else {
|
||||
sprintf(buf, "%+d ", testpoint->code);
|
||||
if (testpoint->code==0) return(0);
|
||||
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) { /* read table */
|
||||
@ -321,7 +321,7 @@ int configInput() {
|
||||
if (t==NULL) ERR_MSG("missing ' in table file");
|
||||
t++;
|
||||
n=1;
|
||||
if (testpoint==&samp) {
|
||||
if (tpoint==&samp) {
|
||||
samp.nSens=0;
|
||||
i=sscanf(t, "%12s%d%d", nam, &nn, &n);
|
||||
if (i<1) ERR_MSG("missing sensor name");
|
||||
@ -337,23 +337,23 @@ int configInput() {
|
||||
if (n<0 || n>2) ERR_MSG("illegal value for nsensor");
|
||||
if (n==0) return(0);
|
||||
nam[strlen(nam)-1]='\0'; /* strip off quote */
|
||||
if (!testpoint->manual) { /* set device name */
|
||||
str_copy(testpoint->device, nam);
|
||||
if (!tpoint->manual) { /* set device name */
|
||||
str_copy(tpoint->device, nam);
|
||||
concatDevice();
|
||||
}
|
||||
str_append(nam, ext);
|
||||
|
||||
ERR_I(retstat=instCurve(nam, testpoint->ch1));
|
||||
ERR_I(retstat=instCurve(nam, tpoint->ch1));
|
||||
if (n==2) {
|
||||
str_append(nam, "l");
|
||||
ERR_I(retstat=instCurve(nam, testpoint->ch2));
|
||||
ERR_I(retstat=instCurve(nam, tpoint->ch2));
|
||||
}
|
||||
testpoint->nSens=n;
|
||||
tpoint->nSens=n;
|
||||
return(0);
|
||||
OnError: return(retstat);
|
||||
}
|
||||
|
||||
int loadCache() {
|
||||
int loadCache(void) {
|
||||
int i, j, k;
|
||||
char *res;
|
||||
char buf[256], nbuf[256], lbuf[16];
|
||||
@ -418,11 +418,9 @@ float WeightedAverage(int n, float tH, float tL) {
|
||||
|
||||
int SetTemp(int switchOn) {
|
||||
char *ch;
|
||||
float scale;
|
||||
|
||||
if (tempC==0) {
|
||||
ERR_P(LscCmd(ser, "RANGE:0;SETP 1:0"));
|
||||
return(0);
|
||||
}
|
||||
scale=cryo.scale;
|
||||
ch=cryo.ch1;
|
||||
if (cryo.nSens>1 && tempC<(tLow+tHigh)/2) ch=cryo.ch2;
|
||||
if (samp.nSens>0) {
|
||||
@ -430,6 +428,7 @@ int SetTemp(int switchOn) {
|
||||
tShift=0;
|
||||
ch=samp.ch1;
|
||||
if (cryo.nSens>1 && tempC<(tLow+tHigh)/2) ch=samp.ch2;
|
||||
scale=samp.scale;
|
||||
} else if (controlMode!=2) {
|
||||
tShift=0;
|
||||
}
|
||||
@ -437,7 +436,14 @@ int SetTemp(int switchOn) {
|
||||
tShift=0;
|
||||
}
|
||||
str_copy(chan, ch);
|
||||
tempH=tempC+tShift;
|
||||
if (scale!=1.0) {
|
||||
ERR_P(LscCmd(ser, "LINEAR C,1,0,1,1,[tempC]"));
|
||||
}
|
||||
if (tempC==0) {
|
||||
ERR_P(LscCmd(ser, "RANGE:0;SETP 1:0"));
|
||||
return(0);
|
||||
}
|
||||
tempH=(tempC+tShift)/scale;
|
||||
if (switchOn) {
|
||||
ERR_P(LscCmd(ser, "CSET 1:[chan],1,1,0;RANGE:[iRange];SETP 1:[tempH]"));
|
||||
} else {
|
||||
@ -447,7 +453,7 @@ int SetTemp(int switchOn) {
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int ReadTemp() {
|
||||
int ReadTemp(void) {
|
||||
char buf[256];
|
||||
int i;
|
||||
|
||||
@ -498,11 +504,11 @@ int ReadTemp() {
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int PeriodicTask() {
|
||||
int PeriodicTask(void) {
|
||||
char buf[256], lbuf[16];
|
||||
char *res;
|
||||
int i, k;
|
||||
float t2[2], p, d;
|
||||
float t2[2], p, d, w;
|
||||
|
||||
ERR_P(LscCmd(ser, "DIOST?>cod1,out1;DOUT 3,29;HTR?>htr;BUSY?>busy"));
|
||||
if (cryo.codDefined) {
|
||||
@ -520,6 +526,7 @@ int PeriodicTask() {
|
||||
str_copy(status, "controller connected");
|
||||
}
|
||||
configuring++;
|
||||
tempC=0;
|
||||
if (cryo.manual || cryo.code!=0) { cryo.dirty=1; }
|
||||
if (samp.manual || samp.code!=0) { samp.dirty=1; }
|
||||
ERR_P(LscCmd(ser, "RANGE:0")); /* switch off heater */
|
||||
@ -549,10 +556,12 @@ int PeriodicTask() {
|
||||
logTime=(tim/logPeriod+1)*logPeriod;
|
||||
}
|
||||
if (samp.nSens>0 && cryo.nSens>0 && controlMode==2 && tempC!=0) {
|
||||
d=tempH-cryo.temp; d=exp(-d*d); /* if d is small, we are far from setpoint */
|
||||
if (tInt<60000/period) tInt+=d; /* increase integral time until 60 sec. */
|
||||
if (tInt>d) {
|
||||
p=d/tInt;
|
||||
d=(tempH-cryo.temp)/cryo.temp-1.0; /* relative difference */
|
||||
w=exp(-d*d*230); /* gaussian */
|
||||
if (w<0.1) tInt=0; /* reset when far from setpoint (more than 10 %) */
|
||||
if (tInt<30000/period) tInt+=w; /* increase integral time until 30 sec. */
|
||||
if (tInt>w) {
|
||||
p=w/tInt;
|
||||
} else {
|
||||
p=1.0;
|
||||
}
|
||||
@ -577,26 +586,27 @@ int PeriodicTask() {
|
||||
cryo.code1=3*decod[cod2 % 8] ^ 2*decod[cod1 % 8]; /* ^ is exclusive OR */
|
||||
samp.code1=-(3*decod[cod2 / 8] ^ 2*decod[cod1 / 8]);
|
||||
for (i=0; i<2; i++) {
|
||||
testpoint=testpoints[i];
|
||||
if (testpoint->code1!=testpoint->code) {
|
||||
testpoint->code=testpoint->code1;
|
||||
testpoint->codChanged=1;
|
||||
tpoint=tpoints[i];
|
||||
if (tpoint->code1!=tpoint->code) {
|
||||
tpoint->code=tpoint->code1;
|
||||
tpoint->codChanged=1;
|
||||
} else {
|
||||
if (testpoint->codChanged) {
|
||||
testpoint->codChanged=0;
|
||||
if (tpoint->codChanged) {
|
||||
tpoint->codChanged=0;
|
||||
Progress(1);
|
||||
if (testpoint->code1==0) {
|
||||
logfileOut(LOG_MAIN, "%s unplugged\n", testpoint->tname);
|
||||
if (tpoint->code1==0) {
|
||||
logfileOut(LOG_MAIN, "%s unplugged\n", tpoint->tname);
|
||||
} else {
|
||||
logfileOut(LOG_MAIN, "plugged %d on %s\n", testpoint->code1, testpoint->tname);
|
||||
logfileOut(LOG_MAIN, "plugged %d on %s\n", tpoint->code1, tpoint->tname);
|
||||
}
|
||||
if (testpoint->codDefined) {
|
||||
testpoint->manual=0;
|
||||
if (tpoint->codDefined) {
|
||||
tpoint->manual=0;
|
||||
}
|
||||
testpoint->dirty=1;
|
||||
tempC=0;
|
||||
tpoint->dirty=1;
|
||||
if (!configuring) configuring=1;
|
||||
}
|
||||
testpoint->codDefined=1;
|
||||
tpoint->codDefined=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -619,32 +629,32 @@ int PeriodicTask() {
|
||||
|
||||
int inputSettings(Testpoint *this) {
|
||||
|
||||
testpoint=this;
|
||||
if (testpoint->dirty && samp.codDefined) {
|
||||
if (busy==0 || cryo.dirty>=0 && testpoint->dirty>=0) { /* do not enter when busy and cryo.dirty/P indicates error on last time */
|
||||
if (testpoint->manual) {
|
||||
logfileOut(LOG_MAIN ,"configure %s inputs for %s\n", testpoint->tname, testpoint->device);
|
||||
tpoint=this;
|
||||
if (tpoint->dirty && samp.codDefined) {
|
||||
if (busy==0 || cryo.dirty>=0 && tpoint->dirty>=0) { /* do not enter when busy and cryo.dirty/P indicates error on last time */
|
||||
if (tpoint->manual) {
|
||||
logfileOut(LOG_MAIN ,"configure %s inputs for %s\n", tpoint->tname, tpoint->device);
|
||||
} else {
|
||||
if (testpoint->code==0) {
|
||||
logfileOut(LOG_MAIN ,"reset %s inputs\n", testpoint->tname);
|
||||
if (tpoint->code==0) {
|
||||
logfileOut(LOG_MAIN ,"reset %s inputs\n", tpoint->tname);
|
||||
} else {
|
||||
logfileOut(LOG_MAIN ,"configure %s inputs for code %+d\n", testpoint->tname, testpoint->code);
|
||||
logfileOut(LOG_MAIN ,"configure %s inputs for code %+d\n", tpoint->tname, tpoint->code);
|
||||
}
|
||||
}
|
||||
if (testpoint->dirty>0) testpoint->try=0;
|
||||
testpoint->nSens=0;
|
||||
if (!testpoint->manual) { testpoint->device[0]='\0'; concatDevice(); }
|
||||
testpoint->dirty=configInput();
|
||||
if (testpoint->dirty<0) {
|
||||
testpoint->try++;
|
||||
if (testpoint->dirty!=-1 || testpoint->try>3) {
|
||||
if (tpoint->dirty>0) tpoint->try=0;
|
||||
tpoint->nSens=0;
|
||||
if (!tpoint->manual) { tpoint->device[0]='\0'; concatDevice(); }
|
||||
tpoint->dirty=configInput();
|
||||
if (tpoint->dirty<0) {
|
||||
tpoint->try++;
|
||||
if (tpoint->dirty!=-1 || tpoint->try>3) {
|
||||
logfileShowErr("fatal error");
|
||||
testpoint->dirty=0; testpoint->device[0]='\0'; concatDevice();
|
||||
tpoint->dirty=0; tpoint->device[0]='\0'; concatDevice();
|
||||
} else {
|
||||
logfileShowErr("try again");
|
||||
}
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "ALARM [testpoint.ch1]:[testpoint.nSens],1,[tLimit],0,0,1;ALARM [testpoint.ch2]:0;RELAY 1:1;BEEP:0"));
|
||||
ERR_P(LscCmd(ser, "ALARM [tpoint.ch1]:[tpoint.nSens],1,[tLimit],0,0,1;ALARM [tpoint.ch2]:0;RELAY 1:1;BEEP:0"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -652,7 +662,7 @@ int inputSettings(Testpoint *this) {
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int Settings() {
|
||||
int Settings(void) {
|
||||
int i, j, k;
|
||||
float pa, pr, pw, dif;
|
||||
char nbuf[256], buf[256], *cfg, *p;
|
||||
@ -661,9 +671,9 @@ int Settings() {
|
||||
if (cryo.dirty && cryo.codDefined || samp.dirty && samp.codDefined) {
|
||||
|
||||
for (i=0; i<2; i++) {
|
||||
testpoint=testpoints[i];
|
||||
if (testpoint->dirty) {
|
||||
ERR_P(LscCmd(ser, "DISPFLD 2,[testpoint.ch1],1;DISPFLD 4,[testpoint.ch2],1"));
|
||||
tpoint=tpoints[i];
|
||||
if (tpoint->dirty) {
|
||||
ERR_P(LscCmd(ser, "DISPFLD 2,[tpoint.ch1],1;DISPFLD 4,[tpoint.ch2],1"));
|
||||
}
|
||||
}
|
||||
inputSettings(&cryo);
|
||||
@ -692,9 +702,7 @@ int Settings() {
|
||||
power=pw;
|
||||
logfileOut(LOG_INFO, "power %f\n", power, iAmp, iRange);
|
||||
ERR_P(LscCmd(ser, "CLIMIT 1:[tLimit],0,0,[iAmp],[iRange]"));
|
||||
tempC=0.001; tShift=0;
|
||||
ERR_I(SetTemp(1));
|
||||
tempC=0;
|
||||
}
|
||||
if (samp.nSens>=cryo.nSens) {
|
||||
maxfld=2*samp.nSens;
|
||||
@ -740,7 +748,7 @@ int Settings() {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int ExecuteRequest() {
|
||||
int ExecuteRequest(void) {
|
||||
char *t, *res;
|
||||
struct CocClient *client;
|
||||
|
||||
@ -765,6 +773,7 @@ int ExecuteRequest() {
|
||||
client->cmd[0]='\0';
|
||||
}
|
||||
if (deviceFlag) {
|
||||
tempC=0;
|
||||
if (!configuring) {
|
||||
str_copy(status, "configuring");
|
||||
configuring=1;
|
||||
@ -860,7 +869,7 @@ int main(int argc, char *argv[])
|
||||
binDir="bin/";
|
||||
logDir="log/";
|
||||
serverId="tecs";
|
||||
host="lnsp26";
|
||||
host="lnsp26:4000/0";
|
||||
port=0;
|
||||
msecTmo=0;
|
||||
logfileOut(LOG_INFO ,"%s ", argv[0]);
|
||||
@ -919,22 +928,25 @@ int main(int argc, char *argv[])
|
||||
|
||||
CocDefStruct(cryo, Testpoint);
|
||||
CocDefStruct(samp, Testpoint);
|
||||
CocDefPtr(testpoint, Testpoint);
|
||||
CocDefPtr(tpoint, Testpoint);
|
||||
|
||||
CocFltFld(Testpoint, temp, CocRD);
|
||||
CocFltFld(Testpoint, t1, CocRD);
|
||||
CocFltFld(Testpoint, t2, CocRD);
|
||||
CocFltFld(Testpoint, scale, CocRD);
|
||||
|
||||
CocStrFld(Testpoint, ch1, CocRD);
|
||||
CocStrFld(Testpoint, ch2, CocRD);
|
||||
|
||||
CocDefFlt(htr, CocRD);
|
||||
CocDefFlt(power, CocRD);
|
||||
CocDefFlt(tempC, setFlag);
|
||||
CocDefFlt(tempH, CocRD);
|
||||
CocDefFlt(tLimit, CocRD);
|
||||
|
||||
CocAlias(tempX,cryo.temp);
|
||||
CocAlias(tempP,samp.temp);
|
||||
CocAlias(set,tempC);
|
||||
|
||||
CocDefStr(device, deviceFlag);
|
||||
|
||||
@ -982,6 +994,7 @@ int main(int argc, char *argv[])
|
||||
logfileOut(LOG_INFO, "opened\n");
|
||||
}
|
||||
logfileWrite(logMask);
|
||||
ERR_P(LscCmd(ser, "MODE:[mode]"));
|
||||
per=period;
|
||||
cntError=0;
|
||||
while (!quit) {
|
||||
@ -994,6 +1007,8 @@ int main(int argc, char *argv[])
|
||||
if (cntError>0) cntError--;
|
||||
}
|
||||
}
|
||||
ERR_P(LscCmd(ser, "MODE:1"));
|
||||
logfileWrite(logMask);
|
||||
ERR_MSG("got quit command");
|
||||
OnError:
|
||||
logfileShowErr("exit TecsServer");
|
||||
|
@ -36,6 +36,8 @@ c Define the dummy arguments
|
||||
character RESPONSE*(*) !! response from temperature controller
|
||||
c------------------------------------------------------------------------------
|
||||
integer iret, l
|
||||
character startcmd*80
|
||||
common /tecs_init_com/startcmd
|
||||
integer*8 conn/0/
|
||||
save conn ! not needed for initialized variables
|
||||
|
||||
@ -46,8 +48,8 @@ c------------------------------------------------------------------------------
|
||||
c------------------------------------------------------------------------------
|
||||
stop 'TECS_TAS: do not call module header'
|
||||
|
||||
entry TECS_INIT (ERRLUN)
|
||||
!! ========================
|
||||
entry TECS_INIT (ERRLUN, CMD)
|
||||
!! =============================
|
||||
|
||||
if (conn .eq. 0) call tecs_open(conn, errlun)
|
||||
return
|
||||
@ -66,6 +68,8 @@ c------------------------------------------------------------------------------
|
||||
iret=tecc_wait(conn)
|
||||
if (iret .lt. 0) goto 9
|
||||
write(errlun, *) '... done'
|
||||
iret=tecc_get3(conn, temp(1), temp(3), temp(2)) ! temp(2) and temp(3) are exchanged in MSHOWT
|
||||
if (iret .lt. 0) goto 9
|
||||
endif
|
||||
2 temp(4)=0.0 ! no auxilliary sensor
|
||||
return
|
||||
@ -140,8 +144,11 @@ c Define the dummy arguments
|
||||
integer*8 conn
|
||||
integer errlun
|
||||
c--------------------------------------------------------------
|
||||
integer lun, port, ios
|
||||
character startcmd*80/' '/
|
||||
integer lun, port, ios, i
|
||||
|
||||
character startcmd*80
|
||||
common /tecs_init_com/startcmd
|
||||
data startcmd/' '/
|
||||
|
||||
integer*8 tecc_init
|
||||
external tecc_init, tecs_err_routine
|
||||
@ -149,15 +156,20 @@ c--------------------------------------------------------------
|
||||
c If MAD_TECS:TECS.INIT exists, read it to get the port number and start command
|
||||
|
||||
call ErrSetOutRtn(tecs_err_routine, errlun)
|
||||
call lib$get_lun (lun)
|
||||
open (lun, file='mad_tecs:tecs.init', status='old',
|
||||
port=0
|
||||
if (startcmd .eq. ' ') then
|
||||
call lib$get_lun (lun)
|
||||
open (lun, file='mad_tecs:tecs.init', status='old',
|
||||
+ readonly, iostat=ios)
|
||||
if (ios .eq. 0) read (lun, *, iostat=ios) port
|
||||
if (ios .eq. 0) read (lun, '(a)', iostat=ios) startcmd
|
||||
close(lun)
|
||||
call lib$free_lun(lun)
|
||||
|
||||
if (ios .ne. 0) port = 9753 ! Otherwise, use default
|
||||
if (ios .eq. 0) read (lun, '(a)', iostat=ios) startcmd
|
||||
close(lun)
|
||||
call lib$free_lun(lun)
|
||||
endif
|
||||
i=index(startcmd, '-p ')
|
||||
if (i .ne. 0) then
|
||||
read(startcmd(i+2:),*,iostat=ios) port
|
||||
endif
|
||||
if (port .eq. 0) port=9753
|
||||
c--------------------------------------------------------------
|
||||
|
||||
conn = tecc_init(startcmd, port)
|
||||
|
126
tecs/test.for
126
tecs/test.for
@ -1,40 +1,108 @@
|
||||
program test
|
||||
|
||||
real*4 temp(4)
|
||||
character device*32, cmd*80, response*80
|
||||
integer i
|
||||
character device*32, line*80, cmd*16, par*80, response*80
|
||||
integer i,j,k
|
||||
|
||||
call tecs_init(6, ' ')
|
||||
|
||||
call tecs_init(6)
|
||||
print *
|
||||
print *,'s <temp> set temperature'
|
||||
print *,'device <device> set cryo device'
|
||||
print *,'<command> direct command to LSC340'
|
||||
print *,'"empty line" show temperature and device'
|
||||
1 read(*,'(a)',end=9) cmd
|
||||
if (cmd(1:2) .eq. 's') then
|
||||
read(cmd(3:),*) temp(1)
|
||||
call tecs_set_temp(6, temp(1))
|
||||
elseif (cmd(1:2) .eq. 'c') then
|
||||
call tecs_send_cmd(6, cmd(3:), response)
|
||||
print *,response
|
||||
elseif (cmd(1:2) .eq. 'q') then
|
||||
print *,'Tecs Client'
|
||||
print *,'-----------'
|
||||
print *
|
||||
print *,'<empty line> show temperature and device'
|
||||
print *,'set <temp> set temperature'
|
||||
print *,'send <command> direct command to LSC340'
|
||||
print *,'device <device> set cryo device'
|
||||
print *,'<parameter> show parameter'
|
||||
print *,'<parameter> <value> set parameter'
|
||||
print *,'help show list of parameters and cryo devices'
|
||||
print *,'quit close TecsServer and exit'
|
||||
print *,'exit exit, but do not close TecsServer'
|
||||
print *
|
||||
1 print '(x,a,$)','tecs> '
|
||||
read(*,'(a)',end=9) line
|
||||
cmd=' '
|
||||
k=0
|
||||
do j=1,len(line)
|
||||
if (line(j:j) .gt. ' ') then
|
||||
k=k+1
|
||||
cmd(k:k)=line(j:j)
|
||||
if (cmd(k:k) .ge. 'A' .and. cmd(k:k) .le. 'Z') then ! set to lowercase
|
||||
cmd(k:k)=char(ichar(cmd(k:k))+32)
|
||||
endif
|
||||
elseif (k .gt. 0) then ! end of command
|
||||
goto 2
|
||||
endif
|
||||
enddo
|
||||
|
||||
if (k .eq. 0) then ! empty line
|
||||
call tecs_get_temp(6, temp)
|
||||
call tecs_get_par(6, 'device', device)
|
||||
print '(x,3(a,f8.3),2a)','tempX=', temp(2),', tempP=',temp(3)
|
||||
1 ,', tempC=',temp(1), ', device=',device
|
||||
goto 1
|
||||
endif
|
||||
|
||||
print *,'command too long'
|
||||
goto 1
|
||||
|
||||
2 par=' '
|
||||
do i=j,len(line)
|
||||
if (line(i:i) .gt. ' ') then
|
||||
par=line(i:)
|
||||
goto 3
|
||||
endif
|
||||
enddo
|
||||
|
||||
! simple query
|
||||
|
||||
if (cmd .eq. 'quit') then
|
||||
call tecs_quit(6)
|
||||
goto 9
|
||||
elseif (cmd .ne. ' ') then
|
||||
i=index(cmd,' ')
|
||||
if (i .gt. 1) then
|
||||
if (cmd(i+1:) .eq. ' ') then
|
||||
call tecs_get_par(6, cmd(1:i-1), response)
|
||||
print *,response
|
||||
else
|
||||
call tecs_set_par(6, cmd(1:i-1), cmd(i+1:))
|
||||
endif
|
||||
endif
|
||||
elseif (cmd .eq. 'exit') then
|
||||
goto 9
|
||||
elseif (cmd .eq. 'help') then
|
||||
print *
|
||||
print *,'Writeable parameters:'
|
||||
print *
|
||||
print *,'tempC temperature set-point'
|
||||
print *,'device temperature device'
|
||||
print *,'controlMode control on: 0: heat exchanger, '
|
||||
1 ,'1: sample, 2: second loop'
|
||||
print *
|
||||
print *,'Read only parameters:'
|
||||
print *
|
||||
print *,'tempX heat exchanger temperature'
|
||||
print *,'tempP sample temperature'
|
||||
print *,'tempH set-point on regulation'
|
||||
print *,'tLimit temperature limit'
|
||||
print *,'htr heater current percentage'
|
||||
print *,'power heater max. power'
|
||||
print *,'resist heater resistance'
|
||||
print *
|
||||
print *,'Temperature devices:'
|
||||
print *
|
||||
print *,'ill1, ill2, ill3 (cryofurnace), ill4 (focus-cryo), '
|
||||
1 ,'ill5 (maxi)'
|
||||
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 *
|
||||
else
|
||||
call tecs_get_temp(6, temp)
|
||||
print *,' x ', temp(2),' p ',temp(3),' set ',temp(1)
|
||||
call tecs_get_par(6, 'device', device)
|
||||
print *,'device=',device
|
||||
call tecs_get_par(6, cmd, response)
|
||||
print '(7x,3a)',cmd(1:k),'=',response
|
||||
endif
|
||||
goto 1
|
||||
|
||||
3 if (cmd .eq. 'send') then
|
||||
call tecs_send_cmd(6, par, response)
|
||||
print '(7x,2a)','response: ',response
|
||||
else
|
||||
call tecs_set_par(6, cmd, par)
|
||||
print '(7x,3a)',cmd(1:k),':=',par
|
||||
endif
|
||||
goto 1
|
||||
|
||||
9 end
|
||||
|
Reference in New Issue
Block a user