Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nl78 committed Dec 17, 2024
1 parent 61eb12e commit 756aa1b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions fmu_manipulation_toolbox/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, name: str, step_size: float = None, mt = False, profiling = F
self.auto_output = auto_output
self.children: List[AssemblyNode] = []

self.fmu_names_list: List[str] = []
self.fmu_names_list: Set[str] = set()
self.input_ports: Dict[Port, str] = {}
self.output_ports: Dict[Port, str] = {}
self.start_values: Dict[Port, str] = {}
Expand All @@ -53,11 +53,11 @@ def add_sub_node(self, sub_node):
if sub_node.name is None:
sub_node.name = str(uuid.uuid4())+".fmu"

self.fmu_names_list.append(sub_node.name)
self.fmu_names_list.add(sub_node.name)
self.children.append(sub_node)

def add_fmu(self, fmu_name: str):
self.fmu_names_list.append(fmu_name)
self.fmu_names_list.add(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 Expand Up @@ -283,7 +283,7 @@ def json_encode_node(self, node: AssemblyNode) -> Dict[str, Any]:
json_node["container"] = [self.json_encode_node(child) for child in node.children]

if node.fmu_names_list:
json_node["fmu"] = [f"{fmu_name}" for fmu_name in node.fmu_names_list]
json_node["fmu"] = [f"{fmu_name}" for fmu_name in sorted(node.fmu_names_list)]

if node.input_ports:
json_node["input"] = [[f"{source}", f"{port.fmu_name}", f"{port.port_name}"]
Expand Down
14 changes: 7 additions & 7 deletions fmu_manipulation_toolbox/ssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
class SSP:
def __init__(self, fmu_directory: Path, ssp_filename: Path):
self.ssp_filename = ssp_filename
self.analyse_ssp(fmu_directory)
self.fmu_directory = fmu_directory
self.analyse_ssp()

def analyse_ssp(self, fmu_directory: Path):
with zipfile.ZipFile(self.ssp_filename) as zin:
def analyse_ssp(self):
with zipfile.ZipFile(self.fmu_directory / self.ssp_filename) as zin:
for file in zin.filelist:
target_filename = Path(file.filename).name
if file.filename.endswith(".fmu"): # Extract all FMUs into the fmu_directory
zin.getinfo(file.filename).filename = target_filename
zin.extract(file, path=fmu_directory)
#elif file.filename == "SystemStructure.ssd":
elif file.filename.endswith(".ssd"):
zin.extract(file, path=self.fmu_directory)
elif file.filename == "SystemStructure.ssd":
zin.getinfo(file.filename).filename = target_filename
zin.extract(file, path=fmu_directory)
zin.extract(file, path=self.fmu_directory)
with zin.open(file) as file_handle:
self.analyse_ssd(file_handle, target_filename)

Expand Down
File renamed without changes.

0 comments on commit 756aa1b

Please sign in to comment.