Path: blob/main/src/traci-server/TraCIServerAPI_LaneArea.cpp
193867 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2014-2026 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 TraCIServerAPI_LaneArea.cpp14/// @author Mario Krumnow15/// @author Robbin Blokpoel16/// @author Daniel Krajzewicz17/// @author Michael Behrisch18/// @date 03.02.201419///20// APIs for getting/setting areal detector values via TraCI21/****************************************************************************/22#include <config.h>2324#include <microsim/output/MSDetectorControl.h>25#include <libsumo/LaneArea.h>26#include <libsumo/TraCIConstants.h>27#include <libsumo/StorageHelper.h>28#include "TraCIServer.h"29#include "TraCIServerAPI_LaneArea.h"303132// ===========================================================================33// method definitions34// ===========================================================================35bool36TraCIServerAPI_LaneArea::processSet(TraCIServer& server, tcpip::Storage& inputStorage,37tcpip::Storage& outputStorage) {38std::string warning = ""; // additional description for response39// variable40int variable = inputStorage.readUnsignedByte();41if (variable != libsumo::VAR_PARAMETER42&& variable != libsumo::VAR_VIRTUAL_DETECTION43) {44return server.writeErrorStatusCmd(libsumo::CMD_SET_LANEAREA_VARIABLE, "Set Lane Area Detector Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);45}46// id47std::string id = inputStorage.readString();48// process49try {50switch (variable) {51case libsumo::VAR_VIRTUAL_DETECTION: {52const int vehNum = StoHelp::readTypedInt(inputStorage, "Overriding the number of detected vehicles requires an integer");53libsumo::LaneArea::overrideVehicleNumber(id, vehNum);54break;55}56case libsumo::VAR_PARAMETER: {57StoHelp::readCompound(inputStorage, 2, "A compound object of size 2 is needed for setting a parameter.");58const std::string name = StoHelp::readTypedString(inputStorage, "The name of the parameter must be given as a string.");59const std::string value = StoHelp::readTypedString(inputStorage, "The value of the parameter must be given as a string.");60libsumo::LaneArea::setParameter(id, name, value);61break;62}63default:64break;65}66} catch (libsumo::TraCIException& e) {67return server.writeErrorStatusCmd(libsumo::CMD_SET_LANEAREA_VARIABLE, e.what(), outputStorage);68}69server.writeStatusCmd(libsumo::CMD_SET_LANEAREA_VARIABLE, libsumo::RTYPE_OK, warning, outputStorage);70return true;71}727374/****************************************************************************/757677