/** * Returns the current tariff subscriptions for the first CustomerInfo. * Useful for customer models with a single CustomerInfo. */ public List<TariffSubscription> getCurrentSubscriptions () { return service.getTariffSubscriptionRepo(). findActiveSubscriptionsForCustomer(allCustomerInfos.get(0)); }
/** * Returns the list of active subscriptions for a given customer. * These are subscriptions that have non-zero committed-customer counts. */ public List<TariffSubscription> findActiveSubscriptionsForCustomer (CustomerInfo customer) { List<TariffSubscription> result = new ArrayList<TariffSubscription>(); for (TariffSubscription sub : findSubscriptionsForCustomer(customer)) { if (sub.getCustomersCommitted() > 0) { result.add(sub); } } return result; }
/** * Returns the subscription, if any, for the specified tariff and customer. * Does not create a subscription in case it cannot be found in the repo. */ public TariffSubscription findSubscriptionForTariffAndCustomer (Tariff tariff, CustomerInfo customer) { List<TariffSubscription> subs = findSubscriptionsForTariff(tariff); if (subs == null) return null; for (TariffSubscription sub : subs) { if (sub.getCustomer() == customer) return sub; } return null; }
/** * Returns the TariffSubscription for the given Tariff/Customer pair, creating * it if necessary. Note that as of issue #505, you can get null back if you * try to get a subscription for a non-existent tariff, such as one that has * been revoked. */ public TariffSubscription getSubscription (CustomerInfo customer, Tariff tariff) { TariffSubscription result = findSubscriptionForCustomer(tariffMap.get(tariff), customer); if (null != result) { // subscription exists return result; } result = new TariffSubscription(customer, tariff); storeSubscription(result, customer, tariff); return result; }
/** * Handles pending subscription/unsubscription events */ private synchronized void processPendingSubscriptions() { for (PendingSubscription pending : pendingSubscriptionEvents) { TariffSubscription sub = tariffSubscriptionRepo.getSubscription(pending.customer, pending.tariff); if (pending.count > 0) sub.subscribe(pending.count); else if (pending.count < 0) sub.deferredUnsubscribe(-pending.count); } pendingSubscriptionEvents.clear(); }
tariffSubscriptionRepo.findActiveSubscriptionsForBroker(broker); for (TariffSubscription sub: subs) { if (CustomerClass.LARGE == sub.getCustomer().getCustomerClass()) {
/** * In this overloaded implementation of the changing subscription function, * Here we just put the tariff we want to change and the whole population is * moved to another random tariff. NOTE: Used only for testing... * * @param tariff */ public void changeSubscription (Tariff tariff, Tariff newTariff, CustomerInfo customer) { TariffSubscription ts = service.getTariffSubscriptionRepo().getSubscription(customer, tariff); int populationCount = ts.getCustomersCommitted(); unsubscribe(ts, populationCount); subscribe(newTariff, populationCount, customer); }
/** * Returns the current tariff subscriptions for the first CustomerInfo * with the given PowerType. Useful for customer models with a single * CustomerInfo per PowerType. */ public List<TariffSubscription> getCurrentSubscriptions (PowerType type) { return service.getTariffSubscriptionRepo(). findActiveSubscriptionsForCustomer(customerInfos.get(type).get(0)); }
private List<TariffSubscription> getBundleSubscriptions (CapacityBundle bundle) { return getTariffSubscriptionRepo() .findSubscriptionsForCustomer(bundle.getCustomerInfo()); }
/** * Exercises an economic control for the current timeslot. */ void exerciseEconomicControl (EconomicControlEvent event) { Tariff tariff = tariffRepo.findTariffById(event.getTariffId()); if (null == tariff) { // should not happen log.error("Null tariff " + event.getTariffId() + " for economic control"); return; } List<TariffSubscription> subs = tariffSubscriptionRepo.findSubscriptionsForTariff(tariff); for (TariffSubscription sub : subs) { sub.postRatioControl(event.getCurtailmentRatio()); } }
public void consumePower () { Timeslot ts = service.getTimeslotRepo().currentTimeslot(); int serial; for (CustomerInfo customer: getCustomerInfos()) { List<TariffSubscription> subscriptions = service.getTariffSubscriptionRepo() .findActiveSubscriptionsForCustomer(customer); String temp = officeMapping.get(customer); String type = temp.substring(0, 2); boolean controllable = temp.contains("Controllable"); if (ts == null) { log.error("Current timeslot is null"); serial = 0; } else { log.debug("Timeslot Serial: " + ts.getSerialNumber()); serial = ts.getSerialNumber(); } double load = getConsumptionByTimeslot(serial, type, controllable); log.debug("Consumption Load for Customer " + customer.toString() + ": " + load + " for subscriptions " + subscriptions.toString()); if (subscriptions != null && subscriptions.size() != 0) { subscriptions.get(0).usePower(load); } } }
postPendingSubscriptionEvent(tariff, customer, customerCount); List<TariffSubscription> existingSubscriptions = tariffSubscriptionRepo.findSubscriptionsForCustomer(customer); if (0 == existingSubscriptions.size()) {
filter(tariffSubscriptionRepo.findSubscriptionsForTariff(tariff), new Predicate<TariffSubscription> () { @Override
@Override public RegulationAccumulator getRegulationCapacity (BalancingOrder order) { Tariff tariff = tariffRepo.findTariffById(order.getTariffId()); if (null == tariff) { // broker error, most likely log.warn("Null tariff " + order.getTariffId() + " for balancing order"); return new RegulationAccumulator(0.0, 0.0); } RegulationAccumulator result = new RegulationAccumulator(0.0, 0.0); List<TariffSubscription> subs = tariffSubscriptionRepo.findSubscriptionsForTariff(tariff); for (TariffSubscription sub : subs) { result.add(sub.getRemainingRegulationCapacity()); } log.info("BalancingOrder " + order.getId() + " capacity = (" + result.getUpRegulationCapacity() + "," + result.getDownRegulationCapacity() + ")"); return result; }
.findActiveSubscriptionsForCustomer(customer).get(0);
tariffSubscriptionRepo.findSubscriptionsForTariff(tariff);
.findActiveSubscriptionsForCustomer(customer).get(0);
tariffSubscriptionRepo.findSubscriptionsForTariff(tariff)) { sub.postRatioControl(event.getCurtailmentRatio());