Skip to content

Conversation

alan412
Copy link
Collaborator

@alan412 alan412 commented Sep 5, 2025

This adds the ability to have private components in mechanisms.

While doing this, I found some problems with using components in mechanisms so I fixed those as well.

@alan412 alan412 requested a review from lizlooney September 5, 2025 17:09
@lizlooney
Copy link
Collaborator

We were not on the same page about components in mechanisms. I thought that the components in mechanisms (before your PR) were private components. It looks like you thought the components in mechanisms were public components.

Can you elaborate specifically about problems with using components in mechanisms that you found and fixed?

I think we should get on the same page about what we have now (before your PR) and what we need.

I'm still working on a PR to fix some things here, but I'm trying to figure out the difference between "Components" and "AllComponents".

@lizlooney
Copy link
Collaborator

I understand now why you thought of components as public components. It's because they are when they are in a robot. So I understand why the new code in mrc_mechanism_component_holder.ts is all about adding private components.

@alan412
Copy link
Collaborator Author

alan412 commented Sep 7, 2025

I understand now why you thought of components as public components. It's because they are when they are in a robot. So I understand why the new code in mrc_mechanism_component_holder.ts is all about adding private components.

I thought we had agreed that you should be able to have public components in a mechanism so we can have students follow the progression:

  • Components in robot
  • Make Mechanisms (by just grouping them)
  • Making components private (encapsulating them)

@lizlooney
Copy link
Collaborator

I understand now why you thought of components as public components. It's because they are when they are in a robot. So I understand why the new code in mrc_mechanism_component_holder.ts is all about adding private components.

I thought we had agreed that you should be able to have public components in a mechanism so we can have students follow the progression:

  • Components in robot
  • Make Mechanisms (by just grouping them)
  • Making components private (encapsulating them)

Yes! Now I remember that!

lizlooney and others added 8 commits September 8, 2025 20:41
…chanism so it can create the port parameters.
Since the mrc_mechanism_component_holder block can't change once it has been
placed on the workspace, the code can be simplified.
…hods.

The mechanismId (and mrcMechanismId) is set to the id of the mechanism so if the mechanism is renamed (in the robot), we update it.

Added mrcComponentNames and mrcMapComponentNameToId. These are filled in during mrcOnLoad and are used to populate the component name dropdown field.
Added privateComponents to module content.
We can use this to get the private components from a mechanism without having to
use a headless blockly workspace to process the blocks.
Added code to upgrade projects to version 0.0.2, which involves updating the
mrc_mechanism_component_holder block in the robot and adding privateComponents
in module content.
storageModuleContent.makeModuleContentText.

Made some methods private where possible.

Modified getAllComponentsFromMechanism so it gets the private components from a
mechanism's module content without having to use a headless blockly workspace to
process the mechanism's blocks.
…to call

getAllComponentsFromMechanism so it can create the port parameters.

Simplified getComponentsCategory to call getAllComponentsFromWorkspace for both robot and mechanism modules and added comments explaining why.
Regular and private components in mechanism
@lizlooney lizlooney merged commit a64a6aa into wpilibsuite:main Sep 9, 2025
1 check passed
@alan412 alan412 deleted the pr_private_components_in_mechanism branch September 9, 2025 16:20
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