Instrument Neutral Distributed Interface INDI  1.9.5
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:
103  virtual void TimerHit() override;
104 
112  virtual bool updateLocation(double latitude, double longitude, double elevation);
113 
119  void setWeatherConnection(const uint8_t &value);
120 
124  uint8_t getWeatherConnection() const;
125 
126  virtual bool saveConfigItems(FILE *fp) override;
127 
129  virtual bool Handshake();
130 
131  // A number vector that stores lattitude and longitude
134 
135  // Active devices to snoop
138 
139  // Update Period
142 
143  // Refresh data
146 
147  // Override
150 
153 
154  int PortFD = -1;
155  int updateTimerID { -1 };
156 
157  private:
158  bool processLocationInfo(double latitude, double longitude, double elevation);
159 
160  bool callHandshake();
161  uint8_t weatherConnection = CONNECTION_SERIAL | CONNECTION_TCP;
162 };
163 }
INDI::Weather::Handshake
virtual bool Handshake()
perform handshake with device to check communication
Definition: indiweather.cpp:379
INDI::Weather::LOCATION_LONGITUDE
@ LOCATION_LONGITUDE
Definition: indiweather.h:74
INDI::Weather::WeatherLocation
WeatherLocation
Definition: indiweather.h:71
ISwitch
One switch descriptor.
INDI::Weather::ActiveDeviceT
IText ActiveDeviceT[1]
Definition: indiweather.h:137
INDI::Weather::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: indiweather.cpp:41
INDI::Weather::Weather
Weather()
Definition: indiweather.cpp:37
INumber
One number descriptor.
Connection::Serial
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Definition: connectionserial.h:56
Connection::TCP
The TCP class manages connection with devices over the network via TCP/IP. Upon successfull connectio...
Definition: connectiontcp.h:55
INDI::Weather::tcpConnection
Connection::TCP * tcpConnection
Definition: indiweather.h:152
INDI::Weather
Definition: indiweather.h:68
INDI::Weather::updateTimerID
int updateTimerID
Definition: indiweather.h:155
INDI::Weather::ISSnoopDevice
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
Definition: indiweather.cpp:247
INDI::Weather::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: indiweather.cpp:133
INDI::Weather::CONNECTION_TCP
@ CONNECTION_TCP
Definition: indiweather.h:85
INDI::Weather::CONNECTION_SERIAL
@ CONNECTION_SERIAL
Definition: indiweather.h:84
INDI::Weather::LocationNP
INumberVectorProperty LocationNP
Definition: indiweather.h:132
INDI::Weather::updateLocation
virtual bool updateLocation(double latitude, double longitude, double elevation)
Update weather station location.
Definition: indiweather.cpp:329
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
INDI::Weather::getWeatherConnection
uint8_t getWeatherConnection() const
Definition: indiweather.cpp:397
INDI::Weather::RefreshSP
ISwitchVectorProperty RefreshSP
Definition: indiweather.h:145
INDI::Weather::setWeatherConnection
void setWeatherConnection(const uint8_t &value)
setWeatherConnection Set Weather connection mode. Child class should call this in the constructor bef...
Definition: indiweather.cpp:402
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
INDI::Weather::PortFD
int PortFD
Definition: indiweather.h:154
INDI::Weather::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition: indiweather.cpp:369
INDI::Weather::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: indiweather.cpp:176
IText
One text descriptor.
INDI::Weather::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: indiweather.cpp:101
xml_ele_
Definition: lilxml.c:105
defaultdevice.h
INDI::Weather::LOCATION_LATITUDE
@ LOCATION_LATITUDE
Definition: indiweather.h:73
INDI::Weather::ISNewText
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition: indiweather.cpp:228
INDI::Weather::OverrideSP
ISwitchVectorProperty OverrideSP
Definition: indiweather.h:149
INDI::Weather::UpdatePeriodNP
INumberVectorProperty UpdatePeriodNP
Definition: indiweather.h:141
INDI::Weather::TimerHit
virtual void TimerHit() override
TimerHit Keep calling updateWeather() until it is successful, if it fails upon first connection.
Definition: indiweather.cpp:281
Connection
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition: arduino_st4.h:33
INDI::Weather::OverrideS
ISwitch OverrideS[1]
Definition: indiweather.h:148
name
const char * name
Definition: indiserver.c:116
INDI::Weather::serialConnection
Connection::Serial * serialConnection
Definition: indiweather.h:151
indiweatherinterface.h
INDI::Weather::UpdatePeriodN
INumber UpdatePeriodN[1]
Definition: indiweather.h:140
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::Weather::CONNECTION_NONE
@ CONNECTION_NONE
Definition: indiweather.h:83
INDI::Weather::LocationN
INumber LocationN[3]
Definition: indiweather.h:133
INDI::Weather::RefreshS
ISwitch RefreshS[1]
Definition: indiweather.h:144
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::Weather::WeatherConnection
enum INDI::Weather::@208 WeatherConnection
INDI::WeatherInterface
Provides interface to implement weather reporting functionality.
Definition: indiweatherinterface.h:55
INDI::Weather::LOCATION_ELEVATION
@ LOCATION_ELEVATION
Definition: indiweather.h:75
INDI::DefaultDevice
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Definition: defaultdevice.h:118
INDI::Weather::ActiveDeviceTP
ITextVectorProperty ActiveDeviceTP
Definition: indiweather.h:136
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365