Hello,
I would like to find the physical components related to a physical link. To do this, I go through the list of my physical components, I get the physical ports, and I retrieve the physical links. But when I have a physical link, I would like to find the component at the other end. I made this code that is not very elegant, but it does not work. Cmp_a and cmp_b are always empty. Is there a way to get the physical components from a physical link? Maybe via the Java API?
I saw that it was possible to use something like this “for nodeSrc in capella_query_by_name(pl, “Physical Link Ends”):” but it no longer works.
def traverse_nodepc(npc):
for pp in npc.get_contained_physical_ports():
for pl in pp.get_physical_links():
if pl.get_id() in link_set:
continue
link_set.add(pl.get_id())
ends = pl.get_connected_physical_ports()
if len(ends) == 2:
a, b = ends[0], ends[1]
comp_a = comp_b = None
for n in se.get_all_contents_by_type(NodePC):
if a in n.get_contained_physical_ports():
comp_a = n
if b in n.get_contained_physical_ports():
comp_b = n
for child in npc.get_owned_physical_components():
if isinstance(child, NodePC):
traverse_nodepc(child)
for npc in se.get_physical_architecture().get_physical_system().get_owned_physical_components():
if isinstance(npc, NodePC):
traverse_nodepc(npc)
Thanks in advance,