示例#1
0
 /** Registers SimRunListeners with the current experiment runner */
 protected void setListeners(SimRunListener[] listeners) {
   if (listeners == null) return;
   for (int i = 0; i < listeners.length; i++) {
     SimRunListener l = listeners[i];
     expRunner.addSimRunListener(l);
   }
 }
示例#2
0
  /** Initializes an experiment run from an xml file */
  void readExperimentRunFromNode(Node root) {
    try {
      Run run = new Run();
      run.readFromNode((Element) root);

      expRunner = run.getExperimentRunner();
      model = run.getModel();
      expRunnerClass = expRunner.getClass();
      modelClass = model.getClass();
      expAccessPoints = new AccessPointTableModel(expRunner.getExperimentSettings());
      modelAccessPoints = new AccessPointTableModel(expRunner.getModelParameters());

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#3
0
  /**
   * Inits a new experiment run from a given model and experiment runner class: model and experiment
   * runner are initialized. Parameter tables are connected to model parameter and experiment
   * setting access points.
   */
  void initNewExperimentRun() {

    try {
      if (expRunnerClass != null && modelClass != null) {

        model = (Model) modelClass.newInstance();
        if (this.modelConstants != null) {
          model
              .getParameterManager()
              .initializeModelParameter(String[].class, "cmdparam", this.modelConstants);
        }
        expRunner = (ExperimentRunner) expRunnerClass.newInstance();
        expRunner.setModel(model);

        expAccessPoints = new AccessPointTableModel(expRunner.getExperimentSettings());
        modelAccessPoints = new AccessPointTableModel(expRunner.getModelParameters());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#4
0
 /** Called when experiment is stopped. Implemented for ExperimentListener */
 public void experimentStopped(SimRunEvent e) {
   Experiment exp = expRunner.getExperiment();
   Map expMap = expAccessPoints.getAccessPoints();
   Object[] expvalues = AccessUtil.getAccessPointValues(expMap);
   String currentTime = model.currentTime().toString(3);
   String experimentValues = expvalues[AccessUtil.getIndexof("name", expMap)].toString();
   String outputPath = exp.getOutputPath();
   List<List<String>> appendixes = exp.getOutputAppendixes();
   String[] appendixesUsed = {
     appendixes.get(0).get(0),
     appendixes.get(1).get(0),
     appendixes.get(2).get(0),
     appendixes.get(3).get(0)
   }; // only use the first one (GUI can only set one output file type per channel)
   experimentGUI.setStopped(currentTime, startTime, experimentValues, outputPath, appendixesUsed);
 }
示例#5
0
  /** Starts the current experiment for the first time */
  void startExperiment() {
    expAccessPoints.setValues();
    modelAccessPoints.setValues();

    expRunner.addSimClockListener(this);
    expRunner.addExperimentListener(this);
    expRunner.init();
    SimRunListener[] l = expRunner.createSimRunListeners(observerDesktop);
    setListeners(l);
    expRunner.registerMessageReceivers();
    startTime = System.currentTimeMillis();
    expRunner.start();
  }
示例#6
0
 /** Pauses and resumes the currentExperiment (called when PAUSE button is switched). */
 void pauseExperiment(boolean isSelected) {
   expRunner.setPaused(isSelected);
 }
示例#7
0
 /** Stops the current experiment (forever). Called when STOP button is pressed */
 void stopExperiment() {
   expRunner.stopExperiment();
 }
示例#8
0
 /**
  * Called when the currently active experiment's SimClock is advanced
  *
  * @param e SimRunEvent: A SimRunEvent.
  */
 public void clockAdvanced(SimRunEvent e) {
   SimTime currentTime = e.getSimTime();
   double timePercent =
       (currentTime.getTimeValue() / expRunner.getExperiment().getStopTime().getTimeValue()) * 100;
   experimentGUI.clockAdvanced(currentTime.toString(3), timePercent, startTime);
 }