                # Measure for a few sec to get a good average
                voltages = []
                currents = []
                for _ in range(6):
                  voltages.append(get_battery_voltage())
                  currents.append(get_battery_current())
                  time.sleep(1)
                current_power = ((mean(voltages) / 1000000) * (mean(currents) / 1000000))
  
                self._perform_integration(now, current_power * FUDGE_FACTOR)
  
 
</s> remove               set_battery_charging(False)
 </s> add               HARDWARE.set_battery_charging(False) </s> remove           current_power = ((get_battery_voltage() / 1000000) * (get_battery_current() / 1000000))
 </s> add           current_power = ((HARDWARE.get_battery_voltage() / 1000000) * (HARDWARE.get_battery_current() / 1000000)) </s> remove         current_power = 0
        if TICI:
          with open("/sys/class/hwmon/hwmon1/power1_input") as f:
            current_power = int(f.read()) / 1e6
        elif get_battery_status() == 'Discharging':
 </s> add         current_power = HARDWARE.get_current_power_draw()
        if current_power is not None:
          pass
        elif HARDWARE.get_battery_status() == 'Discharging': </s> remove               set_battery_charging(True)
 </s> add               HARDWARE.set_battery_charging(True) </s> remove     with pm_patch("get_battery_voltage", BATT_VOLTAGE * 1e6), pm_patch("get_battery_current", BATT_CURRENT * 1e6), \
    pm_patch("get_battery_status", "Discharging"):
 </s> add     with pm_patch("HARDWARE.get_battery_voltage", BATT_VOLTAGE * 1e6), pm_patch("HARDWARE.get_battery_current", BATT_CURRENT * 1e6), \
    pm_patch("HARDWARE.get_battery_status", "Discharging"), pm_patch("HARDWARE.get_current_power_draw", None):
                voltages.append(HARDWARE.get_battery_voltage())
                currents.append(HARDWARE.get_battery_current())
                # Measure for a few sec to get a good average
                voltages = []
                currents = []
                for _ in range(6):
                voltages.append(HARDWARE.get_battery_voltage())
                currents.append(HARDWARE.get_battery_current())
                voltages.append(HARDWARE.get_battery_voltage())
                currents.append(HARDWARE.get_battery_current())
                  time.sleep(1)
                current_power = ((mean(voltages) / 1000000) * (mean(currents) / 1000000))
  
                self._perform_integration(now, current_power * FUDGE_FACTOR)
  
keep keep keep keep replace replace keep keep keep keep keep
 Move thermald hardware calls into HW abstraction layer (#2630)

* abstracted away hardware calls

* oopsie

* remove bugs

* remove bugs #2

* fix unit test

* removed print

Co-authored-by: Comma Device <device@comma.ai> 
selfdrive/thermald/power_monitoring.py