Commit d0b20bab authored by Jakob Schöttl's avatar Jakob Schöttl

Bugfix and refactoring

parent f0f46417
......@@ -7,12 +7,10 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.simulator.control.PassiveCallback;
import org.vadere.simulator.projects.dataprocessing.DataProcessingJsonManager;
import org.vadere.simulator.projects.io.JsonConverter;
import org.vadere.state.attributes.Attributes;
......@@ -26,7 +24,7 @@ import difflib.DiffUtils;
/**
* Represents a Vadere scenario.
* Holds a {@link ScenarioStore} object.
* Holds a {@link ScenarioStore} object.
*
* @author Jakob Schöttl
*
......@@ -37,8 +35,6 @@ public class Scenario {
private ScenarioStore scenarioStore;
private final List<PassiveCallback> passiveCallbacks;
private DataProcessingJsonManager dataProcessingJsonManager;
private ScenarioFinishedListener finishedListener;
......@@ -57,7 +53,6 @@ public class Scenario {
}
public Scenario(final String name, final ScenarioStore store) {
this.passiveCallbacks = new LinkedList<>();
this.scenarioStore = store;
this.dataProcessingJsonManager = new DataProcessingJsonManager();
......@@ -129,10 +124,6 @@ public class Scenario {
return scenarioStore.topography;
}
public void addPassiveCallback(final PassiveCallback pc) {
passiveCallbacks.add(pc);
}
public void setName(String name) {
this.scenarioStore.name = name;
}
......@@ -189,7 +180,6 @@ public class Scenario {
dataProcessingJsonManager = srm.dataProcessingJsonManager;
finishedListener = srm.finishedListener;
simpleOutputProcessorName = srm.simpleOutputProcessorName;
//this.passiveCallbacks = srm.passiveCallbacks; // is final, can't be reassigned
} catch (IOException | VadereClassNotFoundException e) {
e.printStackTrace();
}
......
......@@ -39,7 +39,7 @@ public class ScenarioRun implements Runnable {
private ScenarioStore scenarioStore;
private Path outputPath;
private final List<PassiveCallback> passiveCallbacks;
private final List<PassiveCallback> passiveCallbacks = new LinkedList<>();
private DataProcessingJsonManager dataProcessingJsonManager;
private ProcessorManager processorManager;
......@@ -51,7 +51,6 @@ public class ScenarioRun implements Runnable {
public ScenarioRun(final Scenario scenario) {
this.scenario = scenario;
this.passiveCallbacks = new LinkedList<>();
this.scenarioStore = scenario.getScenarioStore();
this.dataProcessingJsonManager = new DataProcessingJsonManager();
this.setOutputPaths(Paths.get(IOUtils.OUTPUT_DIR)); // TODO [priority=high] [task=bugfix] [Error?] this is a relative path. If you start the application via eclipse this will be VadereParent/output
......@@ -109,8 +108,6 @@ public class ScenarioRun implements Runnable {
if (finishedListener != null)
finishedListener.scenarioFinished(scenario);
passiveCallbacks.clear();
logger.info(String.format("Simulation of scenario %s finished.", scenario.getName()));
}
......@@ -232,11 +229,11 @@ public class ScenarioRun implements Runnable {
}
public ProcessorManager getProcessorManager() {
return this.processorManager;
return processorManager;
}
public DataProcessingJsonManager getDataProcessingJsonManager() {
return this.dataProcessingJsonManager;
return dataProcessingJsonManager;
}
public void setDataProcessingJsonManager(final DataProcessingJsonManager manager) {
......
......@@ -35,6 +35,8 @@ public class VadereProject implements ScenarioFinishedListener {
new LinkedBlockingQueue<>();
private LinkedBlockingDeque<Scenario> scenariosLeft;
private Path outputDirectory;
// TODO should be encapsulated in a class (we are not programming in C):
private int[] migrationStats; // scenarios: [0] total, [1] legacy'ed, [2] nonmigratable
public VadereProject(final String name, final Iterable<Scenario> scenarios) {
......@@ -149,11 +151,11 @@ public class VadereProject implements ScenarioFinishedListener {
notifySingleScenarioFinishListener(nextScenario);
if (visualization != null) {
nextScenario.addPassiveCallback(visualization);
}
final ScenarioRun scenarioRun = new ScenarioRun(nextScenario);
scenarioRun.setOutputPaths(outputDirectory);
if (visualization != null) {
scenarioRun.addPassiveCallback(visualization);
}
return scenarioRun;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment