|
Motion Master 6.0.0-alpha.86
Next-generation motion control software
|
One published generation of the bus: the driver that owns the socket, and the devices found on it. More...
#include <device_manager.h>
Public Member Functions | |
| Device * | find (uint16_t slavePosition) |
Device at slavePosition, or nullptr when the set holds none. | |
| const Device * | find (uint16_t slavePosition) const |
Const overload of find. Same contract. | |
Public Attributes | |
| std::shared_ptr< mm::comm::FieldbusDriver > | driver |
| The driver every device in this set talks through. Shared, so a retired set keeps it alive. | |
| std::vector< Device > | devices |
| The devices in bus order: index 0 is position 1. Frozen once the set is published. | |
| uint64_t | topologyGeneration = 0 |
The value DeviceManager::topologyGeneration reported when this set was published. | |
One published generation of the bus: the driver that owns the socket, and the devices found on it.
A set is built by init or scan, published once, and never modified after that. Publishing freezes the devices vector, not the devices in it — each Device guards its own parameter map with its own mutex.
The set is what makes device lifetime a refcount rather than a lock. Every off-RT caller works through a std::shared_ptr to one (DeviceManager::deviceSet), so a Device& stays valid for as long as the caller holds that pointer. A concurrent scan does not wait for the caller and does not invalidate the reference: it publishes a new set, and the old one dies when its last holder drops it. The retired devices keep working against their own driver, which the set also owns, so a transfer against hardware that is no longer on the bus fails cleanly instead of touching freed memory.
The RT thread does not touch the shared_ptr, because std::atomic<std::shared_ptr<T>> is not lock-free (and libc++ does not implement it at all). It reads a raw published pointer instead, drained by ProcessData::pauseCycle exactly as the process image is.
| Device * mm::node::DeviceSet::find | ( | uint16_t | slavePosition | ) |
Device at slavePosition, or nullptr when the set holds none.
| const Device * mm::node::DeviceSet::find | ( | uint16_t | slavePosition | ) | const |
Const overload of find. Same contract.
| std::vector<Device> mm::node::DeviceSet::devices |
The devices in bus order: index 0 is position 1. Frozen once the set is published.
| std::shared_ptr<mm::comm::FieldbusDriver> mm::node::DeviceSet::driver |
The driver every device in this set talks through. Shared, so a retired set keeps it alive.
| uint64_t mm::node::DeviceSet::topologyGeneration = 0 |
The value DeviceManager::topologyGeneration reported when this set was published.