00001 /****************************************************************************/ 00007 // Writes the state of the tls to a file (in each second) 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 // =========================================================================== 00020 // included modules 00021 // =========================================================================== 00022 #ifdef _MSC_VER 00023 #include <windows_config.h> 00024 #else 00025 #include <config.h> 00026 #endif 00027 00028 #include "Command_SaveTLSState.h" 00029 #include <microsim/traffic_lights/MSTrafficLightLogic.h> 00030 #include <microsim/MSEventControl.h> 00031 #include <microsim/MSNet.h> 00032 #include <utils/common/UtilExceptions.h> 00033 #include <utils/common/MsgHandler.h> 00034 #include <utils/iodevices/OutputDevice.h> 00035 00036 #ifdef CHECK_MEMORY_LEAKS 00037 #include <foreign/nvwa/debug_new.h> 00038 #endif // CHECK_MEMORY_LEAKS 00039 00040 00041 // =========================================================================== 00042 // method definitions 00043 // =========================================================================== 00044 Command_SaveTLSState::Command_SaveTLSState(const MSTLLogicControl::TLSLogicVariants &logics, 00045 OutputDevice &od) throw() 00046 : myOutputDevice(od), myLogics(logics) { 00047 MSNet::getInstance()->getEndOfTimestepEvents().addEvent(this, 00048 0, MSEventControl::ADAPT_AFTER_EXECUTION); 00049 myOutputDevice.writeXMLHeader("tls-states"); 00050 } 00051 00052 00053 Command_SaveTLSState::~Command_SaveTLSState() throw() { 00054 } 00055 00056 00057 SUMOTime 00058 Command_SaveTLSState::execute(SUMOTime currentTime) throw(ProcessError) { 00059 myOutputDevice << " <tlsstate time=\"" << time2string(currentTime) 00060 << "\" id=\"" << myLogics.getActive()->getID() 00061 << "\" subid=\"" << myLogics.getActive()->getSubID() 00062 << "\" phase=\"" << myLogics.getActive()->getCurrentPhaseIndex() 00063 << "\" state=\"" << myLogics.getActive()->getCurrentPhaseDef().getState() << "\"/>\n"; 00064 return DELTA_T; 00065 } 00066 00067 00068 00069 /****************************************************************************/
1.5.6