Classes | Public Types | Public Member Functions | Static Public Attributes

JAUS::Discovery Class Reference

The Discovery Service implementation of the Core Service Set library. More...

#include <discovery.h>

Inheritance diagram for JAUS::Discovery:
JAUS::Events::Child JAUS::Service

List of all members.

Classes

class  Callback
 Callback class used to be notified when a Subsystem is discovered, updated, or disconnects from system. More...

Public Types

typedef std::map< UShort,
std::string > 
List
 List of discovered subsystems.

Public Member Functions

 Discovery ()
 Constructor.
 ~Discovery ()
 Destructor.
virtual bool LoadSettings (const std::string &filename)
 Loads UDP configuration values from an XML file. Only loads values if transport has not been initialized.
virtual void Initialize ()
 Called on initialization.
virtual void Shutdown ()
 Shutsdown the service.
virtual bool IsDiscoverable () const
virtual void Receive (const Message *message)
 Processes message received by the Service. If not supported, then message is passed to inheriting services.
virtual MessageCreateMessage (const UShort messageCode) const
 Attempts to create the message desired. Only message supported by this Service can be created by this Service.
virtual void CheckServiceStatus (const unsigned int timeSinceLastCheckMs)
 Method called periodically by external classes and is used to verify subscriptions are still valid.
virtual bool GenerateEvent (const Events::Subscription &info) const
 Generates an event for the given information.
virtual bool IsEventSupported (const Events::Type type, const double requestedPeriodicRate, const Message *queryMessage, double &confirmedPeriodicRate, std::string &errorMessage) const
 Checks if the event is supported by the Service.
void SetComponentIdentification (const std::string &identification)
void SetNodeIdentification (const std::string &identification)
void SetSubsystemIdentification (const Subsystem::Type type, const std::string &identification)
 Sets the identification information for the subsystem. If this data is not set, then Subsystem Discovery won't work correctly.
bool SetDiscoveryFrequency (const double frequencyHz)
 Sets how often the service to send a query to identify new components through the discovery process.
void DiscoverSubsystems (const bool enable=true)
Subsystem::Type GetSubsystemType () const
std::string GetSubsystemIdentification () const
std::string GetNodeIdentification () const
std::string GetComponentIdentification () const
List GetSubsystemList () const
List GetVehicleList () const
Address::List GetComponentsWithService (const std::string &serviceName) const
Subsystem::Ptr GetSubsystem (const UShort id)
 Gets a pointer to the subsystem information if available. This pointer returned is thread safe.
Subsystem::Ptr GetSubsystem (const Address &id)
const Subsystem::Ptr GetSubsystem (const UShort id) const
 Gets a pointer to the subsystem information if available. This pointer returned is thread safe.
const Subsystem::Ptr GetSubsystem (const Address &id) const
Vehicle::Ptr GetVehicle (const UShort id)
 Gets a pointer to the vehicle information if available. This pointer returned is thread safe. Vehicle data is similar to a Subsystem, except it contains additional information such as position and orientation which is set by other services.
Vehicle::Ptr GetVehicle (const Address &id)
const Vehicle::Ptr GetVehicle (const UShort id) const
 Gets a pointer to the vehicle information if available. This pointer returned is thread safe. Vehicle data is similar to a Subsystem, except it contains additional information such as position and orientation which is set by other services.
const Vehicle::Ptr GetVehicle (const Address &id) const
void GetSubsystems (Subsystem::Map &subsystems) const
 Gets a copy of the subsystem data, you must delete this data.
void GetVehicles (Vehicle::Map &vehicles) const
 Gets a copy of the subsystem data, you must delete this data.
void RegisterCallback (Callback *callback, const bool add=true)
 Method to register a callback to receive Discovery Events.
void PrintSystemConfiguration () const
 Prints system information to the console.
virtual void PrintStatus () const
 Prints status info about the Service to the console.
void TriggerDiscoveryCallbacks ()
 Triggers Discovery callbacks. Only use if you are updating subsystem data externally from Discovery service.
void SetSubsystemsToDiscover (const std::set< UShort > &toDiscover)
 By default, all subsystems are discovered. Use this method to filter out to only a specific set of subsystems you are interested in.
std::set< UShortGetSubsystemsToDiscover () const

Static Public Attributes

static const std::string Name = "urn:jaus:jss:core:Discovery"
 String name of the Service.

Detailed Description

The Discovery Service implementation of the Core Service Set library.

The process of discovery is conducted at both the node level and the subsystem level. This service supports the discovery of both legacy components defined the JAUS Reference Architecture 3.2+, and new components. The Component IDs of legacy components were fixed at specification time (Primitive Driver == 33 for example) and could only contain one service beyond the core service support. New components may use any component ID that is not used in the Reference Architecture for legacy component definitions. New components can also contain two or more services beyond the core service support.

Definition at line 75 of file discovery.h.


Member Typedef Documentation

