Classes | Public Member Functions | Static Public Attributes | Protected Attributes

JAUS::Management Class Reference

The Management Service provides a state machine for the component life-cycle maangement to help clients understand how the component will react to commands and queries. More...

#include <management.h>

Inheritance diagram for JAUS::Management:
JAUS::AccessControl::Child JAUS::Events::Child JAUS::Service

List of all members.

Classes

class  Child
 Class that all direct child Services of Management must inherit from to support state transitions. More...
class  Status
 Namespace for different states the Services can be in. More...

Public Member Functions

 Management ()
 Constructor.
 ~Management ()
 Destructor.
virtual bool Resume (const Address &id, const unsigned int waitTimeMs=Service::DefaultWaitMs)
 Sends a Resume command and then if desired confirms the state transition by sending a Query Status message.
virtual bool Standby (const Address &id, const unsigned int waitTimeMs=0)
 Sends a Standby command and then if desired confirms the state transition by sending a Query Status message.
virtual bool SetEmergency (const Address &id, const unsigned int waitTimeMs=Service::DefaultWaitMs)
 Sends a Set Emergency command and then if desired confirms the state transition by sending a Query Status message.
virtual bool ClearEmergency (const Address &id, const unsigned int waitTimeMs=Service::DefaultWaitMs)
 Sends a Clear Emergency command and then if desired confirms the state transition by sending a Query Status message.
virtual bool Shutdown (const Address &id)
 Sends a Shutdown command to a component.
virtual void Initialize ()
 Initializes the service.
virtual void Shutdown ()
 Shutsdown the service.
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.
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 depending on what type of control has been established for the component.
virtual MessageCreateMessage (const UShort messageCode) const
 Attempts to create the message desired. Only message supported by this Service can be created by this Service.
bool SetStatus (const Byte state)
 Sets the status of the Service.
Byte GetStatus () const
int GetComponentStatus (const Address &id, const unsigned int waitTimeMs=Service::DefaultWaitMs) const
 Gets the status of a component.
virtual bool RequestControl ()
 This method is called whenever control of the parent component for your services has been requested.
virtual bool ReleaseControl ()
 Whenever control is released, revert back to a Standby state because we cannot be in Ready state.
virtual void PrintStatus () const
 Prints status info about the Service to the console.
virtual void PrintStatus (const bool allData) const
 Prints status info about the Service to the console.
void CheckServiceStatus (const unsigned int timeSinceLastCheckMs)
 Method called periodically by external classes and is used to verify control of components.

Static Public Attributes

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

Protected Attributes

Time::Stamp mCheckStatusTimeMs
 The last time status was checked for subsystem.
volatile Byte mStatus
 Status of the service (what state are we in).
Mutex mStatesMutex
 Mutex for states information.
std::map< Address, int > mSubsystemStates
 States/Status of components for this subsystem.

Detailed Description

The Management Service provides a state machine for the component life-cycle maangement to help clients understand how the component will react to commands and queries.

This implementation controls that status of the Component (e.g. ready, standby) and has method to change the state of components.

Definition at line 66 of file management.h.


Constructor & Destructor Documentation

Management::Management (  )

Constructor.

Definition at line 140 of file management.cpp.

Management::~Management (  )

Destructor.

Definition at line 152 of file management.cpp.


Member Function Documentation

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

Method called periodically by external classes and is used to verify control of components.

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

Reimplemented from JAUS::Service.

Definition at line 921 of file management.cpp.

bool Management::ClearEmergency ( const Address id,
const unsigned int  waitTimeMs = Service::DefaultWaitMs 
) [virtual]

Sends a Clear Emergency command and then if desired confirms the state transition by sending a Query Status message.

Parameters:
[in]idID of the component to send command to.
[in]waitTimeMsIf greater than 0, how long to wait for a Report Status response to confirm state transition. If value is 0, then no confirmation is made.
Returns:
True on success, false on failure. If waitTimeMs is 0, a return of true does not gaurantee the component transition states.

Definition at line 323 of file management.cpp.

Message * Management::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 646 of file management.cpp.

bool Management::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 414 of file management.cpp.

int Management::GetComponentStatus ( const Address id,
const unsigned int  waitTimeMs = Service::DefaultWaitMs 
) const

Gets the status of a component.

If the component is part of the same subsystem, then waitTimeMs is usually ignored because in JAUS++ the Management Service automatically keeps track of the state of other components on the same subsystem. Only if the state hasn't been found yet is a message sent to componentID.

Parameters:
[in]idID of the component to get status of.
[in]waitTimeMsHow long to wait for response from component.
Returns:
Status of component (e.g. Status::Initialized, Status::Ready). A value of -1 is returned if unable to retrieve status value.

