Path: blob/main/src/traci_testclient/testlibtraci_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 testlibtraci_main.cpp14/// @author Michael Behrisch15/// @date Tue, 20 Nov 200116///17// Testing libtraci for C++18/****************************************************************************/19#ifdef _MSC_VER20// Avoid some noisy warnings with Visual Studio21#pragma warning(disable:4820 4514 5045 4668 4710)22#endif2324#include <iostream>25#include <libsumo/libtraci.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}37try {38libtraci::Simulation::start(options);39// libtraci::Simulation::start(options, -1, libsumo::DEFAULT_NUM_RETRIES, "default", true);40std::cout << "Simulation started\n";41for (int i = 0; i < 50; i++) {42libtraci::Simulation::step();43}44libtraci::Simulation::close();45} catch (const std::runtime_error& e) {46std::cerr << "Could not start simulation: " << e.what() << "\n";47}48/*49std::vector<libsumo::TraCIStage> result = libsumo::Simulation::findIntermodalRoute("64455492", "-22913705", "public", 21600, 3, -1, -1, 0, 0,0,"ped");50double cost = 0;51double time = 0;52for (const auto& stage : result)53{54std::cout << " type=" << stage.type << " line=" << stage.line << " travelTime=" << stage.travelTime << " cost=" << stage.cost << " destination: "<< stage.destStop<<"\n";55std::cout << "Descr:\n" << stage.description<< std::endl<<std::endl;56cost += stage.cost;57time += stage.travelTime;58}59std::cout<<"end cost: "<<cost<<std::endl;60std::cout<<"end time: "<<time<<std::endl;61*/62}636465/****************************************************************************/666768