# HG changeset patch # User Michiel Broek # Date 1531649116 -7200 # Node ID e833bbd5e733338c3ef218b9908d453ce5dee422 # Parent 3c4c6d5e4b8d2ae5d07b48b2f09d79d548288a64 Versie 0.6.5. LIST LOG commando verwijderd, alleen ARCHIVE LOG is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek. diff -r 3c4c6d5e4b8d -r e833bbd5e733 configure --- a/configure Sat Jul 14 21:36:08 2018 +0200 +++ b/configure Sun Jul 15 12:05:16 2018 +0200 @@ -2035,7 +2035,7 @@ PACKAGE="mbsePi-apps" -VERSION="0.6.4" +VERSION="0.6.5" COPYRIGHT="Copyright (C) 2014-2018 Michiel Broek, All Rights Reserved" CYEARS="2014-2018" diff -r 3c4c6d5e4b8d -r e833bbd5e733 configure.ac --- a/configure.ac Sat Jul 14 21:36:08 2018 +0200 +++ b/configure.ac Sun Jul 15 12:05:16 2018 +0200 @@ -8,7 +8,7 @@ dnl General settings dnl After changeing the version number, run autoconf! PACKAGE="mbsePi-apps" -VERSION="0.6.4" +VERSION="0.6.5" COPYRIGHT="Copyright (C) 2014-2018 Michiel Broek, All Rights Reserved" CYEARS="2014-2018" AC_SUBST(PACKAGE) diff -r 3c4c6d5e4b8d -r e833bbd5e733 thermferm/logger.c --- a/thermferm/logger.c Sat Jul 14 21:36:08 2018 +0200 +++ b/thermferm/logger.c Sun Jul 15 12:05:16 2018 +0200 @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (C) 2014-2015 + * Copyright (C) 2014-2018 * * Michiel Broek * @@ -30,7 +30,7 @@ { char buf[128], *filename; - 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"); + 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,Chiller"); filename = xstrcpy(unit); filename = xstrcat(filename, (char *)".log"); logger(filename, buf); diff -r 3c4c6d5e4b8d -r e833bbd5e733 thermferm/server.c --- a/thermferm/server.c Sat Jul 14 21:36:08 2018 +0200 +++ b/thermferm/server.c Sun Jul 15 12:05:16 2018 +0200 @@ -478,7 +478,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_lo_n, *target_hi_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, *chiller_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; @@ -505,22 +505,23 @@ 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,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 -----------------------------------------------------------+ + * 2014-11-15 18:39,BEER,20.312,19.750,20.0,0,NA,NA,NA,78105,NA,NA,18.000,20.1,5.312 + * | | | | | | | | | | | | | | | + * 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 -----------------------------------------------------------+ | + * chiller_n ------------------------------------------------------------------+ */ hr[0] = q[0] = buffer[11]; hr[1] = q[1] = buffer[12]; @@ -542,6 +543,7 @@ room_n = strtok(NULL, ",\0"); /* fan use counter */ room_n = strtok(NULL, ",\0"); /* room temperature */ target_hi_n = strtok(NULL, ",\0"); /* target high temp */ + chiller_n = strtok(NULL, ",\0"); /* chiller temp */ if (strncmp(mode_n, (char *)"Mode", 4)) { /* @@ -571,8 +573,8 @@ sscanf(room_n, "%f", &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); + snprintf(outbuf, 255, "%s,%s,%s,%s,%s,%s,%s,%d,%d,%.1f,%s,%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, chiller_n); srv_send(outbuf); if (heater_u && h && strcmp(heater_u, "NA")) heater_l = h; @@ -1167,13 +1169,14 @@ */ 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_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; + char *opt; +// char *param, *filename, q[5], hr[3], buffer[256], outbuf[256]; +// char *date_n, *mode_n, *air_n, *beer_n, *target_lo_n, *target_hi_n, *heater_n, *cooler_n, *room_n, *chiller_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; - FILE *fp; - float room_t; +// FILE *fp; +// float room_t; opt = strtok(buf, " \0"); opt = strtok(NULL, " \0"); @@ -1193,10 +1196,10 @@ srv_send((char *)"100 Help text follows:"); srv_send((char *)"Recognized commands:"); srv_send((char *)"LIST List available units"); - srv_send((char *)"LIST LOG uuid List logfile of unit by uuid"); +// srv_send((char *)"LIST LOG uuid List logfile of unit by uuid"); srv_send((char *)"."); return 0; - +/* } else if (strcmp(opt, (char *)"LOG") == 0) { param = strtok(NULL, "\0"); @@ -1221,22 +1224,22 @@ filename = xstrcat(filename, unit->name); filename = xstrcat(filename, (char *)".log"); if ((fp = fopen(filename, "r"))) { - +*/ /* * Count the lines in the logfile */ - lines = 0; +/* lines = 0; while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { lines++; } fseek(fp, 0L, SEEK_SET); - /* +*/ /* * We have counted the lines in the logfile including the header lines. * The header lines should be ignored but there are so few of them, we * just include them in the total. * Now find a reasonable interval of lines to sent to the client. */ - for (graphstep = 1; graphstep <= MAX_INTERVALS; graphstep++) { +/* for (graphstep = 1; graphstep <= MAX_INTERVALS; graphstep++) { if (lines < GRAPH_DATALINES[graphstep]) { break; } @@ -1246,75 +1249,77 @@ syslog(LOG_NOTICE, "LIST LOG %s: lines=%d, interval=%d, graphstep=%d", unit->name, lines, GRAPH_INTERVAL[graphstep], graphstep); 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 */ - hr[0] = q[0] = buffer[11]; - hr[1] = q[1] = buffer[12]; - q[2] = buffer[14]; - 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_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 */ +// hr[0] = q[0] = buffer[11]; +// hr[1] = q[1] = buffer[12]; +// q[2] = buffer[14]; +// 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_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 */ +// chiller_n = strtok(NULL, ",\0"); /* chiller temp */ - if (strncmp(mode_n, (char *)"Mode", 4)) { +// if (strncmp(mode_n, (char *)"Mode", 4)) { /* * Output a line at the right intervals */ - int hour = atoi(hr); - if (((graphstep == 1)) || - ((graphstep == 2) && (q[3] == '0' || q[3] == '5')) || - ((graphstep == 3) && ((q[2] == '0' && q[3] == '0') || (q[2] == '1' && q[3] == '5') || (q[2] == '3' && q[3] == '0') || (q[2] == '4' && q[3] == '5'))) || - ((graphstep == 4) && ((q[2] == '0' && q[3] == '0') || (q[2] == '3' && q[3] == '0'))) || - ((graphstep == 5) && (q[2] == '0' && q[3] == '0')) || - ((graphstep == 6) && (hour % 2 == 0) && (q[2] == '0' && q[3] == '0')) || /* 120 minutes */ - ((graphstep == 7) && (hour % 4 == 0) && (q[2] == '0' && q[3] == '0')) || /* 240 minutes */ - ((graphstep >= 8) && (hour % 8 == 0) && (q[2] == '0' && q[3] == '0')) ) { /* 480 minutes */ - heat_used = cool_used = 0; - if (strcmp(heater_u, "NA") && (sscanf(heater_u, "%d", &h) == 1)) { - if (h && heater_l) { - heat_used = ((h - heater_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); - } - } - if (strcmp(cooler_u, "NA") && (sscanf(cooler_u, "%d", &c) == 1)) { - if (c && cooler_l) { - cool_used = ((c - cooler_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); - } - } - if (room_n) - sscanf(room_n, "%f", &room_t); - else - room_t = 0.0; - 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; - if (c & strcmp(cooler_u, "NA")) - cooler_l = c; - } - } - } - } - free(filename); - filename = NULL; - srv_send((char *)"."); - return 0; +// int hour = atoi(hr); +// if (((graphstep == 1)) || +// ((graphstep == 2) && (q[3] == '0' || q[3] == '5')) || +// ((graphstep == 3) && ((q[2] == '0' && q[3] == '0') || (q[2] == '1' && q[3] == '5') || (q[2] == '3' && q[3] == '0') || (q[2] == '4' && q[3] == '5'))) || +// ((graphstep == 4) && ((q[2] == '0' && q[3] == '0') || (q[2] == '3' && q[3] == '0'))) || +// ((graphstep == 5) && (q[2] == '0' && q[3] == '0')) || +// ((graphstep == 6) && (hour % 2 == 0) && (q[2] == '0' && q[3] == '0')) || /* 120 minutes */ +// ((graphstep == 7) && (hour % 4 == 0) && (q[2] == '0' && q[3] == '0')) || /* 240 minutes */ +// ((graphstep >= 8) && (hour % 8 == 0) && (q[2] == '0' && q[3] == '0')) ) { /* 480 minutes */ +// heat_used = cool_used = 0; +// if (strcmp(heater_u, "NA") && (sscanf(heater_u, "%d", &h) == 1)) { +// if (h && heater_l) { +// heat_used = ((h - heater_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); +// } +// } +// if (strcmp(cooler_u, "NA") && (sscanf(cooler_u, "%d", &c) == 1)) { +// if (c && cooler_l) { +// cool_used = ((c - cooler_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); +// } +// } +// if (room_n) +// sscanf(room_n, "%f", &room_t); +// else +// room_t = 0.0; +// 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,%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, chiller_n); +// srv_send(outbuf); +// if (h && strcmp(heater_u, "NA")) +// heater_l = h; +// if (c & strcmp(cooler_u, "NA")) +// cooler_l = c; +// } +// } +// } +// } +// free(filename); +// filename = NULL; +// srv_send((char *)"."); +// return 0; } srv_send((char *)"504 Subcommand error"); diff -r 3c4c6d5e4b8d -r e833bbd5e733 thermferm/thermferm.c --- a/thermferm/thermferm.c Sat Jul 14 21:36:08 2018 +0200 +++ b/thermferm/thermferm.c Sun Jul 15 12:05:16 2018 +0200 @@ -1943,10 +1943,11 @@ 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,%s", + snprintf(buf, 1023, "%s,%.3f,%.3f,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%.3f", UNITMODE[unit->mode], unit->air_temperature / 1000.0, unit->beer_temperature / 1000.0, - target_lo, heater, cooler, fan, door, use_heater, use_cooler, use_fan, room_temp, target_hi); + target_lo, heater, cooler, fan, door, use_heater, use_cooler, use_fan, room_temp, target_hi, + unit->chiller_temperature / 1000.0); filename = xstrcpy(unit->name); filename = xstrcat(filename, (char *)".log"); logger(filename, buf); diff -r 3c4c6d5e4b8d -r e833bbd5e733 www-thermferm/archives.php --- a/www-thermferm/archives.php Sat Jul 14 21:36:08 2018 +0200 +++ b/www-thermferm/archives.php Sun Jul 15 12:05:16 2018 +0200 @@ -1,6 +1,6 @@ * @@ -125,7 +125,8 @@ $outstr .= ' { name: "Cooler", type: "int" },'.PHP_EOL; $outstr .= ' { name: "HeatUse", type: "int" },'.PHP_EOL; $outstr .= ' { name: "CoolUse", type: "int" },'.PHP_EOL; - $outstr .= ' { name: "Room", type: "float" }'.PHP_EOL; + $outstr .= ' { name: "Room", type: "float" },'.PHP_EOL; + $outstr .= ' { name: "Chiller", type: "float" }'.PHP_EOL; $outstr .= ' ],'.PHP_EOL; $outstr .= ' url: \'getalog.php?name='.urlencode($name).'.log\''.PHP_EOL; $outstr .= ' };'.PHP_EOL; @@ -189,7 +190,8 @@ $outstr .= ' { dataField: "Beer", lineWidth: 2, displayText: "Beer" },'.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 .= ' { dataField: "Room", lineWidth: 1, displayText: "Room", opacity: 0.5 },'.PHP_EOL; + $outstr .= ' { dataField: "Chiller", lineWidth: 1, displayText: "Chiller", opacity: 0.4 }'.PHP_EOL; $outstr .= ' ]'.PHP_EOL; $outstr .= ' }]'.PHP_EOL; $outstr .= ' };'.PHP_EOL; diff -r 3c4c6d5e4b8d -r e833bbd5e733 www-thermferm/getalog.php --- a/www-thermferm/getalog.php Sat Jul 14 21:36:08 2018 +0200 +++ b/www-thermferm/getalog.php Sun Jul 15 12:05:16 2018 +0200 @@ -1,6 +1,6 @@ * @@ -50,7 +50,8 @@ 'HeatUse' => $f[7], 'CoolUse' => $f[8], 'Room' => $f[9], - 'Target_hi' => $f[10] + 'Target_hi' => $f[10], + 'Chiller' => $f[11] ); $row .= json_encode($reply, JSON_NUMERIC_CHECK); $j++; diff -r 3c4c6d5e4b8d -r e833bbd5e733 www-thermferm/getlog.php --- a/www-thermferm/getlog.php Sat Jul 14 21:36:08 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ - - * - * This file is part of ThermFerm - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * ThermFerm is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ThermFerm; see the file COPYING. If not, write to the Free - * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - *****************************************************************************/ - -require_once('utilities.php'); - - -$answer = send_cmd("LIST LOG ".$_GET["unit"]); -$arr = explode("\r\n", $answer); - - -$row = '['; - -/* We don't use json_encode because it doesn't work for our purpose */ -if (startsWith($arr[0], "212")) { - $j = 1; - while (1) { - if (strcmp($arr[$j], ".") == 0) - break; - if ($j > 1) - $row .= ','; - $f = explode(",", $arr[$j]); - $reply = array ( - 'Date' => $f[0], - 'Mode' => $f[1], - 'Air' => $f[2], - 'Beer' => $f[3], - 'Target_lo' => $f[4], - 'Heater' => $f[5] / 100, - 'Cooler' => $f[6] / 100, - 'HeatUse' => $f[7], - 'CoolUse' => $f[8], - 'Room' => $f[9], - 'Target_hi' => $f[10] - ); - $row .= json_encode($reply, JSON_NUMERIC_CHECK); - $j++; - } -} - -$row .= ']'; -echo $row; - -?>