TraCIServerAPI_MeMeDetector Class Reference

#include <TraCIServerAPI_MeMeDetector.h>


Detailed Description

APIs for getting/setting multi-entry/multi-exit detector values via TraCI.

Definition at line 43 of file TraCIServerAPI_MeMeDetector.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 0xa1: Get MeMeDetector Variable).

Private Member Functions

TraCIServerAPI_MeMeDetectoroperator= (const TraCIServerAPI_MeMeDetector &s)
 invalidated assignment operator
 TraCIServerAPI_MeMeDetector (const TraCIServerAPI_MeMeDetector &s)
 invalidated copy constructor

Constructor & Destructor Documentation

TraCIServerAPI_MeMeDetector::TraCIServerAPI_MeMeDetector ( const TraCIServerAPI_MeMeDetector s  )  [private]

invalidated copy constructor


Member Function Documentation

TraCIServerAPI_MeMeDetector& TraCIServerAPI_MeMeDetector::operator= ( const TraCIServerAPI_MeMeDetector s  )  [private]

invalidated assignment operator

bool TraCIServerAPI_MeMeDetector::processGet ( tcpip::Storage inputStorage,
tcpip::Storage outputStorage,
bool  withStatus = true 
) throw (traci::TraCIException) [static]

Processes a get value command (Command 0xa1: Get MeMeDetector Variable).

Parameters:
[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_MeMeDetector.cpp.

References CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, MSE3Collector::getCurrentHaltingNumber(), MSE3Collector::getCurrentMeanSpeed(), MSE3Collector::getCurrentVehicleIDs(), MSNet::getDetectorControl(), MSDetectorControl::getE3Detectors(), MSNet::getInstance(), MSE3Collector::getVehiclesWithin(), ID_LIST, LAST_STEP_MEAN_SPEED, LAST_STEP_VEHICLE_HALTING_NUMBER, LAST_STEP_VEHICLE_ID_LIST, LAST_STEP_VEHICLE_NUMBER, RESPONSE_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, RTYPE_ERR, RTYPE_OK, tcpip::Storage::size(), TYPE_FLOAT, TYPE_INTEGER, TYPE_STRINGLIST, tcpip::Storage::writeFloat(), tcpip::Storage::writeInt(), 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!=LAST_STEP_VEHICLE_NUMBER&&variable!=LAST_STEP_MEAN_SPEED
00062             &&variable!=LAST_STEP_VEHICLE_ID_LIST&&variable!=LAST_STEP_VEHICLE_HALTING_NUMBER) {
00063         TraCIServerAPIHelper::writeStatusCmd(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, RTYPE_ERR, "Get MeMeDetector Variable: unsupported variable specified", outputStorage);
00064         return false;
00065     }
00066     // begin response building
00067     Storage tempMsg;
00068     //  response-code, variableID, objectID
00069     tempMsg.writeUnsignedByte(RESPONSE_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE);
00070     tempMsg.writeUnsignedByte(variable);
00071     tempMsg.writeString(id);
00072     if (variable==ID_LIST) {
00073         std::vector<std::string> ids;
00074         MSNet::getInstance()->getDetectorControl().getE3Detectors().insertIDs(ids);
00075         tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
00076         tempMsg.writeStringList(ids);
00077     } else {
00078         MSE3Collector *e3 = MSNet::getInstance()->getDetectorControl().getE3Detectors().get(id);
00079         if (e3==0) {
00080             TraCIServerAPIHelper::writeStatusCmd(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, RTYPE_ERR, "Areal detector '" + id + "' is not known", outputStorage);
00081             return false;
00082         }
00083         switch (variable) {
00084         case ID_LIST:
00085             break;
00086         case LAST_STEP_VEHICLE_NUMBER:
00087             tempMsg.writeUnsignedByte(TYPE_INTEGER);
00088             tempMsg.writeInt((float) e3->getVehiclesWithin());
00089             break;
00090         case LAST_STEP_MEAN_SPEED:
00091             tempMsg.writeUnsignedByte(TYPE_FLOAT);
00092             tempMsg.writeFloat((float) e3->getCurrentMeanSpeed());
00093             break;
00094         case LAST_STEP_VEHICLE_ID_LIST: {
00095             tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
00096             std::vector<std::string> ids = e3->getCurrentVehicleIDs();
00097             tempMsg.writeStringList(ids);
00098         }
00099         break;
00100         case LAST_STEP_VEHICLE_HALTING_NUMBER:
00101             tempMsg.writeUnsignedByte(TYPE_INTEGER);
00102             tempMsg.writeInt((int) e3->getCurrentHaltingNumber());
00103             break;
00104         default:
00105             break;
00106         }
00107     }
00108     if (withStatus) {
00109         TraCIServerAPIHelper::writeStatusCmd(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, RTYPE_OK, warning, outputStorage);
00110     }
00111     // send response
00112     outputStorage.writeUnsignedByte(0); // command length -> extended
00113     outputStorage.writeInt(1 + 4 + tempMsg.size());
00114     outputStorage.writeStorage(tempMsg);
00115     return true;
00116 }


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:07:01 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6