-
Notifications
You must be signed in to change notification settings - Fork 9
All components take a single port #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When compare port_type with PortType.BASE_COMPOUND, use .value to get the numeric value.
Added type hints for function returns.
Modified get_type to just return self.type.
In component.py:
Changed port.get_type to port.get_type().
In mrc_port.ts, in pythonFromBlock:
Changed _generator to generator.
Added generator.addImport('port');
Changed Port to port.Port in generated python code.
Changed PortType to port.PortType in generated python code.
Changed MOTOR_PORT to EXPANSION_HUB_MOTOR_PORT.
Changed SERVO_PORT to EXPANSION_HUB_SERVO_PORT.
Updated external_samples_data.json.
lizlooney
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried creating a robot with a expansion hub motor and an opmode that spins the motor and it didn't work on my systemcore. I made changes to make it work and created a PR with those changes: alan412#6
| from enum import Enum | ||
| from typing import Self | ||
|
|
||
| class PortType(Enum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a class comment that shows examples of how to use PortType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy to write a comment here, but I couldn't come up with anything about how to use it that didn't seem like "this is the type of port". Suggestions?
Make it work on systemcore
lizlooney
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work!
lizlooney
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. I approved this too soon. I found some problems when running it on systemcore.
…ate json. Regenerated json.
Changed 'unknown:' to 'unknown'.
Fix mrc_port python generator
Now, all components take a single "port"
However, this "port" can be a compound type. For example a motor port on an expansion hub is a singular port, but it has two parts to it.
The advantage to this is that we'll be able to know if the user is trying to use the same physical port in their code twice.
This was much larger than I thought it would be when I started. I apologize for the size of this and I also apologize that this breaks all saved projects.
There is cleanup that needs to occur (things that aren't used anymore), but I didn't want to do all of that until we agreed this is the direction we want to head.