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
MSCalibrator.h
Go to the documentation of this file.
1
/****************************************************************************/
9
// Calibrates the flow on an edge by removing an inserting vehicles
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2005-2014 DLR (http://www.dlr.de/) and contributors
13
/****************************************************************************/
14
//
15
// This file is part of SUMO.
16
// SUMO is free software: you can redistribute it and/or modify
17
// it under the terms of the GNU General Public License as published by
18
// the Free Software Foundation, either version 3 of the License, or
19
// (at your option) any later version.
20
//
21
/****************************************************************************/
22
#ifndef MSCalibrator_h
23
#define MSCalibrator_h
24
25
26
// ===========================================================================
27
// included modules
28
// ===========================================================================
29
#ifdef _MSC_VER
30
#include <
windows_config.h
>
31
#else
32
#include <
config.h
>
33
#endif
34
35
#include <string>
36
#include <vector>
37
#include <
utils/common/Command.h
>
38
#include <
microsim/MSRouteHandler.h
>
39
#include <
microsim/output/MSMeanData_Net.h
>
40
#include <
microsim/trigger/MSTrigger.h
>
41
42
43
// ===========================================================================
44
// class declarations
45
// ===========================================================================
46
class
OutputDevice
;
47
class
MSRouteProbe
;
48
49
50
// ===========================================================================
51
// class definitions
52
// ===========================================================================
57
class
MSCalibrator
:
public
MSTrigger
,
public
MSRouteHandler
,
public
Command
{
58
public
:
60
MSCalibrator
(
const
std::string&
id
,
61
const
MSEdge
*
const
edge,
const
SUMOReal
pos,
62
const
std::string& aXMLFilename,
63
const
std::string& outputFilename,
64
const
SUMOTime
freq,
const
SUMOReal
length,
65
const
MSRouteProbe
* probe,
const
bool
addLaneMeanData =
true
);
66
68
virtual
~MSCalibrator
();
69
70
73
virtual
SUMOTime
execute
(
SUMOTime
currentTime);
74
76
static
void
cleanup
();
77
78
79
80
protected
:
82
83
91
virtual
void
myStartElement
(
int
element,
92
const
SUMOSAXAttributes
& attrs);
93
100
virtual
void
myEndElement
(
int
element);
102
103
104
105
class
VehicleRemover
:
public
MSMoveReminder
{
106
public
:
107
VehicleRemover
(
MSLane
* lane,
int
laneIndex,
MSCalibrator
* parent) :
108
MSMoveReminder
(parent->
getID
(), lane, true),
myLaneIndex
(laneIndex),
myParent
(parent) {}
109
111
112
123
virtual
bool
notifyEnter
(
SUMOVehicle
& veh,
Notification
reason);
124
125
void
disable
() {
126
myParent
= 0;
127
}
128
129
private
:
130
int
myLaneIndex
;
131
MSCalibrator
*
myParent
;
132
};
133
friend
class
VehicleRemover
;
134
135
// @return whether the current state is active (GUI)
136
bool
isActive
()
const
{
137
return
myAmActive
;
138
}
139
140
protected
:
141
142
struct
AspiredState
{
143
AspiredState
() :
begin
(-1),
end
(-1),
q
(-1.),
v
(-1.),
vehicleParameter
(0) {}
144
SUMOTime
begin
;
145
SUMOTime
end
;
146
SUMOReal
q
;
147
SUMOReal
v
;
148
SUMOVehicleParameter
*
vehicleParameter
;
149
};
150
151
void
writeXMLOutput
();
152
153
bool
isCurrentStateActive
(
SUMOTime
time);
154
155
bool
tryEmit
(
MSLane
* lane,
MSVehicle
* vehicle);
156
157
void
init
();
158
159
inline
virtual
int
passed
()
const
{
160
// calibrator measures at start of segment
161
// vehicles drive to the end of an edge by default so they count as passed
162
// but vaporized vehicles do not count
163
// if the calibrator is located on a short edge, the vehicles are
164
// vaporized on the next edge so we cannot rely on myEdgeMeanData.nVehVaporized
165
return
myEdgeMeanData
.
nVehEntered
+
myEdgeMeanData
.
nVehDeparted
-
myClearedInJam
-
myRemoved
;
166
}
167
169
int
totalWished
()
const
;
170
171
/* @brief returns whether the lane is jammed although it should not be
172
* @param[in] lane The lane to check or all for negative values
173
*/
174
bool
invalidJam
(
int
laneIndex)
const
;
175
176
inline
int
inserted
()
const
{
177
return
myInserted
;
178
}
179
inline
int
removed
()
const
{
180
return
myRemoved
;
181
}
182
inline
int
clearedInJam
()
const
{
183
return
myClearedInJam
;
184
}
185
186
/* @brief returns the number of vehicles (of the current type) that still
187
* fit on the given lane
188
* @param[in] lane The lane to check (return the maximum of all lanes for negative values)
189
*/
190
int
remainingVehicleCapacity
(
int
laneIndex)
const
;
191
193
virtual
void
reset
();
194
196
virtual
void
updateMeanData
();
197
200
bool
scheduleRemoval
(
MSVehicle
* veh) {
201
return
myToRemove
.insert(veh->
getID
()).second;
202
};
203
204
207
bool
removePending
();
208
209
protected
:
211
const
MSEdge
*
const
myEdge
;
213
const
SUMOReal
myPos
;
215
const
MSRouteProbe
*
const
myProbe
;
217
std::vector<MSMeanData_Net::MSLaneMeanDataValues*>
myLaneMeanData
;
219
MSMeanData_Net::MSLaneMeanDataValues
myEdgeMeanData
;
221
std::vector<AspiredState>
myIntervals
;
223
std::vector<AspiredState>::const_iterator
myCurrentStateInterval
;
224
225
std::vector<VehicleRemover*>
myVehicleRemovers
;
226
231
std::set<std::string>
myToRemove
;
232
234
OutputDevice
*
myOutput
;
235
237
SUMOTime
myFrequency
;
239
unsigned
int
myRemoved
;
241
unsigned
int
myInserted
;
243
unsigned
int
myClearedInJam
;
245
bool
mySpeedIsDefault
;
247
bool
myDidSpeedAdaption
;
249
bool
myDidInit
;
251
SUMOReal
myDefaultSpeed
;
253
bool
myHaveWarnedAboutClearingJam
;
254
256
bool
myAmActive
;
257
258
/* @brief objects which need to live longer than the MSCalibrator
259
* instance which created them */
260
static
std::vector<MSMoveReminder*>
LeftoverReminders
;
261
static
std::vector<SUMOVehicleParameter*>
LeftoverVehicleParameters
;
262
263
};
264
265
#endif
266
267
/****************************************************************************/
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
trigger
MSCalibrator.h
Generated on Thu Nov 20 2014 19:49:54 for SUMO - Simulation of Urban MObility by
1.8.1.2