  
                self._perform_integration(now, current_power * FUDGE_FACTOR)
  
                # Enable charging again
                set_battery_charging(True)
              except Exception:
                cloudlog.exception("Pulsed power measurement failed")
  
            # Start pulsed measurement and return
            threading.Thread(target=perform_pulse_measurement, args=(now,)).start()
 
</s> remove                 voltages.append(get_battery_voltage())
                currents.append(get_battery_current())
 </s> add                 voltages.append(HARDWARE.get_battery_voltage())
                currents.append(HARDWARE.get_battery_current()) </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           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               set_battery_charging(False)
 </s> add               HARDWARE.set_battery_charging(False) </s> remove     should_shutdown |= ((get_battery_capacity() < BATT_PERC_OFF) and (not get_battery_charging()) and ((now - offroad_timestamp) > 60))
 </s> add     should_shutdown |= ((HARDWARE.get_battery_capacity() < BATT_PERC_OFF) and (not HARDWARE.get_battery_charging()) and ((now - offroad_timestamp) > 60))
              HARDWARE.set_battery_charging(True)
  
                self._perform_integration(now, current_power * FUDGE_FACTOR)
  
                # Enable charging again
              HARDWARE.set_battery_charging(True)
              except Exception:
                cloudlog.exception("Pulsed power measurement failed")
  
            # Start pulsed measurement and return
            threading.Thread(target=perform_pulse_measurement, args=(now,)).start()
keep keep keep keep 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