- small improvements

This commit is contained in:
zolliker
2008-05-14 14:24:16 +00:00
parent d109dd026a
commit 51150961b7

View File

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