SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // Writes e2 state of a link for the time the link has yellow/red 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 00023 00024 // =========================================================================== 00025 // included modules 00026 // =========================================================================== 00027 #ifdef _MSC_VER 00028 #include <windows_config.h> 00029 #else 00030 #include <config.h> 00031 #endif 00032 00033 #include "Command_SaveTLCoupledLaneDet.h" 00034 #include <microsim/MSNet.h> 00035 #include <microsim/traffic_lights/MSTrafficLightLogic.h> 00036 #include <microsim/MSEventControl.h> 00037 #include <microsim/output/MSDetectorFileOutput.h> 00038 #include <microsim/MSLinkCont.h> 00039 #include <utils/common/UtilExceptions.h> 00040 #include <utils/common/MsgHandler.h> 00041 #include <utils/iodevices/OutputDevice.h> 00042 00043 #ifdef CHECK_MEMORY_LEAKS 00044 #include <foreign/nvwa/debug_new.h> 00045 #endif // CHECK_MEMORY_LEAKS 00046 00047 00048 // =========================================================================== 00049 // method definitions 00050 // =========================================================================== 00051 Command_SaveTLCoupledLaneDet::Command_SaveTLCoupledLaneDet(MSTLLogicControl::TLSLogicVariants& tlls, 00052 MSDetectorFileOutput* dtf, unsigned int begin, OutputDevice& device, MSLink* link) 00053 : Command_SaveTLCoupledDet(tlls, dtf, begin, device), 00054 myLink(link), myLastState(LINKSTATE_TL_RED), 00055 myHadOne(false) { 00056 execute(); 00057 } 00058 00059 00060 Command_SaveTLCoupledLaneDet::~Command_SaveTLCoupledLaneDet() { 00061 } 00062 00063 00064 void 00065 Command_SaveTLCoupledLaneDet::execute() { 00066 if (myLink->getState() == myLastState && myHadOne) { 00067 return; 00068 } 00069 myHadOne = true; 00070 if (myLastState == LINKSTATE_TL_RED && myLink->getState() != LINKSTATE_TL_RED) { 00071 SUMOTime end = MSNet::getInstance()->getCurrentTimeStep(); 00072 if (myStartTime != end) { 00073 myDetector->writeXMLOutput(myDevice, myStartTime, end); 00074 myStartTime = end; 00075 } 00076 } else if (myLink->getState() == LINKSTATE_TL_RED) { 00077 myDetector->reset(); 00078 myStartTime = MSNet::getInstance()->getCurrentTimeStep(); 00079 } 00080 myLastState = myLink->getState(); 00081 } 00082 00083 00084 00085 /****************************************************************************/ 00086