ethercatcpp
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ethercatcpp::coe::PDOBuffer Class Reference

#include <coe_utilities.h>

Public Member Functions

 PDOBuffer ()=delete
 
 PDOBuffer (bool is_tx, uint16_t addr_, uint32_t flags_)
 
template<typename... T>
 PDOBuffer (bool is_tx, uint16_t addr, uint32_t flags, T &&... mappings)
 
bool add_mapping (const PDOMapping &mapping, bool may_throw=false)
 add a mapping to the buffer More...
 
template<typename... T>
void add_mappings (T &&... mappings)
 Fill buffer from a list of mappings. More...
 
void bind (uint8_t *data)
 Bind the buffer to a memory zone. More...
 
bool contains_mapping (const PDOMapping &mapping) const
 Tell whether the buffer contains a given mapping. More...
 
size_t mapping_memory_shift (const PDOMapping &mapping) const
 Get the shift in buffer memory to access mapping data. More...
 
size_t entry_memory_shift (const PDOMapping &mapping, std::string_view entry) const
 Get the shift in buffer memory to access a mapping entry data. More...
 
template<typename T >
T & map_memory (const PDOMapping &mapping, std::string_view entry_name)
 Map the entry of a mapping to a typed reference. More...
 
template<typename T >
const T & map_memory (const PDOMapping &mapping, std::string_view entry_name) const
 Map the entry of a mapping to a typed const reference. More...
 
template<typename T >
T & map_memory (const PDOMapping &mapping)
 Map a mapping to a typed reference. More...
 
template<typename T >
const T & map_memory (const PDOMapping &mapping) const
 Map a mapping to a typed reference. More...
 
template<typename T , typename U , typename... Other>
std::tuple< T &, U &, Other &... > map_memory ()
 Map the entire buffer to a typed reference. More...
 
template<typename T , typename U , typename... Other>
std::tuple< const T &, const U &, const Other &... > map_memory () const
 Map the entire buffer to a typed const reference. More...
 
template<typename T >
T & map_memory ()
 Map the entire buffer to a typed reference. More...
 
template<typename T >
const T & map_memory () const
 Map the entire buffer to a typed rconst eference. More...
 
uint16_t memory_size () const
 Get size of the buffer in memory. More...
 
void define_physical_buffer (SlaveDevice &eth_slave)
 define the physical buffer of an ethercat slave More...
 
bool configure (SlaveDevice &eth_slave) const
 Configure an ethercat unit device with the corresponding buffer and mappings. More...
 
bool assign (SlaveDevice &eth_slave) const
 Configure an ethercat unit device with the corresponding assigned PDO mappings. More...
 
void bind_physical_buffer (SlaveDevice &eth_slave)
 bind internal memory zone to the physical buffer of an ethercat slave More...
 

Private Member Functions

void check_mapping_throws (const PDOMapping &mapping) const
 
void check_mapping_size_throws (const PDOMapping &mapping, size_t bytes) const
 
uint8_t * map_memory_internal (const PDOMapping &mapping, size_t bytes)
 
const uint8_t * map_memory_internal (const PDOMapping &mapping, size_t bytes) const
 
const uint8_t * map_memory_internal (const PDOMapping &mapping, std::string_view entry_name, size_t bytes) const
 
uint8_t * map_memory_internal (const PDOMapping &mapping, std::string_view entry_name, size_t bytes)
 
void check_entry_throws (const PDOMapping &mapping, std::string_view entry_name, size_t bytes) const
 
size_t compute_shift (const PDOMapping &mapping, std::string_view entry_name) const
 
const PDOMapping & access_mapping (size_t idx) const
 
template<typename T >
std::tuple< T & > map_memory_tuple (size_t mapping_increment)
 
template<typename T , typename U , typename... Other>
std::tuple< T &, U &, Other &... > map_memory_tuple (size_t mapping_increment)
 
template<typename T , typename U , typename... Other>
std::tuple< const T &, const U &, const Other &... > map_memory_tuple (size_t mapping_increment) const
 
template<typename T >
std::tuple< const T & > map_memory_tuple (size_t mapping_increment) const
 

Private Attributes

std::vector< const PDOMapping * > mappings_
 
uint8_t * data_
 
bool is_tx_
 
uint16_t addr_
 
uint32_t flags_
 

Constructor & Destructor Documentation

◆ PDOBuffer() [1/3]

ethercatcpp::coe::PDOBuffer::PDOBuffer ( )
delete

◆ PDOBuffer() [2/3]

ethercatcpp::coe::PDOBuffer::PDOBuffer ( bool  is_tx,
uint16_t  addr_,
uint32_t  flags_ 
)

◆ PDOBuffer() [3/3]

template<typename... T>
ethercatcpp::coe::PDOBuffer::PDOBuffer ( bool  is_tx,
uint16_t  addr,
uint32_t  flags,
T &&...  mappings 
)
inline

