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-2017 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 
44 // ===========================================================================
45 // method definitions
46 // ===========================================================================
48  MSDetectorFileOutput* dtf, SUMOTime begin, OutputDevice& device, MSLink* link)
49  : Command_SaveTLCoupledDet(tlls, dtf, begin, device),
50  myLink(link), myLastState(LINKSTATE_TL_RED),
51  myHadOne(false) {
52  execute();
53 }
54 
55 
57 }
58 
59 
60 void
62  if (myLink->getState() == myLastState && myHadOne) {
63  return;
64  }
65  myHadOne = true;
68  if (myStartTime != end) {
70  myStartTime = end;
71  }
72  } else if (myLink->getState() == LINKSTATE_TL_RED) {
73  myDetector->reset();
75  }
77 }
78 
79 
80 
81 /****************************************************************************/
82 
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:158
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:257
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
long long int SUMOTime
Definition: TraCIDefs.h:52
OutputDevice & myDevice
The file to write the output to.
MSDetectorFileOutput * myDetector
The detector to use.
Base of value-generating classes (detectors)