Path: blob/main/src/traci_testclient/testlibsumo_main.cpp
169665 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file testlibsumo_main.cpp14/// @author Michael Behrisch15/// @date Tue, 20 Nov 200116///17// Testing libsumo for C++18/****************************************************************************/19#ifdef _MSC_VER20// Avoid some noisy warnings with Visual Studio21#pragma warning(disable:4820 4514 5045 4710 4668)22#endif2324#include <iostream>25#include <libsumo/libsumo.h>262728// ===========================================================================29// main function30// ===========================================================================31int32main(int argc, char** argv) {33std::vector<std::string> options;34for (int i = 1; i < argc; i++) {35options.push_back(argv[i]);36}37libsumo::Simulation::load(options);38std::cout << "Simulation loaded\n";39if (options.size() == 0 || (options[0] != "sumo" && options[0] != "sumo-gui")) {40options.insert(options.begin(), "sumo");41}42libsumo::Simulation::start(options);43std::cout << "Simulation started\n";44libsumo::Simulation::close();45/*46std::vector<libsumo::TraCIStage> result = libsumo::Simulation::findIntermodalRoute("64455492", "-22913705", "public", 21600, 3, -1, -1, 0, 0,0,"ped");47double cost = 0;48double time = 0;49for (const auto& stage : result)50{51std::cout << " type=" << stage.type << " line=" << stage.line << " travelTime=" << stage.travelTime << " cost=" << stage.cost << " destination: "<< stage.destStop<<"\n";52std::cout << "Descr:\n" << stage.description<< std::endl<<std::endl;53cost += stage.cost;54time += stage.travelTime;55}56std::cout<<"end cost: "<<cost<<std::endl;57std::cout<<"end time: "<<time<<std::endl;58*/59}606162/****************************************************************************/636465