@@ -31,14 +31,15 @@ def __init__(self, from_port: Port, to_port: Port):
31
31
32
32
33
33
class AssemblyNode :
34
- def __init__ (self , name : Union [str , None ], step_size : float = None , mt = False , profiling = False ,
34
+ def __init__ (self , name : Optional [str ], step_size : float = None , mt = False , profiling = False ,
35
35
auto_link = True , auto_input = True , auto_output = True ):
36
36
self .name = name
37
37
if step_size :
38
38
try :
39
39
self .step_size = float (step_size )
40
40
except ValueError :
41
- logger .warning (f"{ step_size } " )
41
+ logger .warning (f"Step size '{ step_size } ' is incorrect format." )
42
+ self .step_size = None
42
43
else :
43
44
self .step_size = None
44
45
self .mt = mt
@@ -47,6 +48,7 @@ def __init__(self, name: Union[str, None], step_size: float = None, mt=False, pr
47
48
self .auto_input = auto_input
48
49
self .auto_output = auto_output
49
50
51
+ self .parent : Optional [AssemblyNode ] = None
50
52
self .children : List [AssemblyNode ] = [] # sub-containers
51
53
self .fmu_names_list : Set [str ] = set () # FMUs contained at this level
52
54
self .input_ports : Dict [Port , str ] = {}
@@ -59,9 +61,14 @@ def add_sub_node(self, sub_node):
59
61
if sub_node .name is None :
60
62
sub_node .name = str (uuid .uuid4 ())+ ".fmu"
61
63
64
+ if sub_node .parent is not None :
65
+ raise AssemblyError (f"Internal Error: AssemblyNode { sub_node .name } is already parented." )
66
+
67
+ sub_node .parent = self
62
68
self .fmu_names_list .add (sub_node .name )
63
69
self .children .append (sub_node )
64
70
71
+
65
72
def add_fmu (self , fmu_name : str ):
66
73
self .fmu_names_list .add (fmu_name )
67
74
0 commit comments