本文整理汇总了C++中TraCIServer::getVehicleStateChanges方法的典型用法代码示例。如果您正苦于以下问题:C++ TraCIServer::getVehicleStateChanges方法的具体用法?C++ TraCIServer::getVehicleStateChanges怎么用?C++ TraCIServer::getVehicleStateChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TraCIServer
的用法示例。
在下文中一共展示了TraCIServer::getVehicleStateChanges方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
TraCIServerAPI_Simulation::writeVehicleStateIDs(TraCIServer& server, tcpip::Storage& outputStorage, MSNet::VehicleState state) {
const std::vector<std::string>& ids = server.getVehicleStateChanges().find(state)->second;
outputStorage.writeUnsignedByte(TYPE_STRINGLIST);
outputStorage.writeStringList(ids);
}
示例2: switch
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_Simulation::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
// variable & id
int variable = inputStorage.readUnsignedByte();
std::string id = inputStorage.readString();
// check variable
if (variable != VAR_TIME_STEP
&& variable != VAR_LOADED_VEHICLES_NUMBER && variable != VAR_LOADED_VEHICLES_IDS
&& variable != VAR_DEPARTED_VEHICLES_NUMBER && variable != VAR_DEPARTED_VEHICLES_IDS
&& variable != VAR_TELEPORT_STARTING_VEHICLES_NUMBER && variable != VAR_TELEPORT_STARTING_VEHICLES_IDS
&& variable != VAR_TELEPORT_ENDING_VEHICLES_NUMBER && variable != VAR_TELEPORT_ENDING_VEHICLES_IDS
&& variable != VAR_ARRIVED_VEHICLES_NUMBER && variable != VAR_ARRIVED_VEHICLES_IDS
&& variable != VAR_DELTA_T && variable != VAR_NET_BOUNDING_BOX
&& variable != VAR_MIN_EXPECTED_VEHICLES
&& variable != POSITION_CONVERSION && variable != DISTANCE_REQUEST
&& variable != VAR_BUS_STOP_WAITING
&& variable != VAR_PARKING_STARTING_VEHICLES_NUMBER && variable != VAR_PARKING_STARTING_VEHICLES_IDS
&& variable != VAR_PARKING_ENDING_VEHICLES_NUMBER && variable != VAR_PARKING_ENDING_VEHICLES_IDS
&& variable != VAR_STOP_STARTING_VEHICLES_NUMBER && variable != VAR_STOP_STARTING_VEHICLES_IDS
&& variable != VAR_STOP_ENDING_VEHICLES_NUMBER && variable != VAR_STOP_ENDING_VEHICLES_IDS
) {
return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Get Simulation Variable: unsupported variable specified", outputStorage);
}
// begin response building
tcpip::Storage tempMsg;
// response-code, variableID, objectID
tempMsg.writeUnsignedByte(RESPONSE_GET_SIM_VARIABLE);
tempMsg.writeUnsignedByte(variable);
tempMsg.writeString(id);
// process request
switch (variable) {
case VAR_TIME_STEP:
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt(MSNet::getInstance()->getCurrentTimeStep());
break;
case VAR_LOADED_VEHICLES_NUMBER:
writeVehicleStateNumber(server, tempMsg, MSNet::VEHICLE_STATE_BUILT);
break;
case VAR_LOADED_VEHICLES_IDS: {
const std::vector<std::string>& ids = server.getVehicleStateChanges().find(MSNet::VEHICLE_STATE_BUILT)->second;
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(ids);
}
break;
case VAR_DEPARTED_VEHICLES_NUMBER:
writeVehicleStateNumber(server, tempMsg, MSNet::VEHICLE_STATE_DEPARTED);
break;
case VAR_DEPARTED_VEHICLES_IDS:
writeVehicleStateIDs(server, tempMsg, MSNet::VEHICLE_STATE_DEPARTED);
break;
case VAR_TELEPORT_STARTING_VEHICLES_NUMBER:
writeVehicleStateNumber(server, tempMsg, MSNet::VEHICLE_STATE_STARTING_TELEPORT);
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;
//.........这里部分代码省略.........