Skip to content

Commit 78c9899

Browse files
committed
Put in comment that it is fake, and making it closer to looking real
1 parent d6fe739 commit 78c9899

File tree

1 file changed

+122
-49
lines changed

1 file changed

+122
-49
lines changed

src/toolbox/components_category.ts

Lines changed: 122 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
* @author [email protected] (Alan Smith)
2020
*/
2121

22+
/**
23+
* TODO: This is all fake right now, it will be generated dynamically
24+
* based on the components that are available in the current module.
25+
*/
26+
2227
import * as Blockly from 'blockly/core';
2328

2429
import * as toolboxItems from './items';
@@ -30,10 +35,78 @@ const CUSTOM_CATEGORY_COMPONENTS = 'COMPONENTS';
3035
export const category = {
3136
kind: 'category',
3237
categorystyle: MRC_CATEGORY_STYLE_COMPONENTS,
33-
name: 'Components',
34-
custom: CUSTOM_CATEGORY_COMPONENTS,
38+
name: 'Hardware',
39+
contents: [
40+
{
41+
kind: 'category',
42+
name: 'my_motor',
43+
custom: CUSTOM_CATEGORY_COMPONENTS,
44+
componentConfig: {
45+
name: 'my_motor',
46+
type: 'rev.SmartMotor',
47+
}
48+
},
49+
{
50+
kind: 'category',
51+
name: 'my_touch_sensor',
52+
custom: CUSTOM_CATEGORY_COMPONENTS,
53+
componentConfig: {
54+
name: 'my_touch_sensor',
55+
type: 'rev.TouchSensor',
56+
}
57+
},
58+
{
59+
kind: 'category',
60+
name: 'New',
61+
contents: [
62+
{
63+
kind: 'label',
64+
text: 'Components',
65+
},
66+
{
67+
kind: 'block',
68+
type: 'mrc_component',
69+
fields: {
70+
NAME: 'my_motor',
71+
TYPE: 'SmartMotor'
72+
},
73+
extraState: {
74+
importModule: 'smart_motor',
75+
params: [{ name: 'motor_port', type: 'int' }],
76+
hideParams: true
77+
},
78+
},
79+
{
80+
kind: 'block',
81+
type: 'mrc_component',
82+
fields: {
83+
NAME: 'my_color_range_sensor',
84+
TYPE: 'ColorRangeSensor'
85+
},
86+
extraState: {
87+
importModule: 'color_range_sensor',
88+
params: [{ name: 'i2c_port', type: 'int' }],
89+
hideParams: true
90+
},
91+
},
92+
{
93+
kind: 'block',
94+
type: 'mrc_component',
95+
fields: {
96+
NAME: 'my_touch_sensor',
97+
TYPE: 'RevTouchSensor'
98+
},
99+
extraState: {
100+
importModule: 'rev_touch_sensor',
101+
params: [{ name: 'smartIO_port', type: 'int' }],
102+
hideParams: true
103+
},
104+
},
105+
]
106+
},]
35107
};
36108

109+
37110
export class ComponentsCategory {
38111
private currentModule: commonStorage.Module | null = null;
39112

@@ -83,7 +156,7 @@ export class ComponentsCategory {
83156
EVENT_NAME: 'on_change',
84157
},
85158
},
86-
{
159+
{
87160
kind: 'block',
88161
type: 'mrc_event_handler',
89162
extraState: {
@@ -97,7 +170,7 @@ export class ComponentsCategory {
97170
EVENT_NAME: 'on_pressed',
98171
},
99172
},
100-
{
173+
{
101174
kind: 'block',
102175
type: 'mrc_event_handler',
103176
extraState: {
@@ -112,56 +185,56 @@ export class ComponentsCategory {
112185
},
113186
},
114187
// def set_speed(self, speed: float) -> None:
115-
{
116-
kind: 'block',
117-
type: 'mrc_call_python_function',
118-
extraState: {
119-
functionKind: 'instance_component',
120-
returnType: 'None',
121-
args: [
122-
{
123-
name: 'speed',
124-
type: 'float',
125-
},
126-
],
127-
tooltip: 'Set the motor to a speed between -1 and 1.',
128-
importModule: '',
129-
componentClassName: 'rev.SmartMotor',
130-
componentName: 'my_motor',
131-
},
132-
fields: {
133-
COMPONENT_NAME: 'my_motor',
134-
FUNC: 'set_speed',
135-
},
136-
inputs: {
137-
ARG0: {
138-
block: {
139-
type: 'math_number',
140-
fields: {
141-
NUM: 0.8,
142-
},
188+
{
189+
kind: 'block',
190+
type: 'mrc_call_python_function',
191+
extraState: {
192+
functionKind: 'instance_component',
193+
returnType: 'None',
194+
args: [
195+
{
196+
name: 'speed',
197+
type: 'float',
198+
},
199+
],
200+
tooltip: 'Set the motor to a speed between -1 and 1.',
201+
importModule: '',
202+
componentClassName: 'rev.SmartMotor',
203+
componentName: 'my_motor',
204+
},
205+
fields: {
206+
COMPONENT_NAME: 'my_motor',
207+
FUNC: 'set_speed',
208+
},
209+
inputs: {
210+
ARG0: {
211+
block: {
212+
type: 'math_number',
213+
fields: {
214+
NUM: 0.8,
143215
},
144216
},
145217
},
146218
},
147-
{
148-
kind: 'block',
149-
type: 'mrc_call_python_function',
150-
extraState: {
151-
functionKind: 'instance_component',
152-
returnType: 'None',
153-
args: [
154-
],
155-
tooltip: 'Stop the motor',
156-
importModule: '',
157-
componentClassName: 'rev.SmartMotor',
158-
componentName: 'my_motor',
159-
},
160-
fields: {
161-
COMPONENT_NAME: 'my_motor',
162-
FUNC: 'stop',
163-
},
219+
},
220+
{
221+
kind: 'block',
222+
type: 'mrc_call_python_function',
223+
extraState: {
224+
functionKind: 'instance_component',
225+
returnType: 'None',
226+
args: [
227+
],
228+
tooltip: 'Stop the motor',
229+
importModule: '',
230+
componentClassName: 'rev.SmartMotor',
231+
componentName: 'my_motor',
164232
},
233+
fields: {
234+
COMPONENT_NAME: 'my_motor',
235+
FUNC: 'stop',
236+
},
237+
},
165238
);
166239

167240
const toolboxInfo = {

0 commit comments

Comments
 (0)