Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tests/complex/traci/misc/signature/runner.py
169689 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2008-2025 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file runner.py
15
# @author Michael Behrisch
16
# @date 2023-11-14
17
18
19
import os
20
import sys
21
import inspect
22
if "SUMO_HOME" in os.environ:
23
sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))
24
import sumolib
25
import traci
26
if sys.version_info[0] > 2:
27
import libsumo
28
else:
29
def libsumo(): return None
30
libsumo.DOMAINS = []
31
32
VERBOSE = False
33
34
for dt in traci.DOMAINS:
35
for dl in libsumo.DOMAINS:
36
if dt.DOMAIN_ID == dl.DOMAIN_ID:
37
for ft in inspect.getmembers(dt):
38
if ft[0][0] != "_" and inspect.ismethod(ft[1]):
39
if VERBOSE:
40
print("checking", dt._name, ft[0])
41
for fl in inspect.getmembers(dl):
42
if fl[0] == ft[0]:
43
sigt = inspect.signature(ft[1])
44
sigl = inspect.signature(fl[1])
45
if VERBOSE:
46
print("checking", sigt, sigl)
47
if sigt != sigl:
48
params = list(sigl.parameters.values())
49
if not params or params[0].kind != inspect.Parameter.VAR_POSITIONAL:
50
print(".".join([dt._name, ft[0]]), "traci:", sigt, "libsumo:", sigl)
51
if not traci.isLibsumo():
52
try:
53
traci.start([sumolib.checkBinary("sumo"), "-c", "sumo.sumocfg"])
54
traci.simulationStep()
55
if not traci.isLibtraci():
56
traci.vehicle.setLaneChangeMode("horiz", lcm=0)
57
traci.vehicle.setParameter(objectID="horiz", key="blub", value="blubber")
58
traci.vehicle.setParameter(objID="horiz", key="blub", value="blubber")
59
traci.vehicle.setParameter(objectID="horiz", param="blub", value="blubber")
60
traci.vehicle.setParameter(objID="horiz", param="blub", value="blubber")
61
try:
62
traci.vehicle.setParameter(oID="horiz", param="blub", value="blubber")
63
except TypeError as e:
64
print(str(e).replace("Domain.", ""))
65
finally:
66
traci.close()
67
68