Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing pressure on new robots #1329

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ public async Task AddPressureEntry(float pressureLevel, string isarId)
return;
}

if (robot.PressureLevel is null) return;

if (Math.Abs(pressureLevel - (float)robot.PressureLevel) > Tolerance) await robotService.UpdateRobotPressureLevel(robot.Id, pressureLevel);
if (robot.PressureLevel is null || Math.Abs(pressureLevel - (float)robot.PressureLevel) > Tolerance) await robotService.UpdateRobotPressureLevel(robot.Id, pressureLevel);

try { await timeseriesService.AddPressureEntry(robot.CurrentMissionId!, pressureLevel, robot.Id); }
catch (NpgsqlException e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const StyledTypography = styled(Typography)<{ $fontSize?: 24 | 16 | 18 | 32 | 40
font-size: ${(props) => props.$fontSize};
`
interface PressureStatusDisplayProps {
pressureInBar?: number
pressureInMilliBar?: number
pressureInBar: number
itemSize?: 24 | 16 | 18 | 32 | 40 | 48 | undefined
upperPressureWarningThreshold?: number
lowerPressureWarningThreshold?: number
Expand All @@ -28,27 +27,19 @@ export const PressureStatusDisplay = ({
lowerPressureWarningThreshold,
}: PressureStatusDisplayProps): JSX.Element => {
const barToMillibar = 1000
const pressureInMilliBar = `${Math.round(pressureInBar * barToMillibar)}mBar`
let icon_color: string = tokens.colors.interactive.primary__resting.hex
let pressureStatus: PressureStatus
let pressureInMilliBar: string = ''

if (!pressureInBar) {
pressureInMilliBar = ''
pressureStatus = PressureStatus.Default
return <></>
} else if (!upperPressureWarningThreshold || !lowerPressureWarningThreshold) {
if (!upperPressureWarningThreshold || !lowerPressureWarningThreshold) {
pressureStatus = PressureStatus.Normal
} else if (
pressureInBar * barToMillibar > upperPressureWarningThreshold ||
pressureInBar * barToMillibar < lowerPressureWarningThreshold
) {
pressureStatus = PressureStatus.Critical
} else {
if (
pressureInBar * barToMillibar > upperPressureWarningThreshold ||
pressureInBar * barToMillibar < lowerPressureWarningThreshold
) {
pressureStatus = PressureStatus.Critical
pressureInMilliBar = `${Math.round(pressureInBar * barToMillibar)}mBar`
} else {
pressureStatus = PressureStatus.Normal
pressureInMilliBar = `${Math.round(pressureInBar * barToMillibar)}mBar`
}
pressureStatus = PressureStatus.Normal
}

switch (pressureStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ export const RobotStatusCard = ({ robot }: RobotProps) => {
<VerticalContent $alignItems="end">
{robot.status !== RobotStatus.Offline ? (
<>
<PressureStatusDisplay
pressureInBar={robot.pressureLevel}
upperPressureWarningThreshold={robot.model.upperPressureWarningThreshold}
lowerPressureWarningThreshold={robot.model.lowerPressureWarningThreshold}
/>
{robot.pressureLevel && (
<PressureStatusDisplay
pressureInBar={robot.pressureLevel}
upperPressureWarningThreshold={robot.model.upperPressureWarningThreshold}
lowerPressureWarningThreshold={robot.model.lowerPressureWarningThreshold}
/>
)}
<BatteryStatusDisplay batteryLevel={robot.batteryLevel} />
</>
) : (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Pages/RobotPage/RobotPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const RobotPage = () => {
{selectedRobot.status !== RobotStatus.Offline && (
<>
<BatteryStatusDisplay itemSize={48} batteryLevel={selectedRobot.batteryLevel} />
{selectedRobot.model.upperPressureWarningThreshold && (
Eddasol marked this conversation as resolved.
Show resolved Hide resolved
{selectedRobot.pressureLevel && (
<PressureStatusDisplay
itemSize={48}
pressureInBar={selectedRobot.pressureLevel}
Expand Down
Loading