Instrument Neutral Distributed Interface INDI  1.9.2
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Connection::Interface Class Referenceabstract

The Interface class is the base class for all INDI connection plugins. More...

#include <connectioninterface.h>

Inheritance diagram for Connection::Interface:
Connection::Serial Connection::TCP

Public Types

enum  Type {
  CONNECTION_NONE = 1 << 0, CONNECTION_SERIAL = 1 << 1, CONNECTION_TCP = 1 << 2, CONNECTION_USB = 1 << 3,
  CONNECTION_CUSTOM = 1 << 15
}
 

Public Member Functions

virtual bool Connect ()=0
 Connect Connect to device via the implemented communication medium. Do not perform any handshakes. More...
 
virtual bool Disconnect ()=0
 Disconnect Disconnect from device. More...
 
virtual void Activated ()=0
 Activated Function called by the framework when the plugin is activated (i.e. selected by the user). It is usually used to define properties pertaining to the specific plugin functionalities. More...
 
virtual void Deactivated ()=0
 Deactivated Function called by the framework when the plugin is deactivated. It is usually used to delete properties by were defined previously since the plugin is no longer active. More...
 
virtual std::string name ()=0
 
virtual std::string label ()=0
 
virtual Type type ()
 type Return connection type More...
 
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 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 bool saveConfigItems (FILE *fp)
 
void registerHandshake (std::function< bool()> callback)
 registerHandshake Register a handshake function to be called once the intial connection to the device is established. More...
 

Protected Member Functions

 Interface (INDI::DefaultDevice *dev, Type type=CONNECTION_NONE)
 
virtual ~Interface ()
 
const char * getDeviceName ()
 

Protected Attributes

std::function< bool()> Handshake
 
INDI::DefaultDevicem_Device { nullptr }
 
Type m_Type { CONNECTION_NONE }
 

Detailed Description

The Interface class is the base class for all INDI connection plugins.

Each plugin implements the connection details specific to a particular medium (e.g. serial). After the connection to the medium is successful, a handshake is initialted to make sure the device is online and responding to commands. The child class employing the plugin must register the handshake to perform the actual low-level communication with the device.

See also
Connection::Serial
Connection::TCP
INDI::Telescope utilizes both serial and tcp plugins to communicate with mounts.

Definition at line 51 of file connectioninterface.h.

Member Enumeration Documentation

◆ Type

Enumerator
CONNECTION_NONE 
CONNECTION_SERIAL 

Do not use any connection plugin

CONNECTION_TCP 

For regular serial and bluetooth connections

CONNECTION_USB 

For Wired and WiFI connections

CONNECTION_CUSTOM 

For USB-based connections

Definition at line 58 of file connectioninterface.h.

Constructor & Destructor Documentation

◆ Interface()

Connection::Interface::Interface ( INDI::DefaultDevice dev,
Type  type = CONNECTION_NONE 
)
protected

Definition at line 43 of file connectioninterface.cpp.

◆ ~Interface()

Connection::Interface::~Interface ( )
protectedvirtual

Definition at line 49 of file connectioninterface.cpp.

Member Function Documentation

◆ Activated()

virtual void Connection::Interface::Activated ( )
pure virtual

Activated Function called by the framework when the plugin is activated (i.e. selected by the user). It is usually used to define properties pertaining to the specific plugin functionalities.

Implemented in Connection::Serial, and Connection::TCP.

◆ Connect()

virtual bool Connection::Interface::Connect ( )
pure virtual

Connect Connect to device via the implemented communication medium. Do not perform any handshakes.

Returns
True if successful, false otherwise.

Implemented in Connection::Serial, and Connection::TCP.

◆ Deactivated()

virtual void Connection::Interface::Deactivated ( )
pure virtual

Deactivated Function called by the framework when the plugin is deactivated. It is usually used to delete properties by were defined previously since the plugin is no longer active.

Implemented in Connection::Serial, and Connection::TCP.

◆ Disconnect()

virtual bool Connection::Interface::Disconnect ( )
pure virtual

Disconnect Disconnect from device.

Returns
True if successful, false otherwise.

Implemented in Connection::Serial, and Connection::TCP.

◆ getDeviceName()

const char * Connection::Interface::getDeviceName ( )
protected

Definition at line 53 of file connectioninterface.cpp.

◆ ISNewBLOB()

bool Connection::Interface::ISNewBLOB ( const char *  dev,
const char *  name,
int  sizes[],
int  blobsizes[],
char *  blobs[],
char *  formats[],
char *  names[],
int  n 
)
virtual

Definition at line 88 of file connectioninterface.cpp.

◆ ISNewNumber()

bool Connection::Interface::ISNewNumber ( const char *  dev,
const char *  name,
double  values[],
char *  names[],
int  n 
)
virtual

Definition at line 68 of file connectioninterface.cpp.

◆ ISNewSwitch()

bool Connection::Interface::ISNewSwitch ( const char *  dev,
const char *  name,
ISState states,
char *  names[],
int  n 
)
virtual

Reimplemented in Connection::Serial, and Connection::TCP.

Definition at line 58 of file connectioninterface.cpp.

◆ ISNewText()

bool Connection::Interface::ISNewText ( const char *  dev,
const char *  name,
char *  texts[],
char *  names[],
int  n 
)
virtual

Reimplemented in Connection::Serial, and Connection::TCP.

Definition at line 78 of file connectioninterface.cpp.

◆ label()

virtual std::string Connection::Interface::label ( )
pure virtual
Returns
Plugin friendly label presented to the client/user.

Implemented in Connection::Serial, and Connection::TCP.

◆ name()

virtual std::string Connection::Interface::name ( )
pure virtual
Returns
Plugin name

Implemented in Connection::Serial, and Connection::TCP.

◆ registerHandshake()

void Connection::Interface::registerHandshake ( std::function< bool()>  callback)

registerHandshake Register a handshake function to be called once the intial connection to the device is established.

Parameters
callbackHandshake function callback
See also
INDI::Telescope

Definition at line 108 of file connectioninterface.cpp.

◆ saveConfigItems()

bool Connection::Interface::saveConfigItems ( FILE *  fp)
virtual

Reimplemented in Connection::Serial, and Connection::TCP.

Definition at line 102 of file connectioninterface.cpp.

◆ type()

virtual Type Connection::Interface::type ( )
inlinevirtual

type Return connection type

Returns
connection type

Definition at line 105 of file connectioninterface.h.

Member Data Documentation

◆ Handshake

std::function<bool()> Connection::Interface::Handshake
protected

Definition at line 129 of file connectioninterface.h.

◆ m_Device

INDI::DefaultDevice* Connection::Interface::m_Device { nullptr }
protected

Definition at line 130 of file connectioninterface.h.

◆ m_Type

Type Connection::Interface::m_Type { CONNECTION_NONE }
protected

Definition at line 131 of file connectioninterface.h.


The documentation for this class was generated from the following files: