Instrument Neutral Distributed Interface INDI  1.9.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 { return focuserConnection;}
78 
79  static void buttonHelper(const char *button_n, ISState state, void *context);
80 
81  protected:
87  virtual bool saveConfigItems(FILE *fp) override;
88 
90  virtual bool Handshake();
91 
97  virtual bool SetFocuserMaxPosition(uint32_t ticks) override;
98 
102  virtual void SyncPresets(uint32_t ticks);
103 
108 
109  void processButton(const char *button_n, ISState state);
110 
112 
115 
116  int PortFD = -1;
117 
118  private:
119  bool callHandshake();
120  uint8_t focuserConnection = CONNECTION_SERIAL | CONNECTION_TCP;
121 };
122 }
INDI::Focuser::controller
Controller * controller
Definition: indifocuser.h:111
INDI::Focuser::PresetNP
INumberVectorProperty PresetNP
Definition: indifocuser.h:105
ISwitch
One switch descriptor.
INDI::Focuser::PresetGotoSP
ISwitchVectorProperty PresetGotoSP
Definition: indifocuser.h:107
INDI::Controller
The Controller class provides functionality to access a controller (e.g. joystick) input and send it ...
Definition: indicontroller.h:81
INDI::Focuser::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: indifocuser.cpp:111
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::Focuser::processButton
void processButton(const char *button_n, ISState state)
Definition: indifocuser.cpp:258
INDI::FocuserInterface
Provides interface to implement focuser functionality.
Definition: indifocuserinterface.h:63
INDI::Focuser::~Focuser
virtual ~Focuser()
Definition: indifocuser.cpp:53
INDI::Focuser::ISNewText
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition: indifocuser.cpp:222
INDI::Focuser::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: indifocuser.cpp:241
INDI::Focuser::Focuser
Focuser()
Definition: indifocuser.cpp:46
INDI::Focuser::serialConnection
Connection::Serial * serialConnection
Definition: indifocuser.h:113
INDI::Focuser::PresetGotoS
ISwitch PresetGotoS[3]
Definition: indifocuser.h:106
INDI::Focuser::Handshake
virtual bool Handshake()
perform handshake with device to check communication
Definition: indifocuser.cpp:236
INDI::Focuser::SyncPresets
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...
Definition: indifocuser.cpp:392
INDI::Focuser::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: indifocuser.cpp:229
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
INDI::Focuser::PortFD
int PortFD
Definition: indifocuser.h:116
indifocuserinterface.h
INDI::Focuser::FocuserConnection
enum INDI::Focuser::@181 FocuserConnection
INDI::Focuser::PresetN
INumber PresetN[3]
Definition: indifocuser.h:104
INDI::Focuser::tcpConnection
Connection::TCP * tcpConnection
Definition: indifocuser.h:114
xml_ele_
Definition: lilxml.c:105
INDI::Focuser::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: indifocuser.cpp:120
defaultdevice.h
INDI::Focuser::CONNECTION_SERIAL
@ CONNECTION_SERIAL
Definition: indifocuser.h:55
INDI::Focuser::SetFocuserMaxPosition
virtual bool SetFocuserMaxPosition(uint32_t ticks) override
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
Definition: indifocuser.cpp:386
INDI::Focuser::CONNECTION_TCP
@ CONNECTION_TCP
Definition: indifocuser.h:56
INDI::Focuser::CONNECTION_NONE
@ CONNECTION_NONE
Definition: indifocuser.h:54
Connection
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition: arduino_st4.h:33
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::Focuser::getSupportedConnections
uint8_t getSupportedConnections() const
Definition: indifocuser.h:77
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::Focuser::setSupportedConnections
void setSupportedConnections(const uint8_t &value)
setConnection Set Focuser connection mode. Child class should call this in the constructor before Foc...
Definition: indifocuser.cpp:373
INDI::Focuser
Definition: indifocuser.h:43
INDI::Focuser::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: indifocuser.cpp:58
INDI::DefaultDevice
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Definition: defaultdevice.h:118
INDI::Focuser::buttonHelper
static void buttonHelper(const char *button_n, ISState state, void *context)
Definition: indifocuser.cpp:253
INDI::Focuser::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: indifocuser.cpp:168
INDI::Focuser::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: indifocuser.cpp:145
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365