thermferm/server.c

changeset 195
b34a1b2421fb
parent 194
9eaaba49450f
child 206
78fb6f99e473
equal deleted inserted replaced
194:9eaaba49450f 195:b34a1b2421fb
1114 for (i = 0; i < 5; i++) { 1114 for (i = 0; i < 5; i++) {
1115 if (strcmp(val, UNITMODE[i]) == 0) { 1115 if (strcmp(val, UNITMODE[i]) == 0) {
1116 /* Initialize log if the unit is turned on */ 1116 /* Initialize log if the unit is turned on */
1117 if ((unit->mode == UNITMODE_OFF) && (i != UNITMODE_OFF)) 1117 if ((unit->mode == UNITMODE_OFF) && (i != UNITMODE_OFF))
1118 initlog(unit->name); 1118 initlog(unit->name);
1119 syslog(LOG_NOTICE, "Mode from %s to %s via web interface", UNITMODE[unit->mode], UNITMODE[i]);
1119 unit->mode = i; 1120 unit->mode = i;
1120 /* Allways turn everything off after a mode change */ 1121 /* Allways turn everything off after a mode change */
1122 unit->PID_I_err = unit->PID_err_old = 0.0;
1121 unit->heater_state = unit->cooler_state = unit->fan_state = 0; 1123 unit->heater_state = unit->cooler_state = unit->fan_state = 0;
1122 device_out(unit->heater_address, unit->heater_state); 1124 device_out(unit->heater_address, unit->heater_state);
1123 device_out(unit->cooler_address, unit->cooler_state); 1125 device_out(unit->cooler_address, unit->cooler_state);
1124 device_out(unit->fan_address, unit->fan_state); 1126 device_out(unit->fan_address, unit->fan_state);
1125 break; 1127 break;
1143 free(unit->profile); 1145 free(unit->profile);
1144 if (val) 1146 if (val)
1145 unit->profile = xstrcpy(val); 1147 unit->profile = xstrcpy(val);
1146 else 1148 else
1147 unit->profile = NULL; 1149 unit->profile = NULL;
1150 /*
1151 * Reset all output devices
1152 */
1153 unit->PID_I_err = unit->PID_err_old = 0.0;
1154 unit->heater_state = unit->cooler_state = unit->fan_state = 0;
1155 device_out(unit->heater_address, unit->heater_state);
1156 device_out(unit->cooler_address, unit->cooler_state);
1157 device_out(unit->fan_address, unit->fan_state);
1148 } 1158 }
1149 1159
1150 } else if (val && (strcmp(kwd, (char *)"PROF_STATE") == 0)) { 1160 } else if (val && (strcmp(kwd, (char *)"PROF_STATE") == 0)) {
1151 for (i = 0; i < 4; i++) { 1161 for (i = 0; i < 4; i++) {
1152 if (strcmp(val, PROFSTATE[i]) == 0) { 1162 if (strcmp(val, PROFSTATE[i]) == 0) {

mercurial