- small improvements
This commit is contained in:
65
tecs/tecs.c
65
tecs/tecs.c
@ -175,6 +175,7 @@ static int
|
||||
per, /* effective period */
|
||||
mmInt, mmTime, /* interval and time for next min-max logging */
|
||||
nScan=0, /* number of scanned channels */
|
||||
iScan=1, /* actual scan channel */
|
||||
alarmListSize=0,
|
||||
keepT=0, /* keep control over power-up */
|
||||
swRangeOn=60, /* when not happen several times within less than 60 sec. delay,
|
||||
@ -303,7 +304,7 @@ int InstalCurve(SensorT *sensor, char *devArg) {
|
||||
*e, /* cache part after found entry */
|
||||
*t;
|
||||
int i, n;
|
||||
char used[60];
|
||||
char used[61];
|
||||
FILE *fil;
|
||||
|
||||
sens=sensor;
|
||||
@ -379,7 +380,9 @@ int InstalCurve(SensorT *sensor, char *devArg) {
|
||||
entry=strstr(start, buf);
|
||||
if (entry==NULL) { /* sensor not found in cache */
|
||||
entry=start;
|
||||
for (i=60;i>20;i--) used[i]=0;
|
||||
for (i = 60; i > 20; i--) {
|
||||
used[i]=0;
|
||||
}
|
||||
n=40; num=0;
|
||||
while (entry!=NULL && n>0) {
|
||||
i=0;
|
||||
@ -572,6 +575,7 @@ void InitSensor(SensorT *s) {
|
||||
s->present=0;
|
||||
s->curve[0]='\0';
|
||||
s->type[0]='\0';
|
||||
s->dispfld=0;
|
||||
}
|
||||
|
||||
int PrepInput(char *label) {
|
||||
@ -633,6 +637,11 @@ again:
|
||||
InitSensor(&sensC);
|
||||
InitSensor(&sensD);
|
||||
}
|
||||
|
||||
for (i=5;i<9;i++) {
|
||||
InitSensor(sensors[i]);
|
||||
}
|
||||
|
||||
empty=0;
|
||||
dev[0]='\0';
|
||||
str_copy(heUnits, "%");
|
||||
@ -681,10 +690,6 @@ again:
|
||||
s->typ='1'+i-5;
|
||||
}
|
||||
sensA.type[0]='\0';
|
||||
for (i=5+nScan; i<N_SENSORS; i++) {
|
||||
sensors[i]->t=DATA_UNDEF;
|
||||
sensors[i]->present=0;
|
||||
}
|
||||
}
|
||||
if (tLimit==0.0) {
|
||||
if (tMaxLimit==0.0) {
|
||||
@ -719,6 +724,14 @@ again:
|
||||
}
|
||||
}
|
||||
|
||||
for (i=5;i<9;i++) {
|
||||
s=sensors[i];
|
||||
if (s->type[0] != '\0') {
|
||||
s->present=-1;
|
||||
}
|
||||
s->typ=s->type[0];
|
||||
}
|
||||
|
||||
if (!plug->devcmd) { /* set device name */
|
||||
str_copy(plug->device, nam);
|
||||
ConcatDevice();
|
||||
@ -1000,7 +1013,8 @@ int ReadTemp(void) {
|
||||
char buf[256], typ, *err, dispfmt;
|
||||
int i, doit, stat;
|
||||
int tfill, dfill;
|
||||
static int iScan=0;
|
||||
static time_t lastRead=0;
|
||||
time_t now;
|
||||
float hlev;
|
||||
SensorT *s;
|
||||
|
||||
@ -1008,16 +1022,27 @@ int ReadTemp(void) {
|
||||
|
||||
doit=0;
|
||||
if (nScan>0) {
|
||||
while (1) { /* read until a non-selected channel found */
|
||||
if (iScan>=nScan) iScan=0;
|
||||
s=sensors[iScan+5];
|
||||
if (s->present<1) break;
|
||||
time(&now);
|
||||
if (lastRead == 0) {
|
||||
lastRead = now;
|
||||
} else if (now/30 != lastRead/30) {
|
||||
s=sensors[iScan+4];
|
||||
str_copy(chan, s->ch);
|
||||
ERR_P(LscCmd(ser, "KRDG?[chan]>fbuf;DIOST?>,out1"));
|
||||
if (out1==iScan) break;
|
||||
s->t=fbuf;
|
||||
iScan++;
|
||||
/* find next sensor s2 */
|
||||
for (i = iScan; i < iScan - 1 + nScan; i++) {
|
||||
sens = sensors[i % nScan + 5];
|
||||
if (sens->present >= 1) {
|
||||
iScan = i % nScan + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ibuf = iScan-1;
|
||||
ERR_P(LscCmd(ser, "KRDG?[chan]>fbuf;DOUT 3,[ibuf];XSCAN 1,[iScan];DISPFLD [sens.dispfld],[chan],1"));
|
||||
lastRead = now;
|
||||
s->t = fbuf;
|
||||
}
|
||||
} else {
|
||||
lastRead = 0;
|
||||
}
|
||||
for (i=0; i<4; i++) {
|
||||
s=sensors[i];
|
||||
@ -1727,7 +1752,7 @@ int Settings(void) {
|
||||
SensorT *s;
|
||||
SensorT *fields[8];
|
||||
char *cfg, *p;
|
||||
int i,k,l;
|
||||
int i,k,l,kk;
|
||||
|
||||
if (remoteMode!=2) {
|
||||
remoteMode=2; /* set to remote mode */
|
||||
@ -1746,9 +1771,11 @@ int Settings(void) {
|
||||
}
|
||||
if (s->present < 0) {
|
||||
if (settingsFlag) return 0;
|
||||
/*
|
||||
if (i==4) {
|
||||
ERR_P(LscCmd(ser, "DOUT:2;XSCAN:2,,2"));
|
||||
}
|
||||
*/
|
||||
ERR_I(InstalCurve(s, plug->device));
|
||||
}
|
||||
}
|
||||
@ -1797,9 +1824,13 @@ int Settings(void) {
|
||||
DisplayFmt(auxSens, fields, &k);
|
||||
if (nScan>0) {
|
||||
i=0;
|
||||
kk=k;
|
||||
while (i<nScan && DisplayFmt(sensors[i+5], fields, &k)) {
|
||||
if (k>4) k=kk;
|
||||
i++;
|
||||
}
|
||||
k = kk + nScan + 1;
|
||||
if (k > 4) k = 5;
|
||||
}
|
||||
maxfld=k-1;
|
||||
|
||||
@ -3336,6 +3367,7 @@ int main(int argc, char *argv[]) {
|
||||
CocIntFld(SensorT, readStat, RD);
|
||||
CocIntFld(SensorT, stat1, RD);
|
||||
CocIntFld(SensorT, stat2, RD);
|
||||
CocIntFld(SensorT, dispfld, RD);
|
||||
CocStrFld(SensorT, ch, RD);
|
||||
CocStrFld(SensorT, curve, RD);
|
||||
CocStrFld(SensorT, type, RD);
|
||||
@ -3444,6 +3476,7 @@ int main(int argc, char *argv[]) {
|
||||
CocDefInt(serialNo, RD);
|
||||
CocDefInt(quit, RW);
|
||||
CocDefInt(nScan, RD);
|
||||
CocDefInt(iScan, RW);
|
||||
CocDefInt(keepT, RW);
|
||||
CocDefInt(swRangeOn, RW);
|
||||
CocDefInt(doubleControl, RW);
|
||||
|
Reference in New Issue
Block a user