throws SimulationContextException,
SimulationConfigurationException, InterruptedException {
double targetBrightness = 6000.0D;
Simulation simulation = new Simulation(new SystemTimeTimeSource());
simulation.setResolution(0);
Room room = new Room();
AbstractController controller = new LightingController();
ISensor sensor = new LightSensor();
IActuator[] lights = new IActuator[10];
simulation.addRoom(room);
simulation.getContext().setBrightness(5999.0D);
room.getLocalContext().setPreference("targetBrightness",
String.valueOf(targetBrightness));
controller.attachSensor(sensor);
for (int i = 0; i < 10; i++) {
lights[i] = new LightingActuator();
controller.attachActuator(lights[i]);
room.addActuator(lights[i]);
}
room.addController(controller);
room.addSensor(sensor);
double brightness = room.getLocalContext().getBrightness();
double previousBrightness = brightness;
while (brightness < targetBrightness) {
simulation.step();
previousBrightness = brightness;
brightness = room.getLocalContext().getBrightness();
Assert.assertTrue(brightness > previousBrightness);
}
}