DUNE: Uniform Navigational Environment  2016.03.0
DUNE::Entities::StatefulEntity Class Reference

Detailed Description

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)
 
bool operator== (unsigned int id)
 
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::AbstractTaskm_owner
 
Tasks::Contextm_ctx
 
IMC::EntityInfo m_ent_info
 

Constructor & Destructor Documentation

DUNE::Entities::StatefulEntity::StatefulEntity ( Tasks::AbstractTask owner,
Tasks::Context context 
)
inline

Constructor.

Parameters
[in]ownerpointer to the task containing the entity.
[in]contextentity context.

References DUNE::Status::CODE_INIT, DUNE::IMC::EntityActivationState::EAS_INACTIVE, DUNE::IMC::EntityState::ESTA_BOOT, setState(), and DUNE::IMC::EntityActivationState::state.

Member Function Documentation

void DUNE::Entities::StatefulEntity::consume ( const IMC::QueryEntityState msg)

Consume QueryEntityState messages andreply accordingly.

Parameters
[in]msgQueryEntityState message.

References reportState().

void DUNE::Entities::StatefulEntity::consume ( const IMC::QueryEntityActivationState msg)

Consume QueryEntityActivationState messages and replyaccordingly.

Parameters
[in]msgQueryEntityActivationState message.

References DUNE::IMC::Message::getDestinationEntity(), DUNE::Entities::BasicEntity::getId(), and reportActivationState().

void DUNE::Entities::StatefulEntity::failActivation ( const std::string &  reason)
void DUNE::Entities::StatefulEntity::failDeactivation ( const std::string &  reason)
IMC::EntityActivationState::StateEnum DUNE::Entities::StatefulEntity::getActivationState ( void  ) const
inline

Get the current entity activation state.

Returns
current entity activation state.

References DUNE::IMC::EntityActivationState::state.

Referenced by DUNE::Tasks::Task::activate(), and DUNE::Tasks::Task::deactivate().

IMC::EntityState::StateEnum DUNE::Entities::StatefulEntity::getState ( void  ) const
inline

Retrieve the current entity state.

Returns
entity state.

References DUNE::IMC::EntityState::state.

Referenced by DUNE::Tasks::Task::getEntityState().

bool DUNE::Entities::StatefulEntity::hasPendingActivation ( void  ) const
inline

Check if an activation request arrived while the entity was being deactivated.

Returns
true if an activation request is pending, false otherwise.

Referenced by DUNE::Tasks::Task::deactivate().

bool DUNE::Entities::StatefulEntity::hasPendingDeactivation ( void  ) const
inline

Check if a deactivation request arrived while the entity was being activated.

Returns
true if a deactivation request is pending, false otherwise.

Referenced by DUNE::Tasks::Task::activate().

bool DUNE::Entities::StatefulEntity::isActivating ( void  ) const
inline

Test if entity is activating.

Returns
true if entity is activating, false otherwise.

References DUNE::IMC::EntityActivationState::EAS_ACT_IP, and DUNE::IMC::EntityActivationState::state.

Referenced by DUNE::Tasks::Task::isActivating(), and DUNE::Tasks::Task::requestActivation().

bool DUNE::Entities::StatefulEntity::isActive ( void  ) const
inline

Test if entity is active.

Returns
true if entity is active, false otherwise.

References DUNE::IMC::EntityActivationState::EAS_ACTIVE, and DUNE::IMC::EntityActivationState::state.

Referenced by DUNE::Tasks::Task::isActive().

bool DUNE::Entities::StatefulEntity::isDeactivating ( void  ) const
inline

Test if entity is deactivating.

Returns
true if entity is deactivating, false otherwise.

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::setActTimes ( uint16_t  act_time,
uint16_t  deact_time 
)
inline

Set the expected activation and deactivation times to be included in the EntityInfo message.

Parameters
[in]act_timeexpected activation time.
[in]deact_timeexpected 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().

void DUNE::Entities::StatefulEntity::setBindings ( Tasks::Recipient recipient)
inlinevirtual

Set the IMC bindings using the provided recipient object.

Parameters
[in]recipientpointer 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.

Parameters
[in]statestate to be set.
[in]codestatus 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.

Parameters
[in]statestate to be set.
[in]messagestatus 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  )
void DUNE::Entities::StatefulEntity::succeedDeactivation ( void  )
Collaboration diagram for DUNE::Entities::StatefulEntity:
Collaboration graph