Path: blob/main/src/traci-server/TraCIServerAPI_Junction.cpp
193716 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2009-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_Junction.cpp14/// @author Daniel Krajzewicz15/// @author Laura Bieker16/// @author Michael Behrisch17/// @author Mario Krumnow18/// @author Jakob Erdmann19/// @date 07.05.200920///21// APIs for getting/setting junction values via TraCI22/****************************************************************************/23#include <config.h>2425#include <microsim/MSJunctionControl.h>26#include "TraCIServer.h"27#include <libsumo/Junction.h>28#include <libsumo/StorageHelper.h>29#include "TraCIServerAPI_Junction.h"303132// ===========================================================================33// method definitions34// ===========================================================================35bool36TraCIServerAPI_Junction::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) {43return server.writeErrorStatusCmd(libsumo::CMD_SET_JUNCTION_VARIABLE, "Set Junction Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);44}45// id46std::string id = inputStorage.readString();47// process48try {49switch (variable) {50case libsumo::VAR_PARAMETER: {51StoHelp::readCompound(inputStorage, 2, "A compound object of size 2 is needed for setting a parameter.");52const std::string name = StoHelp::readTypedString(inputStorage, "The name of the parameter must be given as a string.");53const std::string value = StoHelp::readTypedString(inputStorage, "The value of the parameter must be given as a string.");54libsumo::Junction::setParameter(id, name, value);55break;56}57default:58break;59}60} catch (libsumo::TraCIException& e) {61return server.writeErrorStatusCmd(libsumo::CMD_SET_JUNCTION_VARIABLE, e.what(), outputStorage);62}63server.writeStatusCmd(libsumo::CMD_SET_JUNCTION_VARIABLE, libsumo::RTYPE_OK, warning, outputStorage);64return true;65}666768/****************************************************************************/697071