Motion Master
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
EthercatSlave Class Reference

#include <ethercat_slave.h>

Inheritance diagram for EthercatSlave:
Inheritance graph
[legend]
Collaboration diagram for EthercatSlave:
Collaboration graph
[legend]

Public Types

enum class  State : uint8_t {
  kUnspecified = 0 , kInit = 1 , kPreOp = 2 , kBoot = 3 ,
  kSafeOp = 4 , kOp = 8
}
 
enum class  FoeError {
  kNotFound = 0x00008001 , kAccessDenied = 0x00008002 , kDiskFull = 0x00008003 , kIllegal = 0x00008004 ,
  kPacketNumberWrong = 0x00008005 , kAlreadyExists = 0x00008006 , kNoUser = 0x00008007 , kBootstrapOnly = 0x00008008 ,
  kNotBootstrap = 0x00008009 , kNoRights = 0x0000800a , kProgramError = 0x0000800b
}
 
- Public Types inherited from VirtualDevice
enum class  Protocol { kUnspecified = 0 , kMock , kEcat , kSerial }
 
enum class  Type { kUnspecified = 0 , kCia402Drive , kDigitalIo }
 

Public Member Functions

 EthercatSlave ()
 
 EthercatSlave (EthercatSlave const &)
 
 ~EthercatSlave ()
 
uint16_t get_device_id () const override
 Get the ID (absolute position) of the EtherCAT slave in the EtherCAT chain. More...
 
uint16_t get_hardware_id () const override
 Get the hardware ID. More...
 
Protocol get_protocol () const override
 Get the protocol the device uses. More...
 
Type get_device_type () const override
 Get the device type. More...
 
std::list< VirtualParameter * > get_all_virtual_parameters () override
 Get all configuration parameters from a slave. More...
 
VirtualParameterget_virtual_parameter (uint16_t index, uint8_t subindex) override
 Get a configuration parameter by its index/subindex. More...
 
std::variant< MotionMasterError, std::list< std::string > > get_file_list () override
 Get the list of available files on the device. More...
 
std::variant< MotionMasterError, std::vector< uint8_t > > read_file (const std::string &file_name) override
 Return the raw content (bytes) of the requested file from the flash memory. More...
 
MotionMasterError write_file (const std::string &file_name, const std::vector< uint8_t > &content, std::function< void(uint8_t)> progress_callback) override
 Write raw content (bytes) into a file in the flash memory. More...
 
MotionMasterError remove_file (const std::string &file_name) override
 Remove a file from the flash memory. More...
 
virtual bool has_firmware ()
 Check if the slave has a firmware installed. More...
 
bool is_operational () const override
 Request the current slave state. More...
 
virtual bool has_pdos ()
 Check if PDO mapping is available. More...
 
virtual State get_state (bool force_refresh) const
 Get the slave EtherCAT state. More...
 
virtual bool set_state (State state, uint32_t timeout_ms=10000)
 Change the EtherCAT state of the slave. More...
 
virtual MotionMasterError write_sii (const std::vector< uint8_t > &content)
 Write the SII file content onto an EtherCAT slave. More...
 
virtual void update_pdo_mapping_od ()
 
virtual void receive_pdos (const uint8_t *process_data)
 
virtual void send_pdos (const uint8_t *process_data)
 
virtual bool request_state_switch (State state)
 
- Public Member Functions inherited from VirtualDevice
virtual ~VirtualDevice ()=default
 
virtual uint16_t get_device_id () const =0
 Get the device ID. More...
 
virtual uint16_t get_hardware_id () const =0
 Get the hardware ID. More...
 
virtual Protocol get_protocol () const
 Get the protocol the device uses. More...
 
virtual Type get_device_type () const
 Get the device type. More...
 
virtual std::list< VirtualParameter * > get_all_virtual_parameters ()=0
 Get all available configuration parameters on the virtual device. More...
 
virtual VirtualParameterget_virtual_parameter (uint16_t index, uint8_t subindex)=0
 Get a configuration parameter. More...
 
