Instrument Neutral Distributed Interface INDI 2.2.5
pegasus_ppb.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2019 Jasem Mutlaq. All rights reserved.
3
4 Pegasus Pocket Power Box
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 "indipowerinterface.h"
30
31#include <vector>
32#include <stdint.h>
33
34namespace Connection
35{
36class Serial;
37}
38
40{
41 public:
42 PegasusPPB();
43
44 virtual bool initProperties() override;
45 virtual bool updateProperties() override;
46
47 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
48 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
49 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
50
51 protected:
52 const char *getDefaultName() override;
53 virtual bool saveConfigItems(FILE *fp) override;
54
55 // Event loop
56 virtual void TimerHit() override;
57
58 // Weather Overrides
59 virtual IPState updateWeather() override
60 {
61 return IPS_OK;
62 }
63
64 // Power Interface Overrides
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
74 private:
75 bool Handshake();
76
77 // Get Data
78 bool sendFirmware();
79 bool getSensorData();
80 std::vector<std::string> split(const std::string &input, const std::string &regex);
81 enum
82 {
83 PA_NAME,
84 PA_VOLTAGE,
85 PA_CURRENT,
86 PA_TEMPERATURE,
87 PA_HUMIDITY,
88 PA_DEW_POINT,
89 PA_PORT_STATUS,
90 PA_DSLR_STATUS,
91 PA_DEW_1,
92 PA_DEW_2,
93 PA_AUTO_DEW,
94 PA_N,
95 };
96
97 // Device Control
98 bool reboot();
99
100 // Power
101 bool setPowerEnabled(uint8_t port, bool enabled);
102 bool setPowerOnBoot();
103
104 // Dew
105 bool setAutoDewEnabled(bool enabled);
106 bool setDewPWM(uint8_t id, uint8_t value);
107
114 bool sendCommand(const char *cmd, char *res);
115
116 int PortFD { -1 };
117 bool setupComplete { false };
118
119 Connection::Serial *serialConnection { nullptr };
120
125 INDI::PropertySwitch RebootSP {1};
126
127 INDI::PropertySwitch DSLRPowerSP {2};
128
129 // Select which power is ON on bootup
130 INDI::PropertySwitch PowerOnBootSP {4};
131 enum
132 {
133 POWER_PORT_1,
134 POWER_PORT_2,
135 POWER_PORT_3,
136 POWER_PORT_4
137 };
138
139 std::vector<std::string> lastSensorData;
140 char stopChar { 0xD };
141
142 static constexpr const uint8_t PEGASUS_TIMEOUT {3};
143 static constexpr const uint8_t PEGASUS_LEN {128};
144 static constexpr const char *DEW_TAB {"Dew"};
145 static constexpr const char *ENVIRONMENT_TAB {"Environment"};
146};
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 ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool SetUSBPort(size_t port, bool enabled) override
SetUSBPort Set USB port on/off.
virtual bool SetPowerPort(size_t port, bool enabled) override
Power Interface Implementations.
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
Definition pegasus_ppb.h:59
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...
const char * getDefaultName() override
virtual bool SetVariablePort(size_t port, bool enabled, double voltage) override
SetVariablePort Set variable voltage port.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool CyclePower() override
CyclePower Cycle power to all ports.
virtual bool SetLEDEnabled(bool enabled) override
SetLEDEnabled Enable/disable power LEDs.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
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.
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