sumolib.net.generator.straight

 1#!/usr/bin/env python
 2# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
 3# Copyright (C) 2013-2026 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    straight.py
15# @author  Daniel Krajzewicz
16# @date    2013-10-10
17
18from __future__ import absolute_import
19# relative imports don't work if a file is used as a library and executable
20# (https://peps.python.org/pep-0366/#rationale-for-change)
21import os
22import sys
23sys.path.append(os.path.dirname(os.path.realpath(__file__)))
24import network  # noqa
25
26
27def straight(defaultNode=None, defaultEdge=None, centralReservation=0):
28    net = network.Net(defaultNode, defaultEdge)
29    net.addNode(network.Node("0/1", 0, 500, "priority"))
30    net.addNode(network.Node("1/1", 500, 500, "traffic_light"))
31    net.addNode(network.Node("2/1", 1000, 500, "priority"))
32    net.connectNodes("0/1", "1/1", True, centralReservation)
33    net.connectNodes("2/1", "1/1", True, centralReservation)
34    return net
35#  d = demand.Demand()
36#  d.addStream(demand.Stream("1/0_to_1/2", 10, "1/0 1/2"))
37#  d.build(3600)
38
39
40if __name__ == "__main__":
41    net = straight()
42    net.build()
def straight(defaultNode=None, defaultEdge=None, centralReservation=0):
28def straight(defaultNode=None, defaultEdge=None, centralReservation=0):
29    net = network.Net(defaultNode, defaultEdge)
30    net.addNode(network.Node("0/1", 0, 500, "priority"))
31    net.addNode(network.Node("1/1", 500, 500, "traffic_light"))
32    net.addNode(network.Node("2/1", 1000, 500, "priority"))
33    net.connectNodes("0/1", "1/1", True, centralReservation)
34    net.connectNodes("2/1", "1/1", True, centralReservation)
35    return net