Skip to content

Context Diagram extension for capellambse🔗

This is a pluggable extension for py-capellambse that extends the AbstractDiagram base class with ContextDiagrams that are layouted by elkjs' Layered algorithm.

Context diagram of Left

Generate Context Diagrams from your model data!

Interface context diagram of Interface

Features🔗

Functions & Components🔗

The data is collected by either

It is served conveniently by get_elkdata.

Available via .context_diagram on a ModelObject with (diagram-class):

  • oa.Entity (OAB)

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("e37510b9-3166-4f80-a919-dfaac9b696c7").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context diagram of Environment Entity with type [OAB]

  • oa.OperationalActivity (OAIB)

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("8bcb11e6-443b-4b92-bec2-ff1d87a224e7").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context diagram of Activity Eat with type [OAIB]

  • oa.OperationalCapability (OCB)

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("da08ddb6-92ba-4c3b-956a-017424dbfe85").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context diagram of Middle OperationalCapability with type [OCB]

  • ctx.Mission (MCB)

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("5bf3f1e3-0f5e-4fec-81d5-c113d3a1b3a6").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context diagram of Mission Top secret with type [MCB]

  • ctx.Capability (MCB)

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("9390b7d5-598a-42db-bef8-23677e45ba06").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context diagram of Capability Capability with type [MCB]

  • ctx.SystemComponent (SAB)

  • ctx.SystemFunction (SDFB)

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("a5642060-c9cc-4d49-af09-defaa3024bae").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context diagram of Lost SystemFunction with type [SDFB]

  • la.LogicalComponent (LAB)

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("f632888e-51bc-4c9f-8e81-73e9404de784").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context diagram of Left LogicalComponent with type [LAB]

  • la.LogicalFunction (LDFB)

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("957c5799-1d4a-4ac0-b5de-33a65bf1519c").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context diagram of educate Wizards LogicalFunction with type [LDFB]

  • pa.PhysicalComponent (PAB)

    PhysicalNodeComponent

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("fdb34c92-7c49-491d-bf11-dd139930786e").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context of Physical Component [PAB]

    PhysicalBehaviourComponent

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("313f48f4-fb7e-47a8-b28a-76440932fcb9").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context diagram of PC Software [PAB]

  • pa.PhysicalFunction (PDFB)

    import capellambse
    
    model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
    diag = model.by_uuid("ee745644-07d7-40b9-ad7a-910dc8cbb805").context_diagram
    diag.render("svgdiagram").save(pretty=True)
    
    Context of Maintain Switch Firmware [PDFB]

Hierarchy in diagrams🔗

Hierarchical diagrams are diagrams where boxes have child boxes and edges contained. These form subdiagrams which can be layouted via ELK again. Hierarchy is identified and supported:

Hierarchical diagram

import capellambse

model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
obj = model.by_uuid("16b4fcc5-548d-4721-b62a-d3d5b1c1d2eb")
diagram = obj.context_diagram.render("svgdiagram", display_parent_relation=True)
diagram.save(pretty=True)
Context diagram of Hierarchy LogicalComponenet with type [LAB]

Customized edge routing🔗

Custom routing

The routing differs from ELK's Layered Algorithm: The flow display is disrupted! We configure exchanges such that they appear in between the context participants. This decision breaks the display of data flow which is one of the main aims of ELK's Layered algorithm. However this lets counter flow exchanges routes lengths and bendpoints increase.

Context diagram of Weird guy SystemFunction


See the code reference section for understanding the underlying implementation.