/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file MEInductLoop.cpp14/// @author Daniel Krajzewicz15/// @date Tue, May 200516///17// An induction loop for mesoscopic simulation18/****************************************************************************/192021/* =========================================================================22* included modules23* ======================================================================= */24#include <config.h>2526#include "MEInductLoop.h"27#include <cassert>28#include <numeric>29#include <utility>30#include <limits>31#include <utils/common/WrappingCommand.h>32#include <utils/common/ToString.h>33#include <microsim/MSEdge.h>34#include <microsim/MSEventControl.h>35#include <mesosim/MESegment.h>36#include <utils/common/MsgHandler.h>37#include <utils/common/UtilExceptions.h>38#include <utils/common/StringUtils.h>394041// ===========================================================================42// method definitions43// ===========================================================================44MEInductLoop::MEInductLoop(const std::string& id,45MESegment* s,46double positionInMeters,47const std::string name, const std::string& vTypes,48const std::string& nextEdges,49int detectPersons) :50MSDetectorFileOutput(id, vTypes, nextEdges, detectPersons),51myName(name),52mySegment(s),53myPosition(positionInMeters),54myMeanData(nullptr, mySegment->getLength(), false, nullptr) {55myMeanData.setDescription("inductionLoop_" + id);56s->addDetector(&myMeanData);57}585960MEInductLoop::~MEInductLoop() {}616263void64MEInductLoop::writeXMLOutput(OutputDevice& dev,65SUMOTime startTime, SUMOTime stopTime) {66mySegment->prepareDetectorForWriting(myMeanData);67dev.openTag(SUMO_TAG_INTERVAL).writeAttr(SUMO_ATTR_BEGIN, time2string(startTime)).writeAttr(SUMO_ATTR_END, time2string(stopTime));68dev.writeAttr(SUMO_ATTR_ID, StringUtils::escapeXML(myID)).writeAttr("sampledSeconds", myMeanData.getSamples());69myMeanData.write(dev, 0, stopTime - startTime, (int)mySegment->getEdge().getLanes().size(), mySegment->getEdge().getSpeedLimit(), -1.0);70myMeanData.reset();71}7273const MSEdge&74MEInductLoop::getEdge() const {75return mySegment->getEdge();76}7778/****************************************************************************/798081