Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Mar 22, 2024
1 parent 86248ed commit d4870a0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/api-client/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { version as rmfModelVer } from 'rmf-models';

export const version = {
rmfModels: rmfModelVer,
rmfServer: 'aa96f48b48cdc810a8e26c65bdc241fed828daf7',
rmfServer: '86248edcf538b8784769586d406aca55978b1ef0',
openapiGenerator: '6.2.1',
};
5 changes: 3 additions & 2 deletions packages/api-server/api_server/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .rmf_api.cancel_task_response import TaskCancelResponse
from .rmf_api.dispatch_task_request import DispatchTaskRequest
from .rmf_api.dispatch_task_response import *
from .rmf_api.fleet_log import FleetLog as FleetLog
from .rmf_api.fleet_log import FleetLog
from .rmf_api.fleet_log_request import FleetLogRequest
from .rmf_api.fleet_log_response import FleetLogResponse
from .rmf_api.fleet_log_update import TaskEventLogUpdate as FleetLogUpdate
Expand All @@ -29,7 +29,8 @@
from .rmf_api.resume_task_response import TaskResumeResponse
from .rmf_api.rewind_task_request import TaskRewindRequest
from .rmf_api.rewind_task_response import TaskRewindResponse
from .rmf_api.robot_state import RobotState, Status
from .rmf_api.robot_state import RobotState
from .rmf_api.robot_state import Status as Status2
from .rmf_api.robot_task_request import RobotTaskRequest
from .rmf_api.robot_task_response import *
from .rmf_api.skip_phase_request import TaskPhaseSkipRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Box, SxProps, Typography, useTheme, useMediaQuery } from '@mui/material
import * as React from 'react';
import { ApiServerModelsRmfApiRobotStateStatus as Status } from 'api-client';
import { RobotTableData } from './robot-table';
import { robotStatusToUpperCase } from './utils';

export interface RobotDataGridTableProps {
onRobotClick?(ev: MuiEvent<React.MouseEvent<HTMLElement>>, robotName: RobotTableData): void;
Expand Down Expand Up @@ -73,7 +74,7 @@ export function RobotDataGridTable({ onRobotClick, robots }: RobotDataGridTableP
fontSize: isScreenHeightLessThan800 ? 10 : 16,
}}
>
{params.row.status.toUpperCase()}
{robotStatusToUpperCase(params.row.status)}
</Typography>
</Box>
);
Expand Down
18 changes: 8 additions & 10 deletions packages/react-components/lib/robots/robot-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import {
TableRow,
useTheme,
} from '@mui/material';
import type { RobotState } from 'api-client';
import { ApiServerModelsRmfApiRobotStateStatus as RobotStatus } from 'api-client';
import React from 'react';

type RobotStatus = Required<RobotState>['status'];

export interface RobotTableData {
fleet: string;
name: string;
Expand All @@ -37,22 +35,22 @@ const RobotRow = React.memo(
return {};
}
switch (status) {
case 'error':
case RobotStatus.Error:
return {
backgroundColor: theme.palette.error.main,
};
case 'charging':
case RobotStatus.Charging:
return {
backgroundColor: theme.palette.info.main,
};
case 'working':
case RobotStatus.Working:
return {
backgroundColor: theme.palette.success.main,
};
case 'idle':
case 'offline':
case 'shutdown':
case 'uninitialized':
case RobotStatus.Idle:
case RobotStatus.Offline:
case RobotStatus.Shutdown:
case RobotStatus.Uninitialized:
return {
backgroundColor: theme.palette.warning.main,
};
Expand Down
23 changes: 22 additions & 1 deletion packages/react-components/lib/robots/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiServerModelsRmfApiRobotStateStatus as Status } from 'api-client';
import { ApiServerModelsRmfApiRobotStateStatus as Status2 } from 'api-client';
import { RobotMode as RmfRobotMode } from 'rmf-models';

/**
Expand All @@ -8,6 +8,27 @@ export function robotHash(name: string, fleet: string): string {
return `${name}__${fleet}`;
}

export function robotStatusToUpperCase(status: Status2): string {
switch (status) {
case Status2.Charging:
return 'CHARGING';
case Status2.Idle:
return 'IDLE';
case Status2.Working:
return 'WORKING';
case Status2.Offline:
return 'OFFLINE';
case Status2.Uninitialized:
return 'UNINITIALIZED';
case Status2.Shutdown:
return 'SHUTDOWN';
case Status2.Error:
return 'ERROR';
default:
return `UNKNOWN (${status})`;
}
}

export function robotModeToString(robotMode: RmfRobotMode): string {
switch (robotMode.mode) {
case RmfRobotMode.MODE_CHARGING:
Expand Down

0 comments on commit d4870a0

Please sign in to comment.