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
Command_SaveTLSSwitchStates.cpp
Go to the documentation of this file.
1
/****************************************************************************/
8
// Writes the switch times of a tls into a file when the tls switches
9
/****************************************************************************/
10
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11
// Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
12
/****************************************************************************/
13
//
14
// This file is part of SUMO.
15
// SUMO is free software: you can redistribute it and/or modify
16
// it under the terms of the GNU General Public License as published by
17
// the Free Software Foundation, either version 3 of the License, or
18
// (at your option) any later version.
19
//
20
/****************************************************************************/
21
// ===========================================================================
22
// included modules
23
// ===========================================================================
24
#ifdef _MSC_VER
25
#include <
windows_config.h
>
26
#else
27
#include <
config.h
>
28
#endif
29
30
#include "
Command_SaveTLSSwitchStates.h
"
31
#include <
microsim/traffic_lights/MSTrafficLightLogic.h
>
32
#include <
microsim/MSEventControl.h
>
33
#include <
microsim/MSNet.h
>
34
#include <
utils/common/UtilExceptions.h
>
35
#include <
utils/common/MsgHandler.h
>
36
#include <
utils/iodevices/OutputDevice.h
>
37
38
#ifdef CHECK_MEMORY_LEAKS
39
#include <
foreign/nvwa/debug_new.h
>
40
#endif // CHECK_MEMORY_LEAKS
41
42
43
// ===========================================================================
44
// method definitions
45
// ===========================================================================
46
Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates
(
const
MSTLLogicControl::TLSLogicVariants
& logics,
47
OutputDevice
& od)
48
: myOutputDevice(od), myLogics(logics) {
49
MSNet::getInstance
()->
getEndOfTimestepEvents
().
addEvent
(
this
, 0,
MSEventControl::ADAPT_AFTER_EXECUTION
);
50
myOutputDevice
.
writeXMLHeader
(
"tls-switch-states"
);
51
}
52
53
54
Command_SaveTLSSwitchStates::~Command_SaveTLSSwitchStates
() {
55
}
56
57
58
SUMOTime
59
Command_SaveTLSSwitchStates::execute
(
SUMOTime
currentTime) {
60
const
std::string& state =
myLogics
.
getActive
()->
getCurrentPhaseDef
().
getState
();
61
if
(state !=
myPreviousState
||
myLogics
.
getActive
()->
getProgramID
() !=
myPreviousProgramID
) {
62
myOutputDevice
<<
" <tlsstate time=\""
<<
time2string
(currentTime)
63
<<
"\" id=\""
<<
myLogics
.
getActive
()->
getID
()
64
<<
"\" programID=\""
<<
myLogics
.
getActive
()->
getProgramID
()
65
<<
"\" phase=\""
<<
myLogics
.
getActive
()->
getCurrentPhaseIndex
()
66
<<
"\" state=\""
<< state <<
"\"/>\n"
;
67
myPreviousState
= state;
68
myPreviousProgramID
=
myLogics
.
getActive
()->
getProgramID
();
69
}
70
return
DELTA_T
;
71
}
72
73
74
75
/****************************************************************************/
76
build
buildd
sumo-0.18~dfsg
src
microsim
actions
Command_SaveTLSSwitchStates.cpp
Generated on Wed Oct 23 2013 01:15:07 for SUMO - Simulation of Urban MObility by
1.8.4