コード例 #1
0
 /**
  * Reads the OK map node types from settings
  *
  * @param settings The settings where the types are read
  */
 private void readOkMapNodeTypes(Settings settings) {
   if (settings.contains(MAP_SELECT_S)) {
     this.okMapNodeTypes = settings.getCsvInts(MAP_SELECT_S);
     for (int i : okMapNodeTypes) {
       if (i < MapNode.MIN_TYPE || i > MapNode.MAX_TYPE) {
         throw new SettingsError(
             "Map type selection '"
                 + i
                 + "' is out of range for setting "
                 + settings.getFullPropertyName(MAP_SELECT_S));
       }
       if (i > nrofMapFilesRead) {
         throw new SettingsError(
             "Can't use map type selection '"
                 + i
                 + "' for setting "
                 + settings.getFullPropertyName(MAP_SELECT_S)
                 + " because only "
                 + nrofMapFilesRead
                 + " map files are read");
       }
     }
   } else {
     this.okMapNodeTypes = null;
   }
 }
コード例 #2
0
  /** 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());
  }