Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/neteditTestFunctions/general/functions.py
169678 views
1
# -*- coding: utf-8 -*-
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2009-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 functions.py
15
# @author Pablo Alvarez Lopez
16
# @date 28-05-25
17
18
# imports
19
import time
20
from ..constants import DELAY_RECOMPUTE, DELAY_RECOMPUTE_VOLATILE, DELAY_QUESTION
21
from ..input.keyboard import typeKey, typeTwoKeys
22
23
24
def computeJunctions():
25
"""
26
@brief compute junctions (rebuild network)
27
"""
28
typeKey('F5')
29
# wait for output
30
time.sleep(DELAY_RECOMPUTE)
31
32
33
def computeJunctionsVolatileOptions(question):
34
"""
35
@brief rebuild network with volatile options
36
"""
37
typeTwoKeys('shift', 'F5')
38
# confirm recompute
39
if question == "yes":
40
waitQuestion('y')
41
# wait for output
42
time.sleep(DELAY_RECOMPUTE_VOLATILE)
43
elif question == "no":
44
waitQuestion('n')
45
else:
46
waitQuestion('esc')
47
48
49
def joinSelectedJunctions():
50
"""
51
@brief join selected junctions
52
"""
53
typeKey('F7')
54
55
56
def focusOnFrame():
57
"""
58
@brief select focus on upper element of current frame
59
"""
60
typeTwoKeys('shift', 'F12')
61
time.sleep(1)
62
63
64
def waitQuestion(answer):
65
"""
66
@brief wait question of Netedit and select a yes/no answer (by default yes)
67
"""
68
# wait some second to question dialog
69
time.sleep(DELAY_QUESTION)
70
# continue depending on answer
71
if (answer == 'esc'):
72
typeKey('esc')
73
else:
74
if (answer == 'n'):
75
typeKey('tab')
76
elif (answer == 'a'):
77
for _ in range(2):
78
typeKey('tab')
79
# press space to answer question
80
typeKey('space')
81
82
83
def overwritte(value):
84
"""
85
@brief check if overwritte loaded elements
86
"""
87
if value == "yes":
88
typeKey('space')
89
elif value == "no":
90
typeKey('tab')
91
typeKey('space')
92
else:
93
typeKey('tab')
94
typeKey('tab')
95
typeKey('space')
96
97
98
def openAboutDialog(waitingTime=DELAY_QUESTION):
99
"""
100
@brief open and close about dialog
101
"""
102
# type F12 to open about dialog
103
typeKey('F12')
104
# wait before closing
105
time.sleep(waitingTime)
106
# press enter to close dialog (Ok must be focused)
107
typeKey('space')
108
109