66from typing import *
77from pathlib import Path
88
9+ from .container import EmbeddedFMUPort
10+
911logger = logging .getLogger ("fmu_manipulation_toolbox" )
1012
1113
@@ -66,7 +68,7 @@ def __del__(self):
6668 def split_fmu (self ):
6769 logger .info (f"Splitting..." )
6870 config = self ._split_fmu (fmu_filename = str (self .fmu_filename ), relative_path = "" )
69- config_filename = self .directory / self .fmu_filename .with_suffix (".json" )
71+ config_filename = self .directory / self .fmu_filename .with_suffix (".json" ). name
7072 with open (config_filename , "w" ) as file :
7173 json .dump (config , file , indent = 2 )
7274 logger .info (f"Container definition saved to '{ config_filename } '" )
@@ -77,7 +79,7 @@ def _split_fmu(self, fmu_filename: str, relative_path: str) -> Dict[str, Any]:
7779 if txt_filename in self .filenames_list :
7880 description = FMUSplitterDescription (self .zip )
7981 config = description .parse_txt_file (txt_filename )
80- config ["name" ] = fmu_filename
82+ config ["name" ] = Path ( fmu_filename ). name
8183 for i , fmu_filename in enumerate (config ["candidate_fmu" ]):
8284 directory = f"{ relative_path } resources/{ i :02x} /"
8385 if directory not in self .dir_set :
@@ -134,6 +136,7 @@ def __init__(self, zip):
134136 self .current_vr = None
135137 self .current_name = None
136138 self .current_causality = None
139+ self .supported_fmi_types : Tuple [str ] = ()
137140
138141 @staticmethod
139142 def get_line (file ):
@@ -182,10 +185,12 @@ def parse_model_description(self, directory: str, fmu_filename: str):
182185 def parse_txt_file_header (self , file , txt_filename ):
183186 flags = self .get_line (file ).split (" " )
184187 if len (flags ) == 1 :
188+ self .supported_fmi_types = ("Real" , "Integer" , "Boolean" , "String" )
185189 self .config ["mt" ] = flags [0 ] == "1"
186190 self .config ["profiling" ] = self .get_line (file ) == "1"
187191 self .config ["sequential" ] = False
188192 elif len (flags ) == 3 :
193+ self .supported_fmi_types = EmbeddedFMUPort .ALL_TYPES
189194 self .config ["mt" ] = flags [0 ] == "1"
190195 self .config ["profiling" ] = flags [1 ] == "1"
191196 self .config ["sequential" ] = flags [2 ] == "1"
@@ -242,7 +247,7 @@ def add_port(self, fmi_type: str, fmu_id: int, fmu_vr: int, container_vr: int):
242247 logger .debug (f"Adding container port { causality } : { definition } " )
243248
244249 def parse_txt_file_ports (self , file ):
245- for fmi_type in ( "Real" , "Integer" , "Boolean" , "String" ) :
250+ for fmi_type in self . supported_fmi_types :
246251 nb_port_variables = self .get_line (file ).split (" " )[0 ]
247252 for i in range (int (nb_port_variables )):
248253 tokens = self .get_line (file ).split (" " )
0 commit comments