- bug fix in coc_server.c
- bug fixes in tecs - new system to determine host:port in six and tecs_client
This commit is contained in:
136
tecs/tecs.c
136
tecs/tecs.c
@@ -1928,63 +1928,59 @@ int PeriodicTask(void) {
|
||||
|
||||
ERR_I(ReadHeater(1));
|
||||
|
||||
if (relay || loop !=1) {
|
||||
if (alarmListSize!=0) {
|
||||
buf[0]='\0';
|
||||
if (alarmListSize!=0) {
|
||||
buf[0]='\0';
|
||||
for (k=0;k<alarmListSize;k++) {
|
||||
str_append(buf,";ALARMST?");
|
||||
str_append(buf, alarmList[k]);
|
||||
}
|
||||
ERR_P(alms=LscCmd(ser, buf+1)); /* send without leading semicolon */
|
||||
if (0!=strcmp(alarmStatus, alms)) {
|
||||
str_copy(alarmStatus, alms);
|
||||
alarmChannels[0]='\0';
|
||||
for (k=0;k<alarmListSize;k++) {
|
||||
str_append(buf,";ALARMST?");
|
||||
str_append(buf, alarmList[k]);
|
||||
}
|
||||
ERR_P(alms=LscCmd(ser, buf+1)); /* send without leading semicolon */
|
||||
if (0!=strcmp(alarmStatus, alms)) {
|
||||
str_copy(alarmStatus, alms);
|
||||
alarmChannels[0]='\0';
|
||||
for (k=0;k<alarmListSize;k++) {
|
||||
if (alms[k*4] != '0' || alms[k*4+2] != '0') {
|
||||
str_append(alarmChannels, alarmList[k]);
|
||||
str_append(alarmChannels, " ");
|
||||
if (NULL==strstr(alarmHistory, alarmList[k])) { /* if not yet in history */
|
||||
str_append(alarmHistory, alarmList[k]); /* add to history */
|
||||
}
|
||||
if (alms[k*4] != '0') {
|
||||
str_append(alarmChannels, alarmList[k]);
|
||||
str_append(alarmChannels, " ");
|
||||
if (NULL==strstr(alarmHistory, alarmList[k])) { /* if not yet in history */
|
||||
str_append(alarmHistory, alarmList[k]); /* add to history */
|
||||
}
|
||||
}
|
||||
if (alarmChannels[0]=='\0') {
|
||||
if (lockAlarm) {
|
||||
logfileOut(LOG_MAIN, "No more active alarms, latching alarms: %s!\n", alarmHistory);
|
||||
} else {
|
||||
alarmHistory[0]='\0';
|
||||
alarmChannels[0]='\0';
|
||||
logfileOut(LOG_MAIN, "No more active alarms\n");
|
||||
ERR_P(LscCmd(ser, "ALMRST"));
|
||||
relay=0;
|
||||
}
|
||||
}
|
||||
if (alarmChannels[0]=='\0') {
|
||||
if (lockAlarm) {
|
||||
logfileOut(LOG_MAIN, "No more active alarms, latching alarms: %s!\n", alarmHistory);
|
||||
} else {
|
||||
logfileOut(LOG_MAIN, "Alarm on channel %s\n", alarmChannels);
|
||||
if (!relay0 && set!=0) {
|
||||
lockAlarm=1;
|
||||
logfileOut(LOG_MAIN, "Switch off heater\n");
|
||||
jRange=0;
|
||||
if (loop==1) { /* turn on high relay manually, switch off heater and reset alarms */
|
||||
ERR_P(LscCmd(ser, "RELAY 1:2,1;RANGE:0;ALMRST"));
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "RELAY 1:2,1;ANALOG 2:0,0;ALMRST"));
|
||||
relay=1;
|
||||
}
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "ALMRST"));
|
||||
}
|
||||
alarmHistory[0]='\0';
|
||||
alarmChannels[0]='\0';
|
||||
logfileOut(LOG_MAIN, "No more active alarms\n");
|
||||
ERR_P(LscCmd(ser, "ALMRST"));
|
||||
relay=0;
|
||||
}
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "ALMRST"));
|
||||
logfileOut(LOG_MAIN, "Alarm on channel %s\n", alarmChannels);
|
||||
if (!relay0 && set!=0) {
|
||||
lockAlarm=1;
|
||||
logfileOut(LOG_MAIN, "Switch off heater\n");
|
||||
jRange=0;
|
||||
if (loop==1) { /* turn on high relay manually, switch off heater and reset alarms */
|
||||
ERR_P(LscCmd(ser, "RELAY 1:2,1;RANGE:0;ALMRST"));
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "RELAY 1:2,1;ANALOG 2:0,0;ALMRST"));
|
||||
relay=1;
|
||||
}
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "ALMRST"));
|
||||
}
|
||||
}
|
||||
} else if (loop == 1) {
|
||||
if (!relay0) logfileOut(LOG_MAIN, "Relay is on!\n");
|
||||
alarmStatus[0]='\0';
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "ALMRST"));
|
||||
}
|
||||
} else if (loop == 1) {
|
||||
alarmChannels[0]='\0';
|
||||
if (!relay0) logfileOut(LOG_MAIN, "Relay is on!\n");
|
||||
alarmStatus[0]='\0';
|
||||
}
|
||||
|
||||
relay0=relay;
|
||||
|
||||
ERR_I(ReadTemp());
|
||||
@@ -2331,17 +2327,35 @@ int SetPower(float setpower) {
|
||||
OnError: return -1;
|
||||
}
|
||||
|
||||
int AlarmReset(void) {
|
||||
if (relay) {
|
||||
ERR_P(LscCmd(ser, "RELAY 1:2,1"));
|
||||
if (alarmHistory[0]=='\0') {
|
||||
str_copy(alarmHistory, "X");
|
||||
}
|
||||
} else {
|
||||
alarmHistory[0]='\0';
|
||||
alarmStatus[0]='\0';
|
||||
ERR_P(LscCmd(ser, "ALMRST;RELAY 1:1"));
|
||||
logfileOut(LOG_MAIN, "reset alarms\n");
|
||||
relay0=0;
|
||||
lockAlarm=0;
|
||||
}
|
||||
OnError: return -1;
|
||||
}
|
||||
|
||||
int SetHdl(int mode, void *base, int fd) {
|
||||
if (mode==COC_WR) {
|
||||
if (remoteMode!=2) {
|
||||
ERR_MSG("controller is in local mode, enter 'remote' first");
|
||||
} else if (relay && set!=0) {
|
||||
}
|
||||
if (relay && set!=0) {
|
||||
if (alarmChannels[0]!='\0') {
|
||||
ERR_MSG("alarm is active, set prohibited");
|
||||
} else {
|
||||
ERR_MSG("alarm was active, enter 'reset' first");
|
||||
}
|
||||
} else if (set<0) {
|
||||
} else if (set<=0) {
|
||||
set=0;
|
||||
} else if (set>tLimit) {
|
||||
set=0;
|
||||
@@ -2743,20 +2757,8 @@ int RelayHdl(int mode, void *base, int fd) {
|
||||
if (alarmChannels[0]!='\0') ERR_MSG("alarm is still active");
|
||||
return COC_DWR;
|
||||
} else if (mode==COC_DWR) {
|
||||
if (relay) {
|
||||
ERR_P(LscCmd(ser, "RELAY 1:2,1"));
|
||||
if (alarmHistory[0]=='\0') {
|
||||
str_copy(alarmHistory, "X");
|
||||
}
|
||||
} else {
|
||||
alarmHistory[0]='\0';
|
||||
alarmStatus[0]='\0';
|
||||
ERR_P(LscCmd(ser, "ALMRST;RELAY 1:1"));
|
||||
logfileOut(LOG_MAIN, "reset alarms\n");
|
||||
relay0=0;
|
||||
lockAlarm=0;
|
||||
set=0;
|
||||
}
|
||||
ERR_I(AlarmReset());
|
||||
set = 0;
|
||||
}
|
||||
return 0;
|
||||
OnError: return -1;
|
||||
@@ -3079,10 +3081,7 @@ int main(int argc, char *argv[]) {
|
||||
str_append(buf, "/");
|
||||
ERR_I(str_append(buf, logDir));
|
||||
}
|
||||
ERR_I(str_append(buf, serverId));
|
||||
if (strcmp(serverId, "tecs") != 0) {
|
||||
ERR_I(str_append(buf, "/tecs"));
|
||||
}
|
||||
ERR_I(str_append(buf, "tecs"));
|
||||
logfile=logfileInit(buf, logIt, use_stdout, logIt && use_stdout);
|
||||
|
||||
if (loggerDir[0] != '\0') {
|
||||
@@ -3093,11 +3092,6 @@ int main(int argc, char *argv[]) {
|
||||
str_append(buf, "/");
|
||||
ERR_I(str_append(buf, loggerDir));
|
||||
}
|
||||
if (strcmp(serverId, "tecs") != 0) {
|
||||
ERR_I(str_append(buf, serverId));
|
||||
mkdir(buf, S_IRWXU+S_IRGRP+S_IXGRP+S_IROTH+S_IXOTH);
|
||||
/* do not check return value */
|
||||
}
|
||||
str_copy(loggerDir, buf);
|
||||
LoggerSetDir(loggerDir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user