- improvements and bug fixes

This commit is contained in:
zolliker
2010-04-13 14:32:18 +00:00
parent 410166572b
commit 9e4eabeed1
6 changed files with 144 additions and 71 deletions

View File

@@ -374,6 +374,12 @@ $(CFGDIR)x55606.crv: ccrv inp/x55606.inp
$(CFGDIR)x55918.crv: ccrv inp/x55918.inp
$Q -p$(CFGDIR)
$(CFGDIR)x58599.crv: ccrv inp/x58599.inp
$Q -p$(CFGDIR)
$(CFGDIR)x58600.crv: ccrv inp/x58600.inp
$Q -p$(CFGDIR)
$(CFGDIR)z030114.crv: ccrv inp/z030114.inp
$Q -p$(CFGDIR)
@@ -503,6 +509,8 @@ all_crv: dev.list \
$(CFGDIR)x51079.crv \
$(CFGDIR)x55606.crv \
$(CFGDIR)x55918.crv \
$(CFGDIR)x58599.crv \
$(CFGDIR)x58600.crv \
$(CFGDIR)z030114.crv \
ALLINP= \
@@ -631,5 +639,7 @@ inp/x50991.inp \
inp/x51079.inp \
inp/x55606.inp \
inp/x55918.inp \
inp/x58599.inp \
inp/x58600.inp \
inp/z030114.inp \

View File

