Instrument Neutral Distributed Interface INDI  1.9.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 }
Connection::Interface::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Definition: connectioninterface.cpp:68
Connection::Interface::ISNewText
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Definition: connectioninterface.cpp:78
Connection::Interface::Handshake
std::function< bool()> Handshake
Definition: connectioninterface.h:129
Connection::Interface::label
virtual std::string label()=0
Connection::Interface::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Definition: connectioninterface.cpp:58
Connection::Interface::Disconnect
virtual bool Disconnect()=0
Disconnect Disconnect from device.
Connection::Interface::CONNECTION_CUSTOM
@ CONNECTION_CUSTOM
Definition: connectioninterface.h:64
Connection::Interface::Type
Type
Definition: connectioninterface.h:58
Connection::Interface::m_Type
Type m_Type
Definition: connectioninterface.h:131
Connection::Interface::getDeviceName
const char * getDeviceName()
Definition: connectioninterface.cpp:53
Connection::Interface::ISNewBLOB
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
Definition: connectioninterface.cpp:88
indidevapi.h
Interface to the reference INDI C API device implementation on the Device Driver side.
Connection::Interface::type
virtual Type type()
type Return connection type
Definition: connectioninterface.h:105
Connection::Interface::m_Device
INDI::DefaultDevice * m_Device
Definition: connectioninterface.h:130
Connection::Interface::name
virtual std::string name()=0
Connection::Interface::Activated
virtual void Activated()=0
Activated Function called by the framework when the plugin is activated (i.e. selected by the user)....
Connection::Interface::Interface
Interface(INDI::DefaultDevice *dev, Type type=CONNECTION_NONE)
Definition: connectioninterface.cpp:43
Connection::Interface::saveConfigItems
virtual bool saveConfigItems(FILE *fp)
Definition: connectioninterface.cpp:102
Connection::Interface::Deactivated
virtual void Deactivated()=0
Deactivated Function called by the framework when the plugin is deactivated. It is usually used to de...
Connection::Interface::Connect
virtual bool Connect()=0
Connect Connect to device via the implemented communication medium. Do not perform any handshakes.
Type
The Interface class is the base class for the DSP plugins of INDI.
Connection
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition: arduino_st4.h:33
Connection::Interface::~Interface
virtual ~Interface()
Definition: connectioninterface.cpp:49
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
Connection::Interface::registerHandshake
void registerHandshake(std::function< bool()> callback)
registerHandshake Register a handshake function to be called once the intial connection to the device...
Definition: connectioninterface.cpp:108
Connection::Interface::CONNECTION_USB
@ CONNECTION_USB
Definition: connectioninterface.h:63
Connection::Interface::CONNECTION_NONE
@ CONNECTION_NONE
Definition: connectioninterface.h:60
ISState
ISState
Switch state.
Definition: indiapi.h:148
Connection::Interface
The Interface class is the base class for all INDI connection plugins.
Definition: connectioninterface.h:51
Connection::Interface::CONNECTION_SERIAL
@ CONNECTION_SERIAL
Definition: connectioninterface.h:61
INDI::DefaultDevice
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Definition: defaultdevice.h:118
Connection::Interface::CONNECTION_TCP
@ CONNECTION_TCP
Definition: connectioninterface.h:62