Instrument Neutral Distributed Interface INDI 2.2.5
indiweatherinterface.h
Go to the documentation of this file.
1/*
2 Weather Interface
3 Copyright (C) 2018 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 "indipropertynumber.h"
25#include "indipropertyswitch.h"
26#include "indipropertylight.h"
27#include "inditimer.h"
28
29#include <stdint.h>
30#include <string>
31#include <vector>
32
33// Alias
35
36namespace INDI
37{
38
133{
134 public:
135
136 protected:
137 explicit WeatherInterface(DefaultDevice *defaultDevice);
138 virtual ~WeatherInterface();
139
146 void initProperties(const char *statusGroup, const char *paramsGroup);
147
152 bool updateProperties();
153
155 bool processNumber(const char *dev, const char *name, double values[], char *names[], int n);
156
158 bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
159
163 void checkWeatherUpdate();
164
173 virtual IPState updateWeather();
174
180 virtual bool saveConfigItems(FILE *fp);
181
209 void addParameter(std::string name, std::string label, double numMinOk, double numMaxOk, double percWarning, bool flipWarning = false);
210
218 bool setCriticalParameter(std::string name);
219
225 void setParameterValue(std::string name, double value);
226
268 IPState checkParameterState(const std::string &param) const;
269
280
281 // Parameters
283
284 // Parameter Ranges
285 std::vector<INDI::PropertyNumber> ParametersRangeNP;
286 enum
287 {
292 };
293
294 // Weather status
296
297 // Safety status (standard property for safety monitoring)
299
300 // Update Period
302 // Refresh data
304
305 // Override
307
308
309 private:
310 void createParameterRange(std::string name, std::string label, double numMinOk, double numMaxOk, double percWarning, bool flipWarning);
311 DefaultDevice *m_defaultDevice { nullptr };
312 std::string m_ParametersGroup;
313 INDI::Timer m_UpdateTimer;
314};
315}
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
The Timer class provides repetitive and single-shot timers.
Definition inditimer.h:41
Provides interface to implement weather reporting and safety monitoring functionality.
void addParameter(std::string name, std::string label, double numMinOk, double numMaxOk, double percWarning, bool flipWarning=false)
Add a physical weather measurable parameter to the weather driver.
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process weather switch properties.
bool setCriticalParameter(std::string name)
setCriticalParameter Set parameter that is considered critical to the operation of the observatory....
bool syncCriticalParameters()
Synchronize and update the state of all critical parameters.
virtual IPState updateWeather()
updateWeather Update weather conditions from device or service. The function should not change the st...
void setParameterValue(std::string name, double value)
setParameterValue Update weather parameter value
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process weather number properties.
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save parameters ranges in the config file.
INDI::PropertyNumber ParametersNP
std::vector< INDI::PropertyNumber > ParametersRangeNP
INDI::PropertySwitch OverrideSP
IPState checkParameterState(const std::string &param) const
Checks the given parameter against the defined bounds.
void checkWeatherUpdate()
checkWeatherUpdate Calls updateWeather and update critical parameters accordingly.
INDI::PropertyLight SafetyStatusLP
void initProperties(const char *statusGroup, const char *paramsGroup)
Initialize focuser properties. It is recommended to call this function within initProperties() of you...
INDI::PropertySwitch RefreshSP
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
INDI::PropertyLight critialParametersLP
INDI::PropertyNumber UpdatePeriodNP
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
Namespace to encapsulate INDI client, drivers, and mediator classes.