Instrument Neutral Distributed Interface INDI  1.9.5
weatherwatcher.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2018 Jasem Mutlaq. All rights reserved.
3 
4  INDI Weather Watcher Driver
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 
29 #include <map>
30 
32 {
33  public:
35 
36  // Generic indi device entries
37  bool Connect() override;
38  bool Disconnect() override;
39  const char *getDefaultName() override;
40 
41  virtual bool initProperties() override;
42  virtual void ISGetProperties(const char *dev) override;
43  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
44 
45  protected:
46  virtual IPState updateWeather() override;
47  virtual bool saveConfigItems(FILE *fp) override;
48 
49  IText keywordT[8] {};
51 
52  IText separatorT[1] {};
54 
55  private:
56  std::map<std::string, std::string> createMap(std::string const& s);
57  bool readWatchFile();
58  bool createPropertiesFromMap();
59 
60  IText watchFileT[1] {};
61  ITextVectorProperty watchFileTP;
62 
63  bool initialParse { false };
64  std::string readBuffer;
65 
66  std::map<std::string,std::string> weatherMap;
67 };
IPState
IPState
Property state.
Definition: indiapi.h:158
INDI::Weather
Definition: indiweather.h:68
WeatherWatcher::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: weatherwatcher.cpp:184
WeatherWatcher::ISNewText
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition: weatherwatcher.cpp:227
WeatherWatcher::WeatherWatcher
WeatherWatcher()
Definition: weatherwatcher.cpp:42
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
WeatherWatcher::keywordTP
ITextVectorProperty keywordTP
Definition: weatherwatcher.h:72
WeatherWatcher::Connect
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: weatherwatcher.cpp:54
WeatherWatcher::separatorT
IText separatorT[1]
Definition: weatherwatcher.h:74
WeatherWatcher::keywordT
IText keywordT[8]
Definition: weatherwatcher.h:71
IText
One text descriptor.
WeatherWatcher::ISGetProperties
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...
Definition: weatherwatcher.cpp:212
WeatherWatcher::updateWeather
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
Definition: weatherwatcher.cpp:258
WeatherWatcher::Disconnect
bool Disconnect() override
Disconnect from device.
Definition: weatherwatcher.cpp:65
name
const char * name
Definition: indiserver.c:116
WeatherWatcher::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition: weatherwatcher.cpp:337
indiweather.h
WeatherWatcher
Definition: weatherwatcher.h:31
WeatherWatcher::separatorTP
ITextVectorProperty separatorTP
Definition: weatherwatcher.h:75
WeatherWatcher::getDefaultName
const char * getDefaultName() override
Definition: weatherwatcher.cpp:49