DUNE: Uniform Navigational Environment  2019.02.1
DUNE::Tasks::Task Class Referenceabstract

Detailed Description

Public Member Functions

 Task (const std::string &name, Context &context)
 
virtual ~Task (void)
 
const char * getName (void) const
 
const char * getSystemName (void) const
 
unsigned int getSystemId (void) const
 
unsigned int getEntityId (void) const
 
unsigned int resolveEntity (const std::string &label) const
 
std::string resolveEntity (unsigned int id) const
 
DebugLevel getDebugLevel (void) const
 
uint16_t getActivationTime (void) const
 
uint16_t getDeactivationTime (void) const
 
unsigned int resolveSystemName (const std::string &name) const
 
const char * resolveSystemId (unsigned int id) const
 
void loadConfig (void)
 
void setPriority (unsigned int value)
 
unsigned int getPriority (void) const
 
void inf (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void war (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void err (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void void cri (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void void void debug (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void void void void trace (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void void void void void spew (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void void void void void 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)
 
void receive (const IMC::Message *msg)
 
void reserveEntities (void)
 
void resolveEntities (void)
 
void acquireResources (void)
 
void releaseResources (void)
 
void initializeResources (void)
 
void updateParameters (bool act_deact=true)
 
void writeParamsXML (std::ostream &os) const
 
const char * getEntityLabel (void) const
 
void setEntityLabel (const std::string &label)
 
- Public Member Functions inherited from DUNE::Tasks::AbstractTask
 AbstractTask (void)
 
virtual ~AbstractTask (void)
 
- Public Member Functions inherited from DUNE::Concurrency::Thread
 Thread (void)
 
virtual ~Thread (void)
 
int getProcessorUsage (void)
 
- Public Member Functions inherited from DUNE::Concurrency::Runnable
 Runnable (void)
 
virtual ~Runnable (void)
 
void start (void)
 
void stop (void)
 
void join (void)
 
void stopAndJoin (void)
 
void setPriority (Scheduler::Policy policy, unsigned priority)
 
unsigned getPriority (void)
 
State getState (void)
 
bool isCreated (void)
 
bool isStopping (void)
 
bool isRunning (void)
 
bool isStarting (void)
 
bool isDead (void)
 

Protected Member Functions

void setEntityState (IMC::EntityState::StateEnum state, Status::Code code)
 
void setEntityState (IMC::EntityState::StateEnum state, const std::string &description)
 
IMC::EntityState::StateEnum getEntityState (void) const
 
unsigned int reserveEntity (const std::string &label)
 
template<typename E >
E * reserveEntity (const std::string &label)
 
Entities::BasicEntitygetLocalEntity (const std::string &label)
 
bool stopping (void)
 
bool isActive (void) const
 
bool isActivating (void) const
 
bool isDeactivating (void) const
 
void waitForMessages (double timeout)
 
void consumeMessages (void)
 
template<typename T >
Parameterparam (const std::string &name, T &var)
 
template<typename Y , typename T >
Parameterparam (const std::string &name, T &var)
 
template<typename T >
bool paramChanged (T &var)
 
void paramActive (Parameter::Scope def_scope, Parameter::Visibility def_visibility, bool def_value=false)
 
void setParamSectionEditor (const std::string &name)
 
template<typename M , typename T >
void bind (T *task_obj, void(T::*consumer)(const M *)=&T::consume)
 
template<typename T >
void bind (T *task_obj, const std::vector< uint32_t > &list)
 
template<typename T , typename M >
void bind (T *task_obj, const std::vector< uint32_t > &list, void(T::*consumer)(const M *)=&T::consume)
 
template<typename T >
void bind (T *task_obj, const std::vector< std::string > &list)
 
void requestActivation (void)
 
void requestDeactivation (void)
 
void activate (void)
 
void activationFailed (const std::string &reason)
 
void deactivate (void)
 
void deactivationFailed (const std::string &reason)
 
virtual bool onWriteParamsXML (std::ostream &os) const
 
virtual void onEntityReservation (void)
 
virtual void onEntityResolution (void)
 
virtual void onReportEntityState (void)
 
virtual void onResourceAcquisition (void)
 
virtual void onResourceRelease (void)
 
virtual void onResourceInitialization (void)
 
virtual void onUpdateParameters (void)
 
virtual void onRequestActivation (void)
 
virtual void onRequestDeactivation (void)
 
virtual void onActivation (void)
 
virtual void onDeactivation (void)
 
virtual void onQueryEntityParameters (const IMC::QueryEntityParameters *msg)
 
virtual void onSetEntityParameters (const IMC::SetEntityParameters *msg)
 
virtual void onPushEntityParameters (const IMC::PushEntityParameters *msg)
 
virtual void onPopEntityParameters (const IMC::PopEntityParameters *msg)
 
virtual void onMain (void)=0
 
- Protected Member Functions inherited from DUNE::Concurrency::Thread
void startImpl (void)
 
void stopImpl (void)
 
void joinImpl (void)
 
void setPriorityImpl (Scheduler::Policy policy, unsigned priority)
 
unsigned getPriorityImpl (void)
 

Protected Attributes

Contextm_ctx
 
std::vector< Entities::BasicEntity * > m_entities
 

Additional Inherited Members

- Public Types inherited from DUNE::Concurrency::Runnable

Constructor & Destructor Documentation

DUNE::Tasks::Task::Task ( const std::string &  name,
Context context 
)

Construct a task object.

Parameters
[in]namename of the task.
[in]contexttask context.

References DUNE::Tasks::Parameter::defaultValue(), m_ctx, m_entities, param(), and DUNE::Tasks::Recipient.

Member Function Documentation

void DUNE::Tasks::Task::acquireResources ( void  )

Acquire resources whose configuration depends on dynamic parameters.

References DUNE::Tasks::ParameterTable::end(), DUNE::Tasks::ParameterTable::find(), onResourceAcquisition(), and DUNE::Tasks::Parameter::SCOPE_MANEUVER.

Referenced by deactivationFailed(), and receive().

void DUNE::Tasks::Task::activationFailed ( const std::string &  reason)
protected

Derived classes should use this function to signal that activation failed.

Parameters
[in]reasonreason for activation failure.

References DUNE::Entities::StatefulEntity::failActivation(), and spew().

Referenced by DUNE::Hardware::BasicDeviceDriver::BasicDeviceDriver(), and bind().

template<typename M , typename T >
void DUNE::Tasks::Task::bind ( T *  task_obj,
void(T::*)(const M *)  consumer = &T::consume 
)
inlineprotected

Bind a message to a consumer method.

Parameters
task_objconsumer task.
consumerconsumer method.

Referenced by bind(), onDeactivation(), and DUNE::Tasks::SimpleTransport::onMain().

template<typename T >
void DUNE::Tasks::Task::bind ( T *  task_obj,
const std::vector< uint32_t > &  list 
)
inlineprotected

Bind multiple messages to a default consumer method.

Parameters
task_objconsumer object.
listlist of message identifiers.

References bind().

template<typename T , typename M >
void DUNE::Tasks::Task::bind ( T *  task_obj,
const std::vector< uint32_t > &  list,
void(T::*)(const M *)  consumer = &T::consume 
)
inlineprotected

Bind multiple messages to a consumer method.

Parameters
task_objconsumer object.
listlist of message identifiers.
consumerconsumer method.

References bind().

template<typename T >
void DUNE::Tasks::Task::bind ( T *  task_obj,
const std::vector< std::string > &  list 
)
inlineprotected

Bind multiple messages to a default consumer method.

Parameters
task_objconsumer task.
listlist of message abbreviations.

References activate(), activationFailed(), bind(), deactivate(), deactivationFailed(), DUNE::IMC::Factory::getIdFromAbbrev(), requestActivation(), and requestDeactivation().

void DUNE::Tasks::Task::consumeMessages ( void  )
inlineprotected
void DUNE::Tasks::Task::cri ( const char *  format,
  ... 
)
virtual

Send an human-readable critical error message to all configured output channels and files.

Parameters
formatstring format (similar to printf(3)).
...arguments.

Reimplemented from DUNE::Tasks::AbstractTask.

References DUNE::IMC::LogBookEntry::LBET_CRITICAL.

Referenced by getPriority().

void DUNE::Tasks::Task::dispatch ( IMC::Message msg,
unsigned int  flags = 0 
)

Dispatch message to the message bus.

Parameters
[in]msgmessage pointer.
[in]flagsbitfield with flags (see DispatchFlags).

References DUNE::Tasks::DF_KEEP_SRC_EID, DUNE::Tasks::DF_KEEP_TIME, DUNE::Tasks::DF_LOOP_BACK, DUNE::IMC::Bus::dispatch(), getEntityId(), DUNE::IMC::Message::getSource(), DUNE::IMC::Message::getSourceEntity(), getSystemId(), DUNE::IMC::AddressResolver::isValid(), m_ctx, DUNE::Tasks::Context::mbus, DUNE::IMC::Message::setSource(), DUNE::IMC::Message::setSourceEntity(), and DUNE::IMC::Message::setTimeStamp().

Referenced by DUNE::Hardware::BasicDeviceDriver::BasicDeviceDriver(), DUNE::Control::BasicRemoteOperation::consume(), DUNE::Hardware::BasicDeviceDriver::consume(), DUNE::Control::BasicUAVAutopilot::consume(), DUNE::Control::BasicAutopilot::consume(), DUNE::Daemon::consume(), DUNE::Control::PathController::consume(), DUNE::Navigation::BasicNavigation::consume(), deactivationFailed(), DUNE::Navigation::BeamFilter::dispatch(), dispatch(), dispatchReply(), Vision::Lumenera::EntityActivation::entityActivationUpdate(), Transports::DataStore::Router::forwardCommandsAcoustic(), Transports::DataStore::Router::forwardCommandsWifi(), DUNE::Control::PathController::getEta(), getPriority(), Autonomy::TextActions::Task::handleAbortCommand(), Autonomy::TextActions::Task::handleChangeNumCommand(), DUNE::Tasks::SimpleTransport::handleData(), Autonomy::TextActions::Task::handlePlanGeneratorCommand(), Autonomy::TextActions::Task::handleRebootCommand(), Autonomy::TextActions::Task::handleStartCommand(), Transports::DataStore::Router::iridiumUpload(), DUNE::Navigation::BasicNavigation::isActive(), DUNE::Tasks::Manager::measureCpuUsage(), Supervisors::PowerManager::Task::onMain(), Actuators::PWM::Task::onMain(), DUNE::Control::BasicRemoteOperation::onResourceInitialization(), Transports::LogBook::Task::provide(), DUNE::Hardware::BasicModem::readRaw(), Autonomy::TextActions::Task::reply(), DUNE::Navigation::BasicNavigation::reportToBus(), Transports::DataStore::Router::routeOverAcoustic(), Transports::DataStore::Router::routeOverWifi(), DUNE::Navigation::BasicNavigation::runKalmanLBL(), DUNE::Hardware::HayesModem::sendAT(), DUNE::Hardware::HayesModem::setRSSI(), DUNE::Control::PathController::signalError(), spew(), Control::Path::PurePursuit::Task::step(), DUNE::Control::DiscretePID::step(), and DUNE::Daemon::writeParamsXML().

void DUNE::Tasks::Task::dispatch ( IMC::Message msg,
unsigned int  flags = 0 
)
inline

Dispatch message to the message bus.

Parameters
[in]msgmessage reference.
[in]flagsbitfield with flags (see DispatchFlags).

References dispatch().

void DUNE::Tasks::Task::dispatchReply ( const IMC::Message original,
IMC::Message msg,
unsigned int  flags = 0 
)
inline

Dispatch message to the message bus in reply to another message.

Parameters
[in]originaloriginal message.
[in]msgmessage reference.
[in]flagsbitfield with flags (see DispatchFlags).

References dispatch(), DUNE::IMC::Message::getSource(), DUNE::IMC::Message::getSourceEntity(), DUNE::IMC::Message::setDestination(), and DUNE::IMC::Message::setDestinationEntity().

Referenced by onQueryEntityParameters().

uint16_t DUNE::Tasks::Task::getActivationTime ( void  ) const
inline

Retrieve the task's activation time.

Returns
activation time of the task.

Referenced by DUNE::Hardware::BasicDeviceDriver::consume().

uint16_t DUNE::Tasks::Task::getDeactivationTime ( void  ) const
inline

Retrieve the task's deactivation time.

Returns
deactivation time of the task.

Referenced by DUNE::Hardware::BasicDeviceDriver::consume().

DebugLevel DUNE::Tasks::Task::getDebugLevel ( void  ) const
inline

Get current debug level.

Returns
debug level.
unsigned int DUNE::Tasks::Task::getEntityId ( void  ) const
inline

Retrieve the main entity identifier of the task.

Returns
main entity identifier.

References DUNE::Entities::BasicEntity::getId().

Referenced by DUNE::Daemon::consume(), dispatch(), DUNE::Tasks::Manager::measureCpuUsage(), DUNE::Maneuvers::Maneuver::onEntityReservation(), and spew().

const char* DUNE::Tasks::Task::getEntityLabel ( void  ) const
inline
IMC::EntityState::StateEnum DUNE::Tasks::Task::getEntityState ( void  ) const
inlineprotected

Retrieve the current entity state.

Returns
entity state.

References DUNE::Entities::StatefulEntity::getState(), and reserveEntity().

Referenced by DUNE::Control::BasicAutopilot::consume().

Entities::BasicEntity * DUNE::Tasks::Task::getLocalEntity ( const std::string &  label)
protected

Retrieve pointer to a previously stored entity object object.

Parameters
[in]labelentity name/label.
Returns
pointer to entity object.

References m_entities.

Referenced by reserveEntity().

const char* DUNE::Tasks::Task::getName ( void  ) const
inlinevirtual

Retrieve the task's name.

Returns
name of the task.

Implements DUNE::Tasks::AbstractTask.

Referenced by deactivationFailed(), loadConfig(), onSetEntityParameters(), reserveEntities(), reserveEntity(), and spew().

unsigned int DUNE::Tasks::Task::getPriority ( void  ) const
inline

Get scheduling priority.

The priority of a task might change when configuration parameters are updated.

Returns
task priority.

References cri(), debug(), dispatch(), err(), inf(), spew(), trace(), and war().

Referenced by DUNE::Tasks::Manager::adjustPriorities().

const char* DUNE::Tasks::Task::getSystemName ( void  ) const
inline
void DUNE::Tasks::Task::initializeResources ( void  )

Instruct task to initialize the resources acquired in acquireResources().

References err(), onResourceInitialization(), stopping(), and DUNE::Time::Delay::wait().

Referenced by deactivationFailed(), and receive().

bool DUNE::Tasks::Task::isActivating ( void  ) const
inlineprotected

Test if task is activating.

Returns
true if task is activating, false otherwise.

References DUNE::Entities::StatefulEntity::isActivating().

Referenced by DUNE::Hardware::BasicDeviceDriver::consume().

bool DUNE::Tasks::Task::isDeactivating ( void  ) const
inlineprotected

Test if task is deactivating.

Returns
true if task is deactivating, false otherwise.

References DUNE::Entities::StatefulEntity::isDeactivating().

virtual void DUNE::Tasks::Task::onMain ( void  )
protectedpure virtual

Implemented in Control::UAV::Ardupilot::Task, Sensors::MLBL::Task, Transports::Seatrac::Task, Plan::Engine::Task, Sensors::MLBLTracker::Task, Vision::Lumenera::Task, Transports::UAN::Task, Sensors::Microstrain3DMGX1::Task, Control::UAV::PX4::Task, Sensors::MetrecX::Task, Control::AUV::Allocator::Task, Transports::Radio::Task, Sensors::Imagenex881A::Task, Plan::DB::Task, Actuators::MCD4R::Task, Sensors::SADC::Task, Control::AUV::Speed::Task, Power::BATMANv2::Task, Autonomy::TextActions::Task, Monitors::Entities::Task, Power::LUEMB::Task, Power::OPCON::Task, Vision::DFK51BG02H::Task, Transports::CommManager::Task, Actuators::LED4R::Task, Transports::Announce::Task, Transports::Iridium::Task, Sensors::DMS::Task, Sensors::OEMX::Task, Transports::UDP::Task, Sensors::MTi::Task, Transports::IridiumSBD::Task, Sensors::OS4000::Task, Sensors::XR620CTD::Task, Transports::GSM::Task, Transports::DataStore::Task, Power::CPMBv2::Task, Power::CPMB::Task, Autonomy::TREX::Task, Power::APD::Task, Vision::UI2210MGL::Task, Sensors::IFOG::Task, Transports::Replay::Task, Autonomy::OnEvent::Task, Sensors::CyclopsC7::Task, DUNE::Control::PathController, DUNE::Maneuvers::Maneuver, Transports::Cache::Task, Transports::LoggingDigest::Task, Sensors::DataStore::Task, Sensors::EmulatedGPS::Task, Plan::Generator::Task, Navigation::General::GPSNavigation::Task, Transports::SerialOverTCP::Task, Monitors::Clock::Task, Sensors::AIS::Task, Transports::Discovery::Task, Sensors::WifiRSSI::Task, Actuators::PWM::Task, Navigation::AUV::Ranger::Task, Simulators::AcousticModem::Task, Supervisors::Reporter::Task, Vision::PhotoTrigger::Task, Supervisors::PowerManager::Task, Control::AntennaTracker::Task, Sensors::XchangeSV::Task, Transports::LogBook::Task, Vision::UAVCamera::Task, Transports::Fragments::Task, Sensors::MiniSVS::Task, DUNE::Control::BasicAutopilot, Sensors::GillWindObserverII::Task, DUNE::Daemon, DUNE::Control::BasicUAVAutopilot, and DUNE::Tasks::SimpleTransport.

Referenced by deactivationFailed(), and onDeactivation().

void DUNE::Tasks::Task::onPopEntityParameters ( const IMC::PopEntityParameters msg)
protectedvirtual
virtual void DUNE::Tasks::Task::onReportEntityState ( void  )
inlineprotectedvirtual

Called when the task is instructed to report the state of its entities.

Derived classes that need to report the state of entities other than the main entity should override this function to dispatch the EntityState of those entities.

Reimplemented in Navigation::AUV::Navigation::Task, and Monitors::Entities::Task.

Referenced by resolveEntities().

virtual void DUNE::Tasks::Task::onRequestActivation ( void  )
inlineprotectedvirtual

Called when an external activation request is received.

Derived classes that need to perform extra steps to prepare normal execution should replace the default behaviour of immediate activation with calls to activate() when the request is completed or activationFailed() if the request cannot be honoured.

Reimplemented in Maneuver::VehicleFormation::FormCollAvoid::Task, Maneuver::VehicleFormation::Coordinator::Task, Sensors::Imagenex881A::Task, Vision::DFK51BG02H::Task, Transports::Radio::Task, Vision::Lumenera::Task, Vision::UI2210MGL::Task, and Sensors::CyclopsC7::Task.

References activate(), and spew().

Referenced by requestActivation().

virtual void DUNE::Tasks::Task::onRequestDeactivation ( void  )
inlineprotectedvirtual

Called when an external deactivation request is received.

Derived classes that need to perform extra steps to prepare normal execution should replace the default behaviour of immediate deactivation with calls to deactivate() when the request is completed or deactivationFailed() if the request cannot be honoured.

Reimplemented in Maneuver::VehicleFormation::FormCollAvoid::Task, Maneuver::VehicleFormation::Coordinator::Task, Transports::Radio::Task, and Vision::Lumenera::Task.

References deactivate(), and spew().

Referenced by requestDeactivation().

virtual void DUNE::Tasks::Task::onResourceAcquisition ( void  )
inlineprotectedvirtual

Called when the task is instructed to acquire resources whose configuration is defined by run-time parameters.

Reimplemented in Maneuver::VehicleFormation::FormCollAvoid::Task, Maneuver::VehicleFormation::Coordinator::Task, Sensors::MLBL::Task, Control::UAV::Ardupilot::Task, Transports::Radio::Task, Sensors::MetrecX::Task, Sensors::Imagenex881A::Task, Transports::Seatrac::Task, Simulators::UAV::Task, Control::AUV::Attitude::Task, Actuators::MCD4R::Task, Vision::Lumenera::Task, Control::UAV::PX4::Task, Vision::DFK51BG02H::Task, Sensors::MLBLTracker::Task, Control::ROV::RemoteOperation::Task, Power::LUEMB::Task, Monitors::FuelLevel::Task, Sensors::Microstrain3DMGX3::Task, Plan::Engine::Task, Transports::UDP::Task, Vision::UI2210MGL::Task, Power::CPMBv2::Task, Power::CPMB::Task, Power::BATMANv2::Task, Power::APD::Task, Actuators::LED4R::Task, Sensors::SADC::Task, Sensors::Microstrain3DMGX1::Task, Transports::GSM::Task, Transports::UAN::Task, Sensors::CyclopsC7::Task, Sensors::IFOG::Task, Sensors::OS4000::Task, Maneuver::VehicleFormation::Test::Task, Sensors::DMS::Task, Sensors::OEMX::Task, Sensors::XR620CTD::Task, Supervisors::AUV::Assist::Task, Monitors::Emergency::Task, Transports::IridiumSBD::Task, Supervisors::Vehicle::Task, Sensors::MTi::Task, Sensors::AIM104MultiIO::Task, Sensors::SW100::Task, Plan::DB::Task, Sensors::EmulatedGPS::Task, Vision::FrameGrabber::Task, Simulators::AcousticModem::Task, Simulators::UAVAutopilot::Task, Transports::Iridium::Task, Sensors::AIS::Task, Sensors::MiniSVS::Task, Supervisors::PowerManager::Task, Transports::SerialOverTCP::Task, Sensors::XchangeSV::Task, Sensors::GillWindObserverII::Task, DUNE::Control::BasicAutopilot, and DUNE::Control::BasicUAVAutopilot.

Referenced by acquireResources().

virtual void DUNE::Tasks::Task::onResourceInitialization ( void  )
inlineprotectedvirtual

Called when the task is instructed to initialize resources acquired previously or whose initialization depends on run-time parameters.

Reimplemented in Transports::Radio::Task, Sensors::MLBL::Task, Sensors::MetrecX::Task, Sensors::Imagenex881A::Task, Transports::Seatrac::Task, Transports::CommManager::Task, Sensors::MLBLTracker::Task, Actuators::MCD4R::Task, Vision::DFK51BG02H::Task, Navigation::AUV::Navigation::Task, Control::AUV::Attitude::Task, Power::LUEMB::Task, Sensors::Microstrain3DMGX3::Task, Vision::UI2210MGL::Task, Power::CPMBv2::Task, Control::AUV::Allocator::Task, Power::CPMB::Task, Plan::Engine::Task, Power::APD::Task, Power::BATMANv2::Task, Control::ROV::RemoteOperation::Task, Actuators::LED4R::Task, Sensors::SADC::Task, Transports::GSM::Task, Sensors::IFOG::Task, Sensors::OEMX::Task, Sensors::Microstrain3DMGX1::Task, Transports::UAN::Task, Monitors::Medium::Task, Control::AUV::Speed::Task, Sensors::OS4000::Task, Sensors::DMS::Task, Power::OPCON::Task, Autonomy::OnEvent::Task, Transports::DataStore::Task, Sensors::XR620CTD::Task, Control::ROV::HorizontalPlane::Task, Supervisors::AUV::Assist::Task, Transports::Announce::Task, Transports::IridiumSBD::Task, Monitors::Emergency::Task, Navigation::General::ROV::Task, Supervisors::Vehicle::Task, DUNE::Navigation::BasicNavigation, Sensors::WifiRSSI::Task, Control::AUV::LMI::Task, Sensors::DataStore::Task, Monitors::Entities::Task, Sensors::AIM104MultiIO::Task, Sensors::SW100::Task, Transports::SerialOverTCP::Task, Monitors::Clock::Task, Control::ROV::Depth::Task, Sensors::XchangeSV::Task, Supervisors::AUV::LostComms::Task, Vision::FrameGrabber::Task, DUNE::Control::PathController, Transports::Iridium::Task, Transports::LoggingDigest::Task, DUNE::Control::BasicRemoteOperation, Actuators::PWM::Task, Sensors::MiniSVS::Task, Supervisors::PowerManager::Task, Supervisors::Entities::Task, Transports::Cache::Task, Autonomy::TextActions::Task, Transports::Discovery::Task, Navigation::AUV::Ranger::Task, DUNE::Daemon, Transports::LogBook::Task, DUNE::Maneuvers::Maneuver, DUNE::Control::BasicAutopilot, and DUNE::Control::BasicUAVAutopilot.

Referenced by initializeResources().

virtual void DUNE::Tasks::Task::onResourceRelease ( void  )
inlineprotectedvirtual

Called when the task is instructed to release resources.

Derived classes that override this function must not assume that any resource was previously acquired. This function must be implemented in such a way that it can be called at any time.

Reimplemented in Maneuver::VehicleFormation::FormCollAvoid::Task, Maneuver::VehicleFormation::Coordinator::Task, Transports::Radio::Task, Transports::Seatrac::Task, Sensors::MLBL::Task, Control::UAV::Ardupilot::Task, Sensors::MetrecX::Task, Sensors::Imagenex881A::Task, Actuators::MCD4R::Task, Control::UAV::PX4::Task, Transports::CommManager::Task, Sensors::MLBLTracker::Task, Navigation::AUV::Navigation::Task, Control::AUV::Attitude::Task, Vision::Lumenera::Task, Simulators::UAV::Task, Vision::DFK51BG02H::Task, Transports::UDP::Task, Power::LUEMB::Task, Actuators::LED4R::Task, Power::CPMBv2::Task, Power::CPMB::Task, Sensors::Microstrain3DMGX1::Task, Power::APD::Task, Power::BATMANv2::Task, Sensors::SADC::Task, Control::ROV::RemoteOperation::Task, Monitors::FuelLevel::Task, Transports::GSM::Task, Control::AUV::Allocator::Task, Sensors::Microstrain3DMGX3::Task, Sensors::OEMX::Task, Vision::UI2210MGL::Task, Plan::Engine::Task, Transports::UAN::Task, Sensors::DMS::Task, Sensors::IFOG::Task, Sensors::CyclopsC7::Task, Maneuver::VehicleFormation::Test::Task, Sensors::OS4000::Task, Transports::IridiumSBD::Task, Plan::DB::Task, Sensors::XR620CTD::Task, Supervisors::AUV::Assist::Task, Sensors::AIM104MultiIO::Task, Navigation::General::ROV::Task, DUNE::Navigation::BasicNavigation, Monitors::Emergency::Task, Sensors::SW100::Task, Supervisors::Vehicle::Task, Sensors::AIS::Task, Actuators::PWM::Task, Sensors::MTi::Task, Vision::FrameGrabber::Task, Sensors::EmulatedGPS::Task, Transports::Iridium::Task, DUNE::Control::PathController, Simulators::AcousticModem::Task, Plan::Generator::Task, Sensors::MiniSVS::Task, Simulators::UAVAutopilot::Task, Transports::SerialOverTCP::Task, Supervisors::PowerManager::Task, Sensors::XchangeSV::Task, Sensors::GillWindObserverII::Task, DUNE::Control::BasicAutopilot, DUNE::Control::BasicUAVAutopilot, and Transports::Fragments::Task.

Referenced by releaseResources().

virtual void DUNE::Tasks::Task::onUpdateParameters ( void  )
inlineprotectedvirtual

Called when the task is instructed to update its run-time parameters.

Derived classes that need to compute auxiliary values based on run-time parameters should override this function.

Reimplemented in Maneuver::VehicleFormation::FormCollAvoid::Task, Transports::Seatrac::Task, Sensors::MLBL::Task, Control::UAV::Ardupilot::Task, Maneuver::VehicleFormation::Coordinator::Task, Control::AUV::Attitude::Task, Control::UAV::PX4::Task, Transports::Radio::Task, Sensors::Imagenex881A::Task, Actuators::MCD4R::Task, Sensors::MetrecX::Task, Navigation::AUV::Navigation::Task, Vision::DFK51BG02H::Task, Control::ROV::RemoteOperation::Task, Vision::Lumenera::Task, Simulators::UAV::Task, Sensors::MLBLTracker::Task, Autonomy::TREX::Task, Monitors::FuelLevel::Task, Plan::Engine::Task, Sensors::OS4000::Task, Control::AUV::Speed::Task, Sensors::Microstrain3DMGX3::Task, Vision::UI2210MGL::Task, Control::AUV::Allocator::Task, Monitors::OperationalLimits::Task, Transports::UDP::Task, Actuators::LED4R::Task, Sensors::Microstrain3DMGX1::Task, Transports::GSM::Task, Power::LUEMB::Task, Sensors::IFOG::Task, Control::ROV::HorizontalPlane::Task, Power::CPMBv2::Task, Power::CPMB::Task, Transports::Announce::Task, Maneuver::VehicleFormation::Test::Task, Power::APD::Task, Autonomy::OnEvent::Task, Sensors::XR620CTD::Task, Supervisors::AUV::Assist::Task, Transports::DataStore::Task, Control::AUV::LMI::Task, Control::AUV::RemoteOperation::Task, Monitors::Emergency::Task, Control::ROV::Depth::Task, Transports::IridiumSBD::Task, DUNE::Navigation::BasicNavigation, Sensors::WifiRSSI::Task, Control::Path::LOSnSMC::Task, Vision::PhotoTrigger::Task, Control::Path::ILOS::Task, Navigation::General::ROV::Task, Sensors::CyclopsC7::Task, Transports::LoggingDigest::Task, Transports::Replay::Task, DUNE::Control::PathController, Navigation::General::GPSNavigation::Task, Supervisors::UAV::LostComms::Task, Vision::FrameGrabber::Task, Control::UAV::LOS::Task, Supervisors::Reporter::Task, Control::Path::VectorField::Task, Simulators::AcousticModem::Task, Sensors::DataStore::Task, Supervisors::Entities::Task, Transports::CommManager::Task, Control::AntennaTracker::Task, Control::UAV::RemoteOperation::Task, Simulators::UAVAutopilot::Task, Sensors::MiniSVS::Task, Navigation::AUV::Ranger::Task, Supervisors::PowerManager::Task, and Control::Path::PurePursuit::Task.

Referenced by updateParameters().

virtual bool DUNE::Tasks::Task::onWriteParamsXML ( std::ostream &  os) const
inlineprotectedvirtual

Referenced by writeParamsXML().

template<typename T >
Parameter& DUNE::Tasks::Task::param ( const std::string &  name,
T &  var 
)
inlineprotected
template<typename Y , typename T >
Parameter& DUNE::Tasks::Task::param ( const std::string &  name,
T &  var 
)
inlineprotected

Declare a configuration parameter that can be parsed using a custom parameter reader.

Template Parameters
Ytype of the custom parameter reader.
Ttype of the destination variable.
Parameters
[in]nameparameter name.
[in]varvariable that will hold the parameter value.
Returns
Parameter object.

References DUNE::Tasks::ParameterTable::add().

void DUNE::Tasks::Task::paramActive ( Parameter::Scope  def_scope,
Parameter::Visibility  def_visibility,
bool  def_value = false 
)
protected

Declare parameter 'Active' and associated parameters 'Active.

  • Scope' and 'Active - Visibility'. These parameters allows the task to be activated/deactivated using the message SetEntityParameters.
    Parameters
    [in]def_scopedefault scope of 'Active' parameter.
    [in]def_visibilitydefault visibility of 'Active' parameter.
    [in]def_valuedefault value of 'Active' parameter.

References DUNE::Tasks::Parameter::defaultValue(), param(), DUNE::Tasks::Parameter::scope(), DUNE::Tasks::Parameter::SCOPE_GLOBAL, DUNE::Tasks::Parameter::scopeToString(), DUNE::uncastLexical(), DUNE::Tasks::Parameter::visibility(), DUNE::Tasks::Parameter::VISIBILITY_DEVELOPER, and DUNE::Tasks::Parameter::visibilityToString().

Referenced by DUNE::Control::BasicRemoteOperation::BasicRemoteOperation(), and paramChanged().

template<typename T >
bool DUNE::Tasks::Task::paramChanged ( T &  var)
inlineprotected
void DUNE::Tasks::Task::receive ( const IMC::Message msg)
inlinevirtual
void DUNE::Tasks::Task::releaseResources ( void  )

Free all resources acquired in acquireResources().

References onResourceRelease().

Referenced by deactivationFailed(), and receive().

unsigned int DUNE::Tasks::Task::reserveEntity ( const std::string &  label)
protected
template<typename E >
E* DUNE::Tasks::Task::reserveEntity ( const std::string &  label)
inlineprotected

Associate an entity label with an internally stored entity object, and retrieve a pointer to the object.

Parameters
[in]labelentity name/label.
Returns
pointer to entity object.

References DUNE::Tasks::Context::entities, getLocalEntity(), getName(), and DUNE::Entities::EntityDataBase::reserve().

void DUNE::Tasks::Task::resolveEntities ( void  )

Instruct task to resolve all entity identifiers that it needs for normal execution.

References onEntityResolution(), onReportEntityState(), and DUNE::Entities::StatefulEntity::reportState().

Referenced by deactivationFailed(), and receive().

unsigned int DUNE::Tasks::Task::resolveEntity ( const std::string &  label) const
inline

Retrieve the entity id of a given entity label.

Parameters
[in]labelentity label.
Exceptions
NonexistentLabelif the label doesn't have an associated id.
Returns
entity id.

References DUNE::Tasks::Context::entities, m_ctx, and DUNE::Entities::EntityDataBase::resolve().

Referenced by DUNE::Tasks::SourceFilter::defineMessageSystemEntityFilter(), Vision::Lumenera::EntityActivation::entityActivationUpdate(), DUNE::Tasks::SourceFilter::match(), DUNE::Navigation::BasicNavigation::onEntityResolution(), and DUNE::Tasks::MessageFilter::setupEntities().

std::string DUNE::Tasks::Task::resolveEntity ( unsigned int  id) const
inline

Retrieve the entity label of a given entity id.

Parameters
[in]identity id.
Exceptions
NonexistentIdif the id doesn't have an associated label.
Returns
entity label.

References DUNE::Tasks::Context::entities, m_ctx, and DUNE::Entities::EntityDataBase::resolve().

const char* DUNE::Tasks::Task::resolveSystemId ( unsigned int  id) const
inline
unsigned int DUNE::Tasks::Task::resolveSystemName ( const std::string &  name) const
inline
void DUNE::Tasks::Task::setEntityLabel ( const std::string &  label)
inline

Set the main entity label of the task.

Parameters
[in]labelmain entity label.

References DUNE::Entities::BasicEntity::setLabel().

Referenced by DUNE::Daemon::Daemon().

void DUNE::Tasks::Task::setEntityState ( IMC::EntityState::StateEnum  state,
Status::Code  code 
)
inlineprotected

Set current entity state with an optional pre-defined description.

If a status code is not given, then the existing description will be kept.

Parameters
[in]stateentity state.
[in]codestatus code.

References DUNE::Entities::StatefulEntity::setState().

Referenced by DUNE::Control::BasicAutopilot::BasicAutopilot(), DUNE::Hardware::BasicDeviceDriver::BasicDeviceDriver(), DUNE::Control::BasicUAVAutopilot::BasicUAVAutopilot(), DUNE::Navigation::BasicNavigation::checkUncertainty(), DUNE::Control::BasicRemoteOperation::consume(), DUNE::Hardware::BasicDeviceDriver::consume(), DUNE::Control::BasicAutopilot::consume(), Actuators::PWM::Task::consume(), DUNE::Navigation::BasicNavigation::consume(), deactivationFailed(), DUNE::Maneuvers::Maneuver::onActivation(), DUNE::Control::BasicUAVAutopilot::onActivation(), DUNE::Control::BasicAutopilot::onActivation(), DUNE::Maneuvers::Maneuver::onDeactivation(), DUNE::Control::BasicUAVAutopilot::onDeactivation(), DUNE::Control::BasicAutopilot::onDeactivation(), Actuators::PWM::Task::onMain(), DUNE::Maneuvers::Maneuver::onResourceInitialization(), Transports::LogBook::Task::onResourceInitialization(), DUNE::Daemon::onResourceInitialization(), Autonomy::TextActions::Task::onResourceInitialization(), Supervisors::PowerManager::Task::onResourceInitialization(), Actuators::PWM::Task::onResourceInitialization(), DUNE::Control::BasicRemoteOperation::onResourceInitialization(), DUNE::Navigation::BasicNavigation::reset(), DUNE::Control::BasicAutopilot::signalBadVertical(), DUNE::Control::BasicAutopilot::signalBadYaw(), DUNE::Control::PathController::signalError(), and DUNE::Daemon::writeParamsXML().

void DUNE::Tasks::Task::setEntityState ( IMC::EntityState::StateEnum  state,
const std::string &  description 
)
inlineprotected

Set current entity state with a custom description.

Parameters
[in]stateentity state.
[in]descriptioncustom state description.

References DUNE::Entities::StatefulEntity::setState().

void DUNE::Tasks::Task::setParamSectionEditor ( const std::string &  name)
inlineprotected

Set the name of the parameter editor that should be used to interact with the parameters of the task.

Parameters
[in]nameeditor name (free-form string).
void DUNE::Tasks::Task::setPriority ( unsigned int  value)
inline

Set scheduling priority programatically.

The priority of a task might change when configuration parameters are updated.

Parameters
[in]valuedesired scheduling priority.

Referenced by DUNE::Tasks::Manager::adjustPriorities(), deactivationFailed(), and DUNE::Daemon::onResourceInitialization().

void DUNE::Tasks::Task::waitForMessages ( double  timeout)
inlineprotected
void DUNE::Tasks::Task::writeParamsXML ( std::ostream &  os) const

Write task parameters in XML format.

Parameters
[in]osoutput stream.

References getEntityLabel(), onWriteParamsXML(), and DUNE::Tasks::ParameterTable::writeXML().

Referenced by receive().

Member Data Documentation

std::vector<Entities::BasicEntity*> DUNE::Tasks::Task::m_entities
protected

Owned entity list.

Referenced by getLocalEntity(), reserveEntity(), Task(), and ~Task().

Collaboration diagram for DUNE::Tasks::Task:
Collaboration graph