Member Function Documentation

◆ access_mapping()

const PDOMapping& ethercatcpp::coe::PDOBuffer::access_mapping ( size_t  idx) const
private

◆ add_mapping()

bool ethercatcpp::coe::PDOBuffer::add_mapping ( const PDOMapping &  mapping,
bool  may_throw = false 
)

add a mapping to the buffer

Parameters
mappingthe mapping to add
Returns
true if mapping added false otherwise

◆ add_mappings()

template<typename... T>
void ethercatcpp::coe::PDOBuffer::add_mappings ( T &&...  mappings)
inline

Fill buffer from a list of mappings.

Template Parameters
Tis a variadic template made of any number of PDOMapping
Parameters
mappingsthe list of PDO mappings

◆ assign()

bool ethercatcpp::coe::PDOBuffer::assign ( SlaveDevice &  eth_slave) const

Configure an ethercat unit device with the corresponding assigned PDO mappings.

this call is intended to be used in configuration function (configure_at_init()). Copared to configure() this function only performs assignment but no mapping definition.

Parameters
eth_slavethe unit device to configure
Returns
true if configuration succeeded, false otherwise
See also
configure_at_init()

◆ bind()

void ethercatcpp::coe::PDOBuffer::bind ( uint8_t *  data)

Bind the buffer to a memory zone.

Parameters
datathe pointer to the memory zone to bind

◆ bind_physical_buffer()

void ethercatcpp::coe::PDOBuffer::bind_physical_buffer ( SlaveDevice &  eth_slave)

bind internal memory zone to the physical buffer of an ethercat slave

this function must be called during call to master init() function. To do so, use it in init_step function of the device. The call to define_physical_buffer() is not mandatory as long as the physical buffer has been correctly defined with same parameters (addr and flags) as those used in this object. After this call all "map_memory" functions can be used.

Parameters
eth_slavethe target unit device
See also
map_memory()

◆ check_entry_throws()

void ethercatcpp::coe::PDOBuffer::check_entry_throws ( const PDOMapping &  mapping,
std::string_view  entry_name,
size_t  bytes 
) const
private

◆ check_mapping_size_throws()

void ethercatcpp::coe::PDOBuffer::check_mapping_size_throws ( const PDOMapping &  mapping,
size_t  bytes 
) const
private

◆ check_mapping_throws()

void ethercatcpp::coe::PDOBuffer::check_mapping_throws ( const PDOMapping &  mapping) const
private

◆ compute_shift()

size_t ethercatcpp::coe::PDOBuffer::compute_shift ( const PDOMapping &  mapping,
std::string_view  entry_name 
) const
private

◆ configure()

bool ethercatcpp::coe::PDOBuffer::configure ( SlaveDevice &  eth_slave) const

Configure an ethercat unit device with the corresponding buffer and mappings.

this call is intended to be used in configuration function (configure_at_init()). If your code use predefined mappings and assignment simply do not call this function.

Parameters
eth_slavethe unit device to configure
Returns
true if configuration succeeded, false otherwise
See also
configure_at_init()

◆ contains_mapping()

bool ethercatcpp::coe::PDOBuffer::contains_mapping ( const PDOMapping &  mapping) const

Tell whether the buffer contains a given mapping.

Parameters
mappingthe mapping to check
Returns
true if it contains the mapping, false otherwise

◆ define_physical_buffer()

void ethercatcpp::coe::PDOBuffer::define_physical_buffer ( SlaveDevice &  eth_slave)

define the physical buffer of an ethercat slave

only advantage using this function is to avoid problem with memory size. This function is intended to be called at unit device construction time

Parameters
eth_slavethe target unit device

◆ entry_memory_shift()

size_t ethercatcpp::coe::PDOBuffer::entry_memory_shift ( const PDOMapping &  mapping,
std::string_view  entry 
) const

Get the shift in buffer memory to access a mapping entry data.

Parameters
mappingthe mapping defining the entry
entrythe name of the entry
Returns
size_t the number of bytes to shift

◆ map_memory() [1/8]

template<typename T , typename U , typename... Other>
std::tuple<T&, U&, Other&...> ethercatcpp::coe::PDOBuffer::map_memory ( )
inline

Map the entire buffer to a typed reference.

Template Parameters
Ttype of the mapped reference
Returns
reference to the memory zone containing the variable of type T
See also
bind_physical_buffer()

◆ map_memory() [2/8]

template<typename T >
T& ethercatcpp::coe::PDOBuffer::map_memory ( )
inline

Map the entire buffer to a typed reference.

Template Parameters
Ttype of the mapped reference
Returns
reference to the memory zone containing the variable of type T
See also
bind_physical_buffer()

◆ map_memory() [3/8]

template<typename T , typename U , typename... Other>
std::tuple<const T&, const U&, const Other&...> ethercatcpp::coe::PDOBuffer::map_memory ( ) const
inline

