Instrument Neutral Distributed Interface INDI  1.9.5
indirotator.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2017 Jasem Mutlaq. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 *******************************************************************************/
18 
19 #pragma once
20 
21 #include "defaultdevice.h"
22 #include "indirotatorinterface.h"
23 
24 namespace Connection
25 {
26 class Serial;
27 class TCP;
28 }
42 namespace INDI
43 {
44 
45 class Rotator : public DefaultDevice, public RotatorInterface
46 {
47  public:
48  Rotator();
49  virtual ~Rotator();
50 
54  enum
55  {
56  CONNECTION_NONE = 1 << 0,
57  CONNECTION_SERIAL = 1 << 1,
58  CONNECTION_TCP = 1 << 2
60 
61  virtual bool initProperties() override;
62  virtual void ISGetProperties(const char *dev) override;
63  virtual bool updateProperties() override;
64  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
65  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
66 
72  void setRotatorConnection(const uint8_t &value);
73 
77  uint8_t getRotatorConnection() const;
78 
79  protected:
85  virtual bool saveConfigItems(FILE *fp) override;
86 
88  virtual bool Handshake();
89 
94 
97 
98  int PortFD = -1;
99 
100  private:
101  bool callHandshake();
102  uint8_t rotatorConnection = CONNECTION_SERIAL | CONNECTION_TCP;
103 };
104 }
INDI::Rotator::getRotatorConnection
uint8_t getRotatorConnection() const
Definition: indirotator.cpp:220
INDI::Rotator::CONNECTION_SERIAL
@ CONNECTION_SERIAL
Definition: indirotator.h:57
INDI::Rotator::setRotatorConnection
void setRotatorConnection(const uint8_t &value)
setRotatorConnection Set Rotator connection mode. Child class should call this in the constructor bef...
Definition: indirotator.cpp:225
INDI::Rotator::CONNECTION_NONE
@ CONNECTION_NONE
Definition: indirotator.h:56
INDI::Rotator::serialConnection
Connection::Serial * serialConnection
Definition: indirotator.h:95
INDI::Rotator
Definition: indirotator.h:45
ISwitch
One switch descriptor.
INumber
One number descriptor.
Connection::Serial
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Definition: connectionserial.h:56
INDI::Rotator::PortFD
int PortFD
Definition: indirotator.h:98
Connection::TCP
The TCP class manages connection with devices over the network via TCP/IP. Upon successfull connectio...
Definition: connectiontcp.h:55
INDI::Rotator::PresetNP
INumberVectorProperty PresetNP
Definition: indirotator.h:91
INDI::Rotator::PresetGotoSP
ISwitchVectorProperty PresetGotoSP
Definition: indirotator.h:93
INDI::Rotator::~Rotator
virtual ~Rotator()
Definition: indirotator.cpp:49
INDI::Rotator::PresetN
INumber PresetN[3]
Definition: indirotator.h:90
INDI::Rotator::tcpConnection
Connection::TCP * tcpConnection
Definition: indirotator.h:96
INDI::Rotator::CONNECTION_TCP
@ CONNECTION_TCP
Definition: indirotator.h:58
INDI::Rotator::Handshake
virtual bool Handshake()
perform handshake with device to check communication
Definition: indirotator.cpp:191
INDI::Rotator::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: indirotator.cpp:53
indirotatorinterface.h
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
defaultdevice.h
INDI::Rotator::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the reverse direction property in the configuration file
Definition: indirotator.cpp:196
INDI::Rotator::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: indirotator.cpp:110
Connection
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition: arduino_st4.h:33
INDI::Rotator::RotatorConnection
enum INDI::Rotator::@193 RotatorConnection
name
const char * name
Definition: indiserver.c:116
INDI::Rotator::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: indirotator.cpp:132
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::Rotator::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: indirotator.cpp:99
INDI::Rotator::Rotator
Rotator()
Definition: indirotator.cpp:45
INDI::Rotator::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: indirotator.cpp:155
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::RotatorInterface
Definition: indirotatorinterface.h:45
INDI::DefaultDevice
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Definition: defaultdevice.h:118
INDI::Rotator::PresetGotoS
ISwitch PresetGotoS[3]
Definition: indirotator.h:92
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365