Loading files
442335385This file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/openharness-1322671404.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
import 'usage_window.dart';
/// How close a rate-limit window is to being spent.
///
/// Two thresholds, one step each: [warn] turns a figure amber and [critical]
/// turns it red. A third shade between them would be one nobody could name.
enum UsagePressure {
calm,
/// Amber. The window is worth noticing on the way past.
warn,
/// Red. The window is nearly spent.
critical,
}
/// Where a window starts reading amber.
///
/// The figure beside it is already exact, so this number is not carrying the
/// quantity — it is carrying the moment the quantity starts to matter.
const double kUsageWarnPercent = 80;
/// Where a window starts reading red.
const double kUsageCriticalPercent = 90;
UsagePressure usagePressureOf(double usedPercent) {
if (usedPercent >= kUsageCriticalPercent) return UsagePressure.critical;
if (usedPercent >= kUsageWarnPercent) return UsagePressure.warn;
return UsagePressure.calm;
}
extension UsageWindowPressure on UsageWindow {
UsagePressure get pressure => usagePressureOf(usedPercent);
}
442335385This file is pinned to the selected release. Download the original to open it in your design tool.