Implemented the IBoM variants styles.

The core functionality is now tested in the internal BoM.
The IBoM output needs adjust to allow using the variants with it.
This commit is contained in:
Salvador E. Tropea 2020-08-28 20:12:21 -03:00
parent c227b10f86
commit 249caad348
7 changed files with 650 additions and 14 deletions

View File

@ -52,27 +52,28 @@ class IBoMOptions(BaseOptions):
""" Include netlist information in output. """
self.sort_order = 'C,R,L,D,U,Y,X,F,SW,A,~,HS,CNN,J,P,NT,MH'
""" Default sort order for components. Must contain '~' once """
self.blacklist = ''
""" List of comma separated blacklisted components or prefixes with *. E.g. 'X1,MH*' """
# self.blacklist = ''
# """ List of comma separated blacklisted components or prefixes with *. E.g. 'X1,MH*' """
self.no_blacklist_virtual = False
""" Do not blacklist virtual components """
self.blacklist_empty_val = False
""" Blacklist components with empty value """
# self.blacklist_empty_val = False
# """ Blacklist components with empty value """
self.netlist_file = ''
""" Path to netlist or xml file """
self.extra_fields = ''
""" Comma separated list of extra fields to pull from netlist or xml file """
""" Comma separated list of extra fields to pull from netlist or xml file.
These are extra columns in the BoM """
self.normalize_field_case = False
""" Normalize extra field name case. E.g. 'MPN' and 'mpn' will be considered the same field """
self.variant_field = ''
""" Name of the extra field that stores board variant for component """
self.variants_whitelist = ''
""" List of board variants to include in the BOM """
self.variants_blacklist = ''
""" List of board variants to exclude from the BOM """
self.dnp_field = ''
""" Name of the extra field that indicates do not populate status. Components with this field not empty will be
blacklisted """
# self.variant_field = ''
# """ Name of the extra field that stores board variant for component """
# self.variants_whitelist = ''
# """ List of board variants to include in the BOM """
# self.variants_blacklist = ''
# """ List of board variants to exclude from the BOM """
# self.dnp_field = ''
# """ Name of the extra field that indicates do not populate status. Components with this field not empty will be
# blacklisted """
super().__init__()
def run(self, output_dir, board):

97
kibot/var_ibom.py Normal file
View File

@ -0,0 +1,97 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
"""
Implements the IBoM variants mechanism.
"""
from .optionable import Optionable
from .gs import GS
from .macros import macros, document, variant_class # noqa: F401
from . import log
logger = log.get_logger(__name__)
@variant_class
class IBoM(BaseVariant): # noqa: F821
""" IBoM variant style
The Config field (configurable) contains a value.
If this value matches with a value in the whitelist is included.
If this value matches with a value in the blacklist is excluded. """
def __init__(self):
super().__init__()
with document:
self.variant_field = 'Config'
""" Name of the field that stores board variant for component """
self.variants_blacklist = Optionable
""" [string|list(string)=''] List of board variants to exclude from the BOM """
self.variants_whitelist = Optionable
""" [string|list(string)=''] List of board variants to include in the BOM """
self.blacklist = Optionable
""" [string|list(string)=''] List of comma separated blacklisted components or prefixes with *. E.g. 'X1,MH*' """
self.blacklist_empty_val = False
""" Blacklist components with empty value """
self.dnp_field = ''
""" Name of the extra field that indicates do not populate status.
Components with this field not empty will be blacklisted """
@staticmethod
def _force_list(val):
if isinstance(val, type):
# Not used
val = []
elif isinstance(val, str):
# A string
if val:
val = [v.strip() for v in val.split(',')]
else:
# Empty string
val = []
return val
def config(self):
super().config()
self.variants_blacklist = self._force_list(self.variants_blacklist)
self.variants_whitelist = self._force_list(self.variants_whitelist)
self.blacklist = self._force_list(self.blacklist)
def skip_component(self, c):
""" Skip blacklisted components.
This is what IBoM does internally """
if c.ref in self.blacklist:
return True
if c.ref_prefix + '*' in self.blacklist:
return True
# Remove components with empty value
if self.blacklist_empty_val and c.value in ['', '~']:
return True
# Skip virtual components if needed
# TODO: We currently lack this information
# if config.blacklist_virtual and m.attr == 'Virtual':
# return True
# Skip components with dnp field not empty
if self.dnp_field and c.get_field_value(self.dnp_field):
return True
# Apply variants white/black lists
if self.variant_field:
ref_variant = c.get_field_value(self.variant_field).lower()
# skip components with wrong variant field
if self.variants_whitelist and ref_variant not in self.variants_whitelist:
return True
if self.variants_blacklist and ref_variant and ref_variant in self.variants_blacklist:
return True
return False
def filter(self, comps):
logger.debug("Applying IBoM style filter `{}`".format(self.name))
# Make black/white lists case insensitive
self.variants_whitelist = [v.lower() for v in self.variants_whitelist]
self.variants_blacklist = [v.lower() for v in self.variants_blacklist]
# Apply to all the components
for c in comps:
c.fitted = not self.skip_component(c)
c.fixed = False
if not c.fitted and GS.debug_level > 2:
logger.debug('ref: {} value: {} -> False'.format(c.ref, c.value))

