first commit
This commit is contained in:
commit
4b98219bf7
144 changed files with 31561 additions and 0 deletions
114
frontend/lib/thresholds.ts
Normal file
114
frontend/lib/thresholds.ts
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/**
|
||||
* Centralised operational thresholds.
|
||||
* Import from here instead of hardcoding values in individual pages.
|
||||
*/
|
||||
export const THRESHOLDS = {
|
||||
temp: {
|
||||
warn: 26, // °C
|
||||
critical: 28, // °C
|
||||
},
|
||||
humidity: {
|
||||
low: 30, // % RH — static risk below this
|
||||
warn: 65, // % RH
|
||||
critical: 80, // % RH
|
||||
},
|
||||
dewPoint: {
|
||||
warn: 15, // °C — condensation risk zone
|
||||
},
|
||||
power: {
|
||||
warn: 0.75, // fraction of rated capacity
|
||||
critical: 0.85,
|
||||
},
|
||||
rackPower: {
|
||||
warn: 7.5, // kW per rack
|
||||
critical: 9.5, // kW per rack
|
||||
rated: 10, // kW per rack (default rated capacity)
|
||||
},
|
||||
filter: {
|
||||
warn: 80, // Pa differential pressure
|
||||
critical: 120, // Pa
|
||||
ratePerDay: 1.2, // Pa/day assumed fouling rate
|
||||
replaceAt: 120, // Pa
|
||||
},
|
||||
cop: {
|
||||
warn: 1.5, // COP below this is inefficient
|
||||
},
|
||||
compressor: {
|
||||
warn: 0.80, // fraction of capacity
|
||||
critical: 0.95,
|
||||
},
|
||||
battery: {
|
||||
warn: 30, // % state of charge
|
||||
critical: 20, // %
|
||||
},
|
||||
fuel: {
|
||||
warn: 30, // % fuel level
|
||||
critical: 15, // %
|
||||
},
|
||||
ups: {
|
||||
loadWarn: 0.75, // fraction of rated load
|
||||
loadCritical: 0.90,
|
||||
},
|
||||
pue: {
|
||||
target: 1.4,
|
||||
warn: 1.6,
|
||||
critical: 2.0,
|
||||
},
|
||||
phaseImbalance: {
|
||||
warn: 5, // %
|
||||
critical: 15, // %
|
||||
},
|
||||
network: {
|
||||
cpuWarn: 70, // %
|
||||
cpuCritical: 90, // %
|
||||
memWarn: 70, // %
|
||||
memCritical: 85, // %
|
||||
tempWarn: 55, // °C
|
||||
tempCritical: 70, // °C
|
||||
},
|
||||
ashrae: {
|
||||
// ASHRAE A1 Class envelope
|
||||
tempMin: 15, // °C
|
||||
tempMax: 32, // °C
|
||||
rhMin: 20, // %
|
||||
rhMax: 80, // %
|
||||
},
|
||||
} as const;
|
||||
|
||||
/** Colour helper: returns a Tailwind text/bg colour token based on a value vs warn/critical pair */
|
||||
export function severityColor(
|
||||
value: number,
|
||||
warn: number,
|
||||
critical: number,
|
||||
invert = false, // set true when lower is worse (e.g. battery %)
|
||||
): "green" | "amber" | "red" {
|
||||
if (invert) {
|
||||
if (value <= critical) return "red";
|
||||
if (value <= warn) return "amber";
|
||||
return "green";
|
||||
}
|
||||
if (value >= critical) return "red";
|
||||
if (value >= warn) return "amber";
|
||||
return "green";
|
||||
}
|
||||
|
||||
export const COLOR_CLASSES = {
|
||||
green: {
|
||||
text: "text-green-400",
|
||||
bg: "bg-green-500/15",
|
||||
border: "border-green-500/30",
|
||||
badge: "bg-green-500/20 text-green-300",
|
||||
},
|
||||
amber: {
|
||||
text: "text-amber-400",
|
||||
bg: "bg-amber-500/15",
|
||||
border: "border-amber-500/30",
|
||||
badge: "bg-amber-500/20 text-amber-300",
|
||||
},
|
||||
red: {
|
||||
text: "text-red-400",
|
||||
bg: "bg-red-500/15",
|
||||
border: "border-red-500/30",
|
||||
badge: "bg-red-500/20 text-red-300",
|
||||
},
|
||||
} as const;
|
||||
Loading…
Add table
Add a link
Reference in a new issue