public void doActivities (int day, int hour) { //TODO - keep track of plugged-in state and capacity of charger TimeslotData timeslotData = todayMap[hour]; double intendedDistance = timeslotData.getIntendedDistance(); double neededCapacity = getNeededCapacity(intendedDistance); if (intendedDistance < distanceEpsilon) { return; } if (neededCapacity > currentCapacity) { log.warn("Customer {} out of juice!", getName()); return; } try { double before = currentCapacity; discharge(neededCapacity); log.info("{} {} at {}, {} kms {} kWh from {} to {}", name, timeslotData.getActivity().get().getName(), dtf.print(service.getTimeService().getCurrentDateTime()), intendedDistance, neededCapacity, before, currentCapacity); driving = true; } catch (ChargeException ce) { log.error(ce); } }
@Override public CapacityAccumulator useCapacity (TariffSubscription subscription) { int timeslot = timeslotRepo.currentSerialNumber(); double baseCapacity = getBaseCapacity(timeslot); if (Double.isNaN(baseCapacity)) { throw new Error("Base capacity is NaN!"); } //else if (parentBundle.getPowerType().isProduction()) { // // correct sign before going further // baseCapacity *= -1.0; //} logCapacityDetails(logIdentifier + ": Base capacity for timeslot " + timeslot + " = " + baseCapacity); // total adjusted capacity double adjustedCapacity = baseCapacity; adjustedCapacity = adjustCapacityForPeriodicSkew(adjustedCapacity, timeService.getCurrentDateTime(), true); adjustedCapacity = adjustCapacityForCurrentWeather(adjustedCapacity, true); // moved up one level //adjustedCapacity = // adjustCapacityForSubscription(timeslot, adjustedCapacity, subscription); CapacityAccumulator result = addRegCapacityMaybe(subscription, timeslot, adjustedCapacity); actualCapacities.put(timeslot, result.getCapacity()); log.info(logIdentifier + ": Adjusted capacity for tariff " + subscription.getTariff().getId() + " = " + result.getCapacity()); return result; }