DUNE: Uniform Navigational Environment  2017.01.0
Power::MCBv2::Task Struct Reference

Public Types

typedef std::map< std::string,
PowerChannel * > 
PowerChannelMap
 

Public Member Functions

 Task (const std::string &name, Tasks::Context &ctx)
 
 ~Task (void)
 
void onUpdateParameters (void)
 
void clearPowerChannels (void)
 
void onEntityReservation (void)
 
void onResourceAcquisition (void)
 
void onResourceInitialization (void)
 
void packParam (unsigned index, double value, uint8_t *bfr)
 
void updateParams (void)
 
void controlPowerChannel (PowerChannel *channel, IMC::PowerChannelControl::OperationEnum op, double sched=-1.0)
 
void writeLCD (unsigned line, const uint8_t *data, unsigned data_len)
 
void consume (const IMC::LcdControl *msg)
 
void consume (const IMC::PowerChannelControl *msg)
 
void consume (const IMC::QueryPowerChannelState *msg)
 
void onCommand (uint8_t cmd, const uint8_t *data, int data_size)
 
void sendMessages (const uint16_t *unpack)
 
bool waitForCommand (uint8_t code)
 
void onVersion (unsigned major, unsigned minor, unsigned patch)
 
void checkSchedules (void)
 
void updatePowerChannels (void)
 
void onMain (void)
 

Public Attributes

Arguments m_args
 
Hardware::LUCL::Protocol m_proto
 
bool m_pwr_down
 
uint16_t m_pwr_chns
 
MCP23017m_gpios
 
bool m_halt
 
IMC::Message * m_adcs [c_adcs_count]
 
PowerChannelMap m_pwr_chs
 

Static Public Attributes

static const uint8_t c_addr
 

Member Typedef Documentation

typedef std::map<std::string, PowerChannel*> Power::MCBv2::Task::PowerChannelMap

Convenience type definition for a table of power channels.

Constructor & Destructor Documentation

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

References clearPowerChannels(), m_adcs, and m_gpios.

Member Function Documentation

void Power::MCBv2::Task::checkSchedules ( void  )
inline
void Power::MCBv2::Task::clearPowerChannels ( void  )
inline

References m_pwr_chs.

Referenced by onUpdateParameters(), and ~Task().

void Power::MCBv2::Task::consume ( const IMC::LcdControl *  msg)
inline
void Power::MCBv2::Task::consume ( const IMC::PowerChannelControl *  msg)
inline
void Power::MCBv2::Task::consume ( const IMC::QueryPowerChannelState *  msg)
inline

References m_pwr_chs.

void Power::MCBv2::Task::controlPowerChannel ( PowerChannel channel,
IMC::PowerChannelControl::OperationEnum  op,
double  sched = -1.0 
)
inline
void Power::MCBv2::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::MCBv2::BIT_SW_SYS_ON, Power::MCBv2::CMD_STATE, m_pwr_down, and sendMessages().

Referenced by waitForCommand().

void Power::MCBv2::Task::onEntityReservation ( void  )
inline

Reserve entities.

References Power::MCBv2::Arguments::adc_elabels, m_adcs, and m_args.

void Power::MCBv2::Task::onMain ( void  )
inline
void Power::MCBv2::Task::onResourceAcquisition ( void  )
inline
void Power::MCBv2::Task::onResourceInitialization ( void  )
inline

Initialize resources.

References controlPowerChannel(), m_proto, m_pwr_chs, updateParams(), and waitForCommand().

void Power::MCBv2::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.

Referenced by waitForCommand().

void Power::MCBv2::Task::packParam ( unsigned  index,
double  value,
uint8_t *  bfr 
)
inline

Write value to position in a given buffer.

Parameters
[in]indexposition index.
[in]valuevalue to be written.
[out]bfrbuffer.

Referenced by updateParams().

void Power::MCBv2::Task::sendMessages ( const uint16_t *  unpack)
inline

Send Message.

Parameters
[in]unpackpointer to unpacked data buffer.

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

Referenced by onCommand().

void Power::MCBv2::Task::updatePowerChannels ( void  )
inline

References m_pwr_chns, and m_pwr_chs.

Referenced by onMain().

bool Power::MCBv2::Task::waitForCommand ( uint8_t  code)
inline

Wait for command.

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

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

Referenced by onMain(), onResourceInitialization(), updateParams(), and writeLCD().

void Power::MCBv2::Task::writeLCD ( unsigned  line,
const uint8_t *  data,
unsigned  data_len 
)
inline

Member Data Documentation

const uint8_t Power::MCBv2::Task::c_addr
static

Device I2C address.

Referenced by onResourceAcquisition().

IMC::Message* Power::MCBv2::Task::m_adcs[c_adcs_count]
MCP23017* Power::MCBv2::Task::m_gpios

GPIO controller.

Referenced by controlPowerChannel(), onResourceAcquisition(), and ~Task().

bool Power::MCBv2::Task::m_halt

True if system was shutdown.

Referenced by consume(), and onMain().

Hardware::LUCL::Protocol Power::MCBv2::Task::m_proto
uint16_t Power::MCBv2::Task::m_pwr_chns

Power channels (1 bit per channel).

Referenced by consume(), controlPowerChannel(), onResourceAcquisition(), and updatePowerChannels().

bool Power::MCBv2::Task::m_pwr_down

True if power down is in progress.

Referenced by onCommand().

Collaboration diagram for Power::MCBv2::Task:
Collaboration graph