-
Notifications
You must be signed in to change notification settings - Fork 229
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
Better additional component BOM table #226
base: dev
Are you sure you want to change the base?
Conversation
- Use the actual BOM as first parameter instead of the whole harness. - Use a whole AdditionalComponent as second parameter instead of each attribute separately.
Move the lambda declaration out of the function scope for common access from two different functions.
Assign input designators once to a temporary variable for easy reusage.
- Use one common entry loop to consume iterator only once. - Use same key function for sort() and groupby(), except replace None with empty string when sorting.
Seems to be the most popular search alternative: https://stackoverflow.com/questions/8653516/python-list-of-dictionaries-search Raising StopIteration if not found is better than returning None to detect such an internal error more easily.
Make a list from the group iterator for reusage in sum expressions and to pick first group entry. The expected group sizes are very small, so performance loss by creating a temporary list should be neglectable. Alternativly, itertools.tee(group, 3) could be called to triplicate the iterator, but it was not chosen for readability reasons.
This type alias describes the possible types of keys and values in the dict representing a BOM entry.
Build output string in component_table_entry() as the similar strings in generate_bom(). Repeating a couple of minor if-expressions is small cost to obtain a more compact and readable main expression.
This way, both BOM and harness.additional_bom_items uses the same set of keys in their dict entries. This was originally suggested in a #115 review, but had too many issues to be implemented then.
to simplyfy code
Current state: Sourceconnectors:
X1:
type: Plug
pincount: 4
pn: 123
manufacturer: ACME
mpn: ABC
additional_components:
-
type: Crimp
pn: 987
manufacturer: ACME
mpn: ZYX
qty_multiplier: populated
-
type: Housing
pn: 345
manufacturer: OTHER
-
type: Label
note: '"ABC-123"'
X2:
type: Receptacle
pincount: 4
pn: 234
manufacturer: ACME
mpn: DEF
additional_components:
-
type: Crimp
pn: 876
manufacturer: ACME
mpn: WVU
cables:
W1:
wirecount: 4
gauge: 0.25
length: 99
color_code: DIN
pn: qwerty
mpn: uiop
additional_components:
-
type: Sleeving
qty: 5
unit: m
connections:
-
- X1: [1-4]
- W1: [1-4]
- X2: [1-4] The issue of retrieving BOM numbers for the major components is still open. |
I am open for suggestions as to how to extract the assigned BOM ID for cables and connectors (after deduplication etc.) and inserting it into the new |
Using Sourceconnectors:
X1:
type: KK 254
subtype: plug
pincount: 4
pinlabels: [QWE,RTY,UIO,P__]
pn: 123
manufacturer: ACME
mpn: ABC
additional_parameters:
Sleeving removal: 15 mm
Insulation removal: 2 mm
Label: A01-5-10
Tag: ABCDEFG
additional_components:
-
type: Crimp
pn: 987
manufacturer: ACME
mpn: ZYX
qty_multiplier: populated
-
type: Housing
pn: 345
manufacturer: OTHER
-
type: Label
note: '"ABC-123"'
X2:
type: KPPX
subtype: Plug
pincount: 4
pn: 234
manufacturer: ACME
mpn: DEF
additional_components:
-
type: Crimp
pn: 876
manufacturer: ACME
mpn: WVU
qty_multiplier: populated
cables:
W1:
wirecount: 4
gauge: 0.25
length: 99
color_code: DIN
pn: qwerty
mpn: uiop
additional_parameters:
Twist pairs: (1+2) , (3+4)
Twist rate: 5/mm
Twist direction: CCW
additional_components:
-
type: Heat shrink
qty: 30
unit: mm
note: left
-
type: Heat shrink
qty: 20
unit: mm
note: right
connections:
-
- X1: [1-4]
- W1: [1-4]
- X2: [1-4]
|
010b5c9
to
9821ca3
Compare
Instead of storing the Edit: I suggest defining a new helper function: def add_bom_entry_get_key(entries: List[BOMEntry], entry: BOMEntry) -> BOMKey:
entries.append(entry)
return bom_types_group(entry) Then call it for each component by only changing one line at each location, like this: part.bom_key = add_bom_entry_get_key(bom_entries, {
'description': part.description,
...
**optional_fields(part),
})
...
connector.bom_key = add_bom_entry_get_key(bom_entries, {
'description': description, ...
**optional_fields(connector),
}) Edit2: I will add a few changes to #197 to prepare for this. |
Closes #224.
Based on #197 (still unmerged).
Implements an additional
note
attribute for additional components as proposed in #222.Implements
additional_parameters
(Dict) to be displayed in connector and cable nodes.Will integrate #214 to allow the user to set
show_part_numbers
andshow_bom_item_numbers
from YAML.Will rebase this branch onto
dev
once #197 and #214 are merged.