Instrument Neutral Distributed Interface INDI 2.2.5
Terrans_PowerBoxPro_V2.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2015 Jasem Mutlaq. All rights reserved.
3
4 TerransPowerBoxProV2
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"
30
31#include <vector>
32#include <stdint.h>
33
34#include "basedevice.h"
35
36namespace Connection
37{
38 class Serial;
39}
40
42{
43public:
45 public:
46 virtual ~TerransPowerBoxProV2() = default;
47 virtual bool initProperties() override;
48 virtual bool updateProperties() override;
49 virtual void TimerHit() override;
50 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
51 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
52 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
53
54 // Weather Overrides
55 virtual IPState updateWeather() override
56 {
57 return IPS_OK;
58 }
59
60 protected:
61 virtual const char *getDefaultName() override;
62 virtual bool saveConfigItems(FILE *fp) override;
63
64 // Implement virtual methods from INDI::PowerInterface
65 virtual bool SetPowerPort(size_t port, bool enabled) override;
66 virtual bool SetDewPort(size_t port, bool enabled, double dutyCycle) override;
67 virtual bool SetVariablePort(size_t port, bool enabled, double voltage) override;
68 virtual bool SetLEDEnabled(bool enabled) override;
69 virtual bool SetAutoDewEnabled(size_t port, bool enabled) override;
70 virtual bool CyclePower() override;
71 virtual bool SetUSBPort(size_t port, bool enabled) override;
72
73 private:
74 bool Handshake();
75 bool sendCommand(const char * cmd, char * res);
76 int PortFD{-1};
77
78 bool setupComplete { false };
79 bool processButtonSwitch(const char *dev, const char *name, ISState *states, char *names[],int n);
80
81 void Get_State();
82
83 Connection::Serial *serialConnection { nullptr };
84
85 // Retain MCUTempNP as it's not power-related
86 INumber MCUTempN[1];
87 INumberVectorProperty MCUTempNP;
88
89 static constexpr const char *ADD_SETTING_TAB {"Additional Settings"};
90
91};
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 updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool SetDewPort(size_t port, bool enabled, double dutyCycle) override
SetDewPort Set DEW/Dew port duty cycle.
virtual ~TerransPowerBoxProV2()=default
virtual bool SetPowerPort(size_t port, bool enabled) override
SetPowerPort Set power port on/off.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
virtual bool SetAutoDewEnabled(size_t port, bool enabled) override
SetAutoDewEnabled Enable/disable automatic dew control.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool SetLEDEnabled(bool enabled) override
SetLEDEnabled Enable/disable power LEDs.
virtual bool CyclePower() override
CyclePower Cycle power to all ports.
virtual bool SetUSBPort(size_t port, bool enabled) override
SetUSBPort Set USB port on/off.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], 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 SetVariablePort(size_t port, bool enabled, double voltage) override
SetVariablePort Set variable voltage port.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual const char * getDefaultName() override
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
@ IPS_OK
Definition indiapi.h:160
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
One number descriptor.
Number vector property descriptor.
Definition indiapi.h:317