Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/neteditTestFunctions/general/fixElements.py
169679 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 fixElements.py
15
# @author Pablo Alvarez Lopez
16
# @date 28-05-25
17
18
# imports
19
import time
20
from ..constants import DELAY_QUESTION
21
from ..files.save import saveExistentFile
22
from ..input.keyboard import typeKey, typeTwoKeys
23
24
25
def fixRoute(solution):
26
"""
27
@brief fix route
28
"""
29
# save config
30
saveExistentFile("neteditConfig")
31
# select bullet depending of solution
32
if (solution == "selectRouteInvalids"):
33
for _ in range(2):
34
typeTwoKeys('shift', 'tab')
35
typeKey('space')
36
# go back and press accept
37
for _ in range(2):
38
typeKey('tab')
39
typeKey('space')
40
elif (solution == "saveRouteInvalids"):
41
for _ in range(3):
42
typeTwoKeys('shift', 'tab')
43
typeKey('space')
44
# go back and press accept
45
for _ in range(3):
46
typeKey('tab')
47
typeKey('space')
48
elif (solution == "removeRouteInvalids"):
49
for _ in range(4):
50
typeTwoKeys('shift', 'tab')
51
typeKey('space')
52
# go back and press accept
53
for _ in range(4):
54
typeKey('tab')
55
typeKey('space')
56
else:
57
# press cancel
58
typeKey('tab')
59
typeKey('space')
60
61
62
def fixDemandElements(solution):
63
"""
64
@brief fix stoppingPlaces
65
"""
66
# save config
67
saveExistentFile("neteditConfig")
68
# select bullet depending of solution
69
if (solution == "saveInvalids"):
70
for _ in range(3):
71
typeTwoKeys('shift', 'tab')
72
typeKey('space')
73
# go back and press accept
74
for _ in range(3):
75
typeKey('tab')
76
typeKey('space')
77
elif (solution == "fixPositions"):
78
for _ in range(2):
79
typeTwoKeys('shift', 'tab')
80
typeKey('space')
81
# go back and press accept
82
for _ in range(2):
83
typeKey('tab')
84
typeKey('space')
85
elif (solution == "selectInvalids"):
86
typeTwoKeys('shift', 'tab')
87
typeKey('space')
88
# go back and press accept
89
typeKey('tab')
90
typeKey('space')
91
elif (solution == "activateFriendlyPos"):
92
# default option, then press accept
93
typeKey('space')
94
else:
95
# press cancel
96
typeKey('tab')
97
typeKey('space')
98
99
100
def fixStoppingPlace(solution):
101
"""
102
@brief fix stoppingPlaces
103
"""
104
# save config
105
saveExistentFile("neteditConfig")
106
# wait some second to question dialog
107
time.sleep(DELAY_QUESTION)
108
# select bullet depending of solution
109
if (solution == "savePositionInvalids"):
110
for _ in range(3):
111
typeTwoKeys('shift', 'tab')
112
typeKey('space')
113
# go back and press accept
114
for _ in range(3):
115
typeKey('tab')
116
typeKey('space')
117
elif (solution == "fixPositions"):
118
for _ in range(2):
119
typeTwoKeys('shift', 'tab')
120
typeKey('space')
121
# go back and press accept
122
for _ in range(2):
123
typeKey('tab')
124
typeKey('space')
125
elif (solution == "selectPositionInvalids"):
126
typeTwoKeys('shift', 'tab')
127
typeKey('space')
128
# go back and press accept
129
typeKey('tab')
130
typeKey('space')
131
elif (solution == "activatePositionFriendlyPos"):
132
# default option, then press accept
133
typeKey('space')
134
else:
135
# press cancel
136
typeKey('tab')
137
typeKey('space')
138
139
140
def fixCrossings(solution):
141
"""
142
@brief fix stoppingPlaces
143
"""
144
# save config
145
saveExistentFile("neteditConfig")
146
# wait some second to question dialog
147
time.sleep(DELAY_QUESTION)
148
# select bullet depending of solution
149
if (solution == "saveInvalidCrossings"):
150
for _ in range(2):
151
typeTwoKeys('shift', 'tab')
152
typeKey('space')
153
# go back and press accept
154
for _ in range(2):
155
typeKey('tab')
156
typeKey('space')
157
elif (solution == "selectInvalidCrossings"):
158
typeTwoKeys('shift', 'tab')
159
typeKey('space')
160
# go back and press accept
161
typeKey('tab')
162
typeKey('space')
163
elif (solution == "removeInvalidCrossings"):
164
# default option, then press accept
165
typeKey('space')
166
else:
167
# press cancel
168
typeKey('tab')
169
typeKey('space')
170
171