SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
MSAmitranTrajectories.cpp
Go to the documentation of this file.
1
/****************************************************************************/
7
// Realises dumping the complete network state
8
/****************************************************************************/
9
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10
// Copyright (C) 2014-2014 DLR (http://www.dlr.de/) and contributors
11
/****************************************************************************/
12
//
13
// This file is part of SUMO.
14
// SUMO is free software: you can redistribute it and/or modify
15
// it under the terms of the GNU General Public License as published by
16
// the Free Software Foundation, either version 3 of the License, or
17
// (at your option) any later version.
18
//
19
/****************************************************************************/
20
21
22
// ===========================================================================
23
// included modules
24
// ===========================================================================
25
#ifdef _MSC_VER
26
#include <
windows_config.h
>
27
#else
28
#include <
config.h
>
29
#endif
30
31
#include <
microsim/MSVehicleControl.h
>
32
#include <
microsim/MSEdge.h
>
33
#include <
microsim/MSLane.h
>
34
#include <
microsim/MSNet.h
>
35
#include <
microsim/MSVehicle.h
>
36
#include <
microsim/MSGlobals.h
>
37
#include <
utils/iodevices/OutputDevice.h
>
38
#include <
utils/emissions/PollutantsInterface.h
>
39
#include "
MSAmitranTrajectories.h
"
40
41
#ifdef CHECK_MEMORY_LEAKS
42
#include <
foreign/nvwa/debug_new.h
>
43
#endif // CHECK_MEMORY_LEAKS
44
45
// ===========================================================================
46
// static member definitions
47
// ===========================================================================
48
std::set<std::string>
MSAmitranTrajectories::myWrittenTypes
;
49
std::map<std::string, int>
MSAmitranTrajectories::myWrittenVehicles
;
50
51
52
// ===========================================================================
53
// method definitions
54
// ===========================================================================
55
void
56
MSAmitranTrajectories::write
(
OutputDevice
& of,
const
SUMOTime
timestep) {
57
MSVehicleControl
& vc =
MSNet::getInstance
()->
getVehicleControl
();
58
for
(
MSVehicleControl::constVehIt
v = vc.
loadedVehBegin
(); v != vc.
loadedVehEnd
(); ++v) {
59
writeVehicle
(of, *v->second, timestep);
60
}
61
}
62
63
64
void
65
MSAmitranTrajectories::writeVehicle
(
OutputDevice
& of,
const
SUMOVehicle
& veh,
const
SUMOTime
timestep) {
66
if
(veh.
isOnRoad
()) {
67
const
std::string& type = veh.
getVehicleType
().
getID
();
68
if
(
myWrittenTypes
.count(type) == 0) {
69
of.
openTag
(
SUMO_TAG_ACTORCONFIG
).
writeAttr
(
SUMO_ATTR_ID
, veh.
getVehicleType
().
getNumericalID
());
70
const
SUMOEmissionClass
c = veh.
getVehicleType
().
getEmissionClass
();
71
if
(c != 0) {
72
of.
writeAttr
(
SUMO_ATTR_VEHICLECLASS
,
PollutantsInterface::getAmitranVehicleClass
(c));
73
of.
writeAttr
(
"fuel"
,
PollutantsInterface::getFuel
(c));
74
of.
writeAttr
(
SUMO_ATTR_EMISSIONCLASS
,
"Euro"
+
toString
(
PollutantsInterface::getEuroClass
(c)));
75
const
SUMOReal
weight =
PollutantsInterface::getWeight
(c);
76
if
(weight > 0.) {
77
of.
writeAttr
(
SUMO_ATTR_WEIGHT
,
int
(weight / 10. + 0.5));
78
}
79
}
80
of.
writeAttr
(
SUMO_ATTR_REF
, type).
closeTag
();
81
myWrittenTypes
.insert(type);
82
}
83
if
(
myWrittenVehicles
.count(veh.
getID
()) == 0) {
84
const
int
index = (
int
)
myWrittenVehicles
.size();
85
of.
openTag
(
SUMO_TAG_VEHICLE
).
writeAttr
(
SUMO_ATTR_ID
, index)
86
.
writeAttr
(
SUMO_ATTR_ACTORCONFIG
, veh.
getVehicleType
().
getNumericalID
())
87
.writeAttr(
SUMO_ATTR_STARTTIME
,
STEPS2MS
(veh.
getDeparture
()));
88
of.
writeAttr
(
SUMO_ATTR_REF
, veh.
getID
()).closeTag();
89
myWrittenVehicles
[veh.
getID
()] = index;
90
}
91
of.
openTag
(
SUMO_TAG_MOTIONSTATE
).
writeAttr
(
SUMO_ATTR_VEHICLE
,
myWrittenVehicles
[veh.
getID
()])
92
.writeAttr(
SUMO_ATTR_SPEED
,
int
(100.*veh.
getSpeed
() + 0.5))
93
.writeAttr(
SUMO_ATTR_TIME
,
STEPS2MS
(timestep))
94
.writeAttr(
SUMO_ATTR_ACCELERATION
,
int
(1000.*veh.
getAcceleration
() + 0.5));
95
of.
closeTag
();
96
}
97
}
98
99
100
/****************************************************************************/
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
output
MSAmitranTrajectories.cpp
Generated on Thu Nov 20 2014 19:49:54 for SUMO - Simulation of Urban MObility by
1.8.1.2