예제 #1
0
파일: series.py 프로젝트: chintal/tendril
 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)
예제 #2
0
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
예제 #3
0
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)
예제 #4
0
파일: gsymlib.py 프로젝트: chintal/tendril
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
예제 #5
0
파일: gsymlib.py 프로젝트: SayCV/tendril
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
예제 #7
0
파일: LM3150.py 프로젝트: chintal/tendril
 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
예제 #8
0
파일: DLPF1.py 프로젝트: chintal/tendril
 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