Instrument Neutral Distributed Interface INDI  1.9.5
indifilterwheel.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2010, 2011 Gerry Rozema. 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 "indifilterinterface.h"
23 
33 namespace INDI
34 {
35 
37 {
38  protected:
39  FilterWheel();
40  virtual ~FilterWheel() = default;
41 
42  public:
47  enum
48  {
49  CONNECTION_NONE = 1 << 0,
50  CONNECTION_SERIAL = 1 << 1,
51  CONNECTION_TCP = 1 << 2
53 
54  virtual bool initProperties() override;
55  virtual bool updateProperties() override;
56  virtual void ISGetProperties(const char *dev) override;
57  virtual bool ISSnoopDevice(XMLEle *root) override;
58  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
59  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
60  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
61 
62  static void joystickHelper(const char *joystick_n, double mag, double angle, void *context);
63  static void buttonHelper(const char *button_n, ISState state, void *context);
64 
70  void setFilterConnection(const uint8_t &value);
71 
75  uint8_t getFilterConnection() const;
76 
77  protected:
78  virtual bool saveConfigItems(FILE *fp) override;
79  virtual int QueryFilter() override;
80  virtual bool SelectFilter(int) override;
81 
83  virtual bool Handshake();
84 
85  void processJoystick(const char *joystick_n, double mag, double angle);
86  void processButton(const char *button_n, ISState state);
87 
89 
92 
94  int PortFD = -1;
95 
96  private:
97  bool callHandshake();
98  uint8_t filterConnection = CONNECTION_NONE;
99 };
100 }
INDI::FilterWheel::buttonHelper
static void buttonHelper(const char *button_n, ISState state, void *context)
Definition: indifilterwheel.cpp:175
INDI::FilterWheel::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: indifilterwheel.cpp:54
INDI::Controller
The Controller class provides functionality to access a controller (e.g. joystick) input and send it ...
Definition: indicontroller.h:81
INDI::FilterWheel::serialConnection
Connection::Serial * serialConnection
Definition: indifilterwheel.h:90
Connection::Serial
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Definition: connectionserial.h:56
INDI::FilterWheel::controller
Controller * controller
Definition: indifilterwheel.h:88
Connection::TCP
The TCP class manages connection with devices over the network via TCP/IP. Upon successfull connectio...
Definition: connectiontcp.h:55
INDI::FilterWheel::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: indifilterwheel.cpp:113
INDI::FilterWheel::ISNewText
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition: indifilterwheel.cpp:127
INDI::FilterWheel::setFilterConnection
void setFilterConnection(const uint8_t &value)
setFilterConnection Set Filter connection mode. Child class should call this in the constructor befor...
Definition: indifilterwheel.cpp:245
INDI::FilterWheel::CONNECTION_TCP
@ CONNECTION_TCP
Definition: indifilterwheel.h:51
INDI::FilterWheel::getFilterConnection
uint8_t getFilterConnection() const
INDI::FilterWheel::FilterWheel
FilterWheel()
Definition: indifilterwheel.cpp:46
INDI::FilterInterface
Definition: indifilterinterface.h:45
INDI::FilterWheel::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: indifilterwheel.cpp:163
INDI::FilterWheel::~FilterWheel
virtual ~FilterWheel()=default
INDI::FilterWheel::tcpConnection
Connection::TCP * tcpConnection
Definition: indifilterwheel.h:91
INDI::FilterWheel::FilterConnection
enum INDI::FilterWheel::@188 FilterConnection
INDI::FilterWheel::processJoystick
void processJoystick(const char *joystick_n, double mag, double angle)
Definition: indifilterwheel.cpp:180
xml_ele_
Definition: lilxml.c:105
indifilterinterface.h
defaultdevice.h
INDI::FilterWheel
Definition: indifilterwheel.h:36
INDI::FilterWheel::joystickHelper
static void joystickHelper(const char *joystick_n, double mag, double angle, void *context)
Definition: indifilterwheel.cpp:170
INDI::FilterWheel::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: indifilterwheel.cpp:107
name
const char * name
Definition: indiserver.c:116
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::FilterWheel::PortFD
int PortFD
For Serial & TCP connections.
Definition: indifilterwheel.h:94
INDI::FilterWheel::processButton
void processButton(const char *button_n, ISState state)
Definition: indifilterwheel.cpp:213
INDI::FilterWheel::CONNECTION_NONE
@ CONNECTION_NONE
Definition: indifilterwheel.h:49
INDI::FilterWheel::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: indifilterwheel.cpp:93
INDI::FilterWheel::CONNECTION_SERIAL
@ CONNECTION_SERIAL
Definition: indifilterwheel.h:50
INDI::FilterWheel::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: indifilterwheel.cpp:85
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::FilterWheel::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition: indifilterwheel.cpp:142
INDI::DefaultDevice
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Definition: defaultdevice.h:118
INDI::FilterWheel::QueryFilter
virtual int QueryFilter() override
Return current filter position.
Definition: indifilterwheel.cpp:153
INDI::FilterWheel::Handshake
virtual bool Handshake()
perform handshake with device to check communication
Definition: indifilterwheel.cpp:227
INDI::FilterWheel::SelectFilter
virtual bool SelectFilter(int) override
Select a new filter position.
Definition: indifilterwheel.cpp:158