Instrument Neutral Distributed Interface INDI  2.0.2
connectioninterface.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2017 Jasem Mutlaq. All rights reserved.
3 
4  Connection Plugin Interface
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 *******************************************************************************/
20 
21 #pragma once
22 
23 #include "indidevapi.h"
24 
25 #include <functional>
26 #include <string>
27 
28 namespace INDI
29 {
30 class DefaultDevice;
31 }
32 
38 namespace Connection
39 {
51 class Interface
52 {
53  public:
58  typedef enum
59  {
60  CONNECTION_NONE = 1 << 0,
61  CONNECTION_SERIAL = 1 << 1,
62  CONNECTION_TCP = 1 << 2,
63  CONNECTION_USB = 1 << 3,
64  CONNECTION_CUSTOM = 1 << 15,
65  } Type;
66 
71  virtual bool Connect() = 0;
72 
77  virtual bool Disconnect() = 0;
78 
83  virtual void Activated() = 0;
84 
89  virtual void Deactivated() = 0;
90 
94  virtual std::string name() = 0;
95 
99  virtual std::string label() = 0;
100 
105  virtual Type type()
106  {
107  return m_Type;
108  }
109 
110  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
111  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n);
112  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n);
113  virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[],
114  char *formats[], char *names[], int n);
115  virtual bool saveConfigItems(FILE *fp);
116 
122  void registerHandshake(std::function<bool()> callback);
123 
124  protected:
126  virtual ~Interface();
127 
128  const char *getDeviceName();
129  std::function<bool()> Handshake;
132 };
133 }
The Interface class is the base class for all INDI connection plugins.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
virtual Type type()
type Return connection type
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
virtual std::string name()=0
Interface(INDI::DefaultDevice *dev, Type type=CONNECTION_NONE)
virtual void Deactivated()=0
Deactivated Function called by the framework when the plugin is deactivated. It is usually used to de...
virtual bool Disconnect()=0
Disconnect Disconnect from device.
void registerHandshake(std::function< bool()> callback)
registerHandshake Register a handshake function to be called once the intial connection to the device...
virtual void Activated()=0
Activated Function called by the framework when the plugin is activated (i.e. selected by the user)....
std::function< bool()> Handshake
INDI::DefaultDevice * m_Device
virtual std::string label()=0
virtual bool Connect()=0
Connect Connect to device via the implemented communication medium. Do not perform any handshakes.
virtual bool saveConfigItems(FILE *fp)
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
ISState
Switch state.
Definition: indiapi.h:150
Interface to the reference INDI C API device implementation on the Device Driver side.
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.
Holds the connection type.