Motion Master
Loading...
Searching...
No Matches
Classes | Namespaces | Typedefs | Enumerations | Functions | Variables
base.h File Reference
#include <condition_variable>
#include <map>
#include <nlohmann/json.hpp>
#include <optional>
#include <set>
#include <sstream>
#include <string>
#include <typeindex>
#include <variant>
#include <vector>
#include "core/util.h"
Include dependency graph for base.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mm::comm::base::UiPdoMapping
 Represents the PDO mapping for RX and TX channels. More...
 
struct  mm::comm::base::UiConfigJson
 Top-level UI configuration JSON structure. More...
 
struct  mm::comm::base::PdoMappingEntry
 Represents a single PDO (Process Data Object) mapping entry. More...
 
struct  mm::comm::base::PdoMappings
 Represents the mapped PDO entries for a slave device. More...
 
struct  mm::comm::base::MappedParameterValue
 Represents a single mapped parameter value. More...
 
struct  mm::comm::base::MappedParameterValues
 Holds collections of mapped parameter values for RX and TX directions. More...
 
class  mm::comm::base::Parameter
 Represents a device parameter identified by index and subindex. More...
 
class  mm::comm::base::Device
 Abstract interface representing a generic device. More...
 
class  mm::comm::base::DeviceManager
 Manages devices and performs cyclic process data exchange. More...
 
class  mm::comm::base::DeviceResponseException
 Exception thrown when a device responds with an error. More...
 
class  mm::comm::base::DeviceParameterRefresher
 Base class for periodically refreshing a set of device parameters in a background thread. More...
 
struct  nlohmann::adl_serializer< mm::comm::base::ParameterValue >
 Specialization of adl_serializer for common::ParameterValue to enable nlohmann::json serialization and deserialization. More...
 

Namespaces

namespace  mm
 
namespace  mm::comm
 
namespace  mm::comm::base
 
namespace  nlohmann
 

Typedefs

using mm::comm::base::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  mm::comm::base::EtherCATVendorID : uint32_t { mm::comm::base::SYNAPTICON = 0x000022d2 }
 Enum class representing EtherCAT vendor IDs. More...
 
enum class  mm::comm::base::ObjectFlags : uint16_t {
  mm::comm::base::None = 0x0000 , mm::comm::base::PO_RD = 0x0001 , mm::comm::base::SO_RD = 0x0002 , mm::comm::base::OP_RD = 0x0004 ,
  mm::comm::base::ALL_RD = PO_RD | SO_RD | OP_RD , mm::comm::base::PO_WR = 0x0008 , mm::comm::base::SO_WR = 0x0010 , mm::comm::base::OP_WR = 0x0020 ,
  mm::comm::base::ALL_WR = PO_WR | SO_WR | OP_WR , mm::comm::base::PO_RDWR = PO_RD | PO_WR , mm::comm::base::SO_RDWR = SO_RD | SO_WR , mm::comm::base::OP_RDWR = OP_RD | OP_WR ,
  mm::comm::base::ALL_RDWR = PO_RDWR | SO_RDWR | OP_RDWR , mm::comm::base::RXPDO_MAP = 0x0040 , mm::comm::base::TXPDO_MAP = 0x0080 , mm::comm::base::RXTXPDO_MAP = 0x00C0 ,
  mm::comm::base::BACKUP = 0x0100 , mm::comm::base::STARTUP = 0x0200 , mm::comm::base::ALL_LIST_FLAGS = RXPDO_MAP | TXPDO_MAP | BACKUP | STARTUP
}
 Enum class representing various object flags. More...
 
