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

[feature] Accept alternative input syntax for connector pins #279

Open
kvid opened this issue Apr 16, 2022 · 0 comments
Open

[feature] Accept alternative input syntax for connector pins #279

kvid opened this issue Apr 16, 2022 · 0 comments

Comments

@kvid
Copy link
Collaborator

kvid commented Apr 16, 2022

  • @Halfwalker has suggested a syntax change that might help the use case in [feature] Automatic ordering of wires in a wire/bundle #275: defining pins individually (by specifying pin attributes in a dict for each pin - see details below)

  • The pins attribute of a connector contains a list of such dicts in that suggestion. That also enables default auto-numbered pins unless specifying a pin attribute in the dicts for each pin.

  • Optionally, the pins attribute of a connector could contain a dict (as wireinfo in [feature] More control over wire parameters #56) with a set of:

    • Key: Unique pin number/name
    • Value: The same dict for each pin as above (However, a pin attribute in such a dict doesn't make sense in this case)
  • I suggest we accept both the current syntax and at least the upper alternative above (list of dicts). The Connector.__post_init__() should check the pins attribute for alternative syntax, and translate any such values into the current data structure with separate lists.

  • As this probably will only involve adding some code in __post_init__() and nothing else, then conflicts with other PRs should be minimal or none.

  • We might consider expanding this issue scope to also include a similar concept for cable/bundle wires. As we don't support custom wire naming/renumbering, then we probably should reject both a wire attribute in a wire dict, and the optional dict of wire dicts.

@Halfwalker wrote:

Perhaps a syntax change/option would help for this. Right now connectors define pins as a list, which is order-dependent. 3rd one defined is pin 3 etc. Pinlabels are defined the same way - see the connectors above. This means making sure that the pin labels are in the correct order to match the pin colors ...

How about defining pins individually ?

  A4:
    pins:
      - pin: 1
        label: AC lock sensor
        color: GNYE
      - pin: 2
        label: AC lock sensor
        color: VTWH
      - pin: 3
        label: NC
      - pin: 4
        label: AC magnetic clutch
        color: BU

That is a good idea. It should be possible to accept an input syntax similar to your suggestion as an alternative to the existing syntax, and WireViz can easily map the values from such an input into the current data structure. This way, users can select the easiest syntax for each connector and cable. Implementing such a feature should be quite easy and only involve __post_init__() of the classes Connector and Cable, but I suggest raising a separate feature request issue for it, as it is independent from the automatic ordering in #275.

To support such a feature also for cables/bundles, then I guess we need a new attribute wires that can take a list of dicts. Such a syntax alternative might also be an advantage when new attributes per wire is requested, like in #56 or #268. However, supporting custom wire naming/renumbering as is already supported for connector pins, would require numerous changes in several source files, and should therefore perhaps be out of scope for now.

Originally posted by @kvid in #275 (comment)

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

No branches or pull requests

1 participant