API Documentation

Application

This will enable users to connect their application to the PolySync bus data and event notifications.

Usage #include <PolySyncApplication.hpp>

//Example: Subscribe to PolySync node-state events
#include <PolySyncApplication.hpp>
#include <PolySyncDataSubscriber.hpp>

 class EventSubscriber : public polysync::DataSubscriber
 {

 public:

     EventSubscriber ()
     {
         connectSubscriberMethod< EventSubscriber >(
             "ps_application_event_msg",
             &AutonomouSubscriber::handleEvents,
             this );

         polysync::Application::getInstance ()->attachSubscriber( this );

         polysync::Application::getInstance ()->connectPolySync ();
     }


 private:

     void handleEvents( shared_ptr< Message > message )
     {
         if( auto event = getSubclass< ApplicationEventMessage >( message ) )
         {
             if( event->getEventKind () == EventKind::Init )
             {
                 cout << "Init State Event" << endl;
             }
             else if( event->getEventKind () == EventKind::Release )
             {
                 cout << "Release State Event" << endl;
             }
         }
     }
 };

Application

A singleton pattern.

This extends Node and DataInterface. It provides global access to the PolySync bus data and node loop events.

Application::Application ( ) = default

The default empty constructor.

virtual Application::~Application ( )

The destructor with default (empty) implementation.

static Application::getInstance ( )

The standard singleton pattern method allowing access to the Application instance.

Returns

virtual Application::attachSubscriber ( )

This will attach a DataSubsciber object.

Parameters
in/out type name description
in DataSubsciber subscriber Subscriber to detach.
Returns
  • void

virtual Application::attachSubscription ( )

This will enable data flow to a specific DataSubscription method.

Parameters
in/out type name description
in DataSubscription subscription Subscription to attach.
Returns
  • void

virtual Application::detachSubscriber ( )

This will stop data flow to a DataSubsciber object.

Parameters
in/out type name description
in DataSubsciber subsriber Subscriber to detach.
Returns
  • void

virtual Application::detachSubscription ( )

This will stop PolySync data to a specific DataSubscription.

Parameters
in/out type name description
in DataSubscription subscription Subscription to detach.
Returns
  • void

Application::unregisterAllListeners ( )

This will stop this node from receiving PolySync data.

Application::nodeIsConnectedToPolySync ( ) const

This will determine if the application is connected to PolySync.

Returns
  • bool - True once Application::initStateEvent occurs; false if the PolySync node has not initialized

EventKind

Strongly typed enum class type representing PolySync node state.

Parameters
Value Description
SetConfiguration First event to trigger after call to Node::connectPolySync().
Init Called once after PolySync node has initialized (after set configuration event).
Ok Called repeatedly when node is in Ok state.
Warn Called repeatedly when node is in Warn state.
Error Called repeatedly when node is in Error state.
Fatal Called repeatedly when node is in Fatal state.
Release Called once after Node::disconnectPolySync() has been called.

ApplicationEventMessage

This will inherit Message, allowing Application to notify interested DataSubscriber objects of stateful events.

ApplicationEventMessage::ApplicationEventMessage ( … )

The constructor taking EventKind.

Parameters
in/out type name description
in EventKind eventKind Type of PolySync node event, e.g. EventKind::Warn.

ApplicationEventMessage::getEventKind ( )

The accessor for private data.

Returns
  • EventKind - Type of PolySync node event for this object

static ApplicationEventMessage::getName ( )

The accessor for private data. The PolySync string name for this Message.

Returns
  • std::string - “ps_application_event_msg”

DataInterface

The abstract Interface for connecting a data source to data provider.

virtual DataInterface::attachSubscriber ( ) = 0

The classes that inherit from DataInterface are required to override this method.

Parameters
in/out type name description
in DataSubsciber subscriber Subscriber to detach.
Returns
  • void

virtual DataInterface::attachSubscription ( ) = 0

The classes that inherit from DataInterface are required to override this method.

Parameters
in/out type name description
in DataSubscription subscription Subscription to attach.
Returns
  • void

virtual DataInterface::detachSubscriber ( ) = 0

The classes that inherit from DataInterface are required to override this method.

Parameters
in/out type name description
in DataSubsciber Subscriber Subscriber to detach.
Returns
  • void

virtual DataInterface::detachSubscription ( ) = 0

The classes that inherit from DataInterface are required to override this method.

Parameters
in/out type name description
in DataSubscription subscription Subscription to detach.
Returns
  • void

DataSubscriber

This will enable receiving PolySync data and event notification from Application.

virtual DataSubscriber::~DataSubscriber ( )

The destructor.

DataSubscriber::disconnectSubscriberMethod ( )

This will disconnect the PolySync data flow to a member function.

Parameters
in/out type name description
in std::string messageType String representing message type. e.g. “ps_lidar_points_msg.”
Returns
  • void

DataSubscriber::getSubscriptionList ( ) const

The accessor to a private member. This returns a list of DataSubscription objects. It is empty until connectSubscriberMethod has been called.

Returns
  • std::list< std::shared_ptr< polysync::DataSubscription > > - List of DataSubscription objects

DataSubscriber::connectSubscriberMethod ( )

The template method.

This will connect a member function of your DataSubscriber as a DataSubscription to receive PolySync data for a specific message type.

Parameters
in/out type name description
in std::string messageType String representing message type, e.g. “ps_lidar_points_msg.”
in void( T::* )(std::shared_ptr< Message >) functionName Point to member function to connect, e.g. &MySubscriber::handleMessage.
Returns
  • void
//Example:
connectSubscriberMethod< MySubscriber >(
        "ps_lidar_points_msg",
        &MySubscriber::handleLiDARPoints,
        this );
//Example:
Application::getInstance()->attachSubscriber( mySubscriber );

DataSubscription

This class wraps a member function and is called by Application when new data is available for the assigned message type.

DataSubscription::DataSubscription ( )

The constructor. This assigns input function object to private data member.

Parameters
in/out type name description
in const std::function< void( std::shared_ptr< polysync::Message >) message Function object.
Returns
  • void

virtual DataSubscription::~DataSubscription ( )

The destructor.

DataSubscription::operator== ( )

The comparison operator. This will compare message types for subscription.

Returns
  • bool - True for same message type

DataSubscription::handleMessage ( ) const

This will pass input data to the std::function passed to the constructor.

Parameters
in/out type name description
in const std::shared_ptr< polysync::Message > message PolySync message.
Returns
  • void

DataSubscription::getMessageType ( ) const

The accessor to private member data. This will get the message type this subscription receives.

Returns
  • std::string - PolySync message type

DataSubscription::setMessageType ( )

The mutator for private member data. This will set the message type this object receives.

Parameters
in/out type name description
in std::string messageType Message type this object receives.
Returns
  • void

DataSubscription::setSubscriber ( )

The mutator to private member data. This will set the parent DataSubscriber.

Parameters
in/out type name description
in DataSubscriber subscriber The parent subscriber that this method belongs to.
Returns
  • void

DataSubscription::getSubscriber ( ) const

The accessor to private member data. This will get the parent DataSubscriber.

Returns