#include <TraCIServerAPI_VehicleType.h>
Definition at line 43 of file TraCIServerAPI_VehicleType.h.
Static Public Member Functions | |
| static bool | processGet (tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, bool withStatus=true) throw (traci::TraCIException) |
| Processes a get value command (Command 0xa5: Get Vehicle Type Variable). | |
| static bool | processSet (tcpip::Storage &inputStorage, tcpip::Storage &outputStorage) throw (traci::TraCIException) |
| Processes a set value command (Command 0xc5: Change Vehicle Type State). | |
Private Member Functions | |
| TraCIServerAPI_VehicleType & | operator= (const TraCIServerAPI_VehicleType &s) |
| invalidated assignment operator | |
| TraCIServerAPI_VehicleType (const TraCIServerAPI_VehicleType &s) | |
| invalidated copy constructor | |
| TraCIServerAPI_VehicleType::TraCIServerAPI_VehicleType | ( | const TraCIServerAPI_VehicleType & | s | ) | [private] |
invalidated copy constructor
| TraCIServerAPI_VehicleType& TraCIServerAPI_VehicleType::operator= | ( | const TraCIServerAPI_VehicleType & | s | ) | [private] |
invalidated assignment operator
| bool TraCIServerAPI_VehicleType::processGet | ( | tcpip::Storage & | inputStorage, | |
| tcpip::Storage & | outputStorage, | |||
| bool | withStatus = true | |||
| ) | throw (traci::TraCIException) [static] |
Processes a get value command (Command 0xa5: Get Vehicle Type Variable).
| [in] | inputStorage | The storage to read the command from |
| [out] | outputStorage | The storage to write the result to |
| [in] | withStatus | Whether the status message shall be written (not in subscription) |
Definition at line 53 of file TraCIServerAPI_VehicleType.cpp.
References RGBColor::blue(), CMD_GET_VEHICLETYPE_VARIABLE, MSVehicleType::getCarFollowModel(), MSVehicleType::getColor(), MSVehicleType::getEmissionClass(), MSVehicleType::getGuiOffset(), MSVehicleType::getGuiShape(), MSVehicleType::getGuiWidth(), MSNet::getInstance(), MSVehicleType::getLength(), MSCFModel::getMaxAccel(), MSCFModel::getMaxDecel(), MSVehicleType::getMaxSpeed(), MSCFModel::getTau(), MSVehicleType::getVehicleClass(), getVehicleClassName(), MSNet::getVehicleControl(), getVehicleEmissionTypeName(), getVehicleShapeName(), MSVehicleControl::getVType(), RGBColor::green(), ID_LIST, MSVehicleControl::insertVTypeIDs(), RGBColor::red(), RESPONSE_GET_VEHICLETYPE_VARIABLE, RTYPE_ERR, RTYPE_OK, tcpip::Storage::size(), TYPE_COLOR, TYPE_FLOAT, TYPE_STRING, TYPE_STRINGLIST, VAR_ACCEL, VAR_COLOR, VAR_DECEL, VAR_EMISSIONCLASS, VAR_GUIOFFSET, VAR_LENGTH, VAR_MAXSPEED, VAR_SHAPECLASS, VAR_TAU, VAR_VEHICLECLASS, VAR_WIDTH, tcpip::Storage::writeFloat(), TraCIServerAPIHelper::writeStatusCmd(), tcpip::Storage::writeString(), tcpip::Storage::writeStringList(), and tcpip::Storage::writeUnsignedByte().
Referenced by traci::TraCIServer::dispatchCommand(), and traci::TraCIServer::processSingleSubscription().
00055 { 00056 std::string warning = ""; // additional description for response 00057 // variable & id 00058 int variable = inputStorage.readUnsignedByte(); 00059 std::string id = inputStorage.readString(); 00060 // check variable 00061 if (variable!=ID_LIST&&variable!=VAR_LENGTH&&variable!=VAR_MAXSPEED&&variable!=VAR_ACCEL&&variable!=VAR_DECEL 00062 &&variable!=VAR_TAU&&variable!=VAR_VEHICLECLASS&&variable!=VAR_EMISSIONCLASS&&variable!=VAR_SHAPECLASS 00063 &&variable!=VAR_GUIOFFSET&&variable!=VAR_WIDTH&&variable!=VAR_COLOR) { 00064 TraCIServerAPIHelper::writeStatusCmd(CMD_GET_VEHICLETYPE_VARIABLE, RTYPE_ERR, "Get Vehicle Type Variable: unsupported variable specified", outputStorage); 00065 return false; 00066 } 00067 // begin response building 00068 Storage tempMsg; 00069 // response-code, variableID, objectID 00070 tempMsg.writeUnsignedByte(RESPONSE_GET_VEHICLETYPE_VARIABLE); 00071 tempMsg.writeUnsignedByte(variable); 00072 tempMsg.writeString(id); 00073 // process request 00074 if (variable==ID_LIST) { 00075 std::vector<std::string> ids; 00076 MSNet::getInstance()->getVehicleControl().insertVTypeIDs(ids); 00077 tempMsg.writeUnsignedByte(TYPE_STRINGLIST); 00078 tempMsg.writeStringList(ids); 00079 } else { 00080 MSVehicleType *v = MSNet::getInstance()->getVehicleControl().getVType(id); 00081 if (v==0) { 00082 TraCIServerAPIHelper::writeStatusCmd(CMD_GET_VEHICLETYPE_VARIABLE, RTYPE_ERR, "Vehicle type '" + id + "' is not known", outputStorage); 00083 return false; 00084 } 00085 switch (variable) { 00086 case VAR_LENGTH: 00087 tempMsg.writeUnsignedByte(TYPE_FLOAT); 00088 tempMsg.writeFloat(v->getLength()); 00089 break; 00090 case VAR_MAXSPEED: 00091 tempMsg.writeUnsignedByte(TYPE_FLOAT); 00092 tempMsg.writeFloat(v->getMaxSpeed()); 00093 break; 00094 case VAR_ACCEL: 00095 tempMsg.writeUnsignedByte(TYPE_FLOAT); 00096 tempMsg.writeFloat(v->getCarFollowModel().getMaxAccel(0)); 00097 break; 00098 case VAR_DECEL: 00099 tempMsg.writeUnsignedByte(TYPE_FLOAT); 00100 tempMsg.writeFloat(v->getCarFollowModel().getMaxDecel()); 00101 break; 00102 case VAR_TAU: 00103 tempMsg.writeUnsignedByte(TYPE_FLOAT); 00104 tempMsg.writeFloat(v->getCarFollowModel().getTau()); 00105 break; 00106 case VAR_VEHICLECLASS: 00107 tempMsg.writeUnsignedByte(TYPE_STRING); 00108 tempMsg.writeString(getVehicleClassName(v->getVehicleClass())); 00109 break; 00110 case VAR_EMISSIONCLASS: 00111 tempMsg.writeUnsignedByte(TYPE_STRING); 00112 tempMsg.writeString(getVehicleEmissionTypeName(v->getEmissionClass())); 00113 break; 00114 case VAR_SHAPECLASS: 00115 tempMsg.writeUnsignedByte(TYPE_STRING); 00116 tempMsg.writeString(getVehicleShapeName(v->getGuiShape())); 00117 break; 00118 case VAR_GUIOFFSET: 00119 tempMsg.writeUnsignedByte(TYPE_FLOAT); 00120 tempMsg.writeFloat(v->getGuiOffset()); 00121 break; 00122 case VAR_WIDTH: 00123 tempMsg.writeUnsignedByte(TYPE_FLOAT); 00124 tempMsg.writeFloat(v->getGuiWidth()); 00125 break; 00126 case VAR_COLOR: 00127 tempMsg.writeUnsignedByte(TYPE_COLOR); 00128 tempMsg.writeUnsignedByte((int)(v->getColor().red()*255.)); 00129 tempMsg.writeUnsignedByte((int)(v->getColor().green()*255.)); 00130 tempMsg.writeUnsignedByte((int)(v->getColor().blue()*255.)); 00131 tempMsg.writeUnsignedByte(255); 00132 break; 00133 default: 00134 break; 00135 } 00136 } 00137 if (withStatus) { 00138 TraCIServerAPIHelper::writeStatusCmd(CMD_GET_VEHICLETYPE_VARIABLE, RTYPE_OK, warning, outputStorage); 00139 } 00140 // send response 00141 outputStorage.writeUnsignedByte(0); // command length -> extended 00142 outputStorage.writeInt(1 + 4 + tempMsg.size()); 00143 outputStorage.writeStorage(tempMsg); 00144 return true; 00145 }
| bool TraCIServerAPI_VehicleType::processSet | ( | tcpip::Storage & | inputStorage, | |
| tcpip::Storage & | outputStorage | |||
| ) | throw (traci::TraCIException) [static] |
Processes a set value command (Command 0xc5: Change Vehicle Type State).
| [in] | inputStorage | The storage to read the command from |
| [out] | outputStorage | The storage to write the result to |
Definition at line 149 of file TraCIServerAPI_VehicleType.cpp.
1.5.6