Map the entire buffer to a typed const reference.

Template Parameters
Ttype of the mapped reference
Returns
const reference to the memory zone containing the variable of type T
See also
bind_physical_buffer()

◆ map_memory() [4/8]

template<typename T >
const T& ethercatcpp::coe::PDOBuffer::map_memory ( ) const
inline

Map the entire buffer to a typed rconst eference.

Template Parameters
Ttype of the mapped reference
Returns
const reference to the memory zone containing the variable of type T
See also
bind_physical_buffer()

◆ map_memory() [5/8]

template<typename T >
T& ethercatcpp::coe::PDOBuffer::map_memory ( const PDOMapping &  mapping)
inline

Map a mapping to a typed reference.

Template Parameters
Ttype of the mapped reference
Returns
reference to the memory zone containing the mapping of type T
See also
bind_physical_buffer()

◆ map_memory() [6/8]

template<typename T >
const T& ethercatcpp::coe::PDOBuffer::map_memory ( const PDOMapping &  mapping) const
inline

Map a mapping to a typed reference.

Template Parameters
Ttype of the mapped reference
Returns
reference to the memory zone containing the mapping of type T
See also
bind_physical_buffer()

◆ map_memory() [7/8]

template<typename T >
T& ethercatcpp::coe::PDOBuffer::map_memory ( const PDOMapping &  mapping,
std::string_view  entry_name 
)
inline

Map the entry of a mapping to a typed reference.

Template Parameters
Ttype of the mapped reference
Returns
reference to the memory zone containing the variable
See also
bind_physical_buffer()

◆ map_memory() [8/8]

template<typename T >
const T& ethercatcpp::coe::PDOBuffer::map_memory ( const PDOMapping &  mapping,
std::string_view  entry_name 
) const
inline

Map the entry of a mapping to a typed const reference.

Template Parameters
Ttype of the mapped reference
Returns
const reference to the memory zone containing the variable
See also
bind_physical_buffer()

◆ map_memory_internal() [1/4]

uint8_t* ethercatcpp::coe::PDOBuffer::map_memory_internal ( const PDOMapping &  mapping,
size_t  bytes 
)
private

◆ map_memory_internal() [2/4]

const uint8_t* ethercatcpp::coe::PDOBuffer::map_memory_internal ( const PDOMapping &  mapping,
size_t  bytes 
) const
private

◆ map_memory_internal() [3/4]

uint8_t* ethercatcpp::coe::PDOBuffer::map_memory_internal ( const PDOMapping &  mapping,
std::string_view  entry_name,
size_t  bytes 
)
private

◆ map_memory_internal() [4/4]

const uint8_t* ethercatcpp::coe::PDOBuffer::map_memory_internal ( const PDOMapping &  mapping,
std::string_view  entry_name,
size_t  bytes 
) const
private

◆ map_memory_tuple() [1/4]

template<typename T >
std::tuple<T&> ethercatcpp::coe::PDOBuffer::map_memory_tuple ( size_t  mapping_increment)
inlineprivate

◆ map_memory_tuple() [2/4]

template<typename T , typename U , typename... Other>
std::tuple<T&, U&, Other&...> ethercatcpp::coe::PDOBuffer::map_memory_tuple ( size_t  mapping_increment)
inlineprivate

◆ map_memory_tuple() [3/4]

template<typename T , typename U , typename... Other>
std::tuple<const T&, const U&, const Other&...> ethercatcpp::coe::PDOBuffer::map_memory_tuple ( size_t  mapping_increment) const
inlineprivate

◆ map_memory_tuple() [4/4]

template<typename T >
std::tuple<const T&> ethercatcpp::coe::PDOBuffer::map_memory_tuple ( size_t  mapping_increment) const
inlineprivate

◆ mapping_memory_shift()

size_t ethercatcpp::coe::PDOBuffer::mapping_memory_shift ( const PDOMapping &  mapping) const

Get the shift in buffer memory to access mapping data.

Parameters
mappingthe mapping to get shifting for
Returns
size_t the number of bytes to shift

◆ memory_size()

uint16_t ethercatcpp::coe::PDOBuffer::memory_size ( ) const

Get size of the buffer in memory.

this function can be used when calling define_physical_buffer to set the adequate size

Returns
the size of the buffer

Member Data Documentation

◆ addr_

uint16_t ethercatcpp::coe::PDOBuffer::addr_
private

◆ data_

uint8_t* ethercatcpp::coe::PDOBuffer::data_
private

◆ flags_

uint32_t ethercatcpp::coe::PDOBuffer::flags_
private

◆ is_tx_

bool ethercatcpp::coe::PDOBuffer::is_tx_
private

◆ mappings_

std::vector<const PDOMapping*> ethercatcpp::coe::PDOBuffer::mappings_
private

The documentation for this class was generated from the following file: