Link statistics. More...
#include <station_base.h>
Public Member Functions | |
LinkStat () | |
We don't allow creating a link stat without a timeout/length. | |
LinkStat (uint distance, uint capacity=1, uint usage=0) | |
Create a link stat with at least a distance. | |
void | Clear () |
Reset everything to 0. | |
void | Decrease () |
Apply the moving averages to usage and capacity. | |
uint | Capacity () const |
Get an estimate of the current the capacity by calculating the moving average. | |
uint | Usage () const |
Get an estimage of the current usage by calculating the moving average. | |
void | Increase (uint capacity, uint usage) |
Add some capacity and usage. | |
void | Refresh (uint min_capacity) |
Reset the timeout and make sure there is at least a minimum capacity. | |
bool | IsValid () const |
Check if the timeout has hit. | |
Static Public Attributes | |
static const uint | MIN_AVERAGE_LENGTH = 48 |
Minimum length of moving averages for capacity and usage. | |
Private Attributes | |
uint | capacity |
Capacity of the link. | |
uint | timeout |
Time until the link is removed. | |
uint | usage |
Usage of the link. | |
Friends | |
const SaveLoad * | GetLinkStatDesc () |
Wrapper function to get the LinkStat's internal structure while some of the variables are private. |
Link statistics.
They include figures for capacity and usage of a link. Both are moving averages which are increased for every vehicle arriving at the destination station and decreased in regular intervals. Additionally while a vehicle is loading at the source station part of the capacity is frozen and prevented from being decreased. This is done so that the link won't break down all the time when the typical "full load" order is used.
Definition at line 39 of file station_base.h.
LinkStat::LinkStat | ( | uint | distance, | |
uint | capacity = 1 , |
|||
uint | usage = 0 | |||
) | [inline] |
Create a link stat with at least a distance.
distance | Length for the moving average and link timeout. | |
capacity | Initial capacity of the link. | |
usage | Initial usage of the link. |
Definition at line 77 of file station_base.h.
References capacity.
uint LinkStat::Capacity | ( | ) | const [inline] |
Get an estimate of the current the capacity by calculating the moving average.
Definition at line 108 of file station_base.h.
References capacity, and MovingAverage< uint >::Monthly().
Referenced by LinkGraphOverlay::AddStats().
void LinkStat::Increase | ( | uint | capacity, | |
uint | usage | |||
) | [inline] |
Add some capacity and usage.
capacity | Additional capacity. | |
usage | Additional usage. |
Definition at line 127 of file station_base.h.
References timeout.
bool LinkStat::IsValid | ( | ) | const [inline] |
Check if the timeout has hit.
Definition at line 148 of file station_base.h.
References timeout.
uint LinkStat::Usage | ( | ) | const [inline] |
Get an estimage of the current usage by calculating the moving average.
Definition at line 117 of file station_base.h.
References MovingAverage< uint >::Monthly(), and usage.
Referenced by LinkGraphOverlay::AddStats().
const SaveLoad* GetLinkStatDesc | ( | ) | [friend] |
Wrapper function to get the LinkStat's internal structure while some of the variables are private.
Definition at line 249 of file station_sl.cpp.
uint LinkStat::capacity [private] |
Capacity of the link.
This is a moving average. Use MovingAverage::Monthly() to get a meaningful value.
Definition at line 45 of file station_base.h.
Referenced by Capacity(), Clear(), Decrease(), LinkStat(), and Refresh().
uint LinkStat::timeout [private] |
Time until the link is removed.
Decreases exponentially.
Definition at line 50 of file station_base.h.
Referenced by Clear(), Decrease(), Increase(), IsValid(), and Refresh().
uint LinkStat::usage [private] |
Usage of the link.
This is a moving average. Use MovingAverage::Monthly() to get a meaningful value.
Definition at line 56 of file station_base.h.
Referenced by Clear(), Decrease(), and Usage().