Commit 485a6a7
authored
Added toolbox blocks to add a mechanism to the robot (#187)
* In App.tsx:
Pass project to Editor.loadModuleBlocks
Call Editor.abandon and Editor.makeCurrent when switching between modules.
In editor.ts:
Added static variable currentEditor. Updated getEditorForBlocklyWorkspace to return currentEditor if workspace isn't found.
Added static method getCurrentEditor.
Added methods abandon and makeCurrent, which are called from App.tsx when switching between modules.
Add project parameter to loadModuleBlocks. Fetch all the mechanisms in the project.
In block event handler, call block.mrcOnLoad instead of block.onLoad.
Added methods getMechanisms, getComponentsFromMechanism, getEventsFromMechanism, and getMethodsFromMechanism.
In extended_python_generator.ts:
Renamed field hasHardware to hasAnyComponents.
Renamed field ports to componentPorts.
Renamed field hasEventHandler to hasAnyEventHandlers.
Removed method getListOfPorts. Added method getComponentPortParameters.
In hardware_category.ts:
Updated getHardwareCategory function so it fills in the + Mechanism category with blocks representing each the mechanisms in the project.
Changed getComponentsCategory function so it takes moduleType (string) instead hideParams (boolean).
In mrc_mechanism.ts:
Added method mrcOnLoad to handle changes to the mechanism definition.
Added function createMechanismBlock, which is called to put a add mechanism block in the toolbox when editing a robot.
In mrc_mechanism_component_holder.ts:
Updated code in pythonFromBlockInMechanism that calls generator.getComponentPortParameters().
Removed function getHardwarePorts. Added functions hasAnyComponents and getComponentPorts.
In mrc_component.ts:
Modified getComponent to collect the ports for the component.
Modified getAllPossibleComponents and createComponentBlock to take moduleType instead of hideParams.
Removed function getHardwarePorts. Added function getComponentPorts.
In mrc_class_method_def.ts, updated code in pythonFromBlock that calls generator.getComponentPortParameters().
In mrc_call_python_function.ts, renamed onLoad to mrcOnLoad.
In mrc_event_handler.ts:
Renamed mrcTypeOfSender to mrcSenderType.
Renamed typeOfSender to senderType.
Renamed onLoad to mrcOnLoad.
In client_sid_storage.ts, removed temporary code that handled old module type 'project'.
In server_python_scripts/blocks_base_classes/mechanism.py, added code for events.
Updated src/modules/ json files to set editable = false in the non-deletable mrc_class_method_def blocks. This prevents the user from disabling these blocks.
* Added code to create a toolbox subcategory under Hardware -> Mechanisms for each mechanism that has been added to the robot. Currently the subcategories don't have any blocks in them, but there is a TODO to add blocks for each method define in the mechanism.
* In mrc_call_python_function, updated mrcOnLoad for instance component blocks to look at all components that are in scope. If the current module is a mechanism then the components of the mechanism are in scope.1 parent c19dcd5 commit 485a6a7
File tree
17 files changed
+551
-352
lines changed- server_python_scripts/blocks_base_classes
- src
- blocks
- editor
- modules
- storage
- toolbox
17 files changed
+551
-352
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
6 | 29 | | |
7 | 30 | | |
8 | 31 | | |
| 32 | + | |
9 | 33 | | |
10 | 34 | | |
11 | 35 | | |
| 36 | + | |
12 | 37 | | |
13 | 38 | | |
14 | 39 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
| 421 | + | |
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
439 | 442 | | |
| 443 | + | |
440 | 444 | | |
441 | 445 | | |
442 | 446 | | |
443 | | - | |
| 447 | + | |
444 | 448 | | |
445 | 449 | | |
446 | 450 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
469 | | - | |
| 468 | + | |
| 469 | + | |
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
480 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
481 | 486 | | |
482 | 487 | | |
483 | 488 | | |
| |||
495 | 500 | | |
496 | 501 | | |
497 | 502 | | |
498 | | - | |
| 503 | + | |
499 | 504 | | |
500 | 505 | | |
501 | 506 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | | - | |
| 106 | + | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
428 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
429 | 432 | | |
430 | 433 | | |
431 | 434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
| 149 | + | |
147 | 150 | | |
148 | 151 | | |
149 | 152 | | |
| |||
153 | 156 | | |
154 | 157 | | |
155 | 158 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
| |||
197 | 198 | | |
198 | 199 | | |
199 | 200 | | |
200 | | - | |
| 201 | + | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
| |||
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
218 | | - | |
| 219 | + | |
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
| |||
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
227 | | - | |
| 228 | + | |
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
232 | | - | |
| 233 | + | |
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
| |||
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
244 | | - | |
| 245 | + | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
162 | | - | |
| 161 | + | |
| 162 | + | |
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
| 304 | + | |
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
| |||
0 commit comments