1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
10 /// @file SystemFrame.cpp
11 /// @author Daniel Krajzewicz
12 /// @author Jakob Erdmann
13 /// @author Michael Behrisch
14 /// @date Mon, 23.06.2003
15 /// @version $Id$
16 ///
17 // A set of actions common to all applications
18 /****************************************************************************/
19
20
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25
26 #include "SystemFrame.h"
27 #include <string>
28 #include <utils/xml/XMLSubSys.h>
29 #include <utils/common/StdDefs.h>
30 #include <utils/common/MsgHandler.h>
31 #include <utils/options/OptionsCont.h>
32 #include <utils/iodevices/OutputDevice.h>
33 #include "RandHelper.h"
34
35
36 // ===========================================================================
37 // method definitions
38 // ===========================================================================
39 void
addConfigurationOptions(OptionsCont & oc)40 SystemFrame::addConfigurationOptions(OptionsCont& oc) {
41 oc.addOptionSubTopic("Configuration");
42
43 oc.doRegister("configuration-file", 'c', new Option_FileName());
44 oc.addSynonyme("configuration-file", "configuration");
45 oc.addDescription("configuration-file", "Configuration", "Loads the named config on startup");
46 oc.addXMLDefault("configuration-file");
47
48 oc.doRegister("save-configuration", 'C', new Option_FileName());
49 oc.addSynonyme("save-config", "save-configuration");
50 oc.addDescription("save-configuration", "Configuration", "Saves current configuration into FILE");
51
52 oc.doRegister("save-template", new Option_FileName());
53 oc.addDescription("save-template", "Configuration", "Saves a configuration template (empty) into FILE");
54
55 oc.doRegister("save-schema", new Option_FileName());
56 oc.addDescription("save-schema", "Configuration", "Saves the configuration schema into FILE");
57
58 oc.doRegister("save-commented", new Option_Bool(false));
59 oc.addSynonyme("save-commented", "save-template.commented");
60 oc.addDescription("save-commented", "Configuration", "Adds comments to saved template, configuration, or schema");
61 }
62
63
64 void
addReportOptions(OptionsCont & oc)65 SystemFrame::addReportOptions(OptionsCont& oc) {
66 oc.addOptionSubTopic("Report");
67
68 oc.doRegister("verbose", 'v', new Option_Bool(false));
69 oc.addDescription("verbose", "Report", "Switches to verbose output");
70
71 oc.doRegister("print-options", new Option_Bool(false));
72 oc.addDescription("print-options", "Report", "Prints option values before processing");
73
74 oc.doRegister("help", '?', new Option_BoolExtended(false));
75 oc.addDescription("help", "Report", "Prints this screen or selected topics");
76
77 oc.doRegister("version", 'V', new Option_Bool(false));
78 oc.addDescription("version", "Report", "Prints the current version");
79
80 oc.doRegister("xml-validation", 'X', new Option_String("auto"));
81 oc.addDescription("xml-validation", "Report", "Set schema validation scheme of XML inputs (\"never\", \"auto\" or \"always\")");
82
83 oc.doRegister("xml-validation.net", new Option_String("never"));
84 oc.addDescription("xml-validation.net", "Report", "Set schema validation scheme of SUMO network inputs (\"never\", \"auto\" or \"always\")");
85
86 oc.doRegister("no-warnings", 'W', new Option_Bool(false));
87 oc.addSynonyme("no-warnings", "suppress-warnings", true);
88 oc.addDescription("no-warnings", "Report", "Disables output of warnings");
89
90 oc.doRegister("log", 'l', new Option_FileName());
91 oc.addSynonyme("log", "log-file");
92 oc.addDescription("log", "Report", "Writes all messages to FILE (implies verbose)");
93
94 oc.doRegister("message-log", new Option_FileName());
95 oc.addDescription("message-log", "Report", "Writes all non-error messages to FILE (implies verbose)");
96
97 oc.doRegister("error-log", new Option_FileName());
98 oc.addDescription("error-log", "Report", "Writes all warnings and errors to FILE");
99
100 oc.doRegister("write-license", new Option_Bool(false));
101 oc.addDescription("write-license", "Output", "Include license info into every output file");
102
103 oc.doRegister("output-prefix", new Option_String());
104 oc.addDescription("output-prefix", "Output", "Prefix which is applied to all output files. The special string 'TIME' is replaced by the current time.");
105
106 oc.doRegister("precision", new Option_Integer(2));
107 oc.addDescription("precision", "Output", "Defines the number of digits after the comma for floating point output");
108
109 oc.doRegister("precision.geo", new Option_Integer(6));
110 oc.addDescription("precision.geo", "Output", "Defines the number of digits after the comma for lon,lat output");
111
112 oc.doRegister("human-readable-time", 'H', new Option_Bool(false));
113 oc.addDescription("human-readable-time", "Output", "Write time values as hour:minute:second or day:hour:minute:second rathern than seconds");
114 }
115
116
117 bool
checkOptions()118 SystemFrame::checkOptions() {
119 OptionsCont& oc = OptionsCont::getOptions();
120 gPrecision = oc.getInt("precision");
121 gPrecisionGeo = oc.getInt("precision.geo");
122 gHumanReadableTime = oc.getBool("human-readable-time");
123 if (oc.exists("weights.random-factor")) {
124 gWeightsRandomFactor = oc.getFloat("weights.random-factor");
125 }
126 return true;
127 }
128
129
130 void
close()131 SystemFrame::close() {
132 // close all output devices
133 OutputDevice::closeAll();
134 // close the xml-subsystem
135 XMLSubSys::close();
136 // delete build program options
137 OptionsCont::getOptions().clear();
138 // delete messages
139 MsgHandler::cleanupOnEnd();
140 }
141
142
143 /****************************************************************************/
144
145