Skip to content

Conversation

@alan412
Copy link
Collaborator

@alan412 alan412 commented Aug 31, 2025

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.

@alan412 alan412 requested a review from lizlooney August 31, 2025 01:19
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.
Copy link
Collaborator

@lizlooney lizlooney left a 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):
Copy link
Collaborator

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?

Copy link
Collaborator Author

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?

@alan412 alan412 requested a review from lizlooney September 4, 2025 01:39
Copy link
Collaborator

@lizlooney lizlooney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

Copy link
Collaborator

@lizlooney lizlooney left a 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.

@lizlooney
Copy link
Collaborator

alan412#7

@alan412 alan412 requested a review from lizlooney September 4, 2025 11:35
@lizlooney lizlooney merged commit ce30750 into wpilibsuite:main Sep 4, 2025
1 check passed
@alan412 alan412 deleted the pr_multiple_ports branch September 26, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants