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
/****************************************************************************/
8
// Calibrates the flow on an edge by removing an inserting vehicles
9
/****************************************************************************/
10
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11
// Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
12
/****************************************************************************/
13
//
14
// This program 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 2 of the License, or
17
// (at your option) any later version.
18
//
19
/****************************************************************************/
20
#ifndef MSCalibrator_h
21
#define MSCalibrator_h
22
23
24
// ===========================================================================
25
// included modules
26
// ===========================================================================
27
#ifdef _MSC_VER
28
#include <
windows_config.h
>
29
#else
30
#include <
config.h
>
31
#endif
32
33
#include <string>
34
#include <vector>
35
#include <
utils/iodevices/OutputDevice.h
>
36
#include <
utils/common/Command.h
>
37
#include <
microsim/MSRouteHandler.h
>
38
#include <
microsim/output/MSMeanData_Net.h
>
39
#include <
microsim/trigger/MSTrigger.h
>
40
41
42
// ===========================================================================
43
// class definitions
44
// ===========================================================================
49
class
MSCalibrator
:
public
MSTrigger
,
public
MSRouteHandler
,
public
Command
{
50
public
:
52
MSCalibrator
(
const
std::string&
id
,
53
MSEdge
* edge,
SUMOReal
pos,
54
const
std::string& aXMLFilename,
55
const
std::string& outputFilename,
56
const
SUMOTime
freq);
57
59
virtual
~MSCalibrator
();
60
61
64
SUMOTime
execute
(
SUMOTime
currentTime);
65
67
static
void
cleanup
();
68
69
70
71
protected
:
73
74
82
virtual
void
myStartElement
(
int
element,
83
const
SUMOSAXAttributes
& attrs);
84
91
virtual
void
myEndElement
(
int
element);
93
94
95
96
class
VehicleRemover
:
public
MSMoveReminder
{
97
public
:
98
VehicleRemover
(
MSLane
* lane,
int
laneIndex,
MSCalibrator
* parent) :
99
MSMoveReminder
(parent->
getID
(), lane, true),
myLaneIndex
(laneIndex),
myParent
(parent) {}
100
102
103
114
virtual
bool
notifyEnter
(
SUMOVehicle
& veh,
Notification
reason);
115
116
void
disable
() {
117
myParent
= 0;
118
}
119
120
private
:
121
int
myLaneIndex
;
122
MSCalibrator
*
myParent
;
123
};
124
friend
class
VehicleRemover
;
125
126
// @return whether the current state is active (GUI)
127
bool
isActive
()
const
{
128
return
myAmActive
;
129
}
130
131
protected
:
132
133
struct
AspiredState
{
134
AspiredState
() :
begin
(-1),
end
(-1),
q
(-1.),
v
(-1.),
vehicleParameter
(0) {}
135
SUMOTime
begin
;
136
SUMOTime
end
;
137
SUMOReal
q
;
138
SUMOReal
v
;
139
SUMOVehicleParameter
*
vehicleParameter
;
140
};
141
142
void
writeXMLOutput
();
143
144
bool
isCurrentStateActive
(
SUMOTime
time);
145
146
bool
tryEmit
(
MSLane
* lane,
MSVehicle
* vehicle);
147
148
void
init
();
149
150
inline
int
passed
()
const
{
151
// calibrator measures at start of segment
152
// vehicles drive to the end of an edge by default so they count as passed
153
// but vaporized vehicles do not count
154
// if the calibrator is located on a short edge, the vehicles are
155
// vaporized on the next edge so we cannot rely on myEdgeMeanData.nVehVaporized
156
return
myEdgeMeanData
.
nVehEntered
+
myEdgeMeanData
.
nVehDeparted
-
myClearedInJam
-
myRemoved
;
157
}
158
160
int
totalWished
()
const
;
161
162
/* @brief returns whether the lane is jammed although it should not be
163
* @param[in] lane The lane to check or all for negative values
164
*/
165
bool
invalidJam
(
int
laneIndex = -1)
const
;
166
167
inline
int
inserted
()
const
{
168
return
myInserted
;
169
}
170
inline
int
removed
()
const
{
171
return
myRemoved
;
172
}
173
inline
int
clearedInJam
()
const
{
174
return
myClearedInJam
;
175
}
176
177
/* @brief returns the number of vehicles (of the current type) that still
178
* fit on the given lane
179
* @param[in] lane The lane to check (return the maximum of all lanes for negative values)
180
*/
181
int
remainingVehicleCapacity
(
int
laneIndex = -1)
const
;
182
184
void
reset
();
185
187
void
updateMeanData
();
188
191
bool
scheduleRemoval
(
MSVehicle
* veh) {
192
return
myToRemove
.insert(veh).second;
193
};
194
195
protected
:
197
MSEdge
*
const
myEdge
;
199
const
SUMOReal
myPos
;
201
std::vector<MSMeanData_Net::MSLaneMeanDataValues*>
myLaneMeanData
;
203
MSMeanData_Net::MSLaneMeanDataValues
myEdgeMeanData
;
205
std::vector<AspiredState>
myIntervals
;
207
std::vector<AspiredState>::const_iterator
myCurrentStateInterval
;
208
209
std::vector<VehicleRemover*>
myVehicleRemovers
;
210
211
std::set<MSVehicle*>
myToRemove
;
212
214
OutputDevice
*
myOutput
;
215
217
SUMOTime
myFrequency
;
219
unsigned
int
myRemoved
;
221
unsigned
int
myInserted
;
223
unsigned
int
myClearedInJam
;
225
bool
mySpeedIsDefault
;
227
bool
myDidSpeedAdaption
;
229
bool
myDidInit
;
231
SUMOReal
myDefaultSpeed
;
233
bool
myHaveWarnedAboutClearingJam
;
234
236
bool
myAmActive
;
237
238
/* @brief objects which need to live longer than the MSCalibrator
239
* instance which created them */
240
static
std::vector<MSMoveReminder*>
LeftoverReminders
;
241
static
std::vector<SUMOVehicleParameter*>
LeftoverVehicleParameters
;
242
243
};
244
245
#endif
246
247
/****************************************************************************/
build
buildd
sumo-0.18~dfsg
src
microsim
trigger
MSCalibrator.h
Generated on Wed Oct 23 2013 01:15:09 for SUMO - Simulation of Urban MObility by
1.8.4