def test_ebay_30_psi(voltage, psi): """ 30 psi fluid pressure transducer sensor 0 psi = 0.5v 30 psi = 4.5v """ assert Formula.custom(voltage, 0.5, 4.5, 0, 30) == psi
def test_autometer_2246(voltage, psi): """ https://www.autometer.com/sensor_specs 100 psi fluid pressure transducer sensor, could be also known as ebay 100 psi 0 psi = 0.5v 100 psi = 4.5v """ assert Formula.custom(voltage, 0.5, 4.5, 0, 100) == psi
def flt(self): """Fuel temperature TODO: RETURN {"celsius": 0, "fahrenheit": 0} if fails """ indexes = {constants.KPRO4_ID: constants.KPRO4_FLT} flt_celsius = get_value_from_ecu(self.version, indexes, self.data3) flt_fahrenheit = Formula.celsius_to_fahrenheit(flt_celsius) return {"celsius": flt_celsius, "fahrenheit": flt_fahrenheit}
def test_mx5_na_fuel_tank(voltage, level): """ Specs of this tank (https://www.manualslib.com/download/814242/Mazda-Mx-5.html Empty: 110 ohms Full: 3 ohms Resistance used for voltage divider: 56 ohms Vin: 5v """ assert int(Formula.custom(voltage, 3.313, 0.254, 0, 100)) == level
def vss(self): """Vehicle speed sensor""" indexes = { constants.KPRO23_ID: constants.KPRO23_VSS, constants.KPRO4_ID: constants.KPRO4_VSS, } vss_kmh = get_value_from_ecu(self.version, indexes, self.data0) vss_mph = Formula.kmh_to_mph(vss_kmh) return {"kmh": vss_kmh, "mph": int(vss_mph)}
def test_civic_ek_fuel_tank(voltage, level): """ Specs of this tank Empty: 108 ohms Full: 3.5 ohms Resistance used for voltage divider: 56 ohms Vin: 5v """ assert int(Formula.custom(voltage, 3.292, 0.294, 0, 100)) == level
def test_s2000_fuel_tank(voltage, level): """ Specs of this tank Empty: 11 ohms Full: 132 ohms Resistance used for voltage divider: 56 ohms Vin: 5v """ assert int(Formula.custom(voltage, 3.51, 0.82, 0, 100)) == level
def test_mr2_w20_fuel_tank(voltage, level): """ Specs of this tank (http://mr2.ie/mr2/bgb/mk2/mechanical/6_015.html) Empty: 110 ohms Full: 3 ohms Resistance used for voltage divider: 56 ohms Vin: 5v """ assert int(Formula.custom(voltage, 3.313, 0.254, 0, 100)) == level
def test_civic_eg_fuel_tank(voltage, level): """ Specs of this tank Empty: 110 ohms Full: 2 ohms Resistance used for voltage divider: 56 ohms Vin: 5v """ assert int(Formula.custom(voltage, 3.313, 0.172, 0, 100)) == level
def test_accord_cl9_fuel_tank(voltage, level): """ Specs of this tank from TSX workshop manual (http://www.hondahookup.com/forums/downloads.php?do=file&id=158) Empty: 790 ohms Full: 19 ohms Resistance used for voltage divider: 56 ohms Vin: 5v """ assert int(Formula.custom(voltage, 4.669, 1.266, 0, 100)) == level
def test_integra_dc5_fuel_tank(voltage, level): """ Specs of this tank from RSX workshop manual (http://www.mediafire.com/file/dwm2qkmzy2n/%2528LINKED_Edition%252902-06_Acura_RSX_Shop_Manual.pdf/file) Empty: 132 ohms Full: 11 ohms Resistance used for voltage divider: 56 ohms Vin: 5v """ assert int(Formula.custom(voltage, 3.510, 0.82, 0, 100)) == level
def test_mr2_w30_fuel_tank(voltage, level): """ Specs of this tank (http://www.testroete.com/car/Toyota/mr2%20spyder/Repair%20Information/Repair%20Manual/ 20%20-%20Body%20Electrical/21%20-%20Combination%20Meter%20-%20Inspection.pdf) Empty: 192 ohms Full: 16 ohms Resistance used for voltage divider: 56 ohms Vin: 5v """ assert int(Formula.custom(voltage, 3.87, 1.111, 0, 100)) == level
def ect(self): """Engine coolant temperature""" indexes = { constants.S3003_ID: constants.S3003_ECT, } data_from_kpro = get_value_from_ecu( self.version, indexes, self.data6, {"celsius": 0, "fahrenheit": 0} ) if isinstance(data_from_kpro, int): return Formula.kpro_temp(data_from_kpro) else: return data_from_kpro
def iat(self): """Intake air temperature""" indexes = { constants.S3003_ID: constants.S3003_IAT, } data_from_s300 = get_value_from_ecu( self.version, indexes, self.data6, {"celsius": 0, "fahrenheit": 0} ) if isinstance(data_from_s300, int): return Formula.kpro_temp(data_from_s300) else: return data_from_s300
def map(self): """Manifold absolute pressure""" indexes_1 = { constants.S3003_ID: constants.S3003_MAP1, } indexes_2 = { constants.S3003_ID: constants.S3003_MAP2, } data_from_s300 = ( 256 * get_value_from_ecu(self.version, indexes_2, self.data6) ) + get_value_from_ecu(self.version, indexes_1, self.data6) map_bar = data_from_s300 / 100.0 map_mbar = map_bar * 1000 map_psi = Formula.bar_to_psi(map_bar) return {"bar": map_bar, "mbar": map_mbar, "psi": map_psi}
def map(self): """Manifold absolute pressure""" indexes = { constants.KPRO23_ID: constants.KPRO23_MAP, constants.KPRO4_ID: constants.KPRO4_MAP, } data_from_kpro = get_value_from_ecu(self.version, indexes, self.data0, { "bar": 0, "mbar": 0, "psi": 0 }) if isinstance(data_from_kpro, int): map_bar = data_from_kpro / 100.0 map_mbar = map_bar * 1000 map_psi = Formula.bar_to_psi(map_bar) return {"bar": map_bar, "mbar": map_mbar, "psi": map_psi} return data_from_kpro
def vss(self): """Vehicle speed sensor""" indexes_1 = { constants.S3003_ID: constants.S3003_VSS1, } indexes_2 = { constants.S3003_ID: constants.S3003_VSS2, } try: vss_kmh = int( 227125 / ( 256 * get_value_from_ecu(self.version, indexes_2, self.data6) + get_value_from_ecu(self.version, indexes_1, self.data6) ) ) except ZeroDivisionError: vss_kmh = 0 vss_mph = Formula.kmh_to_mph(vss_kmh) return {"kmh": vss_kmh, "mph": int(vss_mph)}
def test_mr2_w20_fuel_tank(voltage, level): assert Formula.mr2_w20_fuel_tank(voltage) == level
-14, -18, -20, -22, -23, -25, -27, -31, -32, -34, -38, -40, -40, -40, -40, ] x = list(range(0, 200)) fahrenheit = [Formula.kpro_temp(z) for z in x] y = [] for result in fahrenheit: y.append(result["celsius"]) real_y = [(temperature[z] - 32) * 5 / 9 for z in x] plt.plot(x, y, x, real_y) plt.xlabel("kpro") plt.ylabel("temp") plt.show()
def test_aem_30_2012(voltage, celsius, fahrenheit): assert Formula.aem_30_2012(voltage) == { "celsius": celsius, "fahrenheit": fahrenheit, }
def test_autometer_2246(voltage, bar, psi): assert Formula.autometer_2246(voltage) == {"bar": bar, "psi": psi}
def test_custom(min_voltage, max_voltage, min_value, max_value, test_value, expected_value): assert (Formula.custom(test_value, min_voltage, max_voltage, min_value, max_value) == expected_value)
def test_vdo_323_057(voltage, celsius, fahrenheit): assert Formula.vdo_323_057(voltage) == { "celsius": celsius, "fahrenheit": fahrenheit, }
def test_bosch_0280130039_0280130026(voltage, celsius, fahrenheit): assert Formula.bosch_0280130039_0280130026(voltage) == { "celsius": celsius, "fahrenheit": fahrenheit, }
def test_kpro_temp(kpro_value, celsius, fahrenheit): assert Formula.kpro_temp(kpro_value) == { "celsius": celsius, "fahrenheit": fahrenheit, }
def test_ebay_150_psi(voltage, bar, psi): assert Formula.ebay_150_psi(voltage) == {"bar": bar, "psi": psi}
def test_voltage(voltage, result): assert Formula.voltage(voltage) == result
def test_civic_eg_fuel_tank(voltage, level): assert Formula.civic_eg_fuel_tank(voltage) == level
def test_adc_to_volts(adc, voltage): assert Formula.adc_to_volts(adc) == voltage
def test_psi_to_bar(psi, bar): assert Formula.psi_to_bar(psi) == bar