enum class  mm::comm::base::ObjectDataType : uint16_t {
  mm::comm::base::UNSPECIFIED = 0x0000 , mm::comm::base::BOOLEAN = 0x0001 , mm::comm::base::BYTE = 0x001E , mm::comm::base::WORD = 0x001F ,
  mm::comm::base::DWORD = 0x0020 , mm::comm::base::BIT1 = 0x0030 , mm::comm::base::BIT2 = 0x0031 , mm::comm::base::BIT3 = 0x0032 ,
  mm::comm::base::BIT4 = 0x0033 , mm::comm::base::BIT5 = 0x0034 , mm::comm::base::BIT6 = 0x0035 , mm::comm::base::BIT7 = 0x0036 ,
  mm::comm::base::BIT8 = 0x0037 , mm::comm::base::BIT9 = 0x0038 , mm::comm::base::BIT10 = 0x0039 , mm::comm::base::BIT11 = 0x003A ,
  mm::comm::base::BIT12 = 0x003B , mm::comm::base::BIT13 = 0x003C , mm::comm::base::BIT14 = 0x003D , mm::comm::base::BIT15 = 0x003E ,
  mm::comm::base::BIT16 = 0x003F , mm::comm::base::BITARR8 = 0x002D , mm::comm::base::BITARR16 = 0x002E , mm::comm::base::BITARR32 = 0x002F ,
  mm::comm::base::INTEGER8 = 0x0002 , mm::comm::base::INTEGER16 = 0x0003 , mm::comm::base::INTEGER24 = 0x0010 , mm::comm::base::INTEGER32 = 0x0004 ,
  mm::comm::base::INTEGER40 = 0x0012 , mm::comm::base::INTEGER48 = 0x0013 , mm::comm::base::INTEGER56 = 0x0014 , mm::comm::base::INTEGER64 = 0x0015 ,
  mm::comm::base::UNSIGNED8 = 0x0005 , mm::comm::base::UNSIGNED16 = 0x0006 , mm::comm::base::UNSIGNED24 = 0x0016 , mm::comm::base::UNSIGNED32 = 0x0007 ,
  mm::comm::base::UNSIGNED40 = 0x0018 , mm::comm::base::UNSIGNED48 = 0x0019 , mm::comm::base::UNSIGNED56 = 0x001A , mm::comm::base::UNSIGNED64 = 0x001B ,
  mm::comm::base::REAL32 = 0x0008 , mm::comm::base::REAL64 = 0x0011 , mm::comm::base::GUID = 0x001D , mm::comm::base::VISIBLE_STRING = 0x0009 ,
  mm::comm::base::OCTET_STRING = 0x000A , mm::comm::base::UNICODE_STRING = 0x000B , mm::comm::base::ARRAY_OF_INT = 0x0260 , mm::comm::base::ARRAY_OF_SINT = 0x0261 ,
  mm::comm::base::ARRAY_OF_DINT = 0x0262 , mm::comm::base::ARRAY_OF_UDINT = 0x0263 , mm::comm::base::PDO_MAPPING = 0x0021 , mm::comm::base::IDENTITY = 0x0023 ,
  mm::comm::base::COMMAND_PAR = 0x0025 , mm::comm::base::PDO_PARAMETER = 0x0027 , mm::comm::base::ENUM = 0x0028 , mm::comm::base::SM_SYNCHRONIZATION ,
  mm::comm::base::RECORD = 0x002A , mm::comm::base::BACKUP_PARAMETER = 0x002B , mm::comm::base::MODULAR_DEVICE_PARAMETER = 0x002C , mm::comm::base::ERROR_SETTING = 0x0281 ,
  mm::comm::base::DIAGNOSIS_HISTORY , mm::comm::base::EXTERNAL_SYNC_STATUS = 0x0283 , mm::comm::base::EXTERNAL_SYNC_SETTINGS = 0x0284 , mm::comm::base::DEFTYPE_FSOEFRAME = 0x0285 ,
  mm::comm::base::DEFTYPE_FSOECOMMPAR , mm::comm::base::TIME_OF_DAY = 0x000C , mm::comm::base::TIME_DIFFERENCE , mm::comm::base::UTYPE_START = 0x0800 ,
  mm::comm::base::UTYPE_END = 0x0FFF
}
 Enumerates the supported data types for parameters. More...
 
enum class  mm::comm::base::ObjectCode : uint16_t {
  mm::comm::base::DEFTYPE = 0x0005 , mm::comm::base::DEFSTRUCT = 0x0006 , mm::comm::base::VAR = 0x0007 , mm::comm::base::ARRAY = 0x0008 ,
  mm::comm::base::RECORD = 0x0009
}
 Enum class representing different object types used in the EtherCAT protocol. More...
 
enum class  mm::comm::base::PdoMappingStatus { mm::comm::base::NOT_MAPPED , mm::comm::base::MAPPED_RX_PDO , mm::comm::base::MAPPED_TX_PDO }
 Represents the PDO mapping status of a parameter. More...
 
