Motion Master
|
Classes | |
class | Device |
Abstract interface representing a generic device. More... | |
class | DeviceManager |
Manages devices and performs cyclic process data exchange. More... | |
class | DeviceParameterRefresher |
Base class for periodically refreshing a set of device parameters in a background thread. More... | |
class | DeviceResponseException |
Exception thrown when a device responds with an error. More... | |
struct | MappedParameterValue |
Represents a single mapped parameter value. More... | |
struct | MappedParameterValues |
Holds collections of mapped parameter values for RX and TX directions. More... | |
class | Parameter |
Represents a device parameter identified by index and subindex. More... | |
struct | PdoMappingEntry |
Represents a single PDO (Process Data Object) mapping entry. More... | |
struct | PdoMappings |
Represents the mapped PDO entries for a slave device. More... | |
struct | UiConfigJson |
Top-level UI configuration JSON structure. More... | |
struct | UiPdoMapping |
Represents the PDO mapping for RX and TX channels. More... | |
Typedefs | |
using | ParameterValue = std::variant< bool, std::int8_t, std::int16_t, std::int32_t, std::int64_t, std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t, float, double, std::string, std::vector< std::uint8_t > > |
Enumerations | |
enum class | EtherCATVendorID : uint32_t { SYNAPTICON = 0x000022d2 } |
Enum class representing EtherCAT vendor IDs. More... | |
enum class | ObjectFlags : uint16_t { None = 0x0000 , PO_RD = 0x0001 , SO_RD = 0x0002 , OP_RD = 0x0004 , ALL_RD = PO_RD | SO_RD | OP_RD , PO_WR = 0x0008 , SO_WR = 0x0010 , OP_WR = 0x0020 , ALL_WR = PO_WR | SO_WR | OP_WR , PO_RDWR = PO_RD | PO_WR , SO_RDWR = SO_RD | SO_WR , OP_RDWR = OP_RD | OP_WR , ALL_RDWR = PO_RDWR | SO_RDWR | OP_RDWR , RXPDO_MAP = 0x0040 , TXPDO_MAP = 0x0080 , RXTXPDO_MAP = 0x00C0 , BACKUP = 0x0100 , STARTUP = 0x0200 , ALL_LIST_FLAGS = RXPDO_MAP | TXPDO_MAP | BACKUP | STARTUP } |
Enum class representing various object flags. More... | |
enum class | ObjectDataType : uint16_t { UNSPECIFIED = 0x0000 , BOOLEAN = 0x0001 , BYTE = 0x001E , WORD = 0x001F , DWORD = 0x0020 , BIT1 = 0x0030 , BIT2 = 0x0031 , BIT3 = 0x0032 , BIT4 = 0x0033 , BIT5 = 0x0034 , BIT6 = 0x0035 , BIT7 = 0x0036 , BIT8 = 0x0037 , BIT9 = 0x0038 , BIT10 = 0x0039 , BIT11 = 0x003A , BIT12 = 0x003B , BIT13 = 0x003C , BIT14 = 0x003D , BIT15 = 0x003E , BIT16 = 0x003F , BITARR8 = 0x002D , BITARR16 = 0x002E , BITARR32 = 0x002F , INTEGER8 = 0x0002 , INTEGER16 = 0x0003 , INTEGER24 = 0x0010 , INTEGER32 = 0x0004 , INTEGER40 = 0x0012 , INTEGER48 = 0x0013 , INTEGER56 = 0x0014 , INTEGER64 = 0x0015 , UNSIGNED8 = 0x0005 , UNSIGNED16 = 0x0006 , UNSIGNED24 = 0x0016 , UNSIGNED32 = 0x0007 , UNSIGNED40 = 0x0018 , UNSIGNED48 = 0x0019 , UNSIGNED56 = 0x001A , UNSIGNED64 = 0x001B , REAL32 = 0x0008 , REAL64 = 0x0011 , GUID = 0x001D , VISIBLE_STRING = 0x0009 , OCTET_STRING = 0x000A , UNICODE_STRING = 0x000B , ARRAY_OF_INT = 0x0260 , ARRAY_OF_SINT = 0x0261 , ARRAY_OF_DINT = 0x0262 , ARRAY_OF_UDINT = 0x0263 , PDO_MAPPING = 0x0021 , IDENTITY = 0x0023 , COMMAND_PAR = 0x0025 , PDO_PARAMETER = 0x0027 , ENUM = 0x0028 , SM_SYNCHRONIZATION , RECORD = 0x002A , BACKUP_PARAMETER = 0x002B , MODULAR_DEVICE_PARAMETER = 0x002C , ERROR_SETTING = 0x0281 , DIAGNOSIS_HISTORY , EXTERNAL_SYNC_STATUS = 0x0283 , EXTERNAL_SYNC_SETTINGS = 0x0284 , DEFTYPE_FSOEFRAME = 0x0285 , DEFTYPE_FSOECOMMPAR , TIME_OF_DAY = 0x000C , TIME_DIFFERENCE , UTYPE_START = 0x0800 , UTYPE_END = 0x0FFF } |
Enumerates the supported data types for parameters. More... | |
enum class | ObjectCode : uint16_t { DEFTYPE = 0x0005 , DEFSTRUCT = 0x0006 , VAR = 0x0007 , ARRAY = 0x0008 , RECORD = 0x0009 } |
Enum class representing different object types used in the EtherCAT protocol. More... | |
enum class | PdoMappingStatus { NOT_MAPPED , MAPPED_RX_PDO , MAPPED_TX_PDO } |
Represents the PDO mapping status of a parameter. More... | |
enum class | DeviceFileError : uint8_t { None = 0x00 , NotFound = 0x01 , AccessDenied = 0x02 , StorageFull = 0x03 , IllegalRequest = 0x04 , PacketNumber = 0x05 , AlreadyExists = 0x06 , NoUser = 0x07 , BootstrapOnly = 0x08 , NotBootstrap = 0x09 , NoRights = 0x0A , ProgramError = 0x0B , Busy = 0x0C , FilenameLength = 0x0D , Timeout = 0x0E , FlashBusy = 0x28 , SuccessAcknowledgement = 0x58 , CommunicationBridgeError = 0x63 , EmptyContent = 0xD0 , UnexpectedNullTerminator = 0xD1 , ZipFailure = 0xD2 , UnzipFailure = 0xD3 , FlashFailure = 0xD4 , WriteFailure = 0xD5 , RemoveFailure = 0xD6 , Unknown = 0xFF } |
Enumeration of possible device file-related error codes. More... | |
Functions | |
void | from_json (const nlohmann::json &j, UiPdoMapping &p) |
Deserialize a JSON object into a UiPdoMapping structure. More... | |
void | from_json (const nlohmann::json &j, UiConfigJson &r) |
Deserialize a JSON object into a UiConfigJson structure. More... | |
std::string | convertParameterValueToString (const ParameterValue &value) |
Converts a ParameterValue to a string representation. More... | |
void | assignGroupsToParameters (std::vector< Parameter > ¶meters) |
Assigns group names to parameters based on their index and subindex. More... | |
void | logParametersMap (const std::unordered_map< Parameter::Address, Parameter > ¶metersMap, bool sortParameters=true) |
Logs the contents of a map of parameters with an option to sort them. More... | |
std::vector< std::uint8_t > | readCompleteDeviceFile (Device &device, const std::string &filename, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(20000)) |
Reads a file from the device, supporting both complete and multipart zipped files. More... | |
void | writeDeviceFileInOptionalParts (Device &device, const std::string &filename, const std::vector< std::uint8_t > &data, std::function< void(uint8_t, std::string)> progressCallback=nullptr, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(30000)) |
Write a file to a device, splitting it into parts if necessary. More... | |
void | removeDeviceFileOrParts (Device &device, const std::string &filename, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(20000)) |
Removes a file from the device, including handling multipart files if applicable. More... | |
void | writeFirmwarePackage (Device &device, const std::vector< std::uint8_t > &data, const std::vector< std::string > &skipFiles={}, std::function< void(uint8_t, std::string)> progressCallback=nullptr, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(60000)) |
Writes a firmware package to the given device. More... | |
bool | operator== (uint32_t lhs, EtherCATVendorID rhs) |
Compares a uint32_t value with an EtherCATVendorID enum value. More... | |
bool | operator== (EtherCATVendorID lhs, uint32_t rhs) |
Compares an EtherCATVendorID enum value with a uint32_t value. More... | |
ObjectFlags | operator| (ObjectFlags lhs, ObjectFlags rhs) |
Bitwise OR operator for ObjectFlags enum class. More... | |
ObjectFlags | operator& (ObjectFlags lhs, ObjectFlags rhs) |
Bitwise AND operator for ObjectFlags enum class. More... | |
ObjectFlags & | operator|= (ObjectFlags &lhs, ObjectFlags rhs) |
Bitwise OR assignment operator for ObjectFlags enum class. More... | |
ObjectFlags | SetObjectFlags (ObjectFlags b, ObjectFlags s, ObjectFlags p, ObjectFlags a) |
Combine multiple ObjectFlags values into one. More... | |
bool | isAppBinFile (const std::string &filename) |
Checks whether a given filename starts with "app_" and ends with ".bin". More... | |
bool | isComBinFile (const std::string &filename) |
Checks whether a given filename starts with "com_" and ends with ".bin". More... | |
bool | isFirmwareBinFile (const std::string &filename) |
Checks whether the given file is a firmware binary file. More... | |
std::string | deviceFileErrorToString (DeviceFileError error) |
Convert a DeviceFileError enum value to a human-readable string. More... | |
std::string | makeParameterId (int index, int subindex) |
Formats the given index and subindex into a parameter identifier string. More... | |
Variables | |
std::set< std::string > | kNonPartedFileNames |
Set of filenames that are always stored as complete files and can be read directly. More... | |
constexpr std::size_t | kDeviceFilePartSize |
using mm::comm::base::ParameterValue = typedef std::variant<bool, std::int8_t, std::int16_t, std::int32_t, std::int64_t, std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t, float, double, std::string, std::vector<std::uint8_t> > |
Alias for a variant type holding multiple value types.
|
strong |
Enumeration of possible device file-related error codes.
|
strong |
Enum class representing EtherCAT vendor IDs.
This enum class defines vendor IDs for EtherCAT devices, with each vendor ID being represented by a unique 32-bit unsigned integer value. It is used to identify different EtherCAT vendors in the system.
Enumerator | |
---|---|
SYNAPTICON | Vendor ID for Synapticon GmbH. Synapticon GmbH provides high-performance and compact servo drives. Vendor ID for Synapticon GmbH |
|
strong |
Enum class representing different object types used in the EtherCAT protocol.
This enum class defines various object types that represent the kind of object in an EtherCAT device. Each value corresponds to a specific type of object, such as a definition, variable, array, or record, in the EtherCAT protocol.
Enumerator | |
---|---|
DEFTYPE | Definition type object. |
DEFSTRUCT | Definition structure object. |
VAR | Variable object type. |
ARRAY | Array object type. |
RECORD | Record object type. |
|
strong |
Enumerates the supported data types for parameters.
This enumeration defines the various data types that parameters can use. Each entry is explicitly mapped to a 16-bit unsigned integer value. It includes basic types such as integers, floating-point numbers, strings, time-related types, bitfields, and user-defined types.
|
strong |
Enum class representing various object flags.
This enum class defines different flags used for controlling access, mapping, and other attributes. It is represented as a 16-bit unsigned integer.
Enumerator | |
---|---|
None | |
PO_RD | |
SO_RD | |
OP_RD | |
ALL_RD | |
PO_WR | |
SO_WR | |
OP_WR | |
ALL_WR | |
PO_RDWR | |
SO_RDWR | |
OP_RDWR | |
ALL_RDWR | |
RXPDO_MAP | |
TXPDO_MAP | |
RXTXPDO_MAP | |
BACKUP | |
STARTUP | |
ALL_LIST_FLAGS |
|
strong |
Represents the PDO mapping status of a parameter.
This enum indicates whether a parameter is not mapped in any PDO, or if it is mapped as a receive (RX) or transmit (TX) PDO.
Enumerator | |
---|---|
NOT_MAPPED | The parameter is not mapped in any PDO. |
MAPPED_RX_PDO | The parameter is mapped as a Receive PDO. |
MAPPED_TX_PDO | The parameter is mapped as a Transmit PDO. |
void mm::comm::base::assignGroupsToParameters | ( | std::vector< Parameter > & | parameters | ) |
Assigns group names to parameters based on their index and subindex.
This function iterates over a list of parameters and assigns a group name to each, based on the presence of subitems within the same index:
parameters | Vector of Parameter objects whose group fields will be updated in-place. |
std::string mm::comm::base::convertParameterValueToString | ( | const ParameterValue & | value | ) |
Converts a ParameterValue to a string representation.
This function uses std::visit
to convert the given ParameterValue
(a std::variant of numeric and string types) to a human-readable string.
bool
values are converted to "true"
or "false"
.std::to_string()
.std::string
values are returned as-is.value | The parameter value to convert. |
|
inline |
Convert a DeviceFileError enum value to a human-readable string.
error | The DeviceFileError value to convert. |
void mm::comm::base::from_json | ( | const nlohmann::json & | j, |
UiConfigJson & | r | ||
) |
Deserialize a JSON object into a UiConfigJson structure.
Extracts the "pdoMapping" field from the JSON object and converts it into a UiPdoMapping instance, which is assigned to the pdoMapping
member.
j | JSON object expected to contain a "pdoMapping" field. |
r | Reference to UiConfigJson struct to populate. |
void mm::comm::base::from_json | ( | const nlohmann::json & | j, |
UiPdoMapping & | p | ||
) |
Deserialize a JSON object into a UiPdoMapping structure.
This function parses the JSON object representing the PDO mappings, extracting the "rx" and "tx" maps. The JSON keys are hex strings (e.g., "0x1600") which are converted to uint16_t keys in the maps. The values are arrays of hex strings representing uint32_t entries.
j | JSON object expected to contain "rx" and "tx" mappings. |
p | Reference to UiPdoMapping struct to populate with parsed data. |
|
inline |
Checks whether a given filename starts with "app_" and ends with ".bin".
This function is used to determine if a file matches the expected naming pattern for application (firmware) binary files, such as "app_motion-drive-v5.4.1.bin".
filename | The name of the file to check. |
|
inline |
Checks whether a given filename starts with "com_" and ends with ".bin".
This function is used to determine if a file matches the expected naming pattern for communication (netX chip) binary files, such as "com_motion-drive-v5.4.1-9002-01.bin".
filename | The name of the file to check. |
|
inline |
Checks whether the given file is a firmware binary file.
This function returns true if the file is recognized as either an application binary (app_
) or a communication binary (com_
).
filename | The name of the file to check. |
void mm::comm::base::logParametersMap | ( | const std::unordered_map< Parameter::Address, Parameter > & | parametersMap, |
bool | sortParameters = true |
||
) |
Logs the contents of a map of parameters with an option to sort them.
This function takes a map of parameters indexed by (index, subindex) pairs, optionally sorts them by index and subindex (based on the sortParameters
flag), and logs each parameter's details including its name, access type, bit length, and other relevant information.
If the sortParameters
flag is true, the parameters will be sorted by index and subindex before logging. If sortParameters
is false, the parameters will be logged in their original order as they appear in the map.
parametersMap | A map where each key is a pair of (index, subindex) and the value is a Parameter object containing metadata. |
sortParameters | A boolean flag indicating whether to sort the parameters before logging. Default is true. If true, the parameters are sorted by index and subindex; if false, they are logged in their original order. |
|
inline |
Formats the given index and subindex into a parameter identifier string.
This function takes an index and a subindex and formats them into a string of the form "0xINDEX:SUBINDEX". The index is formatted as a 4-digit hexadecimal number, and the subindex is formatted as a 2-digit hexadecimal number.
index | The 16-bit index value (e.g., 0x2030). |
subindex | The 8-bit subindex value (e.g., 0x01). |
|
inline |
Bitwise AND operator for ObjectFlags enum class.
This operator allows for checking the intersection of two ObjectFlags
values using the bitwise AND operator.
lhs | Left-hand operand of the bitwise AND operation. |
rhs | Right-hand operand of the bitwise AND operation. |
ObjectFlags
value.
|
inline |
Compares an EtherCATVendorID enum value with a uint32_t value.
This operator allows comparison between an EtherCATVendorID enum value and a raw vendor ID (uint32_t). It converts the enum value to its underlying uint32_t type for the comparison.
lhs | The EtherCATVendorID enum value to compare. |
rhs | The raw vendor ID as a uint32_t. |
|
inline |
Compares a uint32_t value with an EtherCATVendorID enum value.
This operator allows comparison between a raw vendor ID (uint32_t) and an EtherCATVendorID enum value. It converts the enum to its underlying uint32_t type for the comparison.
lhs | The raw vendor ID as a uint32_t. |
rhs | The EtherCATVendorID enum value to compare. |
|
inline |
Bitwise OR operator for ObjectFlags enum class.
This operator allows for combining two ObjectFlags
values using the bitwise OR operator.
lhs | Left-hand operand of the bitwise OR operation. |
rhs | Right-hand operand of the bitwise OR operation. |
ObjectFlags
value.
|
inline |
Bitwise OR assignment operator for ObjectFlags enum class.
This operator allows the modification of an ObjectFlags
value by OR'ing it with another.
lhs | Left-hand operand, which will be modified with the OR operation. |
rhs | Right-hand operand to OR with the left-hand operand. |
ObjectFlags
value. std::vector< std::uint8_t > mm::comm::base::readCompleteDeviceFile | ( | Device & | device, |
const std::string & | filename, | ||
const std::chrono::steady_clock::duration | expiryTime = std::chrono::milliseconds(20000) |
||
) |
Reads a file from the device, supporting both complete and multipart zipped files.
This function handles reading a file from the specified device, covering several cases:
<filename>.zip.partNNN
. All available parts are read, concatenated, and then unzipped.If the resulting content is empty or unzipping yields no files, the function throws a std::runtime_error
.
device | Reference to the device to read from. |
filename | Name of the file to read. |
expiryTime | Maximum duration to wait for the operation (default: 20 seconds). |
std::runtime_error | If the file is empty, missing, or the unzipped content is empty. |
DeviceResponseException | If a device-specific error occurs during reading. |
boost::system::system_error | If socket communication with the device fails. |
Reads and concatenates multipart file segments from the device.
This lambda attempts to reconstruct a file split into multiple parts named using the pattern <filename>.zip.partNNN
, where NNN
is a zero-padded index. If the input filename does not already end with .zip
, the extension is appended automatically.
Reading stops when a part file is missing or empty. All successfully read parts are concatenated in order and returned as a single byte buffer.
filename | The base name of the file to read (with or without ".zip"). |
void mm::comm::base::removeDeviceFileOrParts | ( | Device & | device, |
const std::string & | filename, | ||
const std::chrono::steady_clock::duration | expiryTime = std::chrono::milliseconds(20000) |
||
) |
Removes a file from the device, including handling multipart files if applicable.
This function attempts to remove the specified file from the device by:
.zip.partXXX
), removing all corresponding parts.If no file or parts matching the filename are found, the function logs a warning and throws a std::runtime_error
.
device | Reference to the device from which the file will be removed. |
filename | Name of the file to remove. |
expiryTime | Maximum duration to wait for each removal operation before timing out. Defaults to 20 seconds. |
|
inline |
Combine multiple ObjectFlags
values into one.
This function is a convenience method that combines multiple ObjectFlags
values by OR'ing them together.
b | First ObjectFlags value. |
s | Second ObjectFlags value. |
p | Third ObjectFlags value. |
a | Fourth ObjectFlags value. |
ObjectFlags
values as a single ObjectFlags
value. void mm::comm::base::writeDeviceFileInOptionalParts | ( | Device & | device, |
const std::string & | filename, | ||
const std::vector< std::uint8_t > & | data, | ||
std::function< void(uint8_t, std::string)> | progressCallback = nullptr , |
||
const std::chrono::steady_clock::duration | expiryTime = std::chrono::milliseconds(30000) |
||
) |
Write a file to a device, splitting it into parts if necessary.
This function writes a file to the given device, handling both small and large files.
Progress can be tracked via an optional callback function receiving completion percentage (0–100).
device | Reference to the device object to write to. |
filename | Name of the file to write. |
data | Raw file data to write. |
progressCallback | Optional callback function called with progress percentage after each part. |
expiryTime | Maximum duration to wait for each transfer operation before timing out. Defaults to 30 seconds. |
std::runtime_error | If compression fails or any error occurs during file writing. |
void mm::comm::base::writeFirmwarePackage | ( | Device & | device, |
const std::vector< std::uint8_t > & | data, | ||
const std::vector< std::string > & | skipFiles = {} , |
||
std::function< void(uint8_t, std::string)> | progressCallback = nullptr , |
||
const std::chrono::steady_clock::duration | expiryTime = std::chrono::milliseconds(60000) |
||
) |
Writes a firmware package to the given device.
Unzips the provided firmware package data and writes each file to the device, unless the file name matches an entry in the skip list. Supports parted writing and optional progress reporting.
device | The target device to write the firmware files to. |
data | The firmware package as a vector of bytes (expected to be a zip archive). |
skipFiles | A list of file names to skip during the firmware update. |
progressCallback | Optional callback to report progress (accepts a percentage [0–100]). |
expiryTime | The maximum duration to wait for the operation to complete. Defaults to 60000 milliseconds. |
std::runtime_error | If no files are found in the package or if writing a file fails. |
|
inlineconstexpr |
Default part size (in bytes) for device file operations. Due to the 9 KB transfer limit imposed by the IgH EtherCAT master.
std::set< std::string > mm::comm::base::kNonPartedFileNames |
Set of filenames that are always stored as complete files and can be read directly.
This constant defines a collection of specific filenames that are known to be stored on the device as whole, unsplit files. These files do not require multipart handling or decompression and are accessed via a direct call to device.readFile()
.
readCompleteDeviceFile()
to bypass multipart reading and related processing logic.