hi!
This commit is contained in:
14
tecs/tecs.c
14
tecs/tecs.c
@ -508,6 +508,7 @@ int PeriodicTask(void) {
|
|||||||
char buf[256], lbuf[16];
|
char buf[256], lbuf[16];
|
||||||
char *res;
|
char *res;
|
||||||
int i, k;
|
int i, k;
|
||||||
|
time_t putTim;
|
||||||
float t2[2], p, d, w;
|
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"));
|
||||||
@ -552,8 +553,13 @@ int PeriodicTask(void) {
|
|||||||
if (cryo.dirty==0 && samp.dirty==0 && noResp==0 && tim>logTime) {
|
if (cryo.dirty==0 && samp.dirty==0 && noResp==0 && tim>logTime) {
|
||||||
t2[0]=cryo.temp;
|
t2[0]=cryo.temp;
|
||||||
t2[1]=samp.temp;
|
t2[1]=samp.temp;
|
||||||
DlogPut(&dset, tim, 2, t2); DlogUpd(&dset);
|
time(&putTim);
|
||||||
logTime=(tim/logPeriod+1)*logPeriod;
|
DlogPut(&dset, putTim, 2, t2); DlogUpd(&dset);
|
||||||
|
logTime=(putTim/logPeriod+1)*logPeriod;
|
||||||
|
time(&tim);
|
||||||
|
if (tim-putTim>1) {
|
||||||
|
logfileOut(LOG_MAIN, "needed %d sec. for filling in dlog\n", tim-putTim);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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)/cryo.temp-1.0; /* relative difference */
|
d=(tempH-cryo.temp)/cryo.temp-1.0; /* relative difference */
|
||||||
@ -842,6 +848,8 @@ int mainBody(void)
|
|||||||
if (!noResp) logfileOut(LOG_MAIN ,"no response\n");
|
if (!noResp) logfileOut(LOG_MAIN ,"no response\n");
|
||||||
per=period+10000; /* long period if no response */
|
per=period+10000; /* long period if no response */
|
||||||
noResp=1;
|
noResp=1;
|
||||||
|
cryo.temp=0;
|
||||||
|
samp.temp=0;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -994,7 +1002,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]"));
|
LscCmd(ser, "MODE:[mode]");
|
||||||
per=period;
|
per=period;
|
||||||
cntError=0;
|
cntError=0;
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
|
113
tecs/tecs_dlog.c
113
tecs/tecs_dlog.c
@ -31,6 +31,46 @@ int DlogWrite(DlogSet *dset, int idx, void *data) {
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FILL_BUF_SIZE 1024
|
||||||
|
|
||||||
|
int DlogFill(DlogSet *dset, int from, int to) {
|
||||||
|
int p, q, e, i, size;
|
||||||
|
float fill[FILL_BUF_SIZE];
|
||||||
|
|
||||||
|
for (i=0;i<FILL_BUF_SIZE;i++) fill[i]=dset->undef;
|
||||||
|
e = 0;
|
||||||
|
if (to-from>=dset->nlen) { /* fill all */
|
||||||
|
p = dset->headsize;
|
||||||
|
q = dset->headsize + dset->nlen * dset->fsize;
|
||||||
|
} else {
|
||||||
|
p = dset->headsize + (from % dset->nlen) * dset->fsize;
|
||||||
|
q = dset->headsize + (to % dset->nlen) * dset->fsize;
|
||||||
|
if (q<p) {
|
||||||
|
e = q;
|
||||||
|
q = dset->headsize + dset->nlen * dset->fsize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ERR_SI(lseek(dset->fd, p, SEEK_SET));
|
||||||
|
for (i=p; i<q-sizeof(fill); i+=sizeof(fill)) {
|
||||||
|
ERR_SI(write(dset->fd, fill, sizeof(fill)));
|
||||||
|
}
|
||||||
|
if (q>i) ERR_SI(write(dset->fd, fill, q-i));
|
||||||
|
|
||||||
|
if (e>0) {
|
||||||
|
p = dset -> headsize;
|
||||||
|
ERR_SI(lseek(dset->fd, p, SEEK_SET));
|
||||||
|
for (i=p; i<e-sizeof(fill); i+=sizeof(fill)) {
|
||||||
|
ERR_SI(write(dset->fd, fill, sizeof(fill)));
|
||||||
|
}
|
||||||
|
if (e>i) ERR_SI(write(dset->fd, fill, q-i));
|
||||||
|
}
|
||||||
|
dset->pos = -1; /* set position to undefined */
|
||||||
|
return(0);
|
||||||
|
OnError:
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
int DlogRead(DlogSet *dset, int idx, void *data) {
|
int DlogRead(DlogSet *dset, int idx, void *data) {
|
||||||
int p;
|
int p;
|
||||||
|
|
||||||
@ -44,6 +84,25 @@ int DlogRead(DlogSet *dset, int idx, void *data) {
|
|||||||
OnError:
|
OnError:
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
int DlogRead(DlogSet *dset, int idx, int max, void *data) {
|
||||||
|
int i, p, m;
|
||||||
|
|
||||||
|
i = idx % dset->nlen;
|
||||||
|
p = dset->headsize + i * dset->fsize;
|
||||||
|
if (max > dset->nlen - i) {
|
||||||
|
max = dset->nlen - i;
|
||||||
|
}
|
||||||
|
if (p!=dset->pos) {
|
||||||
|
ERR_SI(lseek(dset->fd, p, SEEK_SET));
|
||||||
|
}
|
||||||
|
ERR_SI(read(dset->fd, data, dset->fsize * max));
|
||||||
|
dset->pos = p + dset->fsize * max;
|
||||||
|
return(max);
|
||||||
|
OnError:
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
int DlogOpenOld(DlogSet *dset, char *name, int write) {
|
int DlogOpenOld(DlogSet *dset, char *name, int write) {
|
||||||
int i, p, np, fd, flags;
|
int i, p, np, fd, flags;
|
||||||
@ -122,7 +181,7 @@ int DlogOpenWrt(DlogSet *dset, char *name, time_t start, int nset, int nlen, int
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DlogPut(DlogSet *dset, time_t time, int nset, float val[]) {
|
int DlogPut(DlogSet *dset, time_t tim, int nset, float val[]) {
|
||||||
int i, i0, j;
|
int i, i0, j;
|
||||||
float f[DLOG_MAX_SET], f0[DLOG_MAX_SET];
|
float f[DLOG_MAX_SET], f0[DLOG_MAX_SET];
|
||||||
|
|
||||||
@ -131,11 +190,11 @@ int DlogPut(DlogSet *dset, time_t time, int nset, float val[]) {
|
|||||||
for (j=0; j < nset; j++) { f[j]=val[j]; }
|
for (j=0; j < nset; j++) { f[j]=val[j]; }
|
||||||
for (j=nset; j < dset->nset; j++) { f[j]=dset->undef; }
|
for (j=nset; j < dset->nset; j++) { f[j]=dset->undef; }
|
||||||
|
|
||||||
i = ( time - dset->start ) / dset->period;
|
i = ( tim - dset->start ) / dset->period;
|
||||||
i0 = ( dset->last - dset->start ) / dset->period;
|
i0 = ( dset->last - dset->start ) / dset->period;
|
||||||
|
|
||||||
if (i0==i) {
|
if (i0==i) {
|
||||||
ERR_I(DlogRead(dset, i, f0));
|
ERR_I(DlogRead(dset, i, 1, f0));
|
||||||
for (j=0; j<nset; j++) {
|
for (j=0; j<nset; j++) {
|
||||||
if (DEFINED(f0[j]) && /* when last point defined */
|
if (DEFINED(f0[j]) && /* when last point defined */
|
||||||
(i%2 && f0[j]>f[j] || /* take maximum (for odd i) */
|
(i%2 && f0[j]>f[j] || /* take maximum (for odd i) */
|
||||||
@ -143,23 +202,20 @@ int DlogPut(DlogSet *dset, time_t time, int nset, float val[]) {
|
|||||||
) f[j]=f0[j]; /* of f0 and f0 */
|
) f[j]=f0[j]; /* of f0 and f0 */
|
||||||
}
|
}
|
||||||
} else if (i0<i-1) {
|
} else if (i0<i-1) {
|
||||||
for (j=0; j < dset->nset; j++) { f0[j]=dset->undef; }
|
DlogFill(dset, i0+1, i);
|
||||||
i0++;
|
|
||||||
while (i0<i) {
|
|
||||||
ERR_I(DlogWrite(dset, i0, f0));
|
|
||||||
i0++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ERR_I(DlogWrite(dset, i, f));
|
ERR_I(DlogWrite(dset, i, f));
|
||||||
dset->last=time;
|
dset->last=tim;
|
||||||
return(0);
|
return(0);
|
||||||
OnError:
|
OnError:
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define RD_BUF_SIZE 1024
|
||||||
|
|
||||||
int DlogGet(DlogSet *dset, int iset, int nmax, double *starttime, float x[], float y[]) {
|
int DlogGet(DlogSet *dset, int iset, int nmax, double *starttime, float x[], float y[]) {
|
||||||
int i0, i1, i, n, undef;
|
int j, i0, i1, i, n, nread, undef;
|
||||||
float f[DLOG_MAX_SET];
|
float f, fbuf[RD_BUF_SIZE+1];
|
||||||
|
|
||||||
if (iset<0) ERR_MSG("illegal iset");
|
if (iset<0) ERR_MSG("illegal iset");
|
||||||
if (iset>=dset->nset) return(0);
|
if (iset>=dset->nset) return(0);
|
||||||
@ -176,21 +232,24 @@ int DlogGet(DlogSet *dset, int iset, int nmax, double *starttime, float x[], flo
|
|||||||
n=0;
|
n=0;
|
||||||
undef=2;
|
undef=2;
|
||||||
while (i0<=i) {
|
while (i0<=i) {
|
||||||
if (n>=nmax) return(n);
|
ERR_I(nread=DlogRead(dset, i0, RD_BUF_SIZE/dset->nset, fbuf));
|
||||||
ERR_I(DlogRead(dset, i0, f));
|
for (j=0; j<nread; j++) {
|
||||||
i0++;
|
if (n>=nmax) return(n);
|
||||||
if (DEFINED(f[iset])) {
|
f=fbuf[j * dset->nset + iset];
|
||||||
x[n]=(float)(i0-i1)*dset->period;
|
i0++;
|
||||||
y[n]=f[iset];
|
if (DEFINED(f)) {
|
||||||
n++;
|
x[n]=(float)(i0-i1)*dset->period;
|
||||||
undef=0;
|
y[n]=f;
|
||||||
} else if (undef==0) {
|
n++;
|
||||||
undef=1;
|
undef=0;
|
||||||
} else if (undef==1) {
|
} else if (undef==0) {
|
||||||
undef=2;
|
undef=1;
|
||||||
x[n]=0;
|
} else if (undef==1) {
|
||||||
y[n]=0;
|
undef=2;
|
||||||
n++;
|
x[n]=0;
|
||||||
|
y[n]=0;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(n);
|
return(n);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
print *,'device <device> set cryo device'
|
print *,'device <device> set cryo device'
|
||||||
print *,'<parameter> show parameter'
|
print *,'<parameter> show parameter'
|
||||||
print *,'<parameter> <value> set parameter'
|
print *,'<parameter> <value> set parameter'
|
||||||
print *,'quit close TecsServer and exit'
|
print *,'kill close TecsServer and exit'
|
||||||
print *,'exit exit, but do not close TecsServer'
|
print *,'exit exit, but do not close TecsServer'
|
||||||
print *,'help show list of parameters and cryo devices'
|
print *,'help show list of parameters and cryo devices'
|
||||||
print *
|
print *
|
||||||
@ -39,8 +39,8 @@
|
|||||||
if (k .eq. 0) then ! empty line
|
if (k .eq. 0) then ! empty line
|
||||||
call tecs_get_temp(6, temp)
|
call tecs_get_temp(6, temp)
|
||||||
call tecs_get_par(6, 'device', device)
|
call tecs_get_par(6, 'device', device)
|
||||||
print '(x,3(a,f8.3),2a)','tempX=', temp(2),', tempP=',temp(3)
|
print '(x,3(a,f8.3),2a)','tempX=', temp(3),', tempP=',temp(2)
|
||||||
1 ,', tempC=',temp(1), ', device=',device
|
1 ,', set=',temp(1), ', device=',device
|
||||||
goto 1
|
goto 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
! simple query
|
! simple query
|
||||||
|
|
||||||
if (cmd .eq. 'quit') then
|
if (cmd .eq. 'kill') then
|
||||||
call tecs_quit(6)
|
call tecs_quit(6)
|
||||||
goto 9
|
goto 9
|
||||||
elseif (cmd .eq. 'exit') then
|
elseif (cmd .eq. 'exit') then
|
||||||
|
@ -117,8 +117,8 @@
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
} else { /* get case or command without parameter */
|
} else { /* get case or command without parameter */
|
||||||
if (0==strcasecmp(argv[1], "quit")) {
|
if (0==strcasecmp(argv[1], "kill")) {
|
||||||
iRet=CocSet(pMe->pData,argv[1],"1"); /* send quit flag */
|
iRet=CocSet(pMe->pData,"quit","1"); /* send quit flag */
|
||||||
strcpy(result, "1");
|
strcpy(result, "1");
|
||||||
} else {
|
} else {
|
||||||
iRet=CocGet(pMe->pData,argv[1],result); /* get parameter */
|
iRet=CocGet(pMe->pData,argv[1],result); /* get parameter */
|
||||||
|
Reference in New Issue
Block a user