virtual std::variant< MotionMasterError, std::list< std::string > > get_file_list ()=0
 Get the list of available files on the device. More...
 
virtual std::variant< MotionMasterError, std::vector< uint8_t > > read_file (const std::string &file_name)=0
 Get the file content from a file from the flash memory. More...
 
virtual MotionMasterError write_file (const std::string &file_name, const std::vector< uint8_t > &content, std::function< void(uint8_t)> progress_callback)=0
 Write the file to the flash memory. More...
 
virtual MotionMasterError remove_file (const std::string &file_name)=0
 Remove the file from the flash memory. More...
 
virtual bool is_operational () const =0
 Check if the device is operational. More...
 

Public Attributes

uint16_t obytes = 0
 
uint16_t ibytes = 0
 

Static Public Attributes

static const std::map< State, std::map< State, State > > ecat_state_machine_table_
 
static const std::map< FoeError, std::string > foe_error_messages_
 
- Static Public Attributes inherited from VirtualDevice
static const std::map< std::pair< uint32_t, uint32_t >, Typedevice_type_map_
 

Member Enumeration Documentation

◆ FoeError

enum class EthercatSlave::FoeError
strong
Enumerator
kNotFound 
kAccessDenied 
kDiskFull 
kIllegal 
kPacketNumberWrong 
kAlreadyExists 
kNoUser 
kBootstrapOnly 
kNotBootstrap 
kNoRights 
kProgramError 

◆ State

enum class EthercatSlave::State : uint8_t
strong
Enumerator
kUnspecified 
kInit 
kPreOp 
kBoot 
kSafeOp 
kOp 

Constructor & Destructor Documentation

◆ EthercatSlave() [1/2]

EthercatSlave::EthercatSlave ( )
inline

◆ EthercatSlave() [2/2]

EthercatSlave::EthercatSlave ( EthercatSlave const &  )
inline

◆ ~EthercatSlave()

EthercatSlave::~EthercatSlave ( )
inline

Member Function Documentation

◆ get_all_virtual_parameters()

std::list< VirtualParameter * > EthercatSlave::get_all_virtual_parameters ( )
inlineoverridevirtual

Get all configuration parameters from a slave.

Returns
a list of configuration parameters

Implements VirtualDevice.

Reimplemented in SoemSlave.

◆ get_device_id()

uint16_t EthercatSlave::get_device_id ( ) const
inlineoverridevirtual

Get the ID (absolute position) of the EtherCAT slave in the EtherCAT chain.

Returns
device ID

Implements VirtualDevice.

Reimplemented in SoemSlave.

◆ get_device_type()

Type EthercatSlave::get_device_type ( ) const
inlineoverridevirtual

Get the device type.

Returns
Type enum

Reimplemented from VirtualDevice.

Reimplemented in SoemSlave.

◆ get_file_list()

std::variant< MotionMasterError, std::list< std::string > > EthercatSlave::get_file_list ( )
inlineoverridevirtual

Get the list of available files on the device.

Returns
the list of available files on the device

Implements VirtualDevice.

Reimplemented in SoemSlave.

◆ get_hardware_id()

uint16_t EthercatSlave::get_hardware_id ( ) const
inlineoverridevirtual

Get the hardware ID.

Returns
the hardware ID

Implements VirtualDevice.

Reimplemented in SoemSlave.

◆ get_protocol()

Protocol EthercatSlave::get_protocol ( ) const
inlineoverridevirtual

Get the protocol the device uses.

Returns
Protocol enum

Reimplemented from VirtualDevice.

◆ get_state()

virtual State EthercatSlave::get_state ( bool  force_refresh) const
inlinevirtual

Get the slave EtherCAT state.

Returns
the slave EtherCAT state

Reimplemented in SoemSlave.

◆ get_virtual_parameter()

VirtualParameter * EthercatSlave::get_virtual_parameter ( uint16_t  index,
uint8_t  subindex 
)
inlineoverridevirtual

