43std::vector<std::string>
44Rerouter::getIDList() {
46 std::vector<std::string> ids;
48 ids.push_back(item.first);
54Rerouter::getIDCount() {
60Rerouter::getParameter(
const std::string& rerouterID,
const std::string& param) {
61 if (param ==
"probability") {
62 return toString(getRerouter(rerouterID)->getProbability());
72Rerouter::setParameter(
const std::string& rerouterID,
const std::string& key,
const std::string& value) {
74 if (key ==
"probability") {
82 throw TraCIException(
"Invalid value '" + value +
"' for parameter '" + key +
"' for rerouter '" + rerouterID +
"'");
84 if (prob < 0. || prob > 1.) {
85 throw TraCIException(
"Invalid value '" + value +
"' for parameter '" + key +
"' for rerouter '" + rerouterID +
"'");
91 throw TraCIException(
"Rerouter '" + rerouterID +
"' does not support parameter '" + key +
"'");
100Rerouter::getRerouter(
const std::string&
id) {
103 const auto it = instances.find(
id);
104 if (it == instances.end()) {
105 throw TraCIException(
"Rerouter '" +
id +
"' is not known");
111std::shared_ptr<VariableWrapper>
112Rerouter::makeWrapper() {
113 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
118Rerouter::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
121 return wrapper->wrapStringList(objID, variable, getIDList());
123 return wrapper->wrapInt(objID, variable, getIDCount());
126 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
129 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Reroutes traffic objects passing an edge.
void setUserUsageProbability(double prob)
Sets the probability with which a vehicle is rerouted given by the user.
static const std::map< std::string, MSTriggeredRerouter * > & getInstances()
return all rerouter instances
void setUserMode(bool val)
Sets whether the process is currently steered by the user.
C++ TraCI client API implementation.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
virtual std::string readString()
virtual int readUnsignedByte()
@ value
the parser finished reading a JSON value
TRACI_CONST int TRACI_ID_LIST
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_PARAMETER_WITH_KEY