Skip to content

Commit

Permalink
feat: sys def template upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
vik378 committed Oct 31, 2024
1 parent aa75d86 commit c899ced
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 30 deletions.
4 changes: 4 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ h1 {
@apply mb-3 mt-5 text-2xl;
}

.html-content h4 {
@apply mb-3 mt-5 text-xl;
}

.html-content table {
@apply min-w-full divide-y divide-gray-400;
}
Expand Down
6 changes: 4 additions & 2 deletions templates/cross-cutting/classes.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
{% endmacro %}

<h1><span style="font-weight: normal">{{ object.__class__.__name__ }}</span> <b>{{ object.name }}</b></h1>
<small style="color: #aaa">UUID: {{ object.uuid }}</small>

<p>Parent: {{ linked_name_with_icon(object.parent) | safe }}</p><br>
{% if object.description %}
<p>{{ object.description }}</p>
Expand Down Expand Up @@ -113,7 +115,7 @@
{% endif %}


{% set handled_attrs = ["from_model", "pvmt", "owned_properties", "properties", "parent", "generalizations", "super", "tree_view", "xtype", "name"]%}
{% set handled_attrs = ["from_model", "pvmt", "owned_properties", "properties", "parent", "generalizations", "super", "tree_view", "xtype", "name", "uuid", "description"]%}

<h2>Other Object Attributes</h2>
{{ show_other_attributes(object, handled_attrs) | safe }}
{{ show_other_attributes(object, excluded=handled_attrs) | safe }}
200 changes: 172 additions & 28 deletions templates/system-analysis/system-definition.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
SPDX-License-Identifier: Apache-2.0
#}

{% from 'common_macros.html.j2' import show_other_attributes, linked_name_with_icon %}
{% from 'common_macros.html.j2' import show_other_attributes, linked_name_with_icon, display_property_label, description %}

{% set object = model.sa.root_component%}
<h1>System Definition</h1>
<small>Template version: 0.1</small>

<h2>Introduction</h2>
<h3>Purpose</h3>
<h2>1 Introduction</h2>
<h3>1.1 Document Purpose</h3>
<p>The purpose of this document is the following:</p>
<ul>
<li>Definition of the system objectives (capabilities)</li>
<li>Definition of the purpose of the system, system capabilities</li>
<li>System description, including the following aspects
<ul>
<li>the system boundary and the actors interacting with the system</li>
<li>the system and actor functions which are necessary to achieve the system capabilities</li>
<li>how the system functions are used to achieve the system capabilities</li>
<li>Definition of the system functions</li>
<li>The system boundary and the actors interacting with the system</li>
<li>Definition of the interfaces between the system and the actors</li>
</ul>
</li>
<li>Application conditions and limitations</li>
Expand All @@ -33,32 +34,175 @@
<li>IVV, to provide basic understanding about the system</li>
</ul>

<h2>System boundary</h2>
<p>The system boundary is defined by the following:</p>
<h2>2 System Description</h2>
{{ description(object) | safe }}

<h2>3 System Capabilities</h2>
{% set capabilities = model.sa.all_capabilities %}
{% if capabilities %}
<p>This chater provides an overview of the capabilities that the <i>{{ object.name }}</i> system enables.</p>
{% for cap in capabilities %}
<h3>3.{{ loop.index }} {{ linked_name_with_icon(cap) | safe }}</h3>
{{ cap.description }}

{% if cap.precondition %}
<p><b>Pre-condition</b>:
{{ cap.precondition.specification['capella:linkedText']|safe }}</p>
{% else %}
<p style="color:red">No pre-condition defined for system capability {{ cap.name }}</p>
{% endif %}

{% if cap.postcondition %}
<p><b>Post-condition</b>:
{{ cap.postcondition.specification['capella:linkedText']|safe }}</p>
{% else %}
<p style="color:red">No post-condition defined for system capability {{ cap.name }}</p>
{% endif %}
{% endfor %}
{% else %}
<p style="color:red">The system is not involved in any Capability.</p>
{% endif %}

<h2>4 System Boundary</h2>
<p>The figure below provides an overview of the system boundary and depicts all the Actors that the <i>{{ object.name }}</i> intearcts with.</p>
{{ object.context_diagram.as_svg | safe}}

<h2>System Functions</h2>
{% if object.allocated_functions | length > 0 %}
<p>The system is expected to perform the following functions:</p>
<ul>
{% for fnc in object.allocated_functions %}
<li><a href="{{ fnc | make_href }}">{{ linked_name_with_icon(fnc) | safe }}</a></li>
{% endfor %}
</ul>
<p>The <i>{{object.name}}</i> interacts with the actors described below.</p>

{% set actors = model.sa.all_actors %}
{% set caps = model.sa.all_capabilities %}
{% if actors %}
{% for actor in actors %}
<h3>4.{{ loop.index }} {{ linked_name_with_icon(actor) | safe }}</h3>
<p>{{ actor.description }}</p>

{%- set involving_caps = [] -%}
{%- for cap in caps -%}
{%- set _none = involving_caps.append(cap) if actor in cap.involved_components else "" %}
{%- endfor -%}

{% if involving_caps %}
<p><i>{{ actor.name }}</i> is involved in the following system capabilities:&nbsp;
{%- for cap in involving_caps -%}
{{ linked_name_with_icon(cap) | safe }}{% if not loop.last %}, {% endif %}
{%- endfor -%}
</p>
{% endif %}
{% endfor %}
{% else %}
<p style="color:red">No actors defined for the system.</p>
{% endif %}

