Skip to content

Commit

Permalink
Merge pull request #13 from pioneers/device-info
Browse files Browse the repository at this point in the history
Communicate with Runtime and display peripheral info
  • Loading branch information
snowNnik authored Oct 12, 2024
2 parents c011fda + f3d97ea commit b7c3835
Show file tree
Hide file tree
Showing 21 changed files with 1,099 additions and 126 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ module.exports = {
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
},
],
'no-redeclare': 'off', // False positives on typescript's function overloads
'no-undef': 'off', // False positives and typescript won't build if actually undefined vars
},
parserOptions: {
ecmaVersion: 2022,
Expand Down
18 changes: 4 additions & 14 deletions assets/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 4 additions & 14 deletions assets/upload.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions src/common/DeviceInfoState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Maps device types to user-friendly names.
*/
export const DeviceTypes: { [type: number]: string } = {
0: 'Dummy device',
1: 'Limit switch',
2: 'Line follower',
3: 'Battery buzzer',
4: 'Servo controller',
5: 'Polar bear motor controller',
6: 'KoalaBear motor controller',
7: 'Power distribution board',
8: 'Distance sensor',
};

/**
* Represents one lowcar device and its reported data.
*/
export default interface DeviceInfoState {
/**
* The device id: the device type and uid separated by an underscore.
*/
id: string;
/**
* Human-presentable data reported by the device, by the keys used by Robot.get_value.
*/
[key: string]: string;
}
49 changes: 27 additions & 22 deletions src/common/IpcEventTypes.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import type AppConsoleMessage from './AppConsoleMessage';
import type DeviceInfoState from './DeviceInfoState';
import { Mode as RobotRunMode } from '../../protos-main/protos';

/**
* IPC event channels used for communication from the main process to the renderer.
*/
export type RendererChannels =
| 'renderer-init'
| 'renderer-robot-update'
| 'renderer-battery-update'
| 'renderer-latency-update'
| 'renderer-devices-update'
| 'renderer-post-console'
| 'renderer-file-control'
| 'renderer-quit-request';
/**
* IPC event channels used for communication from the renderer to the main process.
*/
export type MainChannels = 'main-file-control' | 'main-quit';
export type MainChannels =
| 'main-file-control'
| 'main-quit'
| 'main-update-robot-mode';

/**
* Data for the renderer-init event, sent when the renderer process has finished initializing and is
Expand Down Expand Up @@ -174,27 +181,20 @@ export type RendererFileControlData =
*/
export type RendererPostConsoleData = AppConsoleMessage;
/**
* Data for the renderer-robot-update event when some info related to the robot or its connection
* changes.
* Data for the renderer-battery-update event sent by the main process to update the robot's battery
* voltage.
*/
export interface RendererRobotUpdateData {
/**
* User-presentable runtime version string. May be omitted if the value has not changed since the
* last update.
*/
runtimeVersion?: string;
/**
* Robot battery voltage in volts. May be omitted if the value has not changed since the last
* update.
*/
robotBatteryVoltage?: number;
/**
* Robot connection latency in milliseconds. May be omitted if the value has not changed since the
* last update.
*/
robotLatencyMs?: number;
}

export type RendererBatteryUpdateData = number;
/**
* Data for the renderer-latency-update event sent by the main process to update the displayed robot
* connection latency.
*/
export type RendererLatencyUpdateData = number;
/**
* Data for the renderer-devices-update event sent by the main process to update the state of
* connected lowcar devices.
*/
export type RendererDevicesUpdateData = DeviceInfoState[];
/**
* Data for a specialization of the main-file-control event, sent by the renderer to
* initiate/respond to a request to save the code.
Expand Down Expand Up @@ -300,3 +300,8 @@ export interface MainQuitData {
*/
showDirtyUploadWarning: boolean;
}
/**
* Data for the main-update-robot-mode event sent by the renderer to stop the robot or start it with
* a specified opmode.
*/
export type MainUpdateRobotModeData = RobotRunMode;
Loading

0 comments on commit b7c3835

Please sign in to comment.