Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tests/complex/emissionsMap/energy_custom/runner.py
169685 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
4
# Copyright (C) 2013-2025 German Aerospace Center (DLR) and others.
5
# This program and the accompanying materials are made available under the
6
# terms of the Eclipse Public License 2.0 which is available at
7
# https://www.eclipse.org/legal/epl-2.0/
8
# This Source Code may also be made available under the following Secondary
9
# Licenses when the conditions for such availability set forth in the Eclipse
10
# Public License 2.0 are satisfied: GNU General Public License, version 2
11
# or later which is available at
12
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
13
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
14
15
# @file runner.py
16
# @author Daniel Krajzewicz
17
# @author Michael Behrisch
18
# @date 2013-01-14
19
20
from __future__ import absolute_import
21
from __future__ import print_function
22
23
import sys
24
import os
25
import subprocess
26
sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))
27
from sumolib import checkBinary # noqa
28
29
EDC = checkBinary("emissionsMap", os.path.join(
30
os.path.dirname(sys.argv[0]), '..', '..', '..', "bin"))
31
32
fdo = open("results.csv", "w")
33
ec = sys.argv[1].strip()
34
print("Running '%s'" % ec)
35
sys.stdout.flush()
36
sys.stderr.flush()
37
call = [EDC, "-e", ec, "-o", "tmp.csv",
38
"--v-max", "30",
39
"--v-step", "5",
40
"--a-step", "1",
41
"--s-min", "0",
42
"--s-max", "0",
43
]
44
call += sys.argv[2:]
45
retCode = subprocess.call(call)
46
sys.stdout.flush()
47
sys.stderr.flush()
48
if retCode != 0:
49
print("Error on building PHEMlight measurements")
50
sys.exit(1)
51
fdo.write("%s\n" % ec)
52
with open("tmp.csv") as fd:
53
fdo.write(fd.read())
54
fdo.write("-----\n\n")
55
fdo.close()
56
57