Get a configuration parameter by its index/subindex.

Parameters
index
subindex
Returns
the pointer to the virtual parameter if available, or nullptr if not

Implements VirtualDevice.

Reimplemented in SoemSlave.

◆ has_firmware()

virtual bool EthercatSlave::has_firmware ( )
inlinevirtual

Check if the slave has a firmware installed.

Returns
true if the slave has a firmware installed, false otherwise

Reimplemented in SoemSlave.

◆ has_pdos()

virtual bool EthercatSlave::has_pdos ( )
inlinevirtual

Check if PDO mapping is available.

Try to fetch all of the OD entries that define the PDO mapping

Returns
true if PDO mapping is available, false otherwise

Reimplemented in SoemSlave.

◆ is_operational()

bool EthercatSlave::is_operational ( ) const
inlineoverridevirtual

Request the current slave state.

Parameters
force_refreshforce refresh the state of the slave first
Returns
the current state of the slave

Implements VirtualDevice.

Reimplemented in SoemSlave.

◆ read_file()

std::variant< MotionMasterError, std::vector< uint8_t > > EthercatSlave::read_file ( const std::string &  file_name)
inlineoverridevirtual

Return the raw content (bytes) of the requested file from the flash memory.

Parameters
file_name
Returns
MotionMasterError or file content

Implements VirtualDevice.

Reimplemented in SoemSlave.

◆ receive_pdos()

virtual void EthercatSlave::receive_pdos ( const uint8_t *  process_data)
inlinevirtual

Reimplemented in SoemSlave.

◆ remove_file()

MotionMasterError EthercatSlave::remove_file ( const std::string &  file_name)
inlineoverridevirtual

Remove a file from the flash memory.

Parameters
file_name
Returns
error if any

Implements VirtualDevice.

Reimplemented in SoemSlave.

◆ request_state_switch()

virtual bool EthercatSlave::request_state_switch ( State  state)
inlinevirtual

Reimplemented in SoemSlave.

◆ send_pdos()

virtual void EthercatSlave::send_pdos ( const uint8_t *  process_data)
inlinevirtual

Reimplemented in SoemSlave.

◆ set_state()

virtual bool EthercatSlave::set_state ( State  state,
uint32_t  timeout_ms = 10000 
)
inlinevirtual

Change the EtherCAT state of the slave.

Attention
This is a blocking function, which actually waits until the state has been changed
Parameters
stateEtherCAT state to switch the slave to
timeout_msTimeout in ms, or how long to poll the state, default value is 10000
Returns
true if successful, false otherwise

Reimplemented in SoemSlave.

◆ update_pdo_mapping_od()

virtual void EthercatSlave::update_pdo_mapping_od ( )
inlinevirtual

◆ write_file()

MotionMasterError EthercatSlave::write_file ( const std::string &  file_name,
const std::vector< uint8_t > &  content,
std::function< void(uint8_t)>  progress_callback 
)
inlineoverridevirtual

Write raw content (bytes) into a file in the flash memory.

Parameters
file_name
contentvector of bytes
progress_callbackfunction to call for progress changes
Returns
error if any

Implements VirtualDevice.

Reimplemented in SoemSlave.

◆ write_sii()

virtual MotionMasterError EthercatSlave::write_sii ( const std::vector< uint8_t > &  content)
inlinevirtual

Write the SII file content onto an EtherCAT slave.

content content as a vector of bytes

Returns
MotionMasterError if any

Reimplemented in SoemSlave.

Member Data Documentation

◆ ecat_state_machine_table_

const std::map<State, std::map<State, State> > EthercatSlave::ecat_state_machine_table_
inlinestatic

◆ foe_error_messages_

const std::map<FoeError, std::string> EthercatSlave::foe_error_messages_
inlinestatic

◆ ibytes

uint16_t EthercatSlave::ibytes = 0

◆ obytes

uint16_t EthercatSlave::obytes = 0

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