Motion Master
Loading...
Searching...
No Matches
Classes | Namespaces | Typedefs | Enumerations | Functions
common.h File Reference
#include <algorithm>
#include <charconv>
#include <cstdint>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <nlohmann/json.hpp>
#include <optional>
#include <string>
#include <string_view>
#include <typeindex>
#include <unordered_map>
#include <utility>
#include <variant>
#include <vector>
#include <bit>
#include <type_traits>
Include dependency graph for common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  common::UiPdoMapping
 Represents the PDO mapping for RX and TX channels. More...
 
struct  common::UiConfigJson
 Top-level UI configuration JSON structure. More...
 
struct  common::PdoMappingEntry
 Represents a single PDO (Process Data Object) mapping entry. More...
 
struct  common::PdoMappings
 Represents the mapped PDO entries for a slave device. More...
 
class  common::Parameter
 Represents a device parameter identified by index and subindex. More...
 
class  common::Device
 Abstract interface representing a generic device. More...
 
struct  std::hash< std::pair< uint16_t, uint8_t > >
 

Namespaces

namespace  common
 
namespace  std
 Specialization of std::hash for std::pair<uint16_t, uint8_t>.
 

Typedefs

using common::ParameterKey = std::pair< uint16_t, uint8_t >
 Alias for a pair of uint16_t and uint8_t representing a parameter key. More...
 
using common::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  common::EtherCATVendorID : uint32_t { common::SYNAPTICON = 0x000022d2 }
 Enum class representing EtherCAT vendor IDs. More...
 
enum class  common::ObjectFlags : uint16_t {
  common::None = 0x0000 , common::PO_RD = 0x0001 , common::SO_RD = 0x0002 , common::OP_RD = 0x0004 ,
  common::ALL_RD = PO_RD | SO_RD | OP_RD , common::PO_WR = 0x0008 , common::SO_WR = 0x0010 , common::OP_WR = 0x0020 ,
  common::ALL_WR = PO_WR | SO_WR | OP_WR , common::PO_RDWR = PO_RD | PO_WR , common::SO_RDWR = SO_RD | SO_WR , common::OP_RDWR = OP_RD | OP_WR ,
  common::ALL_RDWR = PO_RDWR | SO_RDWR | OP_RDWR , common::RXPDO_MAP = 0x0040 , common::TXPDO_MAP = 0x0080 , common::RXTXPDO_MAP = 0x00C0 ,
  common::BACKUP = 0x0100 , common::STARTUP = 0x0200 , common::ALL_LIST_FLAGS = RXPDO_MAP | TXPDO_MAP | BACKUP | STARTUP
}
 Enum class representing various object flags. More...
 
enum class  common::ObjectDataType : uint16_t {
  common::UNSPECIFIED = 0x0000 , common::BOOLEAN = 0x0001 , common::BYTE = 0x001E , common::WORD = 0x001F ,
  common::DWORD = 0x0020 , common::BIT1 = 0x0030 , common::BIT2 = 0x0031 , common::BIT3 = 0x0032 ,
  common::BIT4 = 0x0033 , common::BIT5 = 0x0034 , common::BIT6 = 0x0035 , common::BIT7 = 0x0036 ,
  common::BIT8 = 0x0037 , common::BIT9 = 0x0038 , common::BIT10 = 0x0039 , common::BIT11 = 0x003A ,
  common::BIT12 = 0x003B , common::BIT13 = 0x003C , common::BIT14 = 0x003D , common::BIT15 = 0x003E ,
  common::BIT16 = 0x003F , common::BITARR8 = 0x002D , common::BITARR16 = 0x002E , common::BITARR32 = 0x002F ,
  common::INTEGER8 = 0x0002 , common::INTEGER16 = 0x0003 , common::INTEGER24 = 0x0010 , common::INTEGER32 = 0x0004 ,
  common::INTEGER40 = 0x0012 , common::INTEGER48 = 0x0013 , common::INTEGER56 = 0x0014 , common::INTEGER64 = 0x0015 ,
  common::UNSIGNED8 = 0x0005 , common::UNSIGNED16 = 0x0006 , common::UNSIGNED24 = 0x0016 , common::UNSIGNED32 = 0x0007 ,
  common::UNSIGNED40 = 0x0018 , common::UNSIGNED48 = 0x0019 , common::UNSIGNED56 = 0x001A , common::UNSIGNED64 = 0x001B ,
  common::REAL32 = 0x0008 , common::REAL64 = 0x0011 , common::GUID = 0x001D , common::VISIBLE_STRING = 0x0009 ,
  common::OCTET_STRING = 0x000A , common::UNICODE_STRING = 0x000B , common::ARRAY_OF_INT = 0x0260 , common::ARRAY_OF_SINT = 0x0261 ,
  common::ARRAY_OF_DINT = 0x0262 , common::ARRAY_OF_UDINT = 0x0263 , common::PDO_MAPPING = 0x0021 , common::IDENTITY = 0x0023 ,
  common::COMMAND_PAR = 0x0025 , common::PDO_PARAMETER = 0x0027 , common::ENUM = 0x0028 , common::SM_SYNCHRONIZATION ,
  common::RECORD = 0x002A , common::BACKUP_PARAMETER = 0x002B , common::MODULAR_DEVICE_PARAMETER = 0x002C , common::ERROR_SETTING = 0x0281 ,
  common::DIAGNOSIS_HISTORY , common::EXTERNAL_SYNC_STATUS = 0x0283 , common::EXTERNAL_SYNC_SETTINGS = 0x0284 , common::DEFTYPE_FSOEFRAME = 0x0285 ,
  common::DEFTYPE_FSOECOMMPAR , common::TIME_OF_DAY = 0x000C , common::TIME_DIFFERENCE , common::UTYPE_START = 0x0800 ,
  common::UTYPE_END = 0x0FFF
}
 Enumerates the supported data types for parameters. More...
 
