SlaveIdentifier Class Reference

The SlaveIdentifier class is a POD-type representing a unique set of values identifying an EtherCAT slave. More...

#include <armarx/control/ethercat/SlaveIdentifier.h>

Public Member Functions

std::string getName () const
 Returns the combination of slave name and name of the parent device of a slave identifier as a string object. More...
 
const char * getNameAsCStr () const
 Returns the combination of slave name and name of the parent device of a slave identifier as char array. More...
 
bool setName (const std::string &name)
 Sets the slave name of a SlaveIdentifier and returns whether the new name fits together with the parent device name into the name-variable. More...
 
bool setParentDeviceName (const std::string &parentDeviceName)
 Sets the name of the parent device of a slave identifier. More...
 
 SlaveIdentifier ()=default
 
 SlaveIdentifier (hardware_config::SlaveIdentifierConfig &config)
 Construct a SlaveIdentifier from a RapidXmlReaderNode by parsing the node for following entries: More...
 
std::string toMinimalString (const std::string &linePrefix="") const
 Returns a minimal string representation of a SlaveIdentifier. More...
 
std::string toString (const std::string &linePrefix="") const
 Returns a full string representation of a SlaveIdentifier. More...
 

Public Attributes

std::uint32_t productCode = 0
 The product code of the slave. More...
 
std::uint32_t revisionNumber = 0
 The revision number of the slave hard- or firmware (is not used for identifying a slave on the bus) More...
 
std::uint32_t serialNumber = 0
 The serial number of a slave with a certain productCode. More...
 
std::int16_t slaveIndex = -1
 The index of the slave on the bus. More...
 
std::uint32_t vendorID = 0
 The unique id of the vendor of the slave hardware. More...
 

Friends

std::ostream & operator<< (std::ostream &stream, const SlaveIdentifier &rhs)
 

Detailed Description

The SlaveIdentifier class is a POD-type representing a unique set of values identifying an EtherCAT slave.

The requirement of being a POD-type requires a pre-defined length of the name-variable. Therefore it might happen, that the name of a SlaveIdentifier is cut after a pre-defined amount of characters.

Definition at line 53 of file SlaveIdentifier.h.

Constructor & Destructor Documentation

◆ SlaveIdentifier() [1/2]

SlaveIdentifier ( )
default

◆ SlaveIdentifier() [2/2]

Construct a SlaveIdentifier from a RapidXmlReaderNode by parsing the node for following entries:

  • VendorID
  • ProductCode
  • SerialNumber
Parameters
nodeThe RapidXmlReaderNode which is used as input.

Definition at line 35 of file SlaveIdentifier.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ getName()

std::string getName ( ) const

Returns the combination of slave name and name of the parent device of a slave identifier as a string object.

This creates a new std::string obejct and therefore might allocate memory.

Returns
The name as a std::string

Definition at line 44 of file SlaveIdentifier.cpp.

+ Here is the caller graph for this function:

◆ getNameAsCStr()

const char * getNameAsCStr ( ) const

Returns the combination of slave name and name of the parent device of a slave identifier as char array.

This function does not allocate memory and is safe to be used in a rt-thread.

Returns
The name as a const pointer to a char array

Definition at line 50 of file SlaveIdentifier.cpp.

◆ setName()

bool setName ( const std::string &  name)

Sets the slave name of a SlaveIdentifier and returns whether the new name fits together with the parent device name into the name-variable.

The name of the parent device will be kept, unless the combined name is too long for the size of the name-variable and some parts were lost.

Parameters
namethe new slave name
Returns
true if the provided name could be fully set as the salve name, false if parts of the combined name needed to be cut

Definition at line 56 of file SlaveIdentifier.cpp.

+ Here is the caller graph for this function:

◆ setParentDeviceName()

bool setParentDeviceName ( const std::string &  parentDeviceName)

Sets the name of the parent device of a slave identifier.

See also
setName for conditions on possible cutting of the provided name.
Parameters
parentDeviceNamethe new name of the parent device
Returns
true if the provided name could be set without losing data, false if not.

Definition at line 67 of file SlaveIdentifier.cpp.

+ Here is the caller graph for this function:

◆ toMinimalString()

std::string toMinimalString ( const std::string &  linePrefix = "") const

Returns a minimal string representation of a SlaveIdentifier.

This representation contains only the combined name and the slaveIndex. Each printed member will be prefixed by the provided linePrefix and printed on its own line.

Parameters
linePrefixthe string which will be put in front of every line
Returns
A minimal string representation.

Definition at line 100 of file SlaveIdentifier.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toString()

std::string toString ( const std::string &  linePrefix = "") const

Returns a full string representation of a SlaveIdentifier.

This representation contains all members seperated by newlines. Each line will be prefixed by the provided linePrefix.

Parameters
linePrefixthe string which will be put in front of every line
Returns
A full string representation.

Definition at line 76 of file SlaveIdentifier.cpp.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const SlaveIdentifier rhs 
)
friend

Definition at line 83 of file SlaveIdentifier.h.

Member Data Documentation

◆ productCode

std::uint32_t productCode = 0

The product code of the slave.

The same product code means the same salve hardware

Definition at line 75 of file SlaveIdentifier.h.

◆ revisionNumber

std::uint32_t revisionNumber = 0

The revision number of the slave hard- or firmware (is not used for identifying a slave on the bus)

Definition at line 80 of file SlaveIdentifier.h.

◆ serialNumber

std::uint32_t serialNumber = 0

The serial number of a slave with a certain productCode.

Definition at line 77 of file SlaveIdentifier.h.

◆ slaveIndex

std::int16_t slaveIndex = -1

The index of the slave on the bus.

Definition at line 71 of file SlaveIdentifier.h.

◆ vendorID

std::uint32_t vendorID = 0

The unique id of the vendor of the slave hardware.

Definition at line 73 of file SlaveIdentifier.h.


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