DUNE: Uniform Navigational Environment
2019.02.0
|
Stateful Entity class, derived from BasicEntity, and also handling QueryEntityState/EntityState.
The class also implements an entity state and activation interface.
Public Member Functions | |
StatefulEntity (Tasks::AbstractTask *owner, Tasks::Context &context) | |
void | setBindings (Tasks::Recipient *recipient) |
void | setState (IMC::EntityState::StateEnum state, Status::Code code) |
void | setState (IMC::EntityState::StateEnum state, const std::string &message) |
IMC::EntityState::StateEnum | getState (void) const |
void | reportState (void) |
void | setActTimes (uint16_t act_time, uint16_t deact_time) |
void | reportActivationState (void) |
bool | isActive (void) const |
bool | isActivating (void) const |
bool | isDeactivating (void) const |
IMC::EntityActivationState::StateEnum | getActivationState (void) const |
void | requestActivation (void) |
void | requestDeactivation (void) |
void | failActivation (const std::string &reason) |
void | succeedActivation (void) |
void | failDeactivation (const std::string &reason) |
void | succeedDeactivation (void) |
void | consume (const IMC::QueryEntityState *msg) |
void | consume (const IMC::QueryEntityActivationState *msg) |
bool | hasPendingActivation (void) const |
bool | hasPendingDeactivation (void) const |
Public Member Functions inherited from DUNE::Entities::BasicEntity | |
BasicEntity (Tasks::AbstractTask *owner, Tasks::Context &context) | |
virtual | ~BasicEntity () |
const std::string & | getLabel (void) const |
void | setLabel (const std::string &label) |
unsigned int | getId (void) const |
void | setId (unsigned int id) |
void | reportInfo (void) |
bool | operator== (const std::string label) const |
bool | operator== (unsigned int id) const |
void | consume (const IMC::QueryEntityInfo *msg) |
void | dispatch (IMC::Message *msg, unsigned int flags=0) |
void | dispatch (IMC::Message &msg, unsigned int flags=0) |
void | dispatchReply (const IMC::Message &original, IMC::Message &msg, unsigned int flags=0) |
Additional Inherited Members | |
Protected Member Functions inherited from DUNE::Entities::BasicEntity | |
template<typename M , typename E > | |
void | bind (Tasks::Recipient *recipient, E *ent_obj, void(E::*consumer)(const M *)=&E::consume) |
Protected Attributes inherited from DUNE::Entities::BasicEntity | |
Tasks::AbstractTask * | m_owner |
Tasks::Context & | m_ctx |
IMC::EntityInfo | m_ent_info |
|
inline |
Constructor.
[in] | owner | pointer to the task containing the entity. |
[in] | context | entity context. |
References DUNE::Status::CODE_INIT, DUNE::IMC::EntityActivationState::EAS_INACTIVE, DUNE::IMC::EntityState::ESTA_BOOT, setState(), and DUNE::IMC::EntityActivationState::state.
void DUNE::Entities::StatefulEntity::consume | ( | const IMC::QueryEntityState * | msg | ) |
Consume QueryEntityState messages andreply accordingly.
[in] | msg | QueryEntityState message. |
References reportState().
void DUNE::Entities::StatefulEntity::consume | ( | const IMC::QueryEntityActivationState * | msg | ) |
Consume QueryEntityActivationState messages and replyaccordingly.
[in] | msg | QueryEntityActivationState message. |
References DUNE::IMC::Message::getDestinationEntity(), DUNE::Entities::BasicEntity::getId(), and reportActivationState().
void DUNE::Entities::StatefulEntity::failActivation | ( | const std::string & | reason | ) |
Mark the activation as unsuccessful.
[in] | reason | message to the user explaining why the activation failed. |
References DUNE::Entities::BasicEntity::dispatch(), DUNE::IMC::EntityActivationState::EAS_ACT_FAIL, DUNE::IMC::EntityActivationState::EAS_INACTIVE, DUNE::IMC::EntityActivationState::error, and DUNE::IMC::EntityActivationState::state.
Referenced by DUNE::Tasks::Task::activationFailed().
void DUNE::Entities::StatefulEntity::failDeactivation | ( | const std::string & | reason | ) |
Mark the deactivation as unsuccessful.
[in] | reason | message to the user explaining why the deactivation failed. |
References DUNE::Entities::BasicEntity::dispatch(), DUNE::IMC::EntityActivationState::EAS_ACTIVE, DUNE::IMC::EntityActivationState::EAS_DEACT_FAIL, DUNE::IMC::EntityActivationState::error, and DUNE::IMC::EntityActivationState::state.
Referenced by DUNE::Tasks::Task::deactivationFailed().
|
inline |
Get the current entity activation state.
References DUNE::IMC::EntityActivationState::state.
Referenced by DUNE::Tasks::Task::activate(), and DUNE::Tasks::Task::deactivate().
|
inline |
Retrieve the current entity state.
References DUNE::IMC::EntityState::state.
Referenced by DUNE::Tasks::Task::getEntityState().
|
inline |
Check if an activation request arrived while the entity was being deactivated.
Referenced by DUNE::Tasks::Task::deactivate().
|
inline |
Check if a deactivation request arrived while the entity was being activated.
Referenced by DUNE::Tasks::Task::activate().
|
inline |
Test if entity is activating.
References DUNE::IMC::EntityActivationState::EAS_ACT_IP, and DUNE::IMC::EntityActivationState::state.
Referenced by DUNE::Tasks::Task::isActivating(), and DUNE::Tasks::Task::requestActivation().
|
inline |
Test if entity is active.
References DUNE::IMC::EntityActivationState::EAS_ACTIVE, and DUNE::IMC::EntityActivationState::state.
Referenced by DUNE::Tasks::Task::isActive().
|
inline |
Test if entity is deactivating.
References DUNE::IMC::EntityActivationState::EAS_DEACT_IP, and DUNE::IMC::EntityActivationState::state.
Referenced by DUNE::Tasks::Task::isDeactivating(), and DUNE::Tasks::Task::requestDeactivation().
void DUNE::Entities::StatefulEntity::reportActivationState | ( | void | ) |
Report the activation state.
References DUNE::Entities::BasicEntity::dispatch().
Referenced by consume(), and DUNE::Tasks::Task::updateParameters().
void DUNE::Entities::StatefulEntity::reportState | ( | void | ) |
Report the entity state.
References DUNE::Entities::BasicEntity::dispatch().
Referenced by consume().
void DUNE::Entities::StatefulEntity::requestActivation | ( | void | ) |
Request entity activation.
References DUNE::Entities::BasicEntity::dispatch(), DUNE::IMC::EntityActivationState::EAS_ACT_FAIL, DUNE::IMC::EntityActivationState::EAS_ACT_IP, DUNE::IMC::EntityActivationState::EAS_DEACT_DONE, DUNE::IMC::EntityActivationState::EAS_DEACT_FAIL, DUNE::IMC::EntityActivationState::EAS_DEACT_IP, DUNE::IMC::EntityActivationState::EAS_INACTIVE, DUNE::Entities::BasicEntity::m_owner, DUNE::Tasks::AbstractTask::spew(), and DUNE::IMC::EntityActivationState::state.
Referenced by DUNE::Tasks::Task::requestActivation().
void DUNE::Entities::StatefulEntity::requestDeactivation | ( | void | ) |
Request entity deactivation.
References DUNE::Entities::BasicEntity::dispatch(), DUNE::IMC::EntityActivationState::EAS_ACT_DONE, DUNE::IMC::EntityActivationState::EAS_ACT_FAIL, DUNE::IMC::EntityActivationState::EAS_ACT_IP, DUNE::IMC::EntityActivationState::EAS_ACTIVE, DUNE::IMC::EntityActivationState::EAS_DEACT_FAIL, DUNE::IMC::EntityActivationState::EAS_DEACT_IP, DUNE::Entities::BasicEntity::m_owner, DUNE::Tasks::AbstractTask::spew(), and DUNE::IMC::EntityActivationState::state.
Referenced by DUNE::Tasks::Task::requestDeactivation().
|
inline |
Set the expected activation and deactivation times to be included in the EntityInfo message.
[in] | act_time | expected activation time. |
[in] | deact_time | expected deactivation time. |
References DUNE::IMC::EntityInfo::act_time, DUNE::IMC::EntityInfo::deact_time, and DUNE::Entities::BasicEntity::m_ent_info.
Referenced by DUNE::Tasks::Task::updateParameters().
|
inlinevirtual |
Set the IMC bindings using the provided recipient object.
[in] | recipient | pointer to the recipient object to use for binding to IMC messages. |
Reimplemented from DUNE::Entities::BasicEntity.
References DUNE::Entities::BasicEntity::setBindings().
Referenced by DUNE::Tasks::Task::reserveEntities().
void DUNE::Entities::StatefulEntity::setState | ( | IMC::EntityState::StateEnum | state, |
Status::Code | code | ||
) |
Set the entity state with a message constructed from a standard status code.
[in] | state | state to be set. |
[in] | code | status code to be used for generating a status message. |
References DUNE::IMC::EntityState::description, DUNE::Entities::BasicEntity::dispatch(), DUNE::Entities::BasicEntity::getId(), DUNE::Status::getString(), and DUNE::IMC::EntityState::state.
Referenced by DUNE::Tasks::Task::setEntityState(), and StatefulEntity().
void DUNE::Entities::StatefulEntity::setState | ( | IMC::EntityState::StateEnum | state, |
const std::string & | message | ||
) |
Set the entity state with a user-provided message.
[in] | state | state to be set. |
[in] | message | status message to use. |
References DUNE::IMC::EntityState::description, DUNE::Entities::BasicEntity::dispatch(), DUNE::Entities::BasicEntity::getId(), and DUNE::IMC::EntityState::state.
void DUNE::Entities::StatefulEntity::succeedActivation | ( | void | ) |
Mark the activation as successful.
References DUNE::Entities::BasicEntity::dispatch(), DUNE::IMC::EntityActivationState::EAS_ACT_DONE, DUNE::IMC::EntityActivationState::EAS_ACTIVE, and DUNE::IMC::EntityActivationState::state.
Referenced by DUNE::Tasks::Task::activate().
void DUNE::Entities::StatefulEntity::succeedDeactivation | ( | void | ) |
Mark the deactivation as successful.
References DUNE::Entities::BasicEntity::dispatch(), DUNE::IMC::EntityActivationState::EAS_DEACT_DONE, DUNE::IMC::EntityActivationState::EAS_INACTIVE, and DUNE::IMC::EntityActivationState::state.
Referenced by DUNE::Tasks::Task::deactivate().