Public Member Functions

JAUS::Component Class Reference

The Component class is a functional unit in the JAUS architecture which includes single or Multiple services as a collection. More...

#include <component.h>

List of all members.

Public Member Functions

 Component ()
 Constructor, initializes the default services supported by the Component.
virtual ~Component ()
 Destructor.
virtual bool Initialize (const Address &id, const double serviceUpdateFrequency=10.0)
 Initializes the Component and all its' Services with a given Component ID.
virtual bool InitializeWithUniqueID (const unsigned int waitTimeMs=3000, const double serviceUpdateFrequency=10.0)
 Initializes the Component and all its' Services by trying to discover an ID that is not currently in use on the network or host machine.
bool IsInitialized () const
bool LoadSettings (const std::string &filename)
 Method calls the LoadSettings method of each service with the given filename containing XML data.
void Shutdown ()
 Turns off all services and ends initialization. This method does not delete any memory or services.
TransportTransportService ()
EventsEventsService ()
LivenessLivenessService ()
DiscoveryDiscoveryService ()
AccessControlAccessControlService ()
ManagementManagementService ()
TimeServiceGetTimeService ()
const TransportTransportService () const
const EventsEventsService () const
const LivenessLivenessService () const
const DiscoveryDiscoveryService () const
const AccessControlAccessControlService () const
const ManagementManagementService () const
const TimeServiceGetTimeService () const
bool Send (const Message *message, const int broadcastFlags=Service::NoBroadcast) const
 Sends a JAUS message.
bool Send (const Message *message, Message *response, const unsigned int waitTimeMs=Service::DefaultWaitMs) const
 Sends a JAUS message, and blocks until a response is received.
bool EnableService (const std::string &name, const bool enable=true)
 Method to enable/disable a service. Disabling a parent service disables all Services which inherit from it.
bool AddService (Service *service)
 Adds a new Service to the Component. This method can only be called before the Initialize method is called.
ServiceGetService (const std::string &name)
const ServiceGetService (const std::string &name) const
Service::Map GetServices ()
Service::ID::List GetServiceList () const
Service::ID::Set GetServiceSet () const
Address GetComponentID () const
virtual void PrintStatus () const
 Prints component status information for services to console.

Detailed Description

The Component class is a functional unit in the JAUS architecture which includes single or Multiple services as a collection.

All Services are owned by a component, which defines the ID used for communications by the Transport Service. By default, a Component supports the entire Core service set defined by AS5710 standard. It is up to the developer to disable any of the Core Services they do not wish to use. See the example_component.cpp program for basic usage of this class.

New Services are added using the AddService method, however this must be done before a Component is initialized using the Initialize method. It is best practice to add new Services before any other operations are called on the Component class, that way proper settings and initialization procedures can take place.

By default, all Components use the JUDP Transport Service. However, this can be changed by adding a new Transport Service using the AddService method before Initialize is called.

Once added, a Service cannot be removed from a Component, however it can be disabled using the EnableService method.

Definition at line 81 of file component.h.


Constructor & Destructor Documentation

Component::Component (  )

Constructor, initializes the default services supported by the Component.

Definition at line 57 of file component.cpp.

Component::~Component (  ) [virtual]

Destructor.

Definition at line 88 of file component.cpp.


Member Function Documentation

AccessControl * Component::AccessControlService (  )
Returns:
Pointer to the Discovery service.

Definition at line 404 of file component.cpp.

const AccessControl * Component::AccessControlService (  ) const
Returns:
Pointer to the Discovery service.

Definition at line 470 of file component.cpp.

bool Component::AddService ( Service service )

Adds a new Service to the Component. This method can only be called before the Initialize method is called.

Parameters:
[in]serviceThe Service to add to the component. This will be deleted when the Component is deleted or goes out of scope.
Returns:
True on success, false on failure.

Definition at line 573 of file component.cpp.

Discovery * Component::DiscoveryService (  )
Returns:
Pointer to the Discovery service.

Definition at line 393 of file component.cpp.

const Discovery * Component::DiscoveryService (  ) const
Returns:
Pointer to the Discovery service.

Definition at line 459 of file component.cpp.

bool Component::EnableService ( const std::string &  name,
const bool  enable = true 
)

Method to enable/disable a service. Disabling a parent service disables all Services which inherit from it.

Parameters:
[in]nameService to enable/disable.
[in]enableIf true, service is enabled, false to disable.
Returns:
True on success, false on failure.

Definition at line 549 of file component.cpp.

Events * Component::EventsService (  )
Returns:
Pointer to the Events service.

Definition at line 371 of file component.cpp.

const Events * Component::EventsService (  ) const
Returns:
Pointer to the Events service.

Definition at line 437 of file component.cpp.

Address JAUS::Component::GetComponentID (  ) const [inline]

Definition at line 149 of file component.h.

Service * Component::GetService ( const std::string &  name )
Returns:
Pointer to Service, NULL if Service not part of Component.

Definition at line 628 of file component.cpp.

