Link statistics. More...
#include <station_base.h>
Public Member Functions | |
FORCEINLINE | LinkStat (uint distance=1, uint capacity=0, uint frozen=0, uint usage=0) |
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 capacity by calculating the moving average. | |
FORCEINLINE uint | Usage () const |
Get an estimate of the current usage by calculating the moving average. | |
FORCEINLINE uint | Frozen () const |
Get the amount of frozen capacity. | |
FORCEINLINE void | Increase (uint capacity, uint usage) |
Add some capacity and usage. | |
FORCEINLINE void | Freeze (uint capacity) |
Freeze some of the capacity and prevent it from being decreased by the moving average. | |
FORCEINLINE void | Unfreeze (uint capacity) |
Thaw some of the frozen capacity and make it available for Decrease(). | |
FORCEINLINE void | Unfreeze () |
Thaw all frozen capacity. | |
FORCEINLINE bool | IsNull () const |
Check if the capacity is 0. | |
Static Public Attributes | |
static const uint | MIN_AVERAGE_LENGTH = 96 |
Minimum length of moving averages for capacity and usage. | |
Private Attributes | |
uint | capacity |
Capacity of the link. | |
uint | frozen |
Capacity of currently loading vehicles. | |
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 uint LinkStat::Capacity | ( | ) | const [inline] |
Get an estimate of the current capacity by calculating the moving average.
Definition at line 91 of file station_base.h.
References capacity, and MovingAverage< uint >::Monthly().
FORCEINLINE void LinkStat::Freeze | ( | uint | capacity | ) | [inline] |
Freeze some of the capacity and prevent it from being decreased by the moving average.
capacity | Amount of capacity to be frozen. |
Definition at line 130 of file station_base.h.
Referenced by IncreaseStats().
FORCEINLINE uint LinkStat::Frozen | ( | ) | const [inline] |
Get the amount of frozen capacity.
Definition at line 109 of file station_base.h.
References frozen.
Referenced by DecreaseFrozen().
FORCEINLINE void LinkStat::Increase | ( | uint | capacity, | |
uint | usage | |||
) | [inline] |
Add some capacity and usage.
capacity | Additional capacity. | |
usage | Additional usage. |
Definition at line 119 of file station_base.h.
Referenced by IncreaseStats().
FORCEINLINE bool LinkStat::IsNull | ( | ) | const [inline] |
Check if the capacity is 0.
This is necessary as Capacity() might return 0 even if there is a miniscule amount of capacity left.
Definition at line 158 of file station_base.h.
References capacity.
Referenced by DecreaseFrozen(), IncreaseStats(), and Station::RunAverages().
FORCEINLINE void LinkStat::Unfreeze | ( | uint | capacity | ) | [inline] |
Thaw some of the frozen capacity and make it available for Decrease().
capacity | Capacity to be thawed. |
Definition at line 140 of file station_base.h.
References frozen.
Referenced by DecreaseFrozen().
FORCEINLINE uint LinkStat::Usage | ( | ) | const [inline] |
Get an estimate of the current usage by calculating the moving average.
Usage.
Definition at line 100 of file station_base.h.
References MovingAverage< uint >::Monthly(), and usage.
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(), and IsNull().
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().