|
Motion Master 6.0.0-alpha.50
Next-generation motion control software
|
A single object dictionary entry held by a Device.
More...
#include <device_parameter.h>
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< DeviceParameterValue > | defaultValue |
| Slave-reported default, when available. | |
| std::optional< DeviceParameterValue > | minValue |
| Slave-reported minimum, when available. | |
| std::optional< DeviceParameterValue > | maxValue |
| Slave-reported maximum, when available. | |
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.
| 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.
|
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.
T is not the active alternative. | 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).
|
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.
|
inline |
Returns the packed (index, subindex) key used in the parameter map.
| 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.
value is a string / raw bytes. | 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.
v cannot be coerced (e.g. a string into a numeric parameter, or a number into a string parameter).
|
inline |
Strongly-typed setValue overload; wraps v and coerces as above.
| uint16_t mm::node::DeviceParameter::access {} |
ObjAccess bitfield (read/write per-state flags).
| uint16_t mm::node::DeviceParameter::bitLength {} |
Bit length of the value.
| uint16_t mm::node::DeviceParameter::dataType {} |
ETG.1020 data type code (e.g. 0x0007 = UNSIGNED32).
| std::optional<DeviceParameterValue> mm::node::DeviceParameter::defaultValue |
Slave-reported default, when available.
| uint16_t mm::node::DeviceParameter::index {} |
CoE object index.
| std::optional<DeviceParameterValue> mm::node::DeviceParameter::maxValue |
Slave-reported maximum, when available.
| std::optional<DeviceParameterValue> mm::node::DeviceParameter::minValue |
Slave-reported minimum, when available.
| std::string mm::node::DeviceParameter::name |
Textual description from ecx_readOE.
| uint16_t mm::node::DeviceParameter::objectCode {} |
OTYPE_VAR / OTYPE_ARRAY / OTYPE_RECORD (ETG.1000.6 §5).
| uint8_t mm::node::DeviceParameter::subindex {} |
CoE object subindex.
| SyncState mm::node::DeviceParameter::syncState {SyncState::Unknown} |
Freshness of value relative to the device.
| std::optional<uint32_t> mm::node::DeviceParameter::unit |
ETG.1004 unit code, when reported.
| DeviceParameterValue mm::node::DeviceParameter::value |
Last-known value; type-appropriate zero before first read.