The Component class is a functional unit in the JAUS architecture which includes single or Multiple services as a collection. More...
#include <component.h>
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. | |
Transport * | TransportService () |
Events * | EventsService () |
Liveness * | LivenessService () |
Discovery * | DiscoveryService () |
AccessControl * | AccessControlService () |
Management * | ManagementService () |
TimeService * | GetTimeService () |
const Transport * | TransportService () const |
const Events * | EventsService () const |
const Liveness * | LivenessService () const |
const Discovery * | DiscoveryService () const |
const AccessControl * | AccessControlService () const |
const Management * | ManagementService () const |
const TimeService * | GetTimeService () 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. | |
Service * | GetService (const std::string &name) |
const Service * | GetService (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. |
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.
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.
AccessControl * Component::AccessControlService | ( | ) |
Definition at line 404 of file component.cpp.
const AccessControl * Component::AccessControlService | ( | ) | const |
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.
[in] | service | The Service to add to the component. This will be deleted when the Component is deleted or goes out of scope. |
Definition at line 573 of file component.cpp.
Discovery * Component::DiscoveryService | ( | ) |
Definition at line 393 of file component.cpp.
const Discovery * Component::DiscoveryService | ( | ) | const |
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.
[in] | name | Service to enable/disable. |
[in] | enable | If true, service is enabled, false to disable. |
Definition at line 549 of file component.cpp.
Events * Component::EventsService | ( | ) |
Definition at line 371 of file component.cpp.
const Events * Component::EventsService | ( | ) | const |
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 ) |
Definition at line 628 of file component.cpp.
const Service * Component::GetService | ( | const std::string & | name ) | const |
Definition at line 653 of file component.cpp.
Service::ID::List Component::GetServiceList | ( | ) | const |
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 |
Definition at line 699 of file component.cpp.
TimeService * Component::GetTimeService | ( | ) |
Definition at line 426 of file component.cpp.
const TimeService * Component::GetTimeService | ( | ) | const |
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.
[in] | id | The Component ID to use. |
[in] | serviceUpdateFrequency | This 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. |
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.
[in] | waitTimeMs | How long to listen for existing components. A Typical value is 2000 ms. |
[in] | serviceUpdateFrequency | This 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. |
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 | ( | ) |
Definition at line 382 of file component.cpp.
const Liveness * Component::LivenessService | ( | ) | const |
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.
[in] | filename | Name of XML file to load settings from. |
Definition at line 268 of file component.cpp.
Management * Component::ManagementService | ( | ) |
Definition at line 415 of file component.cpp.
const Management * Component::ManagementService | ( | ) | const |
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.
[in] | message | JAUS Message to send. |
[in] | broadcastFlags | Values 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. |
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.
[in] | message | JAUS Message to send. |
[out] | response | Pointer to message that is the response to the message sent which will read received data. |
[in] | waitTimeMs | How long to wait in ms for a response to be received. |
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.