summaryrefslogtreecommitdiff
path: root/frontend/src/util/simulation-load.js
blob: 40b65917be4533ef21c7881c56041480ef14ffe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { SIM_HIGH_COLOR, SIM_LOW_COLOR, SIM_MID_HIGH_COLOR, SIM_MID_LOW_COLOR } from './colors'

export const LOAD_NAME_MAP = {
    LOAD: 'computational load',
    TEMPERATURE: 'temperature',
    MEMORY: 'memory use',
}

export function convertLoadToSimulationColor(load) {
    if (load <= 0.25) {
        return SIM_LOW_COLOR
    } else if (load <= 0.5) {
        return SIM_MID_LOW_COLOR
    } else if (load <= 0.75) {
        return SIM_MID_HIGH_COLOR
    } else {
        return SIM_HIGH_COLOR
    }
}

export function getStateLoad(loadMetric, state) {
    switch (loadMetric) {
        case 'LOAD':
            return state.loadFraction
        case 'TEMPERATURE':
            return state.temperatureC / 100.0
        case 'MEMORY':
            return state.inUseMemoryMb / 10000.0
        default:
            return -1
    }
}