Motion Master 6.0.0-alpha.50
Next-generation motion control software
Loading...
Searching...
No Matches
mm::node::DeviceParameter Struct Reference

A single object dictionary entry held by a Device. More...

#include <device_parameter.h>

Collaboration diagram for mm::node::DeviceParameter:
[legend]

Public Member Functions

uint32_t key () const
 Returns the packed (index, subindex) key used in the parameter map.
 
template<typename T >
std::expected< T, std::string > getValue () const
 Returns value as the requested type T.
 
std::expected< double, std::string > numeric () const
 Returns value coerced to a double, for any numeric parameter.
 
std::expected< void, std::string > setValue (const DeviceParameterValue &v)
 Sets value, coercing v into the parameter's declared data type.
 
template<typename T >
std::expected< void, std::string > setValue (const T &v)
 Strongly-typed setValue overload; wraps v and coerces as above.
 
bool isReadable () const
 Whether the object is readable in any state (ETG.1000.6 ObjAccess read bits 0-2).
 
bool inRange (const DeviceParameterValue &v) const
 Whether v lies within [minValue, maxValue].
 
DeviceParameterValue clampToRange (const DeviceParameterValue &v) const
 Returns v clamped to [minValue, maxValue].
 

Public Attributes

uint16_t index {}
 CoE object index.
 
uint8_t subindex {}
 CoE object subindex.
 
std::string name
 Textual description from ecx_readOE.
 
uint16_t objectCode {}
 OTYPE_VAR / OTYPE_ARRAY / OTYPE_RECORD (ETG.1000.6 §5).
 
uint16_t dataType {}
 ETG.1020 data type code (e.g. 0x0007 = UNSIGNED32).
 
uint16_t bitLength {}
 Bit length of the value.
 
uint16_t access {}
 ObjAccess bitfield (read/write per-state flags).
 
DeviceParameterValue value
 Last-known value; type-appropriate zero before first read.
 
SyncState syncState {SyncState::Unknown}
 Freshness of value relative to the device.
 
std::optional< uint32_t > unit
 ETG.1004 unit code, when reported.
 
std::optional< DeviceParameterValuedefaultValue
 Slave-reported default, when available.
 
std::optional< DeviceParameterValueminValue
 Slave-reported minimum, when available.
 
std::optional< DeviceParameterValuemaxValue
 Slave-reported maximum, when available.
 

Detailed Description

A single object dictionary entry held by a Device.

Combines immutable schema (index, subindex, name, data type, bit length, access flags, object code) with a value that is overwritten by SDO upload or PDO exchange. value is initialised to the type-appropriate zero so callers can std::visit it directly without checking for a read.

Member Function Documentation

◆ clampToRange()

DeviceParameterValue mm::node::DeviceParameter::clampToRange ( const DeviceParameterValue v) const

Returns v clamped to [minValue, maxValue].

Clamps numerically and returns a value of the same alternative as v. Returns v unchanged when it is non-numeric or no numeric bounds apply.

◆ getValue()

template<typename T >
std::expected< T, std::string > mm::node::DeviceParameter::getValue ( ) const
inline

Returns value as the requested type T.

Type-exact: T must be the active variant alternative (e.g. uint32_t for an UNSIGNED32 parameter — booleans are stored as uint8_t, see defaultValueForDataType). Use numeric() when you only need a number and do not care about the exact width.

Returns
The value, or an error string if T is not the active alternative.

◆ inRange()

bool mm::node::DeviceParameter::inRange ( const DeviceParameterValue v) const

Whether v lies within [minValue, maxValue].

Bounds are compared via numeric coercion. Returns true when v is non-numeric or when a bound is unset/non-numeric (i.e. no constraint to violate).

◆ isReadable()

bool mm::node::DeviceParameter::isReadable ( ) const
inline

Whether the object is readable in any state (ETG.1000.6 ObjAccess read bits 0-2).

Write-only objects (e.g. a command/trigger sub-object) report no read bits; an SDO upload of one aborts, so a bulk value refresh should skip them rather than log a spurious failure.

◆ key()

uint32_t mm::node::DeviceParameter::key ( ) const
inline

Returns the packed (index, subindex) key used in the parameter map.

◆ numeric()

std::expected< double, std::string > mm::node::DeviceParameter::numeric ( ) const

Returns value coerced to a double, for any numeric parameter.

The "don't worry about the type" accessor — handy because most parameters are numbers of varying width.

Returns
The numeric value, or an error string if value is a string / raw bytes.

◆ setValue() [1/2]

std::expected< void, std::string > mm::node::DeviceParameter::setValue ( const DeviceParameterValue v)

Sets value, coercing v into the parameter's declared data type.

Numeric inputs are static_cast into the alternative matching dataType, so setValue(5) works regardless of whether the parameter is UNSIGNED8 or UNSIGNED32 — unlike a bare variant assignment, which would store the wrong alternative. Does not touch syncState; the caller decides that.

Returns
Void on success, or an error string when v cannot be coerced (e.g. a string into a numeric parameter, or a number into a string parameter).

◆ setValue() [2/2]

template<typename T >
std::expected< void, std::string > mm::node::DeviceParameter::setValue ( const T &  v)
inline

Strongly-typed setValue overload; wraps v and coerces as above.

Member Data Documentation

◆ access

uint16_t mm::node::DeviceParameter::access {}

ObjAccess bitfield (read/write per-state flags).

◆ bitLength

uint16_t mm::node::DeviceParameter::bitLength {}

Bit length of the value.

◆ dataType

uint16_t mm::node::DeviceParameter::dataType {}

ETG.1020 data type code (e.g. 0x0007 = UNSIGNED32).

◆ defaultValue

std::optional<DeviceParameterValue> mm::node::DeviceParameter::defaultValue

Slave-reported default, when available.

◆ index

uint16_t mm::node::DeviceParameter::index {}

CoE object index.

◆ maxValue

std::optional<DeviceParameterValue> mm::node::DeviceParameter::maxValue

Slave-reported maximum, when available.

◆ minValue

std::optional<DeviceParameterValue> mm::node::DeviceParameter::minValue

Slave-reported minimum, when available.

◆ name

std::string mm::node::DeviceParameter::name

Textual description from ecx_readOE.

◆ objectCode

uint16_t mm::node::DeviceParameter::objectCode {}

OTYPE_VAR / OTYPE_ARRAY / OTYPE_RECORD (ETG.1000.6 §5).

◆ subindex

uint8_t mm::node::DeviceParameter::subindex {}

CoE object subindex.

◆ syncState

SyncState mm::node::DeviceParameter::syncState {SyncState::Unknown}

Freshness of value relative to the device.

◆ unit

std::optional<uint32_t> mm::node::DeviceParameter::unit

ETG.1004 unit code, when reported.

◆ value

DeviceParameterValue mm::node::DeviceParameter::value

Last-known value; type-appropriate zero before first read.


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