Example #1
0
 def execute(self, obj, event):
     global LOGGER, NETWORK, REN, REN_WIN, I_REN
     log_tick("vtkTimerCallback exec " + str(self.timer_count))
     # Non-blocking periodic reading of the pipe TODO: add code
     # that dynamically adjusts the periodicity of checking to a
     # fraction of the expected period of visualisable data input.
     # learning rate 0.1, not more because will swing around stable
     # point.  Bounded, 1ms to 2sec?
     if not self.child_conn.poll():
         log_tick("The pipeline is empty, returning")
         return
     r = interpret_simu_to_visu_message(self.child_conn.recv())
     if r:
         NETWORK = r
         LOGGER.info("Network structure received.")
         lvl_to_g = {0: NETWORK.grids}
         # lvl_to_g = Tns.vn.levels_to_grids()
         all_actors = NETWORK.make_all_actors(lvl_to_g)
         add_actors_to_scene(REN, all_actors)
         REN.ResetCamera()
         prepare_render_env(REN_WIN, I_REN)
     else:
         LOGGER.info("Activity update received.")
         I_REN.GetRenderWindow().Render()
     self.timer_count += 1
Example #2
0
 def execute(self, obj, event):
     global LOGGER, NETWORK, REN, REN_WIN, I_REN
     log_tick("vtkTimerCallback exec " + str(self.timer_count))
     # Non-blocking periodic reading of the pipe TODO: add code
     # that dynamically adjusts the periodicity of checking to a
     # fraction of the expected period of visualisable data input.
     # learning rate 0.1, not more because will swing around stable
     # point.  Bounded, 1ms to 2sec?
     if (not self.child_conn.poll()):
         log_tick("The pipeline is empty, returning")
         return
     r = interpret_simu_to_visu_message(self.child_conn.recv())
     if r:
         NETWORK = r
         LOGGER.info("Network structure received.")
         lvl_to_g = {0: NETWORK.grids}
         # lvl_to_g = Tns.vn.levels_to_grids()
         all_actors = NETWORK.make_all_actors(lvl_to_g)
         add_actors_to_scene(REN, all_actors)
         REN.ResetCamera()
         prepare_render_env(REN_WIN, I_REN)
     else:
         LOGGER.info("Activity update received.")
         I_REN.GetRenderWindow().Render()
     self.timer_count += 1
Example #3
0
def ipc_test(parent_conn, child_conn):
    for a in reversed(range(-1,100)):
        time.sleep(0.1)
        log_tick("just before send")
        # Only pipe in data to be visualised if visualisation pipe is
        # empty.
        if (not child_conn.poll()):
            log_tick("the vis. pipeline is empty, putting in some data")
            parent_conn.send(a)
        log_tick("just after send")
Example #4
0
def ipc_test(parent_conn, child_conn):
    for a in reversed(range(-1, 100)):
        time.sleep(0.1)
        log_tick("just before send")
        # Only pipe in data to be visualised if visualisation pipe is
        # empty.
        if (not child_conn.poll()):
            log_tick("the vis. pipeline is empty, putting in some data")
            parent_conn.send(a)
        log_tick("just after send")
Example #5
0
def visualisation_process_f(child_conn, logger):
    """Function called when main() creates the visualisation process
    through multiprocessing.Process. The parameters are the pipe frrom
    which to read visualisation updates and the logger to use."""
    global LOGGER, REN, REN_WIN, I_REN
    LOGGER = logger
    log_tick("start visu")
    REN, REN_WIN, I_REN = setup_visualisation()
    log_tick("after setup_vis")
    REN.SetBackground(VISU_BG[0], VISU_BG[1], VISU_BG[2])
    log_tick("background set")
    timer_id = setup_timer(I_REN, child_conn)
    I_REN.Start()
Example #6
0
def visualisation_process_f(child_conn, logger):
    """Function called when main() creates the visualisation process
    through multiprocessing.Process. The parameters are the pipe frrom
    which to read visualisation updates and the logger to use."""
    global LOGGER, REN, REN_WIN, I_REN
    LOGGER = logger
    log_tick("start visu")
    REN, REN_WIN, I_REN = setup_visualisation()
    log_tick("after setup_vis")
    REN.SetBackground(VISU_BG[0], VISU_BG[1], VISU_BG[2])
    log_tick("background set")
    timer_id = setup_timer(I_REN, child_conn)
    I_REN.Start()
Example #7
0
def setup_timer(window_interactor, input_conn):
    callback = vtkTimerCallback(input_conn)
    window_interactor.AddObserver("TimerEvent", callback.execute)
    log_tick("observer added")
    return window_interactor.CreateRepeatingTimer(100)
Example #8
0
def prepare_render_env(render_window, window_interactor):
    window_interactor.Initialize()
    render_window.Render()
    log_tick("after render")
Example #9
0
def setup_timer(window_interactor, input_conn):
    callback = vtkTimerCallback(input_conn)
    window_interactor.AddObserver("TimerEvent", callback.execute)
    log_tick("observer added")
    return window_interactor.CreateRepeatingTimer(100)
Example #10
0
def prepare_render_env(render_window, window_interactor):
    window_interactor.Initialize()
    render_window.Render()
    log_tick("after render")