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

JAUS::AccessControl Class Reference

This service offers a basic interface for acquiring preemptable exclusive control to one or more related services that utilize this function. More...

#include <accesscontrol.h>

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

List of all members.

Classes

class  Callback
 Callback class used to be notified when AccessControl service loses control of a component or a component releases control of the Service. More...
class  Child
 Class that all direct child Services of AccessControl must inherit from to support state transitions in control and system management. More...

Public Member Functions

 AccessControl ()
 Constructor.
 ~AccessControl ()
 Destructor.
bool AcceptCommandMessage (const Message *commandMessage) const
 Method to check if the message can be processed or not.
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 Shutdown ()
 Shutsdown the service.
bool RequestComponentControl (const Address &id, const bool reacquire=true, const unsigned int waitTimeMs=Service::DefaultWaitMs)
 Method to request exclusive control of a component.
bool ReleaseComponentControl (const Address &id, const unsigned int waitTimeMs=Service::DefaultWaitMs)
 Method to release exclusive control of a component.
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 SetControllable (const bool on=true)
 Method to enable control of the service/component by other components. By default, all components are controllable.
bool IsControllable () const
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.
void SetAuthorityCode (const Byte authorityCode)
 Sets the value of the authority for the component/service. This value determines what components can request control and what components you can take control of.
Byte GetAuthorityCode () const
bool HaveControl (const Address &id) const
 Check if control has been established for a component.
bool IsControlled () const
void SetControllerID (const Address &id)
Address GetControllerID () const
Byte GetControllerAuthorityCode () const
Address::List GetControlledComponents () const
virtual void CheckServiceStatus (const unsigned int timeSinceLastCheckMs)
 Method called periodically by external classes and is used to verify control of components.
Byte GetTimeoutPeriod () const
void SetTimeoutPeriod (const Byte timeSeconds)
 Sets the timeout period for controlling components to lose control of this component. If timeSeconds is greater than 0, then controlling components must continuously re-acquire control within this window or they will lose it due to timeout.
Time::Stamp GetControlCheckPeriod () const
Time GetControllerUpdateTime () const
void RegisterCallback (Callback *callback, const bool add=true)
 Method to register a callback to receive Control Events.
virtual void PrintStatus () const
 Prints status info about the Service to the console.

Static Public Attributes

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

Protected Attributes

bool mControllableFlag
 Is the Service controllable?
Byte mAuthorityCode
 Authority code of the service.
Mutex mControlMutex
 Mutex for thread protection of data.
Address::Set mControlledComponents
 Components being controlled.
Address::Set mToReleaseControl
 Components control is being released for.
std::map< Address, bool > mMaintainFlags
 Flags to indicate control should be re-established.
std::map< Address, bool > mControlFlags
 Flags to indicate which components we have verified control of.
Address mControllerID
 ID of the controlling component.
Byte mControllerAuthorityCode
 Authority code of controlling component.
Time mControllerUpdateTime
 The last time the controller sent a command message.
Time mControllerCheckTime
 The last time the controller updated control.
Byte mTimeoutPeriod
 Timeout period in seconds.
double mTimeoutThreshold
 Threshold for timeout requests/checking (percentage of timeout period).
std::map< Address, BytemTimeoutPeriods
 Timeout periods for controlled components.
std::map< Address, TimemControlCheckTimes
 The last time a control check occurred for controlled components.
std::map< Address, TimemControlConfirmTimes
 The last time when control was confirmed froma controlled component.
Callback::Set mCallbacks
 Callbacks for control events.
Mutex mCallbacksMutex
 Mutex for thread protection of callbacks.

Detailed Description

This service offers a basic interface for acquiring preemptable exclusive control to one or more related services that utilize this function.

Once exclusive control is established, the related services shall only execute commands originating from the controlling component. Service is always granted to components of higher authority that are requesting exclusive control, all other Command messages will be ignored.

Definition at line 72 of file accesscontrol.h.


Constructor & Destructor Documentation

AccessControl::AccessControl (  )

Constructor.

Definition at line 56 of file accesscontrol.cpp.

AccessControl::~AccessControl (  )

Destructor.

Definition at line 72 of file accesscontrol.cpp.


Member Function Documentation

bool AccessControl::AcceptCommandMessage ( const Message commandMessage ) const

Method to check if the message can be processed or not.

Definition at line 82 of file accesscontrol.cpp.

void AccessControl::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 1072 of file accesscontrol.cpp.

Message * AccessControl::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 896 of file accesscontrol.cpp.

bool AccessControl::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 361 of file accesscontrol.cpp.

Byte JAUS::AccessControl::GetAuthorityCode (  ) const [inline]

Definition at line 177 of file accesscontrol.h.

Time::Stamp JAUS::AccessControl::GetControlCheckPeriod (  ) const
Address::List AccessControl::GetControlledComponents (  ) const
Returns:
List of all components currently controlled by the service.

Definition at line 1045 of file accesscontrol.cpp.

Byte AccessControl::GetControllerAuthorityCode (  ) const
Returns:
Authority level of the controlling component.

Definition at line 1033 of file accesscontrol.cpp.

Address AccessControl::GetControllerID (  ) const
Returns:
ID of the controlling component.

Definition at line 1021 of file accesscontrol.cpp.

Time JAUS::AccessControl::GetControllerUpdateTime (  ) const [inline]

Definition at line 199 of file accesscontrol.h.

Byte AccessControl::GetTimeoutPeriod (  ) const
Returns:
Timeout period for this component (seconds).

