#include <TraCIServerAPI_Junction.h>
Definition at line 43 of file TraCIServerAPI_Junction.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 0xa9: Get Junction Variable). | |
Private Member Functions | |
| TraCIServerAPI_Junction & | operator= (const TraCIServerAPI_Junction &s) |
| invalidated assignment operator | |
| TraCIServerAPI_Junction (const TraCIServerAPI_Junction &s) | |
| invalidated copy constructor | |
| TraCIServerAPI_Junction::TraCIServerAPI_Junction | ( | const TraCIServerAPI_Junction & | s | ) | [private] |
invalidated copy constructor
| TraCIServerAPI_Junction& TraCIServerAPI_Junction::operator= | ( | const TraCIServerAPI_Junction & | s | ) | [private] |
invalidated assignment operator
| bool TraCIServerAPI_Junction::processGet | ( | tcpip::Storage & | inputStorage, | |
| tcpip::Storage & | outputStorage, | |||
| bool | withStatus = true | |||
| ) | throw (traci::TraCIException) [static] |
Processes a get value command (Command 0xa9: Get Junction 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 54 of file TraCIServerAPI_Junction.cpp.
References CMD_GET_JUNCTION_VARIABLE, NamedObjectCont< T >::get(), MSNet::getInstance(), MSNet::getJunctionControl(), MSJunction::getPosition(), ID_LIST, NamedObjectCont< T >::insertIDs(), RESPONSE_GET_JUNCTION_VARIABLE, RTYPE_ERR, RTYPE_OK, tcpip::Storage::size(), TYPE_POSITION2D, TYPE_STRINGLIST, VAR_POSITION, tcpip::Storage::writeFloat(), TraCIServerAPIHelper::writeStatusCmd(), tcpip::Storage::writeString(), tcpip::Storage::writeStringList(), tcpip::Storage::writeUnsignedByte(), Position2D::x(), and Position2D::y().
Referenced by traci::TraCIServer::dispatchCommand(), and traci::TraCIServer::processSingleSubscription().
00056 { 00057 Storage tmpResult; 00058 std::string warning = ""; // additional description for response 00059 // variable 00060 int variable = inputStorage.readUnsignedByte(); 00061 std::string id = inputStorage.readString(); 00062 // check variable 00063 if (variable!=ID_LIST&&variable!=VAR_POSITION) { 00064 TraCIServerAPIHelper::writeStatusCmd(CMD_GET_JUNCTION_VARIABLE, RTYPE_ERR, "Get Junction 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_JUNCTION_VARIABLE); 00071 tempMsg.writeUnsignedByte(variable); 00072 tempMsg.writeString(id); 00073 if (variable==ID_LIST) { 00074 std::vector<std::string> ids; 00075 MSNet::getInstance()->getJunctionControl().insertIDs(ids); 00076 tempMsg.writeUnsignedByte(TYPE_STRINGLIST); 00077 tempMsg.writeStringList(ids); 00078 } else { 00079 MSJunction *j = MSNet::getInstance()->getJunctionControl().get(id); 00080 if (j==0) { 00081 TraCIServerAPIHelper::writeStatusCmd(CMD_GET_JUNCTION_VARIABLE, RTYPE_ERR, "Junction '" + id + "' is not known", outputStorage); 00082 return false; 00083 } 00084 switch (variable) { 00085 case ID_LIST: 00086 break; 00087 case VAR_POSITION: 00088 tempMsg.writeUnsignedByte(TYPE_POSITION2D); 00089 tempMsg.writeFloat(j->getPosition().x()); 00090 tempMsg.writeFloat(j->getPosition().y()); 00091 break; 00092 default: 00093 break; 00094 } 00095 } 00096 if (withStatus) { 00097 TraCIServerAPIHelper::writeStatusCmd(CMD_GET_JUNCTION_VARIABLE, RTYPE_OK, warning, outputStorage); 00098 } 00099 // send response 00100 outputStorage.writeUnsignedByte(0); // command length -> extended 00101 outputStorage.writeInt(1 + 4 + tempMsg.size()); 00102 outputStorage.writeStorage(tempMsg); 00103 return true; 00104 }
1.5.6