// @StateChange private void subscribe(Tariff tariff, CapacityBundle bundle, int customerCount, boolean verbose) { getTariffMarket().subscribeToTariff(tariff, bundle.getCustomerInfo(), customerCount); if (verbose) { log.info( bundle.getName() + ": Subscribed " + customerCount + " customers to tariff " + tariff.getId() + " successfully"); } }
@Override public void initialize(CustomerStructure structure) { log.info("Initializing customer " + customerStructure.name); NodeList capacityBundleNodes = customerStructure.getConfigXml().getElementsByTagName("capacityBundle"); for (int i = 0; i < capacityBundleNodes.getLength(); ++i) { Element capacityBundleElement = (Element) capacityBundleNodes.item(i); CapacityBundle capacityBundle = createCapacityBundle(structure, capacityBundleElement); capacityBundle.initialize(structure, capacityBundleElement); capacityBundles.add(capacityBundle); customerRepo.add(capacityBundle.getCustomerInfo()); } utilityOptimizer = createUtilityOptimizer(structure, capacityBundles); utilityOptimizer.initialize(); log.info("Successfully initialized customer " + customerStructure.name); }
private void usePower(Timeslot timeslot) { for (CapacityBundle bundle : capacityBundles) { List<TariffSubscription> subscriptions = getTariffSubscriptionRepo().findActiveSubscriptionsForCustomer(bundle.getCustomerInfo()); double totalCapacity = 0.0; double totalUsageCharge = 0.0; for (TariffSubscription subscription : subscriptions) { double usageSign = bundle.getPowerType().isConsumption() ? +1 : -1; double currCapacity = usageSign * useCapacity(subscription, bundle); if (Config.getInstance().isUsageChargesLogging()) { double charge = subscription .getTariff() .getUsageCharge(currCapacity, subscription.getTotalUsage(), false); totalUsageCharge += charge; } subscription.usePower(currCapacity); totalCapacity += currCapacity; } log.info( bundle.getName() + ": Total " + bundle.getPowerType() + " capacity for timeslot " + timeslot.getSerialNumber() + " = " + totalCapacity); logUsageCharges( bundle.getName() + ": Total " + bundle.getPowerType() + " usage charge for timeslot " + timeslot.getSerialNumber() + " = " + totalUsageCharge); } }
@Override public CustomerInfo getCustomerInfo() { return bundle.getCustomerInfo(); }