Skip to content
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

Sim API Consistency: Object Creation #3215

Open
Starlight220 opened this issue Feb 27, 2021 · 1 comment
Open

Sim API Consistency: Object Creation #3215

Starlight220 opened this issue Feb 27, 2021 · 1 comment
Labels
os: simulation type: chore Formatting, reorganizing, and other necessary (but less impactful) tasks.

Comments

@Starlight220
Copy link
Member

Each sim class should have three parameter options to create objects:

  • a real hardware object
  • a port/index/channel number
  • a native handle (maybe not expose this?)

SimDeviceSim is a bit different since (1) doesn't make much sense, and (2) uses a string key.

Other than ensuring that everything has all three, we also need to standardize what is a constructor and what is a factory method.
Currently, we have some of each.
I'm of the opinion that everything should be constructors. @PeterJohnson -what about you?

Having this consistent will really help wpilibsuite/frc-docs#1077.

@PeterJohnson
Copy link
Member

PeterJohnson commented Mar 15, 2021

We can't always use constructors because we can't always discriminate on type. Take a look at DutyCycleSim for example. We want to be able to construct it from:

  • a DutyCycle object
  • a DigitalInput channel number
  • a DutyCycle FPGA index number

The last two are both integers, so we use factory functions for those, but a constructor for the first one.

In many other places we don't have this confusion (e.g. AnalogInputSim) so we just use constructors rather than forcing the use of factory functions.

@prateekma prateekma assigned prateekma and unassigned prateekma Mar 27, 2021
@calcmogul calcmogul added os: simulation type: chore Formatting, reorganizing, and other necessary (but less impactful) tasks. labels Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os: simulation type: chore Formatting, reorganizing, and other necessary (but less impactful) tasks.
Projects
None yet
Development

No branches or pull requests

5 participants