Skip to content

Commit 99af0a5

Browse files
committed
Changes needed for opmode to work
1 parent 51ae95d commit 99af0a5

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Base classes for SystemCore blocks interface."""
22

3-
from .opmode import OpMode, Teleop
3+
from .opmode import OpMode, Teleop, Auto, Test, Name, Group
44
from .mechanism import Mechanism
55
from .robot_base import RobotBase
66

7-
__all__ = ['OpMode', 'Teleop', 'Mechanism', 'RobotBase']
7+
__all__ = ['OpMode', 'Teleop', 'Auto', 'Test', 'Name', 'Group'
8+
'Mechanism', 'RobotBase']

server_python_scripts/blocks_base_classes/opmode.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,16 @@ def stop(self):
1111

1212
# For now this does nothing but it lets the decorator work
1313
def Teleop(OpMode):
14+
return OpMode
15+
16+
def Auto(OpMode):
17+
return OpMode
18+
19+
def Test(OpMode):
20+
return OpMode
21+
22+
def Name(OpMode, str):
23+
return OpMode
24+
25+
def Group(OpMode, str):
1426
return OpMode

src/editor/extended_python_generator.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ import * as MechanismContainerHolder from '../blocks/mrc_mechanism_component_hol
2626

2727
export class OpModeDetails {
2828
constructor(private name: string, private group : string, private enabled : boolean, private type : string) {}
29-
annotations() : string{
29+
annotations(className : string) : string{
3030
let code = '';
3131

3232
if (this.enabled){
3333
code += '@' + this.type + "\n";
3434

3535
if (this.name){
36-
code += '@name("' + this.name + '")\n';
36+
code += '@Name(' + className + ', "' + this.name + '")\n';
3737
}
3838
if (this.group){
39-
code += '@group("' + this.group + '")\n';
39+
code += '@Group(' + className + ', "' + this.group + '")\n';
4040
}
4141
}
4242
return code;
@@ -46,10 +46,10 @@ export class OpModeDetails {
4646
if (this.enabled){
4747
code += 'from blocks_base_classes import ' + this.type + '\n';
4848
if (this.name){
49-
code += 'from blocks_base_classes import name\n';
49+
code += 'from blocks_base_classes import Name\n';
5050
}
5151
if (this.group){
52-
code += 'from blocks_base_classes import group\n';
52+
code += 'from blocks_base_classes import Group\n';
5353
}
5454
}
5555

@@ -195,7 +195,7 @@ export class ExtendedPythonGenerator extends PythonGenerator {
195195
if (this.context && this.workspace) {
196196
const className = this.context.getClassName();
197197
const classParent = this.context.getClassParent();
198-
const annotations = this.details?.annotations();
198+
const annotations = this.details?.annotations(className);
199199
const import_annotations = this.details?.imports();
200200

201201
if(import_annotations){

0 commit comments

Comments
 (0)