Thu, 09 May 2019 16:40:17 +0200
Removed writing local unit data logs
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
2 | * Copyright (C) 2008-2019 |
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" |
184 | 25 | #include "devices.h" |
106 | 26 | #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
|
27 | #include "lcd-buffer.h" |
106 | 28 | #include "xutil.h" |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
493
diff
changeset
|
29 | #include "mqtt.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]; |
566 | 38 | extern const char UNITSTAGE[4][12]; |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
39 | 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
|
40 | extern const char DEVTYPE[8][6]; |
174 | 41 | extern const char DEVPRESENT[4][6]; |
42 | extern const char DEVDIR[7][11]; | |
217 | 43 | extern const char PROFSTATE[5][6]; |
174 | 44 | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | |
43 | 46 | int s; /* connected socket */ |
47 | int ls; /* listen socket */ | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | |
43 | 49 | struct sockaddr_in myaddr_in; /* for local socket address */ |
50 | struct sockaddr_in peeraddr_in; /* for peer socket address */ | |
51 | ||
52 | struct hostent *hp; | |
53 | ||
54 | #define SS_BUFSIZE 1024 | |
55 | #define SS_TIMEOUT 300 | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | |
389
584d40bb4b09
Graph lines logging can handle longer logfiles and has a safety limit.
Michiel Broek <mbroek@mbse.eu>
parents:
381
diff
changeset
|
57 | #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
|
58 | 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
|
59 | const int GRAPH_DATALINES[MAX_INTERVALS] = { 0, 800, 3200, 12000, 24000, 48000, 96000, 192000, 384000, 768000 }; |
329 | 60 | const char MONTH[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; |
61 | ||
62 | ||
63 | typedef struct _ls_list { | |
64 | struct _ls_list *next; /* Next record pointer */ | |
65 | char d_name[256]; /* File name */ | |
66 | mode_t mode; /* File mode */ | |
67 | off_t size; /* File size */ | |
68 | time_t mtime; /* File modification time */ | |
69 | } ls_list; | |
70 | ||
71 | ||
72 | ||
73 | void tidy_lslist(ls_list **); | |
74 | void fill_list(ls_list **, char *, mode_t, off_t, time_t); | |
75 | int comp(ls_list **,ls_list **); | |
76 | void sort_list(ls_list **); | |
77 | ||
78 | ||
46
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
79 | |
43 | 80 | /* |
81 | * Send message to client | |
82 | */ | |
83 | int srv_send(const char *format, ...) | |
84 | { | |
85 | char out[SS_BUFSIZE]; | |
86 | va_list va_ptr; | |
87 | ||
88 | if (s == -1) | |
89 | return -1; | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | |
43 | 91 | va_start(va_ptr, format); |
92 | vsnprintf(out, SS_BUFSIZE-1, format, va_ptr); | |
93 | va_end(va_ptr); | |
94 | ||
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
95 | // if (debug) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
96 | // syslog(LOG_NOTICE, "send: \"%s\"", out); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
97 | // fprintf(stdout, "send: \"%s\"\n", out); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
98 | // } |
44 | 99 | |
43 | 100 | 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
|
101 | syslog(LOG_NOTICE, "srv_send failed"); |
43 | 102 | return -1; |
103 | } | |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
79
diff
changeset
|
104 | |
43 | 105 | 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
|
106 | syslog(LOG_NOTICE, "srv_send failed"); |
43 | 107 | return -1; |
108 | } | |
109 | ||
110 | return 0; | |
111 | } | |
112 | ||
113 | ||
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | |
88 | 115 | /* |
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
|
116 | * 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
|
117 | * 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
|
118 | * 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
|
119 | */ |
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 | 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
|
121 | { |
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 | 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
|
123 | 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
|
124 | 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
|
125 | 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
|
126 | |
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 | 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
|
128 | |
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 | 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
|
130 | /* |
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 | * 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
|
132 | */ |
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 | 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
|
134 | ret = recvfrom(s, &buf, 1, 0, (struct sockaddr *)&peeraddr_in, &fromlen); |
368 | 135 | 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
|
136 | 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
|
137 | return -1; /* error */ |
368 | 138 | } else if (ret == 0) { |
139 | 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
|
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 | |
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 | 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
|
143 | 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
|
144 | |
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 | 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
|
146 | 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
|
147 | 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
|
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 | |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
151 | // if (debug) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
152 | // syslog(LOG_NOTICE, "recv: %d `%s'", bytesloaded, buffer); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
153 | // fprintf(stdout, "recv: %d `%s'\n", bytesloaded, buffer); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
154 | // } |
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
|
155 | 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
|
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 | |
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
|
160 | /* |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
161 | * 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
|
162 | */ |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
163 | 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
|
164 | { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
165 | 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
|
166 | |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
167 | 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
|
168 | if (strcmp(device->uuid, uuid) == 0) { |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
169 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
170 | piLock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
171 | #endif |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
172 | 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
|
173 | device->inuse++; |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
174 | } else { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
175 | 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
|
176 | device->inuse--; |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
177 | } |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
178 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
179 | piUnlock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
180 | #endif |
179
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 | |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
186 | |
329 | 187 | void tidy_lslist(ls_list **lap) |
188 | { | |
189 | ls_list *tmp, *old; | |
190 | ||
191 | for (tmp = *lap; tmp; tmp = old) { | |
192 | old = tmp->next; | |
193 | free(tmp); | |
194 | } | |
195 | *lap = NULL; | |
196 | } | |
197 | ||
198 | ||
199 | ||
200 | void fill_list(ls_list **lap, char *name, mode_t mode, off_t size, time_t mtime) | |
201 | { | |
202 | ls_list **tmp; | |
203 | ||
204 | for (tmp = lap; *tmp; tmp = &((*tmp)->next)); | |
205 | ||
206 | *tmp = (ls_list *)malloc(sizeof(ls_list)); | |
207 | (*tmp)->next = NULL; | |
208 | strncpy((*tmp)->d_name, name, 256); | |
209 | (*tmp)->mode = mode; | |
210 | (*tmp)->size = size; | |
211 | (*tmp)->mtime = mtime; | |
212 | tmp = &((*tmp)->next); | |
213 | } | |
214 | ||
215 | ||
216 | ||
217 | void sort_list(ls_list **lap) | |
218 | { | |
219 | ls_list *ta, **vector; | |
220 | size_t n = 0, i; | |
221 | ||
222 | if (*lap == NULL) | |
223 | return; | |
224 | ||
225 | for (ta = *lap; ta; ta = ta->next) | |
226 | n++; | |
227 | vector = (ls_list **)malloc(n * sizeof(ls_list *)); | |
228 | i = 0; | |
229 | ||
230 | for (ta = *lap; ta; ta = ta->next) { | |
231 | vector[i++] = ta; | |
232 | } | |
233 | qsort(vector, n, sizeof(ls_list *), (int(*)(const void*, const void*))comp); | |
234 | ||
235 | (*lap) = vector[0]; | |
236 | i = 1; | |
237 | ||
238 | for (ta = *lap; ta; ta = ta->next) { | |
239 | if (i < n) | |
240 | ta->next = vector[i++]; | |
241 | else | |
242 | ta->next = NULL; | |
243 | } | |
244 | ||
245 | free(vector); | |
246 | return; | |
247 | } | |
248 | ||
249 | ||
250 | ||
251 | int comp(ls_list **lsp1, ls_list **lsp2) | |
252 | { | |
253 | return strcmp((*lsp1)->d_name, (*lsp2)->d_name); | |
254 | } | |
255 | ||
256 | ||
257 | ||
258 | /* | |
259 | * ARCHIVE DIR | |
260 | * ARCHIVE GET filename | |
331 | 261 | * ARCHIVE LOG filename |
329 | 262 | * ARCHIVE HELP |
263 | */ | |
264 | int cmd_archive(char *buf) | |
265 | { | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
266 | char *opt, *param, *name = NULL, *filename = NULL, *logname = NULL, mbits[11], tstr[24]; |
329 | 267 | DIR *dd; |
268 | FILE *fp; | |
562 | 269 | struct dirent *result; |
329 | 270 | ls_list *lsx = NULL, *tmp; |
271 | struct stat sbuf; | |
272 | struct tm *tbuf; | |
273 | time_t ftime; | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
274 | int found; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
275 | units_list *unit; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
276 | |
329 | 277 | |
278 | opt = strtok(buf, " \0"); | |
279 | opt = strtok(NULL, " \0"); | |
280 | ||
281 | if (opt == NULL) { | |
282 | srv_send((char *)"501 Subcommand missing"); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
283 | return 0; |
329 | 284 | } |
285 | param = strtok(NULL, "\0"); | |
286 | ||
287 | if (strcmp(opt, (char *)"HELP") == 0) { | |
288 | srv_send((char *)"100 Help text follows:"); | |
289 | srv_send((char *)"Recognized commands:"); | |
290 | srv_send((char *)"ARCHIVE DIR Archived logfiles directory"); | |
291 | srv_send((char *)"ARCHIVE GET filename Archived logfile download"); | |
331 | 292 | srv_send((char *)"ARCHIVE LOG filename Archived logfile data in graphsteps"); |
329 | 293 | srv_send((char *)"."); |
294 | return 0; | |
295 | } | |
296 | ||
297 | if (strcmp(opt, (char *)"DIR") == 0) { | |
298 | ||
299 | if (getenv((char *)"USER") == NULL) { | |
300 | name = xstrcpy((char *)"/root"); | |
301 | } else { | |
302 | name = xstrcpy(getenv((char *)"HOME")); | |
303 | } | |
304 | name = xstrcat(name, (char *)"/.thermferm/log/"); | |
305 | ||
306 | if ((dd = opendir(name))) { | |
307 | for (;;) { | |
562 | 308 | if (! (result = readdir(dd))) { |
309 | syslog(LOG_NOTICE, "readdir: error=%d", errno); | |
329 | 310 | break; |
311 | } | |
312 | if (result->d_name[0] != '.') { | |
313 | filename = xstrcpy(name); | |
314 | 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
|
315 | /* |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
316 | * 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
|
317 | */ |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
318 | found = 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
319 | 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
|
320 | if (unit->mode != UNITMODE_OFF) { |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
321 | logname = xstrcpy(unit->product_code); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
322 | logname = xstrcat(logname, (char *)" "); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
323 | logname = xstrcat(logname, unit->product_name); |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
324 | 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
|
325 | 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
|
326 | found = 1; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
327 | free(logname); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
328 | logname = NULL; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
329 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
330 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
331 | if ((found == 0) && ((stat(filename, &sbuf)) == 0)) { |
329 | 332 | fill_list(&lsx, result->d_name, sbuf.st_mode, sbuf.st_size, sbuf.st_mtime); |
333 | } | |
334 | free(filename); | |
335 | filename = NULL; | |
336 | } | |
337 | } | |
338 | closedir(dd); | |
339 | } else { | |
340 | syslog(LOG_NOTICE, "opendir: \"%s\" error=%d", name, errno); | |
341 | } | |
342 | ||
343 | sort_list(&lsx); | |
344 | ||
345 | srv_send((char *)"212 Archive directory follows:"); | |
346 | for (tmp = lsx; tmp; tmp = tmp->next) { | |
347 | sprintf(mbits, "----------"); | |
348 | if (tmp->mode & S_IRUSR) | |
349 | mbits[1] = 'r'; | |
350 | if (tmp->mode & S_IWUSR) | |
351 | mbits[2] = 'w'; | |
352 | if (tmp->mode & S_IXUSR) | |
353 | mbits[3] = 'x'; | |
354 | if (tmp->mode & S_IRGRP) | |
355 | mbits[4] = 'r'; | |
356 | if (tmp->mode & S_IWGRP) | |
357 | mbits[5] = 'w'; | |
358 | if (tmp->mode & S_IXGRP) | |
359 | mbits[6] = 'x'; | |
360 | if (tmp->mode & S_IROTH) | |
361 | mbits[7] = 'r'; | |
362 | if (tmp->mode & S_IWOTH) | |
363 | mbits[8] = 'w'; | |
364 | if (tmp->mode & S_IXOTH) | |
365 | mbits[9] = 'x'; | |
366 | ftime = tmp->mtime; | |
367 | tbuf = localtime(&ftime); | |
368 | sprintf(tstr, "%02d %s %04d %02d:%02d", tbuf->tm_mday, MONTH[tbuf->tm_mon], tbuf->tm_year+1900, tbuf->tm_hour, tbuf->tm_min); | |
369 | srv_send((char *)"%s,%s,%d,%s", tmp->d_name, mbits, tmp->size, tstr); | |
370 | } | |
371 | srv_send((char *)"."); | |
372 | tidy_lslist(&lsx); | |
373 | ||
374 | free(name); | |
375 | name = NULL; | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
376 | return 0; |
329 | 377 | } |
378 | ||
379 | if (param == NULL) { | |
380 | srv_send((char *)"502 Parameter missing"); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
381 | return 0; |
329 | 382 | } |
383 | ||
384 | if (strcmp(opt, (char *)"GET") == 0) { | |
385 | if (getenv((char *)"USER") == NULL) { | |
386 | name = xstrcpy((char *)"/root"); | |
387 | } else { | |
388 | name = xstrcpy(getenv((char *)"HOME")); | |
389 | } | |
390 | name = xstrcat(name, (char *)"/.thermferm/log/"); | |
391 | name = xstrcat(name, param); | |
392 | ||
393 | if ((fp = fopen(name, "r"))) { | |
394 | char buffer[256]; | |
395 | ||
396 | srv_send((char *)"212 Archive file follows:"); | |
397 | while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { | |
398 | int i; | |
399 | ||
400 | for (i = 0; i < strlen(buffer); i++) { | |
401 | if (buffer[i] == '\n') | |
402 | buffer[i] = '\0'; | |
403 | if (buffer[i] == '\r') | |
404 | buffer[i] = '\0'; | |
405 | } | |
406 | srv_send(buffer); | |
407 | } | |
408 | srv_send((char *)"."); | |
409 | fclose(fp); | |
410 | } else { | |
411 | srv_send((char *)"440 No such file"); | |
331 | 412 | } |
413 | ||
414 | free(name); | |
415 | name = NULL; | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
416 | return 0; |
331 | 417 | } |
418 | ||
419 | if (strcmp(opt, (char *)"LOG") == 0) { | |
420 | if (getenv((char *)"USER") == NULL) { | |
421 | name = xstrcpy((char *)"/root"); | |
422 | } else { | |
423 | name = xstrcpy(getenv((char *)"HOME")); | |
424 | } | |
425 | name = xstrcat(name, (char *)"/.thermferm/log/"); | |
426 | name = xstrcat(name, param); | |
427 | ||
428 | 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
|
429 | char buffer[256], outbuf[256], q[5], hr[3]; |
536
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
430 | char *date_n, *mode_n, *air_n, *beer_n, *target_lo_n, *target_hi_n, *heater_n, *cooler_n, *room_n, *chiller_n; |
331 | 431 | char *heater_u, *cooler_u; |
432 | 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
|
433 | float room_t = 0.0; |
331 | 434 | |
435 | srv_send((char *)"212 Logfile list follows:"); | |
436 | while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { | |
437 | lines++; | |
438 | } | |
439 | fseek(fp, 0L, SEEK_SET); | |
440 | /* | |
441 | * We have counted the lines in the logfile including the header lines. | |
442 | * The header lines should be ignored but there are so few of them, we | |
443 | * just include them in the total. | |
444 | * Now find a reasonable interval of lines to sent to the client. | |
445 | */ | |
446 | for (graphstep = 1; graphstep <= MAX_INTERVALS; graphstep++) { | |
447 | if (lines < GRAPH_DATALINES[graphstep]) { | |
448 | break; | |
449 | } | |
450 | } | |
389
584d40bb4b09
Graph lines logging can handle longer logfiles and has a safety limit.
Michiel Broek <mbroek@mbse.eu>
parents:
381
diff
changeset
|
451 | 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
|
452 | graphstep = MAX_INTERVALS; |
331 | 453 | syslog(LOG_NOTICE, "ARCHIVE LOG %s: lines=%d, interval=%d, graphstep=%d", param, lines, GRAPH_INTERVAL[graphstep], graphstep); |
454 | ||
455 | while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { | |
456 | /* | |
536
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
457 | * 2014-11-15 18:39,BEER,20.312,19.750,20.0,0,NA,NA,NA,78105,NA,NA,18.000,20.1,5.312 |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
458 | * | | | | | | | | | | | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
459 | * date_n | | | | | | | | | | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
460 | * mode_n ----------+ | | | | | | | | | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
461 | * air_n -----------------+ | | | | | | | | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
462 | * beer_n -----------------------+ | | | | | | | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
463 | * target_lo_n ------------------------+ | | | | | | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
464 | * heater_n -------------------------------+ | | | | | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
465 | * cooler_n ---------------------------------+ | | | | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
466 | * not used ------------------------------------+ | | | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
467 | * not used ---------------------------------------+ | | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
468 | * heater_u --------------------------------------------+ | | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
469 | * cooler_u ------------------------------------------------+ | | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
470 | * not used ---------------------------------------------------+ | | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
471 | * room_n ----------------------------------------------------------+ | | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
472 | * target_hi_n -----------------------------------------------------------+ | |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
473 | * chiller_n ------------------------------------------------------------------+ |
331 | 474 | */ |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
475 | 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
|
476 | hr[1] = q[1] = buffer[12]; |
331 | 477 | q[2] = buffer[14]; |
478 | 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
|
479 | hr[2] = '\0'; |
331 | 480 | 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
|
481 | 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
|
482 | 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
|
483 | 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
|
484 | 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
|
485 | 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
|
486 | 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
|
487 | 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
|
488 | 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
|
489 | 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
|
490 | 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
|
491 | 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
|
492 | 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
|
493 | 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
|
494 | target_hi_n = strtok(NULL, ",\0"); /* target high temp */ |
536
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
495 | chiller_n = strtok(NULL, ",\0"); /* chiller temp */ |
331 | 496 | |
497 | if (strncmp(mode_n, (char *)"Mode", 4)) { | |
498 | /* | |
499 | * Output a line at the right intervals | |
500 | */ | |
390
daa435544ab1
Graphs stepping should now work for archives and current fermenters.
Michiel Broek <mbroek@mbse.eu>
parents:
389
diff
changeset
|
501 | int hour = atoi(hr); |
331 | 502 | if (((graphstep == 1)) || |
503 | ((graphstep == 2) && (q[3] == '0' || q[3] == '5')) || | |
504 | ((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'))) || | |
505 | ((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
|
506 | ((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
|
507 | ((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
|
508 | ((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
|
509 | ((graphstep >= 8) && (hour % 8 == 0) && (q[2] == '0' && q[3] == '0')) ) { /* 480 minutes */ |
331 | 510 | heat_used = cool_used = 0; |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
511 | if (heater_u && strcmp(heater_u, "NA") && (sscanf(heater_u, "%d", &h) == 1)) { |
331 | 512 | if (h && heater_l) { |
513 | heat_used = ((h - heater_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); | |
514 | } | |
515 | } | |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
516 | if (cooler_u && strcmp(cooler_u, "NA") && (sscanf(cooler_u, "%d", &c) == 1)) { |
331 | 517 | if (c && cooler_l) { |
518 | cool_used = ((c - cooler_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60); | |
519 | } | |
520 | } | |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
521 | if (room_n) |
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
522 | 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
|
523 | 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
|
524 | target_hi_n = target_lo_n; |
536
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
525 | snprintf(outbuf, 255, "%s,%s,%s,%s,%s,%s,%s,%d,%d,%.1f,%s,%s", |
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
526 | date_n, mode_n, air_n, beer_n, target_lo_n, heater_n, cooler_n, heat_used, cool_used, room_t,target_hi_n, chiller_n); |
331 | 527 | srv_send(outbuf); |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
528 | if (heater_u && h && strcmp(heater_u, "NA")) |
331 | 529 | heater_l = h; |
356
44bcfe087f9e
Added room temperature to ARCHIVE LOG command output.
Michiel Broek <mbroek@mbse.eu>
parents:
345
diff
changeset
|
530 | if (cooler_u && c & strcmp(cooler_u, "NA")) |
331 | 531 | cooler_l = c; |
532 | } | |
533 | } | |
534 | } | |
535 | ||
536 | srv_send((char *)"."); | |
537 | fclose(fp); | |
538 | } else { | |
539 | srv_send((char *)"440 No such file"); | |
329 | 540 | } |
541 | ||
542 | free(name); | |
543 | name = NULL; | |
544 | } | |
545 | ||
546 | return 0; | |
547 | } | |
548 | ||
549 | ||
550 | ||
174 | 551 | int delete_Device(char *uuid) |
552 | { | |
553 | devices_list *current = Config.devices; | |
554 | devices_list *previous = NULL; | |
555 | ||
556 | while (current) { | |
557 | if (strcmp(current->uuid, uuid) == 0) { | |
558 | if (previous == NULL) { | |
559 | Config.devices = current->next; | |
560 | free(current->uuid); | |
561 | current->uuid = NULL; | |
562 | free(current->address); | |
563 | current->address = NULL; | |
564 | free(current->description); | |
565 | current->description = NULL; | |
566 | free(current->comment); | |
567 | current->comment = NULL; | |
568 | free(current); | |
569 | return 1; | |
570 | } else { | |
571 | free(current->uuid); | |
572 | current->uuid = NULL; | |
573 | free(current->address); | |
574 | current->address = NULL; | |
575 | free(current->description); | |
576 | current->description = NULL; | |
577 | free(current->comment); | |
578 | current->comment = NULL; | |
579 | previous->next = current->next; | |
580 | free(current); | |
581 | current = previous->next; | |
582 | return 1; | |
583 | } | |
584 | } else { | |
585 | previous = current; | |
586 | current = current->next; | |
587 | } | |
588 | } | |
589 | return 0; | |
590 | } | |
591 | ||
592 | ||
593 | ||
81 | 594 | /* |
174 | 595 | * DEVICE ADD type |
596 | * DEVICE DEL uuid | |
597 | * DEVICE LIST | |
598 | * DEVICE GET uuid | |
599 | * DEVICE PUT uuid | |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
600 | */ |
174 | 601 | int cmd_device(char *buf) |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
602 | { |
174 | 603 | char *opt, *param, *kwd, *val, ibuf[SS_BUFSIZE]; |
604 | devices_list *device, *tmpd; | |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
605 | int i, rc, rlen, ival; |
174 | 606 | uuid_t uu; |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
607 | |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
608 | opt = strtok(buf, " \0"); |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
609 | opt = strtok(NULL, " \0"); |
174 | 610 | |
611 | if (opt == NULL) { | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
612 | srv_send((char *)"501 Subcommand missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
613 | return 0; |
174 | 614 | } |
615 | param = strtok(NULL, "\0"); | |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
616 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
617 | 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
|
618 | 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
|
619 | 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
|
620 | 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
|
621 | 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
|
622 | 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
|
623 | 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
|
624 | 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
|
625 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
626 | return 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
627 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
628 | |
174 | 629 | if (strcmp(opt, (char *)"LIST") == 0) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
630 | srv_send((char *)"212 Devices list follows:"); |
174 | 631 | 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
|
632 | 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
|
633 | device->inuse, device->comment, DEVDIR[device->direction], device->value + device->offset); |
174 | 634 | } |
635 | srv_send((char *)"."); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
636 | return 0; |
174 | 637 | } |
638 | ||
639 | if (param == NULL) { | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
640 | 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
|
641 | return 1; |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
642 | } |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
643 | |
174 | 644 | if (strcmp(opt, (char *)"ADD") == 0) { |
645 | if ((strcmp(param, (char *)"RC433") == 0) || (strcmp(param, (char *)"DHT") == 0) || | |
646 | (strcmp(param, (char *)"I2C") == 0) || (strcmp(param, (char *)"SPI") == 0)) { | |
170 | 647 | |
174 | 648 | device = (devices_list *)malloc(sizeof(devices_list)); |
649 | device->next = NULL; | |
650 | device->uuid = malloc(37); | |
651 | uuid_generate(uu); | |
652 | 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
|
653 | for (i = 0; i < 8; i++) { |
174 | 654 | if (strcmp(param, DEVTYPE[i]) == 0) { |
655 | device->type = i; | |
656 | break; | |
657 | } | |
658 | } | |
659 | device->direction = DEVDIR_UNDEF; | |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
660 | device->value = device->offset = device->subdevice = device->inuse = 0; |
174 | 661 | device->present = DEVPRESENT_UNDEF; |
662 | device->address = xstrcpy((char *)"Enter address here"); | |
663 | device->gpiopin = -1; | |
664 | device->description = xstrcpy((char *)"Describe me here"); | |
665 | device->comment = xstrcpy((char *)"Comment here"); | |
170 | 666 | |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
667 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
668 | piLock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
669 | #endif |
174 | 670 | if (Config.devices == NULL) { |
671 | Config.devices = device; | |
672 | } else { | |
673 | for (tmpd = Config.devices; tmpd; tmpd = tmpd->next) { | |
674 | if (tmpd->next == NULL) { | |
675 | tmpd->next = device; | |
676 | break; | |
677 | } | |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
678 | } |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
679 | } |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
680 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
681 | piUnlock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
682 | #endif |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
683 | syslog(LOG_NOTICE, "Device %s added", device->uuid); |
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
684 | 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
|
685 | return 1; |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
686 | |
174 | 687 | } else { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
688 | srv_send((char *)"503 Parameter error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
689 | return 0; |
157
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 | } |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
692 | |
174 | 693 | if (strcmp(opt, (char *)"DEL") == 0) { |
694 | ||
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
695 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
696 | piLock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
697 | #endif |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
698 | rc = delete_Device(param); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
699 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
700 | piUnlock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
701 | #endif |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
237
diff
changeset
|
702 | if (rc) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
703 | syslog(LOG_NOTICE, "Device %s deleted", param); |
174 | 704 | 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
|
705 | return 1; |
174 | 706 | } else { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
707 | srv_send((char *)"440 No such device"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
708 | return 0; |
174 | 709 | } |
710 | } | |
711 | ||
712 | if (strcmp(opt, (char *)"GET") == 0) { | |
713 | for (device = Config.devices; device; device = device->next) { | |
714 | if (strcmp(device->uuid, param) == 0) { | |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
715 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
716 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
717 | #endif |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
718 | int my_value = device->value; |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
719 | int my_timestamp = (int)device->timestamp; |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
720 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
721 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
722 | #endif |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
723 | srv_send((char *)"213 Device record follows:"); |
174 | 724 | 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
|
725 | srv_send((char *)"ADDRESS,%s", device->address); |
174 | 726 | 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
|
727 | 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
|
728 | srv_send((char *)"OFFSET,%d", device->offset); |
174 | 729 | srv_send((char *)"PRESENT,%s", DEVPRESENT[device->present]); |
730 | srv_send((char *)"SUBDEVICE,%d", device->subdevice); | |
731 | srv_send((char *)"GPIOPIN,%d", device->gpiopin); | |
732 | srv_send((char *)"DESCRIPTION,%s", device->description); | |
733 | srv_send((char *)"INUSE,%d", device->inuse); | |
734 | 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
|
735 | srv_send((char *)"TIMESTAMP,%d", my_timestamp); |
174 | 736 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
737 | return 0; |
174 | 738 | } |
739 | } | |
740 | srv_send((char *)"440 No such device"); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
741 | return 0; |
174 | 742 | } |
743 | ||
744 | if (strcmp(opt, (char *)"PUT") == 0) { | |
745 | for (device = Config.devices; device; device = device->next) { | |
746 | if (strcmp(device->uuid, param) == 0) { | |
747 | 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
|
748 | 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
|
749 | if (rlen == -1) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
750 | return 0; |
174 | 751 | } |
752 | if (strlen(ibuf)) { | |
753 | if (strcmp(ibuf, (char *)".") == 0) { | |
754 | srv_send((char *)"219 Accepted Device record"); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
755 | return 1; |
174 | 756 | } |
757 | kwd = strtok(ibuf, ",\0"); | |
758 | val = strtok(NULL, "\0"); | |
759 | if (kwd && val) { | |
760 | 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
|
761 | for (i = 0; i < 8; i++) { |
174 | 762 | if (strcmp(val, DEVTYPE[i]) == 0) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
763 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
764 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
765 | #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
|
766 | 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
|
767 | syslog(LOG_NOTICE, "Device %s changed type %s to %s", device->uuid, DEVTYPE[device->type], DEVTYPE[i]); |
174 | 768 | device->type = i; |
325
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 |
174 | 772 | break; |
773 | } | |
774 | } | |
775 | ||
776 | } else if (strcmp(kwd, (char *)"DIRECTION") == 0) { | |
777 | for (i = 0; i < 7; i++) { | |
778 | if (strcmp(val, DEVDIR[i]) == 0) { | |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
779 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
780 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
781 | #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
|
782 | 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
|
783 | syslog(LOG_NOTICE, "Device %s changed direction %s to %s", device->uuid, DEVDIR[device->type], DEVDIR[i]); |
174 | 784 | device->direction = i; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
785 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
786 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
787 | #endif |
174 | 788 | break; |
789 | } | |
790 | } | |
791 | ||
792 | } 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
|
793 | if (sscanf(val, "%d", &ival) == 1) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
794 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
795 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
796 | #endif |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
797 | 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
|
798 | syslog(LOG_NOTICE, "Device %s changed value %d to %d", device->uuid, device->value, ival); |
174 | 799 | device->value = ival; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
800 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
801 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
802 | #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
|
803 | } |
174 | 804 | |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
805 | } 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
|
806 | if (sscanf(val, "%d", &ival) == 1) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
807 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
808 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
809 | #endif |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
810 | 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
|
811 | 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
|
812 | device->offset = ival; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
813 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
814 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
815 | #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
|
816 | } |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
817 | |
174 | 818 | } else if (strcmp(kwd, (char *)"PRESENT") == 0) { |
819 | 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
|
820 | if (strcmp(val, DEVPRESENT[i]) == 0) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
821 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
822 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
823 | #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
|
824 | 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
|
825 | syslog(LOG_NOTICE, "Device %s changed present %s to %s", device->uuid, DEVPRESENT[device->present], DEVPRESENT[i]); |
174 | 826 | device->present = i; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
827 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
828 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
829 | #endif |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
830 | break; |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
831 | } |
174 | 832 | } |
833 | ||
834 | } 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
|
835 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
836 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
837 | #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
|
838 | 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
|
839 | if (strcmp(device->address, val)) |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
840 | syslog(LOG_NOTICE, "Device %s changed address `%s' to `%s'", device->uuid, device->address, val); |
174 | 841 | 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
|
842 | } |
174 | 843 | device->address = xstrcpy(val); |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
844 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
845 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
846 | #endif |
174 | 847 | |
848 | } 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
|
849 | if (sscanf(val, "%d", &ival) == 1) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
850 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
851 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
852 | #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
|
853 | 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
|
854 | syslog(LOG_NOTICE, "Device %s changed subdevice %d to %d", device->uuid, device->subdevice, ival); |
174 | 855 | device->subdevice = ival; |
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 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
858 | #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
|
859 | } |
174 | 860 | |
861 | } 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
|
862 | if (sscanf(val, "%d", &ival) == 1) { |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
863 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
864 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
865 | #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
|
866 | 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
|
867 | syslog(LOG_NOTICE, "Device %s changed gpiopin %d to %d", device->uuid, device->gpiopin, ival); |
174 | 868 | device->gpiopin = ival; |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
869 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
870 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
871 | #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
|
872 | } |
174 | 873 | |
874 | } 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
|
875 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
876 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
877 | #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
|
878 | 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
|
879 | if (strcmp(device->description, val)) |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
880 | syslog(LOG_NOTICE, "Device %s changed description `%s' to `%s'", device->uuid, device->description, val); |
174 | 881 | 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
|
882 | } |
174 | 883 | device->description = xstrcpy(val); |
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 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
886 | #endif |
174 | 887 | |
888 | } 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
|
889 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
890 | piLock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
891 | #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
|
892 | 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
|
893 | if (strcmp(device->comment, val)) |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
894 | syslog(LOG_NOTICE, "Device %s changed comment `%s' to `%s'", device->uuid, device->comment, val); |
174 | 895 | 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
|
896 | } |
174 | 897 | device->comment = xstrcpy(val); |
325
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
898 | #ifdef HAVE_WIRINGPI_H |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
899 | piUnlock(LOCK_DEVICES); |
35b6f6605ae3
More device locks in the network server
Michiel Broek <mbroek@mbse.eu>
parents:
313
diff
changeset
|
900 | #endif |
174 | 901 | |
902 | } | |
903 | } | |
904 | } | |
905 | } | |
906 | } | |
907 | } | |
908 | srv_send((char *)"440 No such device"); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
909 | return 0; |
174 | 910 | } |
911 | ||
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
912 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
913 | return 0; |
157
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
914 | } |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
915 | |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
916 | |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
917 | |
259a018758f9
Added GET AIR, GET BEER, GET TARGET commands
Michiel Broek <mbroek@mbse.eu>
parents:
156
diff
changeset
|
918 | /* |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
919 | * GLOBAL GET |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
920 | * GLOBAL PUT |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
921 | */ |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
922 | int cmd_global(char *buf) |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
923 | { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
924 | 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
|
925 | int ival, rlen; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
926 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
927 | opt = strtok(buf, " \0"); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
928 | opt = strtok(NULL, "\0"); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
929 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
930 | if (opt == NULL) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
931 | srv_send((char *)"501 Subcommand missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
932 | return 0; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
933 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
934 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
935 | 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
|
936 | 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
|
937 | 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
|
938 | 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
|
939 | 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
|
940 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
941 | return 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
942 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
943 | |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
944 | if (strcmp(opt, (char *)"GET") == 0) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
945 | 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
|
946 | srv_send((char *)"RELEASE,%s", VERSION); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
947 | srv_send((char *)"NAME,%s", Config.name); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
948 | 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
|
949 | srv_send((char *)"TEMPFORMAT,%c", Config.tempFormat); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
950 | 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
|
951 | 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
|
952 | 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
|
953 | 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
|
954 | 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
|
955 | srv_send((char *)"HUM_VALUE,%.0f", Config.hum_value / 1000.0); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
956 | srv_send((char *)"TEMP_HUM_IDX,%d", Config.temp_hum_idx); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
957 | 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
|
958 | srv_send((char *)"LCD_ROWS,%d", Config.lcd_rows); |
500
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
959 | srv_send((char *)"NEXT_UNIT,%d", Config.next_unit); |
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
960 | srv_send((char *)"MQTT_HOST,%s", Config.mqtt_host); |
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
961 | srv_send((char *)"MQTT_PORT,%d", Config.mqtt_port); |
534
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
962 | srv_send((char *)"MQTT_USER,%s", Config.mqtt_username); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
963 | srv_send((char *)"MQTT_PASS,%s", Config.mqtt_password); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
964 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
965 | return 0; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
966 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
967 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
968 | if (strcmp(opt, (char *)"PUT") == 0) { |
545
c382a6c58c20
Fixed compiling whithout mqtt support.
Michiel Broek <mbroek@mbse.eu>
parents:
542
diff
changeset
|
969 | int mqtt_reconnect = 0; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
970 | 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
|
971 | rlen = srv_recv(ibuf); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
972 | if (rlen == -1) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
973 | return 0; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
974 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
975 | if (strlen(ibuf)) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
976 | if (strcmp(ibuf, (char *)".") == 0) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
977 | srv_send((char *)"219 Accepted Global record"); |
534
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
978 | if (mqtt_reconnect) |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
979 | mqtt_connect(); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
980 | return 1; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
981 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
982 | kwd = strtok(ibuf, ",\0"); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
983 | val = strtok(NULL, "\0"); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
984 | if (kwd) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
985 | if (strcmp(kwd, (char *)"NAME") == 0) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
986 | if (val && Config.name && strcmp(val, Config.name)) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
987 | 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
|
988 | if (Config.name) |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
989 | free(Config.name); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
990 | if (val) |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
991 | Config.name = xstrcpy(val); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
992 | else |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
993 | Config.name = NULL; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
994 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
995 | } else if (val && (strcmp(kwd, (char *)"PORT") == 0)) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
996 | if (sscanf(val, "%d", &ival) == 1) { |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
997 | if (Config.my_port != ival) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
998 | 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
|
999 | Config.my_port = ival; |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1000 | } |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1001 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1002 | } else if (val && (strcmp(kwd, (char *)"TEMPFORMAT") == 0)) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1003 | if ((val[0] == 'C') || (val[0] == 'F')) { |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1004 | if (Config.tempFormat != val[0]) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1005 | 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
|
1006 | Config.tempFormat = val[0]; |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1007 | } |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1008 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1009 | } else if (strcmp(kwd, (char *)"TEMP_ADDRESS") == 0) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1010 | 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
|
1011 | 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
|
1012 | if (Config.temp_address) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1013 | device_count(FALSE, Config.temp_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1014 | free(Config.temp_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1015 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1016 | if (val) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1017 | Config.temp_address = xstrcpy(val); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1018 | device_count(TRUE, Config.temp_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1019 | } else |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1020 | Config.temp_address = NULL; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1021 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1022 | } else if (strcmp(kwd, (char *)"HUM_ADDRESS") == 0) { |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1023 | 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
|
1024 | 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
|
1025 | if (Config.hum_address) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1026 | device_count(FALSE, Config.hum_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1027 | free(Config.hum_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1028 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1029 | if (val) { |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1030 | Config.hum_address = xstrcpy(val); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1031 | device_count(TRUE, Config.hum_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1032 | } else |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1033 | Config.hum_address = NULL; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1034 | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1035 | } else if (val && (strcmp(kwd, (char *)"TEMP_HUM_IDX") == 0)) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1036 | if (sscanf(val, "%d", &ival) == 1) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1037 | if (Config.temp_hum_idx != ival) |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1038 | syslog(LOG_NOTICE, "Global Temp/Humidity idx %d to %d", Config.temp_hum_idx, ival); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1039 | Config.temp_hum_idx = ival; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1040 | } |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1041 | |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1042 | } 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
|
1043 | if (sscanf(val, "%d", &ival) == 1) { |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1044 | if (Config.lcd_cols != ival) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1045 | 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
|
1046 | Config.lcd_cols = ival; |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1047 | } |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1048 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1049 | } 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
|
1050 | if (sscanf(val, "%d", &ival) == 1) { |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1051 | if (Config.lcd_rows != ival) |
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1052 | 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
|
1053 | Config.lcd_rows = ival; |
278
76c8a6f18e4d
GLOBAL PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1054 | } |
534
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1055 | |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1056 | } else if (strcmp(kwd, (char *)"MQTT_HOST") == 0) { |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1057 | if (val && Config.mqtt_host && (strcmp(val, Config.mqtt_host))) |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1058 | syslog(LOG_NOTICE, "Global MQTT host `%s' to `%s'", Config.mqtt_host, val); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1059 | mqtt_disconnect(); |
545
c382a6c58c20
Fixed compiling whithout mqtt support.
Michiel Broek <mbroek@mbse.eu>
parents:
542
diff
changeset
|
1060 | mqtt_reconnect = 1; |
534
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1061 | if (Config.mqtt_host) |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1062 | free(Config.mqtt_host); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1063 | if (val) |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1064 | Config.mqtt_host = xstrcpy(val); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1065 | else |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1066 | Config.mqtt_host = NULL; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1067 | |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1068 | } else if (val && (strcmp(kwd, (char *)"MQTT_PORT") == 0)) { |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1069 | if (sscanf(val, "%d", &ival) == 1) { |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1070 | if (Config.mqtt_port != ival) { |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1071 | syslog(LOG_NOTICE, "Global MQTT port %d to %d", Config.mqtt_port, ival); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1072 | mqtt_disconnect(); |
545
c382a6c58c20
Fixed compiling whithout mqtt support.
Michiel Broek <mbroek@mbse.eu>
parents:
542
diff
changeset
|
1073 | mqtt_reconnect = 1; |
534
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1074 | Config.mqtt_port = ival; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1075 | } |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1076 | } |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1077 | |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1078 | } else if (strcmp(kwd, (char *)"MQTT_USER") == 0) { |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1079 | if (val && Config.mqtt_username && (strcmp(val, Config.mqtt_username))) |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1080 | syslog(LOG_NOTICE, "Global MQTT username `%s' to `%s'", Config.mqtt_username, val); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1081 | mqtt_disconnect(); |
545
c382a6c58c20
Fixed compiling whithout mqtt support.
Michiel Broek <mbroek@mbse.eu>
parents:
542
diff
changeset
|
1082 | mqtt_reconnect = 1; |
534
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1083 | if (Config.mqtt_username) |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1084 | free(Config.mqtt_username); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1085 | if (val) |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1086 | Config.mqtt_username = xstrcpy(val); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1087 | else |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1088 | Config.mqtt_username = NULL; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1089 | |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1090 | } else if (strcmp(kwd, (char *)"MQTT_PASS") == 0) { |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1091 | if (val && Config.mqtt_password && (strcmp(val, Config.mqtt_password))) |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1092 | syslog(LOG_NOTICE, "Global MQTT password `%s' to `%s'", Config.mqtt_password, val); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1093 | mqtt_disconnect(); |
545
c382a6c58c20
Fixed compiling whithout mqtt support.
Michiel Broek <mbroek@mbse.eu>
parents:
542
diff
changeset
|
1094 | mqtt_reconnect = 1; |
534
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1095 | if (Config.mqtt_password) |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1096 | free(Config.mqtt_password); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1097 | if (val) |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1098 | Config.mqtt_password = xstrcpy(val); |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1099 | else |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1100 | Config.mqtt_password = NULL; |
92b546d4a839
Versie 0.6.4. Aan de global setup de MQTT instellingen toegevoegd. Die zijn er ook als MQTT niet op het systeem aanwezig is. Indien het de global setup wijzigd, wordt de MQTT verbinding opnieuw gemaakt.
Michiel Broek <mbroek@mbse.eu>
parents:
533
diff
changeset
|
1101 | |
206
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 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1105 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1106 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1107 | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1108 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1109 | return 0; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1110 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1111 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1112 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1113 | |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
1114 | /* |
81 | 1115 | * LIST |
1116 | */ | |
1117 | int cmd_list(char *buf) | |
1118 | { | |
536
e833bbd5e733
Versie 0.6.5. LIST LOG <unit> commando verwijderd, alleen ARCHIVE LOG <unit> is nog in gebruik. De chiller temperatuur zit nu ook in de log en grafiek.
Michiel Broek <mbroek@mbse.eu>
parents:
534
diff
changeset
|
1119 | char *opt; |
84 | 1120 | units_list *unit; |
81 | 1121 | |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1122 | opt = strtok(buf, " \0"); |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1123 | opt = strtok(NULL, " \0"); |
84 | 1124 | |
81 | 1125 | if (opt == NULL) { |
92 | 1126 | /* |
1127 | * Default, list available units | |
1128 | */ | |
81 | 1129 | srv_send((char *)"212 Fermenter list follows:"); |
1130 | for (unit = Config.units; unit; unit = unit->next) { | |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1131 | srv_send((char *)"%s,%s,%s", unit->uuid, unit->alias, UNITMODE[unit->mode]); |
81 | 1132 | } |
1133 | srv_send((char *)"."); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1134 | return 0; |
92 | 1135 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1136 | } 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
|
1137 | 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
|
1138 | 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
|
1139 | 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
|
1140 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1141 | return 0; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1142 | } |
120 | 1143 | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1144 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1145 | return 0; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1146 | } |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1147 | |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1148 | |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
189
diff
changeset
|
1149 | |
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
|
1150 | #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
|
1151 | 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
|
1152 | { |
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
|
1153 | 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
|
1154 | 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
|
1155 | |
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
|
1156 | 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
|
1157 | 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
|
1158 | 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
|
1159 | 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
|
1160 | 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
|
1161 | 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
|
1162 | 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
|
1163 | 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
|
1164 | 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
|
1165 | 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
|
1166 | } 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
|
1167 | 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
|
1168 | 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
|
1169 | 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
|
1170 | 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
|
1171 | 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
|
1172 | 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
|
1173 | 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
|
1174 | 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
|
1175 | } |
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
|
1176 | } 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
|
1177 | 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
|
1178 | 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
|
1179 | } |
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
|
1180 | } |
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
|
1181 | 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
|
1182 | } |
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
|
1183 | |
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
|
1184 | |
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
|
1185 | |
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
|
1186 | /* |
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
|
1187 | * 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
|
1188 | * 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
|
1189 | * 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
|
1190 | * 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
|
1191 | * 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
|
1192 | */ |
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
|
1193 | 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
|
1194 | { |
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
|
1195 | 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
|
1196 | 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
|
1197 | 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
|
1198 | 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
|
1199 | 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
|
1200 | |
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
|
1201 | 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
|
1202 | 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
|
1203 | |
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
|
1204 | 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
|
1205 | srv_send((char *)"501 Subcommand missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1206 | 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
|
1207 | } |
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
|
1208 | 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
|
1209 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1210 | 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
|
1211 | 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
|
1212 | 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
|
1213 | 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
|
1214 | 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
|
1215 | 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
|
1216 | 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
|
1217 | 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
|
1218 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1219 | return 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1220 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1221 | |
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
|
1222 | 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
|
1223 | 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
|
1224 | 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
|
1225 | 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
|
1226 | } |
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
|
1227 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1228 | 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
|
1229 | } |
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
|
1230 | |
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
|
1231 | 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
|
1232 | srv_send((char *)"502 Parameter missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1233 | 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
|
1234 | } |
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
|
1235 | |
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
|
1236 | 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
|
1237 | |
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
|
1238 | /* |
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
|
1239 | * 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
|
1240 | */ |
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
|
1241 | 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
|
1242 | srv_send((char *)"441 Maximum simulators reached"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1243 | 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
|
1244 | } |
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
|
1245 | |
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
|
1246 | 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
|
1247 | 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
|
1248 | 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
|
1249 | 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
|
1250 | 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
|
1251 | 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
|
1252 | 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
|
1253 | 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
|
1254 | simulator->room_temperature = simulator->air_temperature = simulator->beer_temperature = simulator->s_cool_temp = simulator->s_heat_temp = 20.0; |
553
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1255 | simulator->room_humidity = 48.6; |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1256 | simulator->chiller_temperature = 1.5; /* Chiller temperature */ |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1257 | simulator->cooler_temp = 1.5; /* Cooling temperature */ |
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
|
1258 | 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
|
1259 | 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
|
1260 | 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
|
1261 | 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
|
1262 | 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
|
1263 | 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
|
1264 | 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
|
1265 | 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
|
1266 | 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
|
1267 | |
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
|
1268 | 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
|
1269 | 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
|
1270 | } 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
|
1271 | 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
|
1272 | 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
|
1273 | 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
|
1274 | 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
|
1275 | } |
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
|
1276 | } |
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
|
1277 | } |
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
|
1278 | |
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
|
1279 | 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
|
1280 | 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
|
1281 | 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
|
1282 | } |
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
|
1283 | |
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
|
1284 | 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
|
1285 | 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
|
1286 | 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
|
1287 | 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
|
1288 | 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
|
1289 | 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
|
1290 | } 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
|
1291 | srv_send((char *)"440 No such simulator"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1292 | 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
|
1293 | } |
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
|
1294 | } |
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
|
1295 | |
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
|
1296 | 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
|
1297 | 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
|
1298 | 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
|
1299 | 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
|
1300 | 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
|
1301 | 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
|
1302 | 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
|
1303 | srv_send((char *)"ROOM_TEMPERATURE,%.1f", simulator->room_temperature); |
553
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1304 | srv_send((char *)"ROOM_HUMIDITY,%.1f", simulator->room_humidity); |
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
|
1305 | 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
|
1306 | srv_send((char *)"BEER_TEMPERATURE,%.3f", simulator->beer_temperature); |
553
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1307 | srv_send((char *)"CHILLER_TEMPERATURE,%.3f", simulator->chiller_temperature); |
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
|
1308 | 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
|
1309 | srv_send((char *)"COOLER_TIME,%d", simulator->cooler_time); |
261 | 1310 | 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
|
1311 | 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
|
1312 | 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
|
1313 | 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
|
1314 | 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
|
1315 | srv_send((char *)"COOLER_STATE,%d", simulator->cooler_state); |
261 | 1316 | 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
|
1317 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1318 | 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
|
1319 | } |
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
|
1320 | } |
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
|
1321 | srv_send((char *)"440 No such simulator"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1322 | 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
|
1323 | } |
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
|
1324 | |
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
|
1325 | 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
|
1326 | 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
|
1327 | 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
|
1328 | 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
|
1329 | 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
|
1330 | if (rlen == -1) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1331 | 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
|
1332 | } |
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
|
1333 | 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
|
1334 | 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
|
1335 | srv_send((char *)"219 Accepted Simulator record"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1336 | 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
|
1337 | } |
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
|
1338 | 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
|
1339 | 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
|
1340 | 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
|
1341 | |
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
|
1342 | if (strcmp(kwd, (char *)"NAME") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1343 | if (simulator->name) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1344 | if (strcmp(simulator->name, val)) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1345 | 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
|
1346 | free(simulator->name); |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1347 | } |
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
|
1348 | 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
|
1349 | |
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
|
1350 | } else if (strcmp(kwd, (char *)"VOLUME_AIR") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1351 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1352 | if (simulator->volume_air != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1353 | 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
|
1354 | simulator->volume_air = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1355 | } |
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
|
1356 | |
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
|
1357 | } else if (strcmp(kwd, (char *)"VOLUME_BEER") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1358 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1359 | if (simulator->volume_beer != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1360 | 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
|
1361 | simulator->volume_beer = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1362 | } |
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
|
1363 | |
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
|
1364 | } else if (strcmp(kwd, (char *)"ROOM_TEMPERATURE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1365 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1366 | if (simulator->room_temperature != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1367 | 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
|
1368 | simulator->room_temperature = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1369 | } |
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
|
1370 | |
553
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1371 | } else if (strcmp(kwd, (char *)"ROOM_HUMIDITY") == 0) { |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1372 | if (sscanf(val, "%f", &fval) == 1) { |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1373 | if (simulator->room_humidity != fval) |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1374 | syslog(LOG_NOTICE, "Simulator %s room hunidity %.1f to %.1f", simulator->uuid, simulator->room_humidity, fval); |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1375 | simulator->room_humidity = fval; |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1376 | } |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1377 | |
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
|
1378 | } else if (strcmp(kwd, (char *)"AIR_TEMPERATURE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1379 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1380 | if (simulator->air_temperature != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1381 | 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
|
1382 | simulator->air_temperature = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1383 | } |
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
|
1384 | |
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
|
1385 | } else if (strcmp(kwd, (char *)"BEER_TEMPERATURE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1386 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1387 | if (simulator->beer_temperature != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1388 | 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
|
1389 | simulator->beer_temperature = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1390 | } |
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
|
1391 | |
553
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1392 | } else if (strcmp(kwd, (char *)"CHILLER_TEMPERATURE") == 0) { |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1393 | if (sscanf(val, "%f", &fval) == 1) { |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1394 | if (simulator->chiller_temperature != fval) |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1395 | syslog(LOG_NOTICE, "Simulator %s chiller temperature %.1f to %.1f", simulator->uuid, simulator->chiller_temperature, fval); |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1396 | simulator->chiller_temperature = fval; |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1397 | } |
4091d4fe217f
Updated simulator with more simulated devices.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1398 | |
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
|
1399 | } else if (strcmp(kwd, (char *)"COOLER_TEMP") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1400 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1401 | if (simulator->cooler_temp != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1402 | 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
|
1403 | simulator->cooler_temp = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1404 | } |
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
|
1405 | |
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
|
1406 | } else if (strcmp(kwd, (char *)"COOLER_TIME") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1407 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1408 | if (simulator->cooler_time != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1409 | 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
|
1410 | simulator->cooler_time = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1411 | } |
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
|
1412 | |
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
|
1413 | } else if (strcmp(kwd, (char *)"COOLER_SIZE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1414 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1415 | if (simulator->cooler_size != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1416 | 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
|
1417 | simulator->cooler_size = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1418 | } |
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
|
1419 | |
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
|
1420 | } else if (strcmp(kwd, (char *)"HEATER_TEMP") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1421 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1422 | if (simulator->heater_temp != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1423 | 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
|
1424 | simulator->heater_temp = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1425 | } |
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
|
1426 | |
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
|
1427 | } else if (strcmp(kwd, (char *)"HEATER_TIME") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1428 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1429 | if (simulator->heater_time != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1430 | 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
|
1431 | simulator->heater_time = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1432 | } |
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
|
1433 | |
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
|
1434 | } else if (strcmp(kwd, (char *)"HEATER_SIZE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1435 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1436 | if (simulator->heater_size != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1437 | 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
|
1438 | simulator->heater_size = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1439 | } |
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
|
1440 | |
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
|
1441 | } else if (strcmp(kwd, (char *)"HEATER_STATE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1442 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1443 | if (simulator->heater_state != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1444 | 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
|
1445 | simulator->heater_state = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1446 | } |
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
|
1447 | |
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
|
1448 | } else if (strcmp(kwd, (char *)"COOLER_STATE") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1449 | if (sscanf(val, "%d", &ival) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1450 | if (simulator->cooler_state != ival) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1451 | 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
|
1452 | simulator->cooler_state = ival; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1453 | } |
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
|
1454 | |
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
|
1455 | } else if (strcmp(kwd, (char *)"FRIGO_ISOLATION") == 0) { |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1456 | if (sscanf(val, "%f", &fval) == 1) { |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1457 | if (simulator->frigo_isolation != fval) |
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1458 | 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
|
1459 | simulator->frigo_isolation = fval; |
281
12a5dbbfd0e3
SIMULATOR PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
280
diff
changeset
|
1460 | } |
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
|
1461 | |
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
|
1462 | } |
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
|
1463 | } |
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
|
1464 | } |
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
|
1465 | } |
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
|
1466 | } |
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
|
1467 | } |
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
|
1468 | srv_send((char *)"440 No such simulator"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1469 | 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
|
1470 | } |
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
|
1471 | |
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
|
1472 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1473 | 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
|
1474 | } |
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
|
1475 | #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
|
1476 | |
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
|
1477 | |
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
|
1478 | |
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
|
1479 | 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
|
1480 | { |
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
|
1481 | 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
|
1482 | units_list *previous = NULL; |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1483 | prof_step *step, *olds; |
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
|
1484 | |
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
|
1485 | 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
|
1486 | 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
|
1487 | 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
|
1488 | 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
|
1489 | 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
|
1490 | current->uuid = NULL; |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1491 | if (current->product_uuid) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1492 | free(current->product_uuid); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1493 | current->product_uuid = NULL; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1494 | if (current->product_code) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1495 | free(current->product_code); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1496 | current->product_code = NULL; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1497 | if (current->product_name) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1498 | free(current->product_name); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1499 | current->product_name = 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
|
1500 | 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
|
1501 | 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
|
1502 | 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
|
1503 | 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
|
1504 | 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
|
1505 | current->beer_address = NULL; |
518
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1506 | if (current->chiller_address) |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1507 | free(current->chiller_address); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1508 | current->chiller_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
|
1509 | 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
|
1510 | 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
|
1511 | 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
|
1512 | 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
|
1513 | 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
|
1514 | 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
|
1515 | 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
|
1516 | 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
|
1517 | 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
|
1518 | 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
|
1519 | 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
|
1520 | 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
|
1521 | 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
|
1522 | 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
|
1523 | 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
|
1524 | 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
|
1525 | 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
|
1526 | current->psu_address = NULL; |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1527 | if (current->profile_uuid) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1528 | free(current->profile_uuid); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1529 | current->profile_uuid = NULL; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1530 | if (current->profile_name) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1531 | free(current->profile_name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1532 | current->profile_name = 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
|
1533 | 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
|
1534 | 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
|
1535 | 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
|
1536 | 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
|
1537 | 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
|
1538 | current->PID_heat = NULL; |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1539 | if (current->profile_steps) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1540 | for (step = current->profile_steps; step; step = olds) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1541 | olds = step->next; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1542 | free(step); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1543 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1544 | current->profile_steps = NULL; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1545 | } |
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
|
1546 | 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
|
1547 | 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
|
1548 | } 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
|
1549 | 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
|
1550 | current->uuid = NULL; |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1551 | if (current->product_uuid) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1552 | free(current->product_uuid); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1553 | current->product_uuid = NULL; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1554 | if (current->product_code) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1555 | free(current->product_code); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1556 | current->product_code = NULL; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1557 | if (current->product_name) |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1558 | free(current->product_name); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1559 | current->product_name = 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
|
1560 | 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
|
1561 | 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
|
1562 | 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
|
1563 | 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
|
1564 | 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
|
1565 | current->beer_address = NULL; |
518
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1566 | if (current->chiller_address) |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1567 | free(current->chiller_address); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1568 | current->chiller_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
|
1569 | 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
|
1570 | 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
|
1571 | 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
|
1572 | 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
|
1573 | 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
|
1574 | 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
|
1575 | 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
|
1576 | 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
|
1577 | 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
|
1578 | 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
|
1579 | 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
|
1580 | 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
|
1581 | 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
|
1582 | 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
|
1583 | 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
|
1584 | 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
|
1585 | 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
|
1586 | current->psu_address = NULL; |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1587 | if (current->profile_uuid) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1588 | free(current->profile_uuid); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1589 | current->profile_uuid = NULL; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1590 | if (current->profile_name) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1591 | free(current->profile_name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1592 | current->profile_name = 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
|
1593 | 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
|
1594 | 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
|
1595 | 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
|
1596 | 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
|
1597 | 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
|
1598 | current->PID_heat = NULL; |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1599 | if (current->profile_steps) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1600 | for (step = current->profile_steps; step; step = olds) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1601 | olds = step->next; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1602 | free(step); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1603 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1604 | current->profile_steps = NULL; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1605 | } |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1606 | 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
|
1607 | 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
|
1608 | 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
|
1609 | 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
|
1610 | } |
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
|
1611 | } 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
|
1612 | 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
|
1613 | 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
|
1614 | } |
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
|
1615 | } |
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
|
1616 | 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
|
1617 | } |
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
|
1618 | |
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
|
1619 | |
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
|
1620 | |
88 | 1621 | /* |
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
|
1622 | * 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
|
1623 | * 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
|
1624 | * 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
|
1625 | * 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
|
1626 | * UNIT PUT uuid |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1627 | */ |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1628 | int cmd_unit(char *buf) |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1629 | { |
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
|
1630 | 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
|
1631 | 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
|
1632 | 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
|
1633 | 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
|
1634 | float fval; |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1635 | |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1636 | opt = strtok(buf, " \0"); |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1637 | opt = strtok(NULL, " \0"); |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1638 | |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1639 | if (opt == NULL) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1640 | srv_send((char *)"501 Subcommand missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1641 | return 0; |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1642 | } |
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
|
1643 | param = strtok(NULL, "\0"); |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1644 | |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1645 | 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
|
1646 | 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
|
1647 | 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
|
1648 | 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
|
1649 | 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
|
1650 | 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
|
1651 | 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
|
1652 | 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
|
1653 | srv_send((char *)"."); |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1654 | return 0; |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1655 | } |
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
1656 | |
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
|
1657 | if ((strcmp(opt, (char *)"LIST") == 0) && (param == NULL)) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1658 | 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
|
1659 | for (unit = Config.units; unit; unit = unit->next) { |
566 | 1660 | if (strlen(unit->product_code) && strlen(unit->product_name)) { |
1661 | srv_send((char *)"%s,%s %s,%s", unit->uuid, unit->product_code, unit->product_name, UNITMODE[unit->mode]); | |
1662 | } else { | |
1663 | srv_send((char *)"%s,%s,%s", unit->uuid, unit->alias, UNITMODE[unit->mode]); | |
1664 | } | |
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
|
1665 | } |
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
|
1666 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1667 | 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
|
1668 | } |
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
|
1669 | |
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
|
1670 | if (param == NULL) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1671 | srv_send((char *)"502 Parameter missing"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1672 | 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
|
1673 | } |
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
|
1674 | |
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
|
1675 | if (strcmp(opt, (char *)"ADD") == 0) { |
500
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
1676 | char an[128]; |
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
1677 | |
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
1678 | sprintf(an, "unit%d", Config.next_unit); |
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
1679 | Config.next_unit++; |
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
|
1680 | 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
|
1681 | 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
|
1682 | 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
|
1683 | 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
|
1684 | uuid_unparse(uu, unit->uuid); |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1685 | unit->product_uuid = NULL; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1686 | unit->product_code = xstrcpy((char *)"FAKE0000"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1687 | unit->product_name = xstrcpy(param); |
500
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
1688 | unit->alias = xstrcpy(an); |
518
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1689 | unit->air_address = unit->beer_address = unit->chiller_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
|
1690 | unit->fan_address = unit->door_address = unit->light_address = \ |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1691 | unit->psu_address = unit->profile_uuid = unit->profile_name = NULL; |
518
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1692 | unit->air_idx = unit->beer_idx = unit->chiller_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \ |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1693 | unit->door_idx = unit->light_idx = unit->psu_idx = unit->profile_fridge_mode = \ |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1694 | unit->profile_duration = unit->profile_totalsteps = 0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1695 | unit->profile_steps = NULL; |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
1696 | unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
518
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1697 | unit->air_state = unit->beer_state = unit->chiller_state = 1; |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1698 | unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = 20000; |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
1699 | unit->beer_set_lo = unit->beer_set_hi = unit->fridge_set_lo = unit->fridge_set_hi = unit->profile_inittemp_lo = unit->profile_inittemp_hi =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
|
1700 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = \ |
582
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
578
diff
changeset
|
1701 | unit->light_state = unit->light_timer = unit->psu_state = unit->prof_state = unit->stage = 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
|
1702 | 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
|
1703 | 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
|
1704 | 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
|
1705 | 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
|
1706 | 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
|
1707 | unit->temp_set_max = 30.0; |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
1708 | 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
|
1709 | 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
|
1710 | 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
|
1711 | 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
|
1712 | 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
|
1713 | 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
|
1714 | |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1715 | /* |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1716 | * 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
|
1717 | */ |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1718 | 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
|
1719 | for (;;) { |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1720 | usleep(100000); |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1721 | 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
|
1722 | break; |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1723 | } |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1724 | |
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
|
1725 | 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
|
1726 | 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
|
1727 | } 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
|
1728 | 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
|
1729 | 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
|
1730 | 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
|
1731 | 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
|
1732 | } |
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
|
1733 | } |
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
|
1734 | } |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1735 | lcd_buf_reset(); |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1736 | 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
|
1737 | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1738 | syslog(LOG_NOTICE, "Unit %s added", unit->uuid); |
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1739 | 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
|
1740 | 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
|
1741 | } |
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
|
1742 | |
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
|
1743 | 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
|
1744 | /* |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1745 | * 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
|
1746 | */ |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1747 | 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
|
1748 | for (;;) { |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1749 | usleep(100000); |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1750 | 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
|
1751 | break; |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1752 | } |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1753 | |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1754 | rc = delete_Unit(param); |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1755 | lcd_buf_reset(); |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1756 | 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
|
1757 | |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
240
diff
changeset
|
1758 | if (rc) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1759 | 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
|
1760 | 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
|
1761 | 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
|
1762 | } else { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1763 | srv_send((char *)"440 No such unit"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1764 | 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
|
1765 | } |
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
|
1766 | } |
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
|
1767 | |
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
|
1768 | 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
|
1769 | 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
|
1770 | if (strcmp(param, unit->uuid) == 0) { |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1771 | 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
|
1772 | srv_send((char *)"UUID,%s", unit->uuid); |
500
5aa914eb644e
Units now have an unique alias name so that the MQTT messages are more friendly.
Michiel Broek <mbroek@mbse.eu>
parents:
499
diff
changeset
|
1773 | srv_send((char *)"ALIAS,%s", unit->alias); |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1774 | srv_send((char *)"PRODUCT_NAME,%s", unit->product_name); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1775 | srv_send((char *)"PRODUCT_CODE,%s", unit->product_code); |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
1776 | srv_send((char *)"MODE,%s", UNITMODE[unit->mode]); |
564
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
1777 | srv_send((char *)"STAGE,%s", UNITSTAGE[unit->stage]); |
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
|
1778 | 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
|
1779 | 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
|
1780 | 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
|
1781 | srv_send((char *)"AIR_TEMPERATURE,%.3f", unit->air_temperature / 1000.0); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1782 | srv_send((char *)"AIR_IDX,%d", unit->air_idx); |
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
|
1783 | 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
|
1784 | 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
|
1785 | srv_send((char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1786 | srv_send((char *)"BEER_IDX,%d", unit->beer_idx); |
518
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1787 | srv_send((char *)"CHILLER_ADDRESS,%s", MBSE_SS(unit->chiller_address)); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1788 | srv_send((char *)"CHILLER_STATE,%s", TEMPSTATE[unit->chiller_state]); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1789 | srv_send((char *)"CHILLER_TEMPERATURE,%.3f", unit->chiller_temperature / 1000.0); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1790 | srv_send((char *)"CHILLER_IDX,%d", unit->chiller_idx); |
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
|
1791 | 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
|
1792 | 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
|
1793 | srv_send((char *)"HEATER_DELAY,%d", unit->heater_delay); |
293 | 1794 | srv_send((char *)"HEATER_USAGE,%d", unit->heater_usage); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1795 | srv_send((char *)"HEATER_IDX,%d", unit->heater_idx); |
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
|
1796 | 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
|
1797 | 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
|
1798 | srv_send((char *)"PIDH_IDLERANGE,%.2f", unit->PID_heat->idleRange); |
492
750f2468dec5
Changed PID code. PID parameters are now stored 3 digits instead of 2 behind the decimal point. Prevent extreme heating or cooling in Beer mode. Heat and Cool lockdown now allows the lagest value to win instead of zero them both. PID output treshold from 2% to 50%.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
1799 | srv_send((char *)"PIDH_PGAIN,%.3f", unit->PID_heat->pGain); |
750f2468dec5
Changed PID code. PID parameters are now stored 3 digits instead of 2 behind the decimal point. Prevent extreme heating or cooling in Beer mode. Heat and Cool lockdown now allows the lagest value to win instead of zero them both. PID output treshold from 2% to 50%.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
1800 | srv_send((char *)"PIDH_IGAIN,%.3f", unit->PID_heat->iGain); |
750f2468dec5
Changed PID code. PID parameters are now stored 3 digits instead of 2 behind the decimal point. Prevent extreme heating or cooling in Beer mode. Heat and Cool lockdown now allows the lagest value to win instead of zero them both. PID output treshold from 2% to 50%.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
1801 | srv_send((char *)"PIDH_DGAIN,%.3f", unit->PID_heat->dGain); |
750f2468dec5
Changed PID code. PID parameters are now stored 3 digits instead of 2 behind the decimal point. Prevent extreme heating or cooling in Beer mode. Heat and Cool lockdown now allows the lagest value to win instead of zero them both. PID output treshold from 2% to 50%.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
1802 | srv_send((char *)"PIDH_SV,%.2f", unit->PID_heat->SetP); |
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
|
1803 | } |
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
|
1804 | 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
|
1805 | 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
|
1806 | srv_send((char *)"COOLER_DELAY,%d", unit->cooler_delay); |
293 | 1807 | srv_send((char *)"COOLER_USAGE,%d", unit->cooler_usage); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1808 | srv_send((char *)"COOLER_IDX,%d", unit->cooler_idx); |
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
|
1809 | 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
|
1810 | 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
|
1811 | srv_send((char *)"PIDC_IDLERANGE,%.2f", unit->PID_cool->idleRange); |
492
750f2468dec5
Changed PID code. PID parameters are now stored 3 digits instead of 2 behind the decimal point. Prevent extreme heating or cooling in Beer mode. Heat and Cool lockdown now allows the lagest value to win instead of zero them both. PID output treshold from 2% to 50%.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
1812 | srv_send((char *)"PIDC_PGAIN,%.3f", unit->PID_cool->pGain); |
750f2468dec5
Changed PID code. PID parameters are now stored 3 digits instead of 2 behind the decimal point. Prevent extreme heating or cooling in Beer mode. Heat and Cool lockdown now allows the lagest value to win instead of zero them both. PID output treshold from 2% to 50%.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
1813 | srv_send((char *)"PIDC_IGAIN,%.3f", unit->PID_cool->iGain); |
750f2468dec5
Changed PID code. PID parameters are now stored 3 digits instead of 2 behind the decimal point. Prevent extreme heating or cooling in Beer mode. Heat and Cool lockdown now allows the lagest value to win instead of zero them both. PID output treshold from 2% to 50%.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
1814 | srv_send((char *)"PIDC_DGAIN,%.3f", unit->PID_cool->dGain); |
750f2468dec5
Changed PID code. PID parameters are now stored 3 digits instead of 2 behind the decimal point. Prevent extreme heating or cooling in Beer mode. Heat and Cool lockdown now allows the lagest value to win instead of zero them both. PID output treshold from 2% to 50%.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
1815 | srv_send((char *)"PIDC_SV,%.2f", unit->PID_cool->SetP); |
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
|
1816 | } |
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
|
1817 | 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
|
1818 | 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
|
1819 | srv_send((char *)"FAN_DELAY,%d", unit->fan_delay); |
293 | 1820 | srv_send((char *)"FAN_USAGE,%d", unit->fan_usage); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1821 | srv_send((char *)"FAN_IDX,%d", unit->fan_idx); |
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
|
1822 | 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
|
1823 | 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
|
1824 | 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
|
1825 | srv_send((char *)"LIGHT_USAGE,%d", unit->light_usage); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1826 | srv_send((char *)"LIGHT_IDX,%d", unit->light_idx); |
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
|
1827 | 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
|
1828 | srv_send((char *)"DOOR_STATE,%d", unit->door_state); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1829 | srv_send((char *)"DOOR_IDX,%d", unit->door_idx); |
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
|
1830 | 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
|
1831 | srv_send((char *)"PSU_STATE,%d", unit->psu_state); |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1832 | srv_send((char *)"PSU_IDX,%d", unit->psu_idx); |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
1833 | srv_send((char *)"FRIDGE_SET_LO,%.1f", unit->fridge_set_lo); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
1834 | srv_send((char *)"FRIDGE_SET_HI,%.1f", unit->fridge_set_hi); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
1835 | srv_send((char *)"BEER_SET_LO,%.1f", unit->beer_set_lo); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
1836 | srv_send((char *)"BEER_SET_HI,%.1f", unit->beer_set_hi); |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1837 | if (unit->profile_uuid) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1838 | srv_send((char *)"PROFILE_UUID,%s", unit->profile_uuid); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1839 | srv_send((char *)"PROFILE_NAME,%s", unit->profile_name); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1840 | srv_send((char *)"PROFILE_INITTEMP_LO,%.1f", unit->profile_inittemp_lo); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1841 | srv_send((char *)"PROFILE_INITTEMP_HI,%.1f", unit->profile_inittemp_hi); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1842 | srv_send((char *)"PROFILE_FRIDGE_MODE,%d", unit->profile_fridge_mode); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1843 | srv_send((char *)"PROFILE_DURATION,%d", unit->profile_duration); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1844 | srv_send((char *)"PROFILE_TOTALSTEPS,%d", unit->profile_totalsteps); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1845 | srv_send((char *)"PROF_STARTED,%d", (int)unit->prof_started); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1846 | if (unit->prof_state == PROFILE_RUN) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1847 | srv_send((char *)"PROF_STATE,%s %d%%", PROFSTATE[unit->prof_state], unit->prof_percent); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1848 | } else { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1849 | srv_send((char *)"PROF_STATE,%s", PROFSTATE[unit->prof_state]); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1850 | } |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1851 | srv_send((char *)"PROF_TARGET_LO,%.3f", unit->prof_target_lo); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1852 | srv_send((char *)"PROF_TARGET_HI,%.3f", unit->prof_target_hi); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1853 | srv_send((char *)"PROF_FRIDGE_MODE,%d", unit->prof_fridge_mode); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1854 | srv_send((char *)"PROF_PEAK_ABS,%.3f", unit->prof_peak_abs); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1855 | srv_send((char *)"PROF_PEAK_REL,%.3f", unit->prof_peak_rel); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
1856 | srv_send((char *)"PROF_PRIMARY_DONE,%d", (int)unit->prof_primary_done); |
284
9e6fb5aed618
Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
1857 | } |
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
|
1858 | 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
|
1859 | srv_send((char *)"TEMP_SET_MAX,%.1f", unit->temp_set_max); |
529 | 1860 | srv_send((char *)"ALARM,%d", unit->alarm_flag); |
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
|
1861 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1862 | return 0; |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1863 | } |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1864 | } |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
1865 | srv_send((char *)"440 No such unit"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1866 | return 0; |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1867 | } |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1868 | |
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 (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
|
1870 | /* |
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
|
1871 | * 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
|
1872 | */ |
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
|
1873 | 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
|
1874 | 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
|
1875 | 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
|
1876 | 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
|
1877 | 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
|
1878 | } |
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 | |
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
|
1880 | 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
|
1881 | 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
|
1882 | while (1) { |
506 | 1883 | unit->mqtt_flag = 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
|
1884 | 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
|
1885 | 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
|
1886 | run_pause = FALSE; |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1887 | 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
|
1888 | } |
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 | 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
|
1890 | 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
|
1891 | 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
|
1892 | run_pause = FALSE; |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
1893 | 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
|
1894 | } |
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 | 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
|
1896 | val = strtok(NULL, "\0"); |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
1897 | if (kwd) { |
506 | 1898 | unit->mqtt_flag = 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
|
1899 | /* |
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 | * 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
|
1901 | * 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
|
1902 | * 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
|
1903 | */ |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1904 | if (val && (strcmp(kwd, (char *)"PRODUCT_CODE") == 0)) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1905 | if (unit->product_code) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1906 | if (strcmp(unit->product_code, val)) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1907 | syslog(LOG_NOTICE, "Fermenter unit %s name `%s' to `%s'", unit->uuid, unit->product_code, val); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
493
diff
changeset
|
1908 | } |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1909 | free(unit->product_code); |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
1910 | } |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1911 | unit->product_code = xstrcpy(val); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1912 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1913 | |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1914 | } else if (val && (strcmp(kwd, (char *)"PRODUCT_NAME") == 0)) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1915 | if (unit->product_name) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1916 | if (strcmp(unit->product_name, val)) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1917 | syslog(LOG_NOTICE, "Fermenter unit %s name `%s' to `%s'", unit->uuid, unit->product_name, val); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1918 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1919 | free(unit->product_name); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1920 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
553
diff
changeset
|
1921 | unit->product_name = xstrcpy(val); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
1922 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
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
|
1923 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
1924 | } else if (val && (strcmp(kwd, (char *)"VOLUME") == 0)) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
1925 | if (sscanf(val, "%f", &fval) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
1926 | if (unit->volume != fval) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
1927 | 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
|
1928 | unit->volume = fval; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
1929 | } |
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
|
1930 | |
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 | } else if (strcmp(kwd, (char *)"AIR_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
1932 | 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
|
1933 | 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
|
1934 | 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
|
1935 | 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
|
1936 | 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
|
1937 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
1938 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
1939 | 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
|
1940 | 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
|
1941 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
1942 | unit->air_address = NULL; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
1943 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
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
|
1944 | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1945 | } else if (val && (strcmp(kwd, (char *)"AIR_IDX") == 0)) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1946 | if (sscanf(val, "%d", &ival) == 1) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1947 | if (unit->air_idx != ival) |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1948 | syslog(LOG_NOTICE, "Fermenter unit %s air idx %d to %d", unit->uuid, unit->air_idx, ival); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1949 | unit->air_idx = ival; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1950 | } |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1951 | |
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 | } else if (strcmp(kwd, (char *)"BEER_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
1953 | 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
|
1954 | 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
|
1955 | 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
|
1956 | 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
|
1957 | 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
|
1958 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
1959 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
1960 | 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
|
1961 | 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
|
1962 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
1963 | unit->beer_address = NULL; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
1964 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
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
|
1965 | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1966 | } else if (val && (strcmp(kwd, (char *)"BEER_IDX") == 0)) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1967 | if (sscanf(val, "%d", &ival) == 1) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1968 | if (unit->beer_idx != ival) |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1969 | syslog(LOG_NOTICE, "Fermenter unit %s beer idx %d to %d", unit->uuid, unit->beer_idx, ival); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1970 | unit->beer_idx = ival; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1971 | } |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
1972 | |
518
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1973 | } else if (strcmp(kwd, (char *)"CHILLER_ADDRESS") == 0) { |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1974 | if (val && unit->chiller_address && (strcmp(val, unit->chiller_address))) |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1975 | syslog(LOG_NOTICE, "Fermenter unit %s chiller address `%s' to `%s'", unit->uuid, unit->chiller_address, val); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1976 | if (unit->chiller_address) { |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1977 | device_count(FALSE, unit->chiller_address); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1978 | free(unit->chiller_address); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1979 | } |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1980 | if (val) { |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1981 | unit->chiller_address = xstrcpy(val); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1982 | device_count(TRUE, unit->chiller_address); |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1983 | } else |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1984 | unit->chiller_address = NULL; |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1985 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1986 | |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1987 | } else if (val && (strcmp(kwd, (char *)"CHILLER_IDX") == 0)) { |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1988 | if (sscanf(val, "%d", &ival) == 1) { |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1989 | if (unit->chiller_idx != ival) |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1990 | syslog(LOG_NOTICE, "Fermenter unit %s chiller idx %d to %d", unit->uuid, unit->chiller_idx, ival); |
520 | 1991 | unit->chiller_idx = ival; |
518
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1992 | } |
fd36bedab944
Added chiller configuration items
Michiel Broek <mbroek@mbse.eu>
parents:
513
diff
changeset
|
1993 | |
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
|
1994 | } else if (strcmp(kwd, (char *)"HEATER_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
1995 | 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
|
1996 | 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
|
1997 | 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
|
1998 | 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
|
1999 | 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
|
2000 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2001 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2002 | 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
|
2003 | 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
|
2004 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2005 | unit->heater_address = NULL; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2006 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2007 | |
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2008 | } 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
|
2009 | 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
|
2010 | if (unit->heater_state != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2011 | 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
|
2012 | unit->heater_state = ival; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2013 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2014 | } |
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
|
2015 | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2016 | } else if (val && (strcmp(kwd, (char *)"HEATER_IDX") == 0)) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2017 | if (sscanf(val, "%d", &ival) == 1) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2018 | if (unit->heater_idx != ival) |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2019 | syslog(LOG_NOTICE, "Fermenter unit %s heater idx %d to %d", unit->uuid, unit->heater_idx, ival); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2020 | unit->heater_idx = ival; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2021 | } |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2022 | |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2023 | } 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
|
2024 | if (sscanf(val, "%d", &ival) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2025 | if (unit->heater_delay != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2026 | 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
|
2027 | unit->heater_delay = ival; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2028 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2029 | |
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
|
2030 | } else if (strcmp(kwd, (char *)"COOLER_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2031 | 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
|
2032 | 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
|
2033 | 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
|
2034 | 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
|
2035 | 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
|
2036 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2037 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2038 | 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
|
2039 | 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
|
2040 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2041 | unit->cooler_address = NULL; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2042 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2043 | |
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2044 | } 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
|
2045 | 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
|
2046 | if (unit->cooler_state != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2047 | 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
|
2048 | unit->cooler_state = ival; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2049 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2050 | } |
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
|
2051 | |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2052 | } 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
|
2053 | if (sscanf(val, "%d", &ival) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2054 | if (unit->cooler_delay != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2055 | 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
|
2056 | unit->cooler_delay = ival; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2057 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2058 | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2059 | } else if (val && (strcmp(kwd, (char *)"COOLER_IDX") == 0)) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2060 | if (sscanf(val, "%d", &ival) == 1) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2061 | if (unit->cooler_idx != ival) |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2062 | syslog(LOG_NOTICE, "Fermenter unit %s cooler idx %d to %d", unit->uuid, unit->cooler_idx, ival); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2063 | unit->cooler_idx = ival; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2064 | } |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2065 | |
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
|
2066 | } else if (strcmp(kwd, (char *)"FAN_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2067 | 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
|
2068 | 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
|
2069 | 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
|
2070 | device_count(FALSE, unit->fan_address); |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2071 | 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
|
2072 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2073 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2074 | 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
|
2075 | 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
|
2076 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2077 | unit->fan_address = NULL; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2078 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
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
|
2079 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2080 | } 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
|
2081 | 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
|
2082 | if (unit->fan_state != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2083 | 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
|
2084 | unit->fan_state = ival; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2085 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2086 | } |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2087 | |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2088 | } 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
|
2089 | if (sscanf(val, "%d", &ival) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2090 | if (unit->fan_delay != ival) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2091 | 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
|
2092 | unit->fan_delay = ival; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2093 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
269
diff
changeset
|
2094 | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2095 | } else if (val && (strcmp(kwd, (char *)"FAN_IDX") == 0)) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2096 | if (sscanf(val, "%d", &ival) == 1) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2097 | if (unit->fan_idx != ival) |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2098 | syslog(LOG_NOTICE, "Fermenter unit %s fan idx %d to %d", unit->uuid, unit->fan_idx, ival); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2099 | unit->fan_idx = ival; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2100 | } |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2101 | |
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
|
2102 | } 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
|
2103 | 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
|
2104 | 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
|
2105 | 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
|
2106 | 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
|
2107 | 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
|
2108 | } |
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
|
2109 | 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
|
2110 | 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
|
2111 | 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
|
2112 | } 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
|
2113 | unit->light_address = NULL; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2114 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
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 | |
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 | } 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
|
2117 | 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
|
2118 | 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
|
2119 | 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
|
2120 | unit->light_state = ival; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2121 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
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
|
2122 | } |
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
|
2123 | |
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
|
2124 | } 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
|
2125 | 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
|
2126 | 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
|
2127 | 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
|
2128 | 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
|
2129 | } |
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
|
2130 | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2131 | } else if (val && (strcmp(kwd, (char *)"LIGHT_IDX") == 0)) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2132 | if (sscanf(val, "%d", &ival) == 1) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2133 | if (unit->light_idx != ival) |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2134 | syslog(LOG_NOTICE, "Fermenter unit %s light idx %d to %d", unit->uuid, unit->light_idx, ival); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2135 | unit->light_idx = ival; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2136 | } |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2137 | |
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
|
2138 | } else if (strcmp(kwd, (char *)"DOOR_ADDRESS") == 0) { |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2139 | 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
|
2140 | 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
|
2141 | 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
|
2142 | device_count(FALSE, unit->door_address); |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2143 | 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
|
2144 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
178
diff
changeset
|
2145 | if (val) { |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2146 | 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
|
2147 | 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
|
2148 | } else |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2149 | 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
|
2150 | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2151 | } else if (val && (strcmp(kwd, (char *)"DOOR_IDX") == 0)) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2152 | if (sscanf(val, "%d", &ival) == 1) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2153 | if (unit->door_idx != ival) |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2154 | syslog(LOG_NOTICE, "Fermenter unit %s door idx %d to %d", unit->uuid, unit->door_idx, ival); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2155 | unit->door_idx = ival; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2156 | } |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2157 | |
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
|
2158 | } 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
|
2159 | 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
|
2160 | 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
|
2161 | 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
|
2162 | 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
|
2163 | 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
|
2164 | } |
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
|
2165 | 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
|
2166 | 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
|
2167 | 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
|
2168 | } 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
|
2169 | unit->psu_address = NULL; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2170 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
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
|
2171 | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2172 | } else if (val && (strcmp(kwd, (char *)"PSU_IDX") == 0)) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2173 | if (sscanf(val, "%d", &ival) == 1) { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2174 | if (unit->psu_idx != ival) |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2175 | syslog(LOG_NOTICE, "Fermenter unit %s psu idx %d to %d", unit->uuid, unit->psu_idx, ival); |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2176 | unit->psu_idx = ival; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2177 | } |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2178 | |
564
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2179 | } else if (val && (strcmp(kwd, (char *)"STAGE") == 0)) { |
566 | 2180 | for (i = 0; i < 4; i++) { |
564
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2181 | if (strcmp(val, UNITSTAGE[i]) == 0) { |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2182 | if (i != unit->stage) { |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2183 | syslog(LOG_NOTICE, "Fermenter unit %s stage %s to %s", unit->uuid, UNITSTAGE[unit->stage], UNITSTAGE[i]); |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2184 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2185 | } |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2186 | unit->stage = i; |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2187 | break; |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2188 | } |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2189 | } |
3fc61dd28656
Versie 0.8.8 Fermentation stage implemented in units.
Michiel Broek <mbroek@mbse.eu>
parents:
562
diff
changeset
|
2190 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2191 | } 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
|
2192 | 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
|
2193 | if (strcmp(val, UNITMODE[i]) == 0) { |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2194 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
189
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
2195 | /* Initialize log if the unit is turned on */ |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2196 | if ((unit->mode == UNITMODE_OFF) && (i != UNITMODE_OFF)) { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2197 | unit->mqtt_flag |= MQTT_FLAG_BIRTH; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2198 | } else if ((unit->mode != UNITMODE_OFF) && (i == UNITMODE_OFF)) { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2199 | unit->mqtt_flag |= MQTT_FLAG_DEATH; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2200 | } |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2201 | 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
|
2202 | unit->mode = i; |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2203 | /* 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
|
2204 | 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
|
2205 | unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; |
582
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
578
diff
changeset
|
2206 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->light_state = unit->light_timer = 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
|
2207 | unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
184 | 2208 | device_out(unit->heater_address, unit->heater_state); |
2209 | device_out(unit->cooler_address, unit->cooler_state); | |
2210 | 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
|
2211 | 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
|
2212 | if (unit->mode == UNITMODE_PROFILE) { |
51a294d683cd
Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
2213 | /* |
51a294d683cd
Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
2214 | * 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
|
2215 | * main processing loop. |
51a294d683cd
Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
2216 | */ |
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
|
2217 | 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
|
2218 | unit->prof_fridge_mode = 0; |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
2219 | if (unit->profile_uuid) { |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2220 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
493
diff
changeset
|
2221 | } |
237
51a294d683cd
Add a sane default for profile precessing.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
2222 | } |
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
|
2223 | 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
|
2224 | } |
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
|
2225 | } |
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
|
2226 | |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2227 | } else if (val && (strcmp(kwd, (char *)"FRIDGE_SET_LO") == 0)) { |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
2228 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) { |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2229 | if (unit->fridge_set_lo != fval) |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2230 | syslog(LOG_NOTICE, "Fermenter unit %s fridge temp low %.1f to %.1f", unit->uuid, unit->fridge_set_lo, fval); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2231 | unit->fridge_set_lo = fval; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2232 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
2233 | } |
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
|
2234 | |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2235 | } else if (val && (strcmp(kwd, (char *)"FRIDGE_SET_HI") == 0)) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2236 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2237 | if (unit->fridge_set_hi != fval) |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2238 | syslog(LOG_NOTICE, "Fermenter unit %s fridge temp high %.1f to %.1f", unit->uuid, unit->fridge_set_hi, fval); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2239 | unit->fridge_set_hi = fval; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2240 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2241 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2242 | |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2243 | } else if (val && (strcmp(kwd, (char *)"BEER_SET_LO") == 0)) { |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
2244 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) { |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2245 | if (unit->beer_set_lo != fval) |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2246 | syslog(LOG_NOTICE, "Fermenter unit %s beer temp low %.1f to %.1f", unit->uuid, unit->beer_set_lo, fval); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2247 | unit->beer_set_lo = fval; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2248 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2249 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2250 | |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2251 | } else if (val && (strcmp(kwd, (char *)"BEER_SET_HI") == 0)) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2252 | if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2253 | if (unit->beer_set_hi != fval) |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2254 | syslog(LOG_NOTICE, "Fermenter unit %s beer temp high %.1f to %.1f", unit->uuid, unit->beer_set_hi, fval); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
575
diff
changeset
|
2255 | unit->beer_set_hi = fval; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2256 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
2257 | } |
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
|
2258 | |
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
|
2259 | } 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
|
2260 | 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
|
2261 | 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
|
2262 | 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
|
2263 | 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
|
2264 | } |
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
|
2265 | |
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
|
2266 | } 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
|
2267 | 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
|
2268 | if (unit->PID_cool->pGain != fval) |
493
04d726035afe
Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
2269 | syslog(LOG_NOTICE, "Fermenter unit %s PID_cool pGain %.3f to %.3f", unit->uuid, unit->PID_cool->pGain, fval); |
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
|
2270 | 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
|
2271 | } |
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
|
2272 | |
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
|
2273 | } 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
|
2274 | 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
|
2275 | if (unit->PID_cool->dGain != fval) |
493
04d726035afe
Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
2276 | syslog(LOG_NOTICE, "Fermenter unit %s PID_cool dGain %.3f to %.3f", unit->uuid, unit->PID_cool->dGain, fval); |
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
|
2277 | 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
|
2278 | } |
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
|
2279 | |
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
|
2280 | } 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
|
2281 | 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
|
2282 | if (unit->PID_cool->iGain != fval) |
493
04d726035afe
Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
2283 | syslog(LOG_NOTICE, "Fermenter unit %s PID_cool iGain %.3f to %.3f", unit->uuid, unit->PID_cool->iGain, fval); |
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
|
2284 | 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
|
2285 | } |
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
|
2286 | |
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
|
2287 | } 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
|
2288 | 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
|
2289 | 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
|
2290 | 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
|
2291 | 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
|
2292 | } |
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
|
2293 | |
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
|
2294 | } 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
|
2295 | 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
|
2296 | 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
|
2297 | 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
|
2298 | 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
|
2299 | } |
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
|
2300 | |
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
|
2301 | } 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
|
2302 | 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
|
2303 | if (unit->PID_heat->pGain != fval) |
493
04d726035afe
Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
2304 | syslog(LOG_NOTICE, "Fermenter unit %s PID_heat pGain %.3f to %.3f", unit->uuid, unit->PID_heat->pGain, fval); |
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
|
2305 | 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
|
2306 | } |
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
|
2307 | |
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
|
2308 | } 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
|
2309 | 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
|
2310 | if (unit->PID_heat->dGain != fval) |
493
04d726035afe
Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
2311 | syslog(LOG_NOTICE, "Fermenter unit %s PID_heat dGain %.3f to %.3f", unit->uuid, unit->PID_heat->dGain, fval); |
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
|
2312 | 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
|
2313 | } |
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
|
2314 | |
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
|
2315 | } 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
|
2316 | 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
|
2317 | if (unit->PID_heat->iGain != fval) |
493
04d726035afe
Fixed server log when changed PID parameters from the web interface.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
2318 | syslog(LOG_NOTICE, "Fermenter unit %s PIH_heat iGain %.3f to %.3f", unit->uuid, unit->PID_heat->iGain, fval); |
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
|
2319 | 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
|
2320 | } |
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
|
2321 | |
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
|
2322 | } 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
|
2323 | 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
|
2324 | 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
|
2325 | 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
|
2326 | 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
|
2327 | } |
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
|
2328 | |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
2329 | } else if (val && (strcmp(kwd, (char *)"PROF_STATE") == 0) && unit->profile_uuid) { |
217 | 2330 | 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
|
2331 | if (strcmp(val, PROFSTATE[i]) == 0) { |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2332 | 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
|
2333 | 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
|
2334 | unit->prof_state = PROFILE_OFF; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2335 | 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
|
2336 | } |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2337 | 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
|
2338 | 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
|
2339 | unit->prof_state = PROFILE_PAUSE; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2340 | 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
|
2341 | } else if (unit->prof_state == PROFILE_PAUSE) { |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2342 | unit->prof_state = PROFILE_RUN; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2343 | 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
|
2344 | } |
219
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2345 | break; |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2346 | 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
|
2347 | unit->prof_state = PROFILE_RUN; |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2348 | unit->prof_started = time(NULL); |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
2349 | unit->prof_paused = unit->prof_primary_done = 0; |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
285
diff
changeset
|
2350 | 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
|
2351 | 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
|
2352 | } |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2353 | break; |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2354 | case PROFILE_DONE: break; /* Command is illegal */ |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2355 | 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
|
2356 | unit->prof_state = PROFILE_OFF; |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
2357 | unit->prof_started = unit->prof_paused = unit->prof_primary_done = 0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
566
diff
changeset
|
2358 | 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
|
2359 | 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
|
2360 | } |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2361 | break; |
ae720212accc
Added profile running and steps handling.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
2362 | } |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
2363 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
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 | 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
|
2365 | } |
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
|
2366 | } |
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
|
2367 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2368 | } 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
|
2369 | if (sscanf(val, "%f", &fval) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2370 | if (unit->temp_set_min != fval) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2371 | 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
|
2372 | unit->temp_set_min = fval; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2373 | } |
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
|
2374 | |
178
988a898974f3
Web - server communication for switches improved.
Michiel Broek <mbroek@mbse.eu>
parents:
176
diff
changeset
|
2375 | } 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
|
2376 | if (sscanf(val, "%f", &fval) == 1) { |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2377 | if (unit->temp_set_max != fval) |
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2378 | 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
|
2379 | unit->temp_set_max = fval; |
282
885e5243bb50
UNIT PUT command logging added.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
2380 | } |
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
|
2381 | |
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 | } |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2383 | if (unit->mqtt_flag) { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2384 | if (debug) |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2385 | fprintf(stdout, "flag value %d\n", unit->mqtt_flag); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2386 | if (unit->mqtt_flag & MQTT_FLAG_BIRTH) { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2387 | publishDBirth(unit); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2388 | } else { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2389 | publishDData(unit); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2390 | } |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2391 | if (unit->mqtt_flag & MQTT_FLAG_DEATH) { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2392 | publishDDeath(unit); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2393 | } |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
529
diff
changeset
|
2394 | } |
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
|
2395 | } |
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
|
2396 | } |
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 | } |
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
|
2398 | } |
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 | } |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
2400 | 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
|
2401 | run_pause = FALSE; |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2402 | 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
|
2403 | } |
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
|
2404 | |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
2405 | srv_send((char *)"504 Subcommand error"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2406 | return 0; |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2407 | } |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2408 | |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2409 | |
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2410 | |
43 | 2411 | void cmd_server(void) |
2412 | { | |
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
|
2413 | 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
|
2414 | int rlen; |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2415 | |
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
|
2416 | 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
|
2417 | if (rlen != -1) { |
48 | 2418 | if (strlen(buf)) { |
43 | 2419 | /* |
48 | 2420 | * Process commands from the client |
43 | 2421 | */ |
329 | 2422 | if (strncmp(buf, "ARCHIVE", 7) == 0) { |
2423 | cmd_archive(buf); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2424 | |
329 | 2425 | } else if (strncmp(buf, "DEVICE", 6) == 0) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2426 | if (cmd_device(buf)) |
174 | 2427 | wrconfig(); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2428 | |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
2429 | } else if (strncmp(buf, "GLOBAL", 6) == 0) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2430 | if (cmd_global(buf)) |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
2431 | wrconfig(); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2432 | |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
79
diff
changeset
|
2433 | } 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
|
2434 | srv_send((char *)"100 Help text follows"); |
6dba71439cd8
Added first part of out own protocol
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
2435 | srv_send((char *)"Recognized commands:"); |
6dba71439cd8
Added first part of out own protocol
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
2436 | 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
|
2437 | // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 |
331 | 2438 | srv_send((char *)"ARCHIVE <CMD> [parameters] Archive commands"); |
2439 | 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
|
2440 | 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
|
2441 | 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
|
2442 | 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
|
2443 | 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
|
2444 | 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
|
2445 | srv_send((char *)"LIST HELP List help screen"); |
330 | 2446 | srv_send((char *)"PING Check if server is alive"); |
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
|
2447 | #ifdef USE_SIMULATOR |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2448 | 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
|
2449 | 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
|
2450 | #endif |
380
75afd21885f2
Help screens for the commands are moved into the commands.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
2451 | 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
|
2452 | 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
|
2453 | srv_send((char *)"."); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2454 | |
81 | 2455 | } else if (strncmp(buf, "LIST", 4) == 0) { |
2456 | cmd_list(buf); | |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2457 | |
303
19a9a3912d03
Added PING/PONG command to the server. Bumped to version 0.2.7
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
2458 | } 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
|
2459 | srv_send((char *)"101 PONG"); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2460 | |
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
|
2461 | #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
|
2462 | } else if (strncmp(buf, "SIMULATOR", 9) == 0) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2463 | 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
|
2464 | wrconfig(); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2465 | |
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
|
2466 | #endif |
87
55f1315c94f1
Added unit command and list unit command
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
2467 | } else if (strncmp(buf, "UNIT", 4) == 0) { |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2468 | 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
|
2469 | wrconfig(); |
381
b22f8bf63b17
Only write configuration if something changed.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
2470 | |
43 | 2471 | } 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
|
2472 | srv_send((char *)"500 Unknown command"); |
43 | 2473 | } |
2474 | } | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2475 | } |
44 | 2476 | |
2477 | close(s); | |
42
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2478 | } |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2479 | |
01b96a24ae7c
Corrected missing and obsolete files
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2480 | |
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
|
2481 | |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2482 | #ifdef HAVE_WIRINGPI_H |
43 | 2483 | PI_THREAD (my_server_loop) |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2484 | #else |
74 | 2485 | 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
|
2486 | #endif |
43 | 2487 | { |
2488 | socklen_t addrlen; | |
44 | 2489 | int optval = 1; |
43 | 2490 | |
2491 | syslog(LOG_NOTICE, "Thread my_server_loop started"); | |
2492 | if (debug) | |
2493 | fprintf(stdout, "Thread my_server_loop started\n"); | |
2494 | ||
44 | 2495 | memset((char *)&myaddr_in, 0, sizeof(struct sockaddr_in)); |
2496 | memset((char *)&peeraddr_in, 0, sizeof(struct sockaddr_in)); | |
2497 | myaddr_in.sin_family = AF_INET; | |
2498 | myaddr_in.sin_addr.s_addr = INADDR_ANY; | |
2499 | myaddr_in.sin_port = htons(Config.my_port); | |
2500 | ||
2501 | ls = socket(AF_INET, SOCK_STREAM, 0); | |
2502 | if (ls == -1) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
2503 | syslog(LOG_NOTICE, "Can't create listen socket: %s", strerror(errno)); |
44 | 2504 | fprintf(stderr, "Can't create listen socket: %s\n", strerror(errno)); |
2505 | return 0; | |
2506 | } | |
2507 | ||
2508 | 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
|
2509 | syslog(LOG_NOTICE, "Can't setsockopt SO_KEEPALIVE socket: %s", strerror(errno)); |
44 | 2510 | close(ls); |
2511 | return 0; | |
2512 | } | |
2513 | ||
2514 | 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
|
2515 | syslog(LOG_NOTICE, "Can't setsockopt SO_REUSEADDR socket: %s", strerror(errno)); |
44 | 2516 | close(ls); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2517 | return 0; |
44 | 2518 | } |
2519 | ||
2520 | 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
|
2521 | syslog(LOG_NOTICE, "Can't bind to listen socket: %s", strerror(errno)); |
44 | 2522 | close(ls); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2523 | return 0; |
44 | 2524 | } |
2525 | ||
2526 | if (listen(ls, 5) == -1) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
2527 | syslog(LOG_NOTICE, "Can't listen on listen socket: %s", strerror(errno)); |
44 | 2528 | close(ls); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
2529 | return 0; |
44 | 2530 | } |
2531 | ||
2532 | syslog(LOG_NOTICE, "listen socket created %d", ls); | |
2533 | ||
2534 | ||
43 | 2535 | /* |
2536 | * Loop forever until the external shutdown variable is set. | |
2537 | */ | |
2538 | for (;;) { | |
2539 | ||
2540 | addrlen = sizeof(struct sockaddr_in); | |
2541 | /* | |
2542 | * This call will block until a new connection | |
2543 | * arrives. Then it will return the address of | |
2544 | * the connecting peer, and a new socket | |
2545 | * descriptor, s, for that connection. | |
2546 | */ | |
2547 | s = accept(ls, (struct sockaddr *)&peeraddr_in, &addrlen); | |
2548 | if (s == -1) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
2549 | syslog(LOG_NOTICE, "my_server_loop accept failed %s", strerror(errno)); |
43 | 2550 | if (debug) |
2551 | fprintf(stdout, "my_server_loop accept failed %s\n", strerror(errno)); | |
44 | 2552 | return 0; |
43 | 2553 | } |
2554 | ||
48 | 2555 | cmd_server(); |
43 | 2556 | |
2557 | if (my_shutdown) { | |
2558 | syslog(LOG_NOTICE, "Thread my_server_loop stopped"); | |
2559 | if (debug) | |
2560 | fprintf(stdout, "Thread my_server_loop stopped\n"); | |
2561 | return 0; | |
2562 | } | |
583
9795a16de807
Attempt to better check the temperature sensors and lower the cpu load.
Michiel Broek <mbroek@mbse.eu>
parents:
582
diff
changeset
|
2563 | usleep(100000); |
43 | 2564 | } |
2565 | } | |
2566 | ||
2567 |