Instrument Neutral Distributed Interface INDI 2.2.5
wandererbox_pro_v3.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2024 Frank Wang. All rights reserved.
3
4 WandererBox Pro V3
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21 The full GNU General Public License is included in this distribution in the
22 file called LICENSE.
23*******************************************************************************/
24
25#pragma once
26
27#include "defaultdevice.h"
29#include <vector>
30#include <stdint.h>
31
32namespace Connection
33{
34class Serial;
35}
36
38{
39public:
41 virtual ~WandererBoxProV3() = default;
42
43 virtual bool initProperties() override;
44 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
45 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
46 virtual bool updateProperties() override;
47
48
49
50protected:
51 const char *getDefaultName() override;
52 virtual bool saveConfigItems(FILE *fp) override;
53 virtual void TimerHit() override;
54 virtual IPState updateWeather() override;
55
56
57private:
58
59 int firmware=0;
60 bool sendCommand(std::string command);
61 bool DC5DIFFMODE=false;
62 bool DC5CONSTMODE=false;
63 bool DC6DIFFMODE=false;
64 bool DC6CONSTMODE=false;
65 bool DC7DIFFMODE=false;
66 bool DC7CONSTMODE=false;
67 bool getData();
68 static constexpr const char *ENVIRONMENT_TAB {"Environment"};
69 static constexpr const char *SENSORS_TAB {"Sensors"};
70 static constexpr const char *DC5_TAB {"DC5"};
71 static constexpr const char *DC6_TAB {"DC6"};
72 static constexpr const char *DC7_TAB {"DC7"};
73 //Current Calibrate
74 INDI::PropertySwitch CalibrateSP{1};
75
76
77 //Temp1
78 double temp1read = 0;
79 //Temp2
80 double temp2read = 0;
81 //Temp3
82 double temp3read = 0;
83 //DHTH
84 double DHTHread = 0;
85 //DHTT
86 void updateENV(double temp1,double temp2,double temp3,double DHTH,double DHTT);
87 double DHTTread = 0;
88 //Total Current
89 double Tcurrentread = 0;
90 //19V Current
91 double V19currentread = 0;
92 //Adjustable Regulator Current
93 double ARcurrentread = 0;
94 //Power Monitor
95 void updatePower(double Tcurrent,double V19_current,double AR_current,double voltage);
96 double voltageread = 0;
97 //USB31
98 void updateUSB31(int value);
99 int USB31read = 0;
100 //USB32
101 void updateUSB32(int value);
102 int USB32read = 0;
103 //USB33
104 void updateUSB33(int value);
105 int USB33read = 0;
106 //USB21
107 void updateUSB21(int value);
108 int USB21read = 0;
109 //USB22
110 void updateUSB22(int value);
111 int USB22read = 0;
112 //DC34
113 void updateDC34(int value);
114 int DC34read = 0;
115 //DC5
116 void updateDC5(int value);
117 int DC5read = 0;
118 //DC6
119 void updateDC6(int value);
120 int DC6read = 0;
121 //DC7
122 void updateDC7(int value);
123 int DC7read = 0;
124 //DC8_9
125 void updateDC8_9(int value);
126 int DC8_9read = 0;
127 //DC10_11
128 void updateDC10_11(int value);
129 int DC10_11read = 0;
130 //DC34set
131 void updateDC34SET(double value);
132 int DC34SETread = 0;
133
134 bool setDewPWM(uint8_t id, uint8_t value);
135
136 //DC Control//////////////////////////////////////////////////////////////////////////////////
137 INDI::PropertySwitch dc3_4ControlSP{2};
138 INDI::PropertySwitch dc8_9ControlSP{2};
139 INDI::PropertySwitch dc10_11ControlSP{2};
140 //USB Control//////////////////////////////////////////////////////////////////////////////////
141 INDI::PropertySwitch usb31ControlSP{2};
142 INDI::PropertySwitch usb32ControlSP{2};
143 INDI::PropertySwitch usb33ControlSP{2};
144 INDI::PropertySwitch usb21ControlSP{2};
145 INDI::PropertySwitch usb22ControlSP{2};
146 //DC5 Control////////////////////////////////////////////////////////////////
147 INDI::PropertyNumber dc5ControlNP{1};
148 enum
149 {
150 DC5,
151 };
152 //DC6 Control////////////////////////////////////////////////////////////////
153 INDI::PropertyNumber dc6ControlNP{1};
154 enum
155 {
156 DC6,
157 };
158 //DC7 Control////////////////////////////////////////////////////////////////
159 INDI::PropertyNumber dc7ControlNP{1};
160 enum
161 {
162 DC7,
163 };
164 //DC5 DIFF////////////////////////////////////////////////////////////////
165 INDI::PropertySwitch dc5diffSP{3};
166 enum
167 {
168 DC5_Manual,
169 DC5_DPD_Mode,
170 DC5_CT_Mode,
171 };
172
173 INDI::PropertyNumber dc5diffSETNP{1};
174 enum
175 {
176 DC5DIFFSET,
177 };
178 INDI::PropertyNumber dc5constSETNP{1};
179 enum
180 {
181 DC5CONSTSET,
182 };
183
184 //DC6 DIFF////////////////////////////////////////////////////////////////
185 INDI::PropertySwitch dc6diffSP{3};
186 enum
187 {
188 DC6_Manual,
189 DC6_DPD_Mode,
190 DC6_CT_Mode,
191 };
192
193 INDI::PropertyNumber dc6diffSETNP{1};
194 enum
195 {
196 DC6DIFFSET,
197 };
198 INDI::PropertyNumber dc6constSETNP{1};
199 enum
200 {
201 DC6CONSTSET,
202 };
203
204 //DC7 DIFF////////////////////////////////////////////////////////////////
205 INDI::PropertySwitch dc7diffSP{3};
206 enum
207 {
208 DC7_Manual,
209 DC7_DPD_Mode,
210 DC7_CT_Mode,
211 };
212
213 INDI::PropertyNumber dc7diffSETNP{1};
214 enum
215 {
216 DC7DIFFSET,
217 };
218 INDI::PropertyNumber dc7constSETNP{1};
219 enum
220 {
221 DC7CONSTSET,
222 };
223
224 //DC34 Voltage Control////////////////////////////////////////////////////////////////
225 INDI::PropertyNumber setDC34voltageNP{1};
226 enum
227 {
228 setDC34voltage,
229 };
230
231 // Power Monitor
232
233 INDI::PropertyNumber PowerMonitorNP{4};
234 enum
235 {
236 VOLTAGE,
237 TOTAL_CURRENT,
238 V19_CURRENT,
239 AR_CURRENT,
240 };
241
242 // ENV Monitor
243
244 INDI::PropertyNumber ENVMonitorNP{6};
245 enum
246 {
247 Probe1_Temp,
248 Probe2_Temp,
249 Probe3_Temp,
250 ENV_Humidity,
251 ENV_Temp,
252 DEW_Point,
253 };
254
255
256
257 int PortFD{ -1 };
258
259 Connection::Serial *serialConnection{ nullptr };
260};
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Provides interface to implement weather reporting and safety monitoring functionality.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
const char * getDefaultName() override
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual ~WandererBoxProV3()=default
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition arduino_st4.h:34