Instrument Neutral Distributed Interface INDI 2.2.5
indipowerinterface.h
Go to the documentation of this file.
1/*
2 Power Interface
3 Copyright (C) 2025 Jasem Mutlaq ([email protected])
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19*/
20
21#pragma once
22
23#include "indibase.h"
24#include "indipropertyswitch.h"
25#include "indipropertynumber.h"
26#include "indipropertytext.h"
27#include <stdint.h>
28
30
31namespace INDI
32{
33
35{
36 public:
41 enum
42 {
57
61 uint32_t GetCapability() const
62 {
63 return powerCapability;
64 }
65
70 void SetCapability(uint32_t cap)
71 {
72 powerCapability = cap;
73 }
74
79 {
81 }
82
87 {
89 }
90
98
106
114
122
127 {
129 }
130
135 {
137 }
138
143 {
145 }
146
155
164
165 protected:
166 explicit PowerInterface(DefaultDevice *defaultDevice);
167
178 void initProperties(const char *groupName, size_t nPowerPorts = 0, size_t nDewPorts = 0, size_t nVariablePorts = 0,
179 size_t nAutoDewPorts = 0, size_t nUSBPorts = 0);
180
185 bool updateProperties();
186
188 bool processNumber(const char *dev, const char *name, double values[], char *names[], int n);
189
191 bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
192
194 bool processText(const char *dev, const char *name, char *texts[], char *names[], int n);
195
202 virtual bool SetPowerPort(size_t port, bool enabled);
203
211 virtual bool SetDewPort(size_t port, bool enabled, double dutyCycle);
212
220 virtual bool SetVariablePort(size_t port, bool enabled, double voltage);
221
227 virtual bool SetLEDEnabled(bool enabled);
228
234 virtual bool SetAutoDewEnabled(size_t port, bool enabled);
235
240 virtual bool CyclePower();
241
248 virtual bool SetUSBPort(size_t port, bool enabled);
249
255 bool saveConfigItems(FILE *fp);
256
257 // Power Sensors Indices
258 enum
259 {
264 };
265
266 // Main Control - Overall Power Sensors
267 INDI::PropertyNumber PowerSensorsNP {N_POWER_SENSORS}; // Voltage, Total Current, Total Power
268
269 // Power Channels (12V DC)
270 INDI::PropertySwitch PowerChannelsSP {0}; // On/Off switches
271 INDI::PropertyNumber PowerChannelCurrentNP {0}; // Current sensors (if per-channel current monitoring available)
273
274 // DEW/Dew Channels
275 INDI::PropertySwitch DewChannelsSP {0}; // On/Off switches
277 INDI::PropertyNumber DewChannelCurrentNP {0}; // Current sensors (if per-channel current monitoring available)
279
280 // Variable Voltage Channels
284
285 // Over Voltage Protection
287
288 // Power Off on Disconnect
290
291 // LED Control
293
294 // Auto Dew Control
296
297 // USB Ports
300
301 // Power Cycle All
303
304 uint32_t powerCapability = 0;
306
307 const char *POWER_TAB {"Power"};
308 const char *DEW_TAB {"Dew"};
309 const char *USB_TAB {"USB"};
310 const char *VARIABLE_TAB {"Variable"};
311};
312
313}
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
virtual bool SetUSBPort(size_t port, bool enabled)
SetUSBPort Set USB port on/off.
virtual bool CyclePower()
CyclePower Cycle power to all ports.
INDI::PropertySwitch PowerCycleAllSP
INDI::PropertySwitch DewChannelsSP
bool saveConfigItems(FILE *fp)
saveConfigItems Save power properties in config file
virtual bool SetAutoDewEnabled(size_t port, bool enabled)
SetAutoDewEnabled Enable/disable automatic dew control.
INDI::PropertySwitch AutoDewSP
virtual bool SetDewPort(size_t port, bool enabled, double dutyCycle)
SetDewPort Set DEW/Dew port duty cycle.
INDI::PropertyNumber VariableChannelVoltsNP
INDI::PropertyNumber OverVoltageProtectionNP
virtual bool SetVariablePort(size_t port, bool enabled, double voltage)
SetVariablePort Set variable voltage port.
void SetCapability(uint32_t cap)
SetPowerCapability sets the Power capabilities. All capabilities must be initialized.
INDI::PropertyNumber PowerSensorsNP
INDI::PropertyText VariableChannelLabelsTP
INDI::PropertyNumber PowerChannelCurrentNP
virtual bool SetPowerPort(size_t port, bool enabled)
SetPowerPort Set power port on/off.
virtual bool SetLEDEnabled(bool enabled)
SetLEDEnabled Enable/disable power LEDs.
INDI::PropertyNumber DewChannelCurrentNP
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process Power number properties.
void initProperties(const char *groupName, size_t nPowerPorts=0, size_t nDewPorts=0, size_t nVariablePorts=0, size_t nAutoDewPorts=0, size_t nUSBPorts=0)
Initialize Power properties. It is recommended to call this function within initProperties() of your ...
INDI::PropertyText PowerChannelLabelsTP
bool processText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process Power text properties.
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process Power switch properties.
INDI::PropertySwitch PowerChannelsSP
INDI::PropertySwitch USBPortSP
INDI::PropertyNumber DewChannelDutyCycleNP
INDI::PropertyText USBPortLabelsTP
bool updateProperties()
updateProperties Define or Delete Power properties based on the connection status of the base device
INDI::PropertySwitch LEDControlSP
INDI::PropertySwitch VariableChannelsSP
DefaultDevice * m_defaultDevice
uint32_t GetCapability() const
GetPowerCapability returns the capability of the Power device.
enum INDI::PowerInterface::@462 PowerCapability
INDI::PropertyText DewChannelLabelsTP
INDI::PropertySwitch PowerOffOnDisconnectSP
ISState
Switch state.
Definition indiapi.h:148
Namespace to encapsulate INDI client, drivers, and mediator classes.