예제 #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
파일: gsymlib.py 프로젝트: chintal/tendril
def find_resistor(resistance, footprint, device="RES SMD", wattage=None):
    # TODO This should return a symbol instead, and usages should be adapted
    # accordingly to make consistent with find_capacitor
    if isinstance(resistance, str):
        try:
            resistance = Resistance(resistance)
        except ValueError:
            raise NoGedaSymbolException(resistance)
    if isinstance(resistance, Resistance):
        resistance = resistance._value
    if footprint[0:3] == "MY-":
        footprint = footprint[3:]
    if device == "RES THRU":
        resistances = iec60063.gen_vals(iec60063.get_series("E24"), iec60063.res_ostrs)
        if resistance in [parse_resistance(x) for x in resistances]:
            return construct_resistor(normalize_resistance(resistance), "0.25W")  # noqa
        else:
            raise NoGedaSymbolException(resistance, device)
    for symbol in gsymlib:
        if symbol.device == device and symbol.footprint == footprint:
            res, watt = parse_resistor(symbol.value)
            sym_resistance = parse_resistance(res)
            if resistance == sym_resistance:
                return symbol.value
    raise NoGedaSymbolException(resistance)
예제 #3
0
def _res_smd_sanitycheck(name, device, value, footprint):
    v = parse_resistor(value,
                       context={
                           'device': device,
                           'footprint': footprint
                       })
    if not name.startswith(str(v.resistance)):
        return False
    return True
예제 #4
0
def _res_smd_searchterm(device, value, footprint):
    v = parse_resistor(value,
                       context={
                           'device': device,
                           'footprint': footprint
                       })
    parts = ['RES SMD', v.resistance, v.tolerance, footprint]
    parts = [str(x) for x in parts if x]
    return ' '.join(parts)
예제 #5
0
파일: gsymlib.py 프로젝트: SayCV/tendril
def find_resistor(device,
                  footprint,
                  resistance,
                  wattage=None,
                  tolerance=None,
                  tc=None):
    if footprint[0:3] == "MY-":
        footprint = footprint[3:]
    if isinstance(resistance, str):
        try:
            resistance = Resistance(resistance)
        except ParseException:
            tident = ident_transform(device, resistance, footprint)
            symbol = get_symbol(tident)
            return symbol
    tresistor = jb_resistor(resistance,
                            wattage=wattage,
                            tolerance=tolerance,
                            tc=tc)
    candidates = []
    for symbol in gsymlib:
        # TODO Don't search _everything_ here
        # TODO Handle special resistors?
        if symbol.device == device and symbol.footprint == footprint:
            try:
                sresistor = parse_resistor(symbol.value)
            except ParseException:
                continue
            symscore = match_resistor(tresistor, sresistor)
            if symscore:
                candidates.append((symbol, symscore))

    if not len(candidates):
        raise NoGedaSymbolException(resistance)

    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_resistor(tresistor, 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 RLIM(self):
     elem = self.get_elem_by_idx('RLIM')
     assert elem.data['device'] in ['RES SMD', 'RES THRU']
     return Resistance(electronics.parse_resistance(electronics.parse_resistor(elem.data['value'])[0]))  # noqa
예제 #8
0
파일: DLPF1.py 프로젝트: chintal/tendril
 def R2(self):
     # TODO switch to series.get_type_value if custom series to be supported
     elem = self.get_elem_by_idx('R2')
     assert elem.data['device'] in ['RES SMD', 'RES THRU']
     return electronics.parse_resistance(electronics.parse_resistor(elem.data['value'])[0])  # noqa