Skip to content

Commit

Permalink
Merge branch 'main' into features/container_gui
Browse files Browse the repository at this point in the history
  • Loading branch information
nl78 committed Jan 20, 2025
2 parents bae373b + a889e5c commit 6c6c2b9
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions fmu_manipulation_toolbox/fmu_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class EmbeddedFMU(OperationAbstract):
def __init__(self, filename):
self.fmu = FMU(filename)
self.name = Path(filename).name
self.id = Path(filename).stem

self.fmi_version = None
self.step_size = None
Expand Down Expand Up @@ -151,7 +152,7 @@ def __eq__(self, other):

class Local:
def __init__(self, cport_from: ContainerPort):
self.name = cport_from.fmu.name[:-4] + "." + cport_from.port.name # strip .fmu suffix
self.name = cport_from.fmu.id + "." + cport_from.port.name # strip .fmu suffix
self.cport_from = cport_from
self.cport_to_list: List[ContainerPort] = []
self.vr = None
Expand Down Expand Up @@ -325,11 +326,15 @@ def add_implicit_rule(self, auto_input=True, auto_output=True, auto_link=True, a
self.mark_ruled(cport, 'LINK')
self.mark_ruled(candidate_cport, 'LINK')
self.locals[cport] = local
else:
if auto_output:
self.mark_ruled(cport, 'OUTPUT')
self.outputs[port_name] = cport
logger.info(f"AUTO OUTPUT: Expose {cport}")
elif auto_output:
self.mark_ruled(cport, 'OUTPUT')
self.outputs[port_name] = cport
logger.info(f"AUTO OUTPUT: Expose {cport}")
elif cport.port.causality == 'local' and port_name.startswith("container."):
local_portname = "container." + cport.fmu.id + "." + port_name[10:]
self.mark_ruled(cport, 'OUTPUT')
self.outputs[local_portname] = cport
logger.info(f"PROFILING: Expose {cport}")

if auto_input:
# Auto link inputs
Expand Down Expand Up @@ -460,7 +465,7 @@ def make_fmu_xml(self, xml_file, step_size: float, profiling: bool):
if profiling:
for fmu in self.execution_order:
vr = vr_table.add_vr("Real")
name = f"container.{fmu.model_identifier}.rt_ratio"
name = f"container.{fmu.id}.rt_ratio"
print(f'<ScalarVariable valueReference="{vr}" name="{name}" causality="local">'
f'<Real /></ScalarVariable>', file=xml_file)

Expand Down

0 comments on commit 6c6c2b9

Please sign in to comment.