BAOS SDK  18.2.0
Public Types | Public Member Functions | List of all members
kdrive::baos::BaosEvent Class Reference

BaosEvent connects to the rx packet signals from the BaosConnector and filters the received packets to forward the datapoint value indications and the datapoint get value responses to a single handler. More...

#include <BaosEvent.h>

Public Types

typedef std::function< void(BaosDatapoint &)> DatapointEvent
 Callback function called when a datapoint value is changed. More...
 
typedef std::function< void(unsigned short, const std::vector< unsigned char > &)> ServerItemEvent
 Callback function called when a server value indication is received. More...
 
typedef std::function< void(bool)> BusConnectedEvent
 Callback function called when a server value indication is received to indicate whether the bus is connected or not. More...
 
typedef std::function< void()> ConnectorClosedEvent
 Callback function called when the connector is disconnected. More...
 

Public Member Functions

 BaosEvent ()
 Creates a default BaosEvent It is disabled by default and must be enabled once the connector is set. More...
 
 BaosEvent (std::shared_ptr< BaosConnector > connector, bool enabled=true)
 Creates a BaosEvent class associated with a connection. More...
 
 ~BaosEvent ()
 Destroys the BaosEvent. More...
 
void setDatapointEvent (DatapointEvent datapointEvent)
 
void setServerItemEvent (ServerItemEvent serverItemEvent)
 
void setBusConnectedEvent (BusConnectedEvent busConnectedEvent)
 
void setConnectorClosedEvent (ConnectorClosedEvent connectorClosedEvent)
 
void setConnector (std::shared_ptr< BaosConnector > connector, bool enabled=true)
 Sets the baos connector. More...
 
void enable (bool enabled=true)
 Enable/disable the events. More...
 
void disable ()
 Disable the events. More...
 
bool isEnabled () const
 

Detailed Description

BaosEvent connects to the rx packet signals from the BaosConnector and filters the received packets to forward the datapoint value indications and the datapoint get value responses to a single handler.

This has the advantage that you can handle the asynchronous events from the bus as well as the responses to a read request (for example at application startup) with the same code handler.

Examples:
BaosEventListener.cpp, and BaosMultiConnector.cpp.

Member Typedef Documentation

typedef std::function<void (bool)> kdrive::baos::BaosEvent::BusConnectedEvent

Callback function called when a server value indication is received to indicate whether the bus is connected or not.

typedef std::function<void ()> kdrive::baos::BaosEvent::ConnectorClosedEvent

Callback function called when the connector is disconnected.

Callback function called when a datapoint value is changed.

This can be either via a DatapointIndication or one of the services, such as DatapointValueSet.

typedef std::function<void(unsigned short, const std::vector<unsigned char>&)> kdrive::baos::BaosEvent::ServerItemEvent

Callback function called when a server value indication is received.

Constructor & Destructor Documentation

BaosEvent::BaosEvent ( )

Creates a default BaosEvent It is disabled by default and must be enabled once the connector is set.

kdrive::baos::BaosEvent::BaosEvent ( std::shared_ptr< BaosConnector connector,
bool  enabled = true 
)

Creates a BaosEvent class associated with a connection.

BaosEvent::~BaosEvent ( )

Destroys the BaosEvent.

The connector will be released.

Member Function Documentation

void BaosEvent::disable ( )

Disable the events.

void BaosEvent::enable ( bool  enabled = true)

Enable/disable the events.

bool BaosEvent::isEnabled ( ) const
Returns
true if enabled, false otherwise
void BaosEvent::setBusConnectedEvent ( BusConnectedEvent  busConnectedEvent)
void BaosEvent::setConnector ( std::shared_ptr< BaosConnector connector,
bool  enabled = true 
)

Sets the baos connector.

If a connector has already been set we disconnect from its signals

Examples:
BaosEventListener.cpp.
void BaosEvent::setConnectorClosedEvent ( ConnectorClosedEvent  connectorClosedEvent)
void BaosEvent::setDatapointEvent ( DatapointEvent  datapointEvent)
void BaosEvent::setServerItemEvent ( ServerItemEvent  serverItemEvent)

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