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

Represent a CANOpen PDO mapping. More...

#include <coe_utilities.h>

Public Types

using iterator = std::vector< std::pair< uint8_t, uint32_t > >::iterator
 
using const_iterator = std::vector< std::pair< uint8_t, uint32_t > >::const_iterator
 

Public Member Functions

 PDOMapping (ObjectDictionary &dico, uint8_t idx, bool is_tx)
 Construct a new PDOMapping object. More...
 
 PDOMapping (ObjectDictionary &dico, uint8_t idx, bool is_tx, std::initializer_list< std::string_view > objects)
 Construct a new PDOMapping object. More...
 
uint16_t map_addr () const
 get address of the mapping in device memory More...
 
bool has_entry (std::string_view entry) const
 Check whether the mapping use the corresponding entry. More...
 
const_iterator begin () const
 get first iterator on mapped objects More...
 
const_iterator end () const
 get terminal iterator on mapped objects More...
 
void reset ()
 clean mapping memory More...
 
void add_object (std::string_view obj)
 add an object to the mapping More...
 
bool configure (SlaveDevice &eth_slave) const
 Configure an ethercat unit device with the corresponding mapping. More...
 
size_t memory_size () const
 Get total size in bytes of the mapping. More...
 
size_t memory_shift (std::string_view obj) const
 Get memory shift to access a given object of the mapping. More...
 
template<typename T >
bool check_buffer ()
 Check whether a type can be used as a buffer for this mapping. More...
 
bool check_entry_size (std::string_view obj, size_t bytes) const
 Check whether an entry has corresponding size. More...
 
bool is_tx () const
 Give the type of mapping (TX or RX) More...
 
const ObjectDictionary & dictionary () const
 Access reference dictionary. More...
 

Private Member Functions

void check_entry_throws (std::string_view obj) const
 

Private Attributes

ObjectDictionary * reference_dictionnary_
 
uint8_t index_
 
bool is_tx_
 
std::vector< std::pair< uint8_t, uint32_t > > objects_mapping_
 

Detailed Description

Represent a CANOpen PDO mapping.

Member Typedef Documentation

◆ const_iterator

using ethercatcpp::coe::PDOMapping::const_iterator = std::vector<std::pair<uint8_t, uint32_t> >::const_iterator

◆ iterator

using ethercatcpp::coe::PDOMapping::iterator = std::vector<std::pair<uint8_t, uint32_t> >::iterator

Constructor & Destructor Documentation

◆ PDOMapping() [1/2]

ethercatcpp::coe::PDOMapping::PDOMapping ( ObjectDictionary &  dico,
uint8_t  idx,
bool  is_tx 
)

Construct a new PDOMapping object.

index of the mapping is relative to 0x1600 in RX and 0x1A00 if TX

Parameters
dicothe dictionary referenced by the PDO mapping
idxindex of the mapping
is_txtrue if tx (master in) mapping, false if rx (master out) mapping

◆ PDOMapping() [2/2]

ethercatcpp::coe::PDOMapping::PDOMapping ( ObjectDictionary &  dico,
uint8_t  idx,
bool  is_tx,
std::initializer_list< std::string_view >  objects 
)

Construct a new PDOMapping object.

index of the mapping is relative to 0x1600 in RX and 0x1A00 if TX

Parameters
dicothe dictionary referenced by the PDO mapping
idxindex of the mapping
is_txtrue if tx (master in) mapping, false if rx (master out) mapping
objectslist of objects (in order) that define the mapping

Member Function Documentation

◆ add_object()

void ethercatcpp::coe::PDOMapping::add_object ( std::string_view  obj)

add an object to the mapping

Parameters
objthe name of the object's entry in dictionary

◆ begin()

const_iterator ethercatcpp::coe::PDOMapping::begin ( ) const

get first iterator on mapped objects

Returns
const_iterator

◆ check_buffer()

template<typename T >
bool ethercatcpp::coe::PDOMapping::check_buffer ( )
inline

Check whether a type can be used as a buffer for this mapping.

Template Parameters
Tthe type to check against
Returns
true if type size match, false otherwise

◆ check_entry_size()

bool ethercatcpp::coe::PDOMapping::check_entry_size ( std::string_view  obj,
size_t  bytes 
) const

Check whether an entry has corresponding size.

Parameters
objthe object to check
bytesthe size to check
Returns
true if type size match, false otherwise

◆ check_entry_throws()

void ethercatcpp::coe::PDOMapping::check_entry_throws ( std::string_view  obj) const
private

◆ configure()

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

Configure an ethercat unit device with the corresponding mapping.

will reset the mapping in device memory and will reset it accordingly to the mapping description

Parameters
eth_slavethe unit device to configure
Returns
true i configuration succeeded, false otherwise

◆ dictionary()

const ObjectDictionary& ethercatcpp::coe::PDOMapping::dictionary ( ) const

Access reference dictionary.

Returns
const reference on dictionary used by mapping

◆ end()

const_iterator ethercatcpp::coe::PDOMapping::end ( ) const

get terminal iterator on mapped objects

Returns
const_iterator

◆ has_entry()

bool ethercatcpp::coe::PDOMapping::has_entry ( std::string_view  entry) const

Check whether the mapping use the corresponding entry.

Parameters
entrythe CANOpen dictionary entry to check
Returns
true if mapping has entry, false otherwise

◆ is_tx()

bool ethercatcpp::coe::PDOMapping::is_tx ( ) const

Give the type of mapping (TX or RX)

Returns
true if mapping is a TX mapping, false if it is a RX mapping

◆ map_addr()

uint16_t ethercatcpp::coe::PDOMapping::map_addr ( ) const

get address of the mapping in device memory

depends on specified TR/RX and index

Returns
uint16_t the mapping address

◆ memory_shift()

size_t ethercatcpp::coe::PDOMapping::memory_shift ( std::string_view  obj) const

Get memory shift to access a given object of the mapping.

Parameters
objthe name of the object in dictionary
Returns
size_t the shift to access the object, relative to mapping memory

◆ memory_size()

size_t ethercatcpp::coe::PDOMapping::memory_size ( ) const

Get total size in bytes of the mapping.

Returns
size_t the size of the mapping

◆ reset()

void ethercatcpp::coe::PDOMapping::reset ( )

clean mapping memory

Member Data Documentation

◆ index_

uint8_t ethercatcpp::coe::PDOMapping::index_
private

◆ is_tx_

bool ethercatcpp::coe::PDOMapping::is_tx_
private

◆ objects_mapping_

std::vector<std::pair<uint8_t, uint32_t> > ethercatcpp::coe::PDOMapping::objects_mapping_
private

◆ reference_dictionnary_

ObjectDictionary* ethercatcpp::coe::PDOMapping::reference_dictionnary_
private

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