Eclipse SUMO - Simulation of Urban MObility
TraCIServerAPI_LaneArea.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2014-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // APIs for getting/setting areal detector values via TraCI
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
27 #include <libsumo/LaneArea.h>
28 #include <libsumo/TraCIConstants.h>
29 #include "TraCIServer.h"
31 
32 
33 // ===========================================================================
34 // method definitions
35 // ===========================================================================
36 bool
38  tcpip::Storage& outputStorage) {
39  const int variable = inputStorage.readUnsignedByte();
40  const std::string id = inputStorage.readString();
42  try {
43  if (!libsumo::LaneArea::handleVariable(id, variable, &server)) {
44  return server.writeErrorStatusCmd(libsumo::CMD_GET_LANEAREA_VARIABLE, "Get Lane Area Detector Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
45  }
46  } catch (libsumo::TraCIException& e) {
47  return server.writeErrorStatusCmd(libsumo::CMD_GET_LANEAREA_VARIABLE, e.what(), outputStorage);
48  }
50  server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
51  return true;
52 }
53 
54 
55 /****************************************************************************/
libsumo::RTYPE_OK
TRACI_CONST int RTYPE_OK
Definition: TraCIConstants.h:352
MSDetectorControl.h
LaneArea.h
TraCIServer::writeResponseWithLength
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
Definition: TraCIServer.cpp:1366
libsumo::CMD_GET_LANEAREA_VARIABLE
TRACI_CONST int CMD_GET_LANEAREA_VARIABLE
Definition: TraCIConstants.h:284
TraCIServer::getWrapperStorage
tcpip::Storage & getWrapperStorage()
Definition: TraCIServer.cpp:174
TraCIServer::writeStatusCmd
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
Definition: TraCIServer.cpp:968
TraCIServer::initWrapper
void initWrapper(const int domainID, const int variable, const std::string &objID)
Definition: TraCIServer.cpp:102
tcpip::Storage::readUnsignedByte
virtual int readUnsignedByte()
tcpip::Storage::readString
virtual std::string readString()
TraCIConstants.h
libsumo::LaneArea::handleVariable
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: LaneArea.cpp:140
toHex
std::string toHex(const T i, std::streamsize numDigits=0)
Definition: ToString.h:57
TraCIServerAPI_LaneArea.h
libsumo::TraCIException
Definition: TraCIDefs.h:89
libsumo::RESPONSE_GET_LANEAREA_VARIABLE
TRACI_CONST int RESPONSE_GET_LANEAREA_VARIABLE
Definition: TraCIConstants.h:286
TraCIServerAPI_LaneArea::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa1: Get AreaDetector Variable)
Definition: TraCIServerAPI_LaneArea.cpp:37
TraCIServer.h
config.h
TraCIServer
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:61
tcpip::Storage
Definition: storage.h:37
TraCIServer::writeErrorStatusCmd
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
Definition: TraCIServer.cpp:982