Package srsim.simulator

Examples of srsim.simulator.SimulationContext


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


  }
 
  @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

  }
 
  @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

    JsonObjectBuilder contextUpdateBuilder = Json.createObjectBuilder();
    if (rooms != null) {
      for (Room room : rooms) {
        String name = room.getName();
        if (name.equalsIgnoreCase(roomId)) {
          SimulationContext context = room.getLocalContext();
          int[] lightColor = context.getLightColor();
          contextUpdateBuilder
              .add(SimulationContext.BRIGHTNESS,
                  context.getBrightness())
              .add(SimulationContext.TEMPERATURE,
                  context.getTemperature())
              .add(SimulationContext.LIGHTCOLOR,
                  String.format("%d %d %d", lightColor[0],
                      lightColor[1], lightColor[2]))
              .add(SimulationContext.ENERGY_CONSUMPTION,
                  context.getEnergyConsumption())
              .add(SimulationContext.MUSIC_GENRE,
                  context.getMusicGenre())
              .add(SimulationContext.MUSIC_VOLUME,
                  context.getMusicVolume());
        }
      }
    }
    JsonObject contextUpdate = contextUpdateBuilder.build();
    return contextUpdate;
View Full Code Here

  }

  @Override
  public void handleContextChange(ContextChangedEvent event)
      throws SimulationContextException {
    SimulationContext context = event.getContext();
    if (context.getRoom().getName()
        .equals((String) roomSelectionComboBox.getSelectedItem())) {
      updateValues(context);
    }
  }
View Full Code Here

  public Room() {
    sensors = new LinkedList<ISensor>();
    actuators = new LinkedList<IActuator>();
    controllers = new LinkedList<IController>();
    context = new SimulationContext((Room)this);
    id = 0L;
  }
View Full Code Here

   *
   * @param timeSource
   *            ITimesource implementation to be used for timestamping
   */
  public Simulation(final ITimeSource timeSource) {
    globalContext = new SimulationContext(timeSource);
    simulationListeners = new LinkedList<ISimulationListener>();
    rooms = new LinkedList<Room>();
    resolution = 1000;
  }
View Full Code Here

TOP

Related Classes of srsim.simulator.SimulationContext

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.