DUNE: Uniform Navigational Environment  2019.02.1
Power::PCTLv2::Task Struct Reference

Public Member Functions

 Task (const std::string &name, Tasks::Context &ctx)
 
 ~Task (void)
 
void onUpdateParameters (void)
 
void onEntityReservation (void)
 
void onResourceAcquisition (void)
 
void onResourceRelease (void)
 
void onResourceInitialization (void)
 
void updateEEPROM (bool version_pre24)
 
void processADCs (const uint8_t *data)
 
void processLeaks (const uint8_t *data)
 
void processPowerInfo (const uint8_t *data)
 
void processMode (const uint8_t *data)
 
void onCommand (uint8_t cmd, const uint8_t *data, int data_size)
 
void onVersion (unsigned major, unsigned minor, unsigned patch)
 
bool waitForCommand (uint8_t code, unsigned retries=10)
 
void setLeakStatus (int idx, bool leak)
 
void setPowerChannelState (unsigned channel, unsigned state)
 
void onReportEntityState (void)
 
void consume (const IMC::QueryPowerChannelState *msg)
 
void consume (const IMC::PowerChannelControl *msg)
 
void consume (const IMC::SetLedBrightness *msg)
 
void consume (const IMC::QueryLedBrightness *msg)
 
void dispatchPowerChannelStates (void)
 
void onMain (void)
 

Public Attributes

Hardware::LUCL::Protocol m_proto
 
IMC::Message * m_adcs [c_adcs_count]
 
IMC::EntityState m_leaks [c_leak_count]
 
PowerChannels m_channels
 
IMC::PowerOperation m_pwr_op
 
IMC::LedBrightness m_led_bright [c_led_count]
 
bool m_pwr_down
 
IMC::Temperature m_temp
 
Time::Counter< double > m_wdog
 
Time::Counter< double > m_state_timer
 
Arguments m_args
 
std::map< std::string, unsigned > m_led_map
 

Constructor & Destructor Documentation

Power::PCTLv2::Task::~Task ( void  )
inline

Member Function Documentation

void Power::PCTLv2::Task::consume ( const IMC::QueryPowerChannelState *  msg)
inline
void Power::PCTLv2::Task::consume ( const IMC::SetLedBrightness *  msg)
inline
void Power::PCTLv2::Task::consume ( const IMC::QueryLedBrightness *  msg)
inline
void Power::PCTLv2::Task::dispatchPowerChannelStates ( void  )
inline

Dispatch power channel state messages to bus.

References Power::PCTLv2::PowerChannels::begin(), and Power::PCTLv2::PowerChannels::end().

void Power::PCTLv2::Task::onCommand ( uint8_t  cmd,
const uint8_t *  data,
int  data_size 
)
inline

On Command call.

Parameters
[in]cmdcommand.
[in]databuffer of data.
[in]data_sizesize of data.

References Power::PCTLv2::CMD_STATE, and Power::PCTLv2::CMD_TEMP.

void Power::PCTLv2::Task::onEntityReservation ( void  )
inline
void Power::PCTLv2::Task::onMain ( void  )
inline
void Power::PCTLv2::Task::onReportEntityState ( void  )
inline

Report leak entities.

void Power::PCTLv2::Task::onResourceAcquisition ( void  )
inline
void Power::PCTLv2::Task::onResourceInitialization ( void  )
inline
void Power::PCTLv2::Task::onResourceRelease ( void  )
inline
void Power::PCTLv2::Task::onVersion ( unsigned  major,
unsigned  minor,
unsigned  patch 
)
inline

On version call.

Parameters
[in]majormajor version number.
[in]minorminor version number.
[in]patchpatch version number.
void Power::PCTLv2::Task::processADCs ( const uint8_t *  data)
inline

Process data from ADCs.

Parameters
[in]datadata buffer.

References Power::PCTLv2::Arguments::adc_factors, and Power::PCTLv2::Arguments::adc_ref.

void Power::PCTLv2::Task::processLeaks ( const uint8_t *  data)
inline

Process data from leak sensors.

Parameters
[in]datadata buffer.
void Power::PCTLv2::Task::processMode ( const uint8_t *  data)
inline

Process device mode.

Parameters
[in]datadata buffer.

References Power::PCTLv2::PWR_MODE_EMERGENCY, Power::PCTLv2::PWR_MODE_EMERGENCY_IP, and Power::PCTLv2::PWR_MODE_OFF_IP.

void Power::PCTLv2::Task::processPowerInfo ( const uint8_t *  data)
inline

Process power information.

Parameters
[in]datadata buffer.

References Power::PCTLv2::PowerChannels::begin(), and Power::PCTLv2::PowerChannels::end().

void Power::PCTLv2::Task::setLeakStatus ( int  idx,
bool  leak 
)
inline

Set Leak status.

Parameters
[in]idxleak index.
[in]leakleak status.

References Power::PCTLv2::Arguments::leak_medium.

void Power::PCTLv2::Task::setPowerChannelState ( unsigned  channel,
unsigned  state 
)
inline

Define power channel state.

Parameters
[in]channelchannel.
[in]statestate of the power channel.

References Power::PCTLv2::CMD_PWR_CTL.

bool Power::PCTLv2::Task::waitForCommand ( uint8_t  code,
unsigned  retries = 10 
)
inline

Wait for command.

Parameters
[in]codecommand code.
[in]retriesnumber of retries.
Returns
true if succcessful, false otherwise.

Member Data Documentation

IMC::Message* Power::PCTLv2::Task::m_adcs[c_adcs_count]

ADC messages.

Arguments Power::PCTLv2::Task::m_args

Task arguments.

PowerChannels Power::PCTLv2::Task::m_channels

Power channels.

IMC::EntityState Power::PCTLv2::Task::m_leaks[c_leak_count]

Leak detection.

IMC::LedBrightness Power::PCTLv2::Task::m_led_bright[c_led_count]

LED brightness.

std::map<std::string, unsigned> Power::PCTLv2::Task::m_led_map

LED name to id map.

Hardware::LUCL::Protocol Power::PCTLv2::Task::m_proto

Device protocol handler.

bool Power::PCTLv2::Task::m_pwr_down

Power down is in progress.

IMC::PowerOperation Power::PCTLv2::Task::m_pwr_op

Power operation.

Time::Counter<double> Power::PCTLv2::Task::m_state_timer

State timer.

IMC::Temperature Power::PCTLv2::Task::m_temp

Temperature.

Time::Counter<double> Power::PCTLv2::Task::m_wdog

Watchdog.

Collaboration diagram for Power::PCTLv2::Task:
Collaboration graph