Skip to content

Commit

Permalink
Keep ordered list of FMU in Assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Laurent committed Jan 27, 2025
1 parent 54ef6a4 commit 8e0ba1e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
8 changes: 5 additions & 3 deletions fmu_manipulation_toolbox/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, name: Optional[str], step_size: float = None, mt=False, profi

self.parent: Optional[AssemblyNode] = None
self.children: Dict[str, AssemblyNode] = {} # sub-containers
self.fmu_names_list: Set[str] = set() # FMUs contained at this level
self.fmu_names_list: List[str] = [] # FMUs contained at this level (ordered list)
self.input_ports: Dict[Port, str] = {} # value is input port name, key is the source
self.output_ports: Dict[Port, str] = {} # value is output port name, key is the origin
self.start_values: Dict[Port, str] = {}
Expand All @@ -75,11 +75,13 @@ def add_sub_node(self, sub_node):
raise AssemblyError(f"Internal Error: AssemblyNode {sub_node.name} is already child of {self.name}")

sub_node.parent = self
self.fmu_names_list.add(sub_node.name)
if sub_node.name not in self.fmu_names_list:
self.fmu_names_list.append(sub_node.name)
self.children[sub_node.name] = sub_node

def add_fmu(self, fmu_name: str):
self.fmu_names_list.add(fmu_name)
if fmu_name not in self.fmu_names_list:
self.fmu_names_list.append(fmu_name)

def add_input(self, from_port_name: str, to_fmu_filename: str, to_port_name: str):
self.input_ports[Port(to_fmu_filename, to_port_name)] = from_port_name
Expand Down
62 changes: 31 additions & 31 deletions tests/containers/bouncing_ball/REF-container.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
0.001
# NB of embedded FMU's
2
bb_velocity.fmu
bb_velocity
{abf5f61d-b459-3641-3a2c-1e594b990280}
bb_position.fmu
bb_position
{8fbd9f16-ceaa-97ed-127f-987a60b25648}
bb_velocity.fmu
bb_velocity
{abf5f61d-b459-3641-3a2c-1e594b990280}
# NB local variables Real, Integer, Boolean, String
1 0 1 0
# CONTAINER I/O: <VR> <FMU_INDEX> <FMU_VR>
# Real
3
1 1 1
2 0 0
1 0 1
2 1 0
0 -1 0
# Integer
0
Expand All @@ -27,32 +27,6 @@ bb_position
0 -1 0
# String
0
# Inputs of bb_velocity.fmu - Real: <VR> <FMU_VR>
0
# Inputs of bb_velocity.fmu - Integer: <VR> <FMU_VR>
0
# Inputs of bb_velocity.fmu - Boolean: <VR> <FMU_VR>
1
0 0
# Inputs of bb_velocity.fmu - String: <VR> <FMU_VR>
0
# Start values of bb_velocity.fmu - Real: <FMU_VR> <VALUE>
0
# Start values of bb_velocity.fmu - Integer: <FMU_VR> <VALUE>
0
# Start values of bb_velocity.fmu - Boolean: <FMU_VR> <VALUE>
0
# Start values of bb_velocity.fmu - String: <FMU_VR> <VALUE>
0
# Outputs of bb_velocity.fmu - Real: <VR> <FMU_VR>
1
0 0
# Outputs of bb_velocity.fmu - Integer: <VR> <FMU_VR>
0
# Outputs of bb_velocity.fmu - Boolean: <VR> <FMU_VR>
0
# Outputs of bb_velocity.fmu - String: <VR> <FMU_VR>
0
# Inputs of bb_position.fmu - Real: <VR> <FMU_VR>
1
0 0
Expand All @@ -79,3 +53,29 @@ bb_position
0 0
# Outputs of bb_position.fmu - String: <VR> <FMU_VR>
0
# Inputs of bb_velocity.fmu - Real: <VR> <FMU_VR>
0
# Inputs of bb_velocity.fmu - Integer: <VR> <FMU_VR>
0
# Inputs of bb_velocity.fmu - Boolean: <VR> <FMU_VR>
1
0 0
# Inputs of bb_velocity.fmu - String: <VR> <FMU_VR>
0
# Start values of bb_velocity.fmu - Real: <FMU_VR> <VALUE>
0
# Start values of bb_velocity.fmu - Integer: <FMU_VR> <VALUE>
0
# Start values of bb_velocity.fmu - Boolean: <FMU_VR> <VALUE>
0
# Start values of bb_velocity.fmu - String: <FMU_VR> <VALUE>
0
# Outputs of bb_velocity.fmu - Real: <VR> <FMU_VR>
1
0 0
# Outputs of bb_velocity.fmu - Integer: <VR> <FMU_VR>
0
# Outputs of bb_velocity.fmu - Boolean: <VR> <FMU_VR>
0
# Outputs of bb_velocity.fmu - String: <VR> <FMU_VR>
0

0 comments on commit 8e0ba1e

Please sign in to comment.