Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // Writes e2 state of a link for the time the link has yellow/red
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
26 #include <microsim/MSNet.h>
30 #include <microsim/MSLinkCont.h>
34 
35 
36 // ===========================================================================
37 // method definitions
38 // ===========================================================================
40  MSDetectorFileOutput* dtf, SUMOTime begin, OutputDevice& device, const MSLink* link)
41  : Command_SaveTLCoupledDet(tlls, dtf, begin, device),
42  myLink(link), myLastState(LINKSTATE_TL_RED),
43  myHadOne(false) {
44  execute();
45 }
46 
47 
49 }
50 
51 
52 void
54  if (myLink->getState() == myLastState && myHadOne) {
55  return;
56  }
57  myHadOne = true;
60  if (myStartTime != end) {
62  myStartTime = end;
63  }
64  } else if (myLink->getState() == LINKSTATE_TL_RED) {
65  myDetector->reset();
67  }
69 }
70 
71 
72 
73 /****************************************************************************/
74 
Command_SaveTLCoupledDet::myDevice
OutputDevice & myDevice
The file to write the output to.
Definition: Command_SaveTLCoupledDet.h:78
Command_SaveTLCoupledLaneDet::Command_SaveTLCoupledLaneDet
Command_SaveTLCoupledLaneDet(MSTLLogicControl::TLSLogicVariants &tlls, MSDetectorFileOutput *dtf, SUMOTime begin, OutputDevice &device, const MSLink *link)
Constructor.
Definition: Command_SaveTLCoupledLaneDet.cpp:39
Command_SaveTLCoupledDet::myDetector
MSDetectorFileOutput * myDetector
The detector to use.
Definition: Command_SaveTLCoupledDet.h:84
MSNet.h
MSDetectorFileOutput
Base of value-generating classes (detectors)
Definition: MSDetectorFileOutput.h:63
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MsgHandler.h
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSDetectorFileOutput.h
MSTrafficLightLogic.h
Command_SaveTLCoupledLaneDet::myLink
const MSLink * myLink
The link to observe.
Definition: Command_SaveTLCoupledLaneDet.h:74
Command_SaveTLCoupledDet
Writes e2 state on each tls switch.
Definition: Command_SaveTLCoupledDet.h:48
Command_SaveTLCoupledLaneDet.h
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:283
MSDetectorFileOutput::writeXMLOutput
virtual void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)=0
Write the generated output to the given device.
OutputDevice.h
UtilExceptions.h
MSDetectorFileOutput::reset
virtual void reset()
Resets collected values.
Definition: MSDetectorFileOutput.h:114
Command_SaveTLCoupledLaneDet::myHadOne
bool myHadOne
Whether the last link state was already saved.
Definition: Command_SaveTLCoupledLaneDet.h:80
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
Command_SaveTLCoupledLaneDet::myLastState
LinkState myLastState
The state the link had the last time.
Definition: Command_SaveTLCoupledLaneDet.h:77
Command_SaveTLCoupledLaneDet::~Command_SaveTLCoupledLaneDet
~Command_SaveTLCoupledLaneDet()
Destructor.
Definition: Command_SaveTLCoupledLaneDet.cpp:48
MSTLLogicControl::TLSLogicVariants
Storage for all programs of a single tls.
Definition: MSTLLogicControl.h:85
config.h
LINKSTATE_TL_RED
The link has red light (must brake)
Definition: SUMOXMLDefinitions.h:1143
MSEventControl.h
Command_SaveTLCoupledLaneDet::execute
void execute()
Executes the command.
Definition: Command_SaveTLCoupledLaneDet.cpp:53
Command_SaveTLCoupledDet::myStartTime
SUMOTime myStartTime
The last time the values were written.
Definition: Command_SaveTLCoupledDet.h:87