const Service * Component::GetService ( const std::string &  name ) const
Returns:
Pointer to Service, NULL if Service not part of Component.

Definition at line 653 of file component.cpp.

Service::ID::List Component::GetServiceList (  ) const
Returns:
List of all Enabled services on Component.

Definition at line 678 of file component.cpp.

Service::Map JAUS::Component::GetServices (  ) [inline]

Definition at line 143 of file component.h.

Service::ID::Set Component::GetServiceSet (  ) const
Returns:
Set of all Enabled services on Component.

Definition at line 699 of file component.cpp.

TimeService * Component::GetTimeService (  )
Returns:
Pointer to the Discovery service.

Definition at line 426 of file component.cpp.

const TimeService * Component::GetTimeService (  ) const
Returns:
Pointer to the Discovery service.

Definition at line 492 of file component.cpp.

bool Component::Initialize ( const Address id,
const double  serviceUpdateFrequency = 10.0 
) [virtual]

Initializes the Component and all its' Services with a given Component ID.

Once initialized, all components can create a periodic event which will call the CheckServiceStatus method of each Service. This is designed in the Component interface so developers do not need to create their own threads within there Services for performing status checks at low frequency intervals. Status checks include verifying event subscriptions or control status.

Parameters:
[in]idThe Component ID to use.
[in]serviceUpdateFrequencyThis is the frequency (Hz) to call the CheckServiceStatus method on each Service. This is useful if any Service needs to verify connections or check what state it is in periodically. This value will depend on the types of Service your Component includes and defaults to 10Hz. If value is less than 0, no periodic checking happens.
Returns:
True on success, false on failure.

Definition at line 147 of file component.cpp.

bool Component::InitializeWithUniqueID ( const unsigned int  waitTimeMs = 3000,
const double  serviceUpdateFrequency = 10.0 
) [virtual]

Initializes the Component and all its' Services by trying to discover an ID that is not currently in use on the network or host machine.

This method uses the last octect of the IP address of the host machine as a method for ID generation. For example: If the IP address of the host PC is 10.171.191.55, then the subsystem number chosen will be 55 + 10,000 = 10,055. If this ID is reserved on the host machine already, then the component ID of the JAUS ID will be incremented until an available ID is found.

Parameters:
[in]waitTimeMsHow long to listen for existing components. A Typical value is 2000 ms.
[in]serviceUpdateFrequencyThis is the frequency (Hz) to call the CheckServiceStatus method on each Service. This is useful if any Service needs to verify connections or check what state it is in periodically. This value will depend on the types of Service your Component includes and defaults to 10Hz. If value is less than 0, no periodic checking happens.
Returns:
True on success, false on failure.

Definition at line 223 of file component.cpp.

bool JAUS::Component::IsInitialized (  ) const [inline]

Definition at line 95 of file component.h.

Liveness * Component::LivenessService (  )
Returns:
Pointer to the Liveness service.

Definition at line 382 of file component.cpp.

const Liveness * Component::LivenessService (  ) const
Returns:
Pointer to the Liveness service.

Definition at line 448 of file component.cpp.

bool Component::LoadSettings ( const std::string &  filename )

Method calls the LoadSettings method of each service with the given filename containing XML data.

Make sure you have added all Services to the component before calling this method.

Parameters:
[in]filenameName of XML file to load settings from.
Returns:
True if all Services loaded successfully, otherwise false on error.

Definition at line 268 of file component.cpp.

Management * Component::ManagementService (  )
Returns:
Pointer to the Discovery service.

Definition at line 415 of file component.cpp.

const Management * Component::ManagementService (  ) const
Returns:
Pointer to the Discovery service.

Definition at line 481 of file component.cpp.

void Component::PrintStatus (  ) const [virtual]

Prints component status information for services to console.

Definition at line 784 of file component.cpp.

bool Component::Send ( const Message message,
const int  broadcastFlags = Service::NoBroadcast 
) const

Sends a JAUS message.

Parameters:
[in]messageJAUS Message to send.
[in]broadcastFlagsValues to use to signify if message should be sent using any broadcast options (e.g. multicast). 0 = no options, 1 = local broadcast, 2 = global broadcast.
Returns:
True on success, false on failure.

Definition at line 511 of file component.cpp.

bool Component::Send ( const Message message,
Message response,
const unsigned int  waitTimeMs = Service::DefaultWaitMs 
) const

Sends a JAUS message, and blocks until a response is received.

Parameters:
[in]messageJAUS Message to send.
[out]responsePointer to message that is the response to the message sent which will read received data.
[in]waitTimeMsHow long to wait in ms for a response to be received.
Returns:
True on success, false on failure.

Definition at line 530 of file component.cpp.

void Component::Shutdown (  )

Turns off all services and ends initialization. This method does not delete any memory or services.

Definition at line 335 of file component.cpp.

Transport* JAUS::Component::TransportService (  ) [inline]

Definition at line 101 of file component.h.

const Transport* JAUS::Component::TransportService (  ) const [inline]

Definition at line 115 of file component.h.


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