DUNE: Uniform Navigational Environment  2017.01.0
Transports::Seatrac::Task Struct Reference

Public Member Functions

 Task (const std::string &name, Tasks::Context &ctx)
 
void setAndSendState (EntityStates state)
 
bool processSentence (void)
 
void processNewData (void)
 
void readSentence (void)
 
bool openSocket (void)
 
void onResourceAcquisition (void)
 
void onResourceInitialization (void)
 
void onResourceRelease (void)
 
void sendCommandAndWait (const std::string &cmd, double delay_aft)
 
void sendProtectedCommand (const std::string &cmd)
 
void sendCommand (const std::string &cmd)
 
bool hasConnection (void)
 
void handleBinaryMessage (void)
 
void handleRxMessage (const std::string &str)
 
void handleAcousticInformation (const Acofix_t &aco_fix)
 
void handleCommunicationError (void)
 
void handleDatSendResponse (void)
 
void consume (const IMC::UamTxFrame *msg)
 
void sendTxStatus (const Ticket &ticket, IMC::UamTxStatus::ValueEnum value, const std::string &error="")
 
void clearTicket (IMC::UamTxStatus::ValueEnum reason, const std::string &error="")
 
void replaceTicket (const Ticket &ticket)
 
unsigned lookupSystemAddress (const std::string &name)
 
std::string lookupSystemName (unsigned addr)
 
void processInput (double timeout=1.0)
 
void consume (const IMC::VehicleMedium *msg)
 
void checkTxOWAY (void)
 
void onMain (void)
 
- Public Member Functions inherited from DUNE::Tasks::Task
 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)
 

Public Attributes

IO::Handle * m_handle
 
Arguments m_args
 
EntityStates m_state_entity
 
IMC::EntityState m_states [STA_MAX]
 
bool m_stop_comms
 
bool m_usbl_receiver
 
unsigned m_addr
 
std::string m_data
 
std::string m_datahex
 
DataSeatrac m_data_beacon
 
double m_last_input
 
Time::Counter< double > m_oway_timer
 
MapName m_modem_names
 
MapAddr m_modem_addrs
 
Ticketm_ticket
 
IMC::DevDataText m_dev_data
 

Additional Inherited Members

- Public Types inherited from DUNE::Concurrency::Runnable
enum  State {
  StateStarting, StateRunning, StateStopping, StateDead,
  StateUnknown
}
 
- Protected Member Functions inherited from DUNE::Tasks::Task
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)
 
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 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)
 
- 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 inherited from DUNE::Tasks::Task
Contextm_ctx
 
std::vector
< Entities::BasicEntity * > 
m_entities
 

Constructor & Destructor Documentation

Member Function Documentation

void Transports::Seatrac::Task::clearTicket ( IMC::UamTxStatus::ValueEnum  reason,
const std::string &  error = "" 
)
inline

Clear ticket.

Parameters
[in]reasonreason value.
[in]errorerror message.

References m_ticket, and sendTxStatus().

Referenced by checkTxOWAY(), handleBinaryMessage(), handleCommunicationError(), onResourceRelease(), replaceTicket(), and sendProtectedCommand().

void Transports::Seatrac::Task::consume ( const IMC::VehicleMedium *  msg)
inline
void Transports::Seatrac::Task::handleCommunicationError ( void  )
inline

Handle errors of communication with both local and remote beacon.

The method tries to send the packet again until it reaches the maximum number of retries.

See Also
MAX_MESSAGE_ERRORS.

References Transports::Seatrac::CID_DAT_SEND, Transports::Seatrac::DataSeatrac::cid_dat_send_msg, clearTicket(), Transports::Seatrac::commandCreateSeatrac(), m_data_beacon, m_oway_timer, Transports::Seatrac::CidDatSendMsg::packetDataNextPart(), sendProtectedCommand(), and DUNE::Tasks::Task::war().

Referenced by handleDatSendResponse(), and processNewData().

void Transports::Seatrac::Task::handleDatSendResponse ( void  )
inline

Handle the response to a CID_Data_Send command.

If the acknowledged message is an OWAY and it is compound by more than one packet, the method sends the following packet. If the sending fails, it tries to send the packet again. If the modem is busy, it tries to send the packet to poll the status.

