- extended evcontroller

- remote objects
- new ev drivers for oxford IPS,ITC,ILM and LC
M.Z.
This commit is contained in:
cvs
2004-11-17 11:32:05 +00:00
parent 2a93216346
commit aa9ab52528
26 changed files with 3772 additions and 879 deletions

View File

@@ -21,6 +21,7 @@
#endif
#define TABLE_FILE "tecs.cfg"
#define DEV_LIST "dev.list"
#define LSC_CODES "lsc.codes"
#define LOGLIFETIME 24*3600
@@ -168,8 +169,7 @@ static int
swRangeOn=0, /* switch heater range on when controller switched it off */
initMaxPower=0, /* set MaxPower for the first time */
lockAlarm,
cntError,
tableTime; /* last time when table was read */
cntError;
int tim, rdTim; /* actual time, read Time */
@@ -536,14 +536,12 @@ int InstalCurve(SensorT *sensor, char *devArg) {
return -1;
}
int ReadTable(void) {
int ReadTable(void) { /* obsolete */
char nbuf[256];
if (table!=NULL && tim>tableTime+60) { FREE(table); table=NULL; }; /* clear old table */
if (table!=NULL) return 0;
if (table!=NULL) { FREE(table); table=NULL; };
str_copy(nbuf, binDir);
str_append(nbuf, TABLE_FILE);
ERR_P(table=str_read_file(nbuf));
tableTime=tim;
return 1;
OnError: return -1;
}
@@ -574,11 +572,13 @@ int PrepInput(char *label) {
} else {
str_copy(nam, label);
}
again:
str_copy(buf, binDir);
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");
@@ -586,6 +586,14 @@ int PrepInput(char *label) {
if (e==NULL || e>strchr(t,'\n')) ERR_MSG("missing ' or device name in table file");
t=e+1;
}
if (cfg && *cfg=='@') { /* alias */
t=strchr(cfg,'\n');
if (t) *t='\0';
str_copy(nam, cfg+1);
str_copy(plug->device, nam);
FREE(cfg);
goto again;
}
if (plug==&plug0) {
InitSensor(&sensA);
InitSensor(&sensB);
@@ -694,8 +702,15 @@ int PrepInput(char *label) {
str_copy(plug->device, nam);
ConcatDevice();
}
if (cfg) {
FREE(cfg);
}
return 0;
OnError: return -1;
OnError:
if (cfg) {
FREE(cfg);
}
return -1;
}
int LoadCache(void) {
@@ -1708,12 +1723,17 @@ int ConfigByCode(int plugNr) {
}
p=fgets(buf, sizeof(buf), fil);
}
fclose(fil);
logfileOut(LOG_MAIN+LOG_STAT ,"configure plug%d for %s (code %d)\n", plugNr, nam, plug->code);
str_copy(buf, "'");
str_append(buf, nam);
str_append(buf, "'");
ERR_I(PrepInput(buf));
fclose(fil);
if (plug->code != c1 && plug->code != c2) {
logfileOut(LOG_MAIN+LOG_STAT ,"unknown code %d on plug%d\n", plug->code, plugNr);
return 0;
} else {
logfileOut(LOG_MAIN+LOG_STAT ,"configure plug%d for %s (code %d)\n", plugNr, nam, plug->code);
str_copy(buf, "'");
str_append(buf, nam);
str_append(buf, "'");
ERR_I(PrepInput(buf));
}
}
settingsFlag=1;
return 0;
@@ -2606,39 +2626,14 @@ EndStatus:
}
int DevHelpHdl(int mode, void *base, int fd) {
char *t, *n, *d, *en, *ed;
char line[80], nbuf[256];
int l, iret;
static int doit=1;
char nbuf[256];
char *list;
ERR_I(iret=ReadTable());
if (iret) doit=1;
if (doit) {
doit=0;
t=table;
str_copy(devHelp,"\n");
while (t!=NULL) {
t++;
n=strchr(t, '\'');
d=strstr(t, "dev=\"");
t=strchr(t, '\n');
if (n!=NULL && d!=NULL && n < d && d < t) {
en=strchr(n+1, '\'');
ed=strchr(d+5, '"');
if (en != NULL && en<d && ed != NULL && ed<t) {
l=en-n;
if (l>12) l=12;
str_ncpy(line, n+1, l);
str_npad(line, line, 12);
l=ed-d;
if (l>77) l=77;
str_ncpy(line+12, d+5, l);
str_append(line, "\n");
str_append(devHelp, line);
}
}
}
}
str_copy(nbuf, binDir);
str_append(nbuf, DEV_LIST);
ERR_P(list=str_read_file(nbuf));
str_copy(devHelp, list);
FREE(list);
return 0;
OnError: return -1;
}
@@ -2901,7 +2896,7 @@ int main(int argc, char *argv[]) {
CocDefInt(relay, RW); CocHdl(RelayHdl);
CocDefInt(manual, RW); CocHdl(ManualHdl);
CocDefInt(htrst, RD);
CocDefInt(loop, RD);
CocDefInt(loop, RW);
CocDefInt(rdTim, RD);
CocDefInt(tim0, RD);
CocDefInt(ibuf, RD);