Instrument Neutral Distributed Interface INDI  2.0.2
indifocuser.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2013 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 "indifocuserinterface.h"
23 
24 namespace Connection
25 {
26 class Serial;
27 class TCP;
28 }
40 namespace INDI
41 {
42 
43 class Focuser : public DefaultDevice, public FocuserInterface
44 {
45  public:
46  Focuser();
47  virtual ~Focuser();
48 
52  enum
53  {
54  CONNECTION_NONE = 1 << 0,
55  CONNECTION_SERIAL = 1 << 1,
56  CONNECTION_TCP = 1 << 2
58 
59  virtual bool initProperties() override;
60  virtual void ISGetProperties(const char *dev) override;
61  virtual bool updateProperties() override;
62  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
63  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
64  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
65  virtual bool ISSnoopDevice(XMLEle *root) override;
66 
72  void setSupportedConnections(const uint8_t &value);
73 
77  uint8_t getSupportedConnections() const
78  {
79  return focuserConnection;
80  }
81 
82  static void buttonHelper(const char *button_n, ISState state, void *context);
83 
84  protected:
90  virtual bool saveConfigItems(FILE *fp) override;
91 
93  virtual bool Handshake();
94 
100  virtual bool SetFocuserMaxPosition(uint32_t ticks) override;
101 
105  virtual void SyncPresets(uint32_t ticks);
106 
111 
112  void processButton(const char *button_n, ISState state);
113 
115 
118 
119  int PortFD = -1;
120 
121  private:
122  bool callHandshake();
123  uint8_t focuserConnection = CONNECTION_SERIAL | CONNECTION_TCP;
124 };
125 }
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
The Controller class provides functionality to access a controller (e.g. joystick) input and send it ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Provides interface to implement focuser functionality.
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
void processButton(const char *button_n, ISState state)
enum INDI::Focuser::@245 FocuserConnection
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
ISwitchVectorProperty PresetGotoSP
Definition: indifocuser.h:110
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
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: indifocuser.cpp:95
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
INumber PresetN[3]
Definition: indifocuser.h:107
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: indifocuser.cpp:42
Connection::TCP * tcpConnection
Definition: indifocuser.h:117
INumberVectorProperty PresetNP
Definition: indifocuser.h:108
virtual ~Focuser()
Definition: indifocuser.cpp:37
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual void SyncPresets(uint32_t ticks)
syncPresets Updates the min/max/step range of the preset as per the maximum name of Absolute Focus Tr...
Connection::Serial * serialConnection
Definition: indifocuser.h:116
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Controller * controller
Definition: indifocuser.h:114
ISwitch PresetGotoS[3]
Definition: indifocuser.h:109
static void buttonHelper(const char *button_n, ISState state, void *context)
uint8_t getSupportedConnections() const
Definition: indifocuser.h:77
void setSupportedConnections(const uint8_t &value)
setConnection Set Focuser connection mode. Child class should call this in the constructor before Foc...
virtual bool SetFocuserMaxPosition(uint32_t ticks) override
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
virtual bool Handshake()
perform handshake with device to check communication
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 switch descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367