-
Notifications
You must be signed in to change notification settings - Fork 3
/
minmax2300.c
194 lines (184 loc) · 5.64 KB
/
minmax2300.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* open2300 - minmax2300.c
*
* Version 1.10
*
* Control WS2300 weather station
*
* Copyright 2003-2005, Kenneth Lavrsen
* This program is published under the GNU General Public license
*/
#include "rw2300.h"
/********************************************************************
* print_usage prints a short user guide
*
* Input: none
*
* Output: prints to stdout
*
* Returns: exits program
*
********************************************************************/
void print_usage(void)
{
printf("\n");
printf("minmax2300 - Reset minimum/maximum values in a WS-2300 weather station\n");
printf("Version %s (C)2003-2004 Kenneth Lavrsen.\n", VERSION);
printf("This program is released under the GNU General Public License (GPL)\n\n");
printf("Usage:\n");
printf("Reset Daily Maximum (Temp, Humid, WC, DP): minmax2300 dailymax config_filename\n");
printf("Reset Daily Minimum (Temp, Humid, WC, DP): minmax2300 dailymin config_filename\n");
printf("Reset Temperature Indoor Max|Min|Both: minmax2300 timax|timin|tiboth config_filename\n");
printf("Reset Temperature Outdoor Max|Min|Both: minmax2300 tomax|tomin|toboth config_filename\n");
printf("Reset Dewpoint Max|Min|Both: minmax2300 dpmax|dpmin|dpboth config_filename\n");
printf("Reset Windchill Max|Min|Both: minmax2300 wcmax|wcmin|wcboth config_filename\n");
printf("Reset Wind Max|Min|Both: minmax2300 wmax|wmin|wboth config_filename\n");
printf("Reset Humidity Indoor Max|Min|Both: minmax2300 himax|himin|hiboth config_filename\n");
printf("Reset Humidity Outdoor Max|Min|Both: minmax2300 homax|homin|hoboth config_filename\n");
printf("Reset Pressure Max|Min|Both: minmax2300 pmax|pmin|pboth config_filename\n");
printf("Reset Rain Maximum 1h|24h: minmax2300 r1max|r24max config_filename\n");
printf("Reset Rain Counter 1h|24h|Total: minmax2300 r1|r24|rtotal config_filename\n");
exit(0);
}
/********** MAIN PROGRAM ************************************************
*
* Control background light of a WS-2300 weather station
* and writes the data to a log file.
*
* Just run the program without parameters for usage.
*
* It takes two parameters. The first is the log filename with path
* The second is the config file name with path
* If this parameter is omitted the program will look at the default paths
* See the open2300.conf-dist file for info
*
***********************************************************************/
int main(int argc, char *argv[])
{
WEATHERSTATION ws2300;
struct config_type config;
if (argc < 2 || argc > 3)
{
print_usage();
}
get_configuration(&config, argv[2]);
ws2300 = open_weatherstation(config.serial_device_name);
/* Get on or off */
if (strcmp(argv[1],"timax") == 0 || strcmp(argv[1],"dailymax") == 0)
{
temperature_indoor_reset(ws2300, RESET_MAX);
}
if (strcmp(argv[1],"timin") == 0 || strcmp(argv[1],"dailymin") == 0)
{
temperature_indoor_reset(ws2300, RESET_MIN);
}
if (strcmp(argv[1],"tiboth") == 0)
{
temperature_indoor_reset(ws2300, RESET_MIN + RESET_MAX);
}
if (strcmp(argv[1],"tomax") == 0 || strcmp(argv[1],"dailymax") == 0)
{
temperature_outdoor_reset(ws2300, RESET_MAX);
}
if (strcmp(argv[1],"tomin") == 0 || strcmp(argv[1],"dailymin") == 0)
{
temperature_outdoor_reset(ws2300, RESET_MIN);
}
if (strcmp(argv[1],"toboth") == 0)
{
temperature_outdoor_reset(ws2300, RESET_MIN + RESET_MAX);
}
if (strcmp(argv[1],"dpmax") == 0 || strcmp(argv[1],"dailymax") == 0)
{
dewpoint_reset(ws2300, RESET_MAX);
}
if (strcmp(argv[1],"dpmin") == 0 || strcmp(argv[1],"dailymin") == 0)
{
dewpoint_reset(ws2300, RESET_MIN);
}
if (strcmp(argv[1],"dpboth") == 0)
{
dewpoint_reset(ws2300, RESET_MIN + RESET_MAX);
}
if (strcmp(argv[1],"wcmax") == 0 || strcmp(argv[1],"dailymax") == 0)
{
windchill_reset(ws2300, RESET_MAX);
}
if (strcmp(argv[1],"wcmin") == 0 || strcmp(argv[1],"dailymin") == 0)
{
windchill_reset(ws2300, RESET_MIN);
}
if (strcmp(argv[1],"wcboth") == 0)
{
windchill_reset(ws2300, RESET_MIN + RESET_MAX);
}
if (strcmp(argv[1],"wmax") == 0)
{
wind_reset(ws2300, RESET_MAX);
}
if (strcmp(argv[1],"wmin") == 0)
{
wind_reset(ws2300, RESET_MIN);
}
if (strcmp(argv[1],"wboth") == 0)
{
wind_reset(ws2300, RESET_MIN + RESET_MAX);
}
if (strcmp(argv[1],"himax") == 0 || strcmp(argv[1],"dailymax") == 0)
{
humidity_indoor_reset(ws2300, RESET_MAX);
}
if (strcmp(argv[1],"himin") == 0 || strcmp(argv[1],"dailymin") == 0)
{
humidity_indoor_reset(ws2300, RESET_MIN);
}
if (strcmp(argv[1],"hiboth") == 0)
{
humidity_indoor_reset(ws2300, RESET_MIN + RESET_MAX);
}
if (strcmp(argv[1],"homax") == 0 || strcmp(argv[1],"dailymax") == 0)
{
humidity_outdoor_reset(ws2300, RESET_MAX);
}
if (strcmp(argv[1],"homin") == 0 || strcmp(argv[1],"dailymin") == 0)
{
humidity_outdoor_reset(ws2300, RESET_MIN);
}
if (strcmp(argv[1],"hoboth") == 0)
{
humidity_outdoor_reset(ws2300, RESET_MIN + RESET_MAX);
}
if (strcmp(argv[1],"pmax") == 0)
{
pressure_reset(ws2300, RESET_MAX);
}
if (strcmp(argv[1],"pmin") == 0)
{
pressure_reset(ws2300, RESET_MIN);
}
if (strcmp(argv[1],"pboth") == 0)
{
pressure_reset(ws2300, RESET_MIN + RESET_MAX);
}
if (strcmp(argv[1],"r1max") == 0)
{
rain_1h_max_reset(ws2300);
}
if (strcmp(argv[1],"r24max") == 0)
{
rain_24h_max_reset(ws2300);
}
if (strcmp(argv[1],"r1") == 0)
{
rain_1h_reset(ws2300);
}
if (strcmp(argv[1],"r24") == 0)
{
rain_24h_reset(ws2300);
}
if (strcmp(argv[1],"rtotal") == 0)
{
rain_total_reset(ws2300);
}
close_weatherstation(ws2300);
return (0);
}