|
Open Model Railroad Network (OpenMRN)
|
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. | |
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.
|
inline |
Constructor.
| percent | is the percentage (0..100) of the bandwidth that should be assigned to the first source. |
Definition at line 51 of file BandwidthMerger.hxx.
|
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.
|
inline |
Runs one step.
Definition at line 58 of file BandwidthMerger.hxx.
| 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.
| 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.