View File

@ -0,0 +1,268 @@
(kicad_pcb (version 20171130) (host pcbnew 5.1.6+dfsg1-1)
(general
(thickness 1.6)
(drawings 4)
(tracks 0)
(zones 0)
(modules 4)
(nets 9)
)
(page A4)
(layers
(0 F.Cu signal)
(31 B.Cu signal)
(32 B.Adhes user)
(33 F.Adhes user)
(34 B.Paste user)
(35 F.Paste user)
(36 B.SilkS user)
(37 F.SilkS user)
(38 B.Mask user)
(39 F.Mask user)
(40 Dwgs.User user)
(41 Cmts.User user)
(42 Eco1.User user)
(43 Eco2.User user)
(44 Edge.Cuts user)
(45 Margin user)
(46 B.CrtYd user)
(47 F.CrtYd user)
(48 B.Fab user)
(49 F.Fab user)
)
(setup
(last_trace_width 0.25)
(trace_clearance 0.2)
(zone_clearance 0.508)
(zone_45_only no)
(trace_min 0.2)
(via_size 0.8)
(via_drill 0.4)
(via_min_size 0.4)
(via_min_drill 0.3)
(uvia_size 0.3)
(uvia_drill 0.1)
(uvias_allowed no)
(uvia_min_size 0.2)
(uvia_min_drill 0.1)
(edge_width 0.1)
(segment_width 0.2)
(pcb_text_width 0.3)
(pcb_text_size 1.5 1.5)
(mod_edge_width 0.15)
(mod_text_size 1 1)
(mod_text_width 0.15)
(pad_size 1.524 1.524)
(pad_drill 0.762)
(pad_to_mask_clearance 0)
(aux_axis_origin 139.89 89.63)
(visible_elements FFFFFF7F)
(pcbplotparams
(layerselection 0x010fc_ffffffff)
(usegerberextensions false)
(usegerberattributes true)
(usegerberadvancedattributes true)
(creategerberjobfile true)
(excludeedgelayer true)
(linewidth 0.100000)
(plotframeref false)
(viasonmask false)
(mode 1)
(useauxorigin false)
(hpglpennumber 1)
(hpglpenspeed 20)
(hpglpendiameter 15.000000)
(psnegative false)
(psa4output false)
(plotreference true)
(plotvalue true)
(plotinvisibletext false)
(padsonsilk false)
(subtractmaskfromsilk false)
(outputformat 1)
(mirror false)
(drillshape 1)
(scaleselection 1)
(outputdirectory ""))
)
(net 0 "")
(net 1 "Net-(C1-Pad2)")
(net 2 "Net-(C1-Pad1)")
(net 3 "Net-(C2-Pad2)")
(net 4 "Net-(C2-Pad1)")
(net 5 "Net-(R1-Pad2)")
(net 6 "Net-(R1-Pad1)")
(net 7 "Net-(R2-Pad2)")
(net 8 "Net-(R2-Pad1)")
(net_class Default "Esta es la clase de red por defecto."
(clearance 0.2)
(trace_width 0.25)
(via_dia 0.8)
(via_drill 0.4)
(uvia_dia 0.3)
(uvia_drill 0.1)
(add_net "Net-(C1-Pad1)")
(add_net "Net-(C1-Pad2)")
(add_net "Net-(C2-Pad1)")
(add_net "Net-(C2-Pad2)")
(add_net "Net-(R1-Pad1)")
(add_net "Net-(R1-Pad2)")
(add_net "Net-(R2-Pad1)")
(add_net "Net-(R2-Pad2)")
)
(module Resistor_SMD:R_0805_2012Metric (layer F.Cu) (tedit 5B36C52B) (tstamp 5F496A8B)
(at 141.57 90.58)
(descr "Resistor SMD 0805 (2012 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: https://docs.google.com/spreadsheets/d/1BsfQQcO9C6DZCsRaXUlFlo91Tg2WpOkGARC1WS5S8t0/edit?usp=sharing), generated with kicad-footprint-generator")
(tags resistor)
(path /5F43D4BB)
(attr smd)
(fp_text reference R2 (at 0 -1.65) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value 1000 (at 0 1.65) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text user %R (at 0 0) (layer F.Fab)
(effects (font (size 0.5 0.5) (thickness 0.08)))
)
(fp_line (start -1 0.6) (end -1 -0.6) (layer F.Fab) (width 0.1))
(fp_line (start -1 -0.6) (end 1 -0.6) (layer F.Fab) (width 0.1))
(fp_line (start 1 -0.6) (end 1 0.6) (layer F.Fab) (width 0.1))
(fp_line (start 1 0.6) (end -1 0.6) (layer F.Fab) (width 0.1))
(fp_line (start -0.258578 -0.71) (end 0.258578 -0.71) (layer F.SilkS) (width 0.12))
(fp_line (start -0.258578 0.71) (end 0.258578 0.71) (layer F.SilkS) (width 0.12))
(fp_line (start -1.68 0.95) (end -1.68 -0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.68 -0.95) (end 1.68 -0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start 1.68 -0.95) (end 1.68 0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start 1.68 0.95) (end -1.68 0.95) (layer F.CrtYd) (width 0.05))
(pad 2 smd roundrect (at 0.9375 0) (size 0.975 1.4) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
(net 7 "Net-(R2-Pad2)"))
(pad 1 smd roundrect (at -0.9375 0) (size 0.975 1.4) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
(net 8 "Net-(R2-Pad1)"))
(model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(module Resistor_SMD:R_0805_2012Metric (layer F.Cu) (tedit 5B36C52B) (tstamp 5F496A7A)
(at 141.57 87.63)
(descr "Resistor SMD 0805 (2012 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: https://docs.google.com/spreadsheets/d/1BsfQQcO9C6DZCsRaXUlFlo91Tg2WpOkGARC1WS5S8t0/edit?usp=sharing), generated with kicad-footprint-generator")
(tags resistor)
(path /5F43D144)
(attr smd)
(fp_text reference R1 (at 0 -1.65) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value 1k (at 0 1.65) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text user %R (at 0 0) (layer F.Fab)
(effects (font (size 0.5 0.5) (thickness 0.08)))
)
(fp_line (start -1 0.6) (end -1 -0.6) (layer F.Fab) (width 0.1))
(fp_line (start -1 -0.6) (end 1 -0.6) (layer F.Fab) (width 0.1))
(fp_line (start 1 -0.6) (end 1 0.6) (layer F.Fab) (width 0.1))
(fp_line (start 1 0.6) (end -1 0.6) (layer F.Fab) (width 0.1))
(fp_line (start -0.258578 -0.71) (end 0.258578 -0.71) (layer F.SilkS) (width 0.12))
(fp_line (start -0.258578 0.71) (end 0.258578 0.71) (layer F.SilkS) (width 0.12))
(fp_line (start -1.68 0.95) (end -1.68 -0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.68 -0.95) (end 1.68 -0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start 1.68 -0.95) (end 1.68 0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start 1.68 0.95) (end -1.68 0.95) (layer F.CrtYd) (width 0.05))
(pad 2 smd roundrect (at 0.9375 0) (size 0.975 1.4) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
(net 5 "Net-(R1-Pad2)"))
(pad 1 smd roundrect (at -0.9375 0) (size 0.975 1.4) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
(net 6 "Net-(R1-Pad1)"))
(model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(module Capacitor_SMD:C_0805_2012Metric (layer F.Cu) (tedit 5B36C52B) (tstamp 5F496A69)
(at 137.16 90.58)
(descr "Capacitor SMD 0805 (2012 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: https://docs.google.com/spreadsheets/d/1BsfQQcO9C6DZCsRaXUlFlo91Tg2WpOkGARC1WS5S8t0/edit?usp=sharing), generated with kicad-footprint-generator")
(tags capacitor)
(path /5F43CE1C)
(attr smd)
(fp_text reference C2 (at 0 -1.65) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value "1000 pF" (at 0 1.65) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text user %R (at 0 0) (layer F.Fab)
(effects (font (size 0.5 0.5) (thickness 0.08)))
)
(fp_line (start -1 0.6) (end -1 -0.6) (layer F.Fab) (width 0.1))
(fp_line (start -1 -0.6) (end 1 -0.6) (layer F.Fab) (width 0.1))
(fp_line (start 1 -0.6) (end 1 0.6) (layer F.Fab) (width 0.1))
(fp_line (start 1 0.6) (end -1 0.6) (layer F.Fab) (width 0.1))
(fp_line (start -0.258578 -0.71) (end 0.258578 -0.71) (layer F.SilkS) (width 0.12))
(fp_line (start -0.258578 0.71) (end 0.258578 0.71) (layer F.SilkS) (width 0.12))
(fp_line (start -1.68 0.95) (end -1.68 -0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.68 -0.95) (end 1.68 -0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start 1.68 -0.95) (end 1.68 0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start 1.68 0.95) (end -1.68 0.95) (layer F.CrtYd) (width 0.05))
(pad 2 smd roundrect (at 0.9375 0) (size 0.975 1.4) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
(net 3 "Net-(C2-Pad2)"))
(pad 1 smd roundrect (at -0.9375 0) (size 0.975 1.4) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
(net 4 "Net-(C2-Pad1)"))
(model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(module Capacitor_SMD:C_0805_2012Metric (layer F.Cu) (tedit 5B36C52B) (tstamp 5F496A58)
(at 137.16 87.63)
(descr "Capacitor SMD 0805 (2012 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: https://docs.google.com/spreadsheets/d/1BsfQQcO9C6DZCsRaXUlFlo91Tg2WpOkGARC1WS5S8t0/edit?usp=sharing), generated with kicad-footprint-generator")
(tags capacitor)
(path /5F43BEC2)
(attr smd)
(fp_text reference C1 (at 0 -1.65) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value 1nF (at 0 1.65) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text user %R (at 0 0) (layer F.Fab)
(effects (font (size 0.5 0.5) (thickness 0.08)))
)
(fp_line (start -1 0.6) (end -1 -0.6) (layer F.Fab) (width 0.1))
(fp_line (start -1 -0.6) (end 1 -0.6) (layer F.Fab) (width 0.1))
(fp_line (start 1 -0.6) (end 1 0.6) (layer F.Fab) (width 0.1))
(fp_line (start 1 0.6) (end -1 0.6) (layer F.Fab) (width 0.1))
(fp_line (start -0.258578 -0.71) (end 0.258578 -0.71) (layer F.SilkS) (width 0.12))
(fp_line (start -0.258578 0.71) (end 0.258578 0.71) (layer F.SilkS) (width 0.12))
(fp_line (start -1.68 0.95) (end -1.68 -0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.68 -0.95) (end 1.68 -0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start 1.68 -0.95) (end 1.68 0.95) (layer F.CrtYd) (width 0.05))
(fp_line (start 1.68 0.95) (end -1.68 0.95) (layer F.CrtYd) (width 0.05))
(pad 2 smd roundrect (at 0.9375 0) (size 0.975 1.4) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
(net 1 "Net-(C1-Pad2)"))
(pad 1 smd roundrect (at -0.9375 0) (size 0.975 1.4) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
(net 2 "Net-(C1-Pad1)"))
(model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(gr_line (start 133.35 83.82) (end 133.35 93.98) (layer Edge.Cuts) (width 0.1) (tstamp 5F496ACC))
(gr_line (start 146.05 83.82) (end 133.35 83.82) (layer Edge.Cuts) (width 0.1))
(gr_line (start 146.05 93.98) (end 146.05 83.82) (layer Edge.Cuts) (width 0.1))
(gr_line (start 133.35 93.98) (end 146.05 93.98) (layer Edge.Cuts) (width 0.1))
)

View File

@ -0,0 +1,68 @@
EESchema Schematic File Version 4
EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title "KiBom Test Schematic"
Date "2020-03-12"
Rev "A"
Comp "https://github.com/SchrodingersGat/KiBom"
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
Text Notes 500 750 0 79 ~ 0
This schematic serves as a test-file for the KiBot export script.\nHere we implement the IBoM variants style.
$Comp
L Device:C C1
U 1 1 5F43BEC2
P 1000 1700
F 0 "C1" H 1115 1746 50 0000 L CNN
F 1 "1nF" H 1115 1655 50 0000 L CNN
F 2 "Capacitor_SMD:C_0805_2012Metric" H 1038 1550 50 0001 C CNN
F 3 "~" H 1000 1700 50 0001 C CNN
F 4 "T2" H 1000 1700 50 0001 C CNN "Config"
1 1000 1700
1 0 0 -1
$EndComp
$Comp
L Device:C C2
U 1 1 5F43CE1C
P 1450 1700
F 0 "C2" H 1565 1746 50 0000 L CNN
F 1 "1000 pF" H 1565 1655 50 0000 L CNN
F 2 "Capacitor_SMD:C_0805_2012Metric" H 1488 1550 50 0001 C CNN
F 3 "~" H 1450 1700 50 0001 C CNN
F 4 "T3" H 1450 1700 50 0001 C CNN "Config"
1 1450 1700
1 0 0 -1
$EndComp
$Comp
L Device:R R1
U 1 1 5F43D144
P 2100 1700
F 0 "R1" H 2170 1746 50 0000 L CNN
F 1 "1k" H 2170 1655 50 0000 L CNN
F 2 "Resistor_SMD:R_0805_2012Metric" V 2030 1700 50 0001 C CNN
F 3 "~" H 2100 1700 50 0001 C CNN
F 4 "default" H 2100 1700 50 0001 C CNN "Config"
1 2100 1700
1 0 0 -1
$EndComp
$Comp
L Device:R R2
U 1 1 5F43D4BB
P 2500 1700
F 0 "R2" H 2570 1746 50 0000 L CNN
F 1 "1000" H 2570 1655 50 0000 L CNN
F 2 "Resistor_SMD:R_0805_2012Metric" V 2430 1700 50 0001 C CNN
F 3 "~" H 2500 1700 50 0001 C CNN
F 4 "T1" H 2500 1700 50 0001 C CNN "Config"
1 2500 1700
1 0 0 -1
$EndComp
Text Notes 5950 3200 0 118 ~ 0
The test tests the following \nvariants matrix:\n production test default\nC1 X\nC2 X X\nR1 X X X\nR2 X X\n\nproduction: blacklist T2\ntest: blacklist T1\ndefault: whitelist T1,default \n blacklist T2,T3
$EndSCHEMATC

View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<export version="D">
<design>
<source>/home/salvador/0Data/Eccosur/kibot/tests/board_samples/var3/kibom-variant_3.sch</source>
<date>vie 28 ago 2020 18:18:02</date>
<tool>Eeschema 5.1.6+dfsg1-1</tool>
<sheet number="1" name="/" tstamps="/">
<title_block>
<title>KiBom Test Schematic</title>
<company>https://github.com/SchrodingersGat/KiBom</company>
<rev>A</rev>
<date>2020-03-12</date>
<source>kibom-variant_3.sch</source>
<comment number="1" value=""/>
<comment number="2" value=""/>
<comment number="3" value=""/>
<comment number="4" value=""/>
</title_block>
</sheet>
</design>
<components>
<comp ref="C1">
<value>1nF</value>
<footprint>Capacitor_SMD:C_0805_2012Metric</footprint>
<datasheet>~</datasheet>
<fields>
<field name="Config">T2</field>
</fields>
<libsource lib="Device" part="C" description="Unpolarized capacitor"/>
<sheetpath names="/" tstamps="/"/>
<tstamp>5F43BEC2</tstamp>
</comp>
<comp ref="C2">
<value>1000 pF</value>
<footprint>Capacitor_SMD:C_0805_2012Metric</footprint>
<datasheet>~</datasheet>
<fields>
<field name="Config">T3</field>
</fields>
<libsource lib="Device" part="C" description="Unpolarized capacitor"/>
<sheetpath names="/" tstamps="/"/>
<tstamp>5F43CE1C</tstamp>
</comp>
<comp ref="R1">
<value>1k</value>
<footprint>Resistor_SMD:R_0805_2012Metric</footprint>
<datasheet>~</datasheet>
<fields>
<field name="Config">default</field>
</fields>
<libsource lib="Device" part="R" description="Resistor"/>
<sheetpath names="/" tstamps="/"/>
<tstamp>5F43D144</tstamp>
</comp>
<comp ref="R2">
<value>1000</value>
<footprint>Resistor_SMD:R_0805_2012Metric</footprint>
<datasheet>~</datasheet>
<fields>
<field name="Config">T1</field>
</fields>
<libsource lib="Device" part="R" description="Resistor"/>
<sheetpath names="/" tstamps="/"/>
<tstamp>5F43D4BB</tstamp>
</comp>
</components>
<libparts>
<libpart lib="Device" part="C">
<description>Unpolarized capacitor</description>
<docs>~</docs>
<footprints>
<fp>C_*</fp>
</footprints>
<fields>
<field name="Reference">C</field>
<field name="Value">C</field>
</fields>
<pins>
<pin num="1" name="~" type="passive"/>
<pin num="2" name="~" type="passive"/>
</pins>
</libpart>
<libpart lib="Device" part="R">
<description>Resistor</description>
<docs>~</docs>
<footprints>
<fp>R_*</fp>
</footprints>
<fields>
<field name="Reference">R</field>
<field name="Value">R</field>
</fields>
<pins>
<pin num="1" name="~" type="passive"/>
<pin num="2" name="~" type="passive"/>
</pins>
</libpart>
</libparts>
<libraries>
<library logical="Device">
<uri>/usr/share/kicad/library/Device.lib</uri>
</library>
</libraries>
<nets>
<net code="1" name="Net-(C1-Pad1)">
<node ref="C1" pin="1"/>
</net>
<net code="2" name="Net-(C1-Pad2)">
<node ref="C1" pin="2"/>
</net>
<net code="3" name="Net-(C2-Pad1)">
<node ref="C2" pin="1"/>
</net>
<net code="4" name="Net-(C2-Pad2)">
<node ref="C2" pin="2"/>
</net>
<net code="5" name="Net-(R1-Pad1)">
<node ref="R1" pin="1"/>
</net>
<net code="6" name="Net-(R1-Pad2)">
<node ref="R1" pin="2"/>
</net>
<net code="7" name="Net-(R2-Pad1)">
<node ref="R2" pin="1"/>
</net>
<net code="8" name="Net-(R2-Pad2)">
<node ref="R2" pin="2"/>
</net>
</nets>
</export>

View File

@ -1210,3 +1210,19 @@ def test_int_bom_variant_t2():
rows, header, info = ctx.load_csv(prj+'-bom_(test).csv')
check_kibom_test_netlist(rows, ref_column, 2, ['R2'], ['R1', 'C1', 'C2'])
ctx.clean_up()
def test_int_bom_variant_t2i():
prj = 'kibom-variant_3'
ctx = context.TestContextSCH('test_int_bom_variant_t2i', prj, 'int_bom_var_t2i_csv', BOM_DIR)
ctx.run()
rows, header, info = ctx.load_csv(prj+'-bom.csv')
ref_column = header.index(REF_COLUMN_NAME)
check_kibom_test_netlist(rows, ref_column, 1, ['C1', 'C2'], ['R1', 'R2'])
rows, header, info = ctx.load_csv(prj+'-bom_[2].csv')
check_kibom_test_netlist(rows, ref_column, 1, ['C1', 'C2'], ['R1', 'R2'])
rows, header, info = ctx.load_csv(prj+'-bom_(production).csv')
check_kibom_test_netlist(rows, ref_column, 2, ['C1'], ['R1', 'R2', 'C2'])
rows, header, info = ctx.load_csv(prj+'-bom_(test).csv')
check_kibom_test_netlist(rows, ref_column, 2, ['R2'], ['R1', 'C1', 'C2'])
ctx.clean_up()

View File

@ -0,0 +1,56 @@
# Example KiBot config file
kibot:
version: 1
variants:
- name: 'production'
comment: 'Production variant'
type: ibom
file_id: '_(production)'
variants_blacklist: T2
- name: 'test'
comment: 'Test variant'
type: ibom
file_id: '_(test)'
variants_blacklist: T1
- name: 'default'
comment: 'Default variant'
type: ibom
variants_blacklist: T2,T3
- name: 'default2'
comment: 'Default variant 2'
type: ibom
file_id: '_[2]'
variants_whitelist: T1, Default
outputs:
- name: 'bom_internal'
comment: "Bill of Materials in CSV format"
type: bom
dir: BoM
options:
variant: default
- name: 'bom_internal2'
comment: "Bill of Materials in CSV format (2)"
type: bom
dir: BoM
options:
variant: default2
- name: 'bom_internal_production'
comment: "Bill of Materials in CSV format for production"
type: bom
dir: BoM
options:
variant: production
- name: 'bom_internal_test'
comment: "Bill of Materials in CSV format for test"
type: bom
dir: BoM
options:
variant: test