Instrument Neutral Distributed Interface INDI 2.2.5
weather_safety_proxy.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2019 Hans Lambermont. All rights reserved.
3
4 INDI Weather Safety Proxy
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 "indiweather.h"
28
34
35typedef enum
36{
40
47
48typedef enum
49{
53
60
62{
63 public:
65 virtual ~WeatherSafetyProxy();
66
67 // Generic indi device entries
68 bool Connect() override;
69 bool Disconnect() override;
70 const char *getDefaultName() override;
71
72 virtual bool initProperties() override;
73 virtual bool updateProperties() override;
74 virtual void ISGetProperties(const char *dev) override;
75 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
76 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
77 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
78
79
80 protected:
81 virtual IPState updateWeather() override;
82 virtual bool saveConfigItems(FILE *fp) override;
83
84 private:
85 IPState executeScript();
86 IPState executeCurl();
87 IPState parseSafetyJSON(const std::string &buffer);
88
89 INDI::PropertyText keywordTP {1};
90
91 INDI::PropertyText ScriptsTP {1};
92
93 INDI::PropertyText UrlTP {1};
94
95 INDI::PropertySwitch ScriptOrCurlSP {2};
96
97 INDI::PropertyText reasonsTP {1};
98
99 INDI::PropertyNumber softErrorHysteresisNP {2};
100
101 int Safety = -1;
102 int SofterrorCount = 0;
103 int SofterrorRecoveryCount = 0;
104 bool SofterrorRecoveryMode = false;
105 bool LastParseSuccess = false;
106};
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
const char * getDefaultName() override
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
bool Disconnect() override
Disconnect from device.
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
@ WSP_USE_SCRIPT
@ WSP_USE_COUNT
@ WSP_USE_CURL
@ WSP_URL_COUNT
wsp_soft_error_enum
@ WSP_SOFT_ERROR_COUNT
@ WSP_SOFT_ERROR_MAX
@ WSP_SOFT_ERROR_RECOVERY
@ WSP_SCRIPT_COUNT