pySimBlocks.gui.models.project_state

class pySimBlocks.gui.models.project_state.ProjectState(directory_path: Path)[source]

Bases: object

Store the editable state of a GUI project.

blocks

Block instances currently present in the project.

connections

Connections currently present in the project.

simulation

Simulation parameter set for the project.

external

Optional external runtime path or identifier.

directory_path

Project directory on disk.

logging

Signals selected for logging.

logs

Last simulation logs.

plots

Plot configurations defined for the project.

clear()[source]

Reset blocks, connections, logs, plots, and simulation settings.

load_simulation(sim_data: dict, external=None)[source]

Load simulation settings into the project state.

Parameters:
  • sim_data – Serialized simulation settings.

  • external – Optional external runtime value.

get_block(name: str)[source]

Return the block with the given name if it exists.

Parameters:

name – Block instance name.

Returns:

Matching block instance, or None if not found.

add_block(block_instance: BlockInstance)[source]

Add a block instance to the project.

Parameters:

block_instance – Block instance to add.

remove_block(block_instance: BlockInstance)[source]

Remove a block instance from the project if present.

Parameters:

block_instance – Block instance to remove.

add_connection(conn: ConnectionInstance)[source]

Add a connection instance to the project.

Parameters:

conn – Connection instance to add.

remove_connection(conn: ConnectionInstance)[source]

Remove a connection instance from the project if present.

Parameters:

conn – Connection instance to remove.

get_connections_of_block(block_instance: BlockInstance) list[ConnectionInstance][source]

Return all connections touching the given block.

Parameters:

block_instance – Block instance to inspect.

Returns:

Connections where the block is either source or destination.

get_connections_of_port(port_instance: PortInstance) list[ConnectionInstance][source]

Return all connections attached to the given port.

Parameters:

port_instance – Port instance to inspect.

Returns:

Connections where the port is either source or destination.

get_output_signals() list[str][source]

Return all output signal paths currently available in the project.

Returns:

Output signal identifiers in Block.outputs.port format.

can_plot() tuple[bool, str][source]

Return whether plot generation is currently possible.

Returns:

Tuple containing the availability flag and the reason message.