SUMO - Simulation of Urban MObility
Command_SaveTLCoupledLaneDet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Writes e2 state of a link for the time the link has yellow/red
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
33 #include <microsim/MSNet.h>
37 #include <microsim/MSLinkCont.h>
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
47  MSDetectorFileOutput* dtf, SUMOTime begin, OutputDevice& device, MSLink* link)
48  : Command_SaveTLCoupledDet(tlls, dtf, begin, device),
49  myLink(link), myLastState(LINKSTATE_TL_RED),
50  myHadOne(false) {
51  execute();
52 }
53 
54 
56 }
57 
58 
59 void
61  if (myLink->getState() == myLastState && myHadOne) {
62  return;
63  }
64  myHadOne = true;
67  if (myStartTime != end) {
69  myStartTime = end;
70  }
71  } else if (myLink->getState() == LINKSTATE_TL_RED) {
72  myDetector->reset();
74  }
76 }
77 
78 
79 
80 /****************************************************************************/
81 
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:167
Writes e2 state on each tls switch.
SUMOTime myStartTime
The last time the values were written.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:253
Command_SaveTLCoupledLaneDet(MSTLLogicControl::TLSLogicVariants &tlls, MSDetectorFileOutput *dtf, SUMOTime begin, OutputDevice &device, MSLink *link)
Constructor.
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:70
long long int SUMOTime
Definition: TraCIDefs.h:51
OutputDevice & myDevice
The file to write the output to.
MSDetectorFileOutput * myDetector
The detector to use.
Base of value-generating classes (detectors)