@Test public void testPostEconomicControl () { EconomicControlEvent ece1 = new EconomicControlEvent(spec, 0.20, 0); EconomicControlEvent ece3 = new EconomicControlEvent(spec, 0.22, 2); EconomicControlEvent ece4 = new EconomicControlEvent(spec, 0.23, 3); assertNull(capacityControl.getControlsForTimeslot(0), "no controls ts 0"); assertNull(capacityControl.getControlsForTimeslot(1), "no controls ts 1"); capacityControl.postEconomicControl(ece1); List<EconomicControlEvent> controls = capacityControl.getControlsForTimeslot(0); assertNotNull(controls, "some controls ts 0"); assertEquals(1, controls.size(), "one control"); assertEquals(ece1, controls.get(0), "correct control"); assertNull(capacityControl.getControlsForTimeslot(2), "no controls ts 2"); capacityControl.postEconomicControl(ece3); capacityControl.postEconomicControl(ece4); controls = capacityControl.getControlsForTimeslot(0); assertNotNull(controls, "some controls ts 0"); assertEquals(1, controls.size(), "one control"); assertEquals(ece1, controls.get(0), "correct control"); controls = capacityControl.getControlsForTimeslot(2); assertNotNull(controls, "some controls ts 2"); assertEquals(1, controls.size(), "one control"); assertEquals(ece3, controls.get(0), "correct control"); controls = capacityControl.getControlsForTimeslot(3); assertNotNull(controls, "some controls ts 3"); assertEquals(1, controls.size(), "one control"); assertEquals(ece4, controls.get(0), "correct control"); }
@Override public void postEconomicControl (EconomicControlEvent event) { int tsIndex = event.getTimeslotIndex(); int current = timeslotRepo.currentTimeslot().getSerialNumber(); if (tsIndex < current) { log.warn("attempt to save old economic control for ts " + tsIndex + " during timeslot " + current); return; } List<EconomicControlEvent> tsList = pendingEconomicControls.get(tsIndex); if (null == tsList) { tsList = new ArrayList<EconomicControlEvent>(); pendingEconomicControls.put(tsIndex, tsList); } tsList.add(event); }
CapacityControlService extends TimeslotPhaseProcessor implements CapacityControl, InitializationService { @Override public void postEconomicControl (EconomicControlEvent event) { int tsIndex = event.getTimeslotIndex(); int current = timeslotRepo.currentTimeslot().getSerialNumber(); if (tsIndex < current) { log.warn("attempt to save old economic control for ts " + tsIndex + " during timeslot " + current); return; } List<EconomicControlEvent> tsList = pendingEconomicControls.get(tsIndex); if (null == tsList) { tsList = new ArrayList<EconomicControlEvent>(); pendingEconomicControls.put(tsIndex, tsList); } tsList.add(event); } }
CapacityControlService extends TimeslotPhaseProcessor implements CapacityControl, InitializationService { @Override public void postEconomicControl (EconomicControlEvent event) { int tsIndex = event.getTimeslotIndex(); int current = timeslotRepo.currentTimeslot().getSerialNumber(); if (tsIndex < current) { log.warn("attempt to save old economic control for ts " + tsIndex + " during timeslot " + current); return; } List<EconomicControlEvent> tsList = pendingEconomicControls.get(tsIndex); if (null == tsList) { tsList = new ArrayList<EconomicControlEvent>(); pendingEconomicControls.put(tsIndex, tsList); } tsList.add(event); }  }
CapacityControlService extends TimeslotPhaseProcessor implements CapacityControl, InitializationService { @Override public void postEconomicControl (EconomicControlEvent event) { int tsIndex = event.getTimeslotIndex(); int current = timeslotRepo.currentTimeslot().getSerialNumber(); if (tsIndex < current) { log.warn("attempt to save old economic control for ts " + tsIndex + " during timeslot " + current); return; } List<EconomicControlEvent> tsList = pendingEconomicControls.get(tsIndex); if (null == tsList) { tsList = new ArrayList<EconomicControlEvent>(); pendingEconomicControls.put(tsIndex, tsList); } tsList.add(event); }  @Override String initialize(Competition competition, List<String> completedInits); @Override void exerciseBalancingControl(BalancingOrder order,
                                        double kwh, double payment); @Override void postEconomicControl(EconomicControlEvent event); @Override RegulationAccumulator getRegulationCapacity(BalancingOrder order); @Override void activate(Instant time, int phaseNumber); }
CapacityControlService extends TimeslotPhaseProcessor implements CapacityControl, InitializationService { @Override public void postEconomicControl (EconomicControlEvent event) { int tsIndex = event.getTimeslotIndex(); int current = timeslotRepo.currentTimeslot().getSerialNumber(); if (tsIndex < current) { log.warn("attempt to save old economic control for ts " + tsIndex + " during timeslot " + current); return; } List<EconomicControlEvent> tsList = pendingEconomicControls.get(tsIndex); if (null == tsList) { tsList = new ArrayList<EconomicControlEvent>(); pendingEconomicControls.put(tsIndex, tsList); } tsList.add(event); }  @Override String initialize(Competition competition, List<String> completedInits); @Override void exerciseBalancingControl(BalancingOrder order,
                                        double kwh, double payment); @Override void postEconomicControl(EconomicControlEvent event); @Override RegulationAccumulator getRegulationCapacity(BalancingOrder order); @Override void activate(Instant time, int phaseNumber);  }