Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2016 Fraunhofer ESK
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Karsten Roscher <karsten.roscher@esk.fraunhofer.de>
*/
#include "sumo-config.h"
#include "traci-util.h"
namespace ns3 {
SumoConfig::SumoConfig(std::string listDelimiter,
std::string customNameDelimiter)
: m_listDelimiter (listDelimiter),
m_customNameDelimiter (customNameDelimiter)
{
}
void
SumoConfig::SetupCommandLine (CommandLine& cmd)
{
cmd.AddValue ("sumo-config", "SUMO configuration file", m_config);
cmd.AddValue ("sumo-network", "SUMO network file", m_network);
cmd.AddValue ("sumo-routes", "SUMO routes file", m_routes);
cmd.AddValue ("sumo-add", "SUMO additional files, separated by comma", m_additional);
cmd.AddValue ("sumo-seed", "SUMO seed for the random generator (must be an integer)", m_seed);
cmd.AddValue ("sumo-step", "SUMO simulation step length in seconds (float)", m_step);
cmd.AddValue ("sumo-begin", "SUMO begin time in seconds (must be a number)", m_begin);
cmd.AddValue ("sumo-load-state", "Load SUMO state from this file", m_loadState);
cmd.AddValue ("sumo-args", "SUMO custom command line options with ':' instead of spaces", m_args);
cmd.AddValue ("sumo-copy", "List of files to copy to the SUMO launcher, separated by ':'", m_copy);
cmd.AddValue ("sumo-fcd-output", "Filename for fcd output of the SUMO launcher", m_fcd_out);
cmd.AddValue ("sumo-fcd-accel", "Log acceleration in fcd output", m_fcd_accel);
cmd.AddValue ("sumo-lat-resolution", "Lateral resolution for the SUMO sub-lane model", m_lat_resolution);
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
}
bool
SumoConfig::HasRunArguments () const
{
return !m_config.empty () || !m_network.empty () || !m_routes.empty () ||
!m_additional.empty () || !m_args.empty ();
}
SumoConfig::ArgumentList
SumoConfig::GetRunArguments () const
{
ArgumentList list;
if (!m_config.empty ())
{
list.push_back ("-c");
list.push_back (m_config);
}
if (!m_network.empty ())
{
list.push_back ("-n");
list.push_back (m_network);
}
if (!m_routes.empty ())
{
list.push_back ("-r");
list.push_back (m_routes);
}
if (!m_additional.empty ())
{
list.push_back ("-a");
list.push_back (m_additional);
}
if (!m_seed.empty ())
{
list.push_back ("--seed");
list.push_back (m_seed);
}
if (!m_step.empty ())
{
list.push_back ("--step-length");
list.push_back (m_step);
}
if (!m_begin.empty ())
{
list.push_back ("--begin");
list.push_back (m_begin);
}
if (!m_loadState.empty ())
{
list.push_back ("--load-state");
list.push_back (m_loadState);
}
if (!m_fcd_out.empty ())
{
list.push_back ("--fcd-output");
list.push_back (m_fcd_out);
if (m_fcd_accel)
{
list.push_back ("--fcd-output.acceleration");
}
}
if (!m_lat_resolution.empty ())
{
list.push_back ("--lateral-resolution");
list.push_back (m_lat_resolution);
}
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
if (!m_args.empty ())
{
traci::TokenizeString (m_args, list, m_listDelimiter);
}
return list;
}
SumoConfig::CopyFileList
SumoConfig::GetFilesToCopy () const
{
CopyFileList list;
if (m_copy.empty ())
{
// return empty list
return list;
}
traci::StringList files;
traci::TokenizeString (m_copy, files, m_listDelimiter);
for (traci::StringList::const_iterator it = files.begin (); it != files.end (); ++it)
{
std::size_t pos = it->rfind(m_customNameDelimiter);
std::string srcName(*it);
std::string dstName("");
if (pos != std::string::npos)
{
// found a delimiter, split string
srcName = it->substr (0, pos);
dstName = it->substr (pos + m_customNameDelimiter.size ());
}
list.push_back(std::make_pair(srcName, dstName));
}
return list;
}
void
SumoConfig::SetConfiguration (std::string config)
{
m_config = config;
}
void
SumoConfig::SetNetwork (std::string network)
{
m_network = network;
}
void
SumoConfig::SetRoutes (std::string routes)
{
m_routes = routes;
}
void
SumoConfig::SetAdditionalFiles (std::string add)
{
m_additional = add;
}
void
SumoConfig::SetSeed (std::string seed)
{
m_seed = seed;
}
void
SumoConfig::SetStep (std::string step)
{
m_step = step;
}
void
SumoConfig::SetBegin (std::string begin)
{
m_begin = begin;
}
void
SumoConfig::SetLoadState (std::string stateFile)
{
m_loadState = stateFile;
}
void
SumoConfig::SetArguments (std::string arguments)
{
m_args = arguments;
}
void
SumoConfig::SetFilesToCopy (std::string copy)
{
m_copy = copy;
}
void
SumoConfig::SetFcdOutput (std::string fcd_file)
{
m_fcd_out = fcd_file;
}
void
SumoConfig::SetFcdAccel (bool log_accel)
{
m_fcd_accel = log_accel;
}
void
SumoConfig::SetLatResolution (std::string resolution)
{
m_lat_resolution = resolution;
}