Path: blob/main/tools/neteditTestFunctions/general/fixElements.py
169679 views
# -*- coding: utf-8 -*-1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2# Copyright (C) 2009-2025 German Aerospace Center (DLR) and others.3# This program and the accompanying materials are made available under the4# terms of the Eclipse Public License 2.0 which is available at5# https://www.eclipse.org/legal/epl-2.0/6# This Source Code may also be made available under the following Secondary7# Licenses when the conditions for such availability set forth in the Eclipse8# Public License 2.0 are satisfied: GNU General Public License, version 29# or later which is available at10# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1213# @file fixElements.py14# @author Pablo Alvarez Lopez15# @date 28-05-251617# imports18import time19from ..constants import DELAY_QUESTION20from ..files.save import saveExistentFile21from ..input.keyboard import typeKey, typeTwoKeys222324def fixRoute(solution):25"""26@brief fix route27"""28# save config29saveExistentFile("neteditConfig")30# select bullet depending of solution31if (solution == "selectRouteInvalids"):32for _ in range(2):33typeTwoKeys('shift', 'tab')34typeKey('space')35# go back and press accept36for _ in range(2):37typeKey('tab')38typeKey('space')39elif (solution == "saveRouteInvalids"):40for _ in range(3):41typeTwoKeys('shift', 'tab')42typeKey('space')43# go back and press accept44for _ in range(3):45typeKey('tab')46typeKey('space')47elif (solution == "removeRouteInvalids"):48for _ in range(4):49typeTwoKeys('shift', 'tab')50typeKey('space')51# go back and press accept52for _ in range(4):53typeKey('tab')54typeKey('space')55else:56# press cancel57typeKey('tab')58typeKey('space')596061def fixDemandElements(solution):62"""63@brief fix stoppingPlaces64"""65# save config66saveExistentFile("neteditConfig")67# select bullet depending of solution68if (solution == "saveInvalids"):69for _ in range(3):70typeTwoKeys('shift', 'tab')71typeKey('space')72# go back and press accept73for _ in range(3):74typeKey('tab')75typeKey('space')76elif (solution == "fixPositions"):77for _ in range(2):78typeTwoKeys('shift', 'tab')79typeKey('space')80# go back and press accept81for _ in range(2):82typeKey('tab')83typeKey('space')84elif (solution == "selectInvalids"):85typeTwoKeys('shift', 'tab')86typeKey('space')87# go back and press accept88typeKey('tab')89typeKey('space')90elif (solution == "activateFriendlyPos"):91# default option, then press accept92typeKey('space')93else:94# press cancel95typeKey('tab')96typeKey('space')979899def fixStoppingPlace(solution):100"""101@brief fix stoppingPlaces102"""103# save config104saveExistentFile("neteditConfig")105# wait some second to question dialog106time.sleep(DELAY_QUESTION)107# select bullet depending of solution108if (solution == "savePositionInvalids"):109for _ in range(3):110typeTwoKeys('shift', 'tab')111typeKey('space')112# go back and press accept113for _ in range(3):114typeKey('tab')115typeKey('space')116elif (solution == "fixPositions"):117for _ in range(2):118typeTwoKeys('shift', 'tab')119typeKey('space')120# go back and press accept121for _ in range(2):122typeKey('tab')123typeKey('space')124elif (solution == "selectPositionInvalids"):125typeTwoKeys('shift', 'tab')126typeKey('space')127# go back and press accept128typeKey('tab')129typeKey('space')130elif (solution == "activatePositionFriendlyPos"):131# default option, then press accept132typeKey('space')133else:134# press cancel135typeKey('tab')136typeKey('space')137138139def fixCrossings(solution):140"""141@brief fix stoppingPlaces142"""143# save config144saveExistentFile("neteditConfig")145# wait some second to question dialog146time.sleep(DELAY_QUESTION)147# select bullet depending of solution148if (solution == "saveInvalidCrossings"):149for _ in range(2):150typeTwoKeys('shift', 'tab')151typeKey('space')152# go back and press accept153for _ in range(2):154typeKey('tab')155typeKey('space')156elif (solution == "selectInvalidCrossings"):157typeTwoKeys('shift', 'tab')158typeKey('space')159# go back and press accept160typeKey('tab')161typeKey('space')162elif (solution == "removeInvalidCrossings"):163# default option, then press accept164typeKey('space')165else:166# press cancel167typeKey('tab')168typeKey('space')169170171