/** Creates a scenario based on Settings object. */
  protected SimScenario() {
    Settings s = new Settings(SCENARIO_NS);
    nrofGroups = s.getInt(NROF_GROUPS_S);

    this.name = s.valueFillString(s.getSetting(NAME_S));
    this.endTime = s.getDouble(END_TIME_S);
    this.updateInterval = s.getDouble(UP_INT_S);
    this.simulateConnections = s.getBoolean(SIM_CON_S);

    if (s.contains(SIM_FILES_S)) {
      this.simulateFiles = s.getBoolean(SIM_FILES_S);
    } else {
      this.simulateFiles = false;
    }

    ensurePositiveValue(nrofGroups, NROF_GROUPS_S);
    ensurePositiveValue(endTime, END_TIME_S);
    ensurePositiveValue(updateInterval, UP_INT_S);

    this.simMap = null;
    this.maxHostRange = 1;

    this.connectionListeners = new ArrayList<ConnectionListener>();
    this.messageListeners = new ArrayList<MessageListener>();
    this.movementListeners = new ArrayList<MovementListener>();
    this.updateListeners = new ArrayList<UpdateListener>();
    this.appListeners = new ArrayList<ApplicationListener>();
    this.queryListeners = new ArrayList<FileEventListener>();
    this.eqHandler = new EventQueueHandler();

    /* TODO: check size from movement models */
    s.setNameSpace(MovementModel.MOVEMENT_MODEL_NS);
    int[] worldSize = s.getCsvInts(MovementModel.WORLD_SIZE, 2);
    this.worldSizeX = worldSize[0];
    this.worldSizeY = worldSize[1];

    createHosts();
    if (this.simulateFiles) {
      addFilesToHosts();
    }

    this.world =
        new World(
            hosts,
            worldSizeX,
            worldSizeY,
            updateInterval,
            updateListeners,
            simulateConnections,
            eqHandler.getEventQueues());
  }
Beispiel #2
0
 /**
  * Creates a setting object with a namespace. Namespace is the prefix of the all subsequent
  * setting requests.
  *
  * @param namespace Namespace to use
  */
 public Settings(String namespace) {
   this.oldNamespaces = new Stack<String>();
   this.secondaryNamespaces = new Stack<String>();
   setNameSpace(namespace);
 }