Package srsim.domain

Examples of srsim.domain.Room


  public void testTemperatureChangeThroughActuator()
      throws SimulationContextException, InterruptedException {
    double targetTemperature = 21.5D;
    Simulation simulation = new Simulation(new SystemTimeTimeSource());
    simulation.setResolution(0);
    Room room = new Room();
    HeatingController controller = new HeatingController();
    ISensor sensor = new TemperatureSensor();
    IActuator actuator = new HeatingActuator();
    simulation.addRoom(room);
    room.getLocalContext().setTemperature(20.0D);
    room.getLocalContext().setPreference("targetTemperature", "21.5D");
    controller.attachSensor(sensor);
    controller.attachActuator(actuator);
    room.addActuator(actuator);
    room.addController(controller);
    room.addSensor(sensor);
    double temperature = room.getLocalContext().getTemperature();
    double previousTemperature = temperature;
    while (temperature < targetTemperature) {
      simulation.step();
      previousTemperature = temperature;
      temperature = room.getLocalContext().getTemperature();
      Assert.assertTrue(temperature >= previousTemperature);
    }
  }
View Full Code Here


      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);
    }
  }
View Full Code Here

public class RoomTest {

  @Test
  public void testAddingSensors() throws SimulationContextException {
    Room room = new Room();
    room.setContext(new SimulationContext(new SystemTimeTimeSource()));
    TemperatureSensor sensor = new TemperatureSensor();
    room.addSensor(sensor);
    List<ISensor> sensors = room.getSensors();
    Assert.assertSame(sensor, sensors.get(0));
  }
View Full Code Here

    Assert.assertSame(sensor, sensors.get(0));
  }
 
  @Test
  public void testAddingActuators() throws SimulationContextException {
    Room room = new Room();
    room.setContext(new SimulationContext(new SystemTimeTimeSource()));
    HeatingActuator actuator = new HeatingActuator();
    room.addActuator(actuator);
    List<IActuator> actuators = room.getActuators();
    Assert.assertSame(actuator, actuators.get(0));
  }
View Full Code Here

    Assert.assertSame(actuator, actuators.get(0));
  }
 
  @Test
  public void testAddingControllers() throws SimulationContextException {
    Room room = new Room();
    room.setContext(new SimulationContext(new SystemTimeTimeSource()));
    HeatingController controller = new HeatingController();
    room.addController(controller);
    List<IController> controllers = room.getControllers();
    Assert.assertSame(controller, controllers.get(0));
  }
View Full Code Here

  }
 
  @Test
  public void testAddRoom() {
    SmartRoomSimulator simulator = new SmartRoomSimulator();
    Room room = new Room();
    simulator.addRoom(room);
  }
View Full Code Here

  }
 
  @Test
  public void testSetupAndRunSimulation() {
    SmartRoomSimulator simulator = new SmartRoomSimulator();
    Room room = new Room();
    simulator.addRoom(room);
    HeatingActuator heatingActuator = new HeatingActuator();
    TemperatureSensor temperatureSensor = new TemperatureSensor();
    HeatingController heatingController = new HeatingController();
    heatingController.attachActuator(heatingActuator);
    heatingController.attachSensor(temperatureSensor);
    room.addActuator(heatingActuator);
    room.addSensor(temperatureSensor);
    room.addController(heatingController);
    simulator.startSimulation();
  }
View Full Code Here

  }
 
  @Test
  public void testInitiatingActuatorChangeFromSensorUpdate() throws SimulationContextException {
    Simulation simulation = new Simulation(new SystemTimeTimeSource());
    Room room = new Room();
    HeatingController controller = new HeatingController();
    ISensor sensor = new TemperatureSensor();
    IActuator actuator = new HeatingActuator();
    room.setContext(simulation.getContext());
    simulation.getContext().setTemperature(0.0D);
    simulation.getContext().setPreference("targetTemperature","21.5D");
    controller.attachSensor(sensor);
    controller.attachActuator(actuator);
    Assert.assertTrue(actuator.getState() == IActuator.IDLE);
    room.addSensor(sensor);
    room.addController(controller);
    room.addActuator(actuator);
    controller.step();
    Assert.assertTrue(actuator.getState() == IActuator.ACTIVE);
  }
View Full Code Here

          System.out.println(room.getName());
        }
      }
    } else if (input.startsWith("add ")) {
      if (input.endsWith(" room")) {
        Room room = new Room();
        System.out.print("room name: ");
        input = bufferedReader.readLine();
        room.setName(input);
        controller.addRoom(room);
        System.out.println("Room " + input + " added.");
      }
    } else if (input.startsWith("start sim")) {
      System.out.print(getTime(System.currentTimeMillis())
View Full Code Here

  @Override
  public void handleContextChange(ContextChangedEvent event)
      throws SimulationContextException {
    String time = getTime(event.getTimeStamp());
    System.out.print(time + " [CONTEXT_CHANGE]");
    Room room = event.getContext().getRoom();
    System.out
        .print("[" + (room != null ? room.getName() : "GLOBAL") + "]");
    System.out.printf(" Temperature is %.2f deg C", event.getContext()
        .getTemperature());
    System.out.printf(" | Brightness is %.2f", event.getContext()
        .getBrightness());
    System.out.print(" | Light-color is #");
View Full Code Here

TOP

Related Classes of srsim.domain.Room

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.