Skip to content

Commit

Permalink
Test with staff bot and bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
snowNnik committed Oct 24, 2024
1 parent 5593dd8 commit 7beaff2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
14 changes: 7 additions & 7 deletions src/main/MainApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ const CODE_FILE_FILTERS: FileFilter[] = [
* Relative path to persistent configuration file.
*/
const CONFIG_RELPATH = 'dawn-config.json';
/**
* Path on robot to upload student code to.
*/
const REMOTE_CODE_PATH = '/home/pi/runtime/executor/studentcode.py';
/**
* Port to use when connecting to robot with SSH.
*/
const ROBOT_SSH_PORT = 22;
/**
* Username to log in as when connecting to robot with SSH.
*/
const ROBOT_SSH_USER = 'pi';
const ROBOT_SSH_USER = 'ubuntu';
/**
* Password to log in with when connecting to robot with SSH.
*/
const ROBOT_SSH_PASS = 'raspberry';
const ROBOT_SSH_PASS = 'potato';
/**
* Path on robot to upload student code to.
*/
const REMOTE_CODE_PATH = `/home/${ROBOT_SSH_USER}/runtime/executor/studentcode.py`;

/**
* Adds a listener for the main-quit IPC event fired by the renderer.
Expand Down Expand Up @@ -393,7 +393,7 @@ export default class MainApp implements MenuHandler, RuntimeCommsListener {
}

/**
* Tries to load code from a file into the editor. Fails is the user does not choose a path.
* Tries to load code from a file into the editor. Fails if the user does not choose a path.
*/
#openCodeFile() {
const success = this.#showCodePathDialog('load');
Expand Down
2 changes: 1 addition & 1 deletion src/main/network/PacketStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class PacketStream extends Transform {
while (this.#tryReadPacket(shouldConcatHeader)) {
shouldConcatHeader = false;
}
callback(null, chunk);
callback();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/network/RuntimeComms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ export default class RuntimeComms {
const { type, data } = packet;
switch (type) {
case MsgType.LOG:
// this.#commsListener.onReceiveRobotLogs(
// protos.Text.decode(data).payload,
// );
this.#commsListener.onReceiveRobotLogs(
protos.Text.decode(data).payload,
);
break;
case MsgType.TIME_STAMPS:
this.#commsListener.onReceiveLatency(
Expand Down
34 changes: 18 additions & 16 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useLayoutEffect,
} from 'react';
import Topbar from './Topbar';
import Editor, { EditorContentStatus } from './Editor';
import Editor, { EditorContentStatus, KeyboardControlsStatus } from './Editor';
import DeviceInfo from './DeviceInfo';
import AppConsole from './AppConsole';
import type AppConsoleMessage from '../common/AppConsoleMessage'; // No crypto package on the renderer
Expand Down Expand Up @@ -73,8 +73,8 @@ export default function App() {
// Whether a new message has been added to the AppConsole since it has been closed (if it is
// closed)
const [consoleIsAlerted, setConsoleIsAlerted] = useState(false);
// Whether keyboard controls are enabled
const [keyboardControlsEnabled, setKeyboardControlsEnabled] = useState(false);
// Whether keyboard controls are enabled.
const [keyboardControlsEnabled, setKeyboardControlsEnabled] = useState('on' as KeyboardControlsStatus);

Check failure on line 77 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Replace `'on'·as·KeyboardControlsStatus` with `⏎····'on'·as·KeyboardControlsStatus,⏎··`
// Whether the robot is running student code
const [robotRunning, setRobotRunning] = useState(false);
// Most recent window.innerWidth/Height needed to clamp editor and col size
Expand Down Expand Up @@ -268,7 +268,7 @@ export default function App() {
// Possible bug requires testing: gamepad indices are not preserved after filtering
// Filter removes disconnected and 'ghost'/duplicate gamepads (can be distinguished by
// different mapping)
const gamepadInputs = navigator
const inputs = navigator
.getGamepads()
.filter((gp): gp is Gamepad => gp !== null && gp.mapping === 'standard')
.map((gp) => {
Expand All @@ -285,17 +285,19 @@ export default function App() {
source: RobotInputSource.GAMEPAD,
});
});
const keyboardInput = new RobotInput({
connected: keyboardControlsEnabled,
axes: [],
buttons: keyboardControlsEnabled ? Number(keyboardBitmap) : 0,
source: RobotInputSource.KEYBOARD,
});
// Possible bug requires testing: is Runtime ok with mixed input sources in same packet?
window.electron.ipcRenderer.sendMessage('main-robot-input', [
...gamepadInputs,
keyboardInput,
]);
if (keyboardControlsEnabled != 'off') {

Check failure on line 288 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '!==' and instead saw '!='
// Possible bug requires testing: is Runtime ok with mixed input sources in same packet?
inputs.push(new RobotInput({

Check failure on line 290 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Insert `⏎··········`
connected: keyboardControlsEnabled == 'on',

Check failure on line 291 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Insert `··`

Check failure on line 291 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '===' and instead saw '=='
axes: [],

Check failure on line 292 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Insert `··`
buttons: keyboardControlsEnabled ? Number(keyboardBitmap) : 0,

Check failure on line 293 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Replace `··········` with `············`
source: RobotInputSource.KEYBOARD,

Check failure on line 294 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Insert `··`
}));

Check failure on line 295 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Replace `})` with `··}),⏎········`
if (keyboardControlsEnabled == 'offEdge') {

Check failure on line 296 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '===' and instead saw '=='
setKeyboardControlsEnabled('off');
}
}
window.electron.ipcRenderer.sendMessage('main-robot-input', inputs);
}, GAMEPAD_UPDATE_PERIOD_MS);
return () => {
clearInterval(gamepadUpdateInterval);
Expand Down Expand Up @@ -441,7 +443,7 @@ export default function App() {
setConsoleIsAlerted(false);
}}
onToggleKeyboardControls={() => {
setKeyboardControlsEnabled((v) => !v);
setKeyboardControlsEnabled((v) => v == 'on' ? 'offEdge' : 'on');
}}
/>
<ResizeBar
Expand Down
8 changes: 5 additions & 3 deletions src/renderer/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import './Editor.css';
*/
export type EditorContentStatus = 'clean' | 'dirty' | 'extDirty';

export type KeyboardControlsStatus = 'off' | 'on' | 'offEdge';

/**
* Tooltips to display over the editor status indicator.
*/
Expand Down Expand Up @@ -101,7 +103,7 @@ export default function Editor({
content: string;
consoleAlert: boolean;
consoleIsOpen: boolean;
keyboardControlsEnabled: boolean;
keyboardControlsEnabled: KeyboardControlsStatus;
robotConnected: boolean;
robotRunning: boolean;
onOpen: () => void;
Expand Down Expand Up @@ -133,7 +135,7 @@ export default function Editor({
return (
<div
className={`Editor${
keyboardControlsEnabled ? ' Editor-kbctrl-enabled' : ''
keyboardControlsEnabled == 'on' ? ' Editor-kbctrl-enabled' : ''
}`}
style={{ width }}
>
Expand Down Expand Up @@ -270,7 +272,7 @@ export default function Editor({
mode="python"
onChange={onChange}
value={content}
readOnly={keyboardControlsEnabled}
readOnly={keyboardControlsEnabled == 'on'}
/>
</div>
</div>
Expand Down

0 comments on commit 7beaff2

Please sign in to comment.