Instrument Neutral Distributed Interface INDI 2.2.5
Terrans_PowerBoxGo_V2.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2015 Jasem Mutlaq. All rights reserved.
3
4 TerransPowerBoxGoV2
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"
28#include "indipowerinterface.h" // Include the PowerInterface header
29
30#include <vector>
31#include <stdint.h>
32
33#include "basedevice.h"
34
35namespace Connection
36{
37class Serial;
38}
39
41{
42 public:
44 public:
45 virtual ~TerransPowerBoxGoV2() = default;
46 virtual bool initProperties() override;
47 virtual bool updateProperties() override;
48 virtual void TimerHit() override;
49 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
50 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
51 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[],
52 int n) override; // Add ISNewNumber
53
54 protected:
55 virtual const char *getDefaultName() override;
56 virtual bool saveConfigItems(FILE *fp) override;
57
58 // Implement virtual methods from INDI::PowerInterface
59 virtual bool SetPowerPort(size_t port, bool enabled) override;
60 virtual bool SetDewPort(size_t port, bool enabled, double dutyCycle) override;
61 virtual bool SetVariablePort(size_t port, bool enabled, double voltage) override;
62 virtual bool SetLEDEnabled(bool enabled) override;
63 virtual bool SetAutoDewEnabled(size_t port, bool enabled) override;
64 virtual bool CyclePower() override;
65 virtual bool SetUSBPort(size_t port, bool enabled) override;
66
67 private:
68 bool Handshake();
69 bool sendCommand(const char * cmd, char * res);
70 int PortFD{-1};
71
72 bool setupComplete { false };
73 bool processButtonSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
74
75 void Get_State();
76
77 Connection::Serial *serialConnection { nullptr };
78
79 // Removed manual property declarations, now handled by INDI::PowerInterface
80 // Retained MCUTempNP as it's not power-related
81 INDI::PropertyNumber MCUTempNP {1};
82 INDI::PropertySwitch StateSaveSP {2};
83
84 static constexpr const char *ADD_SETTING_TAB {"Additional Settings"};
85
86};
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...
virtual bool SetPowerPort(size_t port, bool enabled) override
SetPowerPort Set power port on/off.
virtual bool SetDewPort(size_t port, bool enabled, double dutyCycle) override
SetDewPort Set DEW/Dew port duty cycle.
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.
virtual bool CyclePower() override
CyclePower Cycle power to all ports.
virtual ~TerransPowerBoxGoV2()=default
virtual const char * getDefaultName() override
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool SetVariablePort(size_t port, bool enabled, double voltage) override
SetVariablePort Set variable voltage port.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool SetAutoDewEnabled(size_t port, bool enabled) override
SetAutoDewEnabled Enable/disable automatic dew control.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool SetLEDEnabled(bool enabled) override
SetLEDEnabled Enable/disable power LEDs.
virtual bool SetUSBPort(size_t port, bool enabled) override
SetUSBPort Set USB port on/off.
ISState
Switch state.
Definition indiapi.h:148
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition arduino_st4.h:34
uint8_t cmd[4]
Definition pwc-ioctl.h:2