typedef std::map<UShort, std::string> JAUS::Discovery::List

List of discovered subsystems.

Definition at line 94 of file discovery.h.


Constructor & Destructor Documentation

Discovery::Discovery (  )

Constructor.

Definition at line 68 of file discovery.cpp.

Discovery::~Discovery (  )

Destructor.

Definition at line 84 of file discovery.cpp.


Member Function Documentation

void Discovery::CheckServiceStatus ( const unsigned int  timeSinceLastCheckMs ) [virtual]

Method called periodically by external classes and is used to verify subscriptions are still valid.

Parameters:
[in]timeSinceLastCheckMsNumber of milliseconds since the last time this method was called.

Reimplemented from JAUS::Service.

Definition at line 740 of file discovery.cpp.

Message * Discovery::CreateMessage ( const UShort  messageCode ) const [virtual]

Attempts to create the message desired. Only message supported by this Service can be created by this Service.

Parameters:
[in]messageCodeMessage to create.
Returns:
Pointer to newly allocated Message data, NULL if message is not supported by the Service.

Implements JAUS::Service.

Definition at line 691 of file discovery.cpp.

void JAUS::Discovery::DiscoverSubsystems ( const bool  enable = true ) [inline]

Definition at line 129 of file discovery.h.

bool Discovery::GenerateEvent ( const Events::Subscription info ) const [virtual]

Generates an event for the given information.