References Transports::Seatrac::CID_DAT_SEND, Transports::Seatrac::DataSeatrac::cid_dat_send_msg, Transports::Seatrac::commandCreateSeatrac(), Transports::Seatrac::CST_OK, Transports::Seatrac::CST_XCVR_BUSY, handleCommunicationError(), m_data_beacon, m_oway_timer, Transports::Seatrac::MSG_OWAY, Transports::Seatrac::MSG_OWAYU, Transports::Seatrac::CidDatSendMsg::msg_type, Transports::Seatrac::CidDatSendMsg::packet_len, Transports::Seatrac::CidDatSendMsg::packetDataNextPart(), sendProtectedCommand(), and Transports::Seatrac::CidDatSendMsg::status.

Referenced by processNewData().

void Transports::Seatrac::Task::handleRxMessage ( const std::string &  str)
inline
bool Transports::Seatrac::Task::hasConnection ( void  )
inline

Checks if the modem is working.

Returns
true if modem has a new message.

References Transports::Seatrac::CID_STATUS, m_data_beacon, and Transports::Seatrac::DataSeatrac::new_message.

Referenced by onResourceInitialization().

unsigned Transports::Seatrac::Task::lookupSystemAddress ( const std::string &  name)
inline

Lookup system address.

Parameters
[in]namesystem name
Returns
system address.

References m_modem_names.

Referenced by consume().

std::string Transports::Seatrac::Task::lookupSystemName ( unsigned  addr)
inline

Lookup system name.

Parameters
[in]addrsystem address.
Returns
system name.

References m_modem_addrs.

Referenced by handleAcousticInformation(), and handleRxMessage().

void Transports::Seatrac::Task::onMain ( void  )
inlinevirtual
void Transports::Seatrac::Task::onResourceAcquisition ( void  )
inlinevirtual
void Transports::Seatrac::Task::onResourceInitialization ( void  )
inlinevirtual

Initialize resources and configure modem.

Reimplemented from DUNE::Tasks::Task.

References Transports::Seatrac::ACC_CAL_FLAG, Transports::Seatrac::Arguments::addr_section, Transports::Seatrac::AHRS_COMP_DATA_FLAG, Transports::Seatrac::AHRS_RAW_DATA_FLAG, Transports::Seatrac::ATTITUDE_FLAG, Transports::Seatrac::BT_X150, Transports::Seatrac::CID_SETTINGS_GET, Transports::Seatrac::DataSeatrac::cid_settings_msg, Transports::Seatrac::CID_SETTINGS_SAVE, Transports::Seatrac::CID_SETTINGS_SET, Transports::Seatrac::DataSeatrac::cid_sys_info, Transports::Seatrac::CID_SYS_INFO, Transports::Seatrac::CID_SYS_REBOOT, Transports::Seatrac::commandCreateSeatrac(), DUNE::Tasks::Context::config, DUNE::Tasks::Task::debug(), Transports::Seatrac::ENVIRONMENT_FLAG, DUNE::Tasks::Task::err(), DUNE::Parsers::Config::get(), DUNE::Tasks::Task::getSystemName(), Transports::Seatrac::CidSysInfo::hardware, hasConnection(), m_addr, m_args, DUNE::Tasks::Task::m_ctx, m_data_beacon, m_last_input, m_modem_addrs, m_modem_names, m_state_entity, m_states, m_usbl_receiver, Transports::Seatrac::MAG_CAL_FLAG, Transports::Seatrac::DataSeatrac::newDataAvailable(), DUNE::Parsers::Config::options(), Transports::Seatrac::Hardware_t::part_number, processInput(), sendCommand(), sendCommandAndWait(), setAndSendState(), Transports::Seatrac::STA_ERR_STP, Transports::Seatrac::STA_IDLE, Transports::Seatrac::CidSettingsMsg::status_flags, Transports::Seatrac::STATUS_MODE_1HZ, Transports::Seatrac::CidSettingsMsg::status_output, Transports::Seatrac::USBL_USE_AHRS_FLAG, DUNE::Tasks::Task::war(), Transports::Seatrac::CidSettingsMsg::xcvr_beacon_id, Transports::Seatrac::XCVR_FIX_MSGS_FLAG, Transports::Seatrac::CidSettingsMsg::xcvr_flags, Transports::Seatrac::XCVR_POSFLT_ENABLE_FLAG, and Transports::Seatrac::XCVR_USBL_MSGS_FLAG.

void Transports::Seatrac::Task::onResourceRelease ( void  )
inlinevirtual

Release resources.

Reimplemented from DUNE::Tasks::Task.

References clearTicket(), and m_handle.

bool Transports::Seatrac::Task::openSocket ( void  )
inline

Open TCP socket.

Returns
true if socket was opened, false otherwise.

References m_args, m_handle, and Transports::Seatrac::Arguments::uart_dev.

