21 package org.matsim.run;
24 import java.util.Collection;
25 import java.util.Iterator;
66 if (args.length == 0) {
67 System.out.println(
"Too few arguments.");
72 while (argIter.hasNext()) {
73 String arg = argIter.next();
74 if (arg.equals(
"-h") || arg.equals(
"--help")) {
78 if (arg.contains(
".xml"))
79 this.configfile = arg;
80 else if (arg.contains(
"events"))
81 this.eventsfile = arg;
83 System.out.println(
"Unrecognized file \"" + arg +
"\"");
93 System.out.println(
"Events2Snapshot");
94 System.out.println(
"Converts an events file to a snapshot file.");
96 System.out.println(
"usage: Events2Snapshot [OPTIONS] configfile [eventsfile]");
97 System.out.println(
" If no eventsfile is given, the in-events-file specified in the config-");
98 System.out.println(
" file will be used.");
99 System.out.println(
" The snapshots are generated according to the snapshot-settings in the");
100 System.out.println(
" simulation-part of the configuration.");
101 System.out.println();
102 System.out.println(
"Options:");
103 System.out.println(
"-h, --help: Displays this message.");
104 System.out.println();
105 System.out.println(
"----------------");
106 System.out.println(
"2007, matsim.org");
107 System.out.println();
114 public void run(
final String[] args) {
130 if (this.eventsfile == null) {
131 this.eventsfile = this.config.
getParam(
"events",
"inputFile");
133 System.out.println(
"reading events from " + this.eventsfile);
134 File file =
new File(this.eventsfile);
135 String outputDir = file.getParent() +
"/";
141 System.out.println(
"done.");
153 this.eventsfile = eventsFile.getAbsolutePath();
157 System.out.println(
"The snapshotPeriod must be larger than 0 seconds.");
165 if (this.eventsfile == null) {
166 this.eventsfile = this.config.
getParam(
"events",
"inputFile");
168 System.out.println(
"reading events from " + this.eventsfile);
169 File file =
new File(this.eventsfile);
170 String outputDir = file.getParent() +
"/";
177 catch (OutOfMemoryError e) {
178 System.err.println(
"OutOfMemoryError while reading all events:");
180 System.err.println(
"Trying to close visualizer file up to this state, it may not be complete though.");
183 System.out.println(
"done.");
203 if (this.writer != null) {
209 for( SnapshotFormat snapshotFormat : snapshotFormats ){
210 switch( snapshotFormat ){
212 String snapshotFile = outputDir +
"T.veh";
221 throw new IllegalStateException(
"Unexpected value: " + snapshotFormat );
226 public static void main(
final String[] args) {
final String getParam(final String moduleName, final String paramName)
void run(final File eventsFile, final Config config, final Network network)
void loadSnapshotWriters(final String outputDir)
final NetworkConfigGroup network()
static Config loadConfig(final String filename, ConfigGroup... customModules)
SnapshotGenerator visualizer
void addHandler(final EventHandler handler)
void run(final String[] args)
final void addSnapshotWriter(final SnapshotWriter writer)
void readFile(final String filename)
void parseArguments(final String[] args)
static EventsManager createEventsManager()
final ControllerConfigGroup controller()
Collection< SnapshotFormat > getSnapshotFormat()
final GlobalConfigGroup global()
static Scenario createScenario(final Config config)
static void main(final String[] args)
void addExternalSnapshotWriter(final SnapshotWriter writer)
Iterator< String > iterator()
double getSnapshotPeriod()