33from typing import Optional , cast , Dict , Any , Tuple , Mapping
44import math
55
6+ from typing_extensions import override
7+
68from ..electronics_model import *
79from .ESeriesUtil import ESeriesUtil
810from .PartsTable import PartsTableColumn , PartsTableRow , PartsTable
@@ -35,6 +37,7 @@ def __init__(self, capacitance: RangeLike, voltage: RangeLike, *,
3537 self .actual_capacitance = self .Parameter (RangeExpr ())
3638 self .actual_voltage_rating = self .Parameter (RangeExpr ())
3739
40+ @override
3841 def contents (self ) -> None :
3942 super ().contents ()
4043
@@ -55,6 +58,7 @@ class Capacitor(UnpolarizedCapacitor, KiCadInstantiableBlock, HasStandardFootpri
5558 "\s*" + f"([\d.{ PartParserUtil .SI_PREFIXES } ]+\s*V)" + "$" )
5659 CAPACITOR_DEFAULT_TOL = 0.20 # TODO this should be unified elsewhere
5760
61+ @override
5862 def symbol_pinning (self , symbol_name : str ) -> Dict [str , BasePort ]:
5963 assert symbol_name in ('Device:C' , 'Device:C_Small' , 'Device:C_Polarized' , 'Device:C_Polarized_Small' )
6064 return {'1' : self .pos , '2' : self .neg }
@@ -75,6 +79,7 @@ def parse_capacitor(cls, value: str) -> Tuple[Range, Range]:
7579 return (capacitance , Range .zero_to_upper (voltage ))
7680
7781 @classmethod
82+ @override
7883 def block_from_symbol (cls , symbol_name : str , properties : Mapping [str , str ]) -> 'Capacitor' :
7984 return Capacitor (* cls .parse_capacitor (properties ['Value' ]))
8085
@@ -180,11 +185,13 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
180185 super ().__init__ (* args , ** kwargs )
181186 self .generator_param (self .capacitance , self .voltage , self .voltage_rating_derating , self .exact_capacitance )
182187
188+ @override
183189 def _row_generate (self , row : PartsTableRow ) -> None :
184190 super ()._row_generate (row )
185191 self .assign (self .actual_voltage_rating , row [self .VOLTAGE_RATING ])
186192 self .assign (self .actual_capacitance , row [self .CAPACITANCE ])
187193
194+ @override
188195 def _row_filter (self , row : PartsTableRow ) -> bool :
189196 derated_voltage = self .get (self .voltage ) / self .get (self .voltage_rating_derating )
190197 return super ()._row_filter (row ) and \
@@ -195,6 +202,7 @@ def _row_filter_capacitance(self, row: PartsTableRow) -> bool:
195202 return row [self .CAPACITANCE ].fuzzy_in (self .get (self .capacitance ))
196203
197204 @classmethod
205+ @override
198206 def _row_sort_by (cls , row : PartsTableRow ) -> Any :
199207 return (ESeriesUtil .series_of (row [cls .NOMINAL_CAPACITANCE ], default = ESeriesUtil .SERIES_MAX + 1 ),
200208 super ()._row_sort_by (row ))
@@ -224,10 +232,12 @@ def __init__(self, *args: Any, single_nominal_capacitance: RangeLike = (0, 22)*u
224232
225233 self .actual_derated_capacitance = self .Parameter (RangeExpr ())
226234
235+ @override
227236 def _row_filter_capacitance (self , row : PartsTableRow ) -> bool :
228237 # post-derating capacitance filtering is in _table_postprocess
229238 return Range .exact (row [self .NOMINAL_CAPACITANCE ]).fuzzy_in (self .get (self .single_nominal_capacitance ))
230239
240+ @override
231241 def _table_postprocess (self , table : PartsTable ) -> PartsTable :
232242 def add_derated_row (row : PartsTableRow ) -> Optional [Dict [PartsTableColumn , Any ]]:
233243 if not self .get (self .exact_capacitance ):
@@ -264,6 +274,7 @@ def add_derated_row(row: PartsTableRow) -> Optional[Dict[PartsTableColumn, Any]]
264274 row [self .PARALLEL_DERATED_CAPACITANCE ].fuzzy_in (self .get (self .capacitance ))
265275 ))
266276
277+ @override
267278 def _row_generate (self , row : PartsTableRow ) -> None :
268279 """This one is weird. Because this is the last in the class order, this is called last.
269280 So the top subclass needs explicit logic to handle parallel capacitors."""
@@ -307,6 +318,7 @@ def __init__(self, footprint: StringLike = "", manufacturer: StringLike = "", pa
307318class DecouplingCapacitor (DiscreteApplication , KiCadImportableBlock ):
308319 """Optionally polarized capacitor used for DC decoupling, with VoltageSink connections with voltage inference.
309320 Implemented as a shim block."""
321+ @override
310322 def symbol_pinning (self , symbol_name : str ) -> Dict [str , BasePort ]:
311323 assert symbol_name in ('Device:C' , 'Device:C_Small' , 'Device:C_Polarized' , 'Device:C_Polarized_Small' )
312324 return {'1' : self .pwr , '2' : self .gnd }
@@ -339,6 +351,7 @@ def connected(self, gnd: Optional[Port[GroundLink]] = None, pwr: Optional[Port[V
339351class AnalogCapacitor (DiscreteApplication , KiCadImportableBlock ):
340352 """Capacitor attached to an analog line, that presents as an open model-wise.
341353 """
354+ @override
342355 def symbol_pinning (self , symbol_name : str ) -> Dict [str , BasePort ]:
343356 assert symbol_name in ('Device:C' , 'Device:C_Small' , 'Device:C_Polarized' , 'Device:C_Polarized_Small' )
344357 return {'1' : self .io , '2' : self .gnd }
@@ -363,6 +376,7 @@ def connected(self, gnd: Optional[Port[GroundLink]] = None, io: Optional[Port[An
363376
364377
365378class CombinedCapacitorElement (Capacitor ): # to avoid an abstract part error
379+ @override
366380 def contents (self ) -> None :
367381 super ().contents ()
368382 self .assign (self .actual_capacitance , self .capacitance ) # fake it, since a combined capacitance is handwavey
@@ -391,6 +405,7 @@ def __init__(self, *, extend_upper: BoolLike = False) -> None:
391405 self .generator_param (self .pos .requested (), self .neg .requested (), self .extend_upper )
392406
393407
408+ @override
394409 def generate (self ) -> None :
395410 super ().generate ()
396411 capacitance = self .capacitances .sum ()
0 commit comments