SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Command_SaveTLCoupledLaneDet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Writes e2 state of a link for the time the link has yellow/red
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-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 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
34 #include <microsim/MSNet.h>
38 #include <microsim/MSLinkCont.h>
42 
43 #ifdef CHECK_MEMORY_LEAKS
44 #include <foreign/nvwa/debug_new.h>
45 #endif // CHECK_MEMORY_LEAKS
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
52  MSDetectorFileOutput* dtf, unsigned int begin, OutputDevice& device, MSLink* link)
53  : Command_SaveTLCoupledDet(tlls, dtf, begin, device),
54  myLink(link), myLastState(LINKSTATE_TL_RED),
55  myHadOne(false) {
56  execute();
57 }
58 
59 
61 }
62 
63 
64 void
66  if (myLink->getState() == myLastState && myHadOne) {
67  return;
68  }
69  myHadOne = true;
72  if (myStartTime != end) {
74  myStartTime = end;
75  }
76  } else if (myLink->getState() == LINKSTATE_TL_RED) {
77  myDetector->reset();
79  }
81 }
82 
83 
84 
85 /****************************************************************************/
86 
bool myHadOne
Whether the last link state was already saved.
Storage for all programs of a single tls.
MSLink * myLink
The link to observe.
virtual void reset()
Resets collected values.
LinkState myLastState
The state the link had the last time.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:216
Command_SaveTLCoupledLaneDet(MSTLLogicControl::TLSLogicVariants &tlls, MSDetectorFileOutput *dtf, unsigned int begin, OutputDevice &device, MSLink *link)
Constructor.
Writes e2 state on each tls switch.
SUMOTime myStartTime
The last time the values were written.
void execute()
Executes the command.
The link has red light (must brake)
virtual void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)=0
Write the generated output to the given device.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
OutputDevice & myDevice
The file to write the output to.
MSDetectorFileOutput * myDetector
The detector to use.
Base of value-generating classes (detectors)