|
Motion Master 6.0.0-alpha.50
Next-generation motion control software
|
Borrowed view of a CiA402 drive — the device control state machine, operation modes, and the standard cyclic setpoints, expressed over a Device's parameter access.
More...
#include <cia402_drive.h>
Public Member Functions | |
| Cia402Drive (Device &device) | |
Binds an (unchecked) CiA402 view to device. Prefer createCia402Drive. | |
| std::expected< cia402::State, std::string > | state () const |
| Reads and decodes the current state machine state (statusword 0x6041). | |
| std::expected< uint16_t, std::string > | statusword () const |
| Reads the raw statusword (0x6041). | |
| std::expected< uint16_t, std::string > | controlword () const |
| Reads the last-commanded controlword (0x6040). | |
| std::expected< void, std::string > | setControlword (uint16_t value) |
| Writes the controlword (0x6040) verbatim. | |
| std::expected< cia402::OperationMode, std::string > | operationMode () const |
| Reads the active operation mode (display object 0x6061). | |
| std::expected< void, std::string > | setOperationMode (cia402::OperationMode mode) |
| Requests an operation mode (0x6060). The drive reflects it in 0x6061 once accepted. | |
| std::expected< void, std::string > | shutdown () |
| Shutdown: → ReadyToSwitchOn. | |
| std::expected< void, std::string > | switchOn () |
| Switch on: ReadyToSwitchOn → SwitchedOn (also disables operation from enabled). | |
| std::expected< void, std::string > | enableOperation () |
| Enable operation: SwitchedOn → OperationEnabled. | |
| std::expected< void, std::string > | disableVoltage () |
| Disable voltage: → SwitchOnDisabled. | |
| std::expected< void, std::string > | quickStop () |
| Quick stop: → QuickStopActive. | |
| std::expected< void, std::string > | faultReset () |
| Fault reset: pulses bit 7 (set then clear) to clear a latched fault. | |
| std::expected< void, std::string > | enable (std::chrono::milliseconds timeout=std::chrono::milliseconds(2000)) |
| Drives the state machine to OperationEnabled, walking every intermediate transition. | |
| std::expected< void, std::string > | disable () |
| Brings the drive to SwitchOnDisabled (disable voltage). Single transition. | |
| std::expected< void, std::string > | setTargetPosition (int32_t counts) |
| Writes target position (0x607A, INTEGER32) — CSP / PP. | |
| std::expected< void, std::string > | setTargetVelocity (int32_t value) |
| Writes target velocity (0x60FF, INTEGER32) — CSV / PV. | |
| std::expected< void, std::string > | setTargetTorque (int16_t perMille) |
| Writes target torque (0x6071, INTEGER16, per-mille of rated) — CST / PT. | |
| std::expected< int32_t, std::string > | positionActualValue () const |
| Reads actual position (0x6064, INTEGER32). | |
| std::expected< int32_t, std::string > | velocityActualValue () const |
| Reads actual velocity (0x606C, INTEGER32). | |
Public Member Functions inherited from mm::node::ProfileDevice | |
| ProfileDevice (Device &device) | |
Binds the view to device. The reference must outlive this view. | |
| Device & | device () |
| The underlying generic device this view operates on. | |
| const Device & | device () const |
Additional Inherited Members | |
Protected Attributes inherited from mm::node::ProfileDevice | |
| Device & | device_ |
| The borrowed device — the only data member permitted in the whole view chain. | |
Borrowed view of a CiA402 drive — the device control state machine, operation modes, and the standard cyclic setpoints, expressed over a Device's parameter access.
Every method routes through Device::readValue / writeValue, so it transparently uses the live PDO image while the device is exchanging (SAFE-OP/OP) and falls back to SDO otherwise — the caller never chooses the transport. The view is stateless (see ProfileDevice): the drive's actual state is its statusword, re-read on every query.
Construct via createCia402Drive, which validates that the device actually implements the profile before binding the view. The bare constructor is unchecked — for tests or already-validated paths.
CyclicTask that re-resolves its Device each cycle, not in a long-lived instance of this view.
|
inlineexplicit |
Binds an (unchecked) CiA402 view to device. Prefer createCia402Drive.
| std::expected< uint16_t, std::string > mm::node::Cia402Drive::controlword | ( | ) | const |
Reads the last-commanded controlword (0x6040).
| std::expected< void, std::string > mm::node::Cia402Drive::disable | ( | ) |
Brings the drive to SwitchOnDisabled (disable voltage). Single transition.
| std::expected< void, std::string > mm::node::Cia402Drive::disableVoltage | ( | ) |
Disable voltage: → SwitchOnDisabled.
| std::expected< void, std::string > mm::node::Cia402Drive::enable | ( | std::chrono::milliseconds | timeout = std::chrono::milliseconds(2000) | ) |
Drives the state machine to OperationEnabled, walking every intermediate transition.
Reads the state, issues the single transition that advances toward OperationEnabled (resetting first if faulted), and polls until the drive reaches it or timeout elapses. Intended for the control-plane (HTTP) thread — it briefly sleeps between polls and must never be called from the RT loop. For the drive to actually advance, process-data exchange must be running (the statusword has to update between polls).
| timeout | Maximum time to wait for OperationEnabled. |
| std::expected< void, std::string > mm::node::Cia402Drive::enableOperation | ( | ) |
Enable operation: SwitchedOn → OperationEnabled.
| std::expected< void, std::string > mm::node::Cia402Drive::faultReset | ( | ) |
Fault reset: pulses bit 7 (set then clear) to clear a latched fault.
| std::expected< cia402::OperationMode, std::string > mm::node::Cia402Drive::operationMode | ( | ) | const |
Reads the active operation mode (display object 0x6061).
| std::expected< int32_t, std::string > mm::node::Cia402Drive::positionActualValue | ( | ) | const |
Reads actual position (0x6064, INTEGER32).
| std::expected< void, std::string > mm::node::Cia402Drive::quickStop | ( | ) |
Quick stop: → QuickStopActive.
| std::expected< void, std::string > mm::node::Cia402Drive::setControlword | ( | uint16_t | value | ) |
Writes the controlword (0x6040) verbatim.
Sets every bit as given — use when composing a mode-specific controlword (e.g. the homing-start or new-setpoint bits). For pure state-machine transitions prefer the named transition methods, which preserve the mode-specific and halt bits.
| std::expected< void, std::string > mm::node::Cia402Drive::setOperationMode | ( | cia402::OperationMode | mode | ) |
Requests an operation mode (0x6060). The drive reflects it in 0x6061 once accepted.
| std::expected< void, std::string > mm::node::Cia402Drive::setTargetPosition | ( | int32_t | counts | ) |
Writes target position (0x607A, INTEGER32) — CSP / PP.
| std::expected< void, std::string > mm::node::Cia402Drive::setTargetTorque | ( | int16_t | perMille | ) |
Writes target torque (0x6071, INTEGER16, per-mille of rated) — CST / PT.
| std::expected< void, std::string > mm::node::Cia402Drive::setTargetVelocity | ( | int32_t | value | ) |
Writes target velocity (0x60FF, INTEGER32) — CSV / PV.
| std::expected< void, std::string > mm::node::Cia402Drive::shutdown | ( | ) |
Shutdown: → ReadyToSwitchOn.
| std::expected< State, std::string > mm::node::Cia402Drive::state | ( | ) | const |
Reads and decodes the current state machine state (statusword 0x6041).
| std::expected< uint16_t, std::string > mm::node::Cia402Drive::statusword | ( | ) | const |
Reads the raw statusword (0x6041).
| std::expected< void, std::string > mm::node::Cia402Drive::switchOn | ( | ) |
Switch on: ReadyToSwitchOn → SwitchedOn (also disables operation from enabled).
| std::expected< int32_t, std::string > mm::node::Cia402Drive::velocityActualValue | ( | ) | const |
Reads actual velocity (0x606C, INTEGER32).