From ca6de7a2df9c94be02a9d7cf80ef559cfd75bf11 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Tue, 4 Apr 2023 00:37:32 +0800 Subject: [PATCH] Add remote execution module Creates a new module, `remote_execution`, and populates it with the EV3's internal functions as an initial version. --- modules.json | 3 ++ src/bundles/remote_execution/ev3/index.ts | 55 +++++++++++++++++++++++ src/bundles/remote_execution/index.ts | 8 ++++ 3 files changed, 66 insertions(+) create mode 100644 src/bundles/remote_execution/ev3/index.ts create mode 100644 src/bundles/remote_execution/index.ts diff --git a/modules.json b/modules.json index cf4b5326a..de3832b5a 100644 --- a/modules.json +++ b/modules.json @@ -82,5 +82,8 @@ "tabs": [ "Repl" ] + }, + "remote_execution": { + "tabs": [] } } diff --git a/src/bundles/remote_execution/ev3/index.ts b/src/bundles/remote_execution/ev3/index.ts new file mode 100644 index 000000000..e59867bfd --- /dev/null +++ b/src/bundles/remote_execution/ev3/index.ts @@ -0,0 +1,55 @@ +import { Chapter } from 'js-slang/dist/types'; + +const ev3DeviceType = { + id: 'EV3', + name: 'Lego Mindstorms EV3', + // This list must be in the same order as the list here: + // https://github.com/source-academy/sinter/blob/master/devices/ev3/src/ev3_functions.c#L891 + internalFunctions: [ + 'ev3_pause', + 'ev3_connected', + 'ev3_motorA', + 'ev3_motorB', + 'ev3_motorC', + 'ev3_motorD', + 'ev3_motorGetSpeed', + 'ev3_motorSetSpeed', + 'ev3_motorStart', + 'ev3_motorStop', + 'ev3_motorSetStopAction', + 'ev3_motorGetPosition', + 'ev3_runForTime', + 'ev3_runToAbsolutePosition', + 'ev3_runToRelativePosition', + 'ev3_colorSensor', + 'ev3_colorSensorRed', + 'ev3_colorSensorGreen', + 'ev3_colorSensorBlue', + 'ev3_reflectedLightIntensity', + 'ev3_ambientLightIntensity', + 'ev3_colorSensorGetColor', + 'ev3_ultrasonicSensor', + 'ev3_ultrasonicSensorDistance', + 'ev3_gyroSensor', + 'ev3_gyroSensorAngle', + 'ev3_gyroSensorRate', + 'ev3_touchSensor1', + 'ev3_touchSensor2', + 'ev3_touchSensor3', + 'ev3_touchSensor4', + 'ev3_touchSensorPressed', + 'ev3_hello', + 'ev3_waitForButtonPress', + 'ev3_speak', + 'ev3_playSequence', + 'ev3_ledLeftGreen', + 'ev3_ledLeftRed', + 'ev3_ledRightGreen', + 'ev3_ledRightRed', + 'ev3_ledGetBrightness', + 'ev3_ledSetBrightness', + ], + languageChapter: Chapter.SOURCE_3, +}; + +export default ev3DeviceType; diff --git a/src/bundles/remote_execution/index.ts b/src/bundles/remote_execution/index.ts new file mode 100644 index 000000000..2e85754fb --- /dev/null +++ b/src/bundles/remote_execution/index.ts @@ -0,0 +1,8 @@ +/** + * Module responsible for execution of Source on remote devices. + * + * @module remote_execution + * @author Richard Dominick + */ + +export { default as EV3 } from './ev3';