@@ -111,8 +111,9 @@ static Plug
static float
set, /* set T */
setH, /* set T on heat exchanger */
set2, /* set T of seconds loop in two loop mode */
set2, /* set T of second loop in two loop mode */
htr, power=DATA_UNDEF, /* heater current percentage, heater power */
power2=DATA_UNDEF, /* heater2 power */
tLimit, /* temperature limit */
tMaxLimit, /* maximal temperature limit */
maxPowerFlt, /* max. Power */
@@ -220,7 +221,6 @@ static char
static char
*alarmList[N_SENSORS], /* enabled alarms */
*table=NULL, /* environment devices table */
*cache=NULL, /* curve list cache */
*logfile="<none>";
@@ -560,16 +560,6 @@ int InstalCurve(SensorT *sensor, char *devArg) {
return -1;
}
int ReadTable(void) { /* obsolete */
char nbuf[256];
if (table!=NULL) { FREE(table); table=NULL; };
str_copy(nbuf, binDir);
str_append(nbuf, TABLE_FILE);
ERR_P(table=str_read_file(nbuf));
return 1;
OnError: return -1;
}
void InitSensor(SensorT *s) {
s->t=DATA_UNDEF;
s->scale=1;
@@ -584,10 +574,10 @@ void InitSensor(SensorT *s) {
}
int PrepInput(char *label) {
char *t, *e;
char nam[16], chans[8], typ;
char *t;
char nam[16], typ;
char buf[256];
int i, j, l;
int i, j;
SensorT *s;
char *cfg;
@@ -602,14 +592,9 @@ again:
str_append(buf, nam);
str_append(buf, ".cfg");
cfg=str_read_file(buf);
if (cfg==NULL) { /* will be obsolete */
logfileOut(LOG_MAIN, "%s not found, try tecs.cfg\n", buf);
ERR_I(ReadTable());
t=strstr(table, label);
if (t==NULL) ERR_MSG("device not found");
e=strchr(t, '\'');
if (e==NULL || e>strchr(t,'\n')) ERR_MSG("missing ' or device name in table file");
t=e+1;
if (cfg==NULL) {
logfileOut(LOG_MAIN, "%s not found\n", buf);
ERR_MSG("device not found");
}
if (cfg && *cfg=='@') { /* alias */
t=strchr(cfg,'\n');
@@ -641,35 +626,30 @@ again:
resist=10;
nScan=0;
unit=1;
empty=0;
full = -1;
} else {
InitSensor(&sensC);
InitSensor(&sensD);
if (strcasecmp(nam, "none") == 0) {
/* exception: he sensor is not cleared when stick is none */
if (full < 0 || sensB.type[0]=='\0' || sensD.type[0] != 'h') {
InitSensor(&sensD);
}
} else {
empty = 0;
full = -1;
InitSensor(&sensD);
}
}
for (i=5;i<9;i++) {
InitSensor(sensors[i]);
}
empty=0;
dev[0]='\0';
str_copy(heUnits, "%");
if (cfg==NULL) { /* will be obsolete */
i=sscanf(t, "%12s%n", nam, &l);
if (i<1) ERR_MSG("missing device name");
nam[strlen(nam)-1]='\0'; /* strip off quote */
t+=l;
str_copy(chans, "____");
i=sscanf(t, "%8s%n", chans, &l);
if (i<1) ERR_MSG("missing chans");
t+=l;
/* interprete settings until '+' appeares (after whitespace) */
ERR_P(CocReadVars(t, '+'));
if (strlen(chans)>4) ERR_MSG("no more than 4 channels allowed");
} else {
ERR_P(CocReadVars(cfg, '\0'));
}
ERR_P(CocReadVars(cfg, '\0'));
if (loop!=2) loop=1;
if (plug==&plug0) {
@@ -678,16 +658,6 @@ again:
j=2;
}
str_copy(plug->descr, dev);
if (cfg==NULL) { /* will be obsolete */
sensA.type[0]=chans[0];
sensA.type[1]='\0';
sensB.type[0]=chans[1];
sensB.type[1]='\0';
sensC.type[0]=chans[2];
sensC.type[1]='\0';
sensD.type[0]=chans[3];
sensD.type[1]='\0';
}
if (sensA.type[0]>'0' && sensA.type[0]<='4') {
nScan=sensA.type[0]-'0';
for (i=5;i<5+nScan;i++) {
@@ -713,6 +683,7 @@ again:
}
maxPowerFlt=25;
sscanf(maxPower, "%f", &maxPowerFlt);
for (i=j; i<j+2; i++) {
s=sensors[i];
typ=s->type[0];
@@ -1257,13 +1228,19 @@ int ReadHeater(int full) {
static int cntOff=3;
time_t now;
power2 = DATA_UNDEF;
if (loop==1) {
if (full) {
if (relay) {
ERR_P(LscCmd(ser, "HTRST?>htrst"));
htr=0;
} else {
ERR_P(LscCmd(ser, "HTR?>htr;HTRST?>htrst;RELAYST?1>relay;RANGE?>ibuf"));
if (twoloops) {
ERR_P(LscCmd(ser, "HTR?>htr;HTRST?>htrst;RELAYST?1>relay;RANGE?>ibuf;AOUT?2>fbuf"));
power2 = fbuf*fbuf*1e-5;
} else {
ERR_P(LscCmd(ser, "HTR?>htr;HTRST?>htrst;RELAYST?1>relay;RANGE?>ibuf"));
}
if (jRange!=0 && ibuf==0) {
if (swRangeOn) {
time(&now);
@@ -1404,7 +1381,7 @@ int SetTemp(int switchOn) {
}
}
ERR_P(LscCmd(ser, "SETP?[loop]>fbuf"));
if (fabsf(setH-fbuf) >= (fbuf+setH)*1.0e-5) {
if (fabsf(setH-fbuf) >= (fbuf+setH)*1.0e-5 || twoloops) {
ERR_P(LscCmd(ser, "SETP [loop]:[setH]"));
if (twoloops) {
ERR_P(LscCmd(ser, "SETP 2:[set2]"));
@@ -1989,12 +1966,8 @@ int ConfigByName(int plugNr) {
logfileOut(LOG_MAIN+LOG_STAT ,"configure plug%d for %s\n", plugNr, plug->device);
plug->sensor1->present=0;
plug->sensor2->present=0;
if (0!=strcmp(plug->device, "none")) {
sprintf(buf, "'%s'", plug->device);
ERR_I(PrepInput(buf));
} else {
plug->descr[0]='\0';
}
sprintf(buf, "'%s'", plug->device);
ERR_I(PrepInput(buf));
settingsFlag=1;
return 0;
OnError:
@@ -3439,6 +3412,7 @@ int main(int argc, char *argv[]) {
CocDefFlt(ramp, RW); CocHdl(SetHdl);
CocDefFlt(still, RW); CocHdl(StillHdl);
CocDefFlt(power, RW); CocHdl(PowerHdl);
CocDefFlt(power2, RD);
CocDefFlt(mout, RW); CocHdl(MoutHdl);
CocDefFlt(tLimit, RW); CocHdl(TLimitHdl);
CocDefFlt(tMaxLimit, RD);
@@ -3682,6 +3656,7 @@ int main(int argc, char *argv[]) {
ERR_P(DataCreateSet(NULL, "T4", &sensA4.t, logPeriod, LOGLIFETIME, tim));
ERR_P(DataCreateSet(NULL, "Aux", &aux, logPeriod, LOGLIFETIME, tim));
ERR_P(DataCreateSet(NULL, "P", &power, logPeriod, LOGLIFETIME, tim));
ERR_P(DataCreateSet(NULL, "power2", &power2, logPeriod, LOGLIFETIME, tim));
ERR_P(DataCreateSet(NULL, "ScanChan", &scanChan, logPeriod, LOGLIFETIME, tim));
DataUndef(0);
ERR_P(DataCreateSet(NULL, "Set", &set, logPeriod, LOGLIFETIME, tim));