thermferm/server.c

changeset 578
d694abd9d809
parent 575
86496d2bc4bb
child 582
ba340e00aab2
equal deleted inserted replaced
577:7a29f835e20a 578:d694abd9d809
1695 unit->profile_duration = unit->profile_totalsteps = 0; 1695 unit->profile_duration = unit->profile_totalsteps = 0;
1696 unit->profile_steps = NULL; 1696 unit->profile_steps = NULL;
1697 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; 1697 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
1698 unit->air_state = unit->beer_state = unit->chiller_state = 1; 1698 unit->air_state = unit->beer_state = unit->chiller_state = 1;
1699 unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = 20000; 1699 unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = 20000;
1700 unit->beer_set = unit->fridge_set = unit->profile_inittemp_lo = unit->profile_inittemp_hi =20.0; 1700 unit->beer_set_lo = unit->beer_set_hi = unit->fridge_set_lo = unit->fridge_set_hi = unit->profile_inittemp_lo = unit->profile_inittemp_hi =20.0;
1701 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = \ 1701 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = \
1702 unit->light_state = unit->psu_state = unit->prof_state = unit->stage = 0; 1702 unit->light_state = unit->psu_state = unit->prof_state = unit->stage = 0;
1703 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ 1703 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */
1704 unit->light_delay = 1; /* 15 seconds delay */ 1704 unit->light_delay = 1; /* 15 seconds delay */
1705 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; 1705 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
1829 srv_send((char *)"DOOR_STATE,%d", unit->door_state); 1829 srv_send((char *)"DOOR_STATE,%d", unit->door_state);
1830 srv_send((char *)"DOOR_IDX,%d", unit->door_idx); 1830 srv_send((char *)"DOOR_IDX,%d", unit->door_idx);
1831 srv_send((char *)"PSU_ADDRESS,%s", unit->psu_address); 1831 srv_send((char *)"PSU_ADDRESS,%s", unit->psu_address);
1832 srv_send((char *)"PSU_STATE,%d", unit->psu_state); 1832 srv_send((char *)"PSU_STATE,%d", unit->psu_state);
1833 srv_send((char *)"PSU_IDX,%d", unit->psu_idx); 1833 srv_send((char *)"PSU_IDX,%d", unit->psu_idx);
1834 srv_send((char *)"FRIDGE_SET,%.1f", unit->fridge_set); 1834 srv_send((char *)"FRIDGE_SET_LO,%.1f", unit->fridge_set_lo);
1835 srv_send((char *)"BEER_SET,%.1f", unit->beer_set); 1835 srv_send((char *)"FRIDGE_SET_HI,%.1f", unit->fridge_set_hi);
1836 srv_send((char *)"BEER_SET_LO,%.1f", unit->beer_set_lo);
1837 srv_send((char *)"BEER_SET_HI,%.1f", unit->beer_set_hi);
1836 if (unit->profile_uuid) { 1838 if (unit->profile_uuid) {
1837 srv_send((char *)"PROFILE_UUID,%s", unit->profile_uuid); 1839 srv_send((char *)"PROFILE_UUID,%s", unit->profile_uuid);
1838 srv_send((char *)"PROFILE_NAME,%s", unit->profile_name); 1840 srv_send((char *)"PROFILE_NAME,%s", unit->profile_name);
1839 srv_send((char *)"PROFILE_INITTEMP_LO,%.1f", unit->profile_inittemp_lo); 1841 srv_send((char *)"PROFILE_INITTEMP_LO,%.1f", unit->profile_inittemp_lo);
1840 srv_send((char *)"PROFILE_INITTEMP_HI,%.1f", unit->profile_inittemp_hi); 1842 srv_send((char *)"PROFILE_INITTEMP_HI,%.1f", unit->profile_inittemp_hi);
2222 } 2224 }
2223 break; 2225 break;
2224 } 2226 }
2225 } 2227 }
2226 2228
2227 } else if (val && (strcmp(kwd, (char *)"FRIDGE_SET") == 0)) { 2229 } else if (val && (strcmp(kwd, (char *)"FRIDGE_SET_LO") == 0)) {
2228 if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) { 2230 if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) {
2229 if (unit->fridge_set != fval) 2231 if (unit->fridge_set_lo != fval)
2230 syslog(LOG_NOTICE, "Fermenter unit %s fridge temperature %.1f to %.1f", unit->uuid, unit->fridge_set, fval); 2232 syslog(LOG_NOTICE, "Fermenter unit %s fridge temp low %.1f to %.1f", unit->uuid, unit->fridge_set_lo, fval);
2231 unit->fridge_set = fval; 2233 unit->fridge_set_lo = fval;
2232 unit->mqtt_flag |= MQTT_FLAG_DATA; 2234 unit->mqtt_flag |= MQTT_FLAG_DATA;
2233 } 2235 }
2234 2236
2235 } else if (val && (strcmp(kwd, (char *)"BEER_SET") == 0)) { 2237 } else if (val && (strcmp(kwd, (char *)"FRIDGE_SET_HI") == 0)) {
2236 if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) { 2238 if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) {
2237 if (unit->beer_set != fval) 2239 if (unit->fridge_set_hi != fval)
2238 syslog(LOG_NOTICE, "Fermenter unit %s beer temperature %.1f to %.1f", unit->uuid, unit->beer_set, fval); 2240 syslog(LOG_NOTICE, "Fermenter unit %s fridge temp high %.1f to %.1f", unit->uuid, unit->fridge_set_hi, fval);
2239 unit->beer_set = fval; 2241 unit->fridge_set_hi = fval;
2242 unit->mqtt_flag |= MQTT_FLAG_DATA;
2243 }
2244
2245 } else if (val && (strcmp(kwd, (char *)"BEER_SET_LO") == 0)) {
2246 if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) {
2247 if (unit->beer_set_lo != fval)
2248 syslog(LOG_NOTICE, "Fermenter unit %s beer temp low %.1f to %.1f", unit->uuid, unit->beer_set_lo, fval);
2249 unit->beer_set_lo = fval;
2250 unit->mqtt_flag |= MQTT_FLAG_DATA;
2251 }
2252
2253 } else if (val && (strcmp(kwd, (char *)"BEER_SET_HI") == 0)) {
2254 if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) {
2255 if (unit->beer_set_hi != fval)
2256 syslog(LOG_NOTICE, "Fermenter unit %s beer temp high %.1f to %.1f", unit->uuid, unit->beer_set_hi, fval);
2257 unit->beer_set_hi = fval;
2240 unit->mqtt_flag |= MQTT_FLAG_DATA; 2258 unit->mqtt_flag |= MQTT_FLAG_DATA;
2241 } 2259 }
2242 2260
2243 } else if (val && (strcmp(kwd, (char *)"PIDC_IMAX") == 0)) { 2261 } else if (val && (strcmp(kwd, (char *)"PIDC_IMAX") == 0)) {
2244 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { 2262 if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {

mercurial