Motion Master
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
mm::comm::spoe::DeviceParameterRefresher Class Reference

Concrete refresher that uploads parameters from a device. More...

#include <spoe.h>

Inheritance diagram for mm::comm::spoe::DeviceParameterRefresher:
Inheritance graph
[legend]
Collaboration diagram for mm::comm::spoe::DeviceParameterRefresher:
Collaboration graph
[legend]

Public Member Functions

 DeviceParameterRefresher (mm::comm::base::Device &device, std::chrono::milliseconds interval)
 
- Public Member Functions inherited from mm::comm::base::DeviceParameterRefresher
 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

- Protected Attributes inherited from mm::comm::base::DeviceParameterRefresher
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::Addressaddresses_
 List of parameter addresses to refresh. More...
 
Devicedevice_
 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DeviceParameterRefresher()

mm::comm::spoe::DeviceParameterRefresher::DeviceParameterRefresher ( mm::comm::base::Device device,
std::chrono::milliseconds  interval 
)

Member Function Documentation

◆ refresh()

void mm::comm::spoe::DeviceParameterRefresher::refresh ( const std::vector< mm::comm::base::Parameter::Address > &  addresses)
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:

  • PRE-OPERATIONAL (2)
  • SAFE-OPERATIONAL (4)
  • OPERATIONAL (8)
Parameters
addressesA snapshot of the current parameter addresses (index and subindex pairs) to be uploaded.

Implements mm::comm::base::DeviceParameterRefresher.


The documentation for this class was generated from the following files: