def get_type_value(self, value): if self._stype == 'capacitor': capacitance, voltage = electronics.parse_capacitor(value) return self._typeclass(capacitance) if self._stype == 'resistor': resistance, wattage = electronics.parse_resistor(value) return self._typeclass(resistance)
def _cap_cer_smd_sanitycheck(name, device, value, footprint): v = parse_capacitor(value, context={ 'device': device, 'footprint': footprint }) if not name.startswith(v.capacitance.fmt_repr('%v %u')): return False return True
def _cap_cer_smd_searchterm(device, value, footprint): v = parse_capacitor(value, context={ 'device': device, 'footprint': footprint }) parts = [v.capacitance.fmt_repr('%v %u'), v.voltage, footprint, 'SMD'] parts = [str(x) for x in parts if x] return ' '.join(parts)
def find_capacitor(capacitance, footprint, device="CAP CER SMD", voltage=None): if isinstance(capacitance, str): try: capacitance = Capacitance(capacitance) except ValueError: raise NoGedaSymbolException(capacitance) if isinstance(capacitance, Capacitance): capacitance = capacitance._value if footprint[0:3] == "MY-": footprint = footprint[3:] for symbol in gsymlib: if symbol.device == device and symbol.footprint == footprint: cap, volt = parse_capacitor(symbol.value) sym_capacitance = parse_capacitance(cap) if capacitance == sym_capacitance: return symbol raise NoGedaSymbolException
def find_capacitor(device, footprint, capacitance, voltage=None, tolerance=None, tcc=None): if footprint[0:3] == "MY-": footprint = footprint[3:] if isinstance(capacitance, str): try: capacitance = Capacitance(capacitance) except ParseException: tident = ident_transform(device, capacitance, footprint) symbol = get_symbol(tident) return symbol tcapacitor = jb_capacitor(capacitance, voltage=voltage, tolerance=tolerance, tcc=tcc, context={ 'device': device, 'footprint': footprint }) candidates = [] for symbol in gsymlib: # TODO Don't search _everything_ here # TODO Handle special resistors? if symbol.device == device and symbol.footprint == footprint: try: scapacitor = parse_capacitor(symbol.value) except ParseException: continue symscore = match_capacitor(tcapacitor, scapacitor) if symscore: candidates.append((symbol, symscore)) if not len(candidates): raise NoGedaSymbolException(capacitance) candidates = sorted(candidates, key=lambda c: c[1], reverse=True) maxscore = candidates[0][1] candidates = [x for x in candidates if x[1] == maxscore] return bestmatch_capacitor(tcapacitor, candidates)
def get_type_value(self, value): if self._stype == 'capacitor': return parse_capacitor(value).capacitance if self._stype == 'resistor': return parse_resistor(value).resistance
def CFF(self): elem = self.get_elem_by_idx('CFF') assert elem.data['device'] in ['CAP CER SMD', 'CAP CER THRU'] return Capacitance(electronics.parse_capacitance(electronics.parse_capacitor(elem.data['value'])[0])) # noqa
def C3(self): # TODO switch to series.get_type_value if custom series to be supported elem = self.get_elem_by_idx('C3') assert elem.data['device'] in ['CAP CER SMD', 'CAP CER THRU'] return electronics.parse_capacitance(electronics.parse_capacitor(elem.data['value'])[0]) # noqa