|
Motion Master 6.0.0-alpha.50
Next-generation motion control software
|
Keeps a reference-counted set of SDO parameters fresh by polling them off-thread. More...
#include <parameter_refresher.h>
Public Member Functions | |
| ParameterRefresher (DeviceManager &deviceManager) | |
Constructs a refresher over deviceManager. Does not start the thread — call start(). | |
| ~ParameterRefresher () | |
| Stops the thread (if running) and joins it. | |
| ParameterRefresher (const ParameterRefresher &)=delete | |
| ParameterRefresher & | operator= (const ParameterRefresher &)=delete |
| void | acquire (uint16_t devicePosition, uint16_t index, uint8_t subindex, std::chrono::milliseconds period) |
Adds a reference to keeping (devicePosition, index, subindex) fresh. | |
| void | release (uint16_t devicePosition, uint16_t index, uint8_t subindex) |
Drops a reference previously taken with acquire. The object stops being polled when its last reference is released. A release with no matching acquire is ignored. | |
| void | start () |
| Starts the background polling thread. Idempotent. | |
| void | stop () |
| Stops and joins the background polling thread. Idempotent. | |
| std::size_t | trackedCount () const |
| Number of distinct objects currently tracked (reference count > 0). For tests/UI. | |
| void | pollDue () |
| Polls every tracked object whose schedule is due as of now, advancing each one's next-due time (and applying error backoff). Called by the background thread each wake-up; exposed so tests can drive one pass deterministically without the thread. | |
Keeps a reference-counted set of SDO parameters fresh by polling them off-thread.
A monitoring that samples objects which are not PDO-mapped cannot read them from the process image — they have to be fetched over SDO, which is far too slow to do on the sampling tick. The refresher decouples the two: it owns one background thread that periodically calls DeviceManager::readDeviceParameter (a live SDO upload that refreshes the device's parameter cache), and the sampler then reads only that cache. Bus access is serialised by the driver's control-plane mutex; a single shared thread matches the bus being one serial resource.
Entries are reference-counted by (devicePosition, index, subindex): several monitorings asking for the same object poll it once, and it stops being polled only when the last one releases it. The effective poll period of an entry is the shortest period any requester asked for, clamped to a floor (SDO is slow; there is no point hammering the mailbox).
All public methods are thread-safe. The class is non-copyable and non-movable (it owns a thread and a mutex).
|
explicit |
Constructs a refresher over deviceManager. Does not start the thread — call start().
| mm::node::ParameterRefresher::~ParameterRefresher | ( | ) |
Stops the thread (if running) and joins it.
|
delete |
| void mm::node::ParameterRefresher::acquire | ( | uint16_t | devicePosition, |
| uint16_t | index, | ||
| uint8_t | subindex, | ||
| std::chrono::milliseconds | period | ||
| ) |
Adds a reference to keeping (devicePosition, index, subindex) fresh.
First reference starts polling the object; later references only raise the count and, if period is shorter than the current one, tighten the poll period. Pair every call with a release. period is clamped to an internal floor.
| devicePosition | 1-based bus position. |
| index | CoE object index. |
| subindex | CoE object subindex. |
| period | Desired maximum time between polls of this object. |
|
delete |
| void mm::node::ParameterRefresher::pollDue | ( | ) |
Polls every tracked object whose schedule is due as of now, advancing each one's next-due time (and applying error backoff). Called by the background thread each wake-up; exposed so tests can drive one pass deterministically without the thread.
| void mm::node::ParameterRefresher::release | ( | uint16_t | devicePosition, |
| uint16_t | index, | ||
| uint8_t | subindex | ||
| ) |
Drops a reference previously taken with acquire. The object stops being polled when its last reference is released. A release with no matching acquire is ignored.
| void mm::node::ParameterRefresher::start | ( | ) |
Starts the background polling thread. Idempotent.
| void mm::node::ParameterRefresher::stop | ( | ) |
Stops and joins the background polling thread. Idempotent.
| std::size_t mm::node::ParameterRefresher::trackedCount | ( | ) | const |
Number of distinct objects currently tracked (reference count > 0). For tests/UI.