Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/neteditTestFunctions/frames/network/connection.py
169686 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 connection.py
15
# @author Pablo Alvarez Lopez
16
# @date 28-05-25
17
18
# imports
19
import time
20
21
from ...enums.attributesEnum import attrs
22
from ...constants import DELAY_SELECT
23
from ...general.functions import focusOnFrame
24
from ...input.mouse import leftClick
25
from ...input.keyboard import typeKey, keyPress, keyRelease
26
27
28
def createConnection(referencePosition, fromLanePosition, toLanePosition):
29
"""
30
@brief create connection
31
"""
32
# select first lane
33
leftClick(referencePosition, fromLanePosition)
34
# select another lane for create a connection
35
leftClick(referencePosition, toLanePosition)
36
37
38
def createConnectionConflict(referencePosition, fromLanePosition, toLanePosition):
39
"""
40
@brief create connection conflict
41
"""
42
# press control
43
keyPress('ctrl')
44
# select first lane
45
leftClick(referencePosition, fromLanePosition)
46
# select another lane for create a connection
47
leftClick(referencePosition, toLanePosition)
48
# release control
49
keyRelease('ctrl')
50
51
52
def createConnectionYield(referencePosition, fromLanePosition, toLanePosition):
53
"""
54
@brief create connection
55
"""
56
# press shift
57
keyPress('shift')
58
# select first lane
59
leftClick(referencePosition, fromLanePosition)
60
# select another lane for create a connection
61
leftClick(referencePosition, toLanePosition)
62
# release shift
63
keyRelease('shift')
64
65
66
def saveConnectionEdit():
67
"""
68
@brief Change to crossing mode
69
"""
70
# focus current frame
71
focusOnFrame()
72
# go to cancel button
73
for _ in range(attrs.connection.saveConnections):
74
typeKey('tab')
75
# type space to press button
76
typeKey('space')
77
# wait for gl debug
78
time.sleep(DELAY_SELECT)
79
80