Referenced by onResourceAcquisition().

void Transports::Seatrac::Task::processInput ( double  timeout = 1.0)
inline
bool Transports::Seatrac::Task::processSentence ( void  )
inline

Process sentence.

Returns
true if message was correctly processed, false otherwise.

References m_data, m_datahex, and DUNE::Tasks::Task::war().

Referenced by readSentence().

void Transports::Seatrac::Task::replaceTicket ( const Ticket ticket)
inline

Replace ticket.

Parameters
[in]ticketnew ticket to replace previous one.

References clearTicket(), and m_ticket.

Referenced by consume().

void Transports::Seatrac::Task::sendCommand ( const std::string &  cmd)
inline

Send command to the acoustic modem.

Parameters
[in]cmdcommand string.

References DUNE::Tasks::Task::dispatch(), m_dev_data, and m_handle.

Referenced by onResourceInitialization(), sendCommandAndWait(), and sendProtectedCommand().

void Transports::Seatrac::Task::sendCommandAndWait ( const std::string &  cmd,
double  delay_aft 
)
inline

Send command and waits for response.

Parameters
[in]cmdcommand string.
[in]delay_befdelay before send comamnd.
[in]delay_aftdelay after send comamnd.

References processInput(), and sendCommand().

Referenced by onResourceInitialization().

void Transports::Seatrac::Task::sendProtectedCommand ( const std::string &  cmd)
inline
void Transports::Seatrac::Task::sendTxStatus ( const Ticket ticket,
IMC::UamTxStatus::ValueEnum  value,
const std::string &  error = "" 
)
inline

Updates transmission status.

Parameters
[in]ticketticket status to be transmitted.
[in]valuestatus index.
[in]errorerror message.

References DUNE::Tasks::Task::dispatch(), Transports::Seatrac::Ticket::imc_eid, Transports::Seatrac::Ticket::imc_sid, and Transports::Seatrac::Ticket::seq.

Referenced by clearTicket(), and consume().

void Transports::Seatrac::Task::setAndSendState ( EntityStates  state)
inline

Set entity state.

Parameters
[in]statenew entity state.

References m_state_entity, m_states, and DUNE::Tasks::Task::setEntityState().

Referenced by onMain(), onResourceAcquisition(), onResourceInitialization(), and processInput().

Member Data Documentation

unsigned Transports::Seatrac::Task::m_addr

Modem address.

Referenced by handleRxMessage(), and onResourceInitialization().

Arguments Transports::Seatrac::Task::m_args
std::string Transports::Seatrac::Task::m_data

Data buffer.

Referenced by processSentence(), and readSentence().

std::string Transports::Seatrac::Task::m_datahex

Converted data buffer.

Referenced by processSentence(), and readSentence().

IMC::DevDataText Transports::Seatrac::Task::m_dev_data

Referenced by readSentence(), and sendCommand().

IO::Handle* Transports::Seatrac::Task::m_handle
double Transports::Seatrac::Task::m_last_input

Time of last serial port input.

Referenced by onMain(), onResourceInitialization(), and readSentence().

MapAddr Transports::Seatrac::Task::m_modem_addrs

Map of seatrac modems by address.

Referenced by lookupSystemName(), and onResourceInitialization().

MapName Transports::Seatrac::Task::m_modem_names

Map of seatrac modems by name.

Referenced by lookupSystemAddress(), and onResourceInitialization().

Time::Counter<double> Transports::Seatrac::Task::m_oway_timer

Timer to manage the fragmentation of OWAY messages.

Referenced by checkTxOWAY(), consume(), handleCommunicationError(), and handleDatSendResponse().

EntityStates Transports::Seatrac::Task::m_state_entity

Current state.

Referenced by onResourceInitialization(), processInput(), and setAndSendState().

IMC::EntityState Transports::Seatrac::Task::m_states[STA_MAX]

Entity states.

Referenced by onResourceInitialization(), setAndSendState(), and Task().

bool Transports::Seatrac::Task::m_stop_comms

Stop reports on the ground.

Referenced by consume(), and sendProtectedCommand().

Ticket* Transports::Seatrac::Task::m_ticket

Current transmission ticket.

Referenced by clearTicket(), handleAcousticInformation(), and replaceTicket().

bool Transports::Seatrac::Task::m_usbl_receiver

True if the beacon has an USBL receiver.

Referenced by handleAcousticInformation(), and onResourceInitialization().

Collaboration diagram for Transports::Seatrac::Task:
Collaboration graph