SUMO - Simulation of Urban MObility
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.dlr.de/
12 // Copyright (C) 2001-2015 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, SUMOTime 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 
long long int SUMOTime
Definition: SUMOTime.h:43
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:162
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:255
Writes e2 state on each tls switch.
SUMOTime myStartTime
The last time the values were written.
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:71
OutputDevice & myDevice
The file to write the output to.
MSDetectorFileOutput * myDetector
The detector to use.
Base of value-generating classes (detectors)