CustomerRecord (CustomerInfo customer, int population) { super(); this.customer = customer; this.subscribedPopulation = population; base = timeslotRepo.findBySerialNumber(0).getStartInstant(); }
private Instant getNowInstant () { return service.getTimeslotRepo().currentTimeslot().getStartInstant(); }
@Override public CapacityProfile getCapacityProfile (Tariff tariff) { Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant(); double drain = capacityKWh * (1.0 - chargeEfficiency) / 2.0; double[] profile = new double[24]; Arrays.fill(profile, drain); return new CapacityProfile (profile, start); } }
protected Instant startOfDay () { Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant(); return start.toDateTime(DateTimeZone.UTC).withHourOfDay(0).toInstant(); }
protected Instant nextStartOfDay () { Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant(); return start.toDateTime(DateTimeZone.UTC) .withHourOfDay(0).toInstant().plus(TimeService.DAY); }
protected Instant lastSunday () { Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant(); return start.toDateTime(DateTimeZone.UTC) .withDayOfWeek(1).withHourOfDay(0).toInstant(); }
competition.getDeactivateTimeslotsAhead() - 1); Timeslot oldTs = timeslotRepo.findBySerialNumber(oldSerial); log.info("Deactivated timeslot " + oldSerial + ", start " + oldTs.getStartInstant().toString()); if (newTs == null) { log.info("newTS null in activateNextTimeslot"); long start = (current.getStartInstant().getMillis() + (newSerial - current.getSerialNumber()) * timeslotMillis); newTs = timeslotRepo.makeTimeslot(new Instant(start)); log.info("Activated timeslot " + newSerial + ", start " + newTs.getStartInstant());
@Override public void step () { int serial = service.getTimeslotRepo().currentSerialNumber(); Timeslot ts = service.getTimeslotRepo().currentTimeslot(); // TODO - this code assumes that games start at midnight. Bad assumption. int day = (int) (serial / VillageConstants.HOURS_OF_DAY); int hour = ts.getStartTime().getHourOfDay(); Instant now = ts.getStartInstant(); weatherCheck(day, hour, now); checkCurtailment(serial, day, hour); consumePower(); // for (Household house: getHouses()) // house.test(); if (hour == 23) { for (String type: numberOfHouses.keySet()) { if (!(type.equals("NS"))) { log.info("Rescheduling " + type); rescheduleNextDay(type); } } } }
@Override public void step () { int serial = service.getTimeslotRepo().currentSerialNumber(); Timeslot ts = service.getTimeslotRepo().currentTimeslot(); // TODO - this code assumes that games start at midnight. Bad assumption. int day = (int) (serial / OfficeComplexConstants.HOURS_OF_DAY); int hour = ts.getStartTime().getHourOfDay(); Instant now = ts.getStartInstant(); weatherCheck(day, hour, now); // checkRevokedSubscriptions(); checkCurtailment(serial, day, hour); consumePower(); // for (Office office: getOffices()) // office.test(); if (hour == 23) { for (String type: numberOfOffices.keySet()) { if (!(type.equals("NS"))) { log.info("Rescheduling " + type); rescheduleNextDay(type); } } } }
double[] getPrices () { if (null != this.prices) return prices; double nhc = getNominalHourlyConsumption(); prices = new double[profileSize]; double cumulativeUsage = 0.0; Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant(); for (int i = 0; i < profileSize; i++) { Instant when = start.plus(i * TimeService.HOUR); if (when.get(DateTimeFieldType.hourOfDay()) == 0) { cumulativeUsage = 0.0; } prices[i] = tariff.getUsageCharge(when, nhc, cumulativeUsage) / nhc; cumulativeUsage += nhc; } return prices; }
/** * TODO: this does not appear to be a reasonable profile */ @Override public CapacityProfile getCapacityProfile (Tariff tariff) { double[] result = new double[config.getProfileLength()]; for (int i = 0; i < result.length; i++) { result[i] = getDominantLoad() / hrsPerDay; } // Assume profile starts at midnight Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant(); return new CapacityProfile(result, start.toDateTime(DateTimeZone.UTC) .withHourOfDay(0).toInstant() .plus(TimeService.DAY)); }