Definition at line 776 of file management.cpp.

Byte JAUS::Management::GetStatus (  ) const [inline]

Definition at line 166 of file management.h.

void Management::Initialize (  ) [virtual]

Initializes the service.

Reimplemented from JAUS::Service.

Definition at line 387 of file management.cpp.

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

Implements JAUS::Service.

Definition at line 158 of file management.h.

bool Management::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 442 of file management.cpp.

void Management::PrintStatus (  ) const [virtual]

Prints status info about the Service to the console.

Reimplemented from JAUS::Service.

Definition at line 816 of file management.cpp.

void Management::PrintStatus ( const bool  allData ) const [virtual]

Prints status info about the Service to the console.

Parameters:
[in]allDataIf true, state information for all components on this subsystem are displayed also.

Definition at line 851 of file management.cpp.

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

Processes message received by the Service. If not supported, then message is passed to inheriting services depending on what type of control has been established for the component.

This Service supports Management related messages only.

Parameters:
[in]messageMessage data to process.

Reimplemented from JAUS::Service.

Definition at line 474 of file management.cpp.

bool Management::ReleaseControl (  ) [virtual]

Whenever control is released, revert back to a Standby state because we cannot be in Ready state.

Reimplemented from JAUS::AccessControl::Child.

Definition at line 754 of file management.cpp.

virtual bool JAUS::Management::RequestControl (  ) [inline, virtual]

This method is called whenever control of the parent component for your services has been requested.

Reimplemented from JAUS::AccessControl::Child.

Definition at line 170 of file management.h.

bool Management::Resume ( const Address id,
const unsigned int  waitTimeMs = Service::DefaultWaitMs 
) [virtual]

Sends a Resume command and then if desired confirms the state transition by sending a Query Status message.

Parameters:
[in]idID of the component to send command to.
[in]waitTimeMsIf greater than 0, how long to wait for a Report Status response to confirm state transition. If value is 0, then no confirmation is made.
Returns:
True on success, false on failure. If waitTimeMs is 0, a return of true does not gaurantee the component transition states.

Definition at line 171 of file management.cpp.

bool Management::SetEmergency ( const Address id,
const unsigned int  waitTimeMs = Service::DefaultWaitMs 
) [virtual]

Sends a Set Emergency command and then if desired confirms the state transition by sending a Query Status message.

Parameters:
[in]idID of the component to send command to.
[in]waitTimeMsIf greater than 0, how long to wait for a Report Status response to confirm state transition. If value is 0, then no confirmation is made.
Returns:
True on success, false on failure. If waitTimeMs is 0, a return of true does not gaurantee the component transition states.

Definition at line 284 of file management.cpp.

bool Management::SetStatus ( const Byte  state )

Sets the status of the Service.

Parameters:
[in]stateDesired state.
Returns:
True on success, false on failure.

Definition at line 692 of file management.cpp.

void Management::Shutdown (  ) [virtual]

Shutsdown the service.

Reimplemented from JAUS::Service.

Definition at line 399 of file management.cpp.

bool Management::Shutdown ( const Address id ) [virtual]

Sends a Shutdown command to a component.

Parameters:
[in]idID of the component to send command to.If ID is invalid (i.e. 0.0.0), then all components we have control of are sent the command.
Returns:
True if message sent, false on failure.

Definition at line 359 of file management.cpp.

bool Management::Standby ( const Address id,
const unsigned int  waitTimeMs = 0 
) [virtual]

Sends a Standby command and then if desired confirms the state transition by sending a Query Status message.

Parameters:
[in]idID of the component to send command to. If ID is invalid (i.e. 0.0.0), then all components we have control of are sent the command.
[in]waitTimeMsIf greater than 0, how long to wait for a Report Status response to confirm state transition. If value is 0, then no confirmation of state change is made (default).
Returns:
True on success, false on failure. If waitTimeMs is 0, a return of true does not gaurantee the component transition states. If id is (0.0.0), True is only returned if standby command is successfully sent to all controlled components.

Definition at line 226 of file management.cpp.


Member Data Documentation

The last time status was checked for subsystem.

Definition at line 180 of file management.h.

Mutex for states information.

Definition at line 182 of file management.h.

volatile Byte JAUS::Management::mStatus [protected]

Status of the service (what state are we in).

Definition at line 181 of file management.h.

std::map<Address, int> JAUS::Management::mSubsystemStates [protected]

States/Status of components for this subsystem.

Definition at line 183 of file management.h.

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

String name of the Service.

Definition at line 126 of file management.h.


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