-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathRemoteExecutionTypes.ts
108 lines (97 loc) · 3.14 KB
/
RemoteExecutionTypes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { SlingClient } from '@sourceacademy/sling-client';
import { Chapter } from 'js-slang/dist/types';
import { ExternalLibraryName } from 'src/commons/application/types/ExternalTypes';
import { WorkspaceLocation } from 'src/commons/workspace/WorkspaceTypes';
import { Ev3DevicePeripherals } from './RemoteExecutionEv3Types';
export const REMOTE_EXEC_FETCH_DEVICES = 'REMOTE_EXEC_FETCH_DEVICES';
export const REMOTE_EXEC_UPDATE_DEVICES = 'REMOTE_EXEC_UPDATE_DEVICES';
export const REMOTE_EXEC_UPDATE_SESSION = 'REMOTE_EXEC_UPDATE_SESSION';
export const REMOTE_EXEC_CONNECT = 'REMOTE_EXEC_CONNECT';
export const REMOTE_EXEC_DISCONNECT = 'REMOTE_EXEC_DISCONNECT';
export const REMOTE_EXEC_RUN = 'REMOTE_EXEC_RUN';
export const REMOTE_EXEC_REPL_INPUT = 'REMOTE_EXEC_REPL_INPUT';
export interface Device {
id: number;
title: string;
secret: string;
type: string;
peripherals?: Ev3DevicePeripherals;
}
export interface WebSocketEndpointInformation {
endpoint: string;
clientNamePrefix: string;
thingName: string;
}
export type DeviceConnection =
| { status: 'CONNECTING'; client?: SlingClient; endpoint?: WebSocketEndpointInformation }
| { status: 'CONNECTED'; client: SlingClient; endpoint: WebSocketEndpointInformation }
| { status: 'FAILED'; error?: string; client?: SlingClient };
export interface DeviceSession {
workspace: WorkspaceLocation;
device: Device;
connection: DeviceConnection;
}
export interface DeviceType {
id: string;
name: string;
internalFunctions: string[];
languageChapter: Chapter;
deviceLibraryName: ExternalLibraryName;
}
export const deviceTypes: DeviceType[] = [
{
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/ev3/devices/ev3/src/ev3_functions.c#L652
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,
deviceLibraryName: ExternalLibraryName.EV3
}
];
export const deviceTypesById: Map<string, DeviceType> = new Map(
deviceTypes.map(type => [type.id, type])
);