Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others. 4 : // This program and the accompanying materials are made available under the 5 : // terms of the Eclipse Public License 2.0 which is available at 6 : // https://www.eclipse.org/legal/epl-2.0/ 7 : // This Source Code may also be made available under the following Secondary 8 : // Licenses when the conditions for such availability set forth in the Eclipse 9 : // Public License 2.0 are satisfied: GNU General Public License, version 2 10 : // or later which is available at 11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 13 : /****************************************************************************/ 14 : /// @file Command_SaveTLCoupledDet.cpp 15 : /// @author Daniel Krajzewicz 16 : /// @author Michael Behrisch 17 : /// @date 15 Feb 2004 18 : /// 19 : // Writes e2 state on each tls switch 20 : /****************************************************************************/ 21 : #include <config.h> 22 : 23 : #include "Command_SaveTLCoupledDet.h" 24 : #include <microsim/MSNet.h> 25 : #include <microsim/traffic_lights/MSTrafficLightLogic.h> 26 : #include <microsim/MSEventControl.h> 27 : #include <microsim/output/MSDetectorFileOutput.h> 28 : #include <utils/common/UtilExceptions.h> 29 : #include <utils/common/MsgHandler.h> 30 : #include <utils/iodevices/OutputDevice.h> 31 : 32 : 33 : // =========================================================================== 34 : // method definitions 35 : // =========================================================================== 36 1071 : Command_SaveTLCoupledDet::Command_SaveTLCoupledDet(MSTLLogicControl::TLSLogicVariants& tlls, 37 1071 : MSDetectorFileOutput* dtf, SUMOTime begin, OutputDevice& device) 38 1071 : : myDevice(device), myLogics(tlls), myDetector(dtf), 39 1071 : myStartTime(begin) { 40 1071 : tlls.addSwitchCommand(this); 41 1071 : dtf->writeXMLDetectorProlog(device); 42 1071 : } 43 : 44 : 45 2134 : Command_SaveTLCoupledDet::~Command_SaveTLCoupledDet() { 46 2134 : } 47 : 48 : 49 : void 50 113448 : Command_SaveTLCoupledDet::execute() { 51 113448 : SUMOTime end = MSNet::getInstance()->getCurrentTimeStep(); 52 113448 : if (myStartTime != end) { 53 112420 : myDetector->writeXMLOutput(myDevice, myStartTime, end); 54 112420 : myStartTime = end; 55 : } 56 113448 : } 57 : 58 : 59 : /****************************************************************************/