diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2018-07-29 23:22:26 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2018-07-29 23:22:26 +0200 |
commit | 661332c3ce7562b30545ae1773d30a784bcbc0db (patch) | |
tree | 76ad1ee053eacc64825e67285c607329cabfdc02 | |
parent | ef5f308dd8d94bf40701c5bb979ad0fe45629ae9 (diff) | |
download | ee-python-661332c3ce7562b30545ae1773d30a784bcbc0db.tar.gz ee-python-661332c3ce7562b30545ae1773d30a784bcbc0db.tar.bz2 ee-python-661332c3ce7562b30545ae1773d30a784bcbc0db.tar.xz ee-python-661332c3ce7562b30545ae1773d30a784bcbc0db.zip |
o Support for resolving 'mpn' fields from digikey. Creates
'digikey-part-stub', can be used to download the entire part later on.
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | demo/doit/dodo.py | 6 | ||||
-rw-r--r-- | demo/doit/ee/digikey-resolved-parts/data-set.ini | 3 | ||||
-rw-r--r-- | demo/doit/ee/digikey-resolved-parts/digikey-part-stub/493-4771-1-ND.ini | 8 | ||||
-rw-r--r-- | demo/doit/ee/digikey-resolved-parts/digikey-part-stub/BC2AAPC-ND.ini | 9 | ||||
-rw-r--r-- | demo/doit/ee/digikey-resolved-parts/digikey-part-stub/RMCF1206JT10K0CT-ND.ini | 8 | ||||
-rw-r--r-- | src/ee/digikey/__init__.py | 4 | ||||
-rw-r--r-- | src/ee/digikey/doit.py | 87 | ||||
-rw-r--r-- | src/ee/doit.py | 23 | ||||
-rw-r--r-- | src/ee/ds/__init__.py | 21 | ||||
-rw-r--r-- | src/ee/kicad/doit.py | 2 | ||||
-rw-r--r-- | test/doit/schematics/schematic-1.kicad_pcb | 292 | ||||
-rw-r--r-- | test/doit/schematics/schematic-1.sch | 61 | ||||
-rw-r--r-- | test/doit/test_doit.py | 6 |
14 files changed, 361 insertions, 171 deletions
@@ -25,3 +25,5 @@ _saved_*.sch *.kicad_pcb-bak _autosave-*.kicad_pcb .pytest_cache/ +test/**/*.net +test/**/*-cache.lib diff --git a/demo/doit/dodo.py b/demo/doit/dodo.py index 145c0a7..15b31c0 100644 --- a/demo/doit/dodo.py +++ b/demo/doit/dodo.py @@ -1,7 +1,11 @@ +import ee.bom.doit +import ee.digikey.doit import ee.doit import ee.kicad.doit # noinspection PyUnresolvedReferences from ee.bom.doit import * +# noinspection PyUnresolvedReferences +from ee.digikey.doit import * from ee.kicad.doit import * prj = "demo" @@ -30,6 +34,8 @@ ee.bom.doit.init( data_set_manager=dsm, ) +ee.digikey.doit.doit_config.configure(data_set_manager=dsm) + def task_orders(): data_sets = [ee.bom.doit.output_data_set_for_task(task_bom)] diff --git a/demo/doit/ee/digikey-resolved-parts/data-set.ini b/demo/doit/ee/digikey-resolved-parts/data-set.ini new file mode 100644 index 0000000..870a079 --- /dev/null +++ b/demo/doit/ee/digikey-resolved-parts/data-set.ini @@ -0,0 +1,3 @@ +[data-set] +name = digikey-resolved-parts + diff --git a/demo/doit/ee/digikey-resolved-parts/digikey-part-stub/493-4771-1-ND.ini b/demo/doit/ee/digikey-resolved-parts/digikey-part-stub/493-4771-1-ND.ini new file mode 100644 index 0000000..3cfb7d9 --- /dev/null +++ b/demo/doit/ee/digikey-resolved-parts/digikey-part-stub/493-4771-1-ND.ini @@ -0,0 +1,8 @@ +[meta] +type = digikey-part-stub + +[values] +part-number = 493-4771-1-ND +mpn = UCA2G100MPD1TD +url = /product-detail/en/nichicon/UCA2G100MPD1TD/493-4771-1-ND/3129112 + diff --git a/demo/doit/ee/digikey-resolved-parts/digikey-part-stub/BC2AAPC-ND.ini b/demo/doit/ee/digikey-resolved-parts/digikey-part-stub/BC2AAPC-ND.ini new file mode 100644 index 0000000..013dae3 --- /dev/null +++ b/demo/doit/ee/digikey-resolved-parts/digikey-part-stub/BC2AAPC-ND.ini @@ -0,0 +1,9 @@ +[meta] +type = digikey-part-stub + +[values] +part-number = BC2AAPC-ND +mpn = BC2AAPC +url = https://www.digikey.com/product-detail/en/mpd-memory-protection-devices/BC2AAPC/BC2AAPC-ND/455777 +description = EMITTER IR 940NM 100MA RADIAL + diff --git a/demo/doit/ee/digikey-resolved-parts/digikey-part-stub/RMCF1206JT10K0CT-ND.ini b/demo/doit/ee/digikey-resolved-parts/digikey-part-stub/RMCF1206JT10K0CT-ND.ini new file mode 100644 index 0000000..86a5504 --- /dev/null +++ b/demo/doit/ee/digikey-resolved-parts/digikey-part-stub/RMCF1206JT10K0CT-ND.ini @@ -0,0 +1,8 @@ +[meta] +type = digikey-part-stub + +[values] +part-number = RMCF1206JT10K0CT-ND +mpn = RMCF1206JT10K0 +url = /product-detail/en/stackpole-electronics-inc/RMCF1206JT10K0/RMCF1206JT10K0CT-ND/1942803 + diff --git a/src/ee/digikey/__init__.py b/src/ee/digikey/__init__.py index f607408..6fa3161 100644 --- a/src/ee/digikey/__init__.py +++ b/src/ee/digikey/__init__.py @@ -203,9 +203,9 @@ class DigikeySearchResponse(object): self.count = count self.response_type = response_type - self.products = list() + self.products = list() # type: List[DigikeyProduct] - def append(self, product): + def append(self, product: DigikeyProduct): self.products.append(product) diff --git a/src/ee/digikey/doit.py b/src/ee/digikey/doit.py new file mode 100644 index 0000000..74259bb --- /dev/null +++ b/src/ee/digikey/doit.py @@ -0,0 +1,87 @@ +import logging + +import ee.digikey as dk +from ee.doit import DoItConfig +from ee.ds import DataSet + +logger = logging.getLogger(__name__) + +doit_config = DoItConfig() + + +def resolve_schematic_components(output: DataSet, in_ds: DataSet): + def find(field, value): + return [o for o in output.items() if o.object_type.name == "digikey-part-stub" and o.get(field) == value] + + def save(p: dk.DigikeyProduct): + logger.info("Found part, dpn={}, mpn={}".format(p.part_number, p.mpn)) + + return output.create_object("digikey-part-stub", p.part_number, replace=True). \ + set("part-number", p.part_number). \ + set("mpn", p.mpn). \ + set("description", p.description). \ + set("quantity-available", p.quantity_available). \ + set("url", p.url) + + digikey = dk.Digikey() + client = dk.DigikeyClient(digikey, on_download=logger.info) + + components = [o for o in in_ds.items() if o.object_type.name == "component"] + + for mpn in sorted({c.get("mpn") for c in components if c.get("mpn")}): + # TODO: support searching by value and digikey part number directly. Priority should be "digikey", "mpn" and + # "value", first field present should be used. + + dk_components = find("mpn", mpn) + + if len(dk_components): + logger.info("Already resolved {} to {}".format(mpn, ", ".join([c.get("mpn") for c in dk_components]))) + continue + + logger.info("Looking up {}".format(mpn)) + response = client.search(mpn) + + if response.response_type == dk.SearchResponseTypes.SINGLE: + save(response.products[0]) + elif response.response_type == dk.SearchResponseTypes.MANY: + # A search for "FOO" might return products "FOO" and "FOOZ" so we pick out the ones with the matching mpn + # This will often be more than one product, but digikey shows the same part in different packagings. + viable_products = [p for p in response.products if p.mpn == mpn] + + if len(viable_products) == 0: + logger.warning("BUG: Got multiple hits ({}) but didn't find anyone that matched the MPN. Strange!". + format(len(response.products))) + else: + if len(viable_products) == 1: + part = viable_products[0] + else: + # Pick the first one, should be as good as any + part = sorted(viable_products, key=lambda x: x.part_number)[0] + + logger.info("Got multiple hits ({})".format(len(viable_products))) + + save(part) + elif response.response_type == dk.SearchResponseTypes.TOO_MANY: + logger.warning("to many matches") + elif response.response_type == dk.SearchResponseTypes.NO_MATCHES: + logger.warning("no matches") + + +def task_digikey_resolve_schematic_components(): + out_data_set, in_data_sets = doit_config.data_sets_for(task_digikey_resolve_schematic_components) + + def action(): + in_ds = doit_config.dsm.load_data_sets(in_data_sets) + + with doit_config.dsm.create_rw(out_data_set, clean=False) as output: + resolve_schematic_components(output, in_ds) + + return dict( + file_dep=[doit_config.dsm.cookie_for_ds(ds) for ds in in_data_sets], + actions=[action], + targets=[doit_config.dsm.cookie_for_ds(out_data_set)], + ) + + +doit_config.set_data_sets_for(task_digikey_resolve_schematic_components, + "digikey-resolved-parts", "components") diff --git a/src/ee/doit.py b/src/ee/doit.py index 87a6601..014af05 100644 --- a/src/ee/doit.py +++ b/src/ee/doit.py @@ -2,6 +2,8 @@ import logging from doit import get_var +from ee.ds import DataSetManager + def configure_logging(): log_level = get_var("log-level", None) @@ -14,3 +16,24 @@ def configure_logging(): ee_logger.addHandler(ch) ee_logger.setLevel(log_level) + + +class DoItConfig(object): + def __init__(self): + self._dsm = None # type: DataSetManager + self._data_sets = {} + + def configure(self, *, data_set_manager: DataSetManager): + self._dsm = data_set_manager + + @property + def dsm(self): + if not self._dsm: + raise Exception("The DataSetManager has not been set") + return self._dsm + + def data_sets_for(self, task): + return self._data_sets[task] + + def set_data_sets_for(self, task, out_dataset: str, *in_datasets: str): + self._data_sets[task] = [out_dataset, in_datasets] diff --git a/src/ee/ds/__init__.py b/src/ee/ds/__init__.py index f71a7c6..14bbb91 100644 --- a/src/ee/ds/__init__.py +++ b/src/ee/ds/__init__.py @@ -144,7 +144,7 @@ class DataSet(object): self._assert_not_frozen() if not create: - raise Exception("No such type: {}:{}".format(object_type, key)) + raise Exception("No such object: {}:{}".format(object_type, key)) o = Object(self, ot, key) objects[key] = o @@ -179,11 +179,15 @@ class DataSet(object): def get_or_create_object(self, object_type: str, key: str) -> Object: return self._check_object(object_type, key, True) - def create_object(self, object_type: str, key: str) -> Object: + def create_object(self, object_type: str, key: str, replace=False) -> Object: self._assert_not_frozen() if self.has_object(object_type, key): - raise Exception("Object already exist: {}:{}".format(object_type, key)) + if not replace: + raise Exception("Object already exist: {}:{}".format(object_type, key)) + + ot, objects = self._check_object_type(object_type, False) + del self._objects_by_type[ot][key] return self._check_object(object_type, key, True) @@ -410,11 +414,14 @@ class LazyRwDataSet(object): cookie = self._dsm.cookie_for_ds(self._name) if cookie.exists(): - if not self._clean: - raise IOError("DataSet already exists: {}, cookie={}".format(self._name, cookie)) - self._dsm.remove(self._name) + if self._clean: + self._dsm.remove(self._name) + ds = DataSet() + else: + ds = self._dsm.load(self._name) + else: + ds = DataSet() - ds = DataSet() self._ds = ds return ds diff --git a/src/ee/kicad/doit.py b/src/ee/kicad/doit.py index bfbf0a1..eff6a03 100644 --- a/src/ee/kicad/doit.py +++ b/src/ee/kicad/doit.py @@ -159,8 +159,6 @@ def task_kicad_create_component_data_set(): out_data_set, in_data_sets = _data_sets[task_kicad_create_component_data_set] def action(): - logger.info("in_data_sets={}, out_data_set={}".format(in_data_sets, out_data_set)) - in_ds = _dsm.load_data_sets(in_data_sets) # for o in in_ds.items(): # logger.info("item: {}/{}".format(o.object_type.name, o.key)) diff --git a/test/doit/schematics/schematic-1.kicad_pcb b/test/doit/schematics/schematic-1.kicad_pcb index 861eed1..fcb69aa 100644 --- a/test/doit/schematics/schematic-1.kicad_pcb +++ b/test/doit/schematics/schematic-1.kicad_pcb @@ -3,10 +3,10 @@ (general (thickness 1.6) (drawings 0) - (tracks 13) + (tracks 10) (zones 0) - (modules 3) - (nets 4) + (modules 4) + (nets 5) ) (page A4) @@ -53,10 +53,10 @@ (pcb_text_width 0.3) (pcb_text_size 1.5 1.5) (mod_edge_width 0.15) - (mod_text_size 0.000001 0.000001) + (mod_text_size 1 1) (mod_text_width 0.15) - (pad_size 1.4 1.4) - (pad_drill 0.6) + (pad_size 1.524 1.524) + (pad_drill 0.762) (pad_to_mask_clearance 0.2) (aux_axis_origin 0 0) (visible_elements FFFFFF7F) @@ -90,9 +90,10 @@ ) (net 0 "") - (net 1 GND) - (net 2 "Net-(BT1-Pad1)") + (net 1 "Net-(BT1-Pad1)") + (net 2 GND) (net 3 "Net-(C1-Pad1)") + (net 4 "Net-(R1-Pad1)") (net_class Default "This is the default net class." (clearance 0.2) @@ -104,177 +105,194 @@ (add_net GND) (add_net "Net-(BT1-Pad1)") (add_net "Net-(C1-Pad1)") + (add_net "Net-(R1-Pad1)") ) - (module Battery:BatteryHolder_Keystone_103_1x20mm (layer F.Cu) (tedit 5787C32C) (tstamp 5B59DAE3) - (at 145.975001 79.779834) - (descr http://www.keyelco.com/product-pdf.cfm?p=719) - (tags "Keystone type 103 battery holder") + (module Battery:BatteryHolder_MPD_BC2AAPC_2xAA (layer F.Cu) (tedit 5AC8F8F7) (tstamp 5B5BC36D) + (at 71.75 60.5) + (descr "2xAA cell battery holder, Memory Protection Devices P/N BC2AAPC, http://www.memoryprotectiondevices.com/datasheets/BC2AAPC-datasheet.pdf") + (tags "AA battery cell holder") (path /5B431438) - (fp_text reference BT1 (at 0 -4.3) (layer F.SilkS) + (fp_text reference BT1 (at 26.16 -10.11) (layer F.SilkS) (effects (font (size 1 1) (thickness 0.15))) ) - (fp_text value 9V (at 15 13) (layer F.Fab) + (fp_text value 9V (at 26.16 23.39) (layer F.Fab) (effects (font (size 1 1) (thickness 0.15))) ) - (fp_text user + (at 2.75 0) (layer F.SilkS) + (fp_line (start -2.84 -8.61) (end -2.84 21.89) (layer F.Fab) (width 0.1)) + (fp_line (start -2.84 21.89) (end 55.16 21.89) (layer F.Fab) (width 0.1)) + (fp_line (start 55.16 21.89) (end 55.16 -8.61) (layer F.Fab) (width 0.1)) + (fp_line (start 55.16 -8.61) (end -2.84 -8.61) (layer F.Fab) (width 0.1)) + (fp_line (start -2.94 -8.71) (end -2.94 21.99) (layer F.SilkS) (width 0.12)) + (fp_line (start -2.94 21.99) (end 55.26 21.99) (layer F.SilkS) (width 0.12)) + (fp_line (start 55.26 21.99) (end 55.26 -8.71) (layer F.SilkS) (width 0.12)) + (fp_line (start 55.26 -8.71) (end -2.94 -8.71) (layer F.SilkS) (width 0.12)) + (fp_line (start -3.34 -9.11) (end -3.34 22.39) (layer F.CrtYd) (width 0.05)) + (fp_line (start -3.34 22.39) (end 55.66 22.39) (layer F.CrtYd) (width 0.05)) + (fp_line (start 55.66 22.39) (end 55.66 -9.11) (layer F.CrtYd) (width 0.05)) + (fp_line (start 55.66 -9.11) (end -3.34 -9.11) (layer F.CrtYd) (width 0.05)) + (fp_line (start 35.685 2.54) (end 17.905 2.54) (layer F.SilkS) (width 0.12)) + (fp_line (start 17.905 2.54) (end 17.905 1.27) (layer F.SilkS) (width 0.12)) + (fp_line (start 17.905 1.27) (end 16.635 1.27) (layer F.SilkS) (width 0.12)) + (fp_line (start 16.635 1.27) (end 16.635 -1.27) (layer F.SilkS) (width 0.12)) + (fp_line (start 16.635 -1.27) (end 17.905 -1.27) (layer F.SilkS) (width 0.12)) + (fp_line (start 17.905 -1.27) (end 17.905 -2.54) (layer F.SilkS) (width 0.12)) + (fp_line (start 17.905 -2.54) (end 35.685 -2.54) (layer F.SilkS) (width 0.12)) + (fp_line (start 35.685 -2.54) (end 35.685 2.54) (layer F.SilkS) (width 0.12)) + (fp_line (start 16.635 16.13) (end 34.415 16.13) (layer F.SilkS) (width 0.12)) + (fp_line (start 34.415 16.13) (end 34.415 14.86) (layer F.SilkS) (width 0.12)) + (fp_line (start 34.415 14.86) (end 35.685 14.86) (layer F.SilkS) (width 0.12)) + (fp_line (start 35.685 14.86) (end 35.685 12.32) (layer F.SilkS) (width 0.12)) + (fp_line (start 35.685 12.32) (end 34.415 12.32) (layer F.SilkS) (width 0.12)) + (fp_line (start 34.415 12.32) (end 34.415 11.05) (layer F.SilkS) (width 0.12)) + (fp_line (start 34.415 11.05) (end 16.635 11.05) (layer F.SilkS) (width 0.12)) + (fp_line (start 16.635 11.05) (end 16.635 16.13) (layer F.SilkS) (width 0.12)) + (fp_text user %R (at 26.16 6.63) (layer F.Fab) + (effects (font (size 1 1) (thickness 0.15))) + ) + (fp_text user - (at 36.955 0) (layer F.SilkS) (effects (font (size 1.5 1.5) (thickness 0.15))) ) - (fp_text user %R (at 0 0) (layer F.Fab) + (fp_text user + (at 15.365 0) (layer F.SilkS) + (effects (font (size 1.5 1.5) (thickness 0.15))) + ) + (fp_text user - (at 15.365 13.59) (layer F.SilkS) + (effects (font (size 1.5 1.5) (thickness 0.15))) + ) + (fp_text user + (at 36.955 13.59) (layer F.SilkS) + (effects (font (size 1.5 1.5) (thickness 0.15))) + ) + (fp_text user + (at -4.34 0) (layer F.SilkS) + (effects (font (size 1.5 1.5) (thickness 0.15))) + ) + (fp_text user - (at -4.34 13.59) (layer F.SilkS) + (effects (font (size 1.5 1.5) (thickness 0.15))) + ) + (pad 1 thru_hole rect (at 0 0) (size 2.17 2.17) (drill 1.17) (layers *.Cu *.Mask) + (net 1 "Net-(BT1-Pad1)")) + (pad 2 thru_hole circle (at 0 13.59) (size 2.17 2.17) (drill 1.17) (layers *.Cu *.Mask) + (net 2 GND)) + (pad "" np_thru_hole circle (at 26.16 6.63) (size 3.65 3.65) (drill 3.65) (layers *.Cu *.Mask)) + (model ${KISYS3DMOD}/Battery.3dshapes/BatteryHolder_MPD_BC2AAPC_2xAA.wrl + (at (xyz 0 0 0)) + (scale (xyz 1 1 1)) + (rotate (xyz 0 0 0)) + ) + ) + + (module Resistor_SMD:R_1206_3216Metric (layer F.Cu) (tedit 5B20DC38) (tstamp 5B5BC1DF) + (at 60 61.4 90) + (descr "Resistor SMD 1206 (3216 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: http://www.tortai-tech.com/upload/download/2011102023233369053.pdf), generated with kicad-footprint-generator") + (tags resistor) + (path /5B431328) + (attr smd) + (fp_text reference R1 (at 0 -1.82 90) (layer F.SilkS) + (effects (font (size 1 1) (thickness 0.15))) + ) + (fp_text value 10k (at 0 1.82 90) (layer F.Fab) (effects (font (size 1 1) (thickness 0.15))) ) - (fp_arc (start 15.2 0) (end 4.01 3.6) (angle -162.5) (layer F.CrtYd) (width 0.05)) - (fp_arc (start 15.2 0) (end 4.01 -3.6) (angle 162.5) (layer F.CrtYd) (width 0.05)) - (fp_arc (start 3.5 3.8) (end 3.5 3.25) (angle 70) (layer F.CrtYd) (width 0.05)) - (fp_arc (start 3.5 -3.8) (end 3.5 -3.25) (angle -70) (layer F.CrtYd) (width 0.05)) - (fp_arc (start 15.2 0) (end 4.25 3.5) (angle -162.5) (layer F.SilkS) (width 0.12)) - (fp_arc (start 3.5 3.8) (end 3.5 3) (angle 70) (layer F.SilkS) (width 0.12)) - (fp_arc (start 15.2 0) (end 4.25 -3.5) (angle 162.5) (layer F.SilkS) (width 0.12)) - (fp_arc (start 3.5 -3.8) (end 3.5 -3) (angle -70) (layer F.SilkS) (width 0.12)) - (fp_arc (start 3.5 3.8) (end 3.5 2.9) (angle 70) (layer F.Fab) (width 0.1)) - (fp_arc (start 15.2 0) (end 4.35 3.5) (angle -162.5) (layer F.Fab) (width 0.1)) - (fp_arc (start 15.2 0) (end 4.35 -3.5) (angle 162.5) (layer F.Fab) (width 0.1)) - (fp_arc (start 15.2 0) (end 5.2 1.3) (angle -180) (layer F.Fab) (width 0.1)) - (fp_line (start -2.45 -3.25) (end 3.5 -3.25) (layer F.CrtYd) (width 0.05)) - (fp_line (start -2.45 3.25) (end 3.5 3.25) (layer F.CrtYd) (width 0.05)) - (fp_line (start -2.45 3.25) (end -2.45 -3.25) (layer F.CrtYd) (width 0.05)) - (fp_line (start -2.2 -3) (end 3.5 -3) (layer F.SilkS) (width 0.12)) - (fp_line (start -2.2 3) (end -2.2 -3) (layer F.SilkS) (width 0.12)) - (fp_line (start -2.2 3) (end 3.5 3) (layer F.SilkS) (width 0.12)) - (fp_arc (start 15.2 0) (end 9 1.3) (angle -170) (layer F.Fab) (width 0.1)) - (fp_arc (start 15.2 0) (end 13.3 1.3) (angle -150) (layer F.Fab) (width 0.1)) - (fp_line (start 23.5712 7.7216) (end 22.6568 6.8834) (layer F.Fab) (width 0.1)) - (fp_line (start 23.5712 -7.7216) (end 22.6314 -6.858) (layer F.Fab) (width 0.1)) - (fp_arc (start 15.2 0) (end 13.3 -1.3) (angle 150) (layer F.Fab) (width 0.1)) - (fp_arc (start 15.2 0) (end 9 -1.3) (angle 170) (layer F.Fab) (width 0.1)) - (fp_arc (start 15.2 0) (end 5.2 -1.3) (angle 180) (layer F.Fab) (width 0.1)) - (fp_line (start 3.5306 -2.9) (end -1.7 -2.9) (layer F.Fab) (width 0.1)) - (fp_line (start -1.7 2.9) (end 3.5306 2.9) (layer F.Fab) (width 0.1)) - (fp_line (start -2.1 -2.5) (end -2.1 2.5) (layer F.Fab) (width 0.1)) - (fp_line (start 0 1.3) (end 16.2 1.3) (layer F.Fab) (width 0.1)) - (fp_line (start 16.2 -1.3) (end 0 -1.3) (layer F.Fab) (width 0.1)) - (fp_arc (start 3.5 -3.8) (end 3.5 -2.9) (angle -70) (layer F.Fab) (width 0.1)) - (fp_arc (start 16.2 0) (end 16.2 -1.3) (angle 180) (layer F.Fab) (width 0.1)) - (fp_line (start 0 -1.3) (end 0 1.3) (layer F.Fab) (width 0.1)) - (fp_arc (start -1.7 2.5) (end -2.1 2.5) (angle -90) (layer F.Fab) (width 0.1)) - (fp_arc (start -1.7 -2.5) (end -2.1 -2.5) (angle 90) (layer F.Fab) (width 0.1)) - (pad 2 thru_hole circle (at 20.49 0) (size 3 3) (drill 1.5) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 1 thru_hole rect (at 0 0) (size 3 3) (drill 1.5) (layers *.Cu *.Mask) - (net 2 "Net-(BT1-Pad1)")) - (model ${KISYS3DMOD}/Battery.3dshapes/BatteryHolder_Keystone_103_1x20mm.wrl + (fp_line (start -1.6 0.8) (end -1.6 -0.8) (layer F.Fab) (width 0.1)) + (fp_line (start -1.6 -0.8) (end 1.6 -0.8) (layer F.Fab) (width 0.1)) + (fp_line (start 1.6 -0.8) (end 1.6 0.8) (layer F.Fab) (width 0.1)) + (fp_line (start 1.6 0.8) (end -1.6 0.8) (layer F.Fab) (width 0.1)) + (fp_line (start -0.602064 -0.91) (end 0.602064 -0.91) (layer F.SilkS) (width 0.12)) + (fp_line (start -0.602064 0.91) (end 0.602064 0.91) (layer F.SilkS) (width 0.12)) + (fp_line (start -2.28 1.12) (end -2.28 -1.12) (layer F.CrtYd) (width 0.05)) + (fp_line (start -2.28 -1.12) (end 2.28 -1.12) (layer F.CrtYd) (width 0.05)) + (fp_line (start 2.28 -1.12) (end 2.28 1.12) (layer F.CrtYd) (width 0.05)) + (fp_line (start 2.28 1.12) (end -2.28 1.12) (layer F.CrtYd) (width 0.05)) + (fp_text user %R (at 0 0 90) (layer F.Fab) + (effects (font (size 0.8 0.8) (thickness 0.12))) + ) + (pad 1 smd roundrect (at -1.4 0 90) (size 1.25 1.75) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.2) + (net 4 "Net-(R1-Pad1)")) + (pad 2 smd roundrect (at 1.4 0 90) (size 1.25 1.75) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.2) + (net 1 "Net-(BT1-Pad1)")) + (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_1206_3216Metric.wrl (at (xyz 0 0 0)) (scale (xyz 1 1 1)) (rotate (xyz 0 0 0)) ) ) - (module Capacitor_THT:CP_Axial_L18.0mm_D8.0mm_P25.00mm_Horizontal (layer F.Cu) (tedit 5AE50EF2) (tstamp 5B59DB0A) - (at 201.5 64.75 270) - (descr "CP, Axial series, Axial, Horizontal, pin pitch=25mm, , length*diameter=18*8mm^2, Electrolytic Capacitor, , http://www.vishay.com/docs/28325/021asm.pdf") - (tags "CP Axial series Axial Horizontal pin pitch 25mm length 18mm diameter 8mm Electrolytic Capacitor") + (module Capacitor_THT:CP_Radial_Tantal_D10.5mm_P5.00mm (layer F.Cu) (tedit 5AE50EF0) (tstamp 5B5D0FE8) + (at 51.25 76) + (descr "CP, Radial_Tantal series, Radial, pin pitch=5.00mm, , diameter=10.5mm, Tantal Electrolytic Capacitor, http://cdn-reichelt.de/documents/datenblatt/B300/TANTAL-TB-Serie%23.pdf") + (tags "CP Radial_Tantal series Radial pin pitch 5.00mm diameter 10.5mm Tantal Electrolytic Capacitor") (path /5B4314AB) - (fp_text reference C1 (at 12.5 -5.12 270) (layer F.SilkS) + (fp_text reference C1 (at 2.5 -6.5) (layer F.SilkS) (effects (font (size 1 1) (thickness 0.15))) ) - (fp_text value 1u (at 12.5 5.12 270) (layer F.Fab) + (fp_text value 1u (at 2.5 6.5) (layer F.Fab) (effects (font (size 1 1) (thickness 0.15))) ) - (fp_line (start 3.5 -4) (end 3.5 4) (layer F.Fab) (width 0.1)) - (fp_line (start 21.5 -4) (end 21.5 4) (layer F.Fab) (width 0.1)) - (fp_line (start 3.5 -4) (end 5.18 -4) (layer F.Fab) (width 0.1)) - (fp_line (start 5.18 -4) (end 6.08 -3.1) (layer F.Fab) (width 0.1)) - (fp_line (start 6.08 -3.1) (end 6.98 -4) (layer F.Fab) (width 0.1)) - (fp_line (start 6.98 -4) (end 21.5 -4) (layer F.Fab) (width 0.1)) - (fp_line (start 3.5 4) (end 5.18 4) (layer F.Fab) (width 0.1)) - (fp_line (start 5.18 4) (end 6.08 3.1) (layer F.Fab) (width 0.1)) - (fp_line (start 6.08 3.1) (end 6.98 4) (layer F.Fab) (width 0.1)) - (fp_line (start 6.98 4) (end 21.5 4) (layer F.Fab) (width 0.1)) - (fp_line (start 0 0) (end 3.5 0) (layer F.Fab) (width 0.1)) - (fp_line (start 25 0) (end 21.5 0) (layer F.Fab) (width 0.1)) - (fp_line (start 5.2 0) (end 7 0) (layer F.Fab) (width 0.1)) - (fp_line (start 6.1 -0.9) (end 6.1 0.9) (layer F.Fab) (width 0.1)) - (fp_line (start 1.28 -2.6) (end 3.08 -2.6) (layer F.SilkS) (width 0.12)) - (fp_line (start 2.18 -3.5) (end 2.18 -1.7) (layer F.SilkS) (width 0.12)) - (fp_line (start 3.38 -4.12) (end 3.38 4.12) (layer F.SilkS) (width 0.12)) - (fp_line (start 21.62 -4.12) (end 21.62 4.12) (layer F.SilkS) (width 0.12)) - (fp_line (start 3.38 -4.12) (end 5.18 -4.12) (layer F.SilkS) (width 0.12)) - (fp_line (start 5.18 -4.12) (end 6.08 -3.22) (layer F.SilkS) (width 0.12)) - (fp_line (start 6.08 -3.22) (end 6.98 -4.12) (layer F.SilkS) (width 0.12)) - (fp_line (start 6.98 -4.12) (end 21.62 -4.12) (layer F.SilkS) (width 0.12)) - (fp_line (start 3.38 4.12) (end 5.18 4.12) (layer F.SilkS) (width 0.12)) - (fp_line (start 5.18 4.12) (end 6.08 3.22) (layer F.SilkS) (width 0.12)) - (fp_line (start 6.08 3.22) (end 6.98 4.12) (layer F.SilkS) (width 0.12)) - (fp_line (start 6.98 4.12) (end 21.62 4.12) (layer F.SilkS) (width 0.12)) - (fp_line (start 1.44 0) (end 3.38 0) (layer F.SilkS) (width 0.12)) - (fp_line (start 23.56 0) (end 21.62 0) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.45 -4.25) (end -1.45 4.25) (layer F.CrtYd) (width 0.05)) - (fp_line (start -1.45 4.25) (end 26.45 4.25) (layer F.CrtYd) (width 0.05)) - (fp_line (start 26.45 4.25) (end 26.45 -4.25) (layer F.CrtYd) (width 0.05)) - (fp_line (start 26.45 -4.25) (end -1.45 -4.25) (layer F.CrtYd) (width 0.05)) - (fp_text user %R (at 12.5 0 270) (layer F.Fab) + (fp_circle (center 2.5 0) (end 7.75 0) (layer F.Fab) (width 0.1)) + (fp_circle (center 2.5 0) (end 7.87 0) (layer F.SilkS) (width 0.12)) + (fp_circle (center 2.5 0) (end 8 0) (layer F.CrtYd) (width 0.05)) + (fp_line (start -2.004387 -2.2975) (end -0.954387 -2.2975) (layer F.Fab) (width 0.1)) + (fp_line (start -1.479387 -2.8225) (end -1.479387 -1.7725) (layer F.Fab) (width 0.1)) + (fp_line (start -3.247133 -3.015) (end -2.197133 -3.015) (layer F.SilkS) (width 0.12)) + (fp_line (start -2.722133 -3.54) (end -2.722133 -2.49) (layer F.SilkS) (width 0.12)) + (fp_text user %R (at 2.5 0) (layer F.Fab) (effects (font (size 1 1) (thickness 0.15))) ) - (pad 1 thru_hole rect (at 0 0 270) (size 2.4 2.4) (drill 1.2) (layers *.Cu *.Mask) + (pad 1 thru_hole rect (at 0 0) (size 1.6 1.6) (drill 0.8) (layers *.Cu *.Mask) (net 3 "Net-(C1-Pad1)")) - (pad 2 thru_hole oval (at 25 0 270) (size 2.4 2.4) (drill 1.2) (layers *.Cu *.Mask) - (net 1 GND)) - (model ${KISYS3DMOD}/Capacitor_THT.3dshapes/CP_Axial_L18.0mm_D8.0mm_P25.00mm_Horizontal.wrl + (pad 2 thru_hole circle (at 5 0) (size 1.6 1.6) (drill 0.8) (layers *.Cu *.Mask) + (net 2 GND)) + (model ${KISYS3DMOD}/Capacitor_THT.3dshapes/CP_Radial_Tantal_D10.5mm_P5.00mm.wrl (at (xyz 0 0 0)) (scale (xyz 1 1 1)) (rotate (xyz 0 0 0)) ) ) - (module Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal (layer F.Cu) (tedit 5AE5139B) (tstamp 5B59DB1D) - (at 183.5 53.5 180) - (descr "Resistor, Axial_DIN0204 series, Axial, Horizontal, pin pitch=5.08mm, 0.167W, length*diameter=3.6*1.6mm^2, http://cdn-reichelt.de/documents/datenblatt/B400/1_4W%23YAG.pdf") - (tags "Resistor Axial_DIN0204 series Axial Horizontal pin pitch 5.08mm 0.167W length 3.6mm diameter 1.6mm") - (path /5B431328) - (fp_text reference R1 (at 2.54 -1.92 180) (layer F.SilkS) + (module Resistor_SMD:R_1206_3216Metric (layer F.Cu) (tedit 5B20DC38) (tstamp 5B5D10B5) + (at 58.75 66.5) + (descr "Resistor SMD 1206 (3216 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: http://www.tortai-tech.com/upload/download/2011102023233369053.pdf), generated with kicad-footprint-generator") + (tags resistor) + (path /5B5CC4D4) + (attr smd) + (fp_text reference R2 (at 0 -1.82) (layer F.SilkS) (effects (font (size 1 1) (thickness 0.15))) ) - (fp_text value 10k (at 2.54 1.92 180) (layer F.Fab) + (fp_text value 10k (at 0 1.82) (layer F.Fab) (effects (font (size 1 1) (thickness 0.15))) ) - (fp_line (start 0.74 -0.8) (end 0.74 0.8) (layer F.Fab) (width 0.1)) - (fp_line (start 0.74 0.8) (end 4.34 0.8) (layer F.Fab) (width 0.1)) - (fp_line (start 4.34 0.8) (end 4.34 -0.8) (layer F.Fab) (width 0.1)) - (fp_line (start 4.34 -0.8) (end 0.74 -0.8) (layer F.Fab) (width 0.1)) - (fp_line (start 0 0) (end 0.74 0) (layer F.Fab) (width 0.1)) - (fp_line (start 5.08 0) (end 4.34 0) (layer F.Fab) (width 0.1)) - (fp_line (start 0.62 -0.92) (end 4.46 -0.92) (layer F.SilkS) (width 0.12)) - (fp_line (start 0.62 0.92) (end 4.46 0.92) (layer F.SilkS) (width 0.12)) - (fp_line (start -0.95 -1.05) (end -0.95 1.05) (layer F.CrtYd) (width 0.05)) - (fp_line (start -0.95 1.05) (end 6.03 1.05) (layer F.CrtYd) (width 0.05)) - (fp_line (start 6.03 1.05) (end 6.03 -1.05) (layer F.CrtYd) (width 0.05)) - (fp_line (start 6.03 -1.05) (end -0.95 -1.05) (layer F.CrtYd) (width 0.05)) - (fp_text user %R (at 2.54 0 180) (layer F.Fab) - (effects (font (size 0.72 0.72) (thickness 0.108))) + (fp_line (start -1.6 0.8) (end -1.6 -0.8) (layer F.Fab) (width 0.1)) + (fp_line (start -1.6 -0.8) (end 1.6 -0.8) (layer F.Fab) (width 0.1)) + (fp_line (start 1.6 -0.8) (end 1.6 0.8) (layer F.Fab) (width 0.1)) + (fp_line (start 1.6 0.8) (end -1.6 0.8) (layer F.Fab) (width 0.1)) + (fp_line (start -0.602064 -0.91) (end 0.602064 -0.91) (layer F.SilkS) (width 0.12)) + (fp_line (start -0.602064 0.91) (end 0.602064 0.91) (layer F.SilkS) (width 0.12)) + (fp_line (start -2.28 1.12) (end -2.28 -1.12) (layer F.CrtYd) (width 0.05)) + (fp_line (start -2.28 -1.12) (end 2.28 -1.12) (layer F.CrtYd) (width 0.05)) + (fp_line (start 2.28 -1.12) (end 2.28 1.12) (layer F.CrtYd) (width 0.05)) + (fp_line (start 2.28 1.12) (end -2.28 1.12) (layer F.CrtYd) (width 0.05)) + (fp_text user %R (at 0 0) (layer F.Fab) + (effects (font (size 0.8 0.8) (thickness 0.12))) ) - (pad 1 thru_hole circle (at 0 0 180) (size 1.4 1.4) (drill 0.7) (layers *.Cu *.Mask) + (pad 1 smd roundrect (at -1.4 0) (size 1.25 1.75) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.2) (net 3 "Net-(C1-Pad1)")) - (pad 2 thru_hole oval (at 5.08 0 180) (size 1.4 1.4) (drill 0.7) (layers *.Cu *.Mask) - (net 2 "Net-(BT1-Pad1)")) - (model ${KISYS3DMOD}/Resistor_THT.3dshapes/R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal.wrl + (pad 2 smd roundrect (at 1.4 0) (size 1.25 1.75) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.2) + (net 4 "Net-(R1-Pad1)")) + (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_1206_3216Metric.wrl (at (xyz 0 0 0)) (scale (xyz 1 1 1)) (rotate (xyz 0 0 0)) ) ) - (segment (start 167.965 81.279833) (end 174.529833 81.279833) (width 0.25) (layer B.Cu) (net 1)) - (segment (start 166.465001 79.779834) (end 167.965 81.279833) (width 0.25) (layer B.Cu) (net 1)) - (segment (start 174.529833 81.279833) (end 189 95.75) (width 0.25) (layer B.Cu) (net 1)) - (segment (start 195.5 95.75) (end 201.5 89.75) (width 0.25) (layer B.Cu) (net 1)) - (segment (start 189 95.75) (end 195.5 95.75) (width 0.25) (layer B.Cu) (net 1)) - (segment (start 145.975001 78.029834) (end 145.75 77.804833) (width 0.25) (layer F.Cu) (net 2)) - (segment (start 145.975001 79.779834) (end 145.975001 78.029834) (width 0.25) (layer F.Cu) (net 2)) - (segment (start 145.75 77.804833) (end 145.75 62.75) (width 0.25) (layer F.Cu) (net 2)) - (segment (start 155 53.5) (end 178.42 53.5) (width 0.25) (layer F.Cu) (net 2)) - (segment (start 145.75 62.75) (end 155 53.5) (width 0.25) (layer F.Cu) (net 2)) - (segment (start 201.5 63.3) (end 201.5 64.75) (width 0.25) (layer F.Cu) (net 3)) - (segment (start 191.7 53.5) (end 201.5 63.3) (width 0.25) (layer F.Cu) (net 3)) - (segment (start 183.5 53.5) (end 191.7 53.5) (width 0.25) (layer F.Cu) (net 3)) + (segment (start 71.25 60) (end 71.75 60.5) (width 0.25) (layer F.Cu) (net 1)) + (segment (start 60 60) (end 71.25 60) (width 0.25) (layer F.Cu) (net 1)) + (segment (start 62.91 74.09) (end 61 76) (width 0.25) (layer B.Cu) (net 2)) + (segment (start 71.75 74.09) (end 62.91 74.09) (width 0.25) (layer B.Cu) (net 2)) + (segment (start 56.25 76) (end 61 76) (width 0.25) (layer B.Cu) (net 2)) + (segment (start 53.25 66.5) (end 51.25 68.5) (width 0.25) (layer F.Cu) (net 3)) + (segment (start 57.35 66.5) (end 53.25 66.5) (width 0.25) (layer F.Cu) (net 3)) + (segment (start 51.25 76) (end 51.25 68.5) (width 0.25) (layer F.Cu) (net 3)) + (segment (start 60 66.35) (end 60.15 66.5) (width 0.25) (layer F.Cu) (net 4)) + (segment (start 60 62.8) (end 60 66.35) (width 0.25) (layer F.Cu) (net 4)) ) diff --git a/test/doit/schematics/schematic-1.sch b/test/doit/schematics/schematic-1.sch index 9efffc4..a0175f3 100644 --- a/test/doit/schematics/schematic-1.sch +++ b/test/doit/schematics/schematic-1.sch @@ -16,13 +16,14 @@ $EndDescr $Comp L Device:R R1 U 1 1 5B431328 -P 4400 2600 -F 0 "R1" V 4193 2600 50 0000 C CNN -F 1 "10k" V 4284 2600 50 0000 C CNN -F 2 "Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal" V 4330 2600 50 0001 C CNN -F 3 "~" H 4400 2600 50 0001 C CNN - 1 4400 2600 - 0 1 1 0 +P 4150 2600 +F 0 "R1" V 3943 2600 50 0000 C CNN +F 1 "10k" V 4034 2600 50 0000 C CNN +F 2 "Resistor_SMD:R_1206_3216Metric" V 4080 2600 50 0001 C CNN +F 3 "~" H 4150 2600 50 0001 C CNN +F 4 "RMCF1206JT10K0" V 4150 2600 50 0001 C CNN "mpn" + 1 4150 2600 + 0 1 1 0 $EndComp $Comp L Device:Battery_Cell BT1 @@ -30,26 +31,28 @@ U 1 1 5B431438 P 3700 2900 F 0 "BT1" H 3818 2996 50 0000 L CNN F 1 "9V" H 3818 2905 50 0000 L CNN -F 2 "Battery:BatteryHolder_Keystone_103_1x20mm" V 3700 2960 50 0001 C CNN +F 2 "Battery:BatteryHolder_MPD_BC2AAPC_2xAA" V 3700 2960 50 0001 C CNN F 3 "~" V 3700 2960 50 0001 C CNN +F 4 "BC2AAPC" H 3700 2900 50 0001 C CNN "mpn" 1 3700 2900 - 1 0 0 -1 + 1 0 0 -1 $EndComp $Comp L Device:C C1 U 1 1 5B4314AB -P 5000 2850 -F 0 "C1" H 5115 2896 50 0000 L CNN -F 1 "1u" H 5115 2805 50 0000 L CNN -F 2 "Capacitor_THT:CP_Axial_L18.0mm_D8.0mm_P25.00mm_Horizontal" H 5038 2700 50 0001 C CNN -F 3 "~" H 5000 2850 50 0001 C CNN - 1 5000 2850 - 1 0 0 -1 +P 5100 2850 +F 0 "C1" H 5215 2896 50 0000 L CNN +F 1 "1u" H 5215 2805 50 0000 L CNN +F 2 "Capacitor_THT:CP_Radial_Tantal_D10.5mm_P5.00mm" H 5138 2700 50 0001 C CNN +F 3 "~" H 5100 2850 50 0001 C CNN +F 4 "UCA2G100MPD1TD" H 5100 2850 50 0001 C CNN "mpn" + 1 5100 2850 + 1 0 0 -1 $EndComp Wire Wire Line 3700 3000 3700 3100 Wire Wire Line - 5000 3100 5000 3000 + 5100 3100 5100 3000 $Comp L power:GND #PWR0101 U 1 1 5B4315FE @@ -59,7 +62,7 @@ F 1 "GND" H 3705 3027 50 0000 C CNN F 2 "" H 3700 3200 50 0001 C CNN F 3 "" H 3700 3200 50 0001 C CNN 1 3700 3200 - 1 0 0 -1 + 1 0 0 -1 $EndComp Wire Wire Line 3700 3200 3700 3100 @@ -67,11 +70,25 @@ Connection ~ 3700 3100 Wire Wire Line 3700 2700 3700 2600 Wire Wire Line - 5000 2600 5000 2700 + 5100 2600 5100 2700 Wire Wire Line - 3700 2600 4250 2600 + 3700 2600 4000 2600 Wire Wire Line - 3700 3100 5000 3100 + 3700 3100 5100 3100 Wire Wire Line - 4550 2600 5000 2600 + 4300 2600 4500 2600 +$Comp +L Device:R R2 +U 1 1 5B5CC4D4 +P 4650 2600 +F 0 "R2" V 4443 2600 50 0000 C CNN +F 1 "10k" V 4534 2600 50 0000 C CNN +F 2 "Resistor_SMD:R_1206_3216Metric" V 4580 2600 50 0001 C CNN +F 3 "~" H 4650 2600 50 0001 C CNN +F 4 "RMCF1206JT10K0" V 4650 2600 50 0001 C CNN "mpn" + 1 4650 2600 + 0 1 1 0 +$EndComp +Wire Wire Line + 4800 2600 5100 2600 $EndSCHEMATC diff --git a/test/doit/test_doit.py b/test/doit/test_doit.py index 32eb138..2f6f035 100644 --- a/test/doit/test_doit.py +++ b/test/doit/test_doit.py @@ -6,15 +6,16 @@ from pathlib import Path from ee.ds import DataSetManager from inspect import Parameter import ee.kicad.doit +import ee.digikey.doit from ee.kicad.doit import * +from ee.digikey.doit import * logger = logging.getLogger(__name__) file_dir = Path(__file__).parent schematics_dir = file_dir / "schematics" - def exec_task(task): targets = task["targets"] for a in task["actions"]: @@ -44,6 +45,9 @@ def test_doit(tmpdir, caplog): sch=schematics_dir / "schematic-1.sch", kicad_pcb=schematics_dir / "schematic-1.kicad_pcb",) + ee.digikey.doit.doit_config.configure(data_set_manager=dsm) + exec_task(task_kicad_sch_to_data_set()) exec_task(task_kicad_pcb_to_data_set()) exec_task(task_kicad_create_component_data_set()) + exec_task(task_digikey_resolve_schematic_components()) |