9. 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.

[ ]:
!pip install capellambse_context_diagrams

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

[1]:
from IPython.display import display, HTML  # 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)
Cannot load PVMT extension: ValueError: Provided model does not have a PropertyValuePkg
Property values are not available in this model

9.1. Logical Component Context

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

[2]:
cmp = model.la.all_components.by_name("Whomping Willow")
cmp.context_diagram
[2]:

9.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

[3]:
cmp.related_exchanges.by_name("Punishment").context_diagram
[3]:

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

9.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

[4]:
fnc = model.la.all_functions.by_name("educate Wizards")
fnc.context_diagram
[4]:

9.4. Layers, other than LA

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

[5]:
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

Context of Sleep

Context of Eat

Context of Spawn wild animal

Context of Make Food

Context of Hunt wild animal

Context of Search for animals

Context of Play games

Context of Spawn tree

Context of Create landslide

Context of Spawn water

Context of Build house

Context of Run away

Context of Repeat

Context of Kill

9.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

[6]:
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

Context of Escape predators

Context of Eat food

Context of Provide environment to live in

Context of Provide clean water

Context of Provide food sources