Instrument Neutral Distributed Interface INDI 2.2.5
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
28namespace INDI
29{
30class DefaultDevice;
31}
32
38namespace Connection
39{
52{
53 public:
58 typedef enum
59 {
60 CONNECTION_NONE = 1 << 0,
62 CONNECTION_TCP = 1 << 2,
63 CONNECTION_USB = 1 << 3,
64 CONNECTION_I2C = 1 << 4,
66 } Type;
67
72 virtual bool Connect() = 0;
73
78 virtual bool Disconnect() = 0;
79
84 virtual void Activated() = 0;
85
90 virtual void Deactivated() = 0;
91
95 virtual std::string name() = 0;
96
100 virtual std::string label() = 0;
101
106 virtual Type type()
107 {
108 return m_Type;
109 }
110
111 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
112 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n);
113 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n);
114 virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[],
115 char *formats[], char *names[], int n);
116 virtual bool saveConfigItems(FILE *fp);
117
123 void registerHandshake(std::function<bool()> callback);
124
125 protected:
127 virtual ~Interface();
128
129 const char *getDeviceName();
130 std::function<bool()> Handshake;
133};
134}
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
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 initial connection to the devic...
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:148
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.