Robot Raconteur Core C++ Library
|
Downsampler to manage rate of packets sent to client. More...
Inherits boost::enable_shared_from_this< BroadcastDownsampler >.
Public Member Functions | |
BroadcastDownsampler () | |
Construct a new BroadcastDownsampler. More... | |
void | Init (const boost::shared_ptr< ServerContext > &context, uint32_t default_downsample=0) |
Initialize the BroadcastDownsampler. More... | |
uint32_t | GetClientDownsample (uint32_t ep) |
Get the downsample for the specified client. More... | |
void | SetClientDownsample (uint32_t ep, uint32_t downsample) |
Set the downsample for the specified client. More... | |
void | BeginStep () |
Begin the update loop step. More... | |
void | EndStep () |
End the update loop step. More... | |
void | AddPipeBroadcaster (const boost::shared_ptr< PipeBroadcasterBase > &broadcaster) |
Add a PipeBroadcaster to the downsampler. More... | |
void | AddWireBroadcaster (const boost::shared_ptr< WireBroadcasterBase > &broadcaster) |
Add a WireBroadcaster to the downsampler. More... | |
Downsampler to manage rate of packets sent to client.
PipeBroadcaster and WireBroadcaster by default sends packets to all clients when a pipe packet is sent or the wire value is changed. The updates typically happen within a sensor or control loop, with the rate set by the specific device producing the updates. Some clients may require less frequent data, and may run in to bandwidth or processing issues if the data is sent at the full update rate. The BroadcastDownsampler is used to implement broadcaster predicates that will drop packets. Clients specify how many packets they want dropped between each packet sent. For instance, a downsample of 0 means that no packets are dropped. A downsample of 1 will drop every other packet. A downsample of two will drop 2 packets between sending 1 packet, etc. The downsample level for each client is set using SetClientDownsample(). This should be made available to the client using a property member.
PipeBroadcaster and WireBroadcaster must be added to the downsampler using AddPipeBroadcaster() and AddWireBroadcaster(), respectively. It is recommended that these functions be called within an IRRServiceObject::RRServiceObjectInit() override.
BeginStep() and EndStep() must be called for each iteration of the broadcasting loop. Use BroadcastDownsamplerStep for automatic management in the loop.
See com.robotraconteur.isoch.IsochDevice for the standard use of downsampling.
RobotRaconteur::BroadcastDownsampler::BroadcastDownsampler | ( | ) |
Construct a new BroadcastDownsampler.
Must use boost::make_shared<BroadcastDownsampler>()
Must call Init() after construction.
void RobotRaconteur::BroadcastDownsampler::AddPipeBroadcaster | ( | const boost::shared_ptr< PipeBroadcasterBase > & | broadcaster | ) |
Add a PipeBroadcaster to the downsampler.
Sets the predicate of the broadcaster to this downsampler
broadcaster | The broadcaster to add |
void RobotRaconteur::BroadcastDownsampler::AddWireBroadcaster | ( | const boost::shared_ptr< WireBroadcasterBase > & | broadcaster | ) |
Add a WireBroadcaster to the downsampler.
Sets the predicate of the broadcaster to this downsampler
broadcaster | The broadcaster to add |
void RobotRaconteur::BroadcastDownsampler::BeginStep | ( | ) |
Begin the update loop step.
Use BroadcastDownsamplerStep for automatic stepping
void RobotRaconteur::BroadcastDownsampler::EndStep | ( | ) |
End the update loop step.
Use BroadcastDownsamplerStep for automatic stepping
uint32_t RobotRaconteur::BroadcastDownsampler::GetClientDownsample | ( | uint32_t | ep | ) |
Get the downsample for the specified client.
ep | The uint32_t endpoint ID of the client |
void RobotRaconteur::BroadcastDownsampler::Init | ( | const boost::shared_ptr< ServerContext > & | context, |
uint32_t | default_downsample = 0 |
||
) |
Initialize the BroadcastDownsampler.
context | The ServerContext of the service |
default_downsample | The default downsample for clients |
void RobotRaconteur::BroadcastDownsampler::SetClientDownsample | ( | uint32_t | ep, |
uint32_t | downsample | ||
) |
Set the downsample for the specified client.
ep | The uint32_t endpoint ID of the client |
downsample | The desired downsample |