def resistor_from_partkeepr_json(resistor_json): parameters = resistor_json["parameters"] if len(resistor_json["manufacturers"]) > 0: part_number = resistor_json["manufacturers"][0]['partNumber'] manufacturer_name = resistor_json["manufacturers"][0]['name'] else: part_number = resistor_json['name'] manufacturer_name = None if 'Part Type' in parameters: resistor_type = Resistor.Type(parameters["Part Type"]['value']) else: resistor_type = None # Resistor.Type.ThinFilmResistor # Resistor.Type(parameters["Resistor Type"]['value']) working_temperature = working_temperature_range_from_partkeepr_json(parameters) resistance = parameters["Resistance"]["value"] tolerance = tolerance_from_partkeepr_json(parameters['Tolerance']) if 'Tolerance' in parameters else None return Resistor(resistor_type=resistor_type, manufacturer=manufacturer_name, partnumber=part_number, working_temperature_range=working_temperature, series=None, resistance=resistance, tolerance=tolerance, power=parameters["Power"]['valueMax'] if 'Power' in parameters else None, max_working_voltage=parameters["Voltage"]['valueMax'] + "V" if 'Voltage' in parameters else None, case=resistor_json['footprint'], note="")
def to_resistor(part): return Resistor(resistor_type=None, manufacturer=part.get_manufacturer_name(), partnumber=part.get_manufacturer_part_number(), working_temperature_range=temperature_range_to_unit(part), series=None, resistance=resistance_paremeter_to_unit(part), power=power_parameter_to_unit(part), max_working_voltage=working_voltage_parameter_to_unit(part), tolerance=None, case=part.get_footprint(), note=part.get_comment())
def decode_match(match): return Resistor(resistor_type=resistor_type[match.group(1)], manufacturer="Yageo", partnumber=match.group(1) + match.group(2) + match.group(3) + match.group(4) + match.group( 5) + match.group(6) + match.group(7) + match.group(8), working_temperature_range=TemperatureRange(Decimal('-55'), Decimal('155')), series=match.group(1), resistance=resistance_string_to_ohm(match.group(7)), power=power[match.group(2)], max_working_voltage=max_working_voltage[match.group(2)], tolerance=tolerance[match.group(3)], case=size[match.group(2)], note=series[match.group(1)])
def decode_match(match): return Resistor(resistor_type=resistor_type[match.group(1)], manufacturer="Bourns", partnumber=match.group(1) + match.group(2) + match.group(3) + match.group(4) + match.group( 5) + match.group(6), working_temperature_range=working_temperature_range[match.group(1)], series=match.group(1), resistance=resistance_string_to_ohm(match.group(3)), power=Decimal('0.125') if match.group(4) + match.group(5) == "J2" else Decimal('0.25'), max_working_voltage='25V' if match.group(1) + match.group(4) + match.group( 5) == "CAY16J8" else '50V', tolerance=tolerance[match.group(4)], case=size[match.group(1)][match.group(4) + match.group(5)], note=series[match.group(1)])
def decode_match_CHV(match): note = series[match.group(1)] + ", TCR=" + tcr[match.group(5)] + ", " + termination[match.group(9)] +\ ", Packing: " + packing[match.group(8)] return Resistor(resistor_type=resistor_type[match.group(1)], manufacturer="Bourns", partnumber=match.group(1) + match.group(2) + match.group(3) + match.group(4) + match.group( 5) + match.group(6) + match.group(7) + match.group(8) + match.group(9), working_temperature_range=working_temperature_range[match.group(1)], series=match.group(1), resistance=resistance_string_to_ohm(match.group(7)), power=power[match.group(2)], max_working_voltage=maximum_working_voltage[match.group(2)], tolerance=tolerance[match.group(4)], case=match.group(2), note=note)
def decode_match_PAT_PNM(match): series_name = match.group(1) return Resistor( resistor_type=resistor_type[match.group(1)], manufacturer="Vishay", partnumber=match.group(1) + match.group(2) + match.group(3) + match.group(4) + match.group(5) + match.group(6) + match.group(7), working_temperature_range=TemperatureRange(Decimal('-55'), Decimal('155')), series=series_name, resistance=resistance_string_to_ohm(match.group(4)), power=power[series_name][match.group(2)], max_working_voltage=max_working_voltage[series_name][match.group(2)], tolerance=tolerance[match.group(5)], case=size[match.group(2)], note=series[series_name])
def decode_match(match): series_name = match.group(1) size_name = size[match.group(2)] partnumber = match.group(1) + match.group(2) + match.group( 3) + match.group(4) resistance = resistance_string_to_ohm(match.group(4)) note = series[series_name] + ", TCR=" + temperature_coefficient[ series_name](resistance) return Resistor( resistor_type=resistor_type[series_name], manufacturer="TE Connectivity", partnumber=partnumber, working_temperature_range=working_temperature_range[series_name], series=series_name, resistance=resistance, power=power_rating[size_name], max_working_voltage=max_working_voltage[size_name], tolerance=tolerance[match.group(3)], case=size_name, note=note)
def decode_match(match): series_name = match.group(1) partnumber = match.group(1) + match.group(2) + match.group( 3) + match.group(4) + match.group(5) + match.group(6) partnumber += match.group(7) if match.group(7) is not None else '' is_e3 = 'e3' if series_name == "TNPW" and match.group( 6) in packing_type_TNPWe3 else '' return Resistor( resistor_type=resistor_type[match.group(1)], manufacturer="Vishay", partnumber=partnumber, series=series_name, working_temperature_range=TemperatureRange(Decimal('-55'), Decimal('155')), resistance=resistance_string_to_ohm(match.group(3)), power=power[series_name + is_e3][match.group(2)], max_working_voltage=max_working_voltage[series_name + is_e3][match.group(2)], tolerance=tolerance[match.group(4)], case=size[match.group(2)], note=series[series_name])
def decode_match(match): series_name = match.group(1) size_name = size[match.group(2)] partnumber = match.group(1) + match.group(2) + match.group( 3) + match.group(4) + match.group(5) + match.group(6) + match.group( 7) + match.group(8) resistance = resistance_string_to_ohm(match.group(8)) note = series[series_name] + ", TCR=" + temperature_coefficient_RL[ size_name](resistance) return Resistor( resistor_type=resistor_type[series_name], manufacturer="Thunder", partnumber=partnumber, working_temperature_range=working_temperature_range[series_name], series=series_name, resistance=resistance, power=power_rating_high_power[size_name] if match.group(6) == "7W" else power_rating_standard, max_working_voltage=max_working_voltage[size_name], tolerance=tolerance[match.group(3)], case=size_name, note=note)
def decode_match(match): size_name = size[match.group(1)] partnumber = match.group(1) + match.group(2) + match.group( 3) + match.group(4) + match.group(5) partnumber += match.group(6) if match.group(6) is not None else "" partnumber += match.group(7) if match.group(7) is not None else "" array = ['2D02', '4D02', '4D03', '10P8', '16P8'] return Resistor( resistor_type=Resistor.Type.ThickFilmResistorArray if match.group(1) in array else Resistor.Type.ThickFilmResistor, manufacturer="Royal Ohm", partnumber=partnumber, working_temperature_range=TemperatureRange(Decimal('-55'), Decimal('155')), series='', resistance=resistance_string_to_ohm(match.group(4)), power=power[match.group(2)], max_working_voltage=max_working_voltage[size_name], tolerance=tolerance[match.group(3)], case=size_name, note=special_feature[match.group(7)] if match.group(7) is not None else "")