Instrument Neutral Distributed Interface INDI  2.0.2
indiweather.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2015 Jasem Mutlaq. All rights reserved.
3 
4  INDI Weather Device Class
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"
28 #include "indiweatherinterface.h"
29 
30 #include <list>
31 
32 namespace Connection
33 {
34 class Serial;
35 class TCP;
36 }
37 
66 namespace INDI
67 {
68 class Weather : public DefaultDevice, public WeatherInterface
69 {
70  public:
72  {
76  };
77 
81  enum
82  {
83  CONNECTION_NONE = 1 << 0,
84  CONNECTION_SERIAL = 1 << 1,
85  CONNECTION_TCP = 1 << 2
87 
88  Weather();
89 
90  virtual bool initProperties() override;
91  virtual bool updateProperties() override;
92  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
93  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
94  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
95 
96  virtual bool ISSnoopDevice(XMLEle *root) override;
97 
98  protected:
106  virtual bool updateLocation(double latitude, double longitude, double elevation);
107 
113  void setWeatherConnection(const uint8_t &value);
114 
118  uint8_t getWeatherConnection() const;
119 
120  virtual bool saveConfigItems(FILE *fp) override;
121 
123  virtual bool Handshake();
124 
125  // A number vector that stores lattitude and longitude
128 
129  // Active devices to snoop
132 
135 
136  int PortFD = -1;
137 
138  private:
139  bool processLocationInfo(double latitude, double longitude, double elevation);
140 
141  bool callHandshake();
142  uint8_t weatherConnection = CONNECTION_SERIAL | CONNECTION_TCP;
143 };
144 }
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
The TCP class manages connection with devices over the network via TCP/IP. Upon successfull connectio...
Definition: connectiontcp.h:38
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Provides interface to implement weather reporting functionality.
ITextVectorProperty ActiveDeviceTP
Definition: indiweather.h:130
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: indiweather.cpp:85
IText ActiveDeviceT[1]
Definition: indiweather.h:131
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool Handshake()
perform handshake with device to check communication
INumberVectorProperty LocationNP
Definition: indiweather.h:126
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
void setWeatherConnection(const uint8_t &value)
setWeatherConnection Set Weather connection mode. Child class should call this in the constructor bef...
INumber LocationN[3]
Definition: indiweather.h:127
virtual bool updateLocation(double latitude, double longitude, double elevation)
Update weather station location.
uint8_t getWeatherConnection() const
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
Connection::Serial * serialConnection
Definition: indiweather.h:133
Connection::TCP * tcpConnection
Definition: indiweather.h:134
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: indiweather.cpp:41
enum INDI::Weather::@265 WeatherConnection
ISState
Switch state.
Definition: indiapi.h:150
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition: arduino_st4.h:34
Namespace to encapsulate INDI client, drivers, and mediator classes.
One number descriptor.
One text descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Text vector property descriptor.
Definition: indiapi.h:246