Link statistics. More...
#include <station_base.h>
Public Member Functions | |
LinkStat () | |
We don't allow creating a link stat without a timeout/length. | |
FORCEINLINE | LinkStat (uint distance, uint capacity=1, uint usage=0) |
Create a link stat with at least a distance. | |
FORCEINLINE void | Clear () |
Reset everything to 0. | |
FORCEINLINE void | Decrease () |
Apply the moving averages to usage and capacity. | |
FORCEINLINE uint | Capacity () const |
Get an estimate of the current the capacity by calculating the moving average. | |
FORCEINLINE uint | Usage () const |
Get an estimage of the current usage by calculating the moving average. | |
FORCEINLINE void | Increase (uint capacity, uint usage) |
Add some capacity and usage. | |
FORCEINLINE void | Refresh (uint min_capacity) |
Reset the timeout and make sure there is at least a minimum capacity. | |
FORCEINLINE 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 38 of file station_base.h.
FORCEINLINE 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 76 of file station_base.h.
References capacity.
FORCEINLINE uint LinkStat::Capacity | ( | ) | const [inline] |
Get an estimate of the current the capacity by calculating the moving average.
Definition at line 107 of file station_base.h.
References capacity, and MovingAverage< uint >::Monthly().
Referenced by LinkGraphOverlay::AddStats().
FORCEINLINE void LinkStat::Increase | ( | uint | capacity, | |
uint | usage | |||
) | [inline] |
Add some capacity and usage.
capacity | Additional capacity. | |
usage | Additional usage. |
Definition at line 126 of file station_base.h.
References timeout.
Referenced by IncreaseStats().
FORCEINLINE bool LinkStat::IsValid | ( | ) | const [inline] |
Check if the timeout has hit.
Definition at line 147 of file station_base.h.
References timeout.
Referenced by IncreaseStats(), and Station::RunAverages().
FORCEINLINE uint LinkStat::Usage | ( | ) | const [inline] |
Get an estimage of the current usage by calculating the moving average.
Definition at line 116 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 248 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 44 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 49 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 55 of file station_base.h.
Referenced by Clear(), Decrease(), and Usage().