Path: blob/main/src/traci-server/TraCIServerAPI_ParkingArea.cpp
193674 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-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_ParkingArea.cpp14/// @author Jakob Erdmann15/// @date 16.03.202016///17// APIs for getting/setting parking area values via TraCI18/****************************************************************************/19#include <config.h>2021#include <microsim/MSNet.h>22#include <microsim/MSEdge.h>23#include <microsim/MSStoppingPlace.h>24#include <libsumo/ParkingArea.h>25#include <libsumo/StorageHelper.h>26#include <libsumo/TraCIConstants.h>27#include "TraCIServerAPI_ParkingArea.h"282930// ===========================================================================31// method definitions32// ===========================================================================33bool34TraCIServerAPI_ParkingArea::processSet(TraCIServer& server, tcpip::Storage& inputStorage,35tcpip::Storage& outputStorage) {36std::string warning = ""; // additional description for response37// variable38int variable = inputStorage.readUnsignedByte();39if (variable != libsumo::VAR_PARAMETER &&40variable != libsumo::VAR_ACCESS_BADGE) {41return server.writeErrorStatusCmd(libsumo::CMD_SET_PARKINGAREA_VARIABLE, "Change ParkingArea State: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);42}43// id44std::string id = inputStorage.readString();4546try {47// process48switch (variable) {49case libsumo::VAR_PARAMETER: {50StoHelp::readCompound(inputStorage, 2, "A compound object of size 2 is needed for setting a parameter.");51const std::string name = StoHelp::readTypedString(inputStorage, "The name of the parameter must be given as a string.");52const std::string value = StoHelp::readTypedString(inputStorage, "The value of the parameter must be given as a string.");53libsumo::ParkingArea::setParameter(id, name, value);54break;55}56case libsumo::VAR_ACCESS_BADGE:57libsumo::ParkingArea::setAcceptedBadges(id, StoHelp::readTypedStringList(inputStorage, "A string list is needed to update the ParkingArea access badges."));58break;59default:60break;61}62} catch (libsumo::TraCIException& e) {63return server.writeErrorStatusCmd(libsumo::CMD_SET_PARKINGAREA_VARIABLE, e.what(), outputStorage);64}65server.writeStatusCmd(libsumo::CMD_SET_PARKINGAREA_VARIABLE, libsumo::RTYPE_OK, warning, outputStorage);66return true;67}686970/****************************************************************************/717273