示例#1
0
def init():
    # Both sim and gui need a navdatabase in all versions of BlueSky
    from bluesky.navdatabase import Navdatabase
    global navdb
    navdb = Navdatabase()

    # The remaining objects are only instantiated in the sim nodes
    if settings.is_sim:
        from bluesky.traffic import Traffic

        if settings.gui == 'pygame':
            from bluesky.ui.pygame import Screen
            from bluesky.simulation.pygame import Simulation
        else:
            from bluesky.simulation.qtgl import Simulation, ScreenIO as Screen

        from bluesky import stack
        from bluesky.tools import plugin, plotter

        # Initialize singletons
        global traf, sim, scr
        traf = Traffic()
        sim = Simulation()
        scr = Screen()

        # Initialize remaining modules
        plugin.init()
        plotter.init()
        stack.init()
示例#2
0
def MainLoop():
    # =============================================================================
    # Start the mainloop (and possible other threads)
    # =============================================================================
    splash.show()
    plugin.init()
    stack.init()
    sim.start()
    scr.init()

    # Main loop for tmx object
    while not sim.mode == sim.end:
        sim.update()   # Update sim
        scr.update()   # GUI update

        # Restart traffic simulation:
        if sim.mode == sim.init:
            sim.reset()
            scr.objdel()     # Delete user defined objects

    # After the simulation is done, close the gui
    sim.stop()
    pg.quit()
    print 'BlueSky normal end.'
    return
示例#3
0
def MainLoop():
    # =============================================================================
    # Start the mainloop (and possible other threads)
    # =============================================================================
    splash.show()
    plugin.init()
    stack.init()
    sim.start()
    scr.init()

    # Main loop for tmx object
    while not sim.mode == sim.end:
        sim.update()   # Update sim
        scr.update()   # GUI update

        # Restart traffic simulation:
        if sim.mode == sim.init:
            sim.reset()
            scr.objdel()     # Delete user defined objects

    # After the simulation is done, close the gui
    sim.stop()
    pg.quit()
    print('BlueSky normal end.')
    return
示例#4
0
def run():
    global connection
    connection = Client(('localhost', 6000), authkey='bluesky')
    plugin.init()
    stack.init()
    bs.sim.doWork()
    connection.close()
    print 'Node', nodeid, 'stopped.'
示例#5
0
def run():
    global connection
    connection = Client(('localhost', 6000), authkey=b'bluesky')
    plugin.init()
    stack.init()
    bs.sim.doWork()
    connection.close()
    print('Node', nodeid, 'stopped.')
示例#6
0
def init(mode='sim', pygame=False, discovery=False, cfgfile='', scnfile=''):
    """ Initialize bluesky modules.

        Arguments:
        - mode: can be 'sim', 'sim-detached', 'server-gui', 'server-headless',
          or 'client'
        - pygame: indicate if BlueSky is started with BlueSky_pygame.py
        - discovery: Enable network discovery
    """
    # Initialize global settings first, possibly loading a custom config file
    settings.init(cfgfile)

    # Is this a server running headless?
    headless = (mode[-8:] == 'headless')

    # Keep track of the gui type.
    global gui_type
    gui_type = 'pygame' if pygame else \
               'none' if headless or mode[:3] == 'sim' else 'qtgl'

    # Load navdatabase in all versions of BlueSky
    # Only the headless server doesn't need this
    if not headless:
        from bluesky.navdatabase import Navdatabase
        global navdb
        navdb = Navdatabase()

    # If mode is server-gui or server-headless start the networking server
    if mode[:6] == 'server':
        global server
        from bluesky.network import Server
        server = Server(headless)

    # The remaining objects are only instantiated in the sim nodes
    if mode[:3] == 'sim':
        # Check whether simulation node should run detached
        detached = (mode[-8:] == 'detached')
        from bluesky.traffic import Traffic

        if pygame:
            from bluesky.ui.pygame import Screen
            from bluesky.simulation.pygame import Simulation
        else:
            from bluesky.simulation.qtgl import Simulation, ScreenIO as Screen

        from bluesky import stack
        from bluesky.tools import plugin, plotter

        # Initialize singletons
        global traf, sim, scr
        traf = Traffic()
        sim = Simulation(detached)
        scr = Screen()

        # Initialize remaining modules
        plugin.init(mode)
        plotter.init()
        stack.init(scnfile)
示例#7
0
def init(mode='sim', pygame=False, discovery=False, cfgfile='', scnfile=''):
    """ Initialize bluesky modules.

        Arguments:
        - mode: can be 'sim', 'sim-detached', 'server-gui', 'server-headless',
          or 'client'
        - pygame: indicate if BlueSky is started with BlueSky_pygame.py
        - discovery: Enable network discovery
    """
    # Initialize global settings first, possibly loading a custom config file
    settings.init(cfgfile)

    # Is this a server running headless?
    headless = (mode[-8:] == 'headless')

    # Keep track of the gui type.
    global gui_type
    gui_type = 'pygame' if pygame else \
               'none' if headless or mode[:3] == 'sim' else 'qtgl'

    # Load navdatabase in all versions of BlueSky
    # Only the headless server doesn't need this
    if not headless:
        from bluesky.navdatabase import Navdatabase
        global navdb
        navdb = Navdatabase()

    # If mode is server-gui or server-headless start the networking server
    if mode[:6] == 'server':
        global server
        from bluesky.network import Server
        server = Server(headless)

    # The remaining objects are only instantiated in the sim nodes
    if mode[:3] == 'sim':
        # Check whether simulation node should run detached
        detached = (mode[-8:] == 'detached')
        from bluesky.traffic import Traffic

        if pygame:
            from bluesky.ui.pygame import Screen
            from bluesky.simulation.pygame import Simulation
        else:
            from bluesky.simulation.qtgl import Simulation, ScreenIO as Screen

        from bluesky import stack
        from bluesky.tools import plugin, varexplorer

        # Initialize singletons
        global traf, sim, scr
        traf = Traffic()
        sim = Simulation(detached)
        scr = Screen()

        # Initialize remaining modules
        plugin.init(mode)
        varexplorer.init()
        stack.init(scnfile)
