vex-ast 0.2.4__py3-none-any.whl → 0.2.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vex_ast/README.md +101 -51
- vex_ast/READMEAPI.md +133 -318
- vex_ast/__init__.py +81 -72
- vex_ast/ast/README.md +87 -87
- vex_ast/ast/__init__.py +74 -74
- vex_ast/ast/core.py +71 -71
- vex_ast/ast/expressions.py +276 -276
- vex_ast/ast/interfaces.py +208 -208
- vex_ast/ast/literals.py +80 -80
- vex_ast/ast/navigator.py +225 -225
- vex_ast/ast/operators.py +135 -135
- vex_ast/ast/statements.py +351 -351
- vex_ast/ast/validators.py +121 -120
- vex_ast/ast/vex_nodes.py +279 -279
- vex_ast/parser/README.md +47 -47
- vex_ast/parser/__init__.py +26 -26
- vex_ast/parser/factory.py +190 -190
- vex_ast/parser/interfaces.py +34 -34
- vex_ast/parser/python_parser.py +831 -786
- vex_ast/registry/README.md +107 -29
- vex_ast/registry/__init__.py +51 -51
- vex_ast/registry/api.py +190 -155
- vex_ast/registry/categories.py +179 -136
- vex_ast/registry/functions/__init__.py +10 -10
- vex_ast/registry/functions/constructors.py +71 -0
- vex_ast/registry/functions/display.py +146 -146
- vex_ast/registry/functions/drivetrain.py +163 -163
- vex_ast/registry/functions/initialize.py +31 -28
- vex_ast/registry/functions/motor.py +140 -140
- vex_ast/registry/functions/sensors.py +194 -194
- vex_ast/registry/functions/timing.py +103 -103
- vex_ast/registry/language_map.py +77 -77
- vex_ast/registry/registry.py +164 -153
- vex_ast/registry/signature.py +269 -191
- vex_ast/registry/simulation_behavior.py +8 -8
- vex_ast/registry/validation.py +43 -43
- vex_ast/serialization/__init__.py +37 -37
- vex_ast/serialization/json_deserializer.py +284 -275
- vex_ast/serialization/json_serializer.py +148 -148
- vex_ast/serialization/schema.py +492 -470
- vex_ast/types/README.md +78 -26
- vex_ast/types/__init__.py +140 -140
- vex_ast/types/base.py +83 -83
- vex_ast/types/enums.py +122 -97
- vex_ast/types/objects.py +64 -64
- vex_ast/types/primitives.py +68 -68
- vex_ast/types/type_checker.py +31 -31
- vex_ast/utils/README.md +39 -39
- vex_ast/utils/__init__.py +37 -37
- vex_ast/utils/errors.py +112 -112
- vex_ast/utils/source_location.py +38 -38
- vex_ast/utils/type_definitions.py +8 -8
- vex_ast/visitors/README.md +49 -49
- vex_ast/visitors/__init__.py +27 -27
- vex_ast/visitors/analyzer.py +102 -102
- vex_ast/visitors/base.py +133 -133
- vex_ast/visitors/printer.py +196 -146
- {vex_ast-0.2.4.dist-info → vex_ast-0.2.6.dist-info}/METADATA +206 -174
- vex_ast-0.2.6.dist-info/RECORD +64 -0
- vex_ast-0.2.4.dist-info/RECORD +0 -63
- {vex_ast-0.2.4.dist-info → vex_ast-0.2.6.dist-info}/WHEEL +0 -0
- {vex_ast-0.2.4.dist-info → vex_ast-0.2.6.dist-info}/licenses/LICENSE +0 -0
- {vex_ast-0.2.4.dist-info → vex_ast-0.2.6.dist-info}/top_level.txt +0 -0
@@ -1,195 +1,195 @@
|
|
1
|
-
from ..registry import registry
|
2
|
-
from ..signature import VexFunctionSignature, VexFunctionParameter, ParameterMode, SimulationCategory
|
3
|
-
from ...types.base import VOID, ANY
|
4
|
-
from ...types.primitives import INT, FLOAT, BOOL
|
5
|
-
from ...types.enums import DISTANCE_UNITS, ROTATION_UNITS, VELOCITY_UNITS
|
6
|
-
from ...types.objects import DISTANCE, ROTATION, INERTIAL, OPTICAL, GPS
|
7
|
-
|
8
|
-
def register_sensor_functions():
|
9
|
-
"""Register sensor-related functions in the registry"""
|
10
|
-
|
11
|
-
# Distance sensor functions
|
12
|
-
|
13
|
-
# Distance.object_distance() method
|
14
|
-
object_distance_params = [
|
15
|
-
VexFunctionParameter("units", DISTANCE_UNITS, "MM", description="Distance units")
|
16
|
-
]
|
17
|
-
|
18
|
-
object_distance_signature = VexFunctionSignature(
|
19
|
-
name="object_distance",
|
20
|
-
return_type=FLOAT,
|
21
|
-
parameters=object_distance_params,
|
22
|
-
description="Get the distance to the detected object",
|
23
|
-
category=SimulationCategory.SENSOR_READING,
|
24
|
-
python_name="object_distance",
|
25
|
-
cpp_name="objectDistance",
|
26
|
-
object_type=DISTANCE,
|
27
|
-
method_name="object_distance"
|
28
|
-
)
|
29
|
-
|
30
|
-
registry.register_function(object_distance_signature)
|
31
|
-
|
32
|
-
# Distance.is_object_detected() method
|
33
|
-
is_object_detected_signature = VexFunctionSignature(
|
34
|
-
name="is_object_detected",
|
35
|
-
return_type=BOOL,
|
36
|
-
parameters=[],
|
37
|
-
description="Check if an object is detected",
|
38
|
-
category=SimulationCategory.SENSOR_READING,
|
39
|
-
python_name="is_object_detected",
|
40
|
-
cpp_name="isObjectDetected",
|
41
|
-
object_type=DISTANCE,
|
42
|
-
method_name="is_object_detected"
|
43
|
-
)
|
44
|
-
|
45
|
-
registry.register_function(is_object_detected_signature)
|
46
|
-
|
47
|
-
# Rotation sensor functions
|
48
|
-
|
49
|
-
# Rotation.angle() method
|
50
|
-
angle_params = [
|
51
|
-
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
52
|
-
]
|
53
|
-
|
54
|
-
angle_signature = VexFunctionSignature(
|
55
|
-
name="angle",
|
56
|
-
return_type=FLOAT,
|
57
|
-
parameters=angle_params,
|
58
|
-
description="Get the angle of the rotation sensor",
|
59
|
-
category=SimulationCategory.SENSOR_READING,
|
60
|
-
python_name="angle",
|
61
|
-
cpp_name="angle",
|
62
|
-
object_type=ROTATION,
|
63
|
-
method_name="angle"
|
64
|
-
)
|
65
|
-
|
66
|
-
registry.register_function(angle_signature)
|
67
|
-
|
68
|
-
# Rotation.reset_position() method
|
69
|
-
reset_position_signature = VexFunctionSignature(
|
70
|
-
name="reset_position",
|
71
|
-
return_type=VOID,
|
72
|
-
parameters=[],
|
73
|
-
description="Reset the position of the rotation sensor",
|
74
|
-
category=SimulationCategory.SENSOR_READING,
|
75
|
-
python_name="reset_position",
|
76
|
-
cpp_name="resetPosition",
|
77
|
-
object_type=ROTATION,
|
78
|
-
method_name="reset_position"
|
79
|
-
)
|
80
|
-
|
81
|
-
registry.register_function(reset_position_signature)
|
82
|
-
|
83
|
-
# Rotation.set_position() method
|
84
|
-
set_position_params = [
|
85
|
-
VexFunctionParameter("value", FLOAT, description="Position value to set"),
|
86
|
-
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
87
|
-
]
|
88
|
-
|
89
|
-
set_position_signature = VexFunctionSignature(
|
90
|
-
name="set_position",
|
91
|
-
return_type=VOID,
|
92
|
-
parameters=set_position_params,
|
93
|
-
description="Set the position of the rotation sensor",
|
94
|
-
category=SimulationCategory.SENSOR_READING,
|
95
|
-
python_name="set_position",
|
96
|
-
cpp_name="setPosition",
|
97
|
-
object_type=ROTATION,
|
98
|
-
method_name="set_position"
|
99
|
-
)
|
100
|
-
|
101
|
-
registry.register_function(set_position_signature)
|
102
|
-
|
103
|
-
# Rotation.velocity() method
|
104
|
-
velocity_params = [
|
105
|
-
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
106
|
-
]
|
107
|
-
|
108
|
-
velocity_signature = VexFunctionSignature(
|
109
|
-
name="velocity",
|
110
|
-
return_type=FLOAT,
|
111
|
-
parameters=velocity_params,
|
112
|
-
description="Get the velocity of the rotation sensor",
|
113
|
-
category=SimulationCategory.SENSOR_READING,
|
114
|
-
python_name="velocity",
|
115
|
-
cpp_name="velocity",
|
116
|
-
object_type=ROTATION,
|
117
|
-
method_name="velocity"
|
118
|
-
)
|
119
|
-
|
120
|
-
registry.register_function(velocity_signature)
|
121
|
-
|
122
|
-
# Inertial sensor functions
|
123
|
-
|
124
|
-
# Inertial.calibrate() method
|
125
|
-
calibrate_signature = VexFunctionSignature(
|
126
|
-
name="calibrate",
|
127
|
-
return_type=VOID,
|
128
|
-
parameters=[],
|
129
|
-
description="Calibrate the inertial sensor",
|
130
|
-
category=SimulationCategory.SENSOR_READING,
|
131
|
-
python_name="calibrate",
|
132
|
-
cpp_name="calibrate",
|
133
|
-
object_type=INERTIAL,
|
134
|
-
method_name="calibrate"
|
135
|
-
)
|
136
|
-
|
137
|
-
registry.register_function(calibrate_signature)
|
138
|
-
|
139
|
-
# Inertial.is_calibrating() method
|
140
|
-
is_calibrating_signature = VexFunctionSignature(
|
141
|
-
name="is_calibrating",
|
142
|
-
return_type=BOOL,
|
143
|
-
parameters=[],
|
144
|
-
description="Check if the inertial sensor is calibrating",
|
145
|
-
category=SimulationCategory.SENSOR_READING,
|
146
|
-
python_name="is_calibrating",
|
147
|
-
cpp_name="isCalibrating",
|
148
|
-
object_type=INERTIAL,
|
149
|
-
method_name="is_calibrating"
|
150
|
-
)
|
151
|
-
|
152
|
-
registry.register_function(is_calibrating_signature)
|
153
|
-
|
154
|
-
# Inertial.heading() method
|
155
|
-
heading_params = [
|
156
|
-
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
157
|
-
]
|
158
|
-
|
159
|
-
heading_signature = VexFunctionSignature(
|
160
|
-
name="heading",
|
161
|
-
return_type=FLOAT,
|
162
|
-
parameters=heading_params,
|
163
|
-
description="Get the heading of the inertial sensor",
|
164
|
-
category=SimulationCategory.SENSOR_READING,
|
165
|
-
python_name="heading",
|
166
|
-
cpp_name="heading",
|
167
|
-
object_type=INERTIAL,
|
168
|
-
method_name="heading"
|
169
|
-
)
|
170
|
-
|
171
|
-
registry.register_function(heading_signature)
|
172
|
-
|
173
|
-
# Inertial.rotation() method
|
174
|
-
rotation_params = [
|
175
|
-
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
176
|
-
]
|
177
|
-
|
178
|
-
rotation_signature = VexFunctionSignature(
|
179
|
-
name="rotation",
|
180
|
-
return_type=FLOAT,
|
181
|
-
parameters=rotation_params,
|
182
|
-
description="Get the rotation of the inertial sensor",
|
183
|
-
category=SimulationCategory.SENSOR_READING,
|
184
|
-
python_name="rotation",
|
185
|
-
cpp_name="rotation",
|
186
|
-
object_type=INERTIAL,
|
187
|
-
method_name="rotation"
|
188
|
-
)
|
189
|
-
|
190
|
-
registry.register_function(rotation_signature)
|
191
|
-
|
192
|
-
# Add more sensor functions for other sensor types...
|
193
|
-
|
194
|
-
if __name__ == "__main__":
|
1
|
+
from ..registry import registry
|
2
|
+
from ..signature import VexFunctionSignature, VexFunctionParameter, ParameterMode, SimulationCategory
|
3
|
+
from ...types.base import VOID, ANY
|
4
|
+
from ...types.primitives import INT, FLOAT, BOOL
|
5
|
+
from ...types.enums import DISTANCE_UNITS, ROTATION_UNITS, VELOCITY_UNITS
|
6
|
+
from ...types.objects import DISTANCE, ROTATION, INERTIAL, OPTICAL, GPS
|
7
|
+
|
8
|
+
def register_sensor_functions():
|
9
|
+
"""Register sensor-related functions in the registry"""
|
10
|
+
|
11
|
+
# Distance sensor functions
|
12
|
+
|
13
|
+
# Distance.object_distance() method
|
14
|
+
object_distance_params = [
|
15
|
+
VexFunctionParameter("units", DISTANCE_UNITS, "MM", description="Distance units")
|
16
|
+
]
|
17
|
+
|
18
|
+
object_distance_signature = VexFunctionSignature(
|
19
|
+
name="object_distance",
|
20
|
+
return_type=FLOAT,
|
21
|
+
parameters=object_distance_params,
|
22
|
+
description="Get the distance to the detected object",
|
23
|
+
category=SimulationCategory.SENSOR_READING,
|
24
|
+
python_name="object_distance",
|
25
|
+
cpp_name="objectDistance",
|
26
|
+
object_type=DISTANCE,
|
27
|
+
method_name="object_distance"
|
28
|
+
)
|
29
|
+
|
30
|
+
registry.register_function(object_distance_signature)
|
31
|
+
|
32
|
+
# Distance.is_object_detected() method
|
33
|
+
is_object_detected_signature = VexFunctionSignature(
|
34
|
+
name="is_object_detected",
|
35
|
+
return_type=BOOL,
|
36
|
+
parameters=[],
|
37
|
+
description="Check if an object is detected",
|
38
|
+
category=SimulationCategory.SENSOR_READING,
|
39
|
+
python_name="is_object_detected",
|
40
|
+
cpp_name="isObjectDetected",
|
41
|
+
object_type=DISTANCE,
|
42
|
+
method_name="is_object_detected"
|
43
|
+
)
|
44
|
+
|
45
|
+
registry.register_function(is_object_detected_signature)
|
46
|
+
|
47
|
+
# Rotation sensor functions
|
48
|
+
|
49
|
+
# Rotation.angle() method
|
50
|
+
angle_params = [
|
51
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
52
|
+
]
|
53
|
+
|
54
|
+
angle_signature = VexFunctionSignature(
|
55
|
+
name="angle",
|
56
|
+
return_type=FLOAT,
|
57
|
+
parameters=angle_params,
|
58
|
+
description="Get the angle of the rotation sensor",
|
59
|
+
category=SimulationCategory.SENSOR_READING,
|
60
|
+
python_name="angle",
|
61
|
+
cpp_name="angle",
|
62
|
+
object_type=ROTATION,
|
63
|
+
method_name="angle"
|
64
|
+
)
|
65
|
+
|
66
|
+
registry.register_function(angle_signature)
|
67
|
+
|
68
|
+
# Rotation.reset_position() method
|
69
|
+
reset_position_signature = VexFunctionSignature(
|
70
|
+
name="reset_position",
|
71
|
+
return_type=VOID,
|
72
|
+
parameters=[],
|
73
|
+
description="Reset the position of the rotation sensor",
|
74
|
+
category=SimulationCategory.SENSOR_READING,
|
75
|
+
python_name="reset_position",
|
76
|
+
cpp_name="resetPosition",
|
77
|
+
object_type=ROTATION,
|
78
|
+
method_name="reset_position"
|
79
|
+
)
|
80
|
+
|
81
|
+
registry.register_function(reset_position_signature)
|
82
|
+
|
83
|
+
# Rotation.set_position() method
|
84
|
+
set_position_params = [
|
85
|
+
VexFunctionParameter("value", FLOAT, description="Position value to set"),
|
86
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
87
|
+
]
|
88
|
+
|
89
|
+
set_position_signature = VexFunctionSignature(
|
90
|
+
name="set_position",
|
91
|
+
return_type=VOID,
|
92
|
+
parameters=set_position_params,
|
93
|
+
description="Set the position of the rotation sensor",
|
94
|
+
category=SimulationCategory.SENSOR_READING,
|
95
|
+
python_name="set_position",
|
96
|
+
cpp_name="setPosition",
|
97
|
+
object_type=ROTATION,
|
98
|
+
method_name="set_position"
|
99
|
+
)
|
100
|
+
|
101
|
+
registry.register_function(set_position_signature)
|
102
|
+
|
103
|
+
# Rotation.velocity() method
|
104
|
+
velocity_params = [
|
105
|
+
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
106
|
+
]
|
107
|
+
|
108
|
+
velocity_signature = VexFunctionSignature(
|
109
|
+
name="velocity",
|
110
|
+
return_type=FLOAT,
|
111
|
+
parameters=velocity_params,
|
112
|
+
description="Get the velocity of the rotation sensor",
|
113
|
+
category=SimulationCategory.SENSOR_READING,
|
114
|
+
python_name="velocity",
|
115
|
+
cpp_name="velocity",
|
116
|
+
object_type=ROTATION,
|
117
|
+
method_name="velocity"
|
118
|
+
)
|
119
|
+
|
120
|
+
registry.register_function(velocity_signature)
|
121
|
+
|
122
|
+
# Inertial sensor functions
|
123
|
+
|
124
|
+
# Inertial.calibrate() method
|
125
|
+
calibrate_signature = VexFunctionSignature(
|
126
|
+
name="calibrate",
|
127
|
+
return_type=VOID,
|
128
|
+
parameters=[],
|
129
|
+
description="Calibrate the inertial sensor",
|
130
|
+
category=SimulationCategory.SENSOR_READING,
|
131
|
+
python_name="calibrate",
|
132
|
+
cpp_name="calibrate",
|
133
|
+
object_type=INERTIAL,
|
134
|
+
method_name="calibrate"
|
135
|
+
)
|
136
|
+
|
137
|
+
registry.register_function(calibrate_signature)
|
138
|
+
|
139
|
+
# Inertial.is_calibrating() method
|
140
|
+
is_calibrating_signature = VexFunctionSignature(
|
141
|
+
name="is_calibrating",
|
142
|
+
return_type=BOOL,
|
143
|
+
parameters=[],
|
144
|
+
description="Check if the inertial sensor is calibrating",
|
145
|
+
category=SimulationCategory.SENSOR_READING,
|
146
|
+
python_name="is_calibrating",
|
147
|
+
cpp_name="isCalibrating",
|
148
|
+
object_type=INERTIAL,
|
149
|
+
method_name="is_calibrating"
|
150
|
+
)
|
151
|
+
|
152
|
+
registry.register_function(is_calibrating_signature)
|
153
|
+
|
154
|
+
# Inertial.heading() method
|
155
|
+
heading_params = [
|
156
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
157
|
+
]
|
158
|
+
|
159
|
+
heading_signature = VexFunctionSignature(
|
160
|
+
name="heading",
|
161
|
+
return_type=FLOAT,
|
162
|
+
parameters=heading_params,
|
163
|
+
description="Get the heading of the inertial sensor",
|
164
|
+
category=SimulationCategory.SENSOR_READING,
|
165
|
+
python_name="heading",
|
166
|
+
cpp_name="heading",
|
167
|
+
object_type=INERTIAL,
|
168
|
+
method_name="heading"
|
169
|
+
)
|
170
|
+
|
171
|
+
registry.register_function(heading_signature)
|
172
|
+
|
173
|
+
# Inertial.rotation() method
|
174
|
+
rotation_params = [
|
175
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
176
|
+
]
|
177
|
+
|
178
|
+
rotation_signature = VexFunctionSignature(
|
179
|
+
name="rotation",
|
180
|
+
return_type=FLOAT,
|
181
|
+
parameters=rotation_params,
|
182
|
+
description="Get the rotation of the inertial sensor",
|
183
|
+
category=SimulationCategory.SENSOR_READING,
|
184
|
+
python_name="rotation",
|
185
|
+
cpp_name="rotation",
|
186
|
+
object_type=INERTIAL,
|
187
|
+
method_name="rotation"
|
188
|
+
)
|
189
|
+
|
190
|
+
registry.register_function(rotation_signature)
|
191
|
+
|
192
|
+
# Add more sensor functions for other sensor types...
|
193
|
+
|
194
|
+
if __name__ == "__main__":
|
195
195
|
register_sensor_functions()
|
@@ -1,104 +1,104 @@
|
|
1
|
-
from ..registry import registry
|
2
|
-
from ..signature import VexFunctionSignature, VexFunctionParameter, ParameterMode, SimulationCategory
|
3
|
-
from ...types.base import VOID, ANY
|
4
|
-
from ...types.primitives import INT, FLOAT, BOOL
|
5
|
-
from ...types.enums import TIME_UNITS
|
6
|
-
from ...types.objects import TIMER
|
7
|
-
|
8
|
-
def register_timing_functions():
|
9
|
-
"""Register timing-related functions in the registry"""
|
10
|
-
|
11
|
-
# Global wait function
|
12
|
-
wait_params = [
|
13
|
-
VexFunctionParameter("time", FLOAT, description="Time to wait"),
|
14
|
-
VexFunctionParameter("units", TIME_UNITS, "MSEC", description="Time units")
|
15
|
-
]
|
16
|
-
|
17
|
-
wait_signature = VexFunctionSignature(
|
18
|
-
name="wait",
|
19
|
-
return_type=VOID,
|
20
|
-
parameters=wait_params,
|
21
|
-
description="Wait for a specified amount of time",
|
22
|
-
category=SimulationCategory.TIMING_CONTROL,
|
23
|
-
python_name="wait",
|
24
|
-
cpp_name="wait"
|
25
|
-
)
|
26
|
-
|
27
|
-
registry.register_function(wait_signature)
|
28
|
-
|
29
|
-
# Timer functions
|
30
|
-
|
31
|
-
# Timer.time() method
|
32
|
-
time_params = [
|
33
|
-
VexFunctionParameter("units", TIME_UNITS, "MSEC", description="Time units")
|
34
|
-
]
|
35
|
-
|
36
|
-
time_signature = VexFunctionSignature(
|
37
|
-
name="time",
|
38
|
-
return_type=FLOAT,
|
39
|
-
parameters=time_params,
|
40
|
-
description="Get the current time of the timer",
|
41
|
-
category=SimulationCategory.TIMING_CONTROL,
|
42
|
-
python_name="time",
|
43
|
-
cpp_name="time",
|
44
|
-
object_type=TIMER,
|
45
|
-
method_name="time"
|
46
|
-
)
|
47
|
-
|
48
|
-
registry.register_function(time_signature)
|
49
|
-
|
50
|
-
# Timer.clear() method
|
51
|
-
clear_signature = VexFunctionSignature(
|
52
|
-
name="clear",
|
53
|
-
return_type=VOID,
|
54
|
-
parameters=[],
|
55
|
-
description="Clear the timer",
|
56
|
-
category=SimulationCategory.TIMING_CONTROL,
|
57
|
-
python_name="clear",
|
58
|
-
cpp_name="clear",
|
59
|
-
object_type=TIMER,
|
60
|
-
method_name="clear"
|
61
|
-
)
|
62
|
-
|
63
|
-
registry.register_function(clear_signature)
|
64
|
-
|
65
|
-
# Timer.reset() method
|
66
|
-
reset_signature = VexFunctionSignature(
|
67
|
-
name="reset",
|
68
|
-
return_type=VOID,
|
69
|
-
parameters=[],
|
70
|
-
description="Reset the timer",
|
71
|
-
category=SimulationCategory.TIMING_CONTROL,
|
72
|
-
python_name="reset",
|
73
|
-
cpp_name="reset",
|
74
|
-
object_type=TIMER,
|
75
|
-
method_name="reset"
|
76
|
-
)
|
77
|
-
|
78
|
-
registry.register_function(reset_signature)
|
79
|
-
|
80
|
-
# Timer.event() method
|
81
|
-
event_params = [
|
82
|
-
VexFunctionParameter("callback", ANY, description="Callback function to execute"),
|
83
|
-
VexFunctionParameter("delay", FLOAT, description="Time delay before callback execution"),
|
84
|
-
VexFunctionParameter("units", TIME_UNITS, "MSEC", description="Time units")
|
85
|
-
]
|
86
|
-
|
87
|
-
event_signature = VexFunctionSignature(
|
88
|
-
name="event",
|
89
|
-
return_type=VOID,
|
90
|
-
parameters=event_params,
|
91
|
-
description="Register a callback function to be called after a delay",
|
92
|
-
category=SimulationCategory.EVENT_HANDLING,
|
93
|
-
python_name="event",
|
94
|
-
cpp_name="event",
|
95
|
-
object_type=TIMER,
|
96
|
-
method_name="event"
|
97
|
-
)
|
98
|
-
|
99
|
-
registry.register_function(event_signature)
|
100
|
-
|
101
|
-
# Add more timing functions as needed...
|
102
|
-
|
103
|
-
if __name__ == "__main__":
|
1
|
+
from ..registry import registry
|
2
|
+
from ..signature import VexFunctionSignature, VexFunctionParameter, ParameterMode, SimulationCategory
|
3
|
+
from ...types.base import VOID, ANY
|
4
|
+
from ...types.primitives import INT, FLOAT, BOOL
|
5
|
+
from ...types.enums import TIME_UNITS
|
6
|
+
from ...types.objects import TIMER
|
7
|
+
|
8
|
+
def register_timing_functions():
|
9
|
+
"""Register timing-related functions in the registry"""
|
10
|
+
|
11
|
+
# Global wait function
|
12
|
+
wait_params = [
|
13
|
+
VexFunctionParameter("time", FLOAT, description="Time to wait"),
|
14
|
+
VexFunctionParameter("units", TIME_UNITS, "MSEC", description="Time units")
|
15
|
+
]
|
16
|
+
|
17
|
+
wait_signature = VexFunctionSignature(
|
18
|
+
name="wait",
|
19
|
+
return_type=VOID,
|
20
|
+
parameters=wait_params,
|
21
|
+
description="Wait for a specified amount of time",
|
22
|
+
category=SimulationCategory.TIMING_CONTROL,
|
23
|
+
python_name="wait",
|
24
|
+
cpp_name="wait"
|
25
|
+
)
|
26
|
+
|
27
|
+
registry.register_function(wait_signature)
|
28
|
+
|
29
|
+
# Timer functions
|
30
|
+
|
31
|
+
# Timer.time() method
|
32
|
+
time_params = [
|
33
|
+
VexFunctionParameter("units", TIME_UNITS, "MSEC", description="Time units")
|
34
|
+
]
|
35
|
+
|
36
|
+
time_signature = VexFunctionSignature(
|
37
|
+
name="time",
|
38
|
+
return_type=FLOAT,
|
39
|
+
parameters=time_params,
|
40
|
+
description="Get the current time of the timer",
|
41
|
+
category=SimulationCategory.TIMING_CONTROL,
|
42
|
+
python_name="time",
|
43
|
+
cpp_name="time",
|
44
|
+
object_type=TIMER,
|
45
|
+
method_name="time"
|
46
|
+
)
|
47
|
+
|
48
|
+
registry.register_function(time_signature)
|
49
|
+
|
50
|
+
# Timer.clear() method
|
51
|
+
clear_signature = VexFunctionSignature(
|
52
|
+
name="clear",
|
53
|
+
return_type=VOID,
|
54
|
+
parameters=[],
|
55
|
+
description="Clear the timer",
|
56
|
+
category=SimulationCategory.TIMING_CONTROL,
|
57
|
+
python_name="clear",
|
58
|
+
cpp_name="clear",
|
59
|
+
object_type=TIMER,
|
60
|
+
method_name="clear"
|
61
|
+
)
|
62
|
+
|
63
|
+
registry.register_function(clear_signature)
|
64
|
+
|
65
|
+
# Timer.reset() method
|
66
|
+
reset_signature = VexFunctionSignature(
|
67
|
+
name="reset",
|
68
|
+
return_type=VOID,
|
69
|
+
parameters=[],
|
70
|
+
description="Reset the timer",
|
71
|
+
category=SimulationCategory.TIMING_CONTROL,
|
72
|
+
python_name="reset",
|
73
|
+
cpp_name="reset",
|
74
|
+
object_type=TIMER,
|
75
|
+
method_name="reset"
|
76
|
+
)
|
77
|
+
|
78
|
+
registry.register_function(reset_signature)
|
79
|
+
|
80
|
+
# Timer.event() method
|
81
|
+
event_params = [
|
82
|
+
VexFunctionParameter("callback", ANY, description="Callback function to execute"),
|
83
|
+
VexFunctionParameter("delay", FLOAT, description="Time delay before callback execution"),
|
84
|
+
VexFunctionParameter("units", TIME_UNITS, "MSEC", description="Time units")
|
85
|
+
]
|
86
|
+
|
87
|
+
event_signature = VexFunctionSignature(
|
88
|
+
name="event",
|
89
|
+
return_type=VOID,
|
90
|
+
parameters=event_params,
|
91
|
+
description="Register a callback function to be called after a delay",
|
92
|
+
category=SimulationCategory.EVENT_HANDLING,
|
93
|
+
python_name="event",
|
94
|
+
cpp_name="event",
|
95
|
+
object_type=TIMER,
|
96
|
+
method_name="event"
|
97
|
+
)
|
98
|
+
|
99
|
+
registry.register_function(event_signature)
|
100
|
+
|
101
|
+
# Add more timing functions as needed...
|
102
|
+
|
103
|
+
if __name__ == "__main__":
|
104
104
|
register_timing_functions()
|