Mon, 05 Oct 2015 15:21:46 +0200
Make sure that a DS2413 device used as input has the output latch turned off.
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2 | * Copyright (C) 2008-2015 |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of the mbsePi-apps |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * mbsePi-apps is distributed in the hope that it will be useful, but |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
106 | 23 | #include "rdconfig.h" |
46
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
24 | #include "thermferm.h" |
155
0d86f3c0a07b
Unit mode can switch between OFF and NONE.
Michiel Broek <mbroek@mbse.eu>
parents:
140
diff
changeset
|
25 | #include "logger.h" |
184 | 26 | #include "devices.h" |
106 | 27 | #include "server.h" |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
28 | #include "lcd-buffer.h" |
106 | 29 | #include "xutil.h" |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | |
58
e8e7b46b705b
Fixed compilation without wiringpi
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
31 | |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
32 | extern int my_shutdown; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
33 | extern int debug; |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
34 | extern int run_pause; |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
35 | extern int run_hold; |
43 | 36 | extern sys_config Config; |
81 | 37 | extern const char UNITMODE[5][8]; |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
38 | extern const char TEMPSTATE[3][8]; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
39 | extern const char DEVTYPE[8][6]; |
174 | 40 | extern const char DEVPRESENT[4][6]; |
41 | extern const char DEVDIR[7][11]; | |
217 | 42 | extern const char PROFSTATE[5][6]; |
174 | 43 | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | |
43 | 45 | int s; /* connected socket */ |
46 | int ls; /* listen socket */ | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | |
43 | 48 | struct sockaddr_in myaddr_in; /* for local socket address */ |
49 | struct sockaddr_in peeraddr_in; /* for peer socket address */ | |
50 | ||
51 | struct hostent *hp; | |
52 | ||
53 | #define SS_BUFSIZE 1024 | |
54 | #define SS_TIMEOUT 300 | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | |
389
584d40bb4b09
Graph lines logging can handle longer logfiles and has a safety limit.
Michiel Broek <mbroek@mbse.eu>
parents:
381
diff
changeset
|
56 | #define MAX_INTERVALS 10 |
584d40bb4b09
Graph lines logging can handle longer logfiles and has a safety limit.
Michiel Broek <mbroek@mbse.eu>
parents:
381
diff
changeset
|
57 | const int GRAPH_INTERVAL[MAX_INTERVALS] = { 0, 1, 5, 15, 30, 60, 120, 240, 480, 960 }; |
584d40bb4b09
Graph lines logging can handle longer logfiles and has a safety limit.
Michiel Broek <mbroek@mbse.eu>
parents:
381
diff
changeset
|
58 | const int GRAPH_DATALINES[MAX_INTERVALS] = { 0, 800, 3200, 12000, 24000, 48000, 96000, 192000, 384000, 768000 }; |
329 | 59 | const char MONTH[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; |
60 | ||
61 | ||
62 | typedef struct _ls_list { | |
63 | struct _ls_list *next; /* Next record pointer */ | |
64 | char d_name[256]; /* File name */ | |
65 | mode_t mode; /* File mode */ | |
66 | off_t size; /* File size */ | |
67 | time_t mtime; /* File modification time */ | |
68 | } ls_list; | |
69 | ||
70 | ||
71 | ||
72 | void tidy_lslist(ls_list **); | |
73 | void fill_list(ls_list **, char *, mode_t, off_t, time_t); | |
74 | int comp(ls_list **,ls_list **); | |
75 | void sort_list(ls_list **); | |
76 | ||
77 | ||
46
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
78 | |
43 | 79 | /* |
80 | * Send message to client | |
81 | */ | |
82 | int srv_send(const char *format, ...) | |
83 | { | |
84 | char out[SS_BUFSIZE]; | |
85 | va_list va_ptr; | |
86 | ||
87 | if (s == -1) | |
88 | return -1; | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | |
43 | 90 | va_start(va_ptr, format); |
91 | vsnprintf(out, SS_BUFSIZE-1, format, va_ptr); | |
92 | va_end(va_ptr); | |
93 | ||
48 | 94 | if (debug) { |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
79
diff
changeset
|
95 | syslog(LOG_NOTICE, "send: \"%s\"", out); |
45
053c4657105f
Mirror LCD display on the webpage works
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
96 | fprintf(stdout, "send: \"%s\"\n", out); |
48 | 97 | } |
44 | 98 | |
43 | 99 | if (send(s, out, strlen(out), 0) != strlen(out)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
100 | syslog(LOG_NOTICE, "srv_send failed"); |
43 | 101 | return -1; |
102 | } | |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
79
diff
changeset
|
103 | |
43 | 104 | if (send(s, (char *)"\r\n", 2, 0) != 2) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
105 | syslog(LOG_NOTICE, "srv_send failed"); |
43 | 106 | return -1; |
107 | } | |
108 | ||
109 | return 0; | |
110 | } | |
111 | ||
112 | ||
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | |
88 | 114 | /* |
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:
358
diff
changeset
|
115 | * Argument is a buffer of size SS_BUFSIZE. |
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:
358
diff
changeset
|
116 | * Return -1 if error, else the number of received |
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:
358
diff
changeset
|
117 | * character. \n is line end, ignore \r. |
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:
358
diff
changeset
|
118 | */ |
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:
358
diff
changeset
|
119 | int srv_recv(char *buffer) |
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:
358
diff
changeset
|
120 | { |
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:
358
diff
changeset
|
121 | int bytesloaded = 0; |
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:
358
diff
changeset
|
122 | ssize_t ret; |
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:
358
diff
changeset
|
123 | unsigned char buf; |
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:
358
diff
changeset
|
124 | socklen_t fromlen; |
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:
358
diff
changeset
|
125 | |
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:
358
diff
changeset
|
126 | memset(buffer, 0, SS_BUFSIZE); |
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:
358
diff
changeset
|
127 | |
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:
358
diff
changeset
|
128 | while(1) { |
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:
358
diff
changeset
|
129 | /* |
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:
358
diff
changeset
|
130 | * read a single byte |
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:
358
diff
changeset
|
131 | */ |
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:
358
diff
changeset
|
132 | fromlen = sizeof(peeraddr_in); |
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:
358
diff
changeset
|
133 | ret = recvfrom(s, &buf, 1, 0, (struct sockaddr *)&peeraddr_in, &fromlen); |
368 | 134 | if (ret < 0) { |
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:
358
diff
changeset
|
135 | syslog(LOG_NOTICE, "recvfrom(): %s", strerror(errno)); |
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:
358
diff
changeset
|
136 | return -1; /* error */ |
368 | 137 | } else if (ret == 0) { |
138 | return -1; /* no data */ | |
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:
358
diff
changeset
|
139 | } |
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:
358
diff
changeset
|
140 | |
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:
358
diff
changeset
|
141 | if (buf == '\n') |
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:
358
diff
changeset
|
142 | break; |
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:
358
diff
changeset
|
143 | |
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:
358
diff
changeset
|
144 | if (buf != '\r') { |
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:
358
diff
changeset
|
145 | buffer[bytesloaded] = buf; |
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:
358
diff
changeset
|
146 | bytesloaded++; |
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:
358
diff
changeset
|
147 | } |
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:
358
diff
changeset
|
148 | } |
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:
358
diff
changeset
|
149 | |
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:
358
diff
changeset
|
150 | if (debug) { |
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:
358
diff
changeset
|
151 | syslog(LOG_NOTICE, "recv: %d `%s'", bytesloaded, buffer); |
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:
358
diff
changeset
|
152 | fprintf(stdout, "recv: %d `%s'\n", bytesloaded, buffer); |
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:
358
diff
changeset
|
153 | } |
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:
358
diff
changeset
|
154 | return bytesloaded; |
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:
358
diff
changeset
|
155 | } |
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:
358
diff
changeset
|
156 | |
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:
358
diff
changeset
|
157 | |
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:
358
diff
changeset
|
158 | |
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:
358
diff
changeset
|
159 | /* |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
160 | * Update the device inuse counter. |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
161 | */ |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
162 | void device_count(int plus, char *uuid) |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
163 | { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
164 | devices_list *device; |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
165 | |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
166 | for (device = Config.devices; device; device = device->next) { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
167 | if (strcmp(device->uuid, uuid) == 0) { |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
168 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
169 | piLock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
170 | #endif |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
171 | if (plus == TRUE) { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
172 | device->inuse++; |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
173 | } else { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
174 | if (device->inuse) |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
175 | device->inuse--; |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
176 | } |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
177 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
178 | piUnlock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
179 | #endif |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
180 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
181 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
182 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
183 | |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
184 | |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
185 | |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
186 | int delete_Profile(char *uuid) |
138 | 187 | { |
188 | profiles_list *current = Config.profiles; | |
189 | profiles_list *previous = NULL; | |
190 | prof_step *step, *olds; | |
191 | ||
192 | while (current) { | |
193 | if (strcmp(current->uuid, uuid) == 0) { | |
194 | if (previous == NULL) { | |
195 | Config.profiles = current->next; | |
196 | free(current->uuid); | |
197 | current->uuid = NULL; | |
198 | free(current->name); | |
199 | current->name = NULL; | |
200 | if (current->steps) { | |
201 | for (step = current->steps; step; step = olds) { | |
202 | olds = step->next; | |
203 | free(step); | |
204 | } | |
205 | current->steps = NULL; | |
206 | } | |
207 | free(current); | |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
208 | return 1; |
138 | 209 | } else { |
210 | free(current->uuid); | |
211 | current->uuid = NULL; | |
212 | free(current->name); | |
213 | current->name = NULL; | |
214 | if (current->steps) { | |
215 | for (step = current->steps; step; step = olds) { | |
216 | olds = step->next; | |
217 | free(step); | |
218 | } | |
219 | current->steps = NULL; | |
220 | } | |
221 | previous->next = current->next; | |
222 | free(current); | |
223 | current = previous->next; | |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
224 | return 1; |
138 | 225 | } |
226 | } else { | |
227 | previous = current; | |
228 | current = current->next; | |
229 | } | |
230 | } | |
231 | ||
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
232 | return 0; |
138 | 233 | } |
234 | ||
235 | ||
236 | ||
329 | 237 | void tidy_lslist(ls_list **lap) |
238 | { | |
239 | ls_list *tmp, *old; | |
240 | ||
241 | for (tmp = *lap; tmp; tmp = old) { | |
242 | old = tmp->next; | |
243 | free(tmp); | |
244 | } | |
245 | *lap = NULL; | |
246 | } | |
247 | ||
248 | ||
249 | ||
250 | void fill_list(ls_list **lap, char *name, mode_t mode, off_t size, time_t mtime) | |
251 | { | |
252 | ls_list **tmp; | |
253 | ||
254 | for (tmp = lap; *tmp; tmp = &((*tmp)->next)); | |
255 | ||
256 | *tmp = (ls_list *)malloc(sizeof(ls_list)); | |
257 | (*tmp)->next = NULL; | |
258 | strncpy((*tmp)->d_name, name, 256); | |
259 | (*tmp)->mode = mode; | |
260 | (*tmp)->size = size; | |
261 | (*tmp)->mtime = mtime; | |
262 | tmp = &((*tmp)->next); | |
263 | } | |
264 | ||
265 | ||
266 | ||
267 | void sort_list(ls_list **lap) | |
268 | { | |
269 | ls_list *ta, **vector; | |
270 | size_t n = 0, i; | |
271 | ||
272 | if (*lap == NULL) | |
273 | return; | |
274 | ||
275 | for (ta = *lap; ta; ta = ta->next) | |
276 | n++; | |
277 | vector = (ls_list **)malloc(n * sizeof(ls_list *)); | |
278 | i = 0; | |
279 | ||
280 | for (ta = *lap; ta; ta = ta->next) { | |
281 | vector[i++] = ta; | |
282 | } | |
283 | qsort(vector, n, sizeof(ls_list *), (int(*)(const void*, const void*))comp); | |
284 | ||
285 | (*lap) = vector[0]; | |
286 | i = 1; | |
287 | ||
288 | for (ta = *lap; ta; ta = ta->next) { | |
289 | if (i < n) | |
290 | ta->next = vector[i++]; | |
291 | else | |
292 | ta->next = NULL; | |
293 | } | |
294 | ||
295 | free(vector); | |
296 | return; | |
297 | } | |
298 | ||
299 | ||
300 | ||
301 | int comp(ls_list **lsp1, ls_list **lsp2) | |
302 | { | |
303 | return strcmp((*lsp1)->d_name, (*lsp2)->d_name); | |
304 | } | |
305 | ||
306 | ||
307 | ||
308 | /* | |
309 | * ARCHIVE DIR | |
310 | * ARCHIVE GET filename | |
331 | 311 | * ARCHIVE LOG filename |
329 | 312 | * ARCHIVE HELP |
313 | */ | |
314 | int cmd_archive(char *buf) | |
315 | { | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
316 | char *opt, *param, *name = NULL, *filename = NULL, *logname = NULL, mbits[11], tstr[24]; |
329 | 317 | DIR *dd; |
318 | FILE *fp; | |
319 | struct dirent entry, *result; | |
320 | ls_list *lsx = NULL, *tmp; | |
321 | struct stat sbuf; | |
322 | struct tm *tbuf; | |
323 | time_t ftime; | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
324 | int found; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
325 | units_list *unit; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
326 | |
329 | 327 | |
328 | opt = strtok(buf, " \0"); | |
329 | opt = strtok(NULL, " \0"); | |
330 | ||
331 | if (opt == NULL) { | |
332 | srv_send((char *)"501 Subcommand missing"); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
333 | return 0; |
329 | 334 | } |
335 | param = strtok(NULL, "\0"); | |
336 | ||
337 | if (strcmp(opt, (char *)"HELP") == 0) { | |
338 | srv_send((char *)"100 Help text follows:"); | |
339 | srv_send((char *)"Recognized commands:"); | |
340 | srv_send((char *)"ARCHIVE DIR Archived logfiles directory"); | |
341 | srv_send((char *)"ARCHIVE GET filename Archived logfile download"); | |
331 | 342 | srv_send((char *)"ARCHIVE LOG filename Archived logfile data in graphsteps"); |
329 | 343 | srv_send((char *)"."); |
344 | return 0; | |
345 | } | |
346 | ||
347 | if (strcmp(opt, (char *)"DIR") == 0) { | |
348 | ||
349 | if (getenv((char *)"USER") == NULL) { | |
350 | name = xstrcpy((char *)"/root"); | |
351 | } else { | |
352 | name = xstrcpy(getenv((char *)"HOME")); | |
353 | } | |
354 | name = xstrcat(name, (char *)"/.thermferm/log/"); | |
355 | ||
356 | if ((dd = opendir(name))) { | |
357 | for (;;) { | |
358 | if ((readdir_r(dd, &entry, &result)) != 0) { | |
359 | syslog(LOG_NOTICE, "readdir_r: error=%d", errno); | |
360 | break; | |
361 | } | |
362 | if (result == NULL) /* End of directory */ | |
363 | break; | |
364 | if (result->d_name[0] != '.') { | |
365 | filename = xstrcpy(name); | |
366 | filename = xstrcat(filename, result->d_name); | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
367 | /* |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
368 | * Remove files from the list when they are in use |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
369 | */ |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
370 | found = 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
371 | for (unit = Config.units; unit; unit = unit->next) { |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
372 | if (unit->mode != UNITMODE_OFF) { |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
373 | logname = xstrcpy(unit->name); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
374 | logname = xstrcat(logname, (char *)".log"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
375 | if (! strcmp(result->d_name, logname)) |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
376 | found = 1; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
377 | free(logname); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
378 | logname = NULL; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
379 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
380 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
381 | if ((found == 0) && ((stat(filename, &sbuf)) == 0)) { |
329 | 382 | fill_list(&lsx, result->d_name, sbuf.st_mode, sbuf.st_size, sbuf.st_mtime); |
383 | } | |
384 | free(filename); | |
385 | filename = NULL; | |
386 | } | |
387 | } | |
388 | closedir(dd); | |
389 | } else { | |
390 | syslog(LOG_NOTICE, "opendir: \"%s\" error=%d", name, errno); | |
391 | } | |
392 | ||
393 | sort_list(&lsx); | |
394 | ||
395 | srv_send((char *)"212 Archive directory follows:"); | |
396 | for (tmp = lsx; tmp; tmp = tmp->next) { | |
397 | sprintf(mbits, "----------"); | |
398 | if (tmp->mode & S_IRUSR) | |
399 | mbits[1] = 'r'; | |
400 | if (tmp->mode & S_IWUSR) | |
401 | mbits[2] = 'w'; | |
402 | if (tmp->mode & S_IXUSR) | |
403 | mbits[3] = 'x'; | |
404 | if (tmp->mode & S_IRGRP) | |
405 | mbits[4] = 'r'; | |
406 | if (tmp->mode & S_IWGRP) | |
407 | mbits[5] = 'w'; | |
408 | if (tmp->mode & S_IXGRP) | |
409 | mbits[6] = 'x'; | |
410 | if (tmp->mode & S_IROTH) | |
411 | mbits[7] = 'r'; | |
412 | if (tmp->mode & S_IWOTH) | |
413 | mbits[8] = 'w'; | |
414 | if (tmp->mode & S_IXOTH) | |
415 | mbits[9] = 'x'; | |
416 | ftime = tmp->mtime; | |
417 | tbuf = localtime(&ftime); | |
418 | sprintf(tstr, "%02d %s %04d %02d:%02d", tbuf->tm_mday, MONTH[tbuf->tm_mon], tbuf->tm_year+1900, tbuf->tm_hour, tbuf->tm_min); | |
419 | srv_send((char *)"%s,%s,%d,%s", tmp->d_name, mbits, tmp->size, tstr); | |
420 | } | |
421 | srv_send((char *)"."); | |
422 | tidy_lslist(&lsx); | |
423 | ||
424 | free(name); | |
425 | name = NULL; | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
426 | return 0; |
329 | 427 | } |
428 | ||
429 | if (param == NULL) { | |
430 | srv_send((char *)"502 Parameter missing"); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
431 | return 0; |
329 | 432 | } |
433 | ||
434 | if (strcmp(opt, (char *)"GET") == 0) { | |
435 | if (getenv((char *)"USER") == NULL) { | |
436 | name = xstrcpy((char *)"/root"); | |
437 | } else { | |
438 | name = xstrcpy(getenv((char *)"HOME")); | |
439 | } | |
440 | name = xstrcat(name, (char *)"/.thermferm/log/"); | |
441 | name = xstrcat(name, param); | |
442 | ||
443 | if ((fp = fopen(name, "r"))) { | |
444 | char buffer[256]; | |
445 | ||
446 | srv_send((char *)"212 Archive file follows:"); | |
447 | while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { | |
448 | int i; | |
449 | ||
450 | for (i = 0; i < strlen(buffer); i++) { | |
451 | if (buffer[i] == '\n') | |
452 | buffer[i] = '\0'; | |
453 | if (buffer[i] == '\r') | |
454 | buffer[i] = '\0'; | |
455 | } | |
456 | srv_send(buffer); | |
457 | } | |
458 | srv_send((char *)"."); | |
459 | fclose(fp); | |
460 | } else { | |
461 | srv_send((char *)"440 No such file"); | |
331 | 462 | } |
463 | ||
464 | free(name); | |
465 | name = NULL; | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
466 | return 0; |
331 | 467 | } |
468 | ||
469 | if (strcmp(opt, (char *)"LOG") == 0) { | |
470 | if (getenv((char *)"USER") == NULL) { | |
471 | name = xstrcpy((char *)"/root"); | |
472 | } else { | |
473 | name = xstrcpy(getenv((char *)"HOME")); | |
474 | } | |
475 | name = xstrcat(name, (char *)"/.thermferm/log/"); | |
476 | name = xstrcat(name, param); | |
477 | ||
478 | if ((fp = fopen(name, "r"))) { | |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
479 | char buffer[256], outbuf[256], q[5], hr[3]; |
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:
390
diff
changeset
|
480 | char *date_n, *mode_n, *air_n, *beer_n, *target_lo_n, *target_hi_n, *heater_n, *cooler_n, *room_n; |
331 | 481 | char *heater_u, *cooler_u; |
482 | int lines = 0, heater_l = 0, cooler_l = 0, h = 0, c = 0, heat_used = 0, cool_used = 0, graphstep = 0; | |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
483 | float room_t = 0.0; |
331 | 484 | |
485 | srv_send((char *)"212 Logfile list follows:"); | |
486 | while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { | |
487 | lines++; | |
488 | } | |
489 | fseek(fp, 0L, SEEK_SET); | |
490 | /* | |
491 | * We have counted the lines in the logfile including the header lines. | |
492 | * The header lines should be ignored but there are so few of them, we | |
493 | * just include them in the total. | |
494 | * Now find a reasonable interval of lines to sent to the client. | |
495 | */ | |
496 | for (graphstep = 1; graphstep <= MAX_INTERVALS; graphstep++) { | |
497 | if (lines < GRAPH_DATALINES[graphstep]) { | |
498 | break; | |
499 | } | |
500 | } | |
389
584d40bb4b09
Graph lines logging can handle longer logfiles and has a safety limit.
Michiel Broek <mbroek@mbse.eu>
parents:
381
diff
changeset
|
501 | if (graphstep > MAX_INTERVALS) |
584d40bb4b09
Graph lines logging can handle longer logfiles and has a safety limit.
Michiel Broek <mbroek@mbse.eu>
parents:
381
diff
changeset
|
502 | graphstep = MAX_INTERVALS; |
331 | 503 | syslog(LOG_NOTICE, "ARCHIVE LOG %s: lines=%d, interval=%d, graphstep=%d", param, lines, GRAPH_INTERVAL[graphstep], graphstep); |
504 | ||
505 | while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { | |
506 | /* | |
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:
390
diff
changeset
|
507 | * 2014-11-15 18:39,BEER,20.312,19.750,20.0,0,NA,NA,NA,78105,NA,NA,18.000,20.1 |
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:
390
diff
changeset
|
508 | * | | | | | | | | | | | | | | |
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:
390
diff
changeset
|
509 | * date_n | | | | | | | | | | | | | |
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:
390
diff
changeset
|
510 | * mode_n ----------+ | | | | | | | | | | | | |
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:
390
diff
changeset
|
511 | * air_n -----------------+ | | | | | | | | | | | |
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:
390
diff
changeset
|
512 | * beer_n -----------------------+ | | | | | | | | | | |
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:
390
diff
changeset
|
513 | * target_lo_n ------------------------+ | | | | | | | | | |
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:
390
diff
changeset
|
514 | * heater_n -------------------------------+ | | | | | | | | |
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:
390
diff
changeset
|
515 | * cooler_n ---------------------------------+ | | | | | | | |
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:
390
diff
changeset
|
516 | * not used ------------------------------------+ | | | | | | |
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:
390
diff
changeset
|
517 | * not used ---------------------------------------+ | | | | | |
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:
390
diff
changeset
|
518 | * heater_u --------------------------------------------+ | | | | |
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:
390
diff
changeset
|
519 | * cooler_u ------------------------------------------------+ | | | |
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:
390
diff
changeset
|
520 | * not used ---------------------------------------------------+ | | |
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:
390
diff
changeset
|
521 | * room_n ----------------------------------------------------------+ | |
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:
390
diff
changeset
|
522 | * target_hi_n -----------------------------------------------------------+ |
331 | 523 | */ |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
524 | hr[0] = q[0] = buffer[11]; |
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
525 | hr[1] = q[1] = buffer[12]; |
331 | 526 | q[2] = buffer[14]; |
527 | q[3] = buffer[15]; | |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
528 | hr[2] = '\0'; |
331 | 529 | buffer[strlen(buffer) -1] = '\0'; |
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:
390
diff
changeset
|
530 | date_n = strtok(buffer, ",\0"); /* timestamp */ |
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:
390
diff
changeset
|
531 | mode_n = strtok(NULL, ",\0"); /* unit mode */ |
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:
390
diff
changeset
|
532 | air_n = strtok(NULL, ",\0"); /* air temp */ |
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:
390
diff
changeset
|
533 | beer_n = strtok(NULL, ",\0"); /* beer temp */ |
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:
390
diff
changeset
|
534 | target_lo_n = strtok(NULL, ",\0"); /* target low temp */ |
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:
390
diff
changeset
|
535 | heater_n = strtok(NULL, ",\0"); /* current heater state */ |
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:
390
diff
changeset
|
536 | cooler_n = strtok(NULL, ",\0"); /* current cooler state */ |
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:
390
diff
changeset
|
537 | heater_u = strtok(NULL, ",\0"); /* current fan state */ |
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:
390
diff
changeset
|
538 | heater_u = strtok(NULL, ",\0"); /* current door state */ |
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:
390
diff
changeset
|
539 | heater_u = strtok(NULL, ",\0"); /* heater use counter */ |
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:
390
diff
changeset
|
540 | cooler_u = strtok(NULL, ",\0"); /* cooler use counter */ |
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:
390
diff
changeset
|
541 | room_n = strtok(NULL, ",\0"); /* fan use counter */ |
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:
390
diff
changeset
|
542 | room_n = strtok(NULL, ",\0"); /* room temperature */ |
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:
390
diff
changeset
|
543 | target_hi_n = strtok(NULL, ",\0"); /* target high temp */ |
331 | 544 | |
545 | if (strncmp(mode_n, (char *)"Mode", 4)) { | |
546 | /* | |
547 | * Output a line at the right intervals | |
548 | */ | |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
549 | int hour = atoi(hr); |
331 | 550 | if (((graphstep == 1)) || |
551 | ((graphstep == 2) && (q[3] == '0' || q[3] == '5')) || | |
552 | ((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'))) || | |
553 | ((graphstep == 4) && ((q[2] == '0' && q[3] == '0') || (q[2] == '3' && q[3] == '0'))) || | |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
554 | ((graphstep == 5) && (q[2] == '0' && q[3] == '0')) || |
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
555 | ((graphstep == 6) && (hour % 2 == 0) && (q[2] == '0' && q[3] == '0')) || /* 120 minutes */ |
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
556 | ((graphstep == 7) && (hour % 4 == 0) && (q[2] == '0' && q[3] == '0')) || /* 240 minutes */ |
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
557 | ((graphstep >= 8) && (hour % 8 == 0) && (q[2] == '0' && q[3] == '0')) ) { /* 480 minutes */ |
331 | 558 | heat_used = cool_used = 0; |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
559 | if (heater_u && strcmp(heater_u, "NA") && (sscanf(heater_u, "%d", &h) == 1)) { |
331 | 560 | if (h && heater_l) { |
561 | heat_used = ((h - heater_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); | |
562 | } | |
563 | } | |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
564 | if (cooler_u && strcmp(cooler_u, "NA") && (sscanf(cooler_u, "%d", &c) == 1)) { |
331 | 565 | if (c && cooler_l) { |
566 | cool_used = ((c - cooler_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); | |
567 | } | |
568 | } | |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
569 | if (room_n) |
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
570 | sscanf(room_n, "%f", &room_t); |
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:
390
diff
changeset
|
571 | if (target_hi_n == NULL) |
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:
390
diff
changeset
|
572 | target_hi_n = target_lo_n; |
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:
390
diff
changeset
|
573 | snprintf(outbuf, 255, "%s,%s,%s,%s,%s,%s,%s,%d,%d,%.1f,%s", |
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:
390
diff
changeset
|
574 | date_n, mode_n, air_n, beer_n, target_lo_n, heater_n, cooler_n, heat_used, cool_used, room_t,target_hi_n); |
331 | 575 | srv_send(outbuf); |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
576 | if (heater_u && h && strcmp(heater_u, "NA")) |
331 | 577 | heater_l = h; |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
578 | if (cooler_u && c & strcmp(cooler_u, "NA")) |
331 | 579 | cooler_l = c; |
580 | } | |
581 | } | |
582 | } | |
583 | ||
584 | srv_send((char *)"."); | |
585 | fclose(fp); | |
586 | } else { | |
587 | srv_send((char *)"440 No such file"); | |
329 | 588 | } |
589 | ||
590 | free(name); | |
591 | name = NULL; | |
592 | } | |
593 | ||
594 | return 0; | |
595 | } | |
596 | ||
597 | ||
598 | ||
174 | 599 | int delete_Device(char *uuid) |
600 | { | |
601 | devices_list *current = Config.devices; | |
602 | devices_list *previous = NULL; | |
603 | ||
604 | while (current) { | |
605 | if (strcmp(current->uuid, uuid) == 0) { | |
606 | if (previous == NULL) { | |
607 | Config.devices = current->next; | |
608 | free(current->uuid); | |
609 | current->uuid = NULL; | |
610 | free(current->address); | |
611 | current->address = NULL; | |
612 | free(current->description); | |
613 | current->description = NULL; | |
614 | free(current->comment); | |
615 | current->comment = NULL; | |
616 | free(current); | |
617 | return 1; | |
618 | } else { | |
619 | free(current->uuid); | |
620 | current->uuid = NULL; | |
621 | free(current->address); | |
622 | current->address = NULL; | |
623 | free(current->description); | |
624 | current->description = NULL; | |
625 | free(current->comment); | |
626 | current->comment = NULL; | |
627 | previous->next = current->next; | |
628 | free(current); | |
629 | current = previous->next; | |
630 | return 1; | |
631 | } | |
632 | } else { | |
633 | previous = current; | |
634 | current = current->next; | |
635 | } | |
636 | } | |
637 | return 0; | |
638 | } | |
639 | ||
640 | ||
641 | ||
81 | 642 | /* |
174 | 643 | * DEVICE ADD type |
644 | * DEVICE DEL uuid | |
645 | * DEVICE LIST | |
646 | * DEVICE GET uuid | |
647 | * DEVICE PUT uuid | |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
648 | */ |
174 | 649 | int cmd_device(char *buf) |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
650 | { |
174 | 651 | char *opt, *param, *kwd, *val, ibuf[SS_BUFSIZE]; |
652 | devices_list *device, *tmpd; | |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
653 | int i, rc, rlen, ival; |
174 | 654 | uuid_t uu; |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
655 | |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
656 | opt = strtok(buf, " \0"); |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
657 | opt = strtok(NULL, " \0"); |
174 | 658 | |
659 | if (opt == NULL) { | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
660 | srv_send((char *)"501 Subcommand missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
661 | return 0; |
174 | 662 | } |
663 | param = strtok(NULL, "\0"); | |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
664 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
665 | if (strcmp(opt, (char *)"HELP") == 0) { |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
666 | srv_send((char *)"100 Help text follows:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
667 | srv_send((char *)"Recognized commands:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
668 | srv_send((char *)"DEVICE ADD type Add device (RC433/DHT/I2C/SPI)"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
669 | srv_send((char *)"DEVICE DEL uuid Delete device by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
670 | srv_send((char *)"DEVICE LIST List all devices"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
671 | srv_send((char *)"DEVICE GET uuid Read device by uuid parameters"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
672 | srv_send((char *)"DEVICE PUT uuid Write device by uuid parameters"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
673 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
674 | return 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
675 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
676 | |
174 | 677 | if (strcmp(opt, (char *)"LIST") == 0) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
678 | srv_send((char *)"212 Devices list follows:"); |
174 | 679 | for (device = Config.devices; device; device = device->next) { |
345
9894b559441c
Added device direction and value in devices maintenance screen
Michiel Broek <mbroek@mbse.eu>
parents:
344
diff
changeset
|
680 | srv_send((char *)"%s,%s,%d,%d,%s,%s,%d", device->uuid, device->address, device->subdevice, |
9894b559441c
Added device direction and value in devices maintenance screen
Michiel Broek <mbroek@mbse.eu>
parents:
344
diff
changeset
|
681 | device->inuse, device->comment, DEVDIR[device->direction], device->value + device->offset); |
174 | 682 | } |
683 | srv_send((char *)"."); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
684 | return 0; |
174 | 685 | } |
686 | ||
687 | if (param == NULL) { | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
688 | srv_send((char *)"502 Parameter missing"); |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
689 | return 1; |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
690 | } |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
691 | |
174 | 692 | if (strcmp(opt, (char *)"ADD") == 0) { |
693 | if ((strcmp(param, (char *)"RC433") == 0) || (strcmp(param, (char *)"DHT") == 0) || | |
694 | (strcmp(param, (char *)"I2C") == 0) || (strcmp(param, (char *)"SPI") == 0)) { | |
170 | 695 | |
174 | 696 | device = (devices_list *)malloc(sizeof(devices_list)); |
697 | device->next = NULL; | |
698 | device->version = 1; | |
699 | device->uuid = malloc(37); | |
700 | uuid_generate(uu); | |
701 | uuid_unparse(uu, device->uuid); | |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
702 | for (i = 0; i < 8; i++) { |
174 | 703 | if (strcmp(param, DEVTYPE[i]) == 0) { |
704 | device->type = i; | |
705 | break; | |
706 | } | |
707 | } | |
708 | device->direction = DEVDIR_UNDEF; | |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
709 | device->value = device->offset = device->subdevice = device->inuse = 0; |
174 | 710 | device->present = DEVPRESENT_UNDEF; |
711 | device->address = xstrcpy((char *)"Enter address here"); | |
712 | device->gpiopin = -1; | |
713 | device->description = xstrcpy((char *)"Describe me here"); | |
714 | device->comment = xstrcpy((char *)"Comment here"); | |
170 | 715 | |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
716 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
717 | piLock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
718 | #endif |
174 | 719 | if (Config.devices == NULL) { |
720 | Config.devices = device; | |
721 | } else { | |
722 | for (tmpd = Config.devices; tmpd; tmpd = tmpd->next) { | |
723 | if (tmpd->next == NULL) { | |
724 | tmpd->next = device; | |
725 | break; | |
726 | } | |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
727 | } |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
728 | } |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
729 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
730 | piUnlock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
731 | #endif |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
732 | syslog(LOG_NOTICE, "Device %s added", device->uuid); |
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
733 | srv_send((char *)"211 Device %s added", device->uuid); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
734 | return 1; |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
735 | |
174 | 736 | } else { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
737 | srv_send((char *)"503 Parameter error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
738 | return 0; |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
739 | } |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
740 | } |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
741 | |
174 | 742 | if (strcmp(opt, (char *)"DEL") == 0) { |
743 | ||
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
744 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
745 | piLock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
746 | #endif |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
747 | rc = delete_Device(param); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
748 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
749 | piUnlock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
750 | #endif |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
751 | if (rc) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
752 | syslog(LOG_NOTICE, "Device %s deleted", param); |
174 | 753 | srv_send((char *)"211 Device %s deleted", param); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
754 | return 1; |
174 | 755 | } else { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
756 | srv_send((char *)"440 No such device"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
757 | return 0; |
174 | 758 | } |
759 | } | |
760 | ||
761 | if (strcmp(opt, (char *)"GET") == 0) { | |
762 | for (device = Config.devices; device; device = device->next) { | |
763 | if (strcmp(device->uuid, param) == 0) { | |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
764 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
765 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
766 | #endif |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
767 | int my_value = device->value; |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
768 | int my_timestamp = (int)device->timestamp; |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
769 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
770 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
771 | #endif |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
772 | srv_send((char *)"213 Device record follows:"); |
174 | 773 | srv_send((char *)"TYPE,%s", DEVTYPE[device->type]); |
344
acd840c9fcc0
Fixed Offset label in device editor. Added code to edit pin states for DS2408 and DS2413 1-wire devices.
Michiel Broek <mbroek@mbse.eu>
parents:
331
diff
changeset
|
774 | srv_send((char *)"ADDRESS,%s", device->address); |
174 | 775 | srv_send((char *)"DIRECTION,%s", DEVDIR[device->direction]); |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
776 | srv_send((char *)"VALUE,%d", my_value); |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
777 | srv_send((char *)"OFFSET,%d", device->offset); |
174 | 778 | srv_send((char *)"PRESENT,%s", DEVPRESENT[device->present]); |
779 | srv_send((char *)"SUBDEVICE,%d", device->subdevice); | |
780 | srv_send((char *)"GPIOPIN,%d", device->gpiopin); | |
781 | srv_send((char *)"DESCRIPTION,%s", device->description); | |
782 | srv_send((char *)"INUSE,%d", device->inuse); | |
783 | srv_send((char *)"COMMENT,%s", device->comment); | |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
784 | srv_send((char *)"TIMESTAMP,%d", my_timestamp); |
174 | 785 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
786 | return 0; |
174 | 787 | } |
788 | } | |
789 | srv_send((char *)"440 No such device"); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
790 | return 0; |
174 | 791 | } |
792 | ||
793 | if (strcmp(opt, (char *)"PUT") == 0) { | |
794 | for (device = Config.devices; device; device = device->next) { | |
795 | if (strcmp(device->uuid, param) == 0) { | |
796 | while (1) { | |
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:
358
diff
changeset
|
797 | rlen = srv_recv(ibuf); |
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:
358
diff
changeset
|
798 | if (rlen == -1) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
799 | return 0; |
174 | 800 | } |
801 | if (strlen(ibuf)) { | |
802 | if (strcmp(ibuf, (char *)".") == 0) { | |
803 | srv_send((char *)"219 Accepted Device record"); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
804 | return 1; |
174 | 805 | } |
806 | kwd = strtok(ibuf, ",\0"); | |
807 | val = strtok(NULL, "\0"); | |
808 | if (kwd && val) { | |
809 | if (strcmp(kwd, (char *)"TYPE") == 0) { | |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
810 | for (i = 0; i < 8; i++) { |
174 | 811 | if (strcmp(val, DEVTYPE[i]) == 0) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
812 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
813 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
814 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
815 | if (device->type != i) |
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
816 | syslog(LOG_NOTICE, "Device %s changed type %s to %s", device->uuid, DEVTYPE[device->type], DEVTYPE[i]); |
174 | 817 | device->type = i; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
818 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
819 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
820 | #endif |
174 | 821 | break; |
822 | } | |
823 | } | |
824 | ||
825 | } else if (strcmp(kwd, (char *)"DIRECTION") == 0) { | |
826 | for (i = 0; i < 7; i++) { | |
827 | if (strcmp(val, DEVDIR[i]) == 0) { | |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
828 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
829 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
830 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
831 | if (device->direction != i) |
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
832 | syslog(LOG_NOTICE, "Device %s changed direction %s to %s", device->uuid, DEVDIR[device->type], DEVDIR[i]); |
174 | 833 | device->direction = i; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
834 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
835 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
836 | #endif |
174 | 837 | break; |
838 | } | |
839 | } | |
840 | ||
841 | } else if (strcmp(kwd, (char *)"VALUE") == 0) { | |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
842 | if (sscanf(val, "%d", &ival) == 1) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
843 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
844 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
845 | #endif |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
846 | if (device->value != ival) |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
847 | syslog(LOG_NOTICE, "Device %s changed value %d to %d", device->uuid, device->value, ival); |
174 | 848 | device->value = ival; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
849 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
850 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
851 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
852 | } |
174 | 853 | |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
854 | } else if (strcmp(kwd, (char *)"OFFSET") == 0) { |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
855 | if (sscanf(val, "%d", &ival) == 1) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
856 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
857 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
858 | #endif |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
859 | if (device->offset != ival) |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
860 | syslog(LOG_NOTICE, "Device %s changed offset %d to %d", device->uuid, device->offset, ival); |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
861 | device->offset = ival; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
862 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
863 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
864 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
865 | } |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
866 | |
174 | 867 | } else if (strcmp(kwd, (char *)"PRESENT") == 0) { |
868 | for (i = 0; i < 4; i++) { | |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
869 | if (strcmp(val, DEVPRESENT[i]) == 0) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
870 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
871 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
872 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
873 | if (device->present != i) |
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
874 | syslog(LOG_NOTICE, "Device %s changed present %s to %s", device->uuid, DEVPRESENT[device->present], DEVPRESENT[i]); |
174 | 875 | device->present = i; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
876 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
877 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
878 | #endif |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
879 | break; |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
880 | } |
174 | 881 | } |
882 | ||
883 | } else if (strcmp(kwd, (char *)"ADDRESS") == 0) { | |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
884 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
885 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
886 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
887 | if (device->address) { |
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
888 | if (strcmp(device->address, val)) |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
889 | syslog(LOG_NOTICE, "Device %s changed address `%s' to `%s'", device->uuid, device->address, val); |
174 | 890 | free(device->address); |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
891 | } |
174 | 892 | device->address = xstrcpy(val); |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
893 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
894 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
895 | #endif |
174 | 896 | |
897 | } else if (strcmp(kwd, (char *)"SUBDEVICE") == 0) { | |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
898 | if (sscanf(val, "%d", &ival) == 1) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
899 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
900 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
901 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
902 | if (device->subdevice != ival) |
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
903 | syslog(LOG_NOTICE, "Device %s changed subdevice %d to %d", device->uuid, device->subdevice, ival); |
174 | 904 | device->subdevice = ival; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
905 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
906 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
907 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
908 | } |
174 | 909 | |
910 | } else if (strcmp(kwd, (char *)"GPIOPIN") == 0) { | |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
911 | if (sscanf(val, "%d", &ival) == 1) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
912 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
913 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
914 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
915 | if (device->gpiopin != ival) |
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
916 | syslog(LOG_NOTICE, "Device %s changed gpiopin %d to %d", device->uuid, device->gpiopin, ival); |
174 | 917 | device->gpiopin = ival; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
918 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
919 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
920 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
921 | } |
174 | 922 | |
923 | } else if (strcmp(kwd, (char *)"DESCRIPTION") == 0) { | |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
924 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
925 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
926 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
927 | if (device->description) { |
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
928 | if (strcmp(device->description, val)) |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
929 | syslog(LOG_NOTICE, "Device %s changed description `%s' to `%s'", device->uuid, device->description, val); |
174 | 930 | free(device->description); |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
931 | } |
174 | 932 | device->description = xstrcpy(val); |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
933 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
934 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
935 | #endif |
174 | 936 | |
937 | } else if (strcmp(kwd, (char *)"COMMENT") == 0) { | |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
938 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
939 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
940 | #endif |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
941 | if (device->comment) { |
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
942 | if (strcmp(device->comment, val)) |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
943 | syslog(LOG_NOTICE, "Device %s changed comment `%s' to `%s'", device->uuid, device->comment, val); |
174 | 944 | free(device->comment); |
276
a19cc3770f09
Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.
Michiel Broek <mbroek@mbse.eu>
parents:
274
diff
changeset
|
945 | } |
174 | 946 | device->comment = xstrcpy(val); |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
947 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
948 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
949 | #endif |
174 | 950 | |
951 | } | |
952 | } | |
953 | } | |
954 | } | |
955 | } | |
956 | } | |
957 | srv_send((char *)"440 No such device"); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
958 | return 0; |
174 | 959 | } |
960 | ||
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
961 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
962 | return 0; |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
963 | } |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
964 | |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
965 | |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
966 | |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
967 | /* |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
968 | * GLOBAL GET |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
969 | * GLOBAL PUT |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
970 | */ |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
971 | int cmd_global(char *buf) |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
972 | { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
973 | char *opt, *kwd, *val, ibuf[SS_BUFSIZE]; |
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:
358
diff
changeset
|
974 | int ival, rlen; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
975 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
976 | opt = strtok(buf, " \0"); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
977 | opt = strtok(NULL, "\0"); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
978 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
979 | if (opt == NULL) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
980 | srv_send((char *)"501 Subcommand missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
981 | return 0; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
982 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
983 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
984 | if (strcmp(opt, (char *)"HELP") == 0) { |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
985 | srv_send((char *)"100 Help text follows:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
986 | srv_send((char *)"Recognized commands:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
987 | srv_send((char *)"GLOBAL GET Get global settings"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
988 | srv_send((char *)"GLOBAL PUT Put global settings"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
989 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
990 | return 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
991 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
992 | |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
993 | if (strcmp(opt, (char *)"GET") == 0) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
994 | srv_send((char *)"213 Global Settings record follows:"); |
269
dc88583a068d
All web screens now show the program name and version
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
995 | srv_send((char *)"RELEASE,%s", VERSION); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
996 | srv_send((char *)"NAME,%s", Config.name); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
997 | srv_send((char *)"PORT,%d", Config.my_port); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
998 | srv_send((char *)"TEMPFORMAT,%c", Config.tempFormat); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
999 | srv_send((char *)"TEMP_ADDRESS,%s", Config.temp_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1000 | srv_send((char *)"TEMP_STATE,%s", TEMPSTATE[Config.temp_state]); |
208
934d45d9751d
Added room temperature and humidity to the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
206
diff
changeset
|
1001 | srv_send((char *)"TEMP_VALUE,%.1f", Config.temp_value / 1000.0); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1002 | srv_send((char *)"HUM_ADDRESS,%s", Config.hum_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1003 | srv_send((char *)"HUM_STATE,%s", TEMPSTATE[Config.hum_state]); |
208
934d45d9751d
Added room temperature and humidity to the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
206
diff
changeset
|
1004 | srv_send((char *)"HUM_VALUE,%.0f", Config.hum_value / 1000.0); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1005 | #ifdef HAVE_WIRINGPI_H |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1006 | srv_send((char *)"LCD_COLS,%d", Config.lcd_cols); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1007 | srv_send((char *)"LCD_ROWS,%d", Config.lcd_rows); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1008 | #endif |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1009 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1010 | return 0; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1011 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1012 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1013 | if (strcmp(opt, (char *)"PUT") == 0) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1014 | while (1) { |
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:
358
diff
changeset
|
1015 | rlen = srv_recv(ibuf); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1016 | if (rlen == -1) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1017 | return 0; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1018 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1019 | if (strlen(ibuf)) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1020 | if (strcmp(ibuf, (char *)".") == 0) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1021 | srv_send((char *)"219 Accepted Global record"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1022 | return 1; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1023 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1024 | kwd = strtok(ibuf, ",\0"); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1025 | val = strtok(NULL, "\0"); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1026 | if (kwd) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1027 | if (strcmp(kwd, (char *)"NAME") == 0) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1028 | if (val && Config.name && strcmp(val, Config.name)) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1029 | syslog(LOG_NOTICE, "Global name `%s' to `%s'", Config.name, val); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1030 | if (Config.name) |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1031 | free(Config.name); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1032 | if (val) |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1033 | Config.name = xstrcpy(val); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1034 | else |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1035 | Config.name = NULL; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1036 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1037 | } else if (val && (strcmp(kwd, (char *)"PORT") == 0)) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1038 | if (sscanf(val, "%d", &ival) == 1) { |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1039 | if (Config.my_port != ival) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1040 | syslog(LOG_NOTICE, "Global port %d to %d", Config.my_port, ival); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1041 | Config.my_port = ival; |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1042 | } |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1043 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1044 | } else if (val && (strcmp(kwd, (char *)"TEMPFORMAT") == 0)) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1045 | if ((val[0] == 'C') || (val[0] == 'F')) { |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1046 | if (Config.tempFormat != val[0]) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1047 | syslog(LOG_NOTICE, "Global port %c to %c", Config.tempFormat, val[0]); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1048 | Config.tempFormat = val[0]; |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1049 | } |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1050 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1051 | } else if (strcmp(kwd, (char *)"TEMP_ADDRESS") == 0) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1052 | if (val && Config.temp_address && (strcmp(val, Config.temp_address))) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1053 | syslog(LOG_NOTICE, "Global temperature address `%s' to `%s'", Config.temp_address, val); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1054 | if (Config.temp_address) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1055 | device_count(FALSE, Config.temp_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1056 | free(Config.temp_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1057 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1058 | if (val) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1059 | Config.temp_address = xstrcpy(val); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1060 | device_count(TRUE, Config.temp_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1061 | } else |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1062 | Config.temp_address = NULL; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1063 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1064 | } else if (strcmp(kwd, (char *)"HUM_ADDRESS") == 0) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1065 | if (val && Config.hum_address && (strcmp(val, Config.hum_address))) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1066 | syslog(LOG_NOTICE, "Global humidity address `%s' to `%s'", Config.hum_address, val); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1067 | if (Config.hum_address) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1068 | device_count(FALSE, Config.hum_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1069 | free(Config.hum_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1070 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1071 | if (val) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1072 | Config.hum_address = xstrcpy(val); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1073 | device_count(TRUE, Config.hum_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1074 | } else |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1075 | Config.hum_address = NULL; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1076 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1077 | #ifdef HAVE_WIRINGPI_H |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1078 | } else if (val && (strcmp(kwd, (char *)"LCD_COLS") == 0)) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1079 | if (sscanf(val, "%d", &ival) == 1) { |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1080 | if (Config.lcd_cols != ival) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1081 | syslog(LOG_NOTICE, "Global LCD columns %d to %d", Config.lcd_cols, ival); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1082 | Config.lcd_cols = ival; |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1083 | } |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1084 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1085 | } else if (val && (strcmp(kwd, (char *)"LCD_ROWS") == 0)) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1086 | if (sscanf(val, "%d", &ival) == 1) { |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1087 | if (Config.lcd_rows != ival) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1088 | syslog(LOG_NOTICE, "Global LCD rows %d to %d", Config.lcd_rows, ival); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1089 | Config.lcd_rows = ival; |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1090 | } |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1091 | #endif |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1092 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1093 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1094 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1095 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1096 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1097 | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1098 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1099 | return 0; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1100 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1101 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1102 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1103 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1104 | /* |
81 | 1105 | * LIST |
120 | 1106 | * LIST LOG |
81 | 1107 | */ |
1108 | int cmd_list(char *buf) | |
1109 | { | |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1110 | char *opt, *param, *filename, q[5], hr[3], buffer[256], outbuf[256]; |
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:
390
diff
changeset
|
1111 | char *date_n, *mode_n, *air_n, *beer_n, *target_lo_n, *target_hi_n, *heater_n, *cooler_n, *room_n; |
299
d1c52fb43e30
Show heater/cooler usgae in percent on the web page. Bunped to version 0.2.5
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1112 | char *heater_u, *cooler_u; |
300
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1113 | int heater_l = 0, cooler_l = 0, h = 0, c = 0, heat_used = 0, cool_used = 0, lines = 0, graphstep = 0; |
84 | 1114 | units_list *unit; |
120 | 1115 | FILE *fp; |
358
8b7ef338bf49
Plot room temperature on the dashboard.
Michiel Broek <mbroek@mbse.eu>
parents:
356
diff
changeset
|
1116 | float room_t; |
81 | 1117 | |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1118 | opt = strtok(buf, " \0"); |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1119 | opt = strtok(NULL, " \0"); |
84 | 1120 | |
81 | 1121 | if (opt == NULL) { |
92 | 1122 | /* |
1123 | * Default, list available units | |
1124 | */ | |
81 | 1125 | srv_send((char *)"212 Fermenter list follows:"); |
1126 | for (unit = Config.units; unit; unit = unit->next) { | |
131
528dc0bb81ab
Always use uuid to select units and remove numeric record id's.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
1127 | srv_send((char *)"%s,%s,%s", unit->uuid, unit->name, UNITMODE[unit->mode]); |
81 | 1128 | } |
1129 | srv_send((char *)"."); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1130 | return 0; |
92 | 1131 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1132 | } else if (strcmp(opt, (char *)"HELP") == 0) { |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1133 | srv_send((char *)"100 Help text follows:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1134 | srv_send((char *)"Recognized commands:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1135 | srv_send((char *)"LIST List available units"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1136 | srv_send((char *)"LIST LOG uuid List logfile of unit by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1137 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1138 | return 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1139 | |
120 | 1140 | } else if (strcmp(opt, (char *)"LOG") == 0) { |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1141 | |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1142 | param = strtok(NULL, "\0"); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1143 | if (param == NULL) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1144 | srv_send((char *)"502 Parameter missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1145 | return 0; |
120 | 1146 | } |
1147 | ||
266
07819a7ad3c1
Better log output for web graphs. Webgraphs can now display heater and cooler usage.
Michiel Broek <mbroek@mbse.eu>
parents:
264
diff
changeset
|
1148 | q[0] = q[1] = q[2] = q[3] = q[4] = 'a'; |
120 | 1149 | for (unit = Config.units; unit; unit = unit->next) { |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1150 | if (strcmp(param, unit->uuid) == 0) |
120 | 1151 | break; |
1152 | } | |
1153 | ||
1154 | srv_send((char *)"212 Logfile list follows:"); | |
1155 | if (getenv((char *)"USER") == NULL) { | |
1156 | filename = xstrcpy((char *)"/root"); | |
1157 | } else { | |
1158 | filename = xstrcpy(getenv((char *)"HOME")); | |
1159 | } | |
1160 | filename = xstrcat(filename, (char *)"/.thermferm/log/"); | |
1161 | filename = xstrcat(filename, unit->name); | |
1162 | filename = xstrcat(filename, (char *)".log"); | |
1163 | if ((fp = fopen(filename, "r"))) { | |
300
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1164 | |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1165 | /* |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1166 | * Count the lines in the logfile |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1167 | */ |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1168 | lines = 0; |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1169 | while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1170 | lines++; |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1171 | } |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1172 | fseek(fp, 0L, SEEK_SET); |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1173 | /* |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1174 | * We have counted the lines in the logfile including the header lines. |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1175 | * The header lines should be ignored but there are so few of them, we |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1176 | * just include them in the total. |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1177 | * Now find a reasonable interval of lines to sent to the client. |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1178 | */ |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1179 | for (graphstep = 1; graphstep <= MAX_INTERVALS; graphstep++) { |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1180 | if (lines < GRAPH_DATALINES[graphstep]) { |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1181 | break; |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1182 | } |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1183 | } |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1184 | if (graphstep > MAX_INTERVALS) |
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1185 | graphstep = MAX_INTERVALS; |
300
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1186 | syslog(LOG_NOTICE, "LIST LOG %s: lines=%d, interval=%d, graphstep=%d", unit->name, lines, GRAPH_INTERVAL[graphstep], graphstep); |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1187 | |
120 | 1188 | while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { |
299
d1c52fb43e30
Show heater/cooler usgae in percent on the web page. Bunped to version 0.2.5
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1189 | /* |
d1c52fb43e30
Show heater/cooler usgae in percent on the web page. Bunped to version 0.2.5
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1190 | * 2014-11-15 18:39,BEER,20.312,19.750,20.0,0,NA,NA,NA,78105,NA,NA |
d1c52fb43e30
Show heater/cooler usgae in percent on the web page. Bunped to version 0.2.5
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1191 | */ |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1192 | hr[0] = q[0] = buffer[11]; |
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1193 | hr[1] = q[1] = buffer[12]; |
300
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1194 | q[2] = buffer[14]; |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1195 | q[3] = buffer[15]; |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1196 | hr[2] = '\0'; |
120 | 1197 | buffer[strlen(buffer) -1] = '\0'; |
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:
390
diff
changeset
|
1198 | date_n = strtok(buffer, ",\0"); /* timestamp */ |
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:
390
diff
changeset
|
1199 | mode_n = strtok(NULL, ",\0"); /* unit mode */ |
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:
390
diff
changeset
|
1200 | air_n = strtok(NULL, ",\0"); /* air temp */ |
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:
390
diff
changeset
|
1201 | beer_n = strtok(NULL, ",\0"); /* beer temp */ |
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:
390
diff
changeset
|
1202 | target_lo_n = strtok(NULL, ",\0"); /* target low temp */ |
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:
390
diff
changeset
|
1203 | heater_n = strtok(NULL, ",\0"); /* current heater state */ |
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:
390
diff
changeset
|
1204 | cooler_n = strtok(NULL, ",\0"); /* current cooler state */ |
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:
390
diff
changeset
|
1205 | heater_u = strtok(NULL, ",\0"); /* current fan state */ |
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:
390
diff
changeset
|
1206 | heater_u = strtok(NULL, ",\0"); /* current door state */ |
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:
390
diff
changeset
|
1207 | heater_u = strtok(NULL, ",\0"); /* heater use counter */ |
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:
390
diff
changeset
|
1208 | cooler_u = strtok(NULL, ",\0"); /* cooler use counter */ |
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:
390
diff
changeset
|
1209 | room_n = strtok(NULL, ",\0"); /* fan use counter */ |
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:
390
diff
changeset
|
1210 | room_n = strtok(NULL, ",\0"); /* room temperature */ |
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:
390
diff
changeset
|
1211 | target_hi_n = strtok(NULL, ",\0"); /* target high temp */ |
264
91c358556ecf
LIST LOG also output lines on state changes
Michiel Broek <mbroek@mbse.eu>
parents:
261
diff
changeset
|
1212 | |
91c358556ecf
LIST LOG also output lines on state changes
Michiel Broek <mbroek@mbse.eu>
parents:
261
diff
changeset
|
1213 | if (strncmp(mode_n, (char *)"Mode", 4)) { |
266
07819a7ad3c1
Better log output for web graphs. Webgraphs can now display heater and cooler usage.
Michiel Broek <mbroek@mbse.eu>
parents:
264
diff
changeset
|
1214 | /* |
300
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1215 | * Output a line at the right intervals |
266
07819a7ad3c1
Better log output for web graphs. Webgraphs can now display heater and cooler usage.
Michiel Broek <mbroek@mbse.eu>
parents:
264
diff
changeset
|
1216 | */ |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1217 | int hour = atoi(hr); |
300
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1218 | if (((graphstep == 1)) || |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1219 | ((graphstep == 2) && (q[3] == '0' || q[3] == '5')) || |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1220 | ((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'))) || |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1221 | ((graphstep == 4) && ((q[2] == '0' && q[3] == '0') || (q[2] == '3' && q[3] == '0'))) || |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1222 | ((graphstep == 5) && (q[2] == '0' && q[3] == '0')) || |
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1223 | ((graphstep == 6) && (hour % 2 == 0) && (q[2] == '0' && q[3] == '0')) || /* 120 minutes */ |
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1224 | ((graphstep == 7) && (hour % 4 == 0) && (q[2] == '0' && q[3] == '0')) || /* 240 minutes */ |
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
1225 | ((graphstep >= 8) && (hour % 8 == 0) && (q[2] == '0' && q[3] == '0')) ) { /* 480 minutes */ |
300
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1226 | heat_used = cool_used = 0; |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1227 | if (strcmp(heater_u, "NA") && (sscanf(heater_u, "%d", &h) == 1)) { |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1228 | if (h && heater_l) { |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1229 | heat_used = ((h - heater_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); |
299
d1c52fb43e30
Show heater/cooler usgae in percent on the web page. Bunped to version 0.2.5
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1230 | } |
300
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1231 | } |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1232 | if (strcmp(cooler_u, "NA") && (sscanf(cooler_u, "%d", &c) == 1)) { |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1233 | if (c && cooler_l) { |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1234 | cool_used = ((c - cooler_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); |
299
d1c52fb43e30
Show heater/cooler usgae in percent on the web page. Bunped to version 0.2.5
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1235 | } |
300
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1236 | } |
358
8b7ef338bf49
Plot room temperature on the dashboard.
Michiel Broek <mbroek@mbse.eu>
parents:
356
diff
changeset
|
1237 | if (room_n) |
8b7ef338bf49
Plot room temperature on the dashboard.
Michiel Broek <mbroek@mbse.eu>
parents:
356
diff
changeset
|
1238 | sscanf(room_n, "%f", &room_t); |
8b7ef338bf49
Plot room temperature on the dashboard.
Michiel Broek <mbroek@mbse.eu>
parents:
356
diff
changeset
|
1239 | else |
8b7ef338bf49
Plot room temperature on the dashboard.
Michiel Broek <mbroek@mbse.eu>
parents:
356
diff
changeset
|
1240 | room_t = 0.0; |
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:
390
diff
changeset
|
1241 | if (target_hi_n == NULL) |
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:
390
diff
changeset
|
1242 | target_hi_n = target_lo_n; |
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:
390
diff
changeset
|
1243 | snprintf(outbuf, 255, "%s,%s,%s,%s,%s,%s,%s,%d,%d,%.1f,%s", |
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:
390
diff
changeset
|
1244 | date_n, mode_n, air_n, beer_n, target_lo_n, heater_n, cooler_n, heat_used, cool_used, room_t, target_hi_n); |
300
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1245 | srv_send(outbuf); |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1246 | if (h && strcmp(heater_u, "NA")) |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1247 | heater_l = h; |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1248 | if (c & strcmp(cooler_u, "NA")) |
4ce46ff3e37d
The LIST LOG command now automatic adjusts the number of output lines and resolution by calculating a reasonable interval between 1 and 60 minutes. Bumped to version 0.2.6
Michiel Broek <mbroek@mbse.eu>
parents:
299
diff
changeset
|
1249 | cooler_l = c; |
120 | 1250 | } |
266
07819a7ad3c1
Better log output for web graphs. Webgraphs can now display heater and cooler usage.
Michiel Broek <mbroek@mbse.eu>
parents:
264
diff
changeset
|
1251 | } |
120 | 1252 | } |
1253 | } | |
1254 | free(filename); | |
1255 | filename = NULL; | |
1256 | srv_send((char *)"."); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1257 | return 0; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1258 | } |
120 | 1259 | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1260 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1261 | return 0; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1262 | } |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1263 | |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1264 | |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1265 | |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1266 | /* |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1267 | * PROFILE ADD name Add a new profile |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1268 | * PROFILE DEL uuid Delete profile with uuid |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1269 | * PROFILE LIST List available profiles |
258
e02393b29733
Updated web dashboard layout
Michiel Broek <mbroek@mbse.eu>
parents:
249
diff
changeset
|
1270 | * PROFILE GET uuid Get profile record |
e02393b29733
Updated web dashboard layout
Michiel Broek <mbroek@mbse.eu>
parents:
249
diff
changeset
|
1271 | * PROFILE PUT uuid Put profile record |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1272 | * PROFILE GETS uuid Get profile steps list |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1273 | * PROFILE PUTS uuid Put profile steps list |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1274 | */ |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1275 | int cmd_profile(char *buf) |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1276 | { |
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:
390
diff
changeset
|
1277 | char ibuf[SS_BUFSIZE], *sstep, *rest, *tlarg, *tharg, *frarg, *param, *kwd, *val; |
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:
390
diff
changeset
|
1278 | int j, ival, rlen, istep, irest, ifrarg; |
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:
390
diff
changeset
|
1279 | float ftlarg, ftharg, fval; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1280 | char *opt; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1281 | profiles_list *profile, *tmpp; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1282 | prof_step *step, *olds; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1283 | uuid_t uu; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1284 | |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1285 | opt = strtok(buf, " \0"); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1286 | opt = strtok(NULL, " \0"); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1287 | |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1288 | if (opt == NULL) { |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1289 | srv_send((char *)"501 Subcommand missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1290 | return 0; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1291 | } |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1292 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1293 | if (strcmp(opt, (char *)"HELP") == 0) { |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1294 | srv_send((char *)"100 Help text follows:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1295 | srv_send((char *)"Recognized commands:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1296 | srv_send((char *)"PROFILE uuid,name Profile rename"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1297 | srv_send((char *)"PROFILE ADD name Add new Profile with name"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1298 | srv_send((char *)"PROFILE DEL uuid Delete Profile by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1299 | srv_send((char *)"PROFILE LIST List available profiles"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1300 | srv_send((char *)"PROFILE GET uuid Get Profile record by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1301 | srv_send((char *)"PROFILE PUT uuid Put Profile record by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1302 | srv_send((char *)"PROFILE GETS uuid Profile get steps list"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1303 | srv_send((char *)"PROFILE PUTS uuid Profile put steps list"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1304 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1305 | return 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1306 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1307 | |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1308 | if (strcmp(opt, (char *)"LIST") == 0) { |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
85
diff
changeset
|
1309 | /* |
92 | 1310 | * Fermenting profiles |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
85
diff
changeset
|
1311 | */ |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1312 | srv_send((char *)"212 Profiles list follows:"); |
92 | 1313 | for (profile = Config.profiles; profile; profile = profile->next) { |
124
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
120
diff
changeset
|
1314 | j = 0; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
120
diff
changeset
|
1315 | for (step = profile->steps; step; step = step->next) |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
120
diff
changeset
|
1316 | j++; |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
1317 | srv_send((char *)"%s,%s,%d,%d", profile->uuid, profile->name, j, profile->busy); |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
85
diff
changeset
|
1318 | } |
92 | 1319 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1320 | return 0; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1321 | } |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1322 | |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1323 | param = strtok(NULL, "\0"); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1324 | if (param == NULL) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1325 | srv_send((char *)"502 Parameter missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1326 | return 0; |
81 | 1327 | } |
1328 | ||
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1329 | if (strcmp(opt, (char *)"ADD") == 0) { |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1330 | profile = (profiles_list *)malloc(sizeof(profiles_list)); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1331 | profile->next = NULL; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1332 | profile->version = 1; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1333 | profile->uuid = malloc(37); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1334 | uuid_generate(uu); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1335 | uuid_unparse(uu, profile->uuid); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1336 | profile->name = xstrcpy(param); |
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:
390
diff
changeset
|
1337 | profile->busy = profile->fridge_mode = 0; |
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:
390
diff
changeset
|
1338 | profile->inittemp_lo = 19.8; |
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:
390
diff
changeset
|
1339 | profile->inittemp_hi = 20.2; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1340 | profile->steps = NULL; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1341 | if (Config.profiles == NULL) { |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1342 | Config.profiles = profile; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1343 | } else { |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1344 | for (tmpp = Config.profiles; tmpp; tmpp = tmpp->next) { |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1345 | if (tmpp->next == NULL) { |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1346 | tmpp->next = profile; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1347 | break; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1348 | } |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1349 | } |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1350 | } |
81 | 1351 | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1352 | syslog(LOG_NOTICE, "Profile %s added", profile->uuid); |
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1353 | srv_send((char *)"211 Profile %s added", profile->uuid); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1354 | return 1; |
81 | 1355 | |
1356 | ||
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1357 | } else if (strcmp(opt, (char *)"DEL") == 0) { |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1358 | if (delete_Profile(param)) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1359 | syslog(LOG_NOTICE, "Profile %s deleted", param); |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1360 | srv_send((char *)"211 Profile %s deleted", param); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1361 | return 1; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1362 | } else { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1363 | srv_send((char *)"440 No such profile"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1364 | return 0; |
132
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
1365 | } |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1366 | |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1367 | } else if (strcmp(opt, (char *)"GET") == 0) { |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1368 | for (profile = Config.profiles; profile; profile = profile->next) { |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1369 | if (strcmp(profile->uuid, param) == 0) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1370 | srv_send((char *)"213 Profile record follows:"); |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1371 | srv_send((char *)"UUID,%s", profile->uuid); |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1372 | srv_send((char *)"NAME,%s", profile->name); |
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:
390
diff
changeset
|
1373 | srv_send((char *)"INITTEMP_LO,%.1f", profile->inittemp_lo); |
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:
390
diff
changeset
|
1374 | srv_send((char *)"INITTEMP_HI,%.1f", profile->inittemp_hi); |
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:
390
diff
changeset
|
1375 | srv_send((char *)"FRIDGE_MODE,%d", profile->fridge_mode); |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1376 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1377 | return 0; |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1378 | } |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1379 | } |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1380 | srv_send((char *)"440 No such profile"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1381 | return 0; |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1382 | |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1383 | } else if (strcmp(opt, (char *)"PUT") == 0) { |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1384 | for (profile = Config.profiles; profile; profile = profile->next) { |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1385 | if (strcmp(profile->uuid, param) == 0) { |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1386 | while (1) { |
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:
358
diff
changeset
|
1387 | rlen = srv_recv(ibuf); |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1388 | if (rlen == -1) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1389 | return 0; |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1390 | } |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1391 | if (strlen(ibuf)) { |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1392 | if (strcmp(ibuf, (char *)".") == 0) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1393 | srv_send((char *)"219 Accepted Profile record"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1394 | return 1; |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1395 | } |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1396 | kwd = strtok(ibuf, ",\0"); |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1397 | val = strtok(NULL, "\0"); |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1398 | if (kwd && val) { |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1399 | if (strcmp(kwd, (char *)"NAME") == 0) { |
279
4c505414435c
PROFILE PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1400 | if (profile->name) { |
4c505414435c
PROFILE PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1401 | if (strcmp(profile->name, val)) |
4c505414435c
PROFILE PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1402 | syslog(LOG_NOTICE, "Profile %s name `%s' to `%s'", profile->uuid, profile->name, val); |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1403 | free(profile->name); |
279
4c505414435c
PROFILE PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1404 | } |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1405 | profile->name = xstrcpy(val); |
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:
390
diff
changeset
|
1406 | } else if (strcmp(kwd, (char *)"INITTEMP_LO") == 0) { |
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:
390
diff
changeset
|
1407 | if (sscanf(val, "%f", &fval) == 1) { |
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:
390
diff
changeset
|
1408 | if (profile->inittemp_lo != fval) |
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:
390
diff
changeset
|
1409 | syslog(LOG_NOTICE, "Profile %s initial temperature low %.1f to %.1f", profile->uuid, profile->inittemp_lo, fval); |
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:
390
diff
changeset
|
1410 | profile->inittemp_lo = fval; |
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:
390
diff
changeset
|
1411 | } |
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:
390
diff
changeset
|
1412 | } else if (strcmp(kwd, (char *)"INITTEMP_HI") == 0) { |
279
4c505414435c
PROFILE PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1413 | if (sscanf(val, "%f", &fval) == 1) { |
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:
390
diff
changeset
|
1414 | if (profile->inittemp_hi != fval) |
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:
390
diff
changeset
|
1415 | syslog(LOG_NOTICE, "Profile %s initial temperature high %.1f to %.1f", profile->uuid, profile->inittemp_hi, fval); |
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:
390
diff
changeset
|
1416 | profile->inittemp_hi = fval; |
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:
390
diff
changeset
|
1417 | } |
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:
390
diff
changeset
|
1418 | } else if (strcmp(kwd, (char *)"FRIDGE_MODE") == 0) { |
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:
390
diff
changeset
|
1419 | if (sscanf(val, "%d", &ival) == 1) { |
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:
390
diff
changeset
|
1420 | if (profile->fridge_mode != ival) |
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:
390
diff
changeset
|
1421 | syslog(LOG_NOTICE, "Profile %s fridge mode %d to %d", profile->uuid, profile->fridge_mode, ival); |
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:
390
diff
changeset
|
1422 | profile->fridge_mode = ival; |
279
4c505414435c
PROFILE PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1423 | } |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1424 | } |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1425 | } |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1426 | } |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1427 | } |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1428 | } |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1429 | } |
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1430 | srv_send((char *)"440 No such profile"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1431 | return 0; |
192
5d013b4a9138
Added PROFILE GET and PROFILE PUT commands. Adjusted the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1432 | |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1433 | } else if (strcmp(opt, (char *)"GETS") == 0) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1434 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1435 | for (profile = Config.profiles; profile; profile = profile->next) { |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1436 | if (strcmp(profile->uuid, param) == 0) { |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1437 | srv_send((char *)"215 Profile steps follow:"); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1438 | for (step = profile->steps; step; step = step->next) { |
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:
390
diff
changeset
|
1439 | srv_send((char *)"%d,%d,%.1f,%.1f,%d", step->steptime, step->resttime, step->target_lo, step->target_hi, step->fridge_mode); |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1440 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1441 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1442 | return 0; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1443 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1444 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1445 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1446 | srv_send((char *)"440 No such profile"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1447 | return 0; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1448 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1449 | } else if (strcmp(opt, (char *)"PUTS") == 0) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1450 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1451 | for (profile = Config.profiles; profile; profile = profile->next) { |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1452 | if (strcmp(profile->uuid, param) == 0) { |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1453 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1454 | if (profile->steps) { |
280
de3dc781ba65
PROFILE PUTS command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
1455 | syslog(LOG_NOTICE, "PROFILE PUTS %s erased all old steps", profile->uuid); |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1456 | for (step = profile->steps; step; step = olds) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1457 | olds = step->next; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1458 | free(step); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1459 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1460 | profile->steps = NULL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1461 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1462 | |
280
de3dc781ba65
PROFILE PUTS command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
1463 | j = 0; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1464 | while (1) { |
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:
358
diff
changeset
|
1465 | rlen = srv_recv(ibuf); |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1466 | if (rlen == -1) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1467 | return 0; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1468 | } else { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1469 | if (strlen(ibuf)) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1470 | if (strcmp(ibuf, (char *)".") == 0) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1471 | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1472 | srv_send((char *)"219 Accepted Profile steps"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1473 | return 1; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1474 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1475 | sstep = strtok(ibuf, ",\0"); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1476 | rest = strtok(NULL, ",\0"); |
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:
390
diff
changeset
|
1477 | tlarg = strtok(NULL, ",\0"); |
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:
390
diff
changeset
|
1478 | tharg = strtok(NULL, ",\0"); |
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:
390
diff
changeset
|
1479 | frarg = strtok(NULL, "\0"); |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1480 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1481 | if ((sscanf(sstep, "%d", &istep) == 1) && |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1482 | (sscanf(rest, "%d", &irest) == 1) && |
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:
390
diff
changeset
|
1483 | (sscanf(tlarg, "%f", &ftlarg) == 1) && |
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:
390
diff
changeset
|
1484 | (sscanf(tharg, "%f", &ftharg) == 1) && |
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:
390
diff
changeset
|
1485 | (sscanf(frarg, "%d", &ifrarg) == 1)) { |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1486 | |
280
de3dc781ba65
PROFILE PUTS command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
1487 | j++; |
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:
390
diff
changeset
|
1488 | syslog(LOG_NOTICE, "PROFILE PUTS %s add step %d: steptime=%d resttime=%d target=%.1f..%.1f fridge_mode=%d", |
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:
390
diff
changeset
|
1489 | profile->uuid, j, istep, irest, ftlarg, ftharg, ifrarg); |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1490 | step = (prof_step *)malloc(sizeof(prof_step)); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1491 | step->next = NULL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1492 | step->version = 1; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1493 | step->steptime = istep; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1494 | step->resttime = irest; |
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:
390
diff
changeset
|
1495 | step->target_lo = ftlarg; |
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:
390
diff
changeset
|
1496 | step->target_hi = ftharg; |
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:
390
diff
changeset
|
1497 | step->fridge_mode = ifrarg; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1498 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1499 | if (profile->steps == NULL) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1500 | profile->steps = step; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1501 | } else { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1502 | for (olds = profile->steps; olds; olds = olds->next) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1503 | if (olds->next == NULL) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1504 | olds->next = step; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1505 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1506 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1507 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1508 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1509 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1510 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1511 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1512 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1513 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1514 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1515 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
138
diff
changeset
|
1516 | srv_send((char *)"440 No such profile"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1517 | return 0; |
88 | 1518 | } |
1519 | ||
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1520 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1521 | return 0; |
88 | 1522 | } |
1523 | ||
1524 | ||
1525 | ||
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1526 | #ifdef USE_SIMULATOR |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1527 | int delete_Simulator(char *uuid) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1528 | { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1529 | simulator_list *current = Config.simulators; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1530 | simulator_list *previous = NULL; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1531 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1532 | while (current) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1533 | if (strcmp(current->uuid, uuid) == 0) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1534 | if (previous == NULL) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1535 | Config.simulators = current->next; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1536 | free(current->uuid); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1537 | current->uuid = NULL; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1538 | free(current->name); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1539 | current->name = NULL; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1540 | free(current); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1541 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1542 | } else { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1543 | free(current->uuid); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1544 | current->uuid = NULL; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1545 | free(current->name); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1546 | current->name = NULL; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1547 | previous->next = current->next; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1548 | free(current); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1549 | current = previous->next; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1550 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1551 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1552 | } else { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1553 | previous = current; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1554 | current = current->next; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1555 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1556 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1557 | return 0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1558 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1559 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1560 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1561 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1562 | /* |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1563 | * SIMULATOR ADD name |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1564 | * SIMULATOR DEL uuid |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1565 | * SIMULATOR LIST |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1566 | * SIMULATOR GET uuid |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1567 | * SIMULATOR PUT uuid |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1568 | */ |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1569 | int cmd_simulator(char *buf) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1570 | { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1571 | char *opt, *param, *kwd, *val, ibuf[SS_BUFSIZE]; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1572 | simulator_list *simulator, *tmps; |
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:
358
diff
changeset
|
1573 | int rc, rlen, ival; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1574 | float fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1575 | uuid_t uu; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1576 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1577 | opt = strtok(buf, " \0"); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1578 | opt = strtok(NULL, " \0"); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1579 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1580 | if (opt == NULL) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1581 | srv_send((char *)"501 Subcommand missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1582 | return 0; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1583 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1584 | param = strtok(NULL, "\0"); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1585 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1586 | if (strcmp(opt, (char *)"HELP") == 0) { |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1587 | srv_send((char *)"100 Help text follows:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1588 | srv_send((char *)"Recognized commands:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1589 | srv_send((char *)"SIMULATOR ADD name Add a new Simulator with name"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1590 | srv_send((char *)"SIMULATOR DEL uuid Delete Simulator by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1591 | srv_send((char *)"SIMULATOR LIST List all Simulators"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1592 | srv_send((char *)"SIMULATOR GET uuid Get Simulator record by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1593 | srv_send((char *)"SIMULATOR PUT uuid Put Simulator record by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1594 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1595 | return 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1596 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1597 | |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1598 | if (strcmp(opt, (char *)"LIST") == 0) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1599 | srv_send((char *)"212 Simulators list follows:"); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1600 | for (simulator = Config.simulators; simulator; simulator = simulator->next) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1601 | srv_send((char *)"%s,%s", simulator->uuid, simulator->name); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1602 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1603 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1604 | return 0; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1605 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1606 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1607 | if (param == NULL) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1608 | srv_send((char *)"502 Parameter missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1609 | return 0; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1610 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1611 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1612 | if (strcmp(opt, (char *)"ADD") == 0) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1613 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1614 | /* |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1615 | * For now, only one simulator is allowed. |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1616 | */ |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1617 | if (Config.simulators) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1618 | srv_send((char *)"441 Maximum simulators reached"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1619 | return 0; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1620 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1621 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1622 | simulator = (simulator_list *)malloc(sizeof(simulator_list)); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1623 | simulator->next = NULL; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1624 | simulator->version = 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1625 | simulator->uuid = malloc(37); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1626 | uuid_generate(uu); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1627 | uuid_unparse(uu, simulator->uuid); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1628 | simulator->name = xstrcpy(param); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1629 | simulator->volume_air = 150; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1630 | simulator->volume_beer = 50; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1631 | simulator->room_temperature = simulator->air_temperature = simulator->beer_temperature = simulator->s_cool_temp = simulator->s_heat_temp = 20.0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1632 | simulator->cooler_temp = -3.0; /* Cooling temperature */ |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1633 | simulator->cooler_time = 720; /* About 12 minutes for the cooler plate */ |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1634 | simulator->cooler_size = 0.8; /* 0.8 square meter cooler plate */ |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1635 | simulator->heater_temp = 150.0; /* Heating temperature */ |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1636 | simulator->heater_time = 3; /* 3 seconds to heat-up */ |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1637 | simulator->heater_size = 0.01; /* 0.01 square meter heater plate */ |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1638 | simulator->heater_state = simulator->cooler_state = 0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1639 | simulator->frigo_isolation = 0.002; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1640 | simulator->s_yeast_heat = 0.0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1641 | simulator->s_yeast_started = simulator->s_cool_changed = simulator->s_heat_changed = (int)0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1642 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1643 | if (Config.simulators == NULL) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1644 | Config.simulators = simulator; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1645 | } else { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1646 | for (tmps = Config.simulators; tmps; tmps = tmps->next) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1647 | if (tmps->next == NULL) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1648 | tmps->next = simulator; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1649 | break; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1650 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1651 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1652 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1653 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1654 | syslog(LOG_NOTICE, "Simulator %s added", simulator->uuid); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1655 | srv_send((char *)"211 Simulator %s added", simulator->uuid); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1656 | return 1; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1657 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1658 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1659 | if (strcmp(opt, (char *)"DEL") == 0) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1660 | rc = delete_Simulator(param); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1661 | if (rc) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1662 | syslog(LOG_NOTICE, "Simulator %s deleted", param); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1663 | srv_send((char *)"211 Simulator %s deleted", param); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1664 | return 1; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1665 | } else { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1666 | srv_send((char *)"440 No such simulator"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1667 | return 0; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1668 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1669 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1670 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1671 | if (strcmp(opt, (char *)"GET") == 0) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1672 | for (simulator = Config.simulators; simulator; simulator = simulator->next) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1673 | if (strcmp(simulator->uuid, param) == 0) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1674 | srv_send((char *)"213 Simulator record follows:"); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1675 | srv_send((char *)"NAME,%s", simulator->name); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1676 | srv_send((char *)"VOLUME_AIR,%d", simulator->volume_air); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1677 | srv_send((char *)"VOLUME_BEER,%d", simulator->volume_beer); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1678 | srv_send((char *)"ROOM_TEMPERATURE,%.1f", simulator->room_temperature); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1679 | srv_send((char *)"AIR_TEMPERATURE,%.3f", simulator->air_temperature); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1680 | srv_send((char *)"BEER_TEMPERATURE,%.3f", simulator->beer_temperature); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1681 | srv_send((char *)"COOLER_TEMP,%.1f", simulator->cooler_temp); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1682 | srv_send((char *)"COOLER_TIME,%d", simulator->cooler_time); |
261 | 1683 | srv_send((char *)"COOLER_SIZE,%.3f", simulator->cooler_size); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1684 | srv_send((char *)"HEATER_TEMP,%.1f", simulator->heater_temp); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1685 | srv_send((char *)"HEATER_TIME,%d", simulator->heater_time); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1686 | srv_send((char *)"HEATER_SIZE,%.3f", simulator->heater_size); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1687 | srv_send((char *)"HEATER_STATE,%d", simulator->heater_state); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1688 | srv_send((char *)"COOLER_STATE,%d", simulator->cooler_state); |
261 | 1689 | srv_send((char *)"FRIGO_ISOLATION,%.3f", simulator->frigo_isolation); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1690 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1691 | return 0; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1692 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1693 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1694 | srv_send((char *)"440 No such simulator"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1695 | return 0; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1696 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1697 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1698 | if (strcmp(opt, (char *)"PUT") == 0) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1699 | for (simulator = Config.simulators; simulator; simulator = simulator->next) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1700 | if (strcmp(simulator->uuid, param) == 0) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1701 | while (1) { |
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:
358
diff
changeset
|
1702 | rlen = srv_recv(ibuf); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1703 | if (rlen == -1) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1704 | return 0; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1705 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1706 | if (strlen(ibuf)) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1707 | if (strcmp(ibuf, (char *)".") == 0) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1708 | srv_send((char *)"219 Accepted Simulator record"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1709 | return 1; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1710 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1711 | kwd = strtok(ibuf, ",\0"); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1712 | val = strtok(NULL, "\0"); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1713 | if (kwd && val) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1714 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1715 | if (strcmp(kwd, (char *)"NAME") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1716 | if (simulator->name) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1717 | if (strcmp(simulator->name, val)) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1718 | syslog(LOG_NOTICE, "Simulator %s name `%s' to `%s'", simulator->uuid, simulator->name, val); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1719 | free(simulator->name); |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1720 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1721 | simulator->name = xstrcpy(val); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1722 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1723 | } else if (strcmp(kwd, (char *)"VOLUME_AIR") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1724 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1725 | if (simulator->volume_air != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1726 | syslog(LOG_NOTICE, "Simulator %s volume air %d to %d", simulator->uuid, simulator->volume_air, ival); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1727 | simulator->volume_air = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1728 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1729 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1730 | } else if (strcmp(kwd, (char *)"VOLUME_BEER") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1731 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1732 | if (simulator->volume_beer != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1733 | syslog(LOG_NOTICE, "Simulator %s volume beer %d to %d", simulator->uuid, simulator->volume_beer, ival); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1734 | simulator->volume_beer = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1735 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1736 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1737 | } else if (strcmp(kwd, (char *)"ROOM_TEMPERATURE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1738 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1739 | if (simulator->room_temperature != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1740 | syslog(LOG_NOTICE, "Simulator %s room temperature %.1f to %.1f", simulator->uuid, simulator->room_temperature, fval); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1741 | simulator->room_temperature = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1742 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1743 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1744 | } else if (strcmp(kwd, (char *)"AIR_TEMPERATURE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1745 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1746 | if (simulator->air_temperature != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1747 | syslog(LOG_NOTICE, "Simulator %s air temperature %.1f to %.1f", simulator->uuid, simulator->air_temperature, fval); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1748 | simulator->air_temperature = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1749 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1750 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1751 | } else if (strcmp(kwd, (char *)"BEER_TEMPERATURE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1752 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1753 | if (simulator->beer_temperature != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1754 | syslog(LOG_NOTICE, "Simulator %s beer temperature %.1f to %.1f", simulator->uuid, simulator->beer_temperature, fval); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1755 | simulator->beer_temperature = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1756 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1757 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1758 | } else if (strcmp(kwd, (char *)"COOLER_TEMP") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1759 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1760 | if (simulator->cooler_temp != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1761 | syslog(LOG_NOTICE, "Simulator %s cooler temperature %.1f to %.1f", simulator->uuid, simulator->cooler_temp, fval); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1762 | simulator->cooler_temp = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1763 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1764 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1765 | } else if (strcmp(kwd, (char *)"COOLER_TIME") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1766 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1767 | if (simulator->cooler_time != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1768 | syslog(LOG_NOTICE, "Simulator %s cooler time %d to %d", simulator->uuid, simulator->cooler_time, ival); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1769 | simulator->cooler_time = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1770 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1771 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1772 | } else if (strcmp(kwd, (char *)"COOLER_SIZE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1773 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1774 | if (simulator->cooler_size != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1775 | syslog(LOG_NOTICE, "Simulator %s cooler size %.1f to %.1f", simulator->uuid, simulator->cooler_size, fval); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1776 | simulator->cooler_size = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1777 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1778 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1779 | } else if (strcmp(kwd, (char *)"HEATER_TEMP") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1780 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1781 | if (simulator->heater_temp != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1782 | syslog(LOG_NOTICE, "Simulator %s heater temperature %.1f to %.1f", simulator->uuid, simulator->heater_temp, fval); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1783 | simulator->heater_temp = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1784 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1785 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1786 | } else if (strcmp(kwd, (char *)"HEATER_TIME") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1787 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1788 | if (simulator->heater_time != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1789 | syslog(LOG_NOTICE, "Simulator %s heater time %d to %d", simulator->uuid, simulator->heater_time, ival); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1790 | simulator->heater_time = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1791 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1792 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1793 | } else if (strcmp(kwd, (char *)"HEATER_SIZE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1794 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1795 | if (simulator->heater_size != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1796 | syslog(LOG_NOTICE, "Simulator %s heater size %.1f to %.1f", simulator->uuid, simulator->heater_size, fval); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1797 | simulator->heater_size = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1798 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1799 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1800 | } else if (strcmp(kwd, (char *)"HEATER_STATE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1801 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1802 | if (simulator->heater_state != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1803 | syslog(LOG_NOTICE, "Simulator %s heater state %d to %d", simulator->uuid, simulator->heater_state, ival); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1804 | simulator->heater_state = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1805 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1806 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1807 | } else if (strcmp(kwd, (char *)"COOLER_STATE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1808 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1809 | if (simulator->cooler_state != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1810 | syslog(LOG_NOTICE, "Simulator %s cooler state %d to %d", simulator->uuid, simulator->cooler_state, ival); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1811 | simulator->cooler_state = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1812 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1813 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1814 | } else if (strcmp(kwd, (char *)"FRIGO_ISOLATION") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1815 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1816 | if (simulator->frigo_isolation != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1817 | syslog(LOG_NOTICE, "Simulator %s frigo isolation %.1f to %.1f", simulator->uuid, simulator->frigo_isolation, fval); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1818 | simulator->frigo_isolation = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1819 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1820 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1821 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1822 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1823 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1824 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1825 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1826 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1827 | srv_send((char *)"440 No such simulator"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1828 | return 0; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1829 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1830 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1831 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1832 | return 0; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1833 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1834 | #endif |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1835 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1836 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
1837 | |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1838 | int delete_Unit(char *uuid) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1839 | { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1840 | units_list *current = Config.units; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1841 | units_list *previous = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1842 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1843 | while (current) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1844 | if (strcmp(current->uuid, uuid) == 0) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1845 | if (previous == NULL) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1846 | Config.units = current->next; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1847 | free(current->uuid); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1848 | current->uuid = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1849 | free(current->name); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1850 | current->name = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1851 | if (current->air_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1852 | free(current->air_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1853 | current->air_address = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1854 | if (current->beer_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1855 | free(current->beer_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1856 | current->beer_address = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1857 | if (current->heater_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1858 | free(current->heater_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1859 | current->heater_address = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1860 | if (current->cooler_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1861 | free(current->cooler_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1862 | current->cooler_address = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1863 | if (current->fan_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1864 | free(current->fan_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1865 | current->fan_address = NULL; |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1866 | if (current->light_address) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1867 | free(current->light_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1868 | current->light_address = NULL; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1869 | if (current->door_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1870 | free(current->door_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1871 | current->door_address = NULL; |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1872 | if (current->psu_address) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1873 | free(current->psu_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1874 | current->psu_address = NULL; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1875 | if (current->profile) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1876 | free(current->profile); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1877 | current->profile = NULL; |
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:
358
diff
changeset
|
1878 | if (current->PID_cool) |
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:
358
diff
changeset
|
1879 | free(current->PID_cool); |
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:
358
diff
changeset
|
1880 | current->PID_cool = NULL; |
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:
358
diff
changeset
|
1881 | if (current->PID_heat) |
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:
358
diff
changeset
|
1882 | free(current->PID_heat); |
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:
358
diff
changeset
|
1883 | current->PID_heat = NULL; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1884 | free(current); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1885 | return 1; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1886 | } else { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1887 | free(current->uuid); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1888 | current->uuid = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1889 | free(current->name); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1890 | current->name = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1891 | if (current->air_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1892 | free(current->air_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1893 | current->air_address = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1894 | if (current->beer_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1895 | free(current->beer_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1896 | current->beer_address = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1897 | if (current->heater_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1898 | free(current->heater_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1899 | current->heater_address = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1900 | if (current->cooler_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1901 | free(current->cooler_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1902 | current->cooler_address = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1903 | if (current->fan_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1904 | free(current->fan_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1905 | current->fan_address = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1906 | if (current->door_address) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1907 | free(current->door_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1908 | current->door_address = NULL; |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1909 | if (current->light_address) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1910 | free(current->light_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1911 | current->light_address = NULL; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1912 | if (current->psu_address) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1913 | free(current->psu_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1914 | current->psu_address = NULL; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1915 | if (current->profile) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1916 | free(current->profile); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1917 | current->profile = NULL; |
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:
358
diff
changeset
|
1918 | if (current->PID_cool) |
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:
358
diff
changeset
|
1919 | free(current->PID_cool); |
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:
358
diff
changeset
|
1920 | current->PID_cool = NULL; |
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:
358
diff
changeset
|
1921 | if (current->PID_heat) |
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:
358
diff
changeset
|
1922 | free(current->PID_heat); |
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:
358
diff
changeset
|
1923 | current->PID_heat = NULL; |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1924 | previous->next = current->next; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1925 | free(current); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1926 | current = previous->next; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1927 | return 1; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1928 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1929 | } else { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1930 | previous = current; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1931 | current = current->next; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1932 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1933 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1934 | return 0; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1935 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1936 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1937 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1938 | |
88 | 1939 | /* |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1940 | * UNIT ADD name |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1941 | * UNIT DEL uuid |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1942 | * UNIT LIST |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1943 | * UNIT GET uuid |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1944 | * UNIT PUT uuid |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1945 | */ |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1946 | int cmd_unit(char *buf) |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1947 | { |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1948 | char *opt, *param = NULL, *kwd, *val, ibuf[SS_BUFSIZE]; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1949 | units_list *unit, *tmpu; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1950 | uuid_t uu; |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1951 | int ival, i, rc, rlen; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1952 | float fval; |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1953 | |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1954 | opt = strtok(buf, " \0"); |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1955 | opt = strtok(NULL, " \0"); |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1956 | |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1957 | if (opt == NULL) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1958 | srv_send((char *)"501 Subcommand missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1959 | return 0; |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1960 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1961 | param = strtok(NULL, "\0"); |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1962 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1963 | if (strcmp(opt, (char *)"HELP") == 0) { |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1964 | srv_send((char *)"100 Help text follows:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1965 | srv_send((char *)"Recognized commands:"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1966 | srv_send((char *)"UNIT ADD name Add a new Unit with name"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1967 | srv_send((char *)"UNIT DEL uuid Delete Unit by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1968 | srv_send((char *)"UNIT LIST List all Units"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1969 | srv_send((char *)"UNIT GET uuid Get Unit record by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1970 | srv_send((char *)"UNIT PUT uuid Put Unit record by uuid"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1971 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1972 | return 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1973 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1974 | |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1975 | if ((strcmp(opt, (char *)"LIST") == 0) && (param == NULL)) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1976 | srv_send((char *)"212 Fermenter list follows:"); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1977 | for (unit = Config.units; unit; unit = unit->next) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1978 | srv_send((char *)"%s,%s,%s", unit->uuid, unit->name, UNITMODE[unit->mode]); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1979 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1980 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1981 | return 0; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1982 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1983 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1984 | if (param == NULL) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1985 | srv_send((char *)"502 Parameter missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1986 | return 0; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1987 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1988 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1989 | if (strcmp(opt, (char *)"ADD") == 0) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1990 | unit = (units_list *)malloc(sizeof(units_list)); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1991 | unit->next = NULL; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1992 | unit->version = 1; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1993 | unit->uuid = malloc(37); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1994 | uuid_generate(uu); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1995 | uuid_unparse(uu, unit->uuid); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1996 | unit->name = xstrcpy(param); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
1997 | unit->air_address = unit->beer_address = unit->heater_address = unit->cooler_address = \ |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1998 | unit->fan_address = unit->door_address = unit->light_address = \ |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
1999 | unit->psu_address = unit->profile = NULL; |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
2000 | unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2001 | unit->air_state = unit->beer_state = 1; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2002 | unit->air_temperature = unit->beer_temperature = 20000; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2003 | unit->beer_set = unit->fridge_set = 20.0; |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2004 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = \ |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2005 | unit->light_state = unit->psu_state = unit->prof_state = 0; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2006 | unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2007 | unit->light_delay = 1; /* 15 seconds delay */ |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2008 | unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2009 | unit->heater_usage = unit->cooler_usage = unit->fan_usage = unit->light_usage = 0; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2010 | unit->temp_set_min = 1.0; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2011 | unit->temp_set_max = 30.0; |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
2012 | unit->prof_started = unit->prof_paused = unit->prof_primary_done = (time_t)0; |
284
9e6fb5aed618
Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
2013 | unit->prof_percent = 0; |
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:
358
diff
changeset
|
2014 | unit->PID_cool = (pid_var *)malloc(sizeof(pid_var)); |
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:
358
diff
changeset
|
2015 | unit->PID_heat = (pid_var *)malloc(sizeof(pid_var)); |
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:
358
diff
changeset
|
2016 | InitPID(unit->PID_cool, PID_TYPE_COOL); |
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:
358
diff
changeset
|
2017 | InitPID(unit->PID_heat, PID_TYPE_HEAT); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2018 | |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2019 | /* |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2020 | * Block main process |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2021 | */ |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2022 | run_pause = TRUE; |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2023 | for (;;) { |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2024 | usleep(100000); |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2025 | if (run_hold) |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2026 | break; |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2027 | } |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2028 | |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2029 | if (Config.units == NULL) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2030 | Config.units = unit; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2031 | } else { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2032 | for (tmpu = Config.units; tmpu; tmpu = tmpu->next) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2033 | if (tmpu->next == NULL) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2034 | tmpu->next = unit; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2035 | break; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2036 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2037 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2038 | } |
249 | 2039 | #ifdef HAVE_WIRINGPI_H |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2040 | lcd_buf_reset(); |
249 | 2041 | #endif |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2042 | run_pause = FALSE; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2043 | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
2044 | syslog(LOG_NOTICE, "Unit %s added", unit->uuid); |
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
2045 | srv_send((char *)"211 Unit %s added", unit->uuid); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2046 | return 1; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2047 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2048 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2049 | if (strcmp(opt, (char *)"DEL") == 0) { |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2050 | /* |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2051 | * Block main process. |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2052 | */ |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2053 | run_pause = TRUE; |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2054 | for (;;) { |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2055 | usleep(100000); |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2056 | if (run_hold) |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2057 | break; |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2058 | } |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2059 | |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2060 | rc = delete_Unit(param); |
249 | 2061 | #ifdef HAVE_WIRINGPI_H |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2062 | lcd_buf_reset(); |
249 | 2063 | #endif |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2064 | run_pause = FALSE; |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2065 | |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
2066 | if (rc) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
2067 | syslog(LOG_NOTICE, "Unit %s deleted", param); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2068 | srv_send((char *)"211 Unit %s deleted", param); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2069 | return 1; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2070 | } else { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
2071 | srv_send((char *)"440 No such unit"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2072 | return 0; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2073 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2074 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2075 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2076 | if (strcmp(opt, (char *)"GET") == 0) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2077 | for (unit = Config.units; unit; unit = unit->next) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2078 | if (strcmp(param, unit->uuid) == 0) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
2079 | srv_send((char *)"213 Unit listing follows:"); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2080 | srv_send((char *)"NAME,%s", unit->name); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2081 | srv_send((char *)"UUID,%s", unit->uuid); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2082 | srv_send((char *)"VOLUME,%2f", unit->volume); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2083 | srv_send((char *)"AIR_ADDRESS,%s", unit->air_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2084 | srv_send((char *)"AIR_STATE,%s", TEMPSTATE[unit->air_state]); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2085 | srv_send((char *)"AIR_TEMPERATURE,%.3f", unit->air_temperature / 1000.0); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2086 | srv_send((char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address)); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2087 | srv_send((char *)"BEER_STATE,%s", TEMPSTATE[unit->beer_state]); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2088 | srv_send((char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2089 | srv_send((char *)"HEATER_ADDRESS,%s", unit->heater_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2090 | srv_send((char *)"HEATER_STATE,%d", unit->heater_state); |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2091 | srv_send((char *)"HEATER_DELAY,%d", unit->heater_delay); |
293 | 2092 | srv_send((char *)"HEATER_USAGE,%d", unit->heater_usage); |
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:
358
diff
changeset
|
2093 | if (unit->PID_heat) { |
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:
358
diff
changeset
|
2094 | srv_send((char *)"PIDH_IMAX,%.1f", unit->PID_heat->iMax); |
364
2f9bbbcd2407
Tuning PID code. Samll changes on the unit web page.
Michiel Broek <mbroek@mbse.eu>
parents:
362
diff
changeset
|
2095 | srv_send((char *)"PIDH_IDLERANGE,%.2f", unit->PID_heat->idleRange); |
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:
358
diff
changeset
|
2096 | srv_send((char *)"PIDH_PGAIN,%.2f", unit->PID_heat->pGain); |
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:
358
diff
changeset
|
2097 | srv_send((char *)"PIDH_IGAIN,%.2f", unit->PID_heat->iGain); |
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:
358
diff
changeset
|
2098 | srv_send((char *)"PIDH_DGAIN,%.2f", unit->PID_heat->dGain); |
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:
358
diff
changeset
|
2099 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2100 | srv_send((char *)"COOLER_ADDRESS,%s", unit->cooler_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2101 | srv_send((char *)"COOLER_STATE,%d", unit->cooler_state); |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2102 | srv_send((char *)"COOLER_DELAY,%d", unit->cooler_delay); |
293 | 2103 | srv_send((char *)"COOLER_USAGE,%d", unit->cooler_usage); |
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:
358
diff
changeset
|
2104 | if (unit->PID_cool) { |
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:
358
diff
changeset
|
2105 | srv_send((char *)"PIDC_IMAX,%.1f", unit->PID_cool->iMax); |
364
2f9bbbcd2407
Tuning PID code. Samll changes on the unit web page.
Michiel Broek <mbroek@mbse.eu>
parents:
362
diff
changeset
|
2106 | srv_send((char *)"PIDC_IDLERANGE,%.2f", unit->PID_cool->idleRange); |
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:
358
diff
changeset
|
2107 | srv_send((char *)"PIDC_PGAIN,%.2f", unit->PID_cool->pGain); |
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:
358
diff
changeset
|
2108 | srv_send((char *)"PIDC_IGAIN,%.2f", unit->PID_cool->iGain); |
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:
358
diff
changeset
|
2109 | srv_send((char *)"PIDC_DGAIN,%.2f", unit->PID_cool->dGain); |
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:
358
diff
changeset
|
2110 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2111 | srv_send((char *)"FAN_ADDRESS,%s", unit->fan_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2112 | srv_send((char *)"FAN_STATE,%d", unit->fan_state); |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2113 | srv_send((char *)"FAN_DELAY,%d", unit->fan_delay); |
293 | 2114 | srv_send((char *)"FAN_USAGE,%d", unit->fan_usage); |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2115 | srv_send((char *)"LIGHT_ADDRESS,%s", unit->light_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2116 | srv_send((char *)"LIGHT_STATE,%d", unit->light_state); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2117 | srv_send((char *)"LIGHT_DELAY,%d", unit->light_delay); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2118 | srv_send((char *)"LIGHT_USAGE,%d", unit->light_usage); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2119 | srv_send((char *)"DOOR_ADDRESS,%s", unit->door_address); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2120 | srv_send((char *)"DOOR_STATE,%d", unit->door_state); |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2121 | srv_send((char *)"PSU_ADDRESS,%s", unit->psu_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2122 | srv_send((char *)"PSU_STATE,%d", unit->psu_state); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2123 | srv_send((char *)"MODE,%s", UNITMODE[unit->mode]); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2124 | srv_send((char *)"FRIDGE_SET,%.1f", unit->fridge_set); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2125 | srv_send((char *)"BEER_SET,%.1f", unit->beer_set); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2126 | srv_send((char *)"PROFILE,%s", unit->profile); |
217 | 2127 | srv_send((char *)"PROF_STARTED,%d", (int)unit->prof_started); |
284
9e6fb5aed618
Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
2128 | if (unit->prof_state == PROFILE_RUN) { |
9e6fb5aed618
Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
2129 | srv_send((char *)"PROF_STATE,%s %d%%", PROFSTATE[unit->prof_state], unit->prof_percent); |
9e6fb5aed618
Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
2130 | } else { |
9e6fb5aed618
Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
2131 | srv_send((char *)"PROF_STATE,%s", PROFSTATE[unit->prof_state]); |
9e6fb5aed618
Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
2132 | } |
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:
390
diff
changeset
|
2133 | srv_send((char *)"PROF_TARGET_LO,%.3f", unit->prof_target_lo); |
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:
390
diff
changeset
|
2134 | srv_send((char *)"PROF_TARGET_HI,%.3f", unit->prof_target_hi); |
398
efdfef1677d1
Fixed crash after profile is finished. Fixed error in UNIT GET output.
Michiel Broek <mbroek@mbse.eu>
parents:
397
diff
changeset
|
2135 | srv_send((char *)"PROF_FRIDGE_MODE,%d", unit->prof_fridge_mode); |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
2136 | srv_send((char *)"PROF_PEAK_ABS,%.3f", unit->prof_peak_abs); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
2137 | srv_send((char *)"PROF_PEAK_REL,%.3f", unit->prof_peak_rel); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
2138 | srv_send((char *)"PROF_PRIMARY_DONE,%d", (int)unit->prof_primary_done); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2139 | srv_send((char *)"TEMP_SET_MIN,%.1f", unit->temp_set_min); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2140 | srv_send((char *)"TEMP_SET_MAX,%.1f", unit->temp_set_max); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2141 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2142 | return 0; |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2143 | } |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2144 | } |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
2145 | srv_send((char *)"440 No such unit"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2146 | return 0; |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2147 | } |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2148 | |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2149 | if (strcmp(opt, (char *)"PUT") == 0) { |
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:
358
diff
changeset
|
2150 | /* |
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:
358
diff
changeset
|
2151 | * Block main process |
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:
358
diff
changeset
|
2152 | */ |
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:
358
diff
changeset
|
2153 | run_pause = TRUE; |
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:
358
diff
changeset
|
2154 | for (;;) { |
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:
358
diff
changeset
|
2155 | usleep(100000); |
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:
358
diff
changeset
|
2156 | if (run_hold) |
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:
358
diff
changeset
|
2157 | break; |
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:
358
diff
changeset
|
2158 | } |
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:
358
diff
changeset
|
2159 | |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2160 | for (unit = Config.units ; unit; unit = unit->next) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2161 | if (strcmp(unit->uuid, param) == 0) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2162 | while (1) { |
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:
358
diff
changeset
|
2163 | rlen = srv_recv(ibuf); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2164 | if (rlen == -1) { |
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:
358
diff
changeset
|
2165 | run_pause = FALSE; |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2166 | return 0; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2167 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2168 | if (strlen(ibuf)) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2169 | if (strcmp(ibuf, (char *)".") == 0) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2170 | srv_send((char *)"219 Accepted Unit record"); |
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:
358
diff
changeset
|
2171 | run_pause = FALSE; |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2172 | return 1; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2173 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2174 | kwd = strtok(ibuf, ",\0"); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2175 | val = strtok(NULL, "\0"); |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2176 | if (kwd) { |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2177 | /* |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2178 | * Accept writable data. The client can sent just one line, |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2179 | * but may also sent everything. Simply ignore things we |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2180 | * don't understand. |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2181 | */ |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2182 | if (val && (strcmp(kwd, (char *)"NAME") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2183 | if (unit->name) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2184 | if (strcmp(unit->name, val)) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2185 | syslog(LOG_NOTICE, "Fermenter unit %s name `%s' to `%s'", unit->uuid, unit->name, val); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2186 | free(unit->name); |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2187 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2188 | unit->name = xstrcpy(val); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2189 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2190 | } else if (val && (strcmp(kwd, (char *)"VOLUME") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2191 | if (sscanf(val, "%f", &fval) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2192 | if (unit->volume != fval) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2193 | syslog(LOG_NOTICE, "Fermenter unit %s volume %.3f to %.3f", unit->uuid, unit->volume, fval); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2194 | unit->volume = fval; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2195 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2196 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2197 | } else if (strcmp(kwd, (char *)"AIR_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2198 | if (val && unit->air_address && (strcmp(val, unit->air_address))) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2199 | syslog(LOG_NOTICE, "Fermenter unit %s air address `%s' to `%s'", unit->uuid, unit->air_address, val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2200 | if (unit->air_address) { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2201 | device_count(FALSE, unit->air_address); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2202 | free(unit->air_address); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2203 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2204 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2205 | unit->air_address = xstrcpy(val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2206 | device_count(TRUE, unit->air_address); |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2207 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2208 | unit->air_address = NULL; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2209 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2210 | } else if (strcmp(kwd, (char *)"BEER_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2211 | if (val && unit->beer_address && (strcmp(val, unit->beer_address))) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2212 | syslog(LOG_NOTICE, "Fermenter unit %s beer address `%s' to `%s'", unit->uuid, unit->beer_address, val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2213 | if (unit->beer_address) { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2214 | device_count(FALSE, unit->beer_address); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2215 | free(unit->beer_address); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2216 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2217 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2218 | unit->beer_address = xstrcpy(val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2219 | device_count(TRUE, unit->beer_address); |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2220 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2221 | unit->beer_address = NULL; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2222 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2223 | } else if (strcmp(kwd, (char *)"HEATER_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2224 | if (val && unit->heater_address && (strcmp(val, unit->heater_address))) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2225 | syslog(LOG_NOTICE, "Fermenter unit %s heater address `%s' to `%s'", unit->uuid, unit->heater_address, val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2226 | if (unit->heater_address) { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2227 | device_count(FALSE, unit->heater_address); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2228 | free(unit->heater_address); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2229 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2230 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2231 | unit->heater_address = xstrcpy(val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2232 | device_count(TRUE, unit->heater_address); |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2233 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2234 | unit->heater_address = NULL; |
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2235 | |
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2236 | } else if (val && (strcmp(kwd, (char *)"HEATER_STATE") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2237 | if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2238 | if (unit->heater_state != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2239 | syslog(LOG_NOTICE, "Fermenter unit %s heater state %d to %d", unit->uuid, unit->heater_state, ival); |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2240 | unit->heater_state = ival; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2241 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2242 | |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2243 | } else if (val && (strcmp(kwd, (char *)"HEATER_DELAY") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2244 | if (sscanf(val, "%d", &ival) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2245 | if (unit->heater_delay != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2246 | syslog(LOG_NOTICE, "Fermenter unit %s heater delay %d to %d", unit->uuid, unit->heater_delay, ival); |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2247 | unit->heater_delay = ival; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2248 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2249 | |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2250 | } else if (strcmp(kwd, (char *)"COOLER_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2251 | if (val && unit->cooler_address && (strcmp(val, unit->cooler_address))) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2252 | syslog(LOG_NOTICE, "Fermenter unit %s cooler address `%s' to `%s'", unit->uuid, unit->cooler_address, val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2253 | if (unit->cooler_address) { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2254 | device_count(FALSE, unit->cooler_address); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2255 | free(unit->cooler_address); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2256 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2257 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2258 | unit->cooler_address = xstrcpy(val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2259 | device_count(TRUE, unit->cooler_address); |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2260 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2261 | unit->cooler_address = NULL; |
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2262 | |
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2263 | } else if (val && (strcmp(kwd, (char *)"COOLER_STATE") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2264 | if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2265 | if (unit->cooler_state != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2266 | syslog(LOG_NOTICE, "Fermenter unit %s cooler state %d to %d", unit->uuid, unit->cooler_state, ival); |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2267 | unit->cooler_state = ival; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2268 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2269 | |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2270 | } else if (val && (strcmp(kwd, (char *)"COOLER_DELAY") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2271 | if (sscanf(val, "%d", &ival) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2272 | if (unit->cooler_delay != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2273 | syslog(LOG_NOTICE, "Fermenter unit %s cooler delay %d to %d", unit->uuid, unit->cooler_delay, ival); |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2274 | unit->cooler_delay = ival; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2275 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2276 | |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2277 | } else if (strcmp(kwd, (char *)"FAN_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2278 | if (val && unit->fan_address && (strcmp(val, unit->fan_address))) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2279 | syslog(LOG_NOTICE, "Fermenter unit %s fan address `%s' to `%s'", unit->uuid, unit->fan_address, val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2280 | if (unit->fan_address) { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2281 | device_count(FALSE, unit->fan_address); |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2282 | free(unit->fan_address); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2283 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2284 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2285 | unit->fan_address = xstrcpy(val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2286 | device_count(TRUE, unit->fan_address); |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2287 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2288 | unit->fan_address = NULL; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2289 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2290 | } else if (val && (strcmp(kwd, (char *)"FAN_STATE") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2291 | if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2292 | if (unit->fan_state != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2293 | syslog(LOG_NOTICE, "Fermenter unit %s fan state %d to %d", unit->uuid, unit->fan_state, ival); |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2294 | unit->fan_state = ival; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2295 | } |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2296 | |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2297 | } else if (val && (strcmp(kwd, (char *)"FAN_DELAY") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2298 | if (sscanf(val, "%d", &ival) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2299 | if (unit->fan_delay != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2300 | syslog(LOG_NOTICE, "Fermenter unit %s fan delay %d to %d", unit->uuid, unit->fan_delay, ival); |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2301 | unit->fan_delay = ival; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2302 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2303 | |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2304 | } else if (strcmp(kwd, (char *)"LIGHT_ADDRESS") == 0) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2305 | if (val && unit->light_address && (strcmp(val, unit->light_address))) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2306 | syslog(LOG_NOTICE, "Fermenter unit %s light address `%s' to `%s'", unit->uuid, unit->light_address, val); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2307 | if (unit->light_address) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2308 | device_count(FALSE, unit->light_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2309 | free(unit->light_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2310 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2311 | if (val) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2312 | unit->light_address = xstrcpy(val); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2313 | device_count(TRUE, unit->light_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2314 | } else |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2315 | unit->light_address = NULL; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2316 | |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2317 | } else if (val && (strcmp(kwd, (char *)"LIGHT_STATE") == 0)) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2318 | if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2319 | if (unit->light_state != ival) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2320 | syslog(LOG_NOTICE, "Fermenter unit %s light state %d to %d", unit->uuid, unit->light_state, ival); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2321 | unit->light_state = ival; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2322 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2323 | |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2324 | } else if (val && (strcmp(kwd, (char *)"LIGHT_DELAY") == 0)) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2325 | if (sscanf(val, "%d", &ival) == 1) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2326 | if (unit->light_delay != ival) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2327 | syslog(LOG_NOTICE, "Fermenter unit %s light delay %d to %d", unit->uuid, unit->light_delay, ival); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2328 | unit->light_delay = ival; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2329 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2330 | |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2331 | } else if (strcmp(kwd, (char *)"DOOR_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2332 | if (val && unit->door_address && (strcmp(val, unit->door_address))) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2333 | syslog(LOG_NOTICE, "Fermenter unit %s door address `%s' to `%s'", unit->uuid, unit->door_address, val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2334 | if (unit->door_address) { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2335 | device_count(FALSE, unit->door_address); |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2336 | free(unit->door_address); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2337 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2338 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2339 | unit->door_address = xstrcpy(val); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2340 | device_count(TRUE, unit->door_address); |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2341 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2342 | unit->door_address = NULL; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2343 | |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2344 | } else if (strcmp(kwd, (char *)"PSU_ADDRESS") == 0) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2345 | if (val && unit->psu_address && (strcmp(val, unit->psu_address))) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2346 | syslog(LOG_NOTICE, "Fermenter unit %s psu address `%s' to `%s'", unit->uuid, unit->psu_address, val); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2347 | if (unit->psu_address) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2348 | device_count(FALSE, unit->psu_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2349 | free(unit->psu_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2350 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2351 | if (val) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2352 | unit->psu_address = xstrcpy(val); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2353 | device_count(TRUE, unit->psu_address); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2354 | } else |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2355 | unit->psu_address = NULL; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2356 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2357 | } else if (val && (strcmp(kwd, (char *)"MODE") == 0)) { |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2358 | for (i = 0; i < 5; i++) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2359 | if (strcmp(val, UNITMODE[i]) == 0) { |
189
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
2360 | /* Initialize log if the unit is turned on */ |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
2361 | if ((unit->mode == UNITMODE_OFF) && (i != UNITMODE_OFF)) |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
2362 | initlog(unit->name); |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2363 | syslog(LOG_NOTICE, "Fermenter unit %s mode %s to %s", unit->uuid, UNITMODE[unit->mode], UNITMODE[i]); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2364 | unit->mode = i; |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2365 | /* Allways turn everything off after a mode change */ |
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:
358
diff
changeset
|
2366 | unit->PID_cool->OutP = unit->PID_heat->OutP = 0.0; |
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:
358
diff
changeset
|
2367 | unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2368 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->light_state = 0; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2369 | unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
184 | 2370 | device_out(unit->heater_address, unit->heater_state); |
2371 | device_out(unit->cooler_address, unit->cooler_state); | |
2372 | device_out(unit->fan_address, unit->fan_state); | |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2373 | device_out(unit->light_address, unit->light_state); |
237
51a294d683cd
Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
2374 | if (unit->mode == UNITMODE_PROFILE) { |
51a294d683cd
Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
2375 | /* |
51a294d683cd
Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
2376 | * Set a sane default until it will be overruled by the |
51a294d683cd
Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
2377 | * main processing loop. |
51a294d683cd
Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
2378 | */ |
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:
390
diff
changeset
|
2379 | unit->prof_target_lo = unit->prof_target_hi = 20.0; |
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:
390
diff
changeset
|
2380 | unit->prof_fridge_mode = 0; |
237
51a294d683cd
Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
2381 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2382 | break; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2383 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2384 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2385 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2386 | } else if (val && (strcmp(kwd, (char *)"FRIDGE_SET") == 0)) { |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
2387 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2388 | if (unit->fridge_set != fval) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2389 | syslog(LOG_NOTICE, "Fermenter unit %s fridge temperature %.1f to %.1f", unit->uuid, unit->fridge_set, fval); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2390 | unit->fridge_set = fval; |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
2391 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2392 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2393 | } else if (val && (strcmp(kwd, (char *)"BEER_SET") == 0)) { |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
2394 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) { |
310
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
2395 | if (unit->beer_set != fval) |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2396 | syslog(LOG_NOTICE, "Fermenter unit %s beer temperature %.1f to %.1f", unit->uuid, unit->beer_set, fval); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2397 | unit->beer_set = fval; |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
2398 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2399 | |
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:
358
diff
changeset
|
2400 | } else if (val && (strcmp(kwd, (char *)"PIDC_IMAX") == 0)) { |
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:
358
diff
changeset
|
2401 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { |
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:
358
diff
changeset
|
2402 | if (unit->PID_cool->iMax != fval) |
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:
358
diff
changeset
|
2403 | syslog(LOG_NOTICE, "Fermenter unit %s PID_cool iGain %.1f to %.1f", unit->uuid, unit->PID_cool->iMax, fval); |
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:
358
diff
changeset
|
2404 | unit->PID_cool->iMax = fval; |
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:
358
diff
changeset
|
2405 | } |
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:
358
diff
changeset
|
2406 | |
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:
358
diff
changeset
|
2407 | } else if (val && (strcmp(kwd, (char *)"PIDC_PGAIN") == 0)) { |
310
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
2408 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { |
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:
358
diff
changeset
|
2409 | if (unit->PID_cool->pGain != fval) |
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:
358
diff
changeset
|
2410 | syslog(LOG_NOTICE, "Fermenter unit %s PID_cool pGain %.2f to %.2f", unit->uuid, unit->PID_cool->pGain, fval); |
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:
358
diff
changeset
|
2411 | unit->PID_cool->pGain = fval; |
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:
358
diff
changeset
|
2412 | } |
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:
358
diff
changeset
|
2413 | |
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:
358
diff
changeset
|
2414 | } else if (val && (strcmp(kwd, (char *)"PIDC_DGAIN") == 0)) { |
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:
358
diff
changeset
|
2415 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { |
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:
358
diff
changeset
|
2416 | if (unit->PID_cool->dGain != fval) |
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:
358
diff
changeset
|
2417 | syslog(LOG_NOTICE, "Fermenter unit %s PID_cool dGain %.2f to %.2f", unit->uuid, unit->PID_cool->dGain, fval); |
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:
358
diff
changeset
|
2418 | unit->PID_cool->dGain = fval; |
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:
358
diff
changeset
|
2419 | } |
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:
358
diff
changeset
|
2420 | |
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:
358
diff
changeset
|
2421 | } else if (val && (strcmp(kwd, (char *)"PIDC_IGAIN") == 0)) { |
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:
358
diff
changeset
|
2422 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { |
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:
358
diff
changeset
|
2423 | if (unit->PID_cool->iGain != fval) |
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:
358
diff
changeset
|
2424 | syslog(LOG_NOTICE, "Fermenter unit %s PID_cool iGain %.2f to %.2f", unit->uuid, unit->PID_cool->iGain, fval); |
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:
358
diff
changeset
|
2425 | unit->PID_cool->iGain = fval; |
310
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
2426 | } |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
2427 | |
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:
358
diff
changeset
|
2428 | } else if (val && (strcmp(kwd, (char *)"PIDC_IDLERANGE") == 0)) { |
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:
358
diff
changeset
|
2429 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { |
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:
358
diff
changeset
|
2430 | if (unit->PID_cool->idleRange != fval) |
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:
358
diff
changeset
|
2431 | syslog(LOG_NOTICE, "Fermenter unit %s PID_cool idleRange %.2f to %.2f", unit->uuid, unit->PID_cool->idleRange, fval); |
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:
358
diff
changeset
|
2432 | unit->PID_cool->idleRange = fval; |
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:
358
diff
changeset
|
2433 | } |
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:
358
diff
changeset
|
2434 | |
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:
358
diff
changeset
|
2435 | } else if (val && (strcmp(kwd, (char *)"PIDH_IMAX") == 0)) { |
310
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
2436 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { |
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:
358
diff
changeset
|
2437 | if (unit->PID_heat->iMax != fval) |
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:
358
diff
changeset
|
2438 | syslog(LOG_NOTICE, "Fermenter unit %s PID_heat iGain %.1f to %.1f", unit->uuid, unit->PID_heat->iMax, fval); |
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:
358
diff
changeset
|
2439 | unit->PID_heat->iMax = fval; |
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:
358
diff
changeset
|
2440 | } |
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:
358
diff
changeset
|
2441 | |
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:
358
diff
changeset
|
2442 | } else if (val && (strcmp(kwd, (char *)"PIDH_PGAIN") == 0)) { |
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:
358
diff
changeset
|
2443 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { |
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:
358
diff
changeset
|
2444 | if (unit->PID_heat->pGain != fval) |
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:
358
diff
changeset
|
2445 | syslog(LOG_NOTICE, "Fermenter unit %s PID_heat pGain %.2f to %.2f", unit->uuid, unit->PID_heat->pGain, fval); |
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:
358
diff
changeset
|
2446 | unit->PID_heat->pGain = fval; |
310
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
2447 | } |
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:
358
diff
changeset
|
2448 | |
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:
358
diff
changeset
|
2449 | } else if (val && (strcmp(kwd, (char *)"PIDH_DGAIN") == 0)) { |
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:
358
diff
changeset
|
2450 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { |
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:
358
diff
changeset
|
2451 | if (unit->PID_heat->dGain != fval) |
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:
358
diff
changeset
|
2452 | syslog(LOG_NOTICE, "Fermenter unit %s PID_heat dGain %.2f to %.2f", unit->uuid, unit->PID_heat->dGain, fval); |
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:
358
diff
changeset
|
2453 | unit->PID_heat->dGain = fval; |
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:
358
diff
changeset
|
2454 | } |
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:
358
diff
changeset
|
2455 | |
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:
358
diff
changeset
|
2456 | } else if (val && (strcmp(kwd, (char *)"PIDH_IGAIN") == 0)) { |
310
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
2457 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { |
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:
358
diff
changeset
|
2458 | if (unit->PID_heat->iGain != fval) |
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:
358
diff
changeset
|
2459 | syslog(LOG_NOTICE, "Fermenter unit %s PIH_heat iGain %.2f to %.2f", unit->uuid, unit->PID_heat->iGain, fval); |
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:
358
diff
changeset
|
2460 | unit->PID_heat->iGain = fval; |
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:
358
diff
changeset
|
2461 | } |
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:
358
diff
changeset
|
2462 | |
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:
358
diff
changeset
|
2463 | } else if (val && (strcmp(kwd, (char *)"PIDH_IDLERANGE") == 0)) { |
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:
358
diff
changeset
|
2464 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) { |
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:
358
diff
changeset
|
2465 | if (unit->PID_heat->idleRange != fval) |
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:
358
diff
changeset
|
2466 | syslog(LOG_NOTICE, "Fermenter unit %s PID_heat idleRange %.2f to %.2f", unit->uuid, unit->PID_heat->idleRange, fval); |
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:
358
diff
changeset
|
2467 | unit->PID_heat->idleRange = fval; |
310
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
2468 | } |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
2469 | |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2470 | } else if (strcmp(kwd, (char *)"PROFILE") == 0) { |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2471 | if (unit->prof_state == PROFILE_OFF) { |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2472 | /* |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2473 | * Only change profile if it is not active, else drop this one. |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2474 | */ |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2475 | if (unit->profile && val && strcmp(unit->profile, val)) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2476 | syslog(LOG_NOTICE, "Fermenter unit %s profile name `%s' to `%s'", unit->uuid, unit->profile, val); |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2477 | if (unit->profile) |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2478 | free(unit->profile); |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2479 | |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2480 | if (val) |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2481 | unit->profile = xstrcpy(val); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2482 | else |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2483 | unit->profile = NULL; |
195
b34a1b2421fb
Reset output when a different profile is selected. Better startup logging about the unit state. Added Beer, Fridge and partial Profile settings from the liveview weeb screen.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
2484 | /* |
b34a1b2421fb
Reset output when a different profile is selected. Better startup logging about the unit state. Added Beer, Fridge and partial Profile settings from the liveview weeb screen.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
2485 | * Reset all output devices |
b34a1b2421fb
Reset output when a different profile is selected. Better startup logging about the unit state. Added Beer, Fridge and partial Profile settings from the liveview weeb screen.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
2486 | */ |
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:
358
diff
changeset
|
2487 | unit->PID_cool->OutP = unit->PID_heat->OutP = 0.0; |
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:
358
diff
changeset
|
2488 | unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2489 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->light_state = 0; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2490 | unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
195
b34a1b2421fb
Reset output when a different profile is selected. Better startup logging about the unit state. Added Beer, Fridge and partial Profile settings from the liveview weeb screen.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
2491 | device_out(unit->heater_address, unit->heater_state); |
b34a1b2421fb
Reset output when a different profile is selected. Better startup logging about the unit state. Added Beer, Fridge and partial Profile settings from the liveview weeb screen.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
2492 | device_out(unit->cooler_address, unit->cooler_state); |
b34a1b2421fb
Reset output when a different profile is selected. Better startup logging about the unit state. Added Beer, Fridge and partial Profile settings from the liveview weeb screen.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
2493 | device_out(unit->fan_address, unit->fan_state); |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
2494 | device_out(unit->light_address, unit->light_state); |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
2495 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2496 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2497 | } else if (val && (strcmp(kwd, (char *)"PROF_STATE") == 0)) { |
217 | 2498 | for (i = 0; i < 5; i++) { |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2499 | if (strcmp(val, PROFSTATE[i]) == 0) { |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2500 | switch (i) { |
274
111b0e9663dc
Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
273
diff
changeset
|
2501 | case PROFILE_OFF: if (unit->prof_state == PROFILE_DONE) { |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2502 | unit->prof_state = PROFILE_OFF; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2503 | syslog(LOG_NOTICE, "Fermenter unit %s profile to OFF", unit->uuid); |
274
111b0e9663dc
Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
273
diff
changeset
|
2504 | } |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2505 | break; |
274
111b0e9663dc
Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
273
diff
changeset
|
2506 | case PROFILE_PAUSE: if (unit->prof_state == PROFILE_RUN) { |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2507 | unit->prof_state = PROFILE_PAUSE; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2508 | syslog(LOG_NOTICE, "Fermenter unit %s profile PAUSE", unit->uuid); |
274
111b0e9663dc
Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
273
diff
changeset
|
2509 | } else if (unit->prof_state == PROFILE_PAUSE) { |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2510 | unit->prof_state = PROFILE_RUN; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2511 | syslog(LOG_NOTICE, "Fermenter unit %s profile RESUME", unit->uuid); |
274
111b0e9663dc
Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
273
diff
changeset
|
2512 | } |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2513 | break; |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2514 | case PROFILE_RUN: if (unit->prof_state == PROFILE_OFF) { |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2515 | unit->prof_state = PROFILE_RUN; |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2516 | unit->prof_started = time(NULL); |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
2517 | unit->prof_paused = unit->prof_primary_done = 0; |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
2518 | unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2519 | syslog(LOG_NOTICE, "Fermenter unit %s profile to RUN", unit->uuid); |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2520 | } |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2521 | break; |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2522 | case PROFILE_DONE: break; /* Command is illegal */ |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2523 | case PROFILE_ABORT: if ((unit->prof_state == PROFILE_RUN) || (unit->prof_state == PROFILE_PAUSE)) { |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2524 | unit->prof_state = PROFILE_OFF; |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2525 | unit->prof_started = 0; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2526 | syslog(LOG_NOTICE, "Fermenter unit %s profile ABORT", unit->uuid); |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2527 | } |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2528 | break; |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2529 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2530 | break; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2531 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2532 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2533 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2534 | } else if (val && (strcmp(kwd, (char *)"TEMP_SET_MIN") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2535 | if (sscanf(val, "%f", &fval) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2536 | if (unit->temp_set_min != fval) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2537 | syslog(LOG_NOTICE, "Fermenter unit %s temperature set minimum %.1f to %.1f", unit->uuid, unit->temp_set_min, fval); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2538 | unit->temp_set_min = fval; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2539 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2540 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2541 | } else if (val && (strcmp(kwd, (char *)"TEMP_SET_MAX") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2542 | if (sscanf(val, "%f", &fval) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2543 | if (unit->temp_set_max != fval) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2544 | syslog(LOG_NOTICE, "Fermenter unit %s temperature set maximum %.1f to %.1f", unit->uuid, unit->temp_set_max, fval); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2545 | unit->temp_set_max = fval; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2546 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2547 | |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2548 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2549 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2550 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2551 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2552 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2553 | } |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
2554 | srv_send((char *)"440 No such unit"); |
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:
358
diff
changeset
|
2555 | run_pause = FALSE; |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2556 | return 0; |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2557 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2558 | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
2559 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2560 | return 0; |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2561 | } |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2562 | |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2563 | |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2564 | |
43 | 2565 | void cmd_server(void) |
2566 | { | |
132
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
2567 | char buf[SS_BUFSIZE]; |
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:
358
diff
changeset
|
2568 | int rlen; |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2569 | |
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:
358
diff
changeset
|
2570 | rlen = srv_recv(buf); |
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:
358
diff
changeset
|
2571 | if (rlen != -1) { |
48 | 2572 | if (strlen(buf)) { |
43 | 2573 | /* |
48 | 2574 | * Process commands from the client |
43 | 2575 | */ |
329 | 2576 | if (strncmp(buf, "ARCHIVE", 7) == 0) { |
2577 | cmd_archive(buf); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2578 | |
329 | 2579 | } else if (strncmp(buf, "DEVICE", 6) == 0) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2580 | if (cmd_device(buf)) |
174 | 2581 | wrconfig(); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2582 | |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
2583 | } else if (strncmp(buf, "GLOBAL", 6) == 0) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2584 | if (cmd_global(buf)) |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
2585 | wrconfig(); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2586 | |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
79
diff
changeset
|
2587 | } else if (strncmp(buf, "HELP", 4) == 0) { |
68
6dba71439cd8
Added first part of out own protocol
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
2588 | srv_send((char *)"100 Help text follows"); |
6dba71439cd8
Added first part of out own protocol
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
2589 | srv_send((char *)"Recognized commands:"); |
6dba71439cd8
Added first part of out own protocol
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
2590 | srv_send((char *)""); |
132
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
2591 | // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 |
331 | 2592 | srv_send((char *)"ARCHIVE <CMD> [parameters] Archive commands"); |
2593 | srv_send((char *)"ARCHIVE HELP Archive help screen"); | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2594 | srv_send((char *)"DEVICE <CMD> [parameters] Device commands"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2595 | srv_send((char *)"DEVICE HELP Device help screen"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2596 | srv_send((char *)"GLOBAL <CMD> [parameters] Global commands"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2597 | srv_send((char *)"GLOBAL HELP Global help screen"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2598 | srv_send((char *)"LIST <CMD> [parameters] List commands"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2599 | srv_send((char *)"LIST HELP List help screen"); |
330 | 2600 | srv_send((char *)"PING Check if server is alive"); |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2601 | srv_send((char *)"PROFILE <CMD> [parameters] Profile commands"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2602 | srv_send((char *)"PROFILE HELP Profile help screen"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
2603 | #ifdef USE_SIMULATOR |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2604 | srv_send((char *)"SIMULATOR <CMD> [parameters] Simulator commands"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2605 | srv_send((char *)"SIMULATOR HELP Simulator help screen"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
2606 | #endif |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2607 | srv_send((char *)"UNIT <CMD> [parameters] Unit commands"); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2608 | srv_send((char *)"UNIT HELP Unit help screen"); |
68
6dba71439cd8
Added first part of out own protocol
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
2609 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2610 | |
81 | 2611 | } else if (strncmp(buf, "LIST", 4) == 0) { |
2612 | cmd_list(buf); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2613 | |
303
19a9a3912d03
Added PING/PONG command to the server. Bumped to version 0.2.7
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
2614 | } else if (strncmp(buf, "PING", 4) == 0) { |
19a9a3912d03
Added PING/PONG command to the server. Bumped to version 0.2.7
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
2615 | srv_send((char *)"101 PONG"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2616 | |
132
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
2617 | } else if (strncmp(buf, "PROFILE", 7) == 0) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2618 | if (cmd_profile(buf)) |
132
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
2619 | wrconfig(); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2620 | |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
2621 | #ifdef USE_SIMULATOR |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
2622 | } else if (strncmp(buf, "SIMULATOR", 9) == 0) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2623 | if (cmd_simulator(buf)) |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
2624 | wrconfig(); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2625 | |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
2626 | #endif |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2627 | } else if (strncmp(buf, "UNIT", 4) == 0) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2628 | if (cmd_unit(buf)) |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
2629 | wrconfig(); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2630 | |
43 | 2631 | } else { |
132
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
2632 | srv_send((char *)"500 Unknown command"); |
43 | 2633 | } |
2634 | } | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2635 | } |
44 | 2636 | |
2637 | close(s); | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2638 | } |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2639 | |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2640 | |
132
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
2641 | |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2642 | #ifdef HAVE_WIRINGPI_H |
43 | 2643 | PI_THREAD (my_server_loop) |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2644 | #else |
74 | 2645 | void *my_server_loop(void *threadid) |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2646 | #endif |
43 | 2647 | { |
2648 | socklen_t addrlen; | |
44 | 2649 | int optval = 1; |
43 | 2650 | |
2651 | syslog(LOG_NOTICE, "Thread my_server_loop started"); | |
2652 | if (debug) | |
2653 | fprintf(stdout, "Thread my_server_loop started\n"); | |
2654 | ||
44 | 2655 | memset((char *)&myaddr_in, 0, sizeof(struct sockaddr_in)); |
2656 | memset((char *)&peeraddr_in, 0, sizeof(struct sockaddr_in)); | |
2657 | myaddr_in.sin_family = AF_INET; | |
2658 | myaddr_in.sin_addr.s_addr = INADDR_ANY; | |
2659 | myaddr_in.sin_port = htons(Config.my_port); | |
2660 | ||
2661 | ls = socket(AF_INET, SOCK_STREAM, 0); | |
2662 | if (ls == -1) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
2663 | syslog(LOG_NOTICE, "Can't create listen socket: %s", strerror(errno)); |
44 | 2664 | fprintf(stderr, "Can't create listen socket: %s\n", strerror(errno)); |
2665 | return 0; | |
2666 | } | |
2667 | ||
2668 | if (setsockopt(ls, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) == -1) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
2669 | syslog(LOG_NOTICE, "Can't setsockopt SO_KEEPALIVE socket: %s", strerror(errno)); |
44 | 2670 | close(ls); |
2671 | return 0; | |
2672 | } | |
2673 | ||
2674 | if (setsockopt(ls, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) == -1) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
2675 | syslog(LOG_NOTICE, "Can't setsockopt SO_REUSEADDR socket: %s", strerror(errno)); |
44 | 2676 | close(ls); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2677 | return 0; |
44 | 2678 | } |
2679 | ||
2680 | if (bind(ls, (struct sockaddr *)&myaddr_in, sizeof(struct sockaddr_in)) == -1) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
2681 | syslog(LOG_NOTICE, "Can't bind to listen socket: %s", strerror(errno)); |
44 | 2682 | close(ls); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2683 | return 0; |
44 | 2684 | } |
2685 | ||
2686 | if (listen(ls, 5) == -1) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
2687 | syslog(LOG_NOTICE, "Can't listen on listen socket: %s", strerror(errno)); |
44 | 2688 | close(ls); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2689 | return 0; |
44 | 2690 | } |
2691 | ||
2692 | syslog(LOG_NOTICE, "listen socket created %d", ls); | |
2693 | ||
2694 | ||
43 | 2695 | /* |
2696 | * Loop forever until the external shutdown variable is set. | |
2697 | */ | |
2698 | for (;;) { | |
2699 | ||
2700 | addrlen = sizeof(struct sockaddr_in); | |
2701 | /* | |
2702 | * This call will block until a new connection | |
2703 | * arrives. Then it will return the address of | |
2704 | * the connecting peer, and a new socket | |
2705 | * descriptor, s, for that connection. | |
2706 | */ | |
2707 | s = accept(ls, (struct sockaddr *)&peeraddr_in, &addrlen); | |
2708 | if (s == -1) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
2709 | syslog(LOG_NOTICE, "my_server_loop accept failed %s", strerror(errno)); |
43 | 2710 | if (debug) |
2711 | fprintf(stdout, "my_server_loop accept failed %s\n", strerror(errno)); | |
44 | 2712 | return 0; |
43 | 2713 | } |
2714 | ||
48 | 2715 | cmd_server(); |
43 | 2716 | |
2717 | if (my_shutdown) { | |
2718 | syslog(LOG_NOTICE, "Thread my_server_loop stopped"); | |
2719 | if (debug) | |
2720 | fprintf(stdout, "Thread my_server_loop stopped\n"); | |
2721 | return 0; | |
2722 | } | |
2723 | ||
2724 | } | |
2725 | } | |
2726 | ||
2727 |