Motion Master
Loading...
Searching...
No Matches
EthernetSlave Class Reference

#include <ethernet_slave.h>

Inheritance diagram for EthernetSlave:
Collaboration diagram for EthernetSlave:

Public Member Functions

 EthernetSlave (const std::string &ipAddress, uint16_t position)
 ~EthernetSlave () override
mm::comm::spoe::DevicegetDevice ()
uint16_t get_device_id () const override
 Get the ID (absolute position) of the EtherCAT slave in the EtherCAT chain.
uint16_t get_hardware_id () const override
 Get the hardware ID.
Type get_device_type () const override
 Get the device type.
std::list< VirtualParameter * > get_all_virtual_parameters () override
 Get all configuration parameters from a slave.
VirtualParameterget_virtual_parameter (uint16_t index, uint8_t subindex) override
 Get a configuration parameter by its index/subindex.
std::variant< MotionMasterError, std::list< std::string > > get_file_list () override
 Get the list of available files on the device.
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.
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.
MotionMasterError remove_file (const std::string &file_name) override
 Remove a file from the flash memory.
bool has_firmware () override
 Check if the slave has a firmware installed.
bool is_operational () const override
 Request the current slave state.
bool is_supported ()
bool has_pdos () override
 Check if PDO mapping is available.
State get_state (bool force_refresh) const override
 Get the slave EtherCAT state.
bool set_state (State state, uint32_t timeout_ms=5000) override
 Change the EtherCAT state of the slave.
Public Member Functions inherited from EthercatSlave
 EthercatSlave ()
 EthercatSlave (EthercatSlave const &)
 ~EthercatSlave ()
Protocol get_protocol () const override
 Get the protocol the device uses.
virtual MotionMasterError write_sii (const std::vector< uint8_t > &content)
 Write the SII file content onto an EtherCAT slave.
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

Additional Inherited Members

Public Types inherited from EthercatSlave
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 Attributes inherited from EthercatSlave
uint16_t obytes = 0
uint16_t ibytes = 0
Static Public Attributes inherited from EthercatSlave
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_

Constructor & Destructor Documentation

◆ EthernetSlave()

EthernetSlave::EthernetSlave ( const std::string & ipAddress,
uint16_t position )
explicit

◆ ~EthernetSlave()

EthernetSlave::~EthernetSlave ( )
override

Member Function Documentation

◆ get_all_virtual_parameters()

std::list< VirtualParameter * > EthernetSlave::get_all_virtual_parameters ( )
nodiscardoverridevirtual

Get all configuration parameters from a slave.

Returns
a list of configuration parameters

Reimplemented from EthercatSlave.

◆ get_device_id()

uint16_t EthernetSlave::get_device_id ( ) const
nodiscardoverridevirtual

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

Returns
device ID

Reimplemented from EthercatSlave.

◆ get_device_type()

VirtualDevice::Type EthernetSlave::get_device_type ( ) const
nodiscardoverridevirtual

Get the device type.

Returns
Type enum

Reimplemented from EthercatSlave.

◆ get_file_list()

std::variant< MotionMasterError, std::list< std::string > > EthernetSlave::get_file_list ( )
nodiscardoverridevirtual

Get the list of available files on the device.

Returns
the list of available files on the device

Reimplemented from EthercatSlave.

◆ get_hardware_id()

uint16_t EthernetSlave::get_hardware_id ( ) const
nodiscardoverridevirtual

Get the hardware ID.

Returns
the hardware ID

Reimplemented from EthercatSlave.

◆ get_state()

EthercatSlave::State EthernetSlave::get_state ( bool force_refresh) const
nodiscardoverridevirtual

Get the slave EtherCAT state.

Returns
the slave EtherCAT state

Reimplemented from EthercatSlave.

◆ get_virtual_parameter()

VirtualParameter * EthernetSlave::get_virtual_parameter ( uint16_t index,
uint8_t subindex )
nodiscardoverridevirtual

Get a configuration parameter by its index/subindex.

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

Reimplemented from EthercatSlave.

◆ getDevice()

mm::comm::spoe::Device & EthernetSlave::getDevice ( )

◆ has_firmware()

bool EthernetSlave::has_firmware ( )
overridevirtual

Check if the slave has a firmware installed.

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

Reimplemented from EthercatSlave.

◆ has_pdos()

bool EthernetSlave::has_pdos ( )
nodiscardoverridevirtual

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 from EthercatSlave.

◆ is_operational()

bool EthernetSlave::is_operational ( ) const
nodiscardoverridevirtual

Request the current slave state.

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

Reimplemented from EthercatSlave.

◆ is_supported()

bool EthernetSlave::is_supported ( )

◆ read_file()

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

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

Parameters
file_name
Returns
MotionMasterError or file content

Reimplemented from EthercatSlave.

◆ remove_file()

MotionMasterError EthernetSlave::remove_file ( const std::string & file_name)
overridevirtual

Remove a file from the flash memory.

Parameters
file_name
Returns
error if any

Reimplemented from EthercatSlave.

◆ set_state()

bool EthernetSlave::set_state ( EthercatSlave::State state,
uint32_t timeout_ms = 5000 )
overridevirtual

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 from EthercatSlave.

◆ write_file()

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

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

Reimplemented from EthercatSlave.


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