import { round } from 'common/math'; import { formatPower } from '../format'; import { Fragment } from 'inferno'; import { useBackend, useLocalState } from '../backend'; import { Box, Button, Icon, LabeledList, ProgressBar, Stack, Section, Tabs, Slider } from '../components'; import { Window } from '../layouts'; import { capitalize } from 'common/string'; // Common power multiplier const POWER_MUL = 1e3; export const RCON = (props, context) => { return ( ); }; export const RCONContent = (props, context) => { const [tabIndex, setTabIndex] = useLocalState(context, 'tabIndex', 0); let body; if (tabIndex === 0) { body = ; } else if (tabIndex === 1) { body = ; } return ( setTabIndex(0)}> SMESs setTabIndex(1)}> Breakers {body} ); }; const RCONSmesList = (props, context) => { const { act, data } = useBackend(context); const { smes_info, pages, current_page } = data; const runCallback = (cb) => { return cb(); }; return (
{smes_info.map((smes) => ( ))} Page Selection:
{runCallback(() => { const row = []; for (let i = 1; i < pages; i++) { row.push( ); } return row; })}
); }; const SMESItem = (props, context) => { const { act } = useBackend(context); const { capacityPercent, capacity, charge, inputAttempt, inputting, inputLevel, inputLevelMax, inputAvailable, outputAttempt, outputting, outputLevel, outputLevelMax, outputUsed, RCON_tag, } = props.smes; return ( {RCON_tag} {round(charge / (1000 * 60), 1)} kWh / {round(capacity / (1000 * 60))} kWh ({capacityPercent}%) ); }; const SMESControls = (props, context) => { const { act } = useBackend(context); const { way, smes } = props; const { capacityPercent, capacity, charge, inputAttempt, inputting, inputLevel, inputLevelMax, inputAvailable, outputAttempt, outputting, outputLevel, outputLevelMax, outputUsed, RCON_tag, } = smes; let level; let levelMax; let available; let direction; let changeStatusAct; let changeAmountAct; let enabled; let powerColor; let powerTooltip; switch (way) { case 'input': level = inputLevel; levelMax = inputLevelMax; available = inputAvailable; direction = 'IN'; changeStatusAct = 'smes_in_toggle'; changeAmountAct = 'smes_in_set'; enabled = inputAttempt; powerColor = !inputAttempt ? null : inputting ? 'green' : 'yellow'; powerTooltip = !inputAttempt ? 'The SMES input is off.' : inputting ? 'The SMES is drawing power.' : 'The SMES lacks power.'; break; case 'output': level = outputLevel; levelMax = outputLevelMax; available = outputUsed; direction = 'OUT'; changeStatusAct = 'smes_out_toggle'; changeAmountAct = 'smes_out_set'; enabled = outputAttempt; powerColor = !outputAttempt ? null : outputting ? 'green' : 'yellow'; powerTooltip = !outputAttempt ? 'The SMES output is off.' : outputting ? 'The SMES is outputting power.' : 'The SMES lacks any draw.'; break; } return ( {capitalize(way)}