Path: blob/main/tests/complex/traci/trafficlight/constraints/swap/redundant_1/runner.py
169779 views
#!/usr/bin/env python1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2# Copyright (C) 2009-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-later1213# @file runner.py14# @author Jakob Erdmann15# @date 2021-04-121617from __future__ import print_function18from __future__ import absolute_import19import os20import sys2122if "SUMO_HOME" in os.environ:23sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))2425import traci # noqa26import sumolib # noqa2728traci.start([sumolib.checkBinary('sumo'),29'-n', 'input_net.net.xml',30'-a', 'input_additional.add.xml',31'-r', 'input_routes.rou.xml',32'--tripinfo-output', 'tripinfo.xml',33'--no-step-log',34] + sys.argv[1:])3536print("constraints before swap")37for tlsID in traci.trafficlight.getIDList():38for c in traci.trafficlight.getConstraints(tlsID):39print(" tls=%s %s" % (tlsID, c))4041traci.trafficlight.swapConstraints("H", "t2", "C", "t0")4243print("constraints after swap")44for tlsID in traci.trafficlight.getIDList():45for c in traci.trafficlight.getConstraints(tlsID):46print(" tls=%s %s" % (tlsID, c))4748while traci.simulation.getMinExpectedNumber() > 0:49traci.simulationStep()5051traci.close()525354