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

#include <mock_slave.h>

Inheritance diagram for MockSlave:
Collaboration diagram for MockSlave:

Public Member Functions

 MockSlave (uint16_t id)
uint16_t get_device_id () const override
 Get the device ID.
uint16_t get_hardware_id () const override
 Get the hardware ID.
Protocol get_protocol () const override
 Get the protocol the device uses.
Type get_device_type () const override
 Get the device type.
std::list< VirtualParameter * > get_all_virtual_parameters () override
 Get all available configuration parameters on the virtual device.
VirtualParameterget_virtual_parameter (uint16_t index, uint8_t subindex) override
 Get a configuration parameter.
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
 Get the file content from a 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 the file to the flash memory.
MotionMasterError remove_file (const std::string &file_name) override
 Remove the file from the flash memory.
bool is_operational () const override
 Check if the device is operational.
Public Member Functions inherited from VirtualDevice
virtual ~VirtualDevice ()=default

Additional Inherited Members

Public Types inherited from VirtualDevice
enum class  Protocol { kUnspecified = 0 , kMock , kEcat , kSerial }
enum class  Type { kUnspecified = 0 , kCia402Drive , kDigitalIo }
Static Public Attributes inherited from VirtualDevice
static const std::map< std::pair< uint32_t, uint32_t >, Typedevice_type_map_

Constructor & Destructor Documentation

◆ MockSlave()

MockSlave::MockSlave ( uint16_t id)
explicit

Member Function Documentation

◆ get_all_virtual_parameters()

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

Get all available configuration parameters on the virtual device.

Returns
a list of pointers to all available configuration parameters

Implements VirtualDevice.

◆ get_device_id()

uint16_t MockSlave::get_device_id ( ) const
nodiscardoverridevirtual

Get the device ID.

Returns
the device ID

Implements VirtualDevice.

◆ get_device_type()

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

Get the device type.

Returns
Type enum

Reimplemented from VirtualDevice.

◆ get_file_list()

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

Get the list of available files on the device.

Returns
MotionMasterError or the list of available files on the device

Implements VirtualDevice.

◆ get_hardware_id()

uint16_t MockSlave::get_hardware_id ( ) const
nodiscardoverridevirtual

Get the hardware ID.

Returns
the hardware ID

Implements VirtualDevice.

◆ get_protocol()

VirtualDevice::Protocol MockSlave::get_protocol ( ) const
nodiscardoverridevirtual

Get the protocol the device uses.

Returns
Protocol enum

Reimplemented from VirtualDevice.

◆ get_virtual_parameter()

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

Get a configuration parameter.

Parameters
indexconfiguration parameter index
subindexconfiguration parameter index
Returns
a pointer to a configuration parameter

Implements VirtualDevice.

◆ is_operational()

bool MockSlave::is_operational ( ) const
nodiscardoverridevirtual

Check if the device is operational.

Returns
true if operational, false otherwise

Implements VirtualDevice.

◆ read_file()

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

Get the file content from a file from the flash memory.

Parameters
file_namename of the file in the flash memory
Returns
MotionMasterError or file content

Implements VirtualDevice.

◆ remove_file()

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

Remove the file from the flash memory.

Parameters
file_namename of the file in the flash memory
Returns
error

Implements VirtualDevice.

◆ write_file()

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

Write the file to the flash memory.

Parameters
file_namethe name of the file to be written
contentthe content of the file to be written
progress_callbackfunction to call for progress changes
Returns
error

Implements VirtualDevice.


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