Skip to content

main

main() #

Starts the replay viewer.

During installation of cogip-tools, setuptools is configured to create the replay script using this function as entrypoint.

Source code in cogip/tools/replay/main.py
55
56
57
58
59
60
61
62
def main():
    """
    Starts the replay viewer.

    During installation of cogip-tools, `setuptools` is configured
    to create the `replay` script using this function as entrypoint.
    """
    typer.run(main_opt)

main_opt(trace_file=typer.Argument(None)) #

Starts replay.

Source code in cogip/tools/replay/main.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def main_opt(trace_file: Optional[Path] = typer.Argument(None)):  # noqa
    """
    Starts replay.
    """

    if trace_file and not trace_file.is_file():
        logger.error(f"Error: '{trace_file}' is not a file or does not exist.")
        sys.exit(1)

    # Create QApplication
    app = QtWidgets.QApplication(sys.argv)

    # Create UI
    win = MainWindow(trace_file)

    # Create table entity
    table_entity = TableEntity(win.game_view.scene_entity)
    win.game_view.add_asset(table_entity)

    # Create robot entity
    robot_entity = RobotEntity()
    win.game_view.add_asset(robot_entity)

    # Connect UI signals
    win.signal_new_robot_state.connect(robot_entity.new_robot_state)
    win.signal_new_robot_state.connect(win.game_view.new_robot_state)
    win.signal_new_robot_state.connect(win.new_robot_state)
    win.signal_new_robot_state.connect(win.charts_view.new_robot_state)

    if trace_file:
        win.load_trace(trace_file)

    # Show UI
    win.show()
    # win.showFullScreen()
    win.raise_()

    sys.exit(app.exec_())