Definition at line 1208 of file accesscontrol.cpp.

bool AccessControl::HaveControl ( const Address id ) const

Check if control has been established for a component.

Parameters:
[in]idThe ID of the component to check for control of. If a ID of 0.0.0 is passed, then the method will check if we are in control of any components.
Returns:
True if you have control, false otherwise.

Definition at line 970 of file accesscontrol.cpp.

bool JAUS::AccessControl::IsControllable (  ) const [inline]

Definition at line 167 of file accesscontrol.h.

bool AccessControl::IsControlled (  ) const
Returns:
True if the component is controlled, false otherwise.

Definition at line 994 of file accesscontrol.cpp.

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

Implements JAUS::Service.

Definition at line 169 of file accesscontrol.h.

bool AccessControl::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 398 of file accesscontrol.cpp.

bool AccessControl::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 113 of file accesscontrol.cpp.

void AccessControl::PrintStatus (  ) const [virtual]

Prints status info about the Service to the console.

Reimplemented from JAUS::Service.

Definition at line 1250 of file accesscontrol.cpp.

void AccessControl::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 AccessControl related messages only.

Parameters:
[in]messageMessage data to process.

Reimplemented from JAUS::Service.

Definition at line 445 of file accesscontrol.cpp.

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

Method to register a callback to receive Control Events.

Control events include loss of control to a component we had control of or release of control by a controlling component.

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

Definition at line 1226 of file accesscontrol.cpp.

bool AccessControl::ReleaseComponentControl ( const Address id,
const unsigned int  waitTimeMs = Service::DefaultWaitMs 
)

Method to release exclusive control of a component.

Parameters:
[in]idThe ID of the component to request control of. If ID is invalid (all zeros), then control is released to all components.
[in]waitTimeMsHow long to wait for a response in milliseconds from the component being requested.
Returns:
True if control is established, otherwise false.

Definition at line 274 of file accesscontrol.cpp.

bool AccessControl::RequestComponentControl ( const Address id,
const bool  reacquire = true,
const unsigned int  waitTimeMs = Service::DefaultWaitMs 
)

Method to request exclusive control of a component.

Parameters:
[in]idThe ID of the component to request control of.
[in]reacquireIf true, and control is lost for any reason, then we will try to re-acquire control. If false, and control is lost, we forget about the component.
[in]waitTimeMsHow long to wait for a response in milliseconds from the component being requested.
Returns:
True if control is established, otherwise false.

Definition at line 186 of file accesscontrol.cpp.

void AccessControl::SetAuthorityCode ( const Byte  authorityCode )

Sets the value of the authority for the component/service. This value determines what components can request control and what components you can take control of.

Parameters:
[in]authorityCodeAuthority level of the component.

Definition at line 951 of file accesscontrol.cpp.

void AccessControl::SetControllable ( const bool  on = true )

Method to enable control of the service/component by other components. By default, all components are controllable.

Parameters:
[in]onIf true, control is enabled, false it disable.

Definition at line 428 of file accesscontrol.cpp.

void AccessControl::SetControllerID ( const Address id )
Returns:
ID of the controlling component.

Definition at line 1006 of file accesscontrol.cpp.

void AccessControl::SetTimeoutPeriod ( const Byte  timeSeconds )

Sets the timeout period for controlling components to lose control of this component. If timeSeconds is greater than 0, then controlling components must continuously re-acquire control within this window or they will lose it due to timeout.

Parameters:
[in]timeSecondsHow long before timeout occurs in seconds. A value of 0 disables timeout.

Definition at line 1197 of file accesscontrol.cpp.

void AccessControl::Shutdown (  ) [virtual]

Shutsdown the service.

Reimplemented from JAUS::Service.

Definition at line 158 of file accesscontrol.cpp.


Member Data Documentation

Authority code of the service.

Definition at line 206 of file accesscontrol.h.

Callbacks for control events.

Definition at line 221 of file accesscontrol.h.

Mutex for thread protection of callbacks.

Definition at line 222 of file accesscontrol.h.

The last time a control check occurred for controlled components.

Definition at line 219 of file accesscontrol.h.

The last time when control was confirmed froma controlled component.

Definition at line 220 of file accesscontrol.h.

std::map<Address, bool> JAUS::AccessControl::mControlFlags [protected]

Flags to indicate which components we have verified control of.

Definition at line 211 of file accesscontrol.h.

Is the Service controllable?

Definition at line 205 of file accesscontrol.h.

Components being controlled.

Definition at line 208 of file accesscontrol.h.

Authority code of controlling component.

Definition at line 213 of file accesscontrol.h.

The last time the controller updated control.

Definition at line 215 of file accesscontrol.h.

ID of the controlling component.

Definition at line 212 of file accesscontrol.h.

The last time the controller sent a command message.

Definition at line 214 of file accesscontrol.h.

Mutex for thread protection of data.

Definition at line 207 of file accesscontrol.h.

std::map<Address, bool> JAUS::AccessControl::mMaintainFlags [protected]

Flags to indicate control should be re-established.

Definition at line 210 of file accesscontrol.h.

Timeout period in seconds.

Definition at line 216 of file accesscontrol.h.

Timeout periods for controlled components.

Definition at line 218 of file accesscontrol.h.

Threshold for timeout requests/checking (percentage of timeout period).

Definition at line 217 of file accesscontrol.h.

Components control is being released for.

Definition at line 209 of file accesscontrol.h.

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

String name of the Service.

Definition at line 138 of file accesscontrol.h.


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