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 /****************************************************************************/
17 // Writes e2 state of a link for the time the link has yellow/red
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
27 #include <microsim/MSNet.h>
31 #include <microsim/MSLinkCont.h>
35 
36 
37 // ===========================================================================
38 // method definitions
39 // ===========================================================================
41  MSDetectorFileOutput* dtf, SUMOTime begin, OutputDevice& device, MSLink* link)
42  : Command_SaveTLCoupledDet(tlls, dtf, begin, device),
43  myLink(link), myLastState(LINKSTATE_TL_RED),
44  myHadOne(false) {
45  execute();
46 }
47 
48 
50 }
51 
52 
53 void
55  if (myLink->getState() == myLastState && myHadOne) {
56  return;
57  }
58  myHadOne = true;
61  if (myStartTime != end) {
63  myStartTime = end;
64  }
65  } else if (myLink->getState() == LINKSTATE_TL_RED) {
66  myDetector->reset();
68  }
70 }
71 
72 
73 
74 /****************************************************************************/
75 
Command_SaveTLCoupledDet::myDevice
OutputDevice & myDevice
The file to write the output to.
Definition: Command_SaveTLCoupledDet.h:79
Command_SaveTLCoupledDet::myDetector
MSDetectorFileOutput * myDetector
The detector to use.
Definition: Command_SaveTLCoupledDet.h:85
MSNet.h
MSDetectorFileOutput
Base of value-generating classes (detectors)
Definition: MSDetectorFileOutput.h:64
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
MsgHandler.h
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSDetectorFileOutput.h
MSTrafficLightLogic.h
Command_SaveTLCoupledDet
Writes e2 state on each tls switch.
Definition: Command_SaveTLCoupledDet.h:49
Command_SaveTLCoupledLaneDet.h
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:284
Command_SaveTLCoupledLaneDet::myLink
MSLink * myLink
The link to observe.
Definition: Command_SaveTLCoupledLaneDet.h:75
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:115
Command_SaveTLCoupledLaneDet::myHadOne
bool myHadOne
Whether the last link state was already saved.
Definition: Command_SaveTLCoupledLaneDet.h:81
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
Command_SaveTLCoupledLaneDet::myLastState
LinkState myLastState
The state the link had the last time.
Definition: Command_SaveTLCoupledLaneDet.h:78
Command_SaveTLCoupledLaneDet::~Command_SaveTLCoupledLaneDet
~Command_SaveTLCoupledLaneDet()
Destructor.
Definition: Command_SaveTLCoupledLaneDet.cpp:49
MSTLLogicControl::TLSLogicVariants
Storage for all programs of a single tls.
Definition: MSTLLogicControl.h:86
config.h
LINKSTATE_TL_RED
The link has red light (must brake)
Definition: SUMOXMLDefinitions.h:1138
MSEventControl.h
Command_SaveTLCoupledLaneDet::execute
void execute()
Executes the command.
Definition: Command_SaveTLCoupledLaneDet.cpp:54
Command_SaveTLCoupledDet::myStartTime
SUMOTime myStartTime
The last time the values were written.
Definition: Command_SaveTLCoupledDet.h:88
Command_SaveTLCoupledLaneDet::Command_SaveTLCoupledLaneDet
Command_SaveTLCoupledLaneDet(MSTLLogicControl::TLSLogicVariants &tlls, MSDetectorFileOutput *dtf, SUMOTime begin, OutputDevice &device, MSLink *link)
Constructor.
Definition: Command_SaveTLCoupledLaneDet.cpp:40