Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
BandwidthMerger Struct Reference

Simple stride scheduler. More...

#include <BandwidthMerger.hxx>

Public Member Functions

 BandwidthMerger (uint8_t percent)
 Constructor.
 
bool step ()
 Runs one step.
 
void reset ()
 If the step function returned false, but still the first source was taken (e.g.
 

Public Attributes

uint8_t currentState_ {0}
 State of the current stride.
 
uint8_t percentFirst_
 Percentage of the bandwidth that should be assigned to the first source.
 

Detailed Description

Simple stride scheduler.

Emulates a two-way split of bandwidth between a first source and a second source. The percentage assigned to the first source is a parameter. Over time the fraction of outputs selected from the first source converges to this percentage.

Definition at line 46 of file BandwidthMerger.hxx.

Constructor & Destructor Documentation

◆ BandwidthMerger()

BandwidthMerger::BandwidthMerger ( uint8_t  percent)
inline

Constructor.

Parameters
percentis the percentage (0..100) of the bandwidth that should be assigned to the first source.

Definition at line 51 of file BandwidthMerger.hxx.

Member Function Documentation

◆ reset()

void BandwidthMerger::reset ( )
inline

If the step function returned false, but still the first source was taken (e.g.

because the second source was empty), call this function to clear the state. This will avoid selecting the first source twice in a row for example.

Definition at line 73 of file BandwidthMerger.hxx.

◆ step()

bool BandwidthMerger::step ( )
inline

Runs one step.

Returns
true if the first source is selected in this step.

Definition at line 58 of file BandwidthMerger.hxx.

Member Data Documentation

◆ currentState_

uint8_t BandwidthMerger::currentState_ {0}

State of the current stride.

This is always between 0..99. It represents the fractional steps that the first source has accumulated but not paid out in the form of selections yet.

Definition at line 83 of file BandwidthMerger.hxx.

◆ percentFirst_

uint8_t BandwidthMerger::percentFirst_

Percentage of the bandwidth that should be assigned to the first source.

Range 0..100.

Definition at line 86 of file BandwidthMerger.hxx.


The documentation for this struct was generated from the following file: