本文整理汇总了C++中TraCIServer::writeResponseWithLength方法的典型用法代码示例。如果您正苦于以下问题:C++ TraCIServer::writeResponseWithLength方法的具体用法?C++ TraCIServer::writeResponseWithLength怎么用?C++ TraCIServer::writeResponseWithLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TraCIServer
的用法示例。
在下文中一共展示了TraCIServer::writeResponseWithLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMainWindow
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_GUI::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
// variable & id
int variable = inputStorage.readUnsignedByte();
std::string id = inputStorage.readString();
// check variable
if (variable != ID_LIST && variable != VAR_VIEW_ZOOM && variable != VAR_VIEW_OFFSET
&& variable != VAR_VIEW_SCHEMA && variable != VAR_VIEW_BOUNDARY) {
return server.writeErrorStatusCmd(CMD_GET_GUI_VARIABLE, "Get GUI Variable: unsupported variable specified", outputStorage);
}
// begin response building
tcpip::Storage tempMsg;
// response-code, variableID, objectID
tempMsg.writeUnsignedByte(RESPONSE_GET_GUI_VARIABLE);
tempMsg.writeUnsignedByte(variable);
tempMsg.writeString(id);
// process request
if (variable == ID_LIST) {
std::vector<std::string> ids = getMainWindow()->getViewIDs();
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(ids);
} else {
GUISUMOAbstractView* v = getNamedView(id);
if (v == 0) {
return server.writeErrorStatusCmd(CMD_GET_GUI_VARIABLE, "View '" + id + "' is not known", outputStorage);
}
switch (variable) {
case VAR_VIEW_ZOOM:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(v->getChanger().getZoom());
break;
case VAR_VIEW_OFFSET:
tempMsg.writeUnsignedByte(POSITION_2D);
tempMsg.writeDouble(v->getChanger().getXPos());
tempMsg.writeDouble(v->getChanger().getYPos());
break;
case VAR_VIEW_SCHEMA: {
FXComboBox& c = v->getColoringSchemesCombo();
tempMsg.writeUnsignedByte(TYPE_STRING);
tempMsg.writeString((std::string)c.getItem(c.getCurrentItem()).text());
break;
}
case VAR_VIEW_BOUNDARY: {
tempMsg.writeUnsignedByte(TYPE_BOUNDINGBOX);
Boundary b = v->getVisibleBoundary();
tempMsg.writeDouble(b.xmin());
tempMsg.writeDouble(b.ymin());
tempMsg.writeDouble(b.xmax());
tempMsg.writeDouble(b.ymax());
break;
}
default:
break;
}
}
server.writeStatusCmd(CMD_GET_GUI_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例2: switch
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_POI::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
const int variable = inputStorage.readUnsignedByte();
const std::string id = inputStorage.readString();
server.initWrapper(libsumo::RESPONSE_GET_POI_VARIABLE, variable, id);
try {
if (!libsumo::POI::handleVariable(id, variable, &server)) {
switch (variable) {
case libsumo::VAR_PARAMETER: {
std::string paramName = "";
if (!server.readTypeCheckingString(inputStorage, paramName)) {
return server.writeErrorStatusCmd(libsumo::CMD_GET_POI_VARIABLE, "Retrieval of a parameter requires its name.", outputStorage);
}
server.getWrapperStorage().writeUnsignedByte(libsumo::TYPE_STRING);
server.getWrapperStorage().writeString(libsumo::POI::getParameter(id, paramName));
break;
}
default:
return server.writeErrorStatusCmd(libsumo::CMD_GET_POI_VARIABLE, "Get PoI Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
}
}
} catch (libsumo::TraCIException& e) {
return server.writeErrorStatusCmd(libsumo::CMD_GET_POI_VARIABLE, e.what(), outputStorage);
}
server.writeStatusCmd(libsumo::CMD_GET_POI_VARIABLE, libsumo::RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
return true;
}
示例3: getPoI
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_POI::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
// variable & id
int variable = inputStorage.readUnsignedByte();
std::string id = inputStorage.readString();
// check variable
if (variable != ID_LIST && variable != VAR_TYPE && variable != VAR_COLOR && variable != VAR_POSITION && variable != ID_COUNT) {
return server.writeErrorStatusCmd(CMD_GET_POI_VARIABLE, "Get PoI Variable: unsupported variable specified", outputStorage);
}
// begin response building
tcpip::Storage tempMsg;
// response-code, variableID, objectID
tempMsg.writeUnsignedByte(RESPONSE_GET_POI_VARIABLE);
tempMsg.writeUnsignedByte(variable);
tempMsg.writeString(id);
// process request
if (variable == ID_LIST || variable == ID_COUNT) {
std::vector<std::string> ids;
ShapeContainer& shapeCont = MSNet::getInstance()->getShapeContainer();
shapeCont.getPOIs().insertIDs(ids);
if (variable == ID_LIST) {
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(ids);
} else {
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) ids.size());
}
} else {
PointOfInterest* p = getPoI(id);
if (p == 0) {
return server.writeErrorStatusCmd(CMD_GET_POI_VARIABLE, "POI '" + id + "' is not known", outputStorage);
}
switch (variable) {
case VAR_TYPE:
tempMsg.writeUnsignedByte(TYPE_STRING);
tempMsg.writeString(p->getType());
break;
case VAR_COLOR:
tempMsg.writeUnsignedByte(TYPE_COLOR);
tempMsg.writeUnsignedByte(p->getColor().red());
tempMsg.writeUnsignedByte(p->getColor().green());
tempMsg.writeUnsignedByte(p->getColor().blue());
tempMsg.writeUnsignedByte(p->getColor().alpha());
break;
case VAR_POSITION:
tempMsg.writeUnsignedByte(POSITION_2D);
tempMsg.writeDouble(p->x());
tempMsg.writeDouble(p->y());
break;
default:
break;
}
}
server.writeStatusCmd(CMD_GET_POI_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例4: toHex
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_Route::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
// variable & id
int variable = inputStorage.readUnsignedByte();
std::string id = inputStorage.readString();
// check variable
if (variable != ID_LIST && variable != VAR_EDGES && variable != ID_COUNT && variable != VAR_PARAMETER) {
return server.writeErrorStatusCmd(CMD_GET_ROUTE_VARIABLE, "Get Route Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
}
// begin response building
tcpip::Storage tempMsg;
// response-code, variableID, objectID
tempMsg.writeUnsignedByte(RESPONSE_GET_ROUTE_VARIABLE);
tempMsg.writeUnsignedByte(variable);
tempMsg.writeString(id);
// process request
if (variable == ID_LIST) {
std::vector<std::string> ids;
MSRoute::insertIDs(ids);
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(ids);
} else if (variable == ID_COUNT) {
std::vector<std::string> ids;
MSRoute::insertIDs(ids);
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) ids.size());
} else {
const MSRoute* r = MSRoute::dictionary(id);
if (r == 0) {
return server.writeErrorStatusCmd(CMD_GET_ROUTE_VARIABLE, "Route '" + id + "' is not known", outputStorage);
}
switch (variable) {
case VAR_EDGES:
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeInt(r->size());
for (MSRouteIterator i = r->begin(); i != r->end(); ++i) {
tempMsg.writeString((*i)->getID());
}
break;
case VAR_PARAMETER: {
std::string paramName = "";
if (!server.readTypeCheckingString(inputStorage, paramName)) {
return server.writeErrorStatusCmd(CMD_GET_ROUTE_VARIABLE, "Retrieval of a parameter requires its name.", outputStorage);
}
tempMsg.writeUnsignedByte(TYPE_STRING);
tempMsg.writeString(r->getParameter(paramName, ""));
}
break;
default:
break;
}
}
server.writeStatusCmd(CMD_GET_ROUTE_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例5: if
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_Junction::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
// variable
int variable = inputStorage.readUnsignedByte();
std::string id = inputStorage.readString();
// check variable
if (variable != ID_LIST && variable != VAR_POSITION && variable != ID_COUNT && variable != VAR_SHAPE) {
return server.writeErrorStatusCmd(CMD_GET_JUNCTION_VARIABLE, "Get Junction Variable: unsupported variable specified", outputStorage);
}
// begin response building
tcpip::Storage tempMsg;
// response-code, variableID, objectID
tempMsg.writeUnsignedByte(RESPONSE_GET_JUNCTION_VARIABLE);
tempMsg.writeUnsignedByte(variable);
tempMsg.writeString(id);
if (variable == ID_LIST) {
std::vector<std::string> ids;
MSNet::getInstance()->getJunctionControl().insertIDs(ids);
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(ids);
} else if (variable == ID_COUNT) {
std::vector<std::string> ids;
MSNet::getInstance()->getJunctionControl().insertIDs(ids);
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) ids.size());
} else {
MSJunction* j = MSNet::getInstance()->getJunctionControl().get(id);
if (j == 0) {
return server.writeErrorStatusCmd(CMD_GET_JUNCTION_VARIABLE, "Junction '" + id + "' is not known", outputStorage);
}
switch (variable) {
case ID_LIST:
break;
case VAR_POSITION:
tempMsg.writeUnsignedByte(POSITION_2D);
tempMsg.writeDouble(j->getPosition().x());
tempMsg.writeDouble(j->getPosition().y());
break;
case VAR_SHAPE:
tempMsg.writeUnsignedByte(TYPE_POLYGON);
tempMsg.writeUnsignedByte((int)MIN2(static_cast<size_t>(255), j->getShape().size()));
for (unsigned int iPoint = 0; iPoint < MIN2(static_cast<size_t>(255), j->getShape().size()); ++iPoint) {
tempMsg.writeDouble(j->getShape()[iPoint].x());
tempMsg.writeDouble(j->getShape()[iPoint].y());
}
break;
default:
break;
}
}
server.writeStatusCmd(CMD_GET_JUNCTION_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例6: toHex
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_MultiEntryExit::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
const int variable = inputStorage.readUnsignedByte();
const std::string id = inputStorage.readString();
server.initWrapper(libsumo::RESPONSE_GET_MULTIENTRYEXIT_VARIABLE, variable, id);
try {
if (!libsumo::MultiEntryExit::handleVariable(id, variable, &server)) {
return server.writeErrorStatusCmd(libsumo::CMD_GET_MULTIENTRYEXIT_VARIABLE, "Get Multi Entry Exit Detector Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
}
} catch (libsumo::TraCIException& e) {
return server.writeErrorStatusCmd(libsumo::CMD_GET_MULTIENTRYEXIT_VARIABLE, e.what(), outputStorage);
}
server.writeStatusCmd(libsumo::CMD_GET_MULTIENTRYEXIT_VARIABLE, libsumo::RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
return true;
}
示例7: if
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_VehicleType::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
std::string warning = ""; // additional description for response
// variable & id
int variable = inputStorage.readUnsignedByte();
std::string id = inputStorage.readString();
// check variable
if (variable != ID_LIST && variable != VAR_LENGTH && variable != VAR_MAXSPEED && variable != VAR_ACCEL && variable != VAR_DECEL
&& variable != VAR_TAU && variable != VAR_VEHICLECLASS && variable != VAR_EMISSIONCLASS && variable != VAR_SHAPECLASS
&& variable != VAR_SPEED_FACTOR && variable != VAR_SPEED_DEVIATION && variable != VAR_IMPERFECTION
&& variable != VAR_MINGAP && variable != VAR_WIDTH && variable != VAR_COLOR && variable != ID_COUNT) {
server.writeStatusCmd(CMD_GET_VEHICLETYPE_VARIABLE, RTYPE_ERR, "Get Vehicle Type Variable: unsupported variable specified", outputStorage);
return false;
}
// begin response building
tcpip::Storage tempMsg;
// response-code, variableID, objectID
tempMsg.writeUnsignedByte(RESPONSE_GET_VEHICLETYPE_VARIABLE);
tempMsg.writeUnsignedByte(variable);
tempMsg.writeString(id);
// process request
if (variable == ID_LIST) {
std::vector<std::string> ids;
MSNet::getInstance()->getVehicleControl().insertVTypeIDs(ids);
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(ids);
} else if (variable == ID_COUNT) {
std::vector<std::string> ids;
MSNet::getInstance()->getVehicleControl().insertVTypeIDs(ids);
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) ids.size());
} else {
MSVehicleType* v = MSNet::getInstance()->getVehicleControl().getVType(id);
if (v == 0) {
server.writeStatusCmd(CMD_GET_VEHICLETYPE_VARIABLE, RTYPE_ERR, "Vehicle type '" + id + "' is not known", outputStorage);
return false;
}
getVariable(variable, *v, tempMsg);
}
server.writeStatusCmd(CMD_GET_VEHICLETYPE_VARIABLE, RTYPE_OK, warning, outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例8: switch
//.........这里部分代码省略.........
break;
case VAR_TELEPORT_STARTING_VEHICLES_IDS:
writeVehicleStateIDs(server, tempMsg, MSNet::VEHICLE_STATE_STARTING_TELEPORT);
break;
case VAR_TELEPORT_ENDING_VEHICLES_NUMBER:
writeVehicleStateNumber(server, tempMsg, MSNet::VEHICLE_STATE_ENDING_TELEPORT);
break;
case VAR_TELEPORT_ENDING_VEHICLES_IDS:
writeVehicleStateIDs(server, tempMsg, MSNet::VEHICLE_STATE_ENDING_TELEPORT);
break;
case VAR_ARRIVED_VEHICLES_NUMBER:
writeVehicleStateNumber(server, tempMsg, MSNet::VEHICLE_STATE_ARRIVED);
break;
case VAR_ARRIVED_VEHICLES_IDS:
writeVehicleStateIDs(server, tempMsg, MSNet::VEHICLE_STATE_ARRIVED);
break;
case VAR_PARKING_STARTING_VEHICLES_NUMBER:
writeVehicleStateNumber(server, tempMsg, MSNet::VEHICLE_STATE_STARTING_PARKING);
break;
case VAR_PARKING_STARTING_VEHICLES_IDS:
writeVehicleStateIDs(server, tempMsg, MSNet::VEHICLE_STATE_STARTING_PARKING);
break;
case VAR_PARKING_ENDING_VEHICLES_NUMBER:
writeVehicleStateNumber(server, tempMsg, MSNet::VEHICLE_STATE_ENDING_PARKING);
break;
case VAR_PARKING_ENDING_VEHICLES_IDS:
writeVehicleStateIDs(server, tempMsg, MSNet::VEHICLE_STATE_ENDING_PARKING);
break;
case VAR_STOP_STARTING_VEHICLES_NUMBER:
writeVehicleStateNumber(server, tempMsg, MSNet::VEHICLE_STATE_STARTING_STOP);
break;
case VAR_STOP_STARTING_VEHICLES_IDS:
writeVehicleStateIDs(server, tempMsg, MSNet::VEHICLE_STATE_STARTING_STOP);
break;
case VAR_STOP_ENDING_VEHICLES_NUMBER:
writeVehicleStateNumber(server, tempMsg, MSNet::VEHICLE_STATE_ENDING_STOP);
break;
case VAR_STOP_ENDING_VEHICLES_IDS:
writeVehicleStateIDs(server, tempMsg, MSNet::VEHICLE_STATE_ENDING_STOP);
break;
case VAR_DELTA_T:
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt(DELTA_T);
break;
case VAR_NET_BOUNDING_BOX: {
tempMsg.writeUnsignedByte(TYPE_BOUNDINGBOX);
Boundary b = GeoConvHelper::getFinal().getConvBoundary();
tempMsg.writeDouble(b.xmin());
tempMsg.writeDouble(b.ymin());
tempMsg.writeDouble(b.xmax());
tempMsg.writeDouble(b.ymax());
break;
}
break;
case VAR_MIN_EXPECTED_VEHICLES:
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt(MSNet::getInstance()->getVehicleControl().getActiveVehicleCount() + MSNet::getInstance()->getInsertionControl().getPendingFlowCount());
break;
case POSITION_CONVERSION:
if (inputStorage.readUnsignedByte() != TYPE_COMPOUND) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Position conversion requires a compound object.", outputStorage);
}
if (inputStorage.readInt() != 2) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Position conversion requires a source position and a position type as parameter.", outputStorage);
}
if (!commandPositionConversion(server, inputStorage, tempMsg, CMD_GET_SIM_VARIABLE)) {
return false;
}
break;
case DISTANCE_REQUEST:
if (inputStorage.readUnsignedByte() != TYPE_COMPOUND) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of distance requires a compound object.", outputStorage);
}
if (inputStorage.readInt() != 3) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of distance requires two positions and a distance type as parameter.", outputStorage);
}
if (!commandDistanceRequest(server, inputStorage, tempMsg, CMD_GET_SIM_VARIABLE)) {
return false;
}
break;
case VAR_BUS_STOP_WAITING: {
std::string id;
if (!server.readTypeCheckingString(inputStorage, id)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of persons at busstop requires a string.", outputStorage);
}
MSBusStop* s = MSNet::getInstance()->getBusStop(id);
if (s == 0) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Unknown bus stop '" + id + "'.", outputStorage);
}
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt(s->getPersonNumber());
break;
}
default:
break;
}
server.writeStatusCmd(CMD_GET_SIM_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例9: if
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_MeMeDetector::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
std::string warning = ""; // additional description for response
// variable & id
int variable = inputStorage.readUnsignedByte();
std::string id = inputStorage.readString();
// check variable
if (variable != ID_LIST && variable != LAST_STEP_VEHICLE_NUMBER && variable != LAST_STEP_MEAN_SPEED
&& variable != LAST_STEP_VEHICLE_ID_LIST && variable != LAST_STEP_VEHICLE_HALTING_NUMBER
&& variable != ID_COUNT) {
server.writeStatusCmd(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, RTYPE_ERR, "Get MeMeDetector Variable: unsupported variable specified", outputStorage);
return false;
}
// begin response building
tcpip::Storage tempMsg;
// response-code, variableID, objectID
tempMsg.writeUnsignedByte(RESPONSE_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE);
tempMsg.writeUnsignedByte(variable);
tempMsg.writeString(id);
if (variable == ID_LIST) {
std::vector<std::string> ids;
MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_ENTRY_EXIT_DETECTOR).insertIDs(ids);
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(ids);
} else if (variable == ID_COUNT) {
std::vector<std::string> ids;
MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_ENTRY_EXIT_DETECTOR).insertIDs(ids);
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) ids.size());
} else {
MSE3Collector* e3 = static_cast<MSE3Collector*>(MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_ENTRY_EXIT_DETECTOR).get(id));
if (e3 == 0) {
server.writeStatusCmd(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, RTYPE_ERR, "Areal detector '" + id + "' is not known", outputStorage);
return false;
}
switch (variable) {
case ID_LIST:
break;
case LAST_STEP_VEHICLE_NUMBER:
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) e3->getVehiclesWithin());
break;
case LAST_STEP_MEAN_SPEED:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(e3->getCurrentMeanSpeed());
break;
case LAST_STEP_VEHICLE_ID_LIST: {
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
std::vector<std::string> ids = e3->getCurrentVehicleIDs();
tempMsg.writeStringList(ids);
}
break;
case LAST_STEP_VEHICLE_HALTING_NUMBER:
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) e3->getCurrentHaltingNumber());
break;
default:
break;
}
}
server.writeStatusCmd(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, RTYPE_OK, warning, outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例10: toHex
//.........这里部分代码省略.........
tempMsg.writeDouble(sum);
}
break;
case VAR_NOISEEMISSION: {
SUMOReal sum = 0;
const std::vector<MSLane*>& lanes = e->getLanes();
for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
sum += (SUMOReal) pow(10., ((*i)->getHarmonoise_NoiseEmissions() / 10.));
}
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
if (sum != 0) {
tempMsg.writeDouble(HelpersHarmonoise::sum(sum));
} else {
tempMsg.writeDouble(0);
}
}
break;
case LAST_STEP_VEHICLE_NUMBER: {
int sum = 0;
const std::vector<MSLane*>& lanes = e->getLanes();
for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
sum += (*i)->getVehicleNumber();
}
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt(sum);
}
break;
case LAST_STEP_MEAN_SPEED: {
SUMOReal sum = 0;
const std::vector<MSLane*>& lanes = e->getLanes();
for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
sum += (*i)->getMeanSpeed();
}
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(sum / (SUMOReal) lanes.size());
}
break;
case LAST_STEP_OCCUPANCY: {
SUMOReal sum = 0;
const std::vector<MSLane*>& lanes = e->getLanes();
for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
sum += (*i)->getNettoOccupancy();
}
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(sum / (SUMOReal) lanes.size());
}
break;
case LAST_STEP_VEHICLE_HALTING_NUMBER: {
int halting = 0;
const std::vector<MSLane*>& lanes = e->getLanes();
for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
const MSLane::VehCont& vehs = (*i)->getVehiclesSecure();
for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
if ((*j)->getSpeed() < SUMO_const_haltingSpeed) {
++halting;
}
}
(*i)->releaseVehicles();
}
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt(halting);
}
break;
case LAST_STEP_LENGTH: {
SUMOReal lengthSum = 0;
int noVehicles = 0;
const std::vector<MSLane*>& lanes = e->getLanes();
for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
const MSLane::VehCont& vehs = (*i)->getVehiclesSecure();
for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
lengthSum += (*j)->getVehicleType().getLength();
}
noVehicles += (int) vehs.size();
(*i)->releaseVehicles();
}
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
if (noVehicles == 0) {
tempMsg.writeDouble(0);
} else {
tempMsg.writeDouble(lengthSum / (SUMOReal) noVehicles);
}
}
break;
case VAR_PARAMETER: {
std::string paramName = "";
if (!server.readTypeCheckingString(inputStorage, paramName)) {
return server.writeErrorStatusCmd(CMD_GET_EDGE_VARIABLE, "Retrieval of a parameter requires its name.", outputStorage);
}
tempMsg.writeUnsignedByte(TYPE_STRING);
tempMsg.writeString(e->getParameter(paramName, ""));
}
break;
default:
break;
}
}
server.writeStatusCmd(CMD_GET_EDGE_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例11: if
//.........这里部分代码省略.........
tempMsg.writeDouble(lane->getCOEmissions());
break;
case VAR_HCEMISSION:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(lane->getHCEmissions());
break;
case VAR_PMXEMISSION:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(lane->getPMxEmissions());
break;
case VAR_NOXEMISSION:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(lane->getNOxEmissions());
break;
case VAR_FUELCONSUMPTION:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(lane->getFuelConsumption());
break;
case VAR_NOISEEMISSION:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(lane->getHarmonoise_NoiseEmissions());
break;
case LAST_STEP_VEHICLE_NUMBER:
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) lane->getVehicleNumber());
break;
case LAST_STEP_MEAN_SPEED:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(lane->getMeanSpeed());
break;
case LAST_STEP_VEHICLE_ID_LIST: {
std::vector<std::string> vehIDs;
const MSLane::VehCont& vehs = lane->getVehiclesSecure();
for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
vehIDs.push_back((*j)->getID());
}
lane->releaseVehicles();
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(vehIDs);
}
break;
case LAST_STEP_OCCUPANCY:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(lane->getNettoOccupancy());
break;
case LAST_STEP_VEHICLE_HALTING_NUMBER: {
int halting = 0;
const MSLane::VehCont& vehs = lane->getVehiclesSecure();
for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
if ((*j)->getSpeed() < SUMO_const_haltingSpeed) {
++halting;
}
}
lane->releaseVehicles();
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt(halting);
}
break;
case LAST_STEP_LENGTH: {
SUMOReal lengthSum = 0;
const MSLane::VehCont& vehs = lane->getVehiclesSecure();
for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
lengthSum += (*j)->getVehicleType().getLength();
}
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
if (vehs.size() == 0) {
tempMsg.writeDouble(0);
} else {
tempMsg.writeDouble(lengthSum / (SUMOReal) vehs.size());
}
lane->releaseVehicles();
}
break;
case VAR_WAITING_TIME: {
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(lane->getWaitingSeconds());
}
break;
case VAR_CURRENT_TRAVELTIME: {
SUMOReal meanSpeed = lane->getMeanSpeed();
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
if (meanSpeed != 0) {
tempMsg.writeDouble(lane->getLength() / meanSpeed);
} else {
tempMsg.writeDouble(1000000.);
}
}
break;
case VAR_WIDTH:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(lane->getWidth());
break;
default:
break;
}
}
server.writeStatusCmd(CMD_GET_LANE_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例12: switch
//.........这里部分代码省略.........
if (inputStorage.readInt() != 5) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires five parameter.", outputStorage);
}
std::string from, to, vtype;
double depart;
int routingMode;
if (!server.readTypeCheckingString(inputStorage, from)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as first parameter.", outputStorage);
}
if (!server.readTypeCheckingString(inputStorage, to)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as second parameter.", outputStorage);
}
if (!server.readTypeCheckingString(inputStorage, vtype)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as third parameter.", outputStorage);
}
if (!server.readTypeCheckingDouble(inputStorage, depart)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as fourth parameter.", outputStorage);
}
if (!server.readTypeCheckingInt(inputStorage, routingMode)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires an integer as fifth parameter.", outputStorage);
}
writeStage(server.getWrapperStorage(), libsumo::Simulation::findRoute(from, to, vtype, TIME2STEPS(depart), routingMode));
break;
}
case FIND_INTERMODAL_ROUTE: {
if (inputStorage.readUnsignedByte() != TYPE_COMPOUND) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of an intermodal route requires a compound object.", outputStorage);
}
if (inputStorage.readInt() != 13) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of an intermodal route requires thirteen parameters.", outputStorage);
}
std::string from, to, modes, ptype, vtype, destStop;
double depart, speed, walkFactor, departPos, arrivalPos, departPosLat;
int routingMode;
if (!server.readTypeCheckingString(inputStorage, from)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as first parameter.", outputStorage);
}
if (!server.readTypeCheckingString(inputStorage, to)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as second parameter.", outputStorage);
}
if (!server.readTypeCheckingString(inputStorage, modes)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as third parameter.", outputStorage);
}
if (!server.readTypeCheckingDouble(inputStorage, depart)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as fourth parameter.", outputStorage);
}
if (!server.readTypeCheckingInt(inputStorage, routingMode)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires an integer as fifth parameter.", outputStorage);
}
if (!server.readTypeCheckingDouble(inputStorage, speed)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as sixth parameter.", outputStorage);
}
if (!server.readTypeCheckingDouble(inputStorage, walkFactor)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as seventh parameter.", outputStorage);
}
if (!server.readTypeCheckingDouble(inputStorage, departPos)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as eigth parameter.", outputStorage);
}
if (!server.readTypeCheckingDouble(inputStorage, arrivalPos)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as nineth parameter.", outputStorage);
}
if (!server.readTypeCheckingDouble(inputStorage, departPosLat)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as tenth parameter.", outputStorage);
}
if (!server.readTypeCheckingString(inputStorage, ptype)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as eleventh parameter.", outputStorage);
}
if (!server.readTypeCheckingString(inputStorage, vtype)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as twelvth parameter.", outputStorage);
}
if (!server.readTypeCheckingString(inputStorage, destStop)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as thirteenth parameter.", outputStorage);
}
const std::vector<libsumo::TraCIStage> result = libsumo::Simulation::findIntermodalRoute(from, to, modes, TIME2STEPS(depart), routingMode, speed, walkFactor, departPos, arrivalPos, departPosLat, ptype, vtype, destStop);
server.getWrapperStorage().writeUnsignedByte(TYPE_COMPOUND);
server.getWrapperStorage().writeInt((int)result.size());
for (const libsumo::TraCIStage s : result) {
writeStage(server.getWrapperStorage(), s);
}
break;
}
case VAR_PARAMETER: {
std::string paramName = "";
if (!server.readTypeCheckingString(inputStorage, paramName)) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a parameter requires its name.", outputStorage);
}
server.getWrapperStorage().writeUnsignedByte(TYPE_STRING);
server.getWrapperStorage().writeString(libsumo::Simulation::getParameter(id, paramName));
break;
}
default:
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Get Simulation Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
}
} catch (libsumo::TraCIException& e) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, e.what(), outputStorage);
}
server.writeStatusCmd(CMD_GET_SIM_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
return true;
}
示例13: getPolygon
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_Polygon::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
// variable & id
int variable = inputStorage.readUnsignedByte();
std::string id = inputStorage.readString();
// check variable
if (variable != ID_LIST && variable != VAR_TYPE && variable != VAR_COLOR && variable != VAR_SHAPE && variable != VAR_FILL
&& variable != ID_COUNT) {
return server.writeErrorStatusCmd(CMD_GET_POLYGON_VARIABLE, "Get Polygon Variable: unsupported variable specified", outputStorage);
}
// begin response building
tcpip::Storage tempMsg;
// response-code, variableID, objectID
tempMsg.writeUnsignedByte(RESPONSE_GET_POLYGON_VARIABLE);
tempMsg.writeUnsignedByte(variable);
tempMsg.writeString(id);
// process request
if (variable == ID_LIST || variable == ID_COUNT) {
std::vector<std::string> ids;
ShapeContainer& shapeCont = MSNet::getInstance()->getShapeContainer();
shapeCont.getPolygons().insertIDs(ids);
if (variable == ID_LIST) {
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(ids);
} else {
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) ids.size());
}
} else {
Polygon* p = getPolygon(id);
if (p == 0) {
return server.writeErrorStatusCmd(CMD_GET_POLYGON_VARIABLE, "Polygon '" + id + "' is not known", outputStorage);
}
switch (variable) {
case VAR_TYPE:
tempMsg.writeUnsignedByte(TYPE_STRING);
tempMsg.writeString(p->getType());
break;
case VAR_COLOR:
tempMsg.writeUnsignedByte(TYPE_COLOR);
tempMsg.writeUnsignedByte(p->getColor().red());
tempMsg.writeUnsignedByte(p->getColor().green());
tempMsg.writeUnsignedByte(p->getColor().blue());
tempMsg.writeUnsignedByte(p->getColor().alpha());
break;
case VAR_SHAPE:
tempMsg.writeUnsignedByte(TYPE_POLYGON);
tempMsg.writeUnsignedByte(MIN2(static_cast<int>(255), static_cast<int>(p->getShape().size())));
for (unsigned int iPoint = 0; iPoint < MIN2(static_cast<size_t>(255), p->getShape().size()); ++iPoint) {
tempMsg.writeDouble(p->getShape()[iPoint].x());
tempMsg.writeDouble(p->getShape()[iPoint].y());
}
break;
case VAR_FILL:
tempMsg.writeUnsignedByte(TYPE_UBYTE);
tempMsg.writeUnsignedByte(p->getFill() ? 1 : 0);
break;
default:
break;
}
}
server.writeStatusCmd(CMD_GET_POLYGON_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例14: if
//.........这里部分代码省略.........
tempContent.writeUnsignedByte(TYPE_INTEGER);
tempContent.writeInt(phase.duration);
++cnt;
tempContent.writeUnsignedByte(TYPE_INTEGER);
tempContent.writeInt(phase.minDuration);
++cnt; // not implemented
tempContent.writeUnsignedByte(TYPE_INTEGER);
tempContent.writeInt(phase.maxDuration);
++cnt; // not implemented
const std::string& state = phase.getState();
//unsigned int linkNo = (unsigned int)(vars.getActive()->getLinks().size());
tempContent.writeUnsignedByte(TYPE_STRING);
tempContent.writeString(state);
++cnt;
}
}
tempMsg.writeInt((int) cnt);
tempMsg.writeStorage(tempContent);
}
break;
case TL_CONTROLLED_LANES: {
const MSTrafficLightLogic::LaneVectorVector& lanes = vars.getActive()->getLanes();
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
std::vector<std::string> laneIDs;
for (MSTrafficLightLogic::LaneVectorVector::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
const MSTrafficLightLogic::LaneVector& llanes = (*i);
for (MSTrafficLightLogic::LaneVector::const_iterator j = llanes.begin(); j != llanes.end(); ++j) {
laneIDs.push_back((*j)->getID());
}
}
tempMsg.writeStringList(laneIDs);
}
break;
case TL_CONTROLLED_LINKS: {
const MSTrafficLightLogic::LaneVectorVector& lanes = vars.getActive()->getLanes();
const MSTrafficLightLogic::LinkVectorVector& links = vars.getActive()->getLinks();
//
tempMsg.writeUnsignedByte(TYPE_COMPOUND);
tcpip::Storage tempContent;
unsigned int cnt = 0;
tempContent.writeUnsignedByte(TYPE_INTEGER);
unsigned int no = (unsigned int) lanes.size();
tempContent.writeInt((int) no);
for (unsigned int i = 0; i < no; ++i) {
const MSTrafficLightLogic::LaneVector& llanes = lanes[i];
const MSTrafficLightLogic::LinkVector& llinks = links[i];
// number of links controlled by this signal (signal i)
tempContent.writeUnsignedByte(TYPE_INTEGER);
unsigned int no2 = (unsigned int) llanes.size();
tempContent.writeInt((int) no2);
++cnt;
for (unsigned int j = 0; j < no2; ++j) {
MSLink* link = llinks[j];
std::vector<std::string> def;
// incoming lane
def.push_back(llanes[j]->getID());
// approached non-internal lane (if any)
def.push_back(link->getLane() != 0 ? link->getLane()->getID() : "");
// approached "via", internal lane (if any)
#ifdef HAVE_INTERNAL_LANES
def.push_back(link->getViaLane() != 0 ? link->getViaLane()->getID() : "");
#else
def.push_back("");
#endif
tempContent.writeUnsignedByte(TYPE_STRINGLIST);
tempContent.writeStringList(def);
++cnt;
}
}
tempMsg.writeInt((int) cnt);
tempMsg.writeStorage(tempContent);
}
break;
case TL_CURRENT_PHASE:
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) vars.getActive()->getCurrentPhaseIndex());
break;
case TL_CURRENT_PROGRAM:
tempMsg.writeUnsignedByte(TYPE_STRING);
tempMsg.writeString(vars.getActive()->getProgramID());
break;
case TL_PHASE_DURATION:
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) vars.getActive()->getCurrentPhaseDef().duration);
break;
case TL_NEXT_SWITCH:
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) vars.getActive()->getNextSwitchTime());
break;
case TL_CONTROLLED_JUNCTIONS: {
}
break;
default:
break;
}
}
server.writeStatusCmd(CMD_GET_TL_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例15: if
//.........这里部分代码省略.........
return server.writeErrorStatusCmd(CMD_GET_INDUCTIONLOOP_VARIABLE, "Get Induction Loop Variable: unsupported variable specified", outputStorage);
}
// begin response building
tcpip::Storage tempMsg;
// response-code, variableID, objectID
tempMsg.writeUnsignedByte(RESPONSE_GET_INDUCTIONLOOP_VARIABLE);
tempMsg.writeUnsignedByte(variable);
tempMsg.writeString(id);
// process request
if (variable == ID_LIST) {
std::vector<std::string> ids;
MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_INDUCTION_LOOP).insertIDs(ids);
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(ids);
} else if (variable == ID_COUNT) {
std::vector<std::string> ids;
MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_INDUCTION_LOOP).insertIDs(ids);
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) ids.size());
} else {
MSInductLoop* il = static_cast<MSInductLoop*>(MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_INDUCTION_LOOP).get(id));
if (il == 0) {
return server.writeErrorStatusCmd(CMD_GET_INDUCTIONLOOP_VARIABLE, "Induction loop '" + id + "' is not known", outputStorage);
}
switch (variable) {
case ID_LIST:
break;
case LAST_STEP_VEHICLE_NUMBER:
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int)(il->getCurrentPassedNumber()));
break;
case LAST_STEP_MEAN_SPEED:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(il->getCurrentSpeed());
break;
case LAST_STEP_VEHICLE_ID_LIST: {
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
std::vector<std::string> ids = il->getCurrentVehicleIDs();
tempMsg.writeStringList(ids);
}
break;
case LAST_STEP_OCCUPANCY:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(il->getCurrentOccupancy());
break;
case LAST_STEP_LENGTH:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(il->getCurrentLength());
break;
case LAST_STEP_TIME_SINCE_DETECTION:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(il->getTimestepsSinceLastDetection());
break;
case LAST_STEP_VEHICLE_DATA: {
std::vector<MSInductLoop::VehicleData> vd = il->collectVehiclesOnDet(MSNet::getInstance()->getCurrentTimeStep() - DELTA_T);
tempMsg.writeUnsignedByte(TYPE_COMPOUND);
tcpip::Storage tempContent;
unsigned int cnt = 0;
tempContent.writeUnsignedByte(TYPE_INTEGER);
tempContent.writeInt((int) vd.size());
++cnt;
for (unsigned int i = 0; i < vd.size(); ++i) {
MSInductLoop::VehicleData& svd = vd[i];
tempContent.writeUnsignedByte(TYPE_STRING);
tempContent.writeString(svd.idM);
++cnt;
tempContent.writeUnsignedByte(TYPE_DOUBLE);
tempContent.writeDouble(svd.lengthM);
++cnt;
tempContent.writeUnsignedByte(TYPE_DOUBLE);
tempContent.writeDouble(svd.entryTimeM);
++cnt;
tempContent.writeUnsignedByte(TYPE_DOUBLE);
tempContent.writeDouble(svd.leaveTimeM);
++cnt;
tempContent.writeUnsignedByte(TYPE_STRING);
tempContent.writeString(svd.typeIDM);
++cnt;
}
tempMsg.writeInt((int) cnt);
tempMsg.writeStorage(tempContent);
break;
}
case VAR_POSITION:
tempMsg.writeUnsignedByte(TYPE_DOUBLE);
tempMsg.writeDouble(il->getPosition());
break;
case VAR_LANE_ID:
tempMsg.writeUnsignedByte(TYPE_STRING);
tempMsg.writeString(il->getLane()->getID());
break;
default:
break;
}
}
server.writeStatusCmd(CMD_GET_INDUCTIONLOOP_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}