Parameters:
[in]infoThe event information (ID, Sequence #, etc.) for generation.
Returns:
True if event generated, otherwise false.

Implements JAUS::Events::Child.

Definition at line 883 of file discovery.cpp.

std::string JAUS::Discovery::GetComponentIdentification (  ) const [inline]

Definition at line 137 of file discovery.h.

Address::List Discovery::GetComponentsWithService ( const std::string &  serviceName ) const
Returns:
A list of any components discovered with a given service.

Definition at line 1075 of file discovery.cpp.

std::string JAUS::Discovery::GetNodeIdentification (  ) const [inline]

Definition at line 135 of file discovery.h.

Subsystem::Ptr Discovery::GetSubsystem ( const UShort  id )

Gets a pointer to the subsystem information if available. This pointer returned is thread safe.

Parameters:
[in]idThe subsystem ID number of the subsystem.
Returns:
Thread safe pointer on success, NULL safe pointer if data not present.

Definition at line 1129 of file discovery.cpp.

Subsystem::Ptr JAUS::Discovery::GetSubsystem ( const Address id ) [inline]

Definition at line 147 of file discovery.h.

const Subsystem::Ptr Discovery::GetSubsystem ( const UShort  id ) const

Gets a pointer to the subsystem information if available. This pointer returned is thread safe.

Parameters:
[in]idThe subsystem ID number of the subsystem.
Returns:
Thread safe pointer on success, NULL safe pointer if data not present.

Definition at line 1163 of file discovery.cpp.

const Subsystem::Ptr JAUS::Discovery::GetSubsystem ( const Address id ) const [inline]

Definition at line 151 of file discovery.h.

std::string JAUS::Discovery::GetSubsystemIdentification (  ) const [inline]

Definition at line 133 of file discovery.h.

Discovery::List Discovery::GetSubsystemList (  ) const
Returns:
A map list of all subsystems and their identification names.

Definition at line 1018 of file discovery.cpp.

void Discovery::GetSubsystems ( Subsystem::Map subsystems ) const

Gets a copy of the subsystem data, you must delete this data.

An easy way to delete the data is with the Subsystem::DeleteSubsystemMap method.

Parameters:
[in]subsystemsWhere to save the system configuration to.

Definition at line 1276 of file discovery.cpp.

std::set< UShort > Discovery::GetSubsystemsToDiscover (  ) const
Returns:
List of subsystems being discovered (if emtpy, all are being discovered - default).

Definition at line 1511 of file discovery.cpp.

Subsystem::Type JAUS::Discovery::GetSubsystemType (  ) const [inline]

Definition at line 131 of file discovery.h.

Vehicle::Ptr JAUS::Discovery::GetVehicle ( const Address id ) [inline]

Definition at line 155 of file discovery.h.

const Vehicle::Ptr JAUS::Discovery::GetVehicle ( const Address id ) const [inline]

Definition at line 159 of file discovery.h.

Vehicle::Ptr Discovery::GetVehicle ( const UShort  id )

Gets a pointer to the vehicle information if available. This pointer returned is thread safe. Vehicle data is similar to a Subsystem, except it contains additional information such as position and orientation which is set by other services.

Parameters:
[in]idThe subsystem ID number of the vehicle.
Returns:
Thread safe pointer on success, NULL safe pointer if data not present.

Definition at line 1199 of file discovery.cpp.

const Vehicle::Ptr Discovery::GetVehicle ( const UShort  id ) const

Gets a pointer to the vehicle information if available. This pointer returned is thread safe. Vehicle data is similar to a Subsystem, except it contains additional information such as position and orientation which is set by other services.

Parameters:
[in]idThe subsystem ID number of the vehicle.
Returns:
Thread safe pointer on success, NULL safe pointer if data not present.

Definition at line 1239 of file discovery.cpp.

Discovery::List Discovery::GetVehicleList (  ) const
Returns:
A map list of all vehicles and their identification names.

Definition at line 1045 of file discovery.cpp.

void Discovery::GetVehicles ( Vehicle::Map vehicles ) const

Gets a copy of the subsystem data, you must delete this data.

An easy way to delete the data is with the Subsystem::DeleteSubsystemMap method.

Parameters:
[in]vehiclesWhere to save the system configuration to.

Definition at line 1312 of file discovery.cpp.

void Discovery::Initialize (  ) [virtual]

Called on initialization.

Reimplemented from JAUS::Service.

Definition at line 152 of file discovery.cpp.

virtual bool JAUS::Discovery::IsDiscoverable (  ) const [inline, virtual]

Implements JAUS::Service.

Definition at line 104 of file discovery.h.

bool Discovery::IsEventSupported ( const Events::Type  type,
const double  requestedPeriodicRate,
const Message queryMessage,
double &  confirmedPeriodicRate,
std::string &  errorMessage 
) const [virtual]

Checks if the event is supported by the Service.

Parameters:
[in]typeThe event type (Periodic/EveryChange).
[in]requestedPeriodicRateIf type == Periodic, then this is the desired update rate.
[in]queryMessageThe query message associated with the event.
[out]confirmedPeriodicRateThis is the confirmed periodic rate supported by the Service.
[out]errorMessageIf not supported, this is an optional error message.
Returns:
True if event supported, otherwise false.

Implements JAUS::Events::Child.

Definition at line 953 of file discovery.cpp.

bool Discovery::LoadSettings ( const std::string &  filename ) [virtual]

Loads UDP configuration values from an XML file. Only loads values if transport has not been initialized.

Parameters:
[in]filenameFile containing Service settings data.
Returns:
True on success, false on failure.

Reimplemented from JAUS::Service.

Definition at line 106 of file discovery.cpp.

void Discovery::PrintStatus (  ) const [virtual]

Prints status info about the Service to the console.

Reimplemented from JAUS::Service.

Definition at line 1434 of file discovery.cpp.

void Discovery::PrintSystemConfiguration (  ) const

Prints system information to the console.

Definition at line 1369 of file discovery.cpp.

void Discovery::Receive ( const Message message ) [virtual]

Processes message received by the Service. If not supported, then message is passed to inheriting services.

This Service supports Discovery related messages only.

Parameters:
[in]messageMessage data to process.

Reimplemented from JAUS::Service.

Definition at line 200 of file discovery.cpp.

void Discovery::RegisterCallback ( Callback callback,
const bool  add = true 
)

Method to register a callback to receive Discovery Events.

Discovery events include changes in configuration, identification, etc. to a subsystem.

Parameters:
[in]callbackPointer to callback to add/remove.
[in]addIf true, callback is added, if false, it is removed.

Definition at line 1345 of file discovery.cpp.

void JAUS::Discovery::SetComponentIdentification ( const std::string &  identification ) [inline]

Definition at line 120 of file discovery.h.

bool Discovery::SetDiscoveryFrequency ( const double  frequencyHz )

Sets how often the service to send a query to identify new components through the discovery process.

Parameters:
[in]frequencyHzThe frequency to broadcast a query message in Hz.
Returns:
True on success, false on failure.

Definition at line 1002 of file discovery.cpp.

void JAUS::Discovery::SetNodeIdentification ( const std::string &  identification ) [inline]

Definition at line 122 of file discovery.h.

void Discovery::SetSubsystemIdentification ( const Subsystem::Type  type,
const std::string &  identification 
)

Sets the identification information for the subsystem. If this data is not set, then Subsystem Discovery won't work correctly.

Parameters:
[in]typeType of subsystem.
[in]identificationSubsystem identification string [255 char max].

Definition at line 984 of file discovery.cpp.

void Discovery::SetSubsystemsToDiscover ( const std::set< UShort > &  toDiscover )

By default, all subsystems are discovered. Use this method to filter out to only a specific set of subsystems you are interested in.

Parameters:
[in]toDiscoverSubsystems to discovery.

Definition at line 1498 of file discovery.cpp.

void Discovery::Shutdown (  ) [virtual]

Shutsdown the service.

Reimplemented from JAUS::Service.

Definition at line 181 of file discovery.cpp.

void Discovery::TriggerDiscoveryCallbacks (  )

Triggers Discovery callbacks. Only use if you are updating subsystem data externally from Discovery service.

Definition at line 1451 of file discovery.cpp.


Member Data Documentation

const std::string Discovery::Name = "urn:jaus:jss:core:Discovery" [static]

String name of the Service.

Definition at line 78 of file discovery.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines