www-thermferm/utilities.php

Sun, 07 Jul 2019 14:31:10 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 07 Jul 2019 14:31:10 +0200
branch
stable
changeset 603
fcff55324b84
parent 397
00ca08f5a6f8
permissions
-rw-r--r--

Merged fix from default

100
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 /*****************************************************************************
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
3 * Copyright (C) 2014-2015
100
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 *
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * Michiel Broek <mbroek at mbse dot eu>
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 *
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * This file is part of ThermFerm
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * This is free software; you can redistribute it and/or modify it
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * under the terms of the GNU General Public License as published by the
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * Free Software Foundation; either version 2, or (at your option) any
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * later version.
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * ThermFerm is distributed in the hope that it will be useful, but
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * General Public License for more details.
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 *
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * along with ThermFerm; see the file COPYING. If not, write to the Free
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 *****************************************************************************/
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
397
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
24 $my_style = 'ui-redmond';
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
25
100
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 function open_socket()
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 {
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 if (!($sock === false)) {
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 if (socket_connect($sock, "localhost", 6554)) {
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 15, 'usec' => 0));
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 } else {
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 socket_close($sock);
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 }
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 }
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 return $sock;
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 }
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42
196
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
43 /*
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
44 * @param string $command to send to the server.
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
45 * Return: string with the complete reply from the
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
46 * server. This can be a multiline reply.
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
47 */
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
48 function send_cmd($command)
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
49 {
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
50 $sock = open_socket();
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
51 if ($sock == false) {
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
52 return "";
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
53 }
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
54 socket_write($sock, $command . "\r\n", 4096);
196
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
55
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
56 $answer = "";
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
57 while (1) {
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
58 $line = socket_read($sock, 4096);
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
59 if ($line === '')
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
60 break;
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
61 $answer .= $line;
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
62 }
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
63 socket_close($sock);
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
64
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
65 return $answer;
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
66 }
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
67
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
68
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
69
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
70 /*
251
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
71 * @param string array of $commands to send to the server.
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
72 * Return: string with the complete reply from the
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
73 * server. This can be a multiline reply.
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
74 */
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
75 function send_array($command)
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
76 {
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
77 $sock = open_socket();
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
78 if ($sock == false) {
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
79 return "";
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
80 }
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
81
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
82 foreach($command as $cmd) {
362
c92651a54969 Made the client-server protocol more robust. When a change to a unit is made using the web interface, the main process is stopped during the update. Splitted the PID in two PID's, one for heating and one for cooling. Adjusted the web edit scrreen for this, but there are still rough edges. Replaced the PID code, maybe this one works better for our purpose. The simulator air temperature changes on the simulator heater and cooler, but it is not realistic at all. This is a development version, do not use in production. The version is 0.3.0
Michiel Broek <mbroek@mbse.eu>
parents: 269
diff changeset
83 socket_write($sock, $cmd . "\r\n", 4096);
251
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
84 }
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
85
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
86 $answer = "";
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
87 while (1) {
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
88 $line = socket_read($sock, 4096);
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
89 if ($line === '')
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
90 break;
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
91 $answer .= $line;
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
92 }
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
93 socket_close($sock);
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
94
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
95 return $answer;
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
96 }
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
97
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
98
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
99
173b4480c4a0 Made a function to send arrays to the server. The room temperature and humidity are now displayed at once when the dashboard is loaded.
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
100 /*
196
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
101 * @param string $command to send to the server.
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
102 * Return: 0 = Ok.
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
103 * 1 = Server responden with an error.
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
104 */
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
105 function send_cmd_check($command)
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
106 {
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
107 $answer = send_cmd($command);
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
108
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
109 if (strlen($answer) && (($answer[0] == '1') || ($answer[0] == '2')))
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
110 return 0;
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
111
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
112 return 1;
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
113 }
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
114
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
115
4d7a96c5d1ff Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
116
255
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
117 /*
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
118 * @param array $command to send to the server.
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
119 * Return: 0 = Ok.
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
120 * 1 = Server responden with an error.
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
121 */
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
122 function send_array_check($command)
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
123 {
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
124 $answer = send_array($command);
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
125
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
126 if (strlen($answer) && (($answer[0] == '1') || ($answer[0] == '2')))
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
127 return 0;
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
128
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
129 return 1;
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
130 }
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
131
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
132
fb930d1db5a6 Added function send_array_check
Michiel Broek <mbroek@mbse.eu>
parents: 251
diff changeset
133
100
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 function startsWith($haystack, $needle)
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 {
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 return !strncmp($haystack, $needle, strlen($needle));
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 }
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138
012576d7386d Basic web idea
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
140 function build_header($heading)
134
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
141 {
397
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
142 global $my_style;
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
143
269
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
144 $answer = send_cmd('GLOBAL GET');
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
145 $arr = explode("\r\n", $answer);
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
146 $version = "?";
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
147
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
148 if (startsWith($arr[0], "213")) {
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
149 $j = 1;
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
150 while (1) {
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
151 if (strcmp($arr[$j], ".") == 0)
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
152 break;
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
153 $f = explode(",", $arr[$j]);
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
154
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
155 if ($f[0] == "RELEASE")
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
156 $version = $f[1];
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
157 $j++;
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
158 }
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
159 }
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
160
134
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
161 $outstr = '<!DOCTYPE html>'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
162 $outstr .= '<html>'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
163 $outstr .= ' <head>'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
164 $outstr .= ' <meta http-equiv="content-type" content="text/html; charset=utf-8" />'.PHP_EOL;
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
165 $outstr .= ' <title>'.$heading.'</title>'.PHP_EOL;
134
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
166 $outstr .= ' <link type="text/css" href="css/style.css" rel="stylesheet" media="all" />'.PHP_EOL;
397
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
167 $outstr .= ' <link type="text/css" href="jqwidgets/styles/jqx.base.css" rel="stylesheet" />'.PHP_EOL;
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
168 $outstr .= ' <link type="text/css" href="jqwidgets/styles/jqx.'.$my_style.'.css" rel="stylesheet" />'.PHP_EOL;
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
169 $outstr .= ' <script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>'.PHP_EOL;
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
170 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxcore.js"></script>'.PHP_EOL;
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
171 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxwindow.js"></script>'.PHP_EOL;
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
172 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxbuttons.js"></script>'.PHP_EOL;
134
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
173 $outstr .= ' </head>'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
174 $outstr .= ' <body class="default">'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
175 $outstr .= ' <div id="jqxWidget">'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
176 $outstr .= ' <div id="header">'.PHP_EOL;
269
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
177 $outstr .= ' <div id="title">'.PHP_EOL;
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
178 $outstr .= ' ThermFerm '.$version.PHP_EOL;
dc88583a068d All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents: 255
diff changeset
179 $outstr .= ' </div>'.PHP_EOL;
134
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
180 $outstr .= ' <form action="maintenance.php" style="margin:30px; float:right">'.PHP_EOL;
397
00ca08f5a6f8 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.
Michiel Broek <mbroek@mbse.eu>
parents: 379
diff changeset
181 $outstr .= ' <input type="submit" id="maintenance" value="Maintenance panel" />'.PHP_EOL;
134
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
182 $outstr .= ' </form>'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
183 $outstr .= ' </div> <!-- header -->'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
184 $outstr .= ' <div id="content">'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
185
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
186 return $outstr;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
187 }
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
188
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
189
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
190
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
191 function build_footer()
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
192 {
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
193 $outstr = ' </div> <!-- content -->'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
194 $outstr .= ' </div> <!-- jqxWidget -->'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
195 $outstr .= ' </body>'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
196 $outstr .= '</html>'.PHP_EOL;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
197
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
198 return $outstr;
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
199 }
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
200
f05601490415 Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
201
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
202
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
203 /*
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
204 * Goto URL. Works also after headers have been sent.
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
205 */
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
206 function load($url) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
207 echo'
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
208 <script>
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
209 if (top.location != self.location) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
210 top.location = "'.$url.'"
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
211 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
212 {location.href="'.$url.'";}
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
213 </script>';
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
214 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
215
155
0d86f3c0a07b Unit mode can switch between OFF and NONE.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
216

mercurial