enum class  common::ObjectCode : uint16_t {
  common::DEFTYPE = 0x0005 , common::DEFSTRUCT = 0x0006 , common::VAR = 0x0007 , common::ARRAY = 0x0008 ,
  common::RECORD = 0x0009
}
 Enum class representing different object types used in the EtherCAT protocol. More...
 

Functions

template<typename T >
common::parseHex (const std::string &s)
 Parses a hexadecimal string into an unsigned integer of type T. More...
 
void common::from_json (const nlohmann::json &j, UiPdoMapping &p)
 Deserialize a JSON object into a UiPdoMapping structure. More...
 
void common::from_json (const nlohmann::json &j, UiConfigJson &r)
 Deserialize a JSON object into a UiConfigJson structure. More...
 
bool common::operator== (uint32_t lhs, EtherCATVendorID rhs)
 Compares a uint32_t value with an EtherCATVendorID enum value. More...
 
bool common::operator== (EtherCATVendorID lhs, uint32_t rhs)
 Compares an EtherCATVendorID enum value with a uint32_t value. More...
 
ObjectFlags common::operator| (ObjectFlags lhs, ObjectFlags rhs)
 Bitwise OR operator for ObjectFlags enum class. More...
 
ObjectFlags common::operator& (ObjectFlags lhs, ObjectFlags rhs)
 Bitwise AND operator for ObjectFlags enum class. More...
 
ObjectFlags & common::operator|= (ObjectFlags &lhs, ObjectFlags rhs)
 Bitwise OR assignment operator for ObjectFlags enum class. More...
 
ObjectFlags common::SetObjectFlags (ObjectFlags b, ObjectFlags s, ObjectFlags p, ObjectFlags a)
 Combine multiple ObjectFlags values into one. More...
 
std::string common::convertParameterValueToString (const ParameterValue &value)
 Converts a ParameterValue to a string representation. More...
 
void common::logParametersMap (const std::unordered_map< std::pair< uint16_t, uint8_t >, Parameter > &parametersMap, bool sortParameters=true)
 Logs the contents of a map of parameters with an option to sort them. More...
 
template<typename T >
bool common::stringViewToNumber (std::string_view sv, T &result)
 Converts a string_view to a numeric type. More...
 
template<typename T >
std::vector< uint8_t > common::toBytes (T value, bool bigEndian=false)
 Converts a value of type T to a vector of bytes (uint8_t) in the specified byte order. More...
 
std::string common::makeParameterId (int index, int subindex)
 Formats the given index and subindex into a parameter identifier string. More...
 
std::string common::bytesToHexString (const std::vector< uint8_t > &data)
 Converts a vector of bytes into a space-separated hexadecimal string. More...
 
std::vector< uint8_t > common::readBinaryFile (const std::string &filename)
 Reads the contents of a binary file into a vector of uint8_t. More...
 
std::string common::joinStrings (const std::vector< std::string > &list, const std::string &delimiter)
 Joins a list of strings into a single string with a delimiter. More...
 
std::string common::formatMacAddress (const std::string &originalMacAddress)
 Formats a MAC address string to ensure each component is two digits and uppercase. More...