Debian Codegraph @

drivers/auxiliary/pegasus_upb.h

raw symbols SCIP
1 /*******************************************************************************
2 Copyright(c) 2018 Jasem Mutlaq. All rights reserved.
3
4 Pegasus Ultimate Power Box (v1 and v2)
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"cxx . . $ `<file>/libs/indibase/defaultdevice.h`/
28 #include "indifocuserinterface.h"cxx . . $ `<file>/libs/indibase/indifocuserinterface.h`/
29 #include "indiweatherinterface.h"cxx . . $ `<file>/libs/indibase/indiweatherinterface.h`/
30 #include <stdint.h>
31
32 namespace Connectioncxx . . $ Connection/
33 {
34 class Serialcxx . . $ Connection/Serial#;
35 }
36
37 class PegasusUPBcxx . . $ PegasusUPB# : public INDIcxx . . $ INDI/::DefaultDevicecxx . . $ INDI/DefaultDevice#, public INDIcxx . . $ INDI/::FocuserInterfacecxx . . $ INDI/FocuserInterface#, public INDIcxx . . $ INDI/::WeatherInterfacecxx . . $ INDI/WeatherInterface#
38 {
39 public:
40 PegasusUPBcxx . . $ PegasusUPB#PegasusUPB(49f6e7a06ebc5aa8).();
41
42 enumcxx . . $ PegasusUPB#$anonymous_type_0#
43 {
44 UPB_V1cxx . . $ PegasusUPB#UPB_V1.,
45 UPB_V2cxx . . $ PegasusUPB#UPB_V2.
46 };
47
48 virtual bool initPropertiescxx . . $ PegasusUPB#initProperties(c9857a73d68e59ba).() override;
49 virtual bool updatePropertiescxx . . $ PegasusUPB#updateProperties(c9857a73d68e59ba).() override;
50
51 virtual bool ISNewNumbercxx . . $ PegasusUPB#ISNewNumber(b910d3521abb33fb).(const char *dev, const char *name, double values[], char *names[], int n) override;
52 virtual bool ISNewSwitchcxx . . $ PegasusUPB#ISNewSwitch(e439c05866add404).(const char *dev, const char *name, ISStatecxx . . $ ISState# *states, char *names[], int n) override;
53 virtual bool ISNewTextcxx . . $ PegasusUPB#ISNewText(1f3dbebc116ed926).(const char *dev, const char *name, char *texts[], char *names[], int n) override;
54
55 protected:
56 const char *getDefaultNamecxx . . $ PegasusUPB#getDefaultName(33a1f659e94feb42).() override;
57 virtual bool saveConfigItemscxx . . $ PegasusUPB#saveConfigItems(dc9e5a301483124c).(FILE *fp) override;
58
59 // Event loop
60 virtual void TimerHitcxx . . $ PegasusUPB#TimerHit(49f6e7a06ebc5aa8).() override;
61
62 // Focuser Overrides
63 virtual IPStatecxx . . $ IPState# MoveAbsFocusercxx . . $ PegasusUPB#MoveAbsFocuser(e933ec4323fbb8bc).(uint32_tcxx . . $ uint32_t# targetTicks) override;
64 virtual IPStatecxx . . $ IPState# MoveRelFocusercxx . . $ PegasusUPB#MoveRelFocuser(7f9c1e68e57c0ac9).(FocusDirectioncxx . . $ INDI/FocuserInterface#FocusDirection# dir, uint32_tcxx . . $ uint32_t# ticks) override;
65 virtual bool AbortFocusercxx . . $ PegasusUPB#AbortFocuser(c9857a73d68e59ba).() override;
66 virtual bool ReverseFocusercxx . . $ PegasusUPB#ReverseFocuser(efaadfb7dc14930a).(bool enabled) override;
67 virtual bool SyncFocusercxx . . $ PegasusUPB#SyncFocuser(dfa6e707f7696010).(uint32_tcxx . . $ uint32_t# ticks) override;
68
69 virtual bool SetFocuserBacklashcxx . . $ PegasusUPB#SetFocuserBacklash(83c267b20bac841a).(int32_t steps) override;
70 virtual bool SetFocuserBacklashEnabledcxx . . $ PegasusUPB#SetFocuserBacklashEnabled(efaadfb7dc14930a).(bool enabled) override;
71
72 // Weather Overrides
73 virtual IPStatecxx . . $ IPState# updateWeathercxx . . $ PegasusUPB#updateWeather(dd764fd8e59c78c4).() override
74 {
75 return IPS_OKcxx . . $ IPS_OK.;
76 }
77
78
79 private:
80 bool Handshakecxx . . $ PegasusUPB#Handshake(c9857a73d68e59ba).();
81
82 // Get Data
83 bool setupParamscxx . . $ PegasusUPB#setupParams(c9857a73d68e59ba).();
84 bool sendFirmwarecxx . . $ PegasusUPB#sendFirmware(c9857a73d68e59ba).();
85 bool getSensorDatacxx . . $ PegasusUPB#getSensorData(c9857a73d68e59ba).();
86 bool getPowerDatacxx . . $ PegasusUPB#getPowerData(c9857a73d68e59ba).();
87 bool getStepperDatacxx . . $ PegasusUPB#getStepperData(c9857a73d68e59ba).();
88 bool getDewAggDatacxx . . $ PegasusUPB#getDewAggData(c9857a73d68e59ba).();
89 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> splitcxx . . $ PegasusUPB#split(c47e161d59f8b6e7).(const stdcxx . . $ std/::stringcxx . . $ std/string# &input, const stdcxx . . $ std/::stringcxx . . $ std/string# &regex);
90
91 // Device Control
92 bool rebootcxx . . $ PegasusUPB#reboot(c9857a73d68e59ba).();
93
94 // Power
95 bool setPowerEnabledcxx . . $ PegasusUPB#setPowerEnabled(e6c03217c9f46667).(uint8_tcxx . . $ uint8_t# port, bool enabled);
96 bool setPowerLEDEnabledcxx . . $ PegasusUPB#setPowerLEDEnabled(efaadfb7dc14930a).(bool enabled);
97 bool setPowerOnBootcxx . . $ PegasusUPB#setPowerOnBoot(c9857a73d68e59ba).();
98 bool getPowerOnBootcxx . . $ PegasusUPB#getPowerOnBoot(c9857a73d68e59ba).();
99 bool setAdjustableOutputcxx . . $ PegasusUPB#setAdjustableOutput(cef82f9be00a201a).(uint8_tcxx . . $ uint8_t# voltage);
100
101 // Dew
102 bool setAutoDewEnabledcxx . . $ PegasusUPB#setAutoDewEnabled(efaadfb7dc14930a).(bool enabled);
103 bool toggleAutoDewV2cxx . . $ PegasusUPB#toggleAutoDewV2(c9857a73d68e59ba).();
104 bool setAutoDewAggcxx . . $ PegasusUPB#setAutoDewAgg(cef82f9be00a201a).(uint8_tcxx . . $ uint8_t# value);
105 bool setDewPWMcxx . . $ PegasusUPB#setDewPWM(4ed805b44025c28a).(uint8_tcxx . . $ uint8_t# id, uint8_tcxx . . $ uint8_t# value);
106
107 // USB
108 bool setUSBHubEnabledcxx . . $ PegasusUPB#setUSBHubEnabled(efaadfb7dc14930a).(bool enabled);
109 bool setUSBPortEnabledcxx . . $ PegasusUPB#setUSBPortEnabled(e6c03217c9f46667).(uint8_tcxx . . $ uint8_t# port, bool enabled);
110
111 // Focuser
112 bool setFocuserMaxSpeedcxx . . $ PegasusUPB#setFocuserMaxSpeed(3c978dac0e5ee2ad).(uint16_tcxx . . $ uint16_t# maxSpeed);
113 // bool setFocuserBacklash(uint16_t value);
114 // bool setFocuserBacklashEnabled(bool enabled);
115
116 /**
117 * @brief sendCommand Send command to unit.
118 * @param cmd Command
119 * @param res if nullptr, respones is ignored, otherwise read response and store it in the buffer.
120 * @return
121 */
122 bool sendCommandcxx . . $ PegasusUPB#sendCommand(84e74a5521f49206).(const char *cmd, char *res);
123
124 /**
125 * @brief cleanupResponse Removes all spaces
126 * @param response buffer
127 */
128 void cleanupResponsecxx . . $ PegasusUPB#cleanupResponse(fda57c8427c60377).(char *response);
129
130 /**
131 * @return Return true if sensor data different from last data
132 *
133 * If the previous sensor data is empty then this will always
134 * return true.
135 */
136 bool sensorUpdatedcxx . . $ PegasusUPB#sensorUpdated(b208c01e895b5b62).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> &result, uint8_tcxx . . $ uint8_t# start, uint8_tcxx . . $ uint8_t# end);
137
138 /**
139 * @return Return true if stepper data different from last data.
140 *
141 * If the previous stepper data is empty then this will always
142 * return true.
143 */
144 bool stepperUpdatedcxx . . $ PegasusUPB#stepperUpdated(34b9cd77ec3c8464).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> &result, u_int8_t index);
145
146 int PortFDcxx . . $ PegasusUPB#PortFD. { -1 };
147 bool setupCompletecxx . . $ PegasusUPB#setupComplete. { false };
148
149 Connectioncxx . . $ Connection/::Serialcxx . . $ Connection/Serial# *serialConnectioncxx . . $ PegasusUPB#serialConnection. { nullptr };
150
151 ////////////////////////////////////////////////////////////////////////////////////
152 /// Main Control
153 ////////////////////////////////////////////////////////////////////////////////////
154 /// Reboot Device
155 ISwitchcxx . . $ ISwitch# RebootScxx . . $ PegasusUPB#RebootS.[1];
156 ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# RebootSPcxx . . $ PegasusUPB#RebootSP.;
157
158 // Power Sensors
159 INumbercxx . . $ INumber# PowerSensorsNcxx . . $ PegasusUPB#PowerSensorsN.[3];
160 INumberVectorPropertycxx . . $ INumberVectorProperty# PowerSensorsNPcxx . . $ PegasusUPB#PowerSensorsNP.;
161 enumcxx . . $ PegasusUPB#$anonymous_type_1#
162 {
163 SENSOR_VOLTAGEcxx . . $ PegasusUPB#SENSOR_VOLTAGE.,
164 SENSOR_CURRENTcxx . . $ PegasusUPB#SENSOR_CURRENT.,
165 SENSOR_POWERcxx . . $ PegasusUPB#SENSOR_POWER.,
166 };
167
168 // Power Consumption
169 INumbercxx . . $ INumber# PowerConsumptionNcxx . . $ PegasusUPB#PowerConsumptionN.[3];
170 INumberVectorPropertycxx . . $ INumberVectorProperty# PowerConsumptionNPcxx . . $ PegasusUPB#PowerConsumptionNP.;
171 enumcxx . . $ PegasusUPB#$anonymous_type_2#
172 {
173 CONSUMPTION_AVG_AMPScxx . . $ PegasusUPB#CONSUMPTION_AVG_AMPS.,
174 CONSUMPTION_AMP_HOURScxx . . $ PegasusUPB#CONSUMPTION_AMP_HOURS.,
175 CONSUMPTION_WATT_HOURScxx . . $ PegasusUPB#CONSUMPTION_WATT_HOURS.,
176 };
177
178 ////////////////////////////////////////////////////////////////////////////////////
179 /// Power Group
180 ////////////////////////////////////////////////////////////////////////////////////
181
182 // Cycle all power on/off
183 ISwitchcxx . . $ ISwitch# PowerCycleAllScxx . . $ PegasusUPB#PowerCycleAllS.[2];
184 ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# PowerCycleAllSPcxx . . $ PegasusUPB#PowerCycleAllSP.;
185 enumcxx . . $ PegasusUPB#$anonymous_type_3#
186 {
187 POWER_CYCLE_OFFcxx . . $ PegasusUPB#POWER_CYCLE_OFF.,
188 POWER_CYCLE_ONcxx . . $ PegasusUPB#POWER_CYCLE_ON.,
189 };
190
191 // Turn on/off power
192 ISwitchcxx . . $ ISwitch# PowerControlScxx . . $ PegasusUPB#PowerControlS.[4];
193 ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# PowerControlSPcxx . . $ PegasusUPB#PowerControlSP.;
194
195 // Rename the power controls above
196 ITextcxx . . $ IText# PowerControlsLabelsTcxx . . $ PegasusUPB#PowerControlsLabelsT.[4] = {};
197 ITextVectorPropertycxx . . $ ITextVectorProperty# PowerControlsLabelsTPcxx . . $ PegasusUPB#PowerControlsLabelsTP.;
198
199 // Current Draw
200 INumbercxx . . $ INumber# PowerCurrentNcxx . . $ PegasusUPB#PowerCurrentN.[4];
201 INumberVectorPropertycxx . . $ INumberVectorProperty# PowerCurrentNPcxx . . $ PegasusUPB#PowerCurrentNP.;
202
203 // Select which power is ON on bootup
204 ISwitchcxx . . $ ISwitch# PowerOnBootScxx . . $ PegasusUPB#PowerOnBootS.[4];
205 ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# PowerOnBootSPcxx . . $ PegasusUPB#PowerOnBootSP.;
206
207 // Overcurrent status
208 ILightcxx . . $ ILight# OverCurrentLcxx . . $ PegasusUPB#OverCurrentL.[7];
209 ILightVectorPropertycxx . . $ ILightVectorProperty# OverCurrentLPcxx . . $ PegasusUPB#OverCurrentLP.;
210
211 // Power LED
212 ISwitchcxx . . $ ISwitch# PowerLEDScxx . . $ PegasusUPB#PowerLEDS.[2];
213 ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# PowerLEDSPcxx . . $ PegasusUPB#PowerLEDSP.;
214 enumcxx . . $ PegasusUPB#$anonymous_type_4#
215 {
216 POWER_LED_ONcxx . . $ PegasusUPB#POWER_LED_ON.,
217 POWER_LED_OFFcxx . . $ PegasusUPB#POWER_LED_OFF.,
218 };
219
220 // Adjustable Output
221 INumbercxx . . $ INumber# AdjustableOutputNcxx . . $ PegasusUPB#AdjustableOutputN.[1];
222 INumberVectorPropertycxx . . $ INumberVectorProperty# AdjustableOutputNPcxx . . $ PegasusUPB#AdjustableOutputNP.;
223
224 ////////////////////////////////////////////////////////////////////////////////////
225 /// Dew Group
226 ////////////////////////////////////////////////////////////////////////////////////
227
228 // Auto Dew v1
229 ISwitchcxx . . $ ISwitch# AutoDewScxx . . $ PegasusUPB#AutoDewS.[2];
230 ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# AutoDewSPcxx . . $ PegasusUPB#AutoDewSP.;
231
232 enumcxx . . $ PegasusUPB#$anonymous_type_5#
233 {
234 DEW_PWM_Acxx . . $ PegasusUPB#DEW_PWM_A.,
235 DEW_PWM_Bcxx . . $ PegasusUPB#DEW_PWM_B.,
236 DEW_PWM_Ccxx . . $ PegasusUPB#DEW_PWM_C.,
237 };
238
239 // Auto Dew v2
240 ISwitchcxx . . $ ISwitch# AutoDewV2Scxx . . $ PegasusUPB#AutoDewV2S.[3];
241 ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# AutoDewV2SPcxx . . $ PegasusUPB#AutoDewV2SP.;
242
243 // Rename the power controls above
244 ITextcxx . . $ IText# DewControlsLabelsTcxx . . $ PegasusUPB#DewControlsLabelsT.[3] = {};
245 ITextVectorPropertycxx . . $ ITextVectorProperty# DewControlsLabelsTPcxx . . $ PegasusUPB#DewControlsLabelsTP.;
246
247 // Auto Dew v2 Aggressiveness
248
249 enumcxx . . $ PegasusUPB#$anonymous_type_6#
250 {
251 AUTO_DEW_AGGcxx . . $ PegasusUPB#AUTO_DEW_AGG.,
252 };
253
254 INumbercxx . . $ INumber# AutoDewAggNcxx . . $ PegasusUPB#AutoDewAggN.[1];
255 INumberVectorPropertycxx . . $ INumberVectorProperty# AutoDewAggNPcxx . . $ PegasusUPB#AutoDewAggNP.;
256
257 // Dew PWM
258 INumbercxx . . $ INumber# DewPWMNcxx . . $ PegasusUPB#DewPWMN.[3];
259 INumberVectorPropertycxx . . $ INumberVectorProperty# DewPWMNPcxx . . $ PegasusUPB#DewPWMNP.;
260
261 // Current Draw
262 INumbercxx . . $ INumber# DewCurrentDrawNcxx . . $ PegasusUPB#DewCurrentDrawN.[3];
263 INumberVectorPropertycxx . . $ INumberVectorProperty# DewCurrentDrawNPcxx . . $ PegasusUPB#DewCurrentDrawNP.;
264
265 ////////////////////////////////////////////////////////////////////////////////////
266 /// USB
267 ////////////////////////////////////////////////////////////////////////////////////
268
269 // Turn on/off usb ports 1-5 (v1)
270 ISwitchcxx . . $ ISwitch# USBControlScxx . . $ PegasusUPB#USBControlS.[2];
271 ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# USBControlSPcxx . . $ PegasusUPB#USBControlSP.;
272
273 // Turn on/off usb ports 1-6 (v2)
274 ISwitchcxx . . $ ISwitch# USBControlV2Scxx . . $ PegasusUPB#USBControlV2S.[6];
275 ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# USBControlV2SPcxx . . $ PegasusUPB#USBControlV2SP.;
276
277 // USB Port Status (1-6)
278 ILightcxx . . $ ILight# USBStatusLcxx . . $ PegasusUPB#USBStatusL.[6];
279 ILightVectorPropertycxx . . $ ILightVectorProperty# USBStatusLPcxx . . $ PegasusUPB#USBStatusLP.;
280
281 // Rename the USB controls above
282 ITextcxx . . $ IText# USBControlsLabelsTcxx . . $ PegasusUPB#USBControlsLabelsT.[6] = {};
283 ITextVectorPropertycxx . . $ ITextVectorProperty# USBControlsLabelsTPcxx . . $ PegasusUPB#USBControlsLabelsTP.;
284
285 ////////////////////////////////////////////////////////////////////////////////////
286 /// Focuser
287 ////////////////////////////////////////////////////////////////////////////////////
288
289 // Focuser speed
290 INumbercxx . . $ INumber# FocuserSettingsNcxx . . $ PegasusUPB#FocuserSettingsN.[1];
291 INumberVectorPropertycxx . . $ INumberVectorProperty# FocuserSettingsNPcxx . . $ PegasusUPB#FocuserSettingsNP.;
292 enumcxx . . $ PegasusUPB#$anonymous_type_7#
293 {
294 //SETTING_BACKLASH,
295 SETTING_MAX_SPEEDcxx . . $ PegasusUPB#SETTING_MAX_SPEED.,
296 };
297
298 ////////////////////////////////////////////////////////////////////////////////////
299 /// USB
300 ////////////////////////////////////////////////////////////////////////////////////
301 ITextVectorPropertycxx . . $ ITextVectorProperty# FirmwareTPcxx . . $ PegasusUPB#FirmwareTP.;
302 ITextcxx . . $ IText# FirmwareTcxx . . $ PegasusUPB#FirmwareT.[2] {};
303 enumcxx . . $ PegasusUPB#$anonymous_type_8#
304 {
305 FIRMWARE_VERSIONcxx . . $ PegasusUPB#FIRMWARE_VERSION.,
306 FIRMWARE_UPTIMEcxx . . $ PegasusUPB#FIRMWARE_UPTIME.
307 };
308
309
310 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> lastSensorDatacxx . . $ PegasusUPB#lastSensorData., lastPowerDatacxx . . $ PegasusUPB#lastPowerData., lastStepperDatacxx . . $ PegasusUPB#lastStepperData., lastDewAggDatacxx . . $ PegasusUPB#lastDewAggData.;
311 bool focusMotorRunningcxx . . $ PegasusUPB#focusMotorRunning. { false };
312 char stopCharcxx . . $ PegasusUPB#stopChar. { 0xD };
313 uint8_tcxx . . $ uint8_t# versioncxx . . $ PegasusUPB#version. { UPB_V1cxx . . $ PegasusUPB#UPB_V1. };
314
315 static constexpr const uint8_tcxx . . $ uint8_t# PEGASUS_TIMEOUTcxx . . $ PegasusUPB#PEGASUS_TIMEOUT. {3};
316 static constexpr const uint8_tcxx . . $ uint8_t# PEGASUS_LENcxx . . $ PegasusUPB#PEGASUS_LEN. {128};
317 static constexpr const char *DEW_TABcxx . . $ PegasusUPB#DEW_TAB. {"Dew"};
318 static constexpr const char *USB_TABcxx . . $ PegasusUPB#USB_TAB. {"USB"};
319 static constexpr const char *ENVIRONMENT_TABcxx . . $ PegasusUPB#ENVIRONMENT_TAB. {"Environment"};
320 static constexpr const char *POWER_TABcxx . . $ PegasusUPB#POWER_TAB. {"Power"};
321 static constexpr const char *FIRMWARE_TABcxx . . $ PegasusUPB#FIRMWARE_TAB. {"Firmware"};
322 };