enum class  mm::comm::base::DeviceFileError : uint8_t {
  mm::comm::base::None = 0x00 , mm::comm::base::NotFound = 0x01 , mm::comm::base::AccessDenied = 0x02 , mm::comm::base::StorageFull = 0x03 ,
  mm::comm::base::IllegalRequest = 0x04 , mm::comm::base::PacketNumber = 0x05 , mm::comm::base::AlreadyExists = 0x06 , mm::comm::base::NoUser = 0x07 ,
  mm::comm::base::BootstrapOnly = 0x08 , mm::comm::base::NotBootstrap = 0x09 , mm::comm::base::NoRights = 0x0A , mm::comm::base::ProgramError = 0x0B ,
  mm::comm::base::Busy = 0x0C , mm::comm::base::FilenameLength = 0x0D , mm::comm::base::Timeout = 0x0E , mm::comm::base::FlashBusy = 0x28 ,
  mm::comm::base::SuccessAcknowledgement = 0x58 , mm::comm::base::CommunicationBridgeError = 0x63 , mm::comm::base::EmptyContent = 0xD0 , mm::comm::base::UnexpectedNullTerminator = 0xD1 ,
  mm::comm::base::ZipFailure = 0xD2 , mm::comm::base::UnzipFailure = 0xD3 , mm::comm::base::FlashFailure = 0xD4 , mm::comm::base::WriteFailure = 0xD5 ,
  mm::comm::base::RemoveFailure = 0xD6 , mm::comm::base::Unknown = 0xFF
}
 Enumeration of possible device file-related error codes. More...
 

Functions

void mm::comm::base::from_json (const nlohmann::json &j, UiPdoMapping &p)
 Deserialize a JSON object into a UiPdoMapping structure. More...
 
void mm::comm::base::from_json (const nlohmann::json &j, UiConfigJson &r)
 Deserialize a JSON object into a UiConfigJson structure. More...
 
bool mm::comm::base::operator== (uint32_t lhs, EtherCATVendorID rhs)
 Compares a uint32_t value with an EtherCATVendorID enum value. More...
 
bool mm::comm::base::operator== (EtherCATVendorID lhs, uint32_t rhs)
 Compares an EtherCATVendorID enum value with a uint32_t value. More...
 
ObjectFlags mm::comm::base::operator| (ObjectFlags lhs, ObjectFlags rhs)
 Bitwise OR operator for ObjectFlags enum class. More...
 
ObjectFlags mm::comm::base::operator& (ObjectFlags lhs, ObjectFlags rhs)
 Bitwise AND operator for ObjectFlags enum class. More...
 
ObjectFlags & mm::comm::base::operator|= (ObjectFlags &lhs, ObjectFlags rhs)
 Bitwise OR assignment operator for ObjectFlags enum class. More...
 
ObjectFlags mm::comm::base::SetObjectFlags (ObjectFlags b, ObjectFlags s, ObjectFlags p, ObjectFlags a)
 Combine multiple ObjectFlags values into one. More...
 
std::string mm::comm::base::convertParameterValueToString (const ParameterValue &value)
 Converts a ParameterValue to a string representation. More...
 
void mm::comm::base::assignGroupsToParameters (std::vector< Parameter > &parameters)
 Assigns group names to parameters based on their index and subindex. More...
 
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. More...
 
bool mm::comm::base::isAppBinFile (const std::string &filename)
 Checks whether a given filename starts with "app_" and ends with ".bin". More...
 
bool mm::comm::base::isComBinFile (const std::string &filename)
 Checks whether a given filename starts with "com_" and ends with ".bin". More...
 
bool mm::comm::base::isFirmwareBinFile (const std::string &filename)
 Checks whether the given file is a firmware binary file. More...
 
std::string mm::comm::base::deviceFileErrorToString (DeviceFileError error)
 Convert a DeviceFileError enum value to a human-readable string. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
std::string mm::comm::base::makeParameterId (int index, int subindex)
 Formats the given index and subindex into a parameter identifier string. More...
 
void nlohmann::to_json (nlohmann::json &j, const mm::comm::base::MappedParameterValue &p)
 Serialize MappedParameterValue to JSON. More...
 
void nlohmann::from_json (const nlohmann::json &j, mm::comm::base::MappedParameterValue &p)
 Deserialize JSON into MappedParameterValue. More...
 
void nlohmann::to_json (json &j, const mm::comm::base::MappedParameterValues &p)
 Serialize MappedParameterValues to JSON. More...
 
void nlohmann::from_json (const json &j, mm::comm::base::MappedParameterValues &p)
 Deserialize JSON into MappedParameterValues. More...
 

Variables

constexpr std::size_t mm::comm::base::kDeviceFilePartSize