From e93cca5e7b8ee2ecb9aa9d2be4f9764e9a44b5cf Mon Sep 17 00:00:00 2001 From: "Hendrik v. Raven" Date: Sun, 18 Aug 2019 17:59:20 +0200 Subject: [PATCH] transformer: introduce naming helpers & fix footprint --- .../Transformer/definitions/block.yaml | 8 ++--- .../Transformer/definitions/breve.yaml | 30 +++++++------------ schlib/autogen/Transformer/transformer.py | 22 ++++++++++++-- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/schlib/autogen/Transformer/definitions/block.yaml b/schlib/autogen/Transformer/definitions/block.yaml index cd507677..8a6541e0 100644 --- a/schlib/autogen/Transformer/definitions/block.yaml +++ b/schlib/autogen/Transformer/definitions/block.yaml @@ -1,17 +1,15 @@ Block_FL: - reference: TR name: "{series}-{va_rating}-{voltage}" manufacturer: Block series: FL description: "{va_rating}VA, 2x{voltage}, Dual Primary, Dual Secondary, Print Transformer" keywords: "{va_rating}VA PCB transformer" + datasheet: "https://www.block.eu/fileadmin/Blaetterkatalog_und_ebook/eBook.pdf#page=278" dots: bottom primary: 2 - secondary: - - dot: bottom - - dot: bottom + secondary: 2 core: true - footprint_library: "Transformer_THT.pretty" + footprint_library: "Transformer_THT" variants: power_rating: - va_rating: 2 diff --git a/schlib/autogen/Transformer/definitions/breve.yaml b/schlib/autogen/Transformer/definitions/breve.yaml index a54d65e2..b6a688b5 100644 --- a/schlib/autogen/Transformer/definitions/breve.yaml +++ b/schlib/autogen/Transformer/definitions/breve.yaml @@ -1,28 +1,24 @@ Breve_TEZ: manufacturer: Breve - name: "{series}{va_rating}-D-{secs}" - description: "TEZ{va_rating}/D/{secs}, {va_rating}VA, Cast Resin Transformer" + name: "{series}{va_rating}-D-{secondaries}" + description: "TEZ{va_rating}/D/{secondaries}, {va_rating}VA, Cast Resin Transformer" keywords: "{va_rating}VA PCB Transformer Single Primary" datasheet: "https://www.breve.pl/pdf/ANG/TEZ_ang.pdf" core: true series: TEZ - footprint_library: "Transformer_THT.pretty" + footprint_library: "Transformer_THT" footprint: "Transformer_{manufacturer}_{series}-{fp_size}" definitions: package_small: &tez_small primary: [1, 5] variants: - - secs: 1 - secondary: [7, 9] - - secs: 2 - secondary: [[6, 7], [9, 10]] + - secondary: [7, 9] + - secondary: [[6, 7], [9, 10]] package_large: &tez_large primary: [1, 7] variants: - - secs: 1 - secondary: [9, 13] - - secs: 2 - secondary: [[8, 9], [13, 14]] + - secondary: [9, 13] + - secondary: [[8, 9], [13, 14]] variants: - va_rating: "0,5" fp_size: "22x24" @@ -30,10 +26,8 @@ Breve_TEZ: - dot: top pins: [1, 4] variants: - - secs: 1 - secondary: [6, 7] - - secs: 2 - secondary: [[5, 6], [7,8]] + - secondary: [6, 7] + - secondary: [[5, 6], [7,8]] - va_rating: "1,5" fp_size: "28x33" <<: *tez_small @@ -59,10 +53,8 @@ Breve_TEZ: fp_size: "44x52" primary: [1, 6] variants: - - secs: 1 - secondary: [8, 11] - - secs: 2 - secondary: [[7, 8], [11, 12]] + - secondary: [8, 11] + - secondary: [[7, 8], [11, 12]] - va_rating: "16,0" fp_size: "47x57" <<: *tez_large diff --git a/schlib/autogen/Transformer/transformer.py b/schlib/autogen/Transformer/transformer.py index 31776cf8..72acfc5d 100755 --- a/schlib/autogen/Transformer/transformer.py +++ b/schlib/autogen/Transformer/transformer.py @@ -67,7 +67,8 @@ def generate_transformer(generator, config): if config.get("core"): drawing.append(draw_core(height)) - translate = drawing_sep % 200 / 2 + translate = ((max(config["primaries"], config["secondaries"]) - 1) + * (drawing_sep % 200) / 2) drawing.translate(dict( x=0, y=translate)) @@ -81,7 +82,9 @@ def generate_transformer(generator, config): fontsize=fontsize, alignment_vertical=SymbolField.FieldAlignment.CENTER ) - symbol.setDefaultFootprint(value=config["footprint"].format(**config)) + symbol.setDefaultFootprint(value=( + config["footprint_library"] + ":" + config["footprint"] + ).format(**config)) for alias in config.get("aliases", []): name = alias["name"] @@ -256,6 +259,7 @@ def expand_definition(name, config): last_used_pin = max(max(*prim["pins"]) for prim in exp["primary"]) exp["secondary"] = expand_coil_definition(exp, exp["secondary"], pin_start=last_used_pin) + exp.update(add_naming_helpers(exp)) return expanded @@ -280,6 +284,20 @@ def expand_coil_definition(config, coil_config, pin_start=1): out.append(coil_conf) return out +def add_naming_helpers(config): + """inject extra entries usefull for constructing names""" + counting_dict = { + 1: "single", + 2: "dual", + 3: "triple" + } + return dict( + primaries=len(config["primary"]), + secondaries=len(config["secondary"]), + text_primaries=counting_dict[len(config["primary"])], + text_secondaries=counting_dict[len(config["secondary"])], + ) + def build_symbols(file_path): defs = [] for path in Path("definitions").glob("*.yaml"):