示例#8
0
def init():
    # Both sim and gui need a navdatabase in all versions of BlueSky
    if settings.is_sim or settings.is_gui:
        from bluesky.navdatabase import Navdatabase
        global navdb
        navdb = Navdatabase()

    if settings.start_server:
        global server
        from bluesky.network import Server
        server = Server()
        server.start()

    # The remaining objects are only instantiated in the sim nodes
    if settings.is_sim:
        from bluesky.traffic import Traffic

        if settings.gui == 'pygame':
            from bluesky.ui.pygame import Screen
            from bluesky.simulation.pygame import Simulation
        else:
            from bluesky.simulation.qtgl import Simulation, ScreenIO as Screen

        from bluesky import stack
        from bluesky.tools import plugin, plotter

        # Initialize singletons
        global traf, sim, scr
        traf  = Traffic()
        sim   = Simulation()
        scr   = Screen()

        # Initialize remaining modules
        plugin.init()
        plotter.init()
        stack.init()
示例#9
0
def init(mode='sim', configfile=None, scenfile=None, discoverable=False,
         gui=None, detached=False, **kwargs):
    ''' Initialize bluesky modules.

        Arguments:

    '''

    # Keep track of mode and gui type.
    globals()['mode'] = mode
    globals()['gui'] = gui

    # Initialize global settings first, possibly loading a custom config file
    settings.init(configfile)

    # Initialise tools
    tools.init()

    # Load navdatabase in all versions of BlueSky
    # Only the headless server doesn't need this
    if mode == "sim" or gui is not None:
        from bluesky.navdatabase import Navdatabase
        global navdb
        navdb = Navdatabase()

    # If mode is server-gui or server-headless start the networking server
    if mode == 'server':
        global server
        from bluesky.network.server import Server
        server = Server(discoverable, configfile, scenfile)

    # The remaining objects are only instantiated in the sim nodes
    if mode == 'sim':
        from bluesky.traffic import Traffic
        from bluesky.simulation import Simulation
        if gui == 'pygame':
            from bluesky.ui.pygame import Screen
            from bluesky.network.detached import Node
        else:
            from bluesky.simulation import ScreenIO as Screen
            if detached:
                from bluesky.network.detached import Node
            else:
                from bluesky.network.node import Node

        from bluesky.core import varexplorer

        # Initialize singletons
        global traf, sim, scr, net
        traf = Traffic()
        sim = Simulation()
        scr = Screen()
        net = Node(settings.simevent_port,
                   settings.simstream_port)

        # Initialize remaining modules
        varexplorer.init()
        if scenfile:
            stack.stack(f'IC {scenfile}')

    from bluesky.core import plugin
    plugin.init(mode)
    stack.init(mode)
示例#10
0
def init(mode='sim', pygame=False, discovery=False, cfgfile='', scnfile=''):
    ''' Initialize bluesky modules.

        Arguments:
        - mode: can be 'sim', 'sim-detached', 'server-gui', 'server-headless',
          or 'client'
        - pygame: indicate if BlueSky is started with BlueSky_pygame.py
        - discovery: Enable network discovery
    '''
    # Is this a server running headless?
    headless = (mode[-8:] == 'headless')

    # Keep track of the gui type.
    global gui_type
    gui_type = 'pygame' if pygame else \
               'none' if headless or mode[:3] == 'sim' else 'qtgl'

    # Initialize global settings first, possibly loading a custom config file
    settings.init(cfgfile)

    # Initialise tools
    tools.init()

    # Load navdatabase in all versions of BlueSky
    # Only the headless server doesn't need this
    if not headless:
        from bluesky.navdatabase import Navdatabase
        global navdb
        navdb = Navdatabase()

    # If mode is server-gui or server-headless start the networking server
    if mode[:6] == 'server':
        global server
        from bluesky.network.server import Server
        server = Server(discovery)

    # The remaining objects are only instantiated in the sim nodes
    if mode[:3] == 'sim':
        # Check whether simulation node should run detached
        detached = (mode[-8:] == 'detached')
        from bluesky.traffic import Traffic
        from bluesky.simulation import Simulation
        if pygame:
            from bluesky.ui.pygame import Screen
            from bluesky.network.detached import Node
        else:
            from bluesky.simulation import ScreenIO as Screen
            if detached:
                from bluesky.network.detached import Node
            else:
                from bluesky.network.node import Node

        from bluesky.core import varexplorer

        # Initialize singletons
        global traf, sim, scr, net
        traf = Traffic()
        sim = Simulation()
        scr = Screen()
        net = Node(settings.simevent_port,
                   settings.simstream_port)

        # Initialize remaining modules
        varexplorer.init()
        if scnfile:
            stack.stack(f'IC {scnfile}')

    from bluesky.core import plugin
    plugin.init(mode)
    stack.init(mode)