www-thermferm/getlog.php

changeset 536
e833bbd5e733
parent 535
3c4c6d5e4b8d
child 537
4eebab50993e
equal deleted inserted replaced
535:3c4c6d5e4b8d 536:e833bbd5e733
1 <?php
2 /*****************************************************************************
3 * Copyright (C) 2014-2017
4 *
5 * Michiel Broek <mbroek at mbse dot eu>
6 *
7 * This file is part of ThermFerm
8 *
9 * This is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any
12 * later version.
13 *
14 * ThermFerm is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ThermFerm; see the file COPYING. If not, write to the Free
21 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *****************************************************************************/
23
24 require_once('utilities.php');
25
26
27 $answer = send_cmd("LIST LOG ".$_GET["unit"]);
28 $arr = explode("\r\n", $answer);
29
30
31 $row = '[';
32
33 /* We don't use json_encode because it doesn't work for our purpose */
34 if (startsWith($arr[0], "212")) {
35 $j = 1;
36 while (1) {
37 if (strcmp($arr[$j], ".") == 0)
38 break;
39 if ($j > 1)
40 $row .= ',';
41 $f = explode(",", $arr[$j]);
42 $reply = array (
43 'Date' => $f[0],
44 'Mode' => $f[1],
45 'Air' => $f[2],
46 'Beer' => $f[3],
47 'Target_lo' => $f[4],
48 'Heater' => $f[5] / 100,
49 'Cooler' => $f[6] / 100,
50 'HeatUse' => $f[7],
51 'CoolUse' => $f[8],
52 'Room' => $f[9],
53 'Target_hi' => $f[10]
54 );
55 $row .= json_encode($reply, JSON_NUMERIC_CHECK);
56 $j++;
57 }
58 }
59
60 $row .= ']';
61 echo $row;
62
63 ?>

mercurial