Motion Master
|
Concrete refresher that uploads parameters from a device. More...
#include <spoe.h>
Public Member Functions | |
DeviceParameterRefresher (mm::comm::base::Device &device, std::chrono::milliseconds interval) | |
![]() | |
DeviceParameterRefresher (Device &device, std::chrono::milliseconds intervalBetweenUploads) | |
Constructor initializes the refresher with a device reference and upload interval. More... | |
~DeviceParameterRefresher () | |
Destructor ensures the refresher thread is stopped cleanly. More... | |
void | add (uint16_t index, uint8_t subindex) |
Add a parameter identified by (index, subindex) to the refresh list. More... | |
void | remove (uint16_t index, uint8_t subindex) |
Remove a parameter identified by (index, subindex) from the refresh list. More... | |
void | clear () |
Remove all parameters from the refresh list. More... | |
void | start () |
Starts the refresher background thread if it is not already running. More... | |
void | stop () |
Stops the refresher background thread if it is running. More... | |
void | triggerManualRefresh (bool async=false) |
Triggers a manual refresh of device parameters. More... | |
Protected Member Functions | |
void | refresh (const std::vector< mm::comm::base::Parameter::Address > &addresses) override |
Rereads the specified device parameters in a single message exchange. More... | |
virtual void | refresh (const std::vector< Parameter::Address > &addresses)=0 |
Rereads the specified device parameters. More... | |
Additional Inherited Members | |
![]() | |
std::chrono::milliseconds | interval_ |
Time to wait between consecutive parameter uploads. More... | |
std::condition_variable | cv_ |
Condition variable used to notify the worker thread. More... | |
std::mutex | mutex_ |
Mutex protecting access to shared data members. More... | |
std::vector< Parameter::Address > | addresses_ |
List of parameter addresses to refresh. More... | |
Device & | device_ |
Reference to the device instance used for uploading. More... | |
bool | running_ |
Flag indicating whether the refresher thread is running. More... | |
std::thread | worker_ |
The background thread performing periodic uploads. More... | |
Concrete refresher that uploads parameters from a device.
This class derives from mm::comm::DeviceParameterRefresher
and implements the refresh()
method to handle parameter uploads in bulk over SPoE.
The refresh()
method is called by the base class's worker thread. It receives a snapshot of the current parameters and performs a single bulk upload operation, which is more efficient for SPoE-based devices than uploading parameters one by one.
mm::comm::spoe::DeviceParameterRefresher::DeviceParameterRefresher | ( | mm::comm::base::Device & | device, |
std::chrono::milliseconds | interval | ||
) |
|
overrideprotectedvirtual |
Rereads the specified device parameters in a single message exchange.
This method is automatically called by the base class in a background thread. The implementation should handle uploading all parameters using the SPoE-specific protocol (readSdoBatch).
The refresh operation is performed only if the device is in a state that permits parameter reading—namely:
addresses | A snapshot of the current parameter addresses (index and subindex pairs) to be uploaded. |
Implements mm::comm::base::DeviceParameterRefresher.