2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit f212a646 authored by Mario Teixeira Parente's avatar Mario Teixeira Parente
Browse files

Changes 'log file' naming to 'output file' and 'data processing'

parent fd06d8af
......@@ -262,7 +262,7 @@ Tab.Model.addAttributesMenu.title=Add Attributes
Tab.Model.insertModelNameMenu.title=Insert model-name
Tab.Pedestrians.title=Pedestrians
Tab.Topography.title=Topography
Tab.OutputProcessors.title=Log files
Tab.OutputProcessors.title=Data processing
Tab.TopographyCreator.title=Topography creator
Tab.PostVisualization.title=Post-Visualization
......
......@@ -262,7 +262,7 @@ Tab.Model.addAttributesMenu.title=Attributes hinzuf\u00fcgen
Tab.Model.insertModelNameMenu.title=Model-Name einf\u00fcgen
Tab.Pedestrians.title=Fu\u00dfg\u00e4nger
Tab.Topography.title=Topographie
Tab.OutputProcessors.title=Log-Dateien
Tab.OutputProcessors.title=Datenverarbeitung
Tab.TopographyCreator.title=Topographie-Designer
Tab.PostVisualization.title=Post-Visualisierung
......
{
"logfiles": [ {
"type": "org.vadere.simulator.projects.dataprocessing_mtp.TimestepPedestrianIdLogFile",
"filename": "log_ts_pid.txt",
"files": [ {
"type": "org.vadere.simulator.projects.dataprocessing_mtp.TimestepPedestrianIdOutputFile",
"filename": "output_ts_pid.txt",
"processors": [ 1, 2, 3, 5, 13, 14, 17 ]
}, {
"type": "org.vadere.simulator.projects.dataprocessing_mtp.PedestrianIdLogFile",
"filename": "log_pid.txt",
"type": "org.vadere.simulator.projects.dataprocessing_mtp.PedestrianIdOutputFile",
"filename": "output_pid.txt",
"processors": [ 4, 8, 9, 10, 15, 16 ]
}, {
"type": "org.vadere.simulator.projects.dataprocessing_mtp.TimestepLogFile",
"filename": "log_ts.txt",
"type": "org.vadere.simulator.projects.dataprocessing_mtp.TimestepOutputFile",
"filename": "output_ts.txt",
"processors": [ 6, 7 ]
}, {
"type": "org.vadere.simulator.projects.dataprocessing_mtp.NoDataKeyLogFile",
"filename": "log_nokey.txt",
"type": "org.vadere.simulator.projects.dataprocessing_mtp.NoDataKeyOutputFile",
"filename": "output_nokey.txt",
"processors": [ 11, 12 ]
}],
} ],
"processors": [ {
"type": "org.vadere.simulator.projects.dataprocessing_mtp.PedestrianPositionProcessor",
"id": 1
......
......@@ -38,7 +38,7 @@ public class ActionRunOutput extends AbstractAction {
OfflineSimulation offlineSimulation = new OfflineSimulation(
IOOutput.readTrajectories(outputBundle.getProject(), vadere, directoryName),
vadere, model.getProject().getOutputDir()
.resolveSibling(IOUtils.LOG_DIR));
.resolveSibling(IOUtils.DATAPROCESSING_DIR));
offlineSimulation.run();
} catch (IOException e1) {
logger.error("Could not run offline simulation (simulate output):"
......
......@@ -178,12 +178,12 @@ public class ScenarioJPanel extends JPanel implements IProjectChangeListener, Pr
tabbedPane.addTab(Messages.getString("Tab.OutputProcessors.title"), null, outputProcessorsView, null);
*/
outputView = new TextView("/" + IOUtils.LOG_DIR, "default_directory_outputprocessors", AttributeType.OUTPUTPROCESSOR);
outputView = new TextView("/" + IOUtils.DATAPROCESSING_DIR, "default_directory_outputprocessors", AttributeType.OUTPUTPROCESSOR);
try {
// TODO add more templates and make a loop here
String templateFileName = "log_default.json";
String templateJson = org.apache.commons.io.IOUtils.toString(this.getClass().getResourceAsStream("/logTemplates/" + templateFileName), "UTF-8");
String templateFileName = "output_default.json";
String templateJson = org.apache.commons.io.IOUtils.toString(this.getClass().getResourceAsStream("/outputTemplates/" + templateFileName), "UTF-8");
JMenuBar processorsMenuBar = new JMenuBar();
JMenu processorsMenu = new JMenu(Messages.getString("Tab.Model.loadTemplateMenu.title"));
......
......@@ -156,7 +156,7 @@ public class Simulation {
public void run() {
try {
processorManager.setModel(this.model);
processorManager.initLogFiles();
processorManager.initOutputFiles();
preLoop();
processorManager.preLoop(this.simulationState);
......@@ -213,7 +213,7 @@ public class Simulation {
postLoop();
processorManager.postLoop(this.simulationState);
processorManager.writeLog();
processorManager.writeOutput();
this.logger.info("Logged all processors in logfiles");
}
}
......
......@@ -64,7 +64,7 @@ public class VadereFactory {
ScenarioRunManager v = IOVadere.fromJson(json);
Path outPath = Paths.get(projectdirectory, IOUtils.OUTPUT_DIR);
Path outProcessorPath = Paths.get(projectdirectory, IOUtils.LOG_DIR);
Path outProcessorPath = Paths.get(projectdirectory, IOUtils.DATAPROCESSING_DIR);
if (!Files.exists(outPath))
Files.createDirectories(outPath);
if (!Files.exists(outProcessorPath))
......
......@@ -78,7 +78,7 @@ public class ScenarioRunManager implements Runnable {
this.writers = new LinkedList<>();
this.scenarioStore = store;
this.outputPath = 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
this.processorOutputPath = Paths.get(IOUtils.LOG_DIR);
this.processorOutputPath = Paths.get(IOUtils.DATAPROCESSING_DIR);
saveChanges();
}
......@@ -336,7 +336,7 @@ public class ScenarioRunManager implements Runnable {
}
// New processors
this.processorManager.setLogPath(this.processorOutputPath.toString());
this.processorManager.setOutputPath(this.processorOutputPath.toString());
}
}
......
......@@ -75,7 +75,7 @@ public class VadereProject implements ScenarioFinishedListener {
public void runScenarios(final Collection<ScenarioRunManager> scenariosRMsToRun) {
for (ScenarioRunManager scenarioRM : scenariosRMsToRun) {
scenarioRM.setOutputPaths(outputDirectory,
outputDirectory.resolveSibling(IOUtils.LOG_DIR));
outputDirectory.resolveSibling(IOUtils.DATAPROCESSING_DIR));
}
// TODO [priority=normal] [task=bugfix] this is a bug: scenariosLeft may be overwritten even if there are still scenarios in it
......
package org.vadere.simulator.projects.dataprocessing_mtp;
public class NoDataKeyLogFile extends LogFile<NoDataKey> {
public NoDataKeyLogFile() {
public class NoDataKeyOutputFile extends OutputFile<NoDataKey> {
public NoDataKeyOutputFile() {
super(new String[] { });
}
......
......@@ -10,7 +10,7 @@ import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.List;
public abstract class LogFile<K extends Comparable<K>> {
public abstract class OutputFile<K extends Comparable<K>> {
private String[] keyHeaders;
private String fileName;
......@@ -19,7 +19,7 @@ public abstract class LogFile<K extends Comparable<K>> {
private static Character SEPARATOR = ' ';
LogFile(final String... keyHeaders) {
OutputFile(final String... keyHeaders) {
this.keyHeaders = keyHeaders;
this.processors = new ArrayList<>();
}
......
package org.vadere.simulator.projects.dataprocessing_mtp;
public class PedestrianIdLogFile extends LogFile<PedestrianIdDataKey> {
public class PedestrianIdOutputFile extends OutputFile<PedestrianIdDataKey> {
public PedestrianIdLogFile() {
public PedestrianIdOutputFile() {
super(PedestrianIdDataKey.getHeader());
}
}
......@@ -17,10 +17,10 @@ public class ProcessorManager {
private Map<Integer, Processor<?, ?>> processorMap;
private Map<Integer, AttributesProcessor> attributesMap;
private List<LogFile<?>> logFiles;
private List<OutputFile<?>> outputFiles;
public ProcessorManager(List<Processor<?, ?>> processors, List<AttributesProcessor> attributesProcessor, List<LogFile<?>> logFiles) {
this.logFiles = logFiles;
public ProcessorManager(List<Processor<?, ?>> processors, List<AttributesProcessor> attributesProcessor, List<OutputFile<?>> outputFiles) {
this.outputFiles = outputFiles;
this.attributesMap = new LinkedHashMap<>();
for (AttributesProcessor att : attributesProcessor)
......@@ -37,16 +37,16 @@ public class ProcessorManager {
this.model = model;
}
public void initLogFiles() {
logFiles.forEach(logfile -> logfile.init(this));
public void initOutputFiles() {
outputFiles.forEach(file -> file.init(this));
}
public Processor<?, ?> getProcessor(int id) {
return this.processorMap.containsKey(id) ? this.processorMap.get(id) : null;
}
public List<LogFile<?>> getLogFiles() {
return this.logFiles;
public List<OutputFile<?>> getOutputFiles() {
return this.outputFiles;
}
public Model getModel() {
......@@ -77,12 +77,12 @@ public class ProcessorManager {
return this.attributesMap.get(processorId);
}
public void setLogPath(String directory) {
public void setOutputPath(String directory) {
String dateString = new SimpleDateFormat(IOUtils.DATE_FORMAT).format(new Date());
this.logFiles.forEach(logfile -> logfile.setFileName(IOUtils.getPath(directory, String.format("%s_%s", dateString, logfile.getFileName())).toString()));
this.outputFiles.forEach(file -> file.setFileName(IOUtils.getPath(directory, String.format("%s_%s", dateString, file.getFileName())).toString()));
}
public void writeLog() {
this.logFiles.forEach(logfile -> logfile.write());
public void writeOutput() {
this.outputFiles.forEach(file -> file.write());
}
}
package org.vadere.simulator.projects.dataprocessing_mtp;
public class TimestepLogFile extends LogFile<TimestepDataKey> {
public class TimestepOutputFile extends OutputFile<TimestepDataKey> {
public TimestepLogFile() {
public TimestepOutputFile() {
super(TimestepDataKey.getHeader());
}
}
package org.vadere.simulator.projects.dataprocessing_mtp;
public class TimestepPedestrianIdLogFile extends LogFile<TimestepPedestrianIdDataKey> {
public class TimestepPedestrianIdOutputFile extends OutputFile<TimestepPedestrianIdDataKey> {
public TimestepPedestrianIdLogFile() {
public TimestepPedestrianIdOutputFile() {
super(TimestepPedestrianIdDataKey.getHeaders());
}
......
......@@ -29,7 +29,7 @@ import org.vadere.simulator.projects.ScenarioRunManager;
import org.vadere.simulator.projects.ScenarioStore;
import org.vadere.simulator.projects.dataprocessing.writer.ProcessorWriter;
import org.vadere.simulator.projects.dataprocessing_mtp.AttributesProcessor;
import org.vadere.simulator.projects.dataprocessing_mtp.LogFile;
import org.vadere.simulator.projects.dataprocessing_mtp.OutputFile;
import org.vadere.simulator.projects.dataprocessing_mtp.Processor;
import org.vadere.simulator.projects.dataprocessing_mtp.ProcessorManager;
import org.vadere.state.attributes.Attributes;
......@@ -253,7 +253,7 @@ public abstract class JsonConverter {
int id;
}
private static class LogFileStore {
private static class OutputFileStore {
String type;
String filename;
List<Integer> processors;
......@@ -271,20 +271,20 @@ public abstract class JsonConverter {
}
public static ProcessorManager deserializeProcessorManagerFromNode(JsonNode node) throws IOException {
ArrayNode logFilesArrayNode = (ArrayNode) node.get("logfiles");
ArrayNode outputFilesArrayNode = (ArrayNode) node.get("files");
ArrayNode processorsArrayNode = (ArrayNode) node.get("processors");
JsonNode attributesNode = node.get("attributes");
// part 1: log files
List<LogFile<?>> logFiles = new ArrayList<>();
if (logFilesArrayNode != null) {
DynamicClassInstantiator<LogFile<?>> instantiator1 = new DynamicClassInstantiator<>();
for (JsonNode fileNode : logFilesArrayNode) {
LogFileStore writerStore = mapper.treeToValue(fileNode, LogFileStore.class);
LogFile<?> file = instantiator1.createObject(writerStore.type);
// part 1: output files
List<OutputFile<?>> outputFiles = new ArrayList<>();
if (outputFilesArrayNode != null) {
DynamicClassInstantiator<OutputFile<?>> instantiator1 = new DynamicClassInstantiator<>();
for (JsonNode fileNode : outputFilesArrayNode) {
OutputFileStore writerStore = mapper.treeToValue(fileNode, OutputFileStore.class);
OutputFile<?> file = instantiator1.createObject(writerStore.type);
file.setFileName(writerStore.filename);
file.setProcessorIds(writerStore.processors);
logFiles.add(file);
outputFiles.add(file);
}
}
......@@ -313,7 +313,7 @@ public abstract class JsonConverter {
}
}
return new ProcessorManager(processors, attributes, logFiles);
return new ProcessorManager(processors, attributes, outputFiles);
}
public static String serializeProcessorManager(ProcessorManager processorManager) throws JsonProcessingException {
......@@ -323,18 +323,18 @@ public abstract class JsonConverter {
private static JsonNode serializeProcessorManagerToNode(ProcessorManager processorManager) {
ObjectNode main = mapper.createObjectNode();
ArrayNode logFilesArrayNode = mapper.createArrayNode();
ArrayNode outputFilesArrayNode = mapper.createArrayNode();
ArrayNode processorsArrayNode = mapper.createArrayNode();
ObjectNode attributesNode = mapper.createObjectNode();
if (processorManager != null) {
// part 1: logfiles
processorManager.getLogFiles().forEach(logfile -> {
// part 1: output files
processorManager.getOutputFiles().forEach(file -> {
ObjectNode node = mapper.createObjectNode();
node.put("type", logfile.getClass().getName());
node.put("filename", logfile.getFileName());
node.set("processors", mapper.convertValue(logfile.getProcessorIds(), JsonNode.class));
logFilesArrayNode.add(node);
node.put("type", file.getClass().getName());
node.put("filename", file.getFileName());
node.set("processors", mapper.convertValue(file.getProcessorIds(), JsonNode.class));
outputFilesArrayNode.add(node);
});
// part 2: processors
......@@ -352,7 +352,7 @@ public abstract class JsonConverter {
});
}
main.set("logfiles", logFilesArrayNode);
main.set("files", outputFilesArrayNode);
main.set("processors", processorsArrayNode);
main.set("attributes", attributesNode);
return main;
......
......@@ -49,7 +49,7 @@ public class IOUtils {
public static final String CORRUPT_DIR = "corrupt";
public static final String LOG_DIR = "log";
public static final String DATAPROCESSING_DIR = "data processing";
public static final String VADERE_PROJECT_FILENAME = "vadere.project";
......
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