From f7f0b6f13609f17b96fcdd0e4df0a170d96f603e Mon Sep 17 00:00:00 2001 From: Richard Lin Date: Sun, 18 Aug 2024 17:58:34 -0700 Subject: [PATCH] cleaning --- edg/jlcparts/JlcPartsBase.py | 8 +------- edg/jlcparts/JlcPartsBjt.py | 2 +- edg/jlcparts/JlcPartsBoardTop.py | 2 +- edg/jlcparts/JlcPartsMlcc.py | 22 ++++++++++++++++++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/edg/jlcparts/JlcPartsBase.py b/edg/jlcparts/JlcPartsBase.py index 43fb5b4e9..1b228ec4a 100644 --- a/edg/jlcparts/JlcPartsBase.py +++ b/edg/jlcparts/JlcPartsBase.py @@ -81,10 +81,6 @@ def config_root_dir(root_dir: str): @classmethod def _make_table(cls) -> PartsTable: - return cls._jlc_table() - - @classmethod - def _jlc_table(cls) -> PartsTable: """Return the table, cached if possible""" if cls._cached_table is None: cls._cached_table = cls._parse_table() @@ -116,7 +112,6 @@ def _parse_table(cls) -> PartsTable: datasheet_index = data.jlcpart_schema.index("datasheet") attributes_index = data.jlcpart_schema.index("attributes") - for component in data.components: row_dict: Dict[PartsTableColumn, Any] = {} @@ -132,10 +127,9 @@ def _parse_table(cls) -> PartsTable: if attributes.get("Status", str) in ["Discontinued"]: continue row_dict[cls.BASIC_PART_COL] = attributes.get("Basic/Extended", str) == "Basic" - row_dict[cls.MANUFACTURER_COL] = attributes.get("Manufacturer", str) - package = attributes.get("Package", str) + package = attributes.get("Package", str) row_dict_opt = cls._entry_to_table_row(row_dict, filename, package, attributes) if row_dict_opt is not None: rows.append(PartsTableRow(row_dict_opt)) diff --git a/edg/jlcparts/JlcPartsBjt.py b/edg/jlcparts/JlcPartsBjt.py index 4139e3998..bd342db27 100644 --- a/edg/jlcparts/JlcPartsBjt.py +++ b/edg/jlcparts/JlcPartsBjt.py @@ -22,7 +22,7 @@ def _entry_to_table_row(cls, row_dict: Dict[PartsTableColumn, Any], filename: st attributes.get("Collector-emitter breakdown voltage (vceo)", str), 'V')) row_dict[cls.ICE_RATING] = Range.zero_to_upper(PartParserUtil.parse_value( attributes.get("Collector current (ic)", str), 'A')) - row_dict[cls.GAIN] = Range.zero_to_upper(PartParserUtil.parse_value( + row_dict[cls.GAIN] = Range.exact(PartParserUtil.parse_value( attributes.get("Dc current gain (hfe@ic,vce)", str).split('@')[0], '')) row_dict[cls.POWER_RATING] = Range.zero_to_upper( attributes.get("Power dissipation (pd)", float, sub='power')) diff --git a/edg/jlcparts/JlcPartsBoardTop.py b/edg/jlcparts/JlcPartsBoardTop.py index ca53bd323..d93cd2015 100644 --- a/edg/jlcparts/JlcPartsBoardTop.py +++ b/edg/jlcparts/JlcPartsBoardTop.py @@ -24,7 +24,7 @@ def refinements(self) -> Refinements: (Led, JlcPartsLed), (Bjt, JlcPartsBjt), (Fet, JlcPartsFet), - (SwitchFet, JlcSwitchFet), + # (SwitchFet, JlcSwitchFet), # TODO IMPLEMENT ME (PptcFuse, JlcPartsPptcFuse), (FerriteBead, JlcPartsFerriteBead) ] diff --git a/edg/jlcparts/JlcPartsMlcc.py b/edg/jlcparts/JlcPartsMlcc.py index f090338a4..4b7146e38 100644 --- a/edg/jlcparts/JlcPartsMlcc.py +++ b/edg/jlcparts/JlcPartsMlcc.py @@ -1,6 +1,7 @@ from typing import Any, Optional, Dict from ..abstract_parts import * from ..parts import JlcCapacitor +from ..parts.JlcCapacitor import JlcDummyCapacitor from .JlcPartsBase import JlcPartsBase, JlcPartsAttributes @@ -31,3 +32,24 @@ def _entry_to_table_row(cls, row_dict: Dict[PartsTableColumn, Any], filename: st return row_dict except (KeyError, TypeError, PartParserUtil.ParseError): return None + + @classmethod + def _row_sort_by(cls, row: PartsTableRow) -> Any: + return [row[cls.PARALLEL_COUNT], super(JlcPartsMlcc, cls)._row_sort_by(row)] + + def _make_parallel_footprints(self, row: PartsTableRow) -> None: + cap_model = JlcDummyCapacitor(set_lcsc_part=row[self.LCSC_COL], + set_basic_part=row[self.BASIC_PART_COL], + footprint=row[self.KICAD_FOOTPRINT], + manufacturer=row[self.MANUFACTURER_COL], part_number=row[self.PART_NUMBER_COL], + value=row[self.DESCRIPTION_COL], + capacitance=row[self.NOMINAL_CAPACITANCE], + voltage=self.voltage) + self.c = ElementDict[JlcDummyCapacitor]() + for i in range(row[self.PARALLEL_COUNT]): + self.c[i] = self.Block(cap_model) + self.connect(self.c[i].pos, self.pos) + self.connect(self.c[i].neg, self.neg) + + self.assign(self.lcsc_part, row[self.LCSC_COL]) + self.assign(self.actual_basic_part, row[self.BASIC_PART_COL])