Skip to content

Commit

Permalink
Add units for latency display (#92)
Browse files Browse the repository at this point in the history
* Add units for latency display

* Variable renaming
  • Loading branch information
ewc340 authored Apr 22, 2021
1 parent 264c7df commit 61a9ed7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion renderer/components/DNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Props = StateProps & OwnProps;

const LOW_LATENCY_THRESHOLD_MSEC = 200;
const HIGH_LATENCY_THRESHOLD_MSEC = 300;
const MSEC_IN_ONE_SECOND = 1000;

/**
* 3 Icons at the top right of Dawn: Tour, RobotIP, Upload
Expand All @@ -60,6 +61,15 @@ const DNavComponent = (props: Props) => {
}
}

const formatLatencyValue = (latency: number) => {
if (latency > MSEC_IN_ONE_SECOND) {
latency = latency / MSEC_IN_ONE_SECOND;
return `${latency} sec`;
}

return `${latency} ms`;
}

const {
connectionStatus,
runtimeStatus,
Expand Down Expand Up @@ -112,7 +122,7 @@ const DNavComponent = (props: Props) => {
/>
</Navbar.Text>
<Navbar.Text id="Latency">
<Label bsStyle={getLatencyThresholdColor(props.latencyValue)}>{`Latency: ${props.latencyValue}`}</Label>
<Label bsStyle={getLatencyThresholdColor(props.latencyValue)}>{`Latency: ${formatLatencyValue(props.latencyValue)}`}</Label>
</Navbar.Text>
<Navbar.Form pullRight>
<ButtonToolbar>
Expand Down

0 comments on commit 61a9ed7

Please sign in to comment.