Class BattFuelGauge

java.lang.Object
com.playingwithfusion.BattFuelGauge
All Implemented Interfaces:
Sendable, AutoCloseable

public class BattFuelGauge extends Object implements Sendable, AutoCloseable
CAN based Battery Fuel Gauge (BFG) sensor instance
  • Constructor Details

    • BattFuelGauge

      public BattFuelGauge(int sensorId)
      Create an instance of the CAN Battery Fuel Gauge sensor. This is designed to support the Playing With Fusion (PWF) ROB-70001 battery fuel gauge sensor
      Parameters:
      sensorId - The 6-bit identifier used to select a particular sensor on the CAN bus. This identifier may be set through the PWF Device configuration page on the roboRIO.
  • Method Details

    • close

      public void close()
      Destroy the BattFuelGauge object and free any asscioated resources
      Specified by:
      close in interface AutoCloseable
    • initSendable

      public void initSendable(SendableBuilder builder)
      Specified by:
      initSendable in interface Sendable
    • identifySensor

      public void identifySensor()
      Dispay 'Identification' page on the BFG OLED display to indicate the sensor asscioated with this instance of software
    • getFirmwareVersion

      public long getFirmwareVersion()
      Determine the sensor firmware version
      Returns:
      The sensor firmware version
    • getSerialNumber

      public long getSerialNumber()
      Determine the sensor hardware serial number
      Returns:
      The sensor hardware serial number
    • getBatteryState

      public BattFuelGauge.BatteryChargeState getBatteryState()
      Determine the charge/discharge state of the battery
      Returns:
      The charge/discharge state enumeration of the battery
    • getCurrent

      public float getCurrent()
      Gets the current battery discharge current.
      Returns:
      battery discharge current in Amps (A)
    • getVoltage

      public float getVoltage()
      Gets the current battery terminal voltage.
      Returns:
      battery voltage in Volts (V)
    • getDodAh

      public float getDodAh()
      Gets the current depth of discharge in ampere-hours.
      Returns:
      depth of discharge in Ah
    • getDodWh

      public float getDodWh()
      Gets the current depth of discharge energy.
      Returns:
      depth of discharge energy in Watt-hours (Wh)
    • getRemainingChargePct

      public float getRemainingChargePct()
      Gets the estimated remaining charge as a percentage.
      Returns:
      remaining charge in percent (typically 0–100)
    • getEffectiveCapacityAh

      public float getEffectiveCapacityAh()
      Gets the effective (usable) capacity of the battery.
      Returns:
      effective capacity in Ah
    • getBatteryAgeDays

      public float getBatteryAgeDays()
      Gets the age of the battery.
      Returns:
      battery age in days
    • getCapacityAh

      public float getCapacityAh()
      Gets the current estimated battery capacity.
      Returns:
      battery capacity in Ah
    • getRatedCapacityAh

      public float getRatedCapacityAh()
      Gets the original rated capacity of the battery when new.
      Returns:
      rated capacity in Ah
    • getNumCycles

      public int getNumCycles()
      Gets the total number of charge/discharge cycles experienced by the battery.
      Returns:
      number of charge/discharge cycles
    • getNickname

      public String getNickname()
      Gets the user-defined nickname of this battery.
      Returns:
      battery nickname, or empty string if not set or unavailable
    • getManufacturer

      public BattFuelGauge.BatteryManufacturer getManufacturer()
      Gets the manufacturer identifier of the battery.
      Returns:
      Battery manufacturer reported by the BFG
    • setNickname

      public void setNickname(String newName)
      Sets the user-defined nickname of this battery.
      Parameters:
      newName - New battery nickname
    • setManufacturer

      public void setManufacturer(BattFuelGauge.BatteryManufacturer newMfg)
      Sets the battery manufacturer
      Parameters:
      newMfg - New battery manufacturer
    • getCycleRmsDischargeCurrent

      public float getCycleRmsDischargeCurrent()
      Returns the RMS discharge current from the most recent full charge cycle.
      Returns:
      RMS discharge current in amperes (A)
    • getCycleMaxCurrent

      public float getCycleMaxCurrent()
      Returns the highest charging current seen in the last charge cycle.
      Returns:
      maximum charging current in amperes (A)
    • getCycleMinCurrent

      public float getCycleMinCurrent()
      Returns the most negative (highest discharge) current from the last charge cycle.
      Returns:
      minimum current in amperes (A)
    • getCycleMinVoltage

      public float getCycleMinVoltage()
      Returns the lowest voltage recorded during the last charge cycle.
      Returns:
      minimum voltage in volts (V)
    • getCycleMaxVoltage

      public float getCycleMaxVoltage()
      Returns the highest voltage recorded during the last charge cycle.
      Returns:
      maximum voltage in volts (V)
    • getCycleMinDodAh

      public float getCycleMinDodAh()
      Returns the lowest depth of discharge reached in the last charge cycle.
      Returns:
      minimum depth of discharge in ampere-hours (Ah)
    • getCycleMaxDodAh

      public float getCycleMaxDodAh()
      Returns the highest depth of discharge reached in the last charge cycle.
      Returns:
      maximum depth of discharge in ampere-hours (Ah)
    • getCycleMinDodWh

      public float getCycleMinDodWh()
      Returns the lowest energy discharged in the last charge cycle.
      Returns:
      minimum discharged energy in watt-hours (Wh)
    • getCycleMaxDodWh

      public float getCycleMaxDodWh()
      Returns the highest energy discharged in the last charge cycle.
      Returns:
      maximum discharged energy in watt-hours (Wh)
    • getCycleChargeTime

      public float getCycleChargeTime()
      Returns how long the battery was charging during the last full cycle.
      Returns:
      charging time in seconds
    • getCycleDischargeTime

      public float getCycleDischargeTime()
      Returns how long the battery was discharging during the last full cycle.
      Returns:
      discharging time in seconds
    • getCycleStartingVoltage

      public float getCycleStartingVoltage()
      Returns the voltage at the start of the most recent charge cycle.
      Returns:
      starting voltage in volts (V)
    • getMatchRmsDischargeCurrent

      public float getMatchRmsDischargeCurrent()
      Returns the RMS discharge current observed during the last robot match.
      Returns:
      RMS discharge current in amperes (A)
    • getMatchMaxCurrent

      public float getMatchMaxCurrent()
      Returns the peak current (highest magnitude) during the last match.
      Returns:
      maximum current in amperes (A)
    • getMatchMinCurrent

      public float getMatchMinCurrent()
      Returns the most negative (highest discharge) current from the last match.
      Returns:
      minimum current in amperes (A)
    • getMatchMinVoltage

      public float getMatchMinVoltage()
      Returns the lowest voltage seen during the last robot match.
      Returns:
      minimum voltage in volts (V)
    • getMatchMaxVoltage

      public float getMatchMaxVoltage()
      Returns the highest voltage seen during the last robot match.
      Returns:
      maximum voltage in volts (V)
    • getMatchMinDodAh

      public float getMatchMinDodAh()
      Returns the lowest depth of discharge reached during the last match.
      Returns:
      minimum depth of discharge in ampere-hours (Ah)
    • getMatchMaxDodAh

      public float getMatchMaxDodAh()
      Returns the highest depth of discharge reached during the last match.
      Returns:
      maximum depth of discharge in ampere-hours (Ah)
    • getMatchChargeTime

      public float getMatchChargeTime()
      Returns total charging time (if any) during the last robot match.
      Returns:
      charging time in seconds
    • getMatchDischargeTime

      public float getMatchDischargeTime()
      Returns total discharging time during the last robot match.
      Returns:
      discharging time in seconds
    • getMatchStartingVoltage

      public float getMatchStartingVoltage()
      Returns the battery voltage at the beginning of the last robot match.
      Returns:
      starting voltage in volts (V)
    • getMatchStartingEnergy

      public float getMatchStartingEnergy()
      Returns the stored energy at the start of the last robot match.
      Returns:
      starting energy in watt-hours (Wh)
    • getMatchEndingEnergy

      public float getMatchEndingEnergy()
      Returns the remaining energy at the end of the last robot match.
      Returns:
      ending energy in watt-hours (Wh)
    • getMatchStartingCharge

      public float getMatchStartingCharge()
      Returns the stored charge at the beginning of the last robot match.
      Returns:
      starting charge in ampere-hours (Ah)
    • getMatchEndingCharge

      public float getMatchEndingCharge()
      Returns the remaining charge at the end of the last robot match.
      Returns:
      ending charge in ampere-hours (Ah)
    • getMatchDuration

      public float getMatchDuration()
      Returns the total duration of the last robot match.
      Returns:
      match duration in seconds