public void subscribeDefault (TariffMarket tariffMarketService) { for (CustomerInfo customer: getCustomerInfos()) { Tariff candidate = tariffMarketService.getDefaultTariff(customer.getPowerType()); if (null == candidate) { log.error("No default tariff for " + customer.getPowerType().toString()); } tariffMarketService.subscribeToTariff(candidate, customer, customer.getPopulation()); } }
/** * This function called once at the beginning of each game by the server * initialization service. Here is where you do pre-game setup. This will read * the server properties file to take the competition input variables needed * (configuration files, days of competition), create a listener for our * service, in order to get the new tariff, as well as create the household * Consumers that will be running in the game. */ @Override public String initialize (Competition competition, List<String> completedInits) { if (!completedInits.contains("DefaultBroker") || !completedInits.contains("TariffMarket")) return null; super.init(); tariffMarketService.registerNewTariffListener(this); configuration = new Properties(); villageList = new ArrayList<Village>(); serverPropertiesService.configureMe(this); if (configFile1 == null) { log.info("No Config File for VillageType1 Taken"); configFile1 = "VillageDefault.properties"; } addVillages(configFile1, "1"); return "HouseholdCustomer"; }
/** * Removes customerCount customers (at most) from this subscription, * posts early-withdrawal fees if appropriate. */ public void unsubscribe (int customerCount) { getTariffMarket().subscribeToTariff(getTariff(), getCustomer(), -customerCount); pendingUnsubscribeCount += customerCount; }
private Tariff getDefaultTariff () { return getTariffMarket().getDefaultTariff(customerInfo.getPowerType()); }
tariffMarketService.setDefaultTariff(defaultConsumption); customerSubscriptions.put(defaultConsumption, new LinkedHashMap<>()); tariffMarketService.setDefaultTariff(defaultProduction); customerSubscriptions.put(defaultProduction, new LinkedHashMap<>()); .withUpRegulationPayment(defaultProductionRate) .withDownRegulationPayment(defaultConsumptionRate)); tariffMarketService.setDefaultTariff(defaultStorage); customerSubscriptions.put(defaultStorage, new LinkedHashMap<>());
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"); } }
if (getTariffMarket().getDefaultTariff(powerType) != null) { log.info(bundle.getName() + ": Subscribing " + bundle.getPopulation() + " customers to default " + powerType + " tariff"); subscribe(getTariffMarket().getDefaultTariff(powerType), bundle, bundle.getPopulation(), false); + powerType + "; trying generic type"); PowerType genericType = powerType.getGenericType(); if (getTariffMarket().getDefaultTariff(genericType) == null) { log.error(bundle.getName() + ": No default tariff for generic power type " log.info(bundle.getName() + ": Subscribing " + bundle.getPopulation() + " customers to default " + genericType + " tariff"); subscribe(getTariffMarket().getDefaultTariff(genericType), bundle, bundle.getPopulation(), false);
public void subscribeDefault (TariffMarket tariffMarketService) { for (CustomerInfo customer: getCustomerInfos()) { Tariff candidate = tariffMarketService.getDefaultTariff(customer.getPowerType()); if (null == candidate) { log.error("No default tariff for " + customer.getPowerType().toString()); } else { log.info("Subscribe " + customer.getName() + " to " + candidate.getPowerType().toString()); } tariffMarketService.subscribeToTariff(candidate, customer, customer.getPopulation()); } }
/** Subscribing a certain population amount to a certain subscription */ void subscribe (Tariff tariff, int customerCount, CustomerInfo customer) { tariffMarketService.subscribeToTariff(tariff, customer, customerCount); log.info(this.toString() + " " + tariff.getPowerType().toString() + ": " + customerCount + " were subscribed to tariff " + tariff.getId()); }
/** * This function called once at the beginning of each game by the server * initialization service. Here is where you do pre-game setup. This will read * the server properties file to take the competition input variables needed * (configuration files, days of competition), create a listener for our * service, in order to get the new tariff, as well as create the household * Consumers that will be running in the game. */ @Override public String initialize (Competition competition, List<String> completedInits) { if (!completedInits.contains("DefaultBroker") || !completedInits.contains("TariffMarket")) return null; super.init(); configuration = new Properties(); officeComplexList = new ArrayList<OfficeComplex>(); tariffMarketService.registerNewTariffListener(this); serverPropertiesService.configureMe(this); //tariffMarketService.registerNewTariffListener(this); if (configFile1 == null) { log.info("No Config File for OfficeComplexType1 Taken"); configFile1 = "OfficeComplexDefault.properties"; } addOfficeComplexes(configFile1, "1"); return "OfficeComplexCustomer"; }
tariffMarketService.subscribeToTariff(tariffMarketService .getDefaultTariff(cust.getPowerType()), cust, cust.getPopulation()); customerRepo.add(cust);
private void updateSubscriptions () { int check = 0; for (Tariff tariff : allocations.keySet()) { int count = allocations.get(tariff); check += count; if (count < 0) { //unsubscribe TariffSubscription sub = getTariffSubscriptionRepo().findSubscriptionForTariffAndCustomer (tariff, customerInfo); sub.unsubscribe(-count); log.info("customer " + customerInfo.getName() + " unsubscribes " + -count + " from tariff " + tariff.getId()); } else if (count > 0) { // subscribe getTariffMarket().subscribeToTariff(tariff, customerInfo, count); log.info("customer " + customerInfo.getName() + " subscribes " + count + " to tariff " + tariff.getId()); } } // sanity check if (check != 0) { log.error("Subscription updates do not add up for " + customerInfo.getName() + ": " + check); } }
customerFactory = new CustomerFactory(); newTariffs = false; tariffMarketService.registerNewTariffListener(this);
getTariffMarket().getDefaultTariff(tariff.getTariffSpec() .getPowerType()); getTariffMarket().getDefaultTariff(tariff.getTariffSpec() .getPowerType().getGenericType()); getTariffMarket().subscribeToTariff(tariff, customer, -customersCommitted); getTariffMarket().subscribeToTariff(newTariff, customer, customersCommitted); log.info("Tariff " + tariff.getId() + " superseded by " + newTariff.getId()