Eclipse SUMO - Simulation of Urban MObility
TraCIServerAPI_MultiEntryExit.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
16 // APIs for getting/setting multi-entry/multi-exit detector values via TraCI
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
26 #include <libsumo/MultiEntryExit.h>
27 #include <libsumo/TraCIConstants.h>
29 
30 
31 // ===========================================================================
32 // method definitions
33 // ===========================================================================
34 bool
36  tcpip::Storage& outputStorage) {
37  const int variable = inputStorage.readUnsignedByte();
38  const std::string id = inputStorage.readString();
40  try {
41  if (!libsumo::MultiEntryExit::handleVariable(id, variable, &server)) {
42  return server.writeErrorStatusCmd(libsumo::CMD_GET_MULTIENTRYEXIT_VARIABLE, "Get Multi Entry Exit Detector Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
43  }
44  } catch (libsumo::TraCIException& e) {
45  return server.writeErrorStatusCmd(libsumo::CMD_GET_MULTIENTRYEXIT_VARIABLE, e.what(), outputStorage);
46  }
48  server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
49  return true;
50 }
51 
52 
53 /****************************************************************************/
MultiEntryExit.h
libsumo::RTYPE_OK
TRACI_CONST int RTYPE_OK
Definition: TraCIConstants.h:353
MSDetectorControl.h
TraCIServer::writeResponseWithLength
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
Definition: TraCIServer.cpp:1368
libsumo::MultiEntryExit::handleVariable
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: MultiEntryExit.cpp:104
TraCIServerAPI_MultiEntryExit::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa1: Get MeMeDetector Variable)
Definition: TraCIServerAPI_MultiEntryExit.cpp:35
TraCIServer::getWrapperStorage
tcpip::Storage & getWrapperStorage()
Definition: TraCIServer.cpp:175
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:967
TraCIServer::initWrapper
void initWrapper(const int domainID, const int variable, const std::string &objID)
Definition: TraCIServer.cpp:103
libsumo::RESPONSE_GET_MULTIENTRYEXIT_VARIABLE
TRACI_CONST int RESPONSE_GET_MULTIENTRYEXIT_VARIABLE
Definition: TraCIConstants.h:109
tcpip::Storage::readUnsignedByte
virtual int readUnsignedByte()
tcpip::Storage::readString
virtual std::string readString()
TraCIConstants.h
toHex
std::string toHex(const T i, std::streamsize numDigits=0)
Definition: ToString.h:58
libsumo::TraCIException
Definition: TraCIDefs.h:90
TraCIServerAPI_MultiEntryExit.h
libsumo::CMD_GET_MULTIENTRYEXIT_VARIABLE
TRACI_CONST int CMD_GET_MULTIENTRYEXIT_VARIABLE
Definition: TraCIConstants.h:107
config.h
TraCIServer
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:62
tcpip::Storage
Definition: storage.h:36
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:981