43 const std::string
id = inputStorage.
readString();
46 if (!libsumo::VehicleType::handleVariable(
id, variable, &server, &inputStorage)) {
48 "Get Vehicle Type Variable: unsupported variable " +
toHex(variable, 2)
49 +
" specified", outputStorage);
63 std::string warning =
"";
81 "Change Vehicle Type State: unsupported variable " +
toHex(variable, 2)
82 +
" specified", outputStorage);
114 return server.
writeErrorStatusCmd(cmd,
"Setting length requires a double.", outputStorage);
116 if (value <= 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
119 libsumo::VehicleType::setLength(
id, value);
125 return server.
writeErrorStatusCmd(cmd,
"Setting height requires a double.", outputStorage);
127 if (value <= 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
130 libsumo::VehicleType::setHeight(
id, value);
136 return server.
writeErrorStatusCmd(cmd,
"Setting maximum speed requires a double.", outputStorage);
138 if (value <= 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
141 libsumo::VehicleType::setMaxSpeed(
id, value);
147 return server.
writeErrorStatusCmd(cmd,
"Setting vehicle class requires a string.", outputStorage);
150 libsumo::VehicleType::setVehicleClass(
id, vclass);
152 return server.
writeErrorStatusCmd(cmd,
"Unknown vehicle class '" + vclass +
"'.", outputStorage);
159 return server.
writeErrorStatusCmd(cmd,
"Setting speed factor requires a double.", outputStorage);
161 if (value <= 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
164 libsumo::VehicleType::setSpeedFactor(
id, value);
170 return server.
writeErrorStatusCmd(cmd,
"Setting speed deviation requires a double.", outputStorage);
172 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
175 libsumo::VehicleType::setSpeedDeviation(
id, value);
181 return server.
writeErrorStatusCmd(cmd,
"Setting emission class requires a string.", outputStorage);
184 libsumo::VehicleType::setEmissionClass(
id, eclass);
195 if (value <= 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
198 libsumo::VehicleType::setWidth(
id, value);
204 return server.
writeErrorStatusCmd(cmd,
"Setting minimum gap requires a double.", outputStorage);
206 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
209 libsumo::VehicleType::setMinGap(
id, value);
215 return server.
writeErrorStatusCmd(cmd,
"Setting minimum lateral gap requires a double.", outputStorage);
217 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
220 libsumo::VehicleType::setMinGapLat(
id, value);
226 return server.
writeErrorStatusCmd(cmd,
"Setting maximum lateral speed requires a double.", outputStorage);
228 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
231 libsumo::VehicleType::setMaxSpeedLat(
id, value);
235 std::string latAlign;
237 return server.
writeErrorStatusCmd(cmd,
"Setting preferred lateral alignment requires a string.",
241 libsumo::VehicleType::setLateralAlignment(
id, latAlign);
250 return server.
writeErrorStatusCmd(cmd,
"Setting vehicle shape requires a string.", outputStorage);
253 libsumo::VehicleType::setShapeClass(
id, sclass);
262 return server.
writeErrorStatusCmd(cmd,
"Setting acceleration requires a double.", outputStorage);
264 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
267 libsumo::VehicleType::setAccel(
id, value);
273 return server.
writeErrorStatusCmd(cmd,
"Setting deceleration requires a double.", outputStorage);
275 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
278 libsumo::VehicleType::setDecel(
id, value);
284 return server.
writeErrorStatusCmd(cmd,
"Setting deceleration requires a double.", outputStorage);
286 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
289 libsumo::VehicleType::setEmergencyDecel(
id, value);
295 return server.
writeErrorStatusCmd(cmd,
"Setting deceleration requires a double.", outputStorage);
297 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
300 libsumo::VehicleType::setApparentDecel(
id, value);
306 return server.
writeErrorStatusCmd(cmd,
"Setting traffic scale requires a double.", outputStorage);
309 return server.
writeErrorStatusCmd(cmd,
"Traffic scale may not be negative.", outputStorage);
311 libsumo::VehicleType::setScale(
id, value);
319 if (fabs(value) == std::numeric_limits<double>::infinity()) {
322 bool resetActionOffset = value >= 0.0;
323 libsumo::VehicleType::setActionStepLength(
id, fabs(value), resetActionOffset);
329 return server.
writeErrorStatusCmd(cmd,
"Setting driver imperfection requires a double.", outputStorage);
331 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
334 libsumo::VehicleType::setImperfection(
id, value);
340 return server.
writeErrorStatusCmd(cmd,
"Setting headway time requires a double.", outputStorage);
342 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
345 libsumo::VehicleType::setTau(
id, value);
351 return server.
writeErrorStatusCmd(cmd,
"The color must be given using the according type.", outputStorage);
353 libsumo::VehicleType::setColor(
id, col);
357 std::string newTypeID;
362 libsumo::VehicleType::copy(
id, newTypeID);
367 return server.
writeErrorStatusCmd(cmd,
"A compound object is needed for setting a parameter.",
374 return server.
writeErrorStatusCmd(cmd,
"The name of the parameter must be given as a string.",
379 return server.
writeErrorStatusCmd(cmd,
"The value of the parameter must be given as a string.",
382 libsumo::VehicleType::setParameter(
id, name, value);
std::string toHex(const T i, std::streamsize numDigits=0)
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc5: Change Vehicle Type State)
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa5: Get Vehicle Type Variable)
static bool setVariable(const int cmd, const int variable, const std::string &id, TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value for the given type.
TraCI server used to control sumo by a remote TraCI client.
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
tcpip::Storage & getWrapperStorage()
void initWrapper(const int domainID, const int variable, const std::string &objID)
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
bool readTypeCheckingColor(tcpip::Storage &inputStorage, libsumo::TraCIColor &into)
Reads the value type and a color, verifying the type.
An error which allows to continue.
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST int VAR_VEHICLECLASS
TRACI_CONST int VAR_LATALIGNMENT
TRACI_CONST int VAR_SCALE
TRACI_CONST int VAR_MINGAP
TRACI_CONST int VAR_SHAPECLASS
TRACI_CONST int VAR_ACTIONSTEPLENGTH
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_WIDTH
TRACI_CONST int VAR_MAXSPEED
TRACI_CONST int CMD_SET_VEHICLE_VARIABLE
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_MAXSPEED_LAT
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int CMD_SET_VEHICLETYPE_VARIABLE
TRACI_CONST int CMD_GET_VEHICLETYPE_VARIABLE
TRACI_CONST int VAR_IMPERFECTION
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int VAR_APPARENT_DECEL
TRACI_CONST int VAR_DECEL
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int VAR_EMERGENCY_DECEL
TRACI_CONST int RESPONSE_GET_VEHICLETYPE_VARIABLE
TRACI_CONST int VAR_EMISSIONCLASS
TRACI_CONST int VAR_ACCEL
TRACI_CONST int VAR_SPEED_DEVIATION