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