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>
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 Message * | CreateMessage (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, Byte > | mTimeoutPeriods |
Timeout periods for controlled components. | |
std::map< Address, Time > | mControlCheckTimes |
The last time a control check occurred for controlled components. | |
std::map< Address, Time > | mControlConfirmTimes |
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. |
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.
AccessControl::AccessControl | ( | ) |
Constructor.
Definition at line 56 of file accesscontrol.cpp.
AccessControl::~AccessControl | ( | ) |
Destructor.
Definition at line 72 of file accesscontrol.cpp.
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.
[in] | timeSinceLastCheckMs | Number of milliseconds since the last time this method was called. |
Reimplemented from JAUS::Service.
Definition at line 1072 of file accesscontrol.cpp.
Attempts to create the message desired. Only message supported by this Service can be created by this Service.
[in] | messageCode | Message to create. |
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.
[in] | info | The event information (ID, Sequence #, etc.) for generation. |
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 |
Definition at line 1045 of file accesscontrol.cpp.
Byte AccessControl::GetControllerAuthorityCode | ( | ) | const |
Definition at line 1033 of file accesscontrol.cpp.
Address AccessControl::GetControllerID | ( | ) | const |
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 |
Definition at line 1208 of file accesscontrol.cpp.
bool AccessControl::HaveControl | ( | const Address & | id ) | const |
Check if control has been established for a component.
[in] | id | The 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. |
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 |
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.
[in] | type | The event type (Periodic/EveryChange). |
[in] | requestedPeriodicRate | If type == Periodic, then this is the desired update rate. |
[in] | queryMessage | The query message associated with the event. |
[out] | confirmedPeriodicRate | This is the confirmed periodic rate supported by the Service. |
[out] | errorMessage | If not supported, this is an optional error message. |
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.
[in] | filename | File containing Service settings data. |
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.
[in] | message | Message 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.
[in] | callback | Pointer to callback to add/remove. |
[in] | add | If 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.
[in] | id | The ID of the component to request control of. If ID is invalid (all zeros), then control is released to all components. |
[in] | waitTimeMs | How long to wait for a response in milliseconds from the component being requested. |
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.
[in] | id | The ID of the component to request control of. |
[in] | reacquire | If 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] | waitTimeMs | How long to wait for a response in milliseconds from the component being requested. |
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.
[in] | authorityCode | Authority 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.
[in] | on | If true, control is enabled, false it disable. |
Definition at line 428 of file accesscontrol.cpp.
void AccessControl::SetControllerID | ( | const Address & | id ) |
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.
[in] | timeSeconds | How 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.
Byte JAUS::AccessControl::mAuthorityCode [protected] |
Authority code of the service.
Definition at line 206 of file accesscontrol.h.
Callback::Set JAUS::AccessControl::mCallbacks [protected] |
Callbacks for control events.
Definition at line 221 of file accesscontrol.h.
Mutex JAUS::AccessControl::mCallbacksMutex [protected] |
Mutex for thread protection of callbacks.
Definition at line 222 of file accesscontrol.h.
std::map<Address, Time> JAUS::AccessControl::mControlCheckTimes [protected] |
The last time a control check occurred for controlled components.
Definition at line 219 of file accesscontrol.h.
std::map<Address, Time> JAUS::AccessControl::mControlConfirmTimes [protected] |
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.
bool JAUS::AccessControl::mControllableFlag [protected] |
Is the Service controllable?
Definition at line 205 of file accesscontrol.h.
Components being controlled.
Definition at line 208 of file accesscontrol.h.
Byte JAUS::AccessControl::mControllerAuthorityCode [protected] |
Authority code of controlling component.
Definition at line 213 of file accesscontrol.h.
Time JAUS::AccessControl::mControllerCheckTime [protected] |
The last time the controller updated control.
Definition at line 215 of file accesscontrol.h.
Address JAUS::AccessControl::mControllerID [protected] |
ID of the controlling component.
Definition at line 212 of file accesscontrol.h.
Time JAUS::AccessControl::mControllerUpdateTime [protected] |
The last time the controller sent a command message.
Definition at line 214 of file accesscontrol.h.
Mutex JAUS::AccessControl::mControlMutex [protected] |
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.
Byte JAUS::AccessControl::mTimeoutPeriod [protected] |
Timeout period in seconds.
Definition at line 216 of file accesscontrol.h.
std::map<Address, Byte> JAUS::AccessControl::mTimeoutPeriods [protected] |
Timeout periods for controlled components.
Definition at line 218 of file accesscontrol.h.
double JAUS::AccessControl::mTimeoutThreshold [protected] |
Threshold for timeout requests/checking (percentage of timeout period).
Definition at line 217 of file accesscontrol.h.
Address::Set JAUS::AccessControl::mToReleaseControl [protected] |
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.