コード例 #1
0
  /**
   * Calculate the number of hours to discharge the battery till the minimum SoC (20%), based on the
   * current consumption (or maximum discharging rate)
   *
   * @param ts evaluation time
   */
  public final double basedOnCurrentCons(final long ts) {
    double autonomyHrs = 0;
    if (currentConsumption > 0 && currentSoCPercent > bat.getMinSoC()) {
      // limit the discharging rate to the maximum rate
      double power = currentConsumption;
      if (power > bat.getMaxDischargingRate()) {
        power = bat.getDischargingEfficiency();
      }

      double toDischarge =
          getCurrentSoCKWh() - (bat.getMinSoC() * (bat.getCapacityKWh() * 1000.) / 100);
      autonomyHrs = toDischarge / power;
    }
    if (autonomyHrs >= 0) {
      return autonomyHrs;
    }
    return 0;
  }