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 =
"";
80 "Change Vehicle Type State: unsupported variable " +
toHex(variable, 2)
81 +
" specified", outputStorage);
113 return server.
writeErrorStatusCmd(cmd,
"Setting length requires a double.", outputStorage);
115 if (value <= 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
118 libsumo::VehicleType::setLength(
id, value);
124 return server.
writeErrorStatusCmd(cmd,
"Setting height requires a double.", outputStorage);
126 if (value <= 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
129 libsumo::VehicleType::setHeight(
id, value);
135 return server.
writeErrorStatusCmd(cmd,
"Setting maximum speed requires a double.", outputStorage);
137 if (value <= 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
140 libsumo::VehicleType::setMaxSpeed(
id, value);
146 return server.
writeErrorStatusCmd(cmd,
"Setting vehicle class requires a string.", outputStorage);
149 libsumo::VehicleType::setVehicleClass(
id, vclass);
151 return server.
writeErrorStatusCmd(cmd,
"Unknown vehicle class '" + vclass +
"'.", outputStorage);
158 return server.
writeErrorStatusCmd(cmd,
"Setting speed factor requires a double.", outputStorage);
160 if (value <= 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
163 libsumo::VehicleType::setSpeedFactor(
id, value);
169 return server.
writeErrorStatusCmd(cmd,
"Setting speed deviation requires a double.", outputStorage);
171 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
174 libsumo::VehicleType::setSpeedDeviation(
id, value);
180 return server.
writeErrorStatusCmd(cmd,
"Setting emission class requires a string.", outputStorage);
183 libsumo::VehicleType::setEmissionClass(
id, eclass);
194 if (value <= 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
197 libsumo::VehicleType::setWidth(
id, value);
203 return server.
writeErrorStatusCmd(cmd,
"Setting minimum gap requires a double.", outputStorage);
205 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
208 libsumo::VehicleType::setMinGap(
id, value);
214 return server.
writeErrorStatusCmd(cmd,
"Setting minimum lateral gap requires a double.", outputStorage);
216 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
219 libsumo::VehicleType::setMinGapLat(
id, value);
225 return server.
writeErrorStatusCmd(cmd,
"Setting maximum lateral speed requires a double.", outputStorage);
227 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
230 libsumo::VehicleType::setMaxSpeedLat(
id, value);
234 std::string latAlign;
236 return server.
writeErrorStatusCmd(cmd,
"Setting preferred lateral alignment requires a string.",
240 libsumo::VehicleType::setLateralAlignment(
id, latAlign);
249 return server.
writeErrorStatusCmd(cmd,
"Setting vehicle shape requires a string.", outputStorage);
252 libsumo::VehicleType::setShapeClass(
id, sclass);
261 return server.
writeErrorStatusCmd(cmd,
"Setting acceleration requires a double.", outputStorage);
263 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
266 libsumo::VehicleType::setAccel(
id, value);
272 return server.
writeErrorStatusCmd(cmd,
"Setting deceleration requires a double.", outputStorage);
274 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
277 libsumo::VehicleType::setDecel(
id, value);
283 return server.
writeErrorStatusCmd(cmd,
"Setting deceleration requires a double.", outputStorage);
285 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
288 libsumo::VehicleType::setEmergencyDecel(
id, value);
294 return server.
writeErrorStatusCmd(cmd,
"Setting deceleration requires a double.", outputStorage);
296 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
299 libsumo::VehicleType::setApparentDecel(
id, value);
307 if (fabs(value) == std::numeric_limits<double>::infinity()) {
310 bool resetActionOffset = value >= 0.0;
311 libsumo::VehicleType::setActionStepLength(
id, fabs(value), resetActionOffset);
317 return server.
writeErrorStatusCmd(cmd,
"Setting driver imperfection requires a double.", outputStorage);
319 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
322 libsumo::VehicleType::setImperfection(
id, value);
328 return server.
writeErrorStatusCmd(cmd,
"Setting headway time requires a double.", outputStorage);
330 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
333 libsumo::VehicleType::setTau(
id, value);
339 return server.
writeErrorStatusCmd(cmd,
"The color must be given using the according type.", outputStorage);
341 libsumo::VehicleType::setColor(
id, col);
345 std::string newTypeID;
350 libsumo::VehicleType::copy(
id, newTypeID);
355 return server.
writeErrorStatusCmd(cmd,
"A compound object is needed for setting a parameter.",
362 return server.
writeErrorStatusCmd(cmd,
"The name of the parameter must be given as a string.",
367 return server.
writeErrorStatusCmd(cmd,
"The value of the parameter must be given as a string.",
370 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_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