DUNE: Uniform Navigational Environment  2016.09.0
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

References m_adcs.

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

References m_led_bright, and m_led_map.

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

Dispatch power channel state messages to bus.

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

Referenced by consume().

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, Power::PCTLv2::CMD_TEMP, m_temp, processADCs(), processLeaks(), processMode(), and processPowerInfo().

Referenced by waitForCommand().

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

Report leak entities.

References m_leaks.

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.

References updateEEPROM().

Referenced by waitForCommand().

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

Process data from ADCs.

Parameters
[in]datadata buffer.

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

Referenced by onCommand().

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

Process data from leak sensors.

Parameters
[in]datadata buffer.

References setLeakStatus().

Referenced by onCommand().

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

Process device mode.

Parameters
[in]datadata buffer.

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

Referenced by onCommand().

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

Process power information.

Parameters
[in]datadata buffer.

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

Referenced by onCommand().

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, m_args, and m_leaks.

Referenced by processLeaks().

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, m_proto, and waitForCommand().

Referenced by onResourceInitialization(), and onResourceRelease().

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.

References m_proto, m_wdog, onCommand(), and onVersion().

Referenced by consume(), onMain(), onResourceRelease(), setPowerChannelState(), and updateEEPROM().

Member Data Documentation

IMC::Message* Power::PCTLv2::Task::m_adcs[c_adcs_count]
IMC::EntityState Power::PCTLv2::Task::m_leaks[c_leak_count]

Leak detection.

Referenced by onEntityReservation(), onReportEntityState(), and setLeakStatus().

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

LED brightness.

Referenced by consume(), and onUpdateParameters().

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

LED name to id map.

Referenced by consume(), and onUpdateParameters().

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

Power down is in progress.

Referenced by processMode().

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

Power operation.

Referenced by processMode(), and Task().

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

State timer.

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

Temperature.

Referenced by onCommand().

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

Watchdog.

Referenced by onMain(), onResourceAcquisition(), and waitForCommand().

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