Instrument Neutral Distributed Interface INDI  2.0.2
indiweatherinterface.h
Go to the documentation of this file.
1 /*
2  Weather Interface
3  Copyright (C) 2018 Jasem Mutlaq (mutlaqja@ikarustech.com)
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 "inditimer.h"
27 
28 #include <stdint.h>
29 #include <string>
30 
31 // Alias
33 
34 namespace INDI
35 {
36 
58 {
59  public:
60 
61  protected:
62  explicit WeatherInterface(DefaultDevice *defaultDevice);
63  virtual ~WeatherInterface();
64 
71  void initProperties(const char *statusGroup, const char *paramsGroup);
72 
77  bool updateProperties();
78 
80  bool processNumber(const char *dev, const char *name, double values[], char *names[], int n);
81 
83  bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
84 
88  void checkWeatherUpdate();
89 
98  virtual IPState updateWeather();
99 
105  virtual bool saveConfigItems(FILE *fp);
106 
122  void addParameter(std::string name, std::string label, double numMinOk, double numMaxOk, double percWarning);
123 
131  bool setCriticalParameter(std::string param);
132 
138  void setParameterValue(std::string name, double value);
139 
148  IPState checkParameterState(const std::string &param) const;
149 
150  IPState checkParameterState(const INumber &parameter) const;
151 
156  bool syncCriticalParameters();
157 
158  // Parameters
159  INumber *ParametersN {nullptr};
161 
162  // Parameter Ranges
164  uint8_t nRanges {0};
165 
166  // Weather status
169 
170  // Update Period
172  // Refresh data
174 
175  // Override
177 
178 
179  private:
180  void createParameterRange(std::string name, std::string label);
181  DefaultDevice *m_defaultDevice { nullptr };
182  std::string m_ParametersGroup;
183  INDI::Timer m_UpdateTimer;
184 };
185 }
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 functionality.
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process weather switch properties.
bool syncCriticalParameters()
updateWeatherState Send update weather state to client
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 setCriticalParameter(std::string param)
setCriticalParameter Set parameter that is considered critical to the operation of the observatory....
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process weather number properties.
WeatherInterface(DefaultDevice *defaultDevice)
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save parameters ranges in the config file.
ILightVectorProperty critialParametersLP
INDI::PropertySwitch OverrideSP
INumberVectorProperty ParametersNP
IPState checkParameterState(const std::string &param) const
checkParameterState Checks the given parameter against the defined bounds
void addParameter(std::string name, std::string label, double numMinOk, double numMaxOk, double percWarning)
addParameter Add a physical weather measurable parameter to the weather driver. The weather value has...
void checkWeatherUpdate()
checkWeatherUpdate Calls updateWeather and update critical parameters accordingly.
void initProperties(const char *statusGroup, const char *paramsGroup)
Initilize focuser properties. It is recommended to call this function within initProperties() of your...
INDI::PropertySwitch RefreshSP
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
INDI::PropertyNumber UpdatePeriodNP
INumberVectorProperty * ParametersRangeNP
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
Namespace to encapsulate INDI client, drivers, and mediator classes.
One light descriptor.
One number descriptor.
Light vector property descriptor.
Definition: indiapi.h:417
Number vector property descriptor.
Definition: indiapi.h:319