# HG changeset patch # User Michiel Broek # Date 1442433905 -7200 # Node ID 00ca08f5a6f8d78baef408e585ec5f2ced1a437f # Parent 66d4e137b99db5100ad1bac51487b3bf3b580b5a Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2. diff -r 66d4e137b99d -r 00ca08f5a6f8 configure --- a/configure Tue Sep 15 17:29:15 2015 +0200 +++ b/configure Wed Sep 16 22:05:05 2015 +0200 @@ -2034,7 +2034,7 @@ PACKAGE="mbsePi-apps" -VERSION="0.4.1" +VERSION="0.4.2" COPYRIGHT="Copyright (C) 2014-2015 Michiel Broek, All Rights Reserved" CYEARS="2014-2015" diff -r 66d4e137b99d -r 00ca08f5a6f8 configure.ac --- a/configure.ac Tue Sep 15 17:29:15 2015 +0200 +++ b/configure.ac Wed Sep 16 22:05:05 2015 +0200 @@ -8,7 +8,7 @@ dnl General settings dnl After changeing the version number, run autoconf! PACKAGE="mbsePi-apps" -VERSION="0.4.1" +VERSION="0.4.2" COPYRIGHT="Copyright (C) 2014-2015 Michiel Broek, All Rights Reserved" CYEARS="2014-2015" AC_SUBST(PACKAGE) diff -r 66d4e137b99d -r 00ca08f5a6f8 thermferm/logger.c --- a/thermferm/logger.c Tue Sep 15 17:29:15 2015 +0200 +++ b/thermferm/logger.c Wed Sep 16 22:05:05 2015 +0200 @@ -30,7 +30,7 @@ { char buf[128], *filename; - snprintf(buf, 127, "Mode,Air,Beer,Target,S_Heater,S_Cooler,S_Fan,S_Door,U_Heater,U_Cooler,U_Fan,Room"); + snprintf(buf, 127, "Mode,Air,Beer,Target_L,S_Heater,S_Cooler,S_Fan,S_Door,U_Heater,U_Cooler,U_Fan,Room,Target_H"); filename = xstrcpy(unit); filename = xstrcat(filename, (char *)".log"); logger(filename, buf); diff -r 66d4e137b99d -r 00ca08f5a6f8 thermferm/rdconfig.c --- a/thermferm/rdconfig.c Tue Sep 15 17:29:15 2015 +0200 +++ b/thermferm/rdconfig.c Wed Sep 16 22:05:05 2015 +0200 @@ -640,7 +640,15 @@ syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); return 1; } - if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP", "%.1f", tmp4->inittemp)) < 0) { + if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP_LO", "%.1f", tmp4->inittemp_lo)) < 0) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } + if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP_HI", "%.1f", tmp4->inittemp_hi)) < 0) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } + if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_MODE", "%d", tmp4->fridge_mode)) < 0) { syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); return 1; } @@ -666,10 +674,18 @@ syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); return 1; } - if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET", "%.1f", tmp5->target)) < 0) { + if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET_LO", "%.1f", tmp5->target_lo)) < 0) { syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); return 1; } + if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET_HI", "%.1f", tmp5->target_hi)) < 0) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } + if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_MODE", "%d", tmp5->fridge_mode)) < 0) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } if ((rc = xmlTextWriterEndElement(writer)) < 0) { syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); return 1; @@ -1436,8 +1452,8 @@ step = (prof_step *)malloc(sizeof(prof_step)); step->next = NULL; step->version = 1; - step->steptime = step->resttime = 0; - step->target = 20.0; + step->steptime = step->resttime = step->fridge_mode = 0; + step->target_lo = step->target_hi = 20.0; cur = cur->xmlChildrenNode; while (cur != NULL) { @@ -1462,10 +1478,30 @@ step->steptime = ival; xmlFree(key); } - if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET"))) { + if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET"))) { /* Upgrade from single values */ + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + if (sscanf((const char *)key, "%f", &val) == 1) { + step->target_lo = val - 0.2; + step->target_hi = val + 0.2; + } + xmlFree(key); + } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET_LO"))) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); if (sscanf((const char *)key, "%f", &val) == 1) - step->target = val; + step->target_lo = val; + xmlFree(key); + } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET_HI"))) { + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + if (sscanf((const char *)key, "%f", &val) == 1) + step->target_hi = val; + xmlFree(key); + } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIDGE_MODE"))) { + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + if (sscanf((const char *)key, "%d", &ival) == 1) + step->fridge_mode = ival; xmlFree(key); } cur = cur->next; @@ -1511,8 +1547,8 @@ profile->next = NULL; profile->version = 1; profile->uuid = profile->name = NULL; - profile->busy = 0; - profile->inittemp = 20.0; + profile->busy = profile->fridge_mode = 0; + profile->inittemp_lo = profile->inittemp_hi = 20.0; profile->steps = NULL; cur = cur->xmlChildrenNode; @@ -1538,10 +1574,30 @@ profile->busy = ival; xmlFree(key); } - if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP"))) { + if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP"))) { /* Upgrade from single temp */ + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + if (sscanf((const char *)key, "%f", &fval) == 1) { + profile->inittemp_lo = fval - 0.2; + profile->inittemp_hi = fval + 0.2; + } + xmlFree(key); + } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP_LO"))) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); if (sscanf((const char *)key, "%f", &fval) == 1) - profile->inittemp = fval; + profile->inittemp_lo = fval; + xmlFree(key); + } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP_HI"))) { + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + if (sscanf((const char *)key, "%f", &fval) == 1) + profile->inittemp_hi = fval; + xmlFree(key); + } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIDGE_MODE"))) { + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + if (sscanf((const char *)key, "%d", &ival) == 1) + profile->fridge_mode = ival; xmlFree(key); } if ((!xmlStrcmp(cur->name, (const xmlChar *)"STEPS"))) { diff -r 66d4e137b99d -r 00ca08f5a6f8 thermferm/server.c --- a/thermferm/server.c Tue Sep 15 17:29:15 2015 +0200 +++ b/thermferm/server.c Wed Sep 16 22:05:05 2015 +0200 @@ -477,7 +477,7 @@ if ((fp = fopen(name, "r"))) { char buffer[256], outbuf[256], q[5], hr[3]; - char *date_n, *mode_n, *air_n, *beer_n, *target_n, *heater_n, *cooler_n, *room_n; + char *date_n, *mode_n, *air_n, *beer_n, *target_lo_n, *target_hi_n, *heater_n, *cooler_n, *room_n; char *heater_u, *cooler_u; int lines = 0, heater_l = 0, cooler_l = 0, h = 0, c = 0, heat_used = 0, cool_used = 0, graphstep = 0; float room_t = 0.0; @@ -504,21 +504,22 @@ while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { /* - * 2014-11-15 18:39,BEER,20.312,19.750,20.0,0,NA,NA,NA,78105,NA,NA,18.000 - * | | | | | | | | | | | | | - * date_n | | | | | | | | | | | | - * mode_n ----------+ | | | | | | | | | | | - * air_n -----------------+ | | | | | | | | | | - * beer_n -----------------------+ | | | | | | | | | - * target_n ---------------------------+ | | | | | | | | - * heater_n -------------------------------+ | | | | | | | - * cooler_n ---------------------------------+ | | | | | | - * not used ------------------------------------+ | | | | | - * not used ---------------------------------------+ | | | | - * heater_u --------------------------------------------+ | | | - * cooler_u ------------------------------------------------+ | | - * not used ---------------------------------------------------+ | - * room_n ----------------------------------------------------------+ + * 2014-11-15 18:39,BEER,20.312,19.750,20.0,0,NA,NA,NA,78105,NA,NA,18.000,20.1 + * | | | | | | | | | | | | | | + * date_n | | | | | | | | | | | | | + * mode_n ----------+ | | | | | | | | | | | | + * air_n -----------------+ | | | | | | | | | | | + * beer_n -----------------------+ | | | | | | | | | | + * target_lo_n ------------------------+ | | | | | | | | | + * heater_n -------------------------------+ | | | | | | | | + * cooler_n ---------------------------------+ | | | | | | | + * not used ------------------------------------+ | | | | | | + * not used ---------------------------------------+ | | | | | + * heater_u --------------------------------------------+ | | | | + * cooler_u ------------------------------------------------+ | | | + * not used ---------------------------------------------------+ | | + * room_n ----------------------------------------------------------+ | + * target_hi_n -----------------------------------------------------------+ */ hr[0] = q[0] = buffer[11]; hr[1] = q[1] = buffer[12]; @@ -526,19 +527,20 @@ q[3] = buffer[15]; hr[2] = '\0'; buffer[strlen(buffer) -1] = '\0'; - date_n = strtok(buffer, ",\0"); /* timestamp */ - mode_n = strtok(NULL, ",\0"); /* unit mode */ - air_n = strtok(NULL, ",\0"); /* air temp */ - beer_n = strtok(NULL, ",\0"); /* beer temp */ - target_n = strtok(NULL, ",\0"); /* target temp */ - heater_n = strtok(NULL, ",\0"); /* current heater state */ - cooler_n = strtok(NULL, ",\0"); /* current cooler state */ - heater_u = strtok(NULL, ",\0"); /* current fan state */ - heater_u = strtok(NULL, ",\0"); /* current door state */ - heater_u = strtok(NULL, ",\0"); /* heater use counter */ - cooler_u = strtok(NULL, ",\0"); /* cooler use counter */ - room_n = strtok(NULL, ",\0"); /* fan use counter */ - room_n = strtok(NULL, ",\0"); /* room temperature */ + date_n = strtok(buffer, ",\0"); /* timestamp */ + mode_n = strtok(NULL, ",\0"); /* unit mode */ + air_n = strtok(NULL, ",\0"); /* air temp */ + beer_n = strtok(NULL, ",\0"); /* beer temp */ + target_lo_n = strtok(NULL, ",\0"); /* target low temp */ + heater_n = strtok(NULL, ",\0"); /* current heater state */ + cooler_n = strtok(NULL, ",\0"); /* current cooler state */ + heater_u = strtok(NULL, ",\0"); /* current fan state */ + heater_u = strtok(NULL, ",\0"); /* current door state */ + heater_u = strtok(NULL, ",\0"); /* heater use counter */ + cooler_u = strtok(NULL, ",\0"); /* cooler use counter */ + room_n = strtok(NULL, ",\0"); /* fan use counter */ + room_n = strtok(NULL, ",\0"); /* room temperature */ + target_hi_n = strtok(NULL, ",\0"); /* target high temp */ if (strncmp(mode_n, (char *)"Mode", 4)) { /* @@ -566,8 +568,10 @@ } if (room_n) sscanf(room_n, "%f", &room_t); - snprintf(outbuf, 255, "%s,%s,%s,%s,%s,%s,%s,%d,%d,%.1f", - date_n, mode_n, air_n, beer_n, target_n, heater_n, cooler_n, heat_used, cool_used, room_t); + if (target_hi_n == NULL) + target_hi_n = target_lo_n; + snprintf(outbuf, 255, "%s,%s,%s,%s,%s,%s,%s,%d,%d,%.1f,%s", + date_n, mode_n, air_n, beer_n, target_lo_n, heater_n, cooler_n, heat_used, cool_used, room_t,target_hi_n); srv_send(outbuf); if (heater_u && h && strcmp(heater_u, "NA")) heater_l = h; @@ -1104,7 +1108,7 @@ int cmd_list(char *buf) { char *opt, *param, *filename, q[5], hr[3], buffer[256], outbuf[256]; - char *date_n, *mode_n, *air_n, *beer_n, *target_n, *heater_n, *cooler_n, *room_n; + char *date_n, *mode_n, *air_n, *beer_n, *target_lo_n, *target_hi_n, *heater_n, *cooler_n, *room_n; char *heater_u, *cooler_u; int heater_l = 0, cooler_l = 0, h = 0, c = 0, heat_used = 0, cool_used = 0, lines = 0, graphstep = 0; units_list *unit; @@ -1191,19 +1195,20 @@ q[3] = buffer[15]; hr[2] = '\0'; buffer[strlen(buffer) -1] = '\0'; - date_n = strtok(buffer, ",\0"); /* timestamp */ - mode_n = strtok(NULL, ",\0"); /* unit mode */ - air_n = strtok(NULL, ",\0"); /* air temp */ - beer_n = strtok(NULL, ",\0"); /* beer temp */ - target_n = strtok(NULL, ",\0"); /* target temp */ - heater_n = strtok(NULL, ",\0"); /* current heater state */ - cooler_n = strtok(NULL, ",\0"); /* current cooler state */ - heater_u = strtok(NULL, ",\0"); /* current fan state */ - heater_u = strtok(NULL, ",\0"); /* current door state */ - heater_u = strtok(NULL, ",\0"); /* heater use counter */ - cooler_u = strtok(NULL, ",\0"); /* cooler use counter */ - room_n = strtok(NULL, ",\0"); /* fan use counter */ - room_n = strtok(NULL, ",\0"); /* room temperature */ + date_n = strtok(buffer, ",\0"); /* timestamp */ + mode_n = strtok(NULL, ",\0"); /* unit mode */ + air_n = strtok(NULL, ",\0"); /* air temp */ + beer_n = strtok(NULL, ",\0"); /* beer temp */ + target_lo_n = strtok(NULL, ",\0"); /* target low temp */ + heater_n = strtok(NULL, ",\0"); /* current heater state */ + cooler_n = strtok(NULL, ",\0"); /* current cooler state */ + heater_u = strtok(NULL, ",\0"); /* current fan state */ + heater_u = strtok(NULL, ",\0"); /* current door state */ + heater_u = strtok(NULL, ",\0"); /* heater use counter */ + cooler_u = strtok(NULL, ",\0"); /* cooler use counter */ + room_n = strtok(NULL, ",\0"); /* fan use counter */ + room_n = strtok(NULL, ",\0"); /* room temperature */ + target_hi_n = strtok(NULL, ",\0"); /* target high temp */ if (strncmp(mode_n, (char *)"Mode", 4)) { /* @@ -1233,8 +1238,10 @@ sscanf(room_n, "%f", &room_t); else room_t = 0.0; - snprintf(outbuf, 255, "%s,%s,%s,%s,%s,%s,%s,%d,%d,%.1f", - date_n, mode_n, air_n, beer_n, target_n, heater_n, cooler_n, heat_used, cool_used, room_t); + if (target_hi_n == NULL) + target_hi_n = target_lo_n; + snprintf(outbuf, 255, "%s,%s,%s,%s,%s,%s,%s,%d,%d,%.1f,%s", + date_n, mode_n, air_n, beer_n, target_lo_n, heater_n, cooler_n, heat_used, cool_used, room_t, target_hi_n); srv_send(outbuf); if (h && strcmp(heater_u, "NA")) heater_l = h; @@ -1267,9 +1274,9 @@ */ int cmd_profile(char *buf) { - char ibuf[SS_BUFSIZE], *sstep, *rest, *targ, *param, *kwd, *val; - int j, rlen, istep, irest; - float ftarg, fval; + char ibuf[SS_BUFSIZE], *sstep, *rest, *tlarg, *tharg, *frarg, *param, *kwd, *val; + int j, ival, rlen, istep, irest, ifrarg; + float ftlarg, ftharg, fval; char *opt; profiles_list *profile, *tmpp; prof_step *step, *olds; @@ -1327,8 +1334,9 @@ uuid_generate(uu); uuid_unparse(uu, profile->uuid); profile->name = xstrcpy(param); - profile->busy = 0; - profile->inittemp = 20.0; + profile->busy = profile->fridge_mode = 0; + profile->inittemp_lo = 19.8; + profile->inittemp_hi = 20.2; profile->steps = NULL; if (Config.profiles == NULL) { Config.profiles = profile; @@ -1362,7 +1370,9 @@ srv_send((char *)"213 Profile record follows:"); srv_send((char *)"UUID,%s", profile->uuid); srv_send((char *)"NAME,%s", profile->name); - srv_send((char *)"INITTEMP,%.1f", profile->inittemp); + srv_send((char *)"INITTEMP_LO,%.1f", profile->inittemp_lo); + srv_send((char *)"INITTEMP_HI,%.1f", profile->inittemp_hi); + srv_send((char *)"FRIDGE_MODE,%d", profile->fridge_mode); srv_send((char *)"."); return 0; } @@ -1393,11 +1403,23 @@ free(profile->name); } profile->name = xstrcpy(val); - } else if (strcmp(kwd, (char *)"INITTEMP") == 0) { + } else if (strcmp(kwd, (char *)"INITTEMP_LO") == 0) { + if (sscanf(val, "%f", &fval) == 1) { + if (profile->inittemp_lo != fval) + syslog(LOG_NOTICE, "Profile %s initial temperature low %.1f to %.1f", profile->uuid, profile->inittemp_lo, fval); + profile->inittemp_lo = fval; + } + } else if (strcmp(kwd, (char *)"INITTEMP_HI") == 0) { if (sscanf(val, "%f", &fval) == 1) { - if (profile->inittemp != fval) - syslog(LOG_NOTICE, "Profile %s initial temperature %.1f to %.1f", profile->uuid, profile->inittemp, fval); - profile->inittemp = fval; + if (profile->inittemp_hi != fval) + syslog(LOG_NOTICE, "Profile %s initial temperature high %.1f to %.1f", profile->uuid, profile->inittemp_hi, fval); + profile->inittemp_hi = fval; + } + } else if (strcmp(kwd, (char *)"FRIDGE_MODE") == 0) { + if (sscanf(val, "%d", &ival) == 1) { + if (profile->fridge_mode != ival) + syslog(LOG_NOTICE, "Profile %s fridge mode %d to %d", profile->uuid, profile->fridge_mode, ival); + profile->fridge_mode = ival; } } } @@ -1414,7 +1436,7 @@ if (strcmp(profile->uuid, param) == 0) { srv_send((char *)"215 Profile steps follow:"); for (step = profile->steps; step; step = step->next) { - srv_send((char *)"%d,%d,%.1f", step->steptime, step->resttime, step->target); + srv_send((char *)"%d,%d,%.1f,%.1f,%d", step->steptime, step->resttime, step->target_lo, step->target_hi, step->fridge_mode); } srv_send((char *)"."); return 0; @@ -1452,21 +1474,27 @@ } sstep = strtok(ibuf, ",\0"); rest = strtok(NULL, ",\0"); - targ = strtok(NULL, "\0"); + tlarg = strtok(NULL, ",\0"); + tharg = strtok(NULL, ",\0"); + frarg = strtok(NULL, "\0"); if ((sscanf(sstep, "%d", &istep) == 1) && (sscanf(rest, "%d", &irest) == 1) && - (sscanf(targ, "%f", &ftarg) == 1)) { + (sscanf(tlarg, "%f", &ftlarg) == 1) && + (sscanf(tharg, "%f", &ftharg) == 1) && + (sscanf(frarg, "%d", &ifrarg) == 1)) { j++; - syslog(LOG_NOTICE, "PROFILE PUTS %s add step %d: steptime=%d resttime=%d target=%.1f", - profile->uuid, j, istep, irest, ftarg); + syslog(LOG_NOTICE, "PROFILE PUTS %s add step %d: steptime=%d resttime=%d target=%.1f..%.1f fridge_mode=%d", + profile->uuid, j, istep, irest, ftlarg, ftharg, ifrarg); step = (prof_step *)malloc(sizeof(prof_step)); step->next = NULL; step->version = 1; step->steptime = istep; step->resttime = irest; - step->target = ftarg; + step->target_lo = ftlarg; + step->target_hi = ftharg; + step->fridge_mode = ifrarg; if (profile->steps == NULL) { profile->steps = step; @@ -2102,7 +2130,9 @@ } else { srv_send((char *)"PROF_STATE,%s", PROFSTATE[unit->prof_state]); } - srv_send((char *)"PROF_TARGET,%.3f", unit->prof_target); + srv_send((char *)"PROF_TARGET_LO,%.3f", unit->prof_target_lo); + srv_send((char *)"PROF_TARGET_HI,%.3f", unit->prof_target_hi); + srv_send((char *)"PROF_FRIDGE_MODE,%.3f", unit->prof_fridge_mode); srv_send((char *)"PROF_PEAK_ABS,%.3f", unit->prof_peak_abs); srv_send((char *)"PROF_PEAK_REL,%.3f", unit->prof_peak_rel); srv_send((char *)"PROF_PRIMARY_DONE,%d", (int)unit->prof_primary_done); @@ -2346,7 +2376,8 @@ * Set a sane default until it will be overruled by the * main processing loop. */ - unit->prof_target = 20.0; + unit->prof_target_lo = unit->prof_target_hi = 20.0; + unit->prof_fridge_mode = 0; } break; } diff -r 66d4e137b99d -r 00ca08f5a6f8 thermferm/thermferm.c --- a/thermferm/thermferm.c Tue Sep 15 17:29:15 2015 +0200 +++ b/thermferm/thermferm.c Wed Sep 16 22:05:05 2015 +0200 @@ -811,7 +811,7 @@ int server(void) { - char buf[1024], *filename, target[40], heater[40], cooler[40], fan[40], door[40]; + char buf[1024], *filename, target_lo[40], target_hi[40], heater[40], cooler[40], fan[40], door[40]; char use_heater[40], use_cooler[40], use_fan[40], room_temp[40]; time_t now, last = (time_t)0; units_list *unit; @@ -826,7 +826,7 @@ long t = 0; #endif int current_step, valid_step, time_until_now; - float previous_target; + float previous_target_lo, previous_target_hi; if (lockprog((char *)"thermferm")) { @@ -1144,7 +1144,9 @@ switch (unit->prof_state) { case PROFILE_OFF: - unit->prof_target = profile->inittemp; + unit->prof_target_lo = profile->inittemp_lo; + unit->prof_target_hi = profile->inittemp_hi; + unit->prof_fridge_mode = 0; unit->prof_percent = 0; break; case PROFILE_PAUSE: @@ -1158,7 +1160,8 @@ * Calculate current profile step and desired temperature. * When all steps are done, set state to PROFILE_DONE. */ - previous_target = profile->inittemp; + previous_target_lo = profile->inittemp_lo; + previous_target_hi = profile->inittemp_hi; time_until_now = current_step = 0; run_seconds = (int)(now - unit->prof_started - unit->prof_paused); run_minutes = run_seconds / 60; @@ -1216,24 +1219,31 @@ * This is our current step */ valid_step = TRUE; + unit->prof_fridge_mode = step->fridge_mode; if (debug) - fprintf(stdout, "step=%d step_pos=%d step=%d/%d target=%.1f ", + fprintf(stdout, "step=%d step_pos=%d step=%d/%d target=%.1f..%.1f ", current_step, run_hours - time_until_now, - step->steptime, step->resttime, step->target); + step->steptime, step->resttime, step->target_lo, step->target_hi); if ((run_hours - time_until_now) < step->steptime) { - unit->prof_target = previous_target + (((run_minutes - (time_until_now * 60.0)) / (step->steptime * 60.0)) * (step->target - previous_target)); + unit->prof_target_lo = previous_target_lo + (((run_minutes - (time_until_now * 60.0)) / (step->steptime * 60.0)) * (step->target_lo - previous_target_lo)); + unit->prof_target_hi = previous_target_hi + (((run_minutes - (time_until_now * 60.0)) / (step->steptime * 60.0)) * (step->target_hi - previous_target_hi)); if (debug) - fprintf(stdout, "tempshift=%.1f minutes=%d duration=%d temp_move=%.3f ", - step->target - previous_target, run_minutes - (time_until_now * 60), - step->steptime * 60, unit->prof_target); + fprintf(stdout, "tempshift=%.1f..%.1f minutes=%d duration=%d temp_move=%.3f..%.3f ", + step->target_lo - previous_target_lo, + step->target_hi - previous_target_hi, + run_minutes - (time_until_now * 60), + step->steptime * 60, unit->prof_target_lo, unit->prof_target_hi); } else { - unit->prof_target = step->target; - fprintf(stdout, "resting target=%.1f ", step->target); + unit->prof_target_lo = step->target_lo; + unit->prof_target_hi = step->target_hi; + if (debug) + fprintf(stdout, "resting target=%.1f..%.1f ", step->target_lo, step->target_hi); } break; } time_until_now += step->steptime + step->resttime; - previous_target = step->target; + previous_target_lo = step->target_lo; + previous_target_hi = step->target_hi; } if (debug) fprintf(stdout, " %s %02d:%02d\n", valid_step ? "TRUE":"FALSE", minutes, seconds); @@ -1241,9 +1251,10 @@ if (valid_step == TRUE) { unit->prof_percent = (100 * run_minutes) / tot_minutes; if (((minutes == 10) || (minutes == 40)) && (seconds == 1)) { - syslog(LOG_NOTICE, "Profile `%s' running %dd %02d:%02d in step %d, %d%% done, target %.3f degrees", + syslog(LOG_NOTICE, "Profile `%s' running %dd %02d:%02d in step %d, %d%% done, target %s %.3f..%.3f degrees", profile->name, run_hours / 24, run_hours % 24, run_minutes % 60, current_step, - unit->prof_percent, unit->prof_target); + unit->prof_percent, unit->prof_fridge_mode ? (char *)"air":(char *)"beer", + unit->prof_target_lo, unit->prof_target_hi); } } else { /* @@ -1259,13 +1270,20 @@ /* * Keep this state, set target temperature to the last step. */ - previous_target = profile->inittemp; + previous_target_lo = profile->inittemp_lo; + previous_target_hi = profile->inittemp_hi; + unit->prof_fridge_mode = profile->fridge_mode; for (step = profile->steps; step; step = step->next) { if (step->steptime == 0) break; - previous_target = step->target; + previous_target_lo = step->target_lo; + previous_target_hi = step->target_hi; + unit->prof_fridge_mode = step->fridge_mode; + } - unit->prof_target = previous_target; + unit->prof_target_lo = previous_target_lo; + unit->prof_target_hi = previous_target_hi; + unit->prof_fridge_mode = step->fridge_mode; unit->prof_percent = 100; break; } /* switch */ @@ -1369,8 +1387,12 @@ unit->PID_cool->Input = unit->PID_heat->Input = unit->beer_temperature / 1000.0; unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_AUTO; } else if (unit->mode == UNITMODE_PROFILE) { - unit->PID_cool->SetP = unit->PID_heat->SetP = unit->prof_target; - unit->PID_cool->Input = unit->PID_heat->Input = unit->beer_temperature / 1000.0; + unit->PID_cool->SetP = unit->prof_target_hi; + unit->PID_heat->SetP = unit->prof_target_lo; + if (unit->prof_fridge_mode) + unit->PID_cool->Input = unit->PID_heat->Input = unit->air_temperature / 1000.0; + else + unit->PID_cool->Input = unit->PID_heat->Input = unit->beer_temperature / 1000.0; unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_AUTO; } @@ -1517,7 +1539,8 @@ for (unit = Config.units; unit; unit = unit->next) { if (unit->mode != UNITMODE_OFF) { - snprintf(target, 39, "NA"); + snprintf(target_lo, 39, "NA"); + snprintf(target_hi, 39, "NA"); snprintf(heater, 39, "NA"); snprintf(cooler, 39, "NA"); snprintf(fan, 39, "NA"); @@ -1527,12 +1550,16 @@ snprintf(use_fan, 39, "NA"); snprintf(room_temp, 39, "NA"); - if (unit->mode == UNITMODE_BEER) - snprintf(target, 39, "%.1f", unit->beer_set); - else if (unit->mode == UNITMODE_FRIDGE) - snprintf(target, 39, "%.1f", unit->fridge_set); - else if (unit->mode == UNITMODE_PROFILE) - snprintf(target, 39, "%.1f", unit->prof_target); + if (unit->mode == UNITMODE_BEER) { + snprintf(target_lo, 39, "%.1f", unit->beer_set); + snprintf(target_hi, 39, "%.1f", unit->beer_set); + } else if (unit->mode == UNITMODE_FRIDGE) { + snprintf(target_lo, 39, "%.1f", unit->fridge_set); + snprintf(target_hi, 39, "%.1f", unit->fridge_set); + } else if (unit->mode == UNITMODE_PROFILE) { + snprintf(target_lo, 39, "%.1f", unit->prof_target_lo); + snprintf(target_hi, 39, "%.1f", unit->prof_target_hi); + } if (unit->heater_address) { snprintf(heater, 39, "%d", unit->heater_state); @@ -1553,9 +1580,10 @@ snprintf(room_temp, 39, "%.3f", Config.temp_value / 1000.0); } - snprintf(buf, 1023, "%s,%.3f,%.3f,%s,%s,%s,%s,%s,%s,%s,%s,%s", + snprintf(buf, 1023, "%s,%.3f,%.3f,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", UNITMODE[unit->mode], unit->air_temperature / 1000.0, - unit->beer_temperature / 1000.0, target, heater, cooler, fan, door, use_heater, use_cooler, use_fan, room_temp); + unit->beer_temperature / 1000.0, + target_lo, heater, cooler, fan, door, use_heater, use_cooler, use_fan, room_temp, target_hi); filename = xstrcpy(unit->name); filename = xstrcat(filename, (char *)".log"); logger(filename, buf); diff -r 66d4e137b99d -r 00ca08f5a6f8 thermferm/thermferm.h --- a/thermferm/thermferm.h Tue Sep 15 17:29:15 2015 +0200 +++ b/thermferm/thermferm.h Wed Sep 16 22:05:05 2015 +0200 @@ -164,12 +164,14 @@ char *profile; /* Active profile uuid */ time_t prof_started; /* Profile start time */ int prof_state; /* Profile OFF|PAUSE|RUN|DONE */ - float prof_target; /* Profile current target temp */ + float prof_target_lo; /* Profile current target low */ + float prof_target_hi; /* Profile current target high */ time_t prof_paused; /* Profile total pause time */ int prof_percent; /* Profile percentage done */ float prof_peak_abs; /* Profile absolute peak temp */ float prof_peak_rel; /* Profile relative peak temp */ time_t prof_primary_done; /* Profile primary is done */ + int prof_fridge_mode; /* Profile fridge/beer mode */ pid_var *PID_cool; /* PID cooler */ pid_var *PID_heat; /* PID heater */ } units_list; @@ -189,7 +191,9 @@ int version; /* Version 1 */ int steptime; /* Step time to target in hours */ int resttime; /* Rest time on target in hours */ - float target; /* Target temperature */ + float target_lo; /* Low Target temperature */ + float target_hi; /* High target temperature */ + int fridge_mode; /* Fridge or beer mode */ } prof_step; /* @@ -201,7 +205,9 @@ char *uuid; /* Profile uuid */ char *name; /* Profile name */ int busy; /* Profile busy == 1, free == 0 */ - float inittemp; /* Temp target before start */ + float inittemp_lo; /* Low target before start */ + float inittemp_hi; /* High target before start */ + int fridge_mode; /* Fridge or beer mode */ prof_step *steps; /* Profile steps */ } profiles_list; diff -r 66d4e137b99d -r 00ca08f5a6f8 www-thermferm/archives.php --- a/www-thermferm/archives.php Tue Sep 15 17:29:15 2015 +0200 +++ b/www-thermferm/archives.php Wed Sep 16 22:05:05 2015 +0200 @@ -113,7 +113,8 @@ $outstr .= ' { name: "Mode" },'.PHP_EOL; $outstr .= ' { name: "Air", type: "float" },'.PHP_EOL; $outstr .= ' { name: "Beer", type: "float" },'.PHP_EOL; - $outstr .= ' { name: "Target", type: "float" },'.PHP_EOL; + $outstr .= ' { name: "Target_lo", type: "float" },'.PHP_EOL; + $outstr .= ' { name: "Target_hi", type: "float" },'.PHP_EOL; $outstr .= ' { name: "Heater", type: "int" },'.PHP_EOL; $outstr .= ' { name: "Cooler", type: "int" },'.PHP_EOL; $outstr .= ' { name: "HeatUse", type: "int" },'.PHP_EOL; @@ -180,7 +181,8 @@ $outstr .= ' series: ['.PHP_EOL; $outstr .= ' { dataField: "Air", lineWidth: 1, displayText: "Air" },'.PHP_EOL; $outstr .= ' { dataField: "Beer", lineWidth: 2, displayText: "Beer" },'.PHP_EOL; - $outstr .= ' { dataField: "Target", lineWidth: 1, displayText: "Target", opacity: 0.7 },'.PHP_EOL; + $outstr .= ' { dataField: "Target_lo", lineWidth: 1, displayText: "Target Lo", opacity: 0.7 },'.PHP_EOL; + $outstr .= ' { dataField: "Target_hi", lineWidth: 1, displayText: "Target Hi", opacity: 0.7 },'.PHP_EOL; $outstr .= ' { dataField: "Room", lineWidth: 1, displayText: "Room", opacity: 0.5 }'.PHP_EOL; $outstr .= ' ]'.PHP_EOL; $outstr .= ' }]'.PHP_EOL; @@ -309,6 +311,11 @@ $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; $outstr .= build_footer(); echo $outstr; } diff -r 66d4e137b99d -r 00ca08f5a6f8 www-thermferm/css/style.css --- a/www-thermferm/css/style.css Tue Sep 15 17:29:15 2015 +0200 +++ b/www-thermferm/css/style.css Wed Sep 16 22:05:05 2015 +0200 @@ -315,6 +315,18 @@ color: blue; } +.ltemp { + font-weight: bold; + font-size: 1.2em; + color: green; +} + +.htemp { + font-weight: bold; + font-size: 1.2em; + color: red; +} + #fermentor_toggle1 { width: 79px; height: 70px; diff -r 66d4e137b99d -r 00ca08f5a6f8 www-thermferm/devices.php --- a/www-thermferm/devices.php Tue Sep 15 17:29:15 2015 +0200 +++ b/www-thermferm/devices.php Wed Sep 16 22:05:05 2015 +0200 @@ -443,6 +443,11 @@ $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; $outstr .= build_footer(); echo $outstr; } @@ -548,6 +553,11 @@ $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; $outstr .= build_footer(); echo $outstr; diff -r 66d4e137b99d -r 00ca08f5a6f8 www-thermferm/getalog.php --- a/www-thermferm/getalog.php Tue Sep 15 17:29:15 2015 +0200 +++ b/www-thermferm/getalog.php Wed Sep 16 22:05:05 2015 +0200 @@ -41,8 +41,8 @@ $f = explode(",", $arr[$j]); $heater = $f[5] / 100; $cooler = $f[6] / 100; - $row .= '{"Date":"'.$f[0].'","Mode":"'.$f[1].'","Air":"'.$f[2].'","Beer":"'.$f[3].'","Target":"'.$f[4].'",'; - $row .= '"Heater":'.$heater.',"Cooler":'.$cooler.',"HeatUse":'.$f[7].',"CoolUse":"'.$f[8].'","Room":"'.$f[9].'"}'; + $row .= '{"Date":"'.$f[0].'","Mode":"'.$f[1].'","Air":"'.$f[2].'","Beer":"'.$f[3].'","Target_lo":"'.$f[4].'",'; + $row .= '"Heater":'.$heater.',"Cooler":'.$cooler.',"HeatUse":'.$f[7].',"CoolUse":"'.$f[8].'","Room":"'.$f[9].'","Target_hi":"'.$f[10].'"}'; $j++; } } diff -r 66d4e137b99d -r 00ca08f5a6f8 www-thermferm/getlog.php --- a/www-thermferm/getlog.php Tue Sep 15 17:29:15 2015 +0200 +++ b/www-thermferm/getlog.php Wed Sep 16 22:05:05 2015 +0200 @@ -1,6 +1,6 @@ * @@ -28,7 +28,6 @@ $arr = explode("\r\n", $answer); -//$data[] = array('Date','Mode','Air','Beer','Target','Heater','Cooler','Fan','Door'); $row = '['; /* We don't use json_encode because it doesn't work for our purpose */ @@ -42,8 +41,8 @@ $f = explode(",", $arr[$j]); $heater = $f[5] / 100; $cooler = $f[6] / 100; - $row .= '{"Date":"'.$f[0].'","Mode":"'.$f[1].'","Air":"'.$f[2].'","Beer":"'.$f[3].'","Target":"'.$f[4].'",'; - $row .= '"Heater":'.$heater.',"Cooler":'.$cooler.',"HeatUse":'.$f[7].',"CoolUse":"'.$f[8].'","Room":"'.$f[9].'"}'; + $row .= '{"Date":"'.$f[0].'","Mode":"'.$f[1].'","Air":"'.$f[2].'","Beer":"'.$f[3].'","Target_lo":"'.$f[4].'",'; + $row .= '"Heater":'.$heater.',"Cooler":'.$cooler.',"HeatUse":'.$f[7].',"CoolUse":"'.$f[8].'","Room":"'.$f[9].'","Target_hi":"'.$f[10].'"}'; $j++; } } diff -r 66d4e137b99d -r 00ca08f5a6f8 www-thermferm/getstate.php --- a/www-thermferm/getstate.php Tue Sep 15 17:29:15 2015 +0200 +++ b/www-thermferm/getstate.php Wed Sep 16 22:05:05 2015 +0200 @@ -35,7 +35,8 @@ $air_state = "NA"; $beer_temperature = "NA"; $beer_state = "NA"; -$target_temperature = "NA"; +$target_temperature_lo = "NA"; +$target_temperature_hi = "NA"; $led1 = $led2 = $led3 = $sw1 = $sw2 = $sw3 = ""; $fridge_set = "NA"; $beer_set = "NA"; @@ -87,11 +88,13 @@ if (($f[0] == "DOOR_ADDRESS") && (strcmp($f[1], "(null)"))) $door = "yes"; if (($f[0] == "BEER_SET") && ($mode == "BEER")) - $target_temperature = $f[1]; + $target_temperature_lo = $target_temperature_hi = $f[1]; if (($f[0] == "FRIDGE_SET") && ($mode == "FRIDGE")) - $target_temperature = $f[1]; - if (($f[0] == "PROF_TARGET") && ($mode == "PROFILE")) - $target_temperature = $f[1]; + $target_temperature_lo = $target_temperature_hi = $f[1]; + if (($f[0] == "PROF_TARGET_LO") && ($mode == "PROFILE")) + $target_temperature_lo = $f[1]; + if (($f[0] == "PROF_TARGET_HI") && ($mode == "PROFILE")) + $target_temperature_hi = $f[1]; if (($f[0] == "PROF_STATE") && ($mode == "PROFILE")) $prof_state = 'State: '.$f[1]; $j++; @@ -139,17 +142,18 @@ $reply = array ( - 'air_temperature' => $air_temperature, - 'beer_temperature' => $beer_temperature, - 'target_temperature' => $target_temperature, - 'mode' => $modestr, - 'led1' => $led1, - 'led2' => $led2, - 'led3' => $led3, - 'sw1' => $sw1, - 'sw2' => $sw2, - 'sw3' => $sw3, - 'profile_state' => $prof_state + 'air_temperature' => $air_temperature, + 'beer_temperature' => $beer_temperature, + 'target_temperature_lo' => $target_temperature_lo, + 'target_temperature_hi' => $target_temperature_hi, + 'mode' => $modestr, + 'led1' => $led1, + 'led2' => $led2, + 'led3' => $led3, + 'sw1' => $sw1, + 'sw2' => $sw2, + 'sw3' => $sw3, + 'profile_state' => $prof_state ); diff -r 66d4e137b99d -r 00ca08f5a6f8 www-thermferm/global.php --- a/www-thermferm/global.php Tue Sep 15 17:29:15 2015 +0200 +++ b/www-thermferm/global.php Wed Sep 16 22:05:05 2015 +0200 @@ -227,6 +227,11 @@ $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; $outstr .= build_footer(); echo $outstr; diff -r 66d4e137b99d -r 00ca08f5a6f8 www-thermferm/liveview.php --- a/www-thermferm/liveview.php Tue Sep 15 17:29:15 2015 +0200 +++ b/www-thermferm/liveview.php Wed Sep 16 22:05:05 2015 +0200 @@ -37,7 +37,8 @@ if (startsWith($arr[0], "213")) { - $set_temperature = "NA"; + $set_temperature_lo = "NA"; + $set_temperature_hi = "NA"; $air_temperature = "NA"; $beer_temperature = "NA"; $profile = ""; @@ -90,13 +91,16 @@ $prof_state = $vals[1]; } if (($vals[0] == "BEER_SET") && ($mode == "BEER")) { - $set_temperature = $vals[1]; + $set_temperature_lo = $set_temperature_hi = $vals[1]; } if (($vals[0] == "FRIDGE_SET") && ($mode == "FRIDGE")) { - $set_temperature = $vals[1]; + $set_temperature_lo = $set_temperature_hi = $vals[1]; } - if (($vals[0] == "PROF_TARGET") && ($mode == "PROFILE")) { - $set_temperature = $vals[1]; + if (($vals[0] == "PROF_TARGET_LO") && ($mode == "PROFILE")) { + $set_temperature_lo = $vals[1]; + } + if (($vals[0] == "PROF_TARGET_HI") && ($mode == "PROFILE")) { + $set_temperature_hi = $vals[1]; } } @@ -114,7 +118,8 @@ $outstr .= ' { name: "Mode" },'.PHP_EOL; $outstr .= ' { name: "Air", type: "float" },'.PHP_EOL; $outstr .= ' { name: "Beer", type: "float" },'.PHP_EOL; - $outstr .= ' { name: "Target", type: "float" },'.PHP_EOL; + $outstr .= ' { name: "Target_lo", type: "float" },'.PHP_EOL; + $outstr .= ' { name: "Target_hi", type: "float" },'.PHP_EOL; $outstr .= ' { name: "Heater", type: "int" },'.PHP_EOL; $outstr .= ' { name: "Cooler", type: "int" },'.PHP_EOL; $outstr .= ' { name: "HeatUse", type: "int" },'.PHP_EOL; @@ -181,7 +186,8 @@ $outstr .= ' series: ['.PHP_EOL; $outstr .= ' { dataField: "Air", lineWidth: 1, displayText: "Air" },'.PHP_EOL; $outstr .= ' { dataField: "Beer", lineWidth: 2, displayText: "Beer" },'.PHP_EOL; - $outstr .= ' { dataField: "Target", lineWidth: 1, displayText: "Target", opacity: 0.7 },'.PHP_EOL; + $outstr .= ' { dataField: "Target_lo", lineWidth: 1, displayText: "Target Lo", opacity: 0.7 },'.PHP_EOL; + $outstr .= ' { dataField: "Target_hi", lineWidth: 1, displayText: "Target Hi", opacity: 0.7 },'.PHP_EOL; $outstr .= ' { dataField: "Room", lineWidth: 1, displayText: "Room", opacity: 0.5 }'.PHP_EOL; $outstr .= ' ]'.PHP_EOL; $outstr .= ' }]'.PHP_EOL; @@ -226,7 +232,8 @@ $outstr .= ' $.getJSON("getstate.php?uuid='.$unit.'", function(data) {'.PHP_EOL; $outstr .= ' $("#load_air_'.$unr.'").html(data.air_temperature);'.PHP_EOL; $outstr .= ' $("#load_beer_'.$unr.'").html(data.beer_temperature);'.PHP_EOL; - $outstr .= ' $("#load_target_'.$unr.'").html(data.target_temperature);'.PHP_EOL; + $outstr .= ' $("#load_target_lo_'.$unr.'").html(data.target_temperature_lo);'.PHP_EOL; + $outstr .= ' $("#load_target_hi_'.$unr.'").html(data.target_temperature_hi);'.PHP_EOL; $outstr .= ' $("#load_select_'.$unr.'").html(data.mode);'.PHP_EOL; $outstr .= ' $("#load_led1_'.$unr.'").html(data.led1);'.PHP_EOL; $outstr .= ' $("#load_led2_'.$unr.'").html(data.led2);'.PHP_EOL; @@ -270,14 +277,14 @@ $outstr .= '
'.PHP_EOL; if ($mode == "FRIDGE") { $outstr .= '
'.PHP_EOL; - $outstr .= '
'.PHP_EOL; + $outstr .= '
'.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= '
'.PHP_EOL; } if ($mode == "BEER") { $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= '
'.PHP_EOL; @@ -354,7 +361,8 @@ $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; - $outstr .= '
'.$set_temperature.'
Set'.PHP_EOL; + $outstr .= '
'.$set_temperature_hi.'
'.PHP_EOL; + $outstr .= '
'.$set_temperature_lo.'
'.PHP_EOL; $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; $outstr .= '
'.$air_temperature.'
Air'.PHP_EOL; diff -r 66d4e137b99d -r 00ca08f5a6f8 www-thermferm/maintenance.php --- a/www-thermferm/maintenance.php Tue Sep 15 17:29:15 2015 +0200 +++ b/www-thermferm/maintenance.php Wed Sep 16 22:05:05 2015 +0200 @@ -1,6 +1,6 @@ * @@ -50,6 +50,12 @@ $outstr .= ' '.PHP_EOL; $outstr .= ' ThermFerm - Maintenance Menu'.PHP_EOL; $outstr .= ' '.PHP_EOL; +$outstr .= ' '.PHP_EOL; +$outstr .= ' '.PHP_EOL; +$outstr .= ' '.PHP_EOL; +$outstr .= ' '.PHP_EOL; +$outstr .= ' '.PHP_EOL; +$outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= '
'.PHP_EOL; @@ -58,7 +64,7 @@ $outstr .= ' ThermFerm '.$version.PHP_EOL; $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; -$outstr .= ' '.PHP_EOL; +$outstr .= ' '.PHP_EOL; $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; @@ -94,6 +100,11 @@ } $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; +$outstr .= ' '.PHP_EOL; $outstr .= build_footer(); echo $outstr; diff -r 66d4e137b99d -r 00ca08f5a6f8 www-thermferm/profiles.php --- a/www-thermferm/profiles.php Tue Sep 15 17:29:15 2015 +0200 +++ b/www-thermferm/profiles.php Wed Sep 16 22:05:05 2015 +0200 @@ -22,6 +22,8 @@ *****************************************************************************/ require_once('utilities.php'); +$my_style = 'ui-redmond'; + /* * Each time this page is loaded, get the profiles from the server. @@ -68,14 +70,14 @@ * $steps contains all steps of a profile */ $steps = array ( - 1 => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ), - 2 => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ), - 3 => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ), - 4 => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ), - 5 => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ), - 6 => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ), - 7 => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ), - 8 => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ), + 1 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), + 2 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), + 3 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), + 4 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), + 5 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), + 6 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), + 7 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), + 8 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), ); $answer = send_cmd("PROFILE GETS ".$UUID); @@ -89,7 +91,9 @@ $f = explode(",", $psteps[$j]); $steps[$j]["steptime"] = $f[0]; $steps[$j]["resttime"] = $f[1]; - $steps[$j]["target"] = $f[2]; + $steps[$j]["target_lo"] = $f[2]; + $steps[$j]["target_hi"] = $f[3]; + $steps[$j]["fridge_mode"] = $f[4]; $j++; } } @@ -111,7 +115,9 @@ $outstr .= ' Step'.PHP_EOL; $outstr .= ' Steptime'.PHP_EOL; $outstr .= ' Resttime'.PHP_EOL; - $outstr .= ' Temperature'.PHP_EOL; + $outstr .= ' Temp low'.PHP_EOL; + $outstr .= ' Temp high'.PHP_EOL; + $outstr .= ' Fridge mode'.PHP_EOL; $outstr .= ' '.PHP_EOL; for ($i = 1; $i <= 8; $i++) { @@ -119,7 +125,12 @@ $outstr .= ' Step '.$i.''.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; - $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; + $outstr .= ' 30)) - return 3; + if (($_POST['target_lo'.$i] < -5) || ($_POST['target_lo'.$i] > 30)) + return 3; + if (($_POST['target_hi'.$i] < -5) || ($_POST['target_hi'.$i] > 30)) + return 3; + if ($_POST['target_lo'.$i] > $_POST['target_hi'.$i]) + return 3; } } else { return 1; @@ -260,11 +288,13 @@ case 0: $cmd = array("PROFILE PUTS ".$_POST['UUID']); for ($i = 1; $i <= 8; $i++) { if (($_POST['steptime'.$i] > 0) || ($_POST['resttime'.$i] > 0)) { - $cmd[] = $_POST['steptime'.$i].','.$_POST['resttime'.$i].','.$_POST['target'.$i]; + $cmd[] = $_POST['steptime'.$i].','.$_POST['resttime'.$i].','.$_POST['target_lo'.$i].','.$_POST['target_hi'.$i].','.$_POST['fridge_mode'.$i]; } unset($_POST['steptime'.$i]); unset($_POST['resttime'.$i]); - unset($_POST['target'.$i]); + unset($_POST['target_lo'.$i]); + unset($_POST['target_hi'.$i]); + unset($_POST['fridge_mode'.$i]); } $cmd[] = "."; send_array($cmd); @@ -285,14 +315,14 @@ } $steps = array ( - 1 => array("steptime" => $_POST['steptime1'], "resttime" => $_POST['resttime1'], "target" => $_POST['target1'] ), - 2 => array("steptime" => $_POST['steptime2'], "resttime" => $_POST['resttime2'], "target" => $_POST['target2'] ), - 3 => array("steptime" => $_POST['steptime3'], "resttime" => $_POST['resttime3'], "target" => $_POST['target3'] ), - 4 => array("steptime" => $_POST['steptime4'], "resttime" => $_POST['resttime4'], "target" => $_POST['target4'] ), - 5 => array("steptime" => $_POST['steptime5'], "resttime" => $_POST['resttime5'], "target" => $_POST['target5'] ), - 6 => array("steptime" => $_POST['steptime6'], "resttime" => $_POST['resttime6'], "target" => $_POST['target6'] ), - 7 => array("steptime" => $_POST['steptime7'], "resttime" => $_POST['resttime7'], "target" => $_POST['target7'] ), - 8 => array("steptime" => $_POST['steptime8'], "resttime" => $_POST['resttime8'], "target" => $_POST['target8'] ), + 1 => array("steptime" => $_POST['steptime1'], "resttime" => $_POST['resttime1'], "target_lo" => $_POST['target_lo1'], "target_hi" => $_POST['target_hi1'], "fridge_mode" => $_POST['mode_fridge1'] ), + 2 => array("steptime" => $_POST['steptime2'], "resttime" => $_POST['resttime2'], "target_lo" => $_POST['target_lo2'], "target_hi" => $_POST['target_hi2'], "fridge_mode" => $_POST['mode_fridge2'] ), + 3 => array("steptime" => $_POST['steptime3'], "resttime" => $_POST['resttime3'], "target_lo" => $_POST['target_lo3'], "target_hi" => $_POST['target_hi3'], "fridge_mode" => $_POST['mode_fridge3'] ), + 4 => array("steptime" => $_POST['steptime4'], "resttime" => $_POST['resttime4'], "target_lo" => $_POST['target_lo4'], "target_hi" => $_POST['target_hi4'], "fridge_mode" => $_POST['mode_fridge4'] ), + 5 => array("steptime" => $_POST['steptime5'], "resttime" => $_POST['resttime5'], "target_lo" => $_POST['target_lo5'], "target_hi" => $_POST['target_hi5'], "fridge_mode" => $_POST['mode_fridge5'] ), + 6 => array("steptime" => $_POST['steptime6'], "resttime" => $_POST['resttime6'], "target_lo" => $_POST['target_lo6'], "target_hi" => $_POST['target_hi6'], "fridge_mode" => $_POST['mode_fridge6'] ), + 7 => array("steptime" => $_POST['steptime7'], "resttime" => $_POST['resttime7'], "target_lo" => $_POST['target_lo7'], "target_hi" => $_POST['target_hi7'], "fridge_mode" => $_POST['mode_fridge7'] ), + 8 => array("steptime" => $_POST['steptime8'], "resttime" => $_POST['resttime8'], "target_lo" => $_POST['target_lo8'], "target_hi" => $_POST['target_hi8'], "fridge_mode" => $_POST['mode_fridge8'] ), ); edit_steps($_POST['UUID'], $steps, $error, "ThermFerm - Edit Profile Steps"); @@ -305,7 +335,9 @@ * * @param string $_POST['UUID'] Unique record UUID * @param string $_POST['Name'] Profile name - * @param float $_POST['Inittemp'] Profile initial temperature + * @param float $_POST['Inittemp_lo'] Profile initial temperature + * @param float $_POST['Inittemp_hi'] Profile initial temperature + * @param float $_POST['Fridge_mode'] Profile fridge mode * @param string $_POST['key'] Key choice, Save or Cancel * @param string $_POST['command'] Command used, 'add' or 'update' * @@ -319,7 +351,7 @@ global $arr; - if (isset($_POST['UUID']) && isset($_POST['Name']) && isset($_POST['Inittemp']) && isset($_POST['key']) && isset($_POST['command'])) { + if (isset($_POST['UUID']) && isset($_POST['Name']) && isset($_POST['Inittemp_lo']) && isset($_POST['Inittemp_hi']) && isset($_POST['key']) && isset($_POST['command'])) { if ($_POST['key'] == 'Cancel') return 99; @@ -426,12 +458,28 @@ $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; } - if ($f[0] == "INITTEMP") { + if ($f[0] == "INITTEMP_LO") { $outstr .= ' '.PHP_EOL; - $outstr .= ' Initial temperature'.PHP_EOL; - $outstr .= ' '.PHP_EOL; + $outstr .= ' Initial temperature low'.PHP_EOL; + $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; } + if ($f[0] == "INITTEMP_HI") { + $outstr .= ' '.PHP_EOL; + $outstr .= ' Initial temperature high'.PHP_EOL; + $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; + } + if ($f[0] == "FRIDGE_MODE") { + $outstr .= ' '.PHP_EOL; + $outstr .= ' Fridge mode'.PHP_EOL; + $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= '
'.PHP_EOL; @@ -168,7 +178,7 @@ $outstr .= ' ThermFerm '.$version.PHP_EOL; $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; - $outstr .= ' '.PHP_EOL; + $outstr .= ' '.PHP_EOL; $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL;