  
      should_shutdown = False
      # Wait until we have shut down charging before powering down
      should_shutdown |= (not panda_charging and self.should_disable_charging(health, offroad_timestamp))
      should_shutdown |= ((get_battery_capacity() < BATT_PERC_OFF) and (not get_battery_charging()) and ((now - offroad_timestamp) > 60))
      should_shutdown &= started_seen
      return should_shutdown
 
</s> remove               set_battery_charging(True)
 </s> add               HARDWARE.set_battery_charging(True) </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     msg.thermal.batteryPercent = get_battery_capacity()
    msg.thermal.batteryStatus = get_battery_status()
    msg.thermal.batteryCurrent = get_battery_current()
    msg.thermal.batteryVoltage = get_battery_voltage()
    msg.thermal.usbOnline = get_usb_present()
 </s> add     msg.thermal.batteryPercent = HARDWARE.get_battery_capacity()
    msg.thermal.batteryStatus = HARDWARE.get_battery_status()
    msg.thermal.batteryCurrent = HARDWARE.get_battery_current()
    msg.thermal.batteryVoltage = HARDWARE.get_battery_voltage()
    msg.thermal.usbOnline = HARDWARE.get_usb_present() </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':
    should_shutdown |= ((HARDWARE.get_battery_capacity() < BATT_PERC_OFF) and (not HARDWARE.get_battery_charging()) and ((now - offroad_timestamp) > 60))
  
      should_shutdown = False
      # Wait until we have shut down charging before powering down
      should_shutdown |= (not panda_charging and self.should_disable_charging(health, offroad_timestamp))
    should_shutdown |= ((HARDWARE.get_battery_capacity() < BATT_PERC_OFF) and (not HARDWARE.get_battery_charging()) and ((now - offroad_timestamp) > 60))
      should_shutdown &= started_seen
      return should_shutdown
keep keep keep keep replace 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