<h2>5 System Functions</h2>
<p>This chapter defines the functions of the system</p>

{% if object.allocated_functions %}
{% for function in object.allocated_functions %}
<h3>5.{{ loop.index }} {{ linked_name_with_icon(function) | safe }}</h3>
{{ description(function) | safe }}

{# TODO: describe inputs, outputs and capability involvements; distinguish internal vs external #}

{% if function.involved_in %}
<p>While performing <i>{{ function.name }}</i> the <i>{{ object.name }}</i> contributes to the following system capabilities:&nbsp;
{%- for cap in function.involved_in -%}
{{ linked_name_with_icon(cap) | safe }}{% if not loop.last %}, {% endif %}
{%- endfor -%}</p>
{% endif %}

{% endfor %}
{% else %}
<p style="color:red">No functions allocated to the system.</p>
{% endif %}

{% if object.diagrams %}
<h2>Diagrams</h2>
<p>The following diagrams provide additional details on the system</p>
{% for diagram in object.diagrams %}
<h3>{{diagram.name}}</h3>
{{ diagram.as_svg |safe }}
<h2>6 System Interfaces</h2>
<p>This chapter describes the interfaces between the system and the actors.</p>

{% set exchange_items_catalog = [] %}

{% macro describe_exchange(object) %}
{%- set source_function = object.source.owner -%}
{%- set target_function = object.target.owner -%}
{%- set source = source_function.owner -%}
{%- set target = target_function.owner -%}
The {{ linked_name_with_icon(source) | safe }} shall provide {{ linked_name_with_icon(object) | safe }} to {{ linked_name_with_icon(target) | safe }} so that the {{ linked_name_with_icon(target) | safe }} could {{ linked_name_with_icon(target_function)|safe }}.
{% endmacro %}

{% set interfaces = object.related_exchanges %}
{% if interfaces %}
{% for interface in interfaces %}
<h3>6.{{ loop.index }} {{ linked_name_with_icon(interface) | safe }}</h3>
{% if interface.description %}
{{ interface.description | safe }}
{% endif %}

{% if interface.allocated_functional_exchanges %}
<p>The figure below provides an overviow of the functional interactions enabled by this interface.</p>
{{ interface.context_diagram.as_svg | safe }}

<p>The interface may be used for the following functional interactions:</p>
<table>
<thead>
<tr>
<th>ID</th>
<th>Interaction description</th>
</thead>
<tbody>
{% for exchange in interface.allocated_functional_exchanges %}
<tr>
<td><a href="{{ exchange | make_href }}">{{ "LEXC-" + exchange.uuid[:5] | upper }}</a></td>
<td>
{{ describe_exchange(exchange) | safe }}
{% if exchange.exchange_items %}
{% if exchange.exchange_itemslength > 1 %}
<p>{{ exchange.name }} is further specified via the following Exchange Items:</p>
<ul>
{% for item in exchange.exchange_items %}
<li>{{ linked_name_with_icon(item) | safe }}</li>
{%- if item not in exchange_items_catalog -%}
{%- set _none = exchange_items_catalog.append(item) -%}
{%- endif -%}
{% endfor %}
</ul>
{% else %}
<p>This interaction is further specified via {{ linked_name_with_icon(exchange.exchange_items[0]) | safe}} Exchange Item</p>
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p style="color:red">No exchanges defined for the interface.</p>
{% endif %}
{% endfor %}
{% else %}
<p style="color:red">No interfaces defined for the system.</p>
{% endif %}

<h2>State Machines</h2>
{% if exchange_items_catalog %}
<h2>Apendix A: Exchange Items Catalog</h2>
<p>The following items (energy, material, information) are exchanged through the system interactions with its interface partners</p>
{% for item in exchange_items_catalog %}
<h3>A.{{ loop.index}} {{ linked_name_with_icon(item) | safe }}</h3>
{% if item.description %}
{{ item.description | safe }}
{% endif %}

{% if item.elements %}
<h4>Composition</h4>
<p>The exchange item "{{ item.name }}" is composed of the following elements:</p>
<ul>
{%- for element in item.elements -%}
<li>{{ display_property_label(item, element) | safe }}</li>
{%- endfor -%}
</ul>
{% endif %}
{% endfor %}
{% endif %}


{# <h2>State Machines</h2>
<p>The following state machines describe system modes and states:</p>
{% for stm in object.state_machines %}
<h3>{{ stm.name }}</h3>
Expand All @@ -79,11 +223,11 @@
{% else %}
<p style="color:red">State machine {{ stm.name }} has no regions.</p>
{% endif %}
{% endfor %}
{% endfor %} #}

{# TODO: object.description may contain a malformed link, we need to handle that #}

<h2>Other properties of the system</h2>
{% set excluded = ["description", "context_diagram", "owner", "parent", "allocated_functions", "diagrams", "name", "parts", "realizing_components", "state_machines", "xtype"] %}
{# <h2>Other properties of the system</h2>
{% set excluded = ["description", "context_diagram", "owner", "parent", "allocated_functions", "diagrams", "name", "parts", "realizing_components", "state_machines", "xtype", "ports", "related_exchanges"] %} #}

{{ show_other_attributes(object, excluded) | safe}}
{# show_other_attributes(object, excluded=excluded) | safe #}

0 comments on commit c899ced

Please sign in to comment.