10. Context Diagrams Extension

We have an extension that visualizes contexts of Capella objects. The viewpoint definiton depends on the object type. The extension is external to capellambse library and needs to be installed separately. You may use the below command to install it or find more guidance in the package documentation.

[1]:
!pip install -q capellambse_context_diagrams

Now that the lib is installed we can load a test model

[2]:
from IPython.display import HTML, display  # we'll need that later

import capellambse

path_to_model = "../../../tests/data/melodymodel/5_2/Melody Model Test.aird"
model = capellambse.MelodyModel(path_to_model)

10.1. Logical Component Context

and now as the model is loaded lets have a look at a context diagram for the School component

[3]:
cmp = model.la.all_components.by_name("Whomping Willow")
cmp.context_diagram
[3]:
../_images/examples_09_Context_Diagrams_6_0.svg

10.2. Component Exchange Context

We also found it useful to spell-out the ComponentExchanges - this gives us a nice overview of functional interactions between the components

[4]:
cmp.related_exchanges.by_name("Punishment").context_diagram
[4]:
../_images/examples_09_Context_Diagrams_8_0.svg

it also works for more complex arrangements but we dont have one in the current test model ;-)

10.3. Functional (dataflow) Context

same applies for functions - we saw it useful to see what functions are dependent on an output of a function of interest and what inputs it needs to do what it should. We frequently use that view in documentation

[5]:
fnc = model.la.all_functions.by_name("educate Wizards")
fnc.context_diagram
[5]:
../_images/examples_09_Context_Diagrams_11_0.svg

10.4. Layers, other than LA

Other layers are supported too - for complete list see https://dsd-dbs.github.io/capellambse-context-diagrams/ (Features section)

[6]:
for act in model.oa.all_activities:
    display(HTML(f"<h3>Context of {act.name}</h3>"))
    display(act.context_diagram)

Context of Root Operational Activity

../_images/examples_09_Context_Diagrams_13_1.svg

Context of Sleep

../_images/examples_09_Context_Diagrams_13_3.svg

Context of Eat

../_images/examples_09_Context_Diagrams_13_5.svg

Context of Spawn wild animal

../_images/examples_09_Context_Diagrams_13_7.svg

Context of Make Food

../_images/examples_09_Context_Diagrams_13_9.svg

Context of Hunt wild animal

../_images/examples_09_Context_Diagrams_13_11.svg

Context of Search for animals

../_images/examples_09_Context_Diagrams_13_13.svg

Context of Play games

../_images/examples_09_Context_Diagrams_13_15.svg

Context of Spawn tree

../_images/examples_09_Context_Diagrams_13_17.svg

Context of Create landslide

../_images/examples_09_Context_Diagrams_13_19.svg

Context of Spawn water

../_images/examples_09_Context_Diagrams_13_21.svg

Context of Build house

../_images/examples_09_Context_Diagrams_13_23.svg

Context of Run away

../_images/examples_09_Context_Diagrams_13_25.svg

Context of Repeat

../_images/examples_09_Context_Diagrams_13_27.svg

Context of Kill

../_images/examples_09_Context_Diagrams_13_29.svg

10.5. Customizing context views

For almost every context view you can do some tuning. Just like in Capella itself you can apply view filters, like hide or show exchange items instead or next to exchange names. You can see more of the tuning options here: https://dsd-dbs.github.io/capellambse-context-diagrams/extras/filters/#capella-filters

[7]:
for cap in model.oa.all_capabilities:
    display(HTML(f"<h3>Context of {cap.name}</h3>"))
    diag = cap.context_diagram
    diag.display_symbols_as_boxes = True
    diag.render(None, no_edgelabels=True)
    display(diag)

Context of Stay alive

../_images/examples_09_Context_Diagrams_15_1.svg

Context of Escape predators

../_images/examples_09_Context_Diagrams_15_3.svg

Context of Eat food

../_images/examples_09_Context_Diagrams_15_5.svg

Context of Provide environment to live in

../_images/examples_09_Context_Diagrams_15_7.svg

Context of Provide clean water

../_images/examples_09_Context_Diagrams_15_9.svg

Context of Provide food sources

../_images/examples_09_Context_Diagrams_15_11.svg