Skip to content

Commit

Permalink
Merge branch 'templates-update'
Browse files Browse the repository at this point in the history
  • Loading branch information
vik378 committed Nov 21, 2024
2 parents cad7e36 + 8ce2f4c commit 8cc2259
Show file tree
Hide file tree
Showing 7 changed files with 595 additions and 49 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
31 changes: 17 additions & 14 deletions templates/common_macros.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -263,26 +263,29 @@
{% macro display_property_values(object) %}
{% if object.property_value_groups %}
<h2>Other properties (PVMT)</h2>
<p>The following properties were additionally assigned to {{ object.name }} via PVMT extension</p>
<p>The following properties were additionally assigned to {{ object.name }}:</p>
{# <p><b>{{ group.name | safe}}</b></p> #}
<table>
<thead>
<tr>
<th><b>Property</b></th>
<th><b>Value</b></th>
</tr>
</thead>
<tbody>
{% for group in object.property_value_groups %}
<p><b>{{ group.name | safe}}</b></p>
<table>
<thead>
<tr>
<th><b>Property</b></th>
<th><b>Value</b></th>
</tr>
</thead>
<tbody>
{% for prop in group.property_values %}
{%- set prop_def = prop.applied_property_values | first -%}
{%- set unit_def = prop_def.property_values | selectattr("name", "equalto", "__UNIT__") | first -%}
{%- set unit = unit_def.value if unit_def else "" -%}
<tr>
<td>{{ prop.name }}</td>
<td>{{ prop.value.name | safe if prop.value.name else prop.value }}</td>
<td>{{ linked_name_with_icon(prop) | safe }}</td>
<td>{{ prop.value.name | safe if prop.value.name else prop.value }} {{ unit }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endmacro %}

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 }}
145 changes: 145 additions & 0 deletions templates/logical-architecture/FIS.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{#
Copyright DB InfraGO AG and contributors
SPDX-License-Identifier: Apache-2.0
#}

{% from 'common_macros.html.j2' import show_other_attributes, description, typed_name, linked_name, linked_name_with_icon, display_traceability, render_requirements_table %}

{# {% macro linked_name_with_icon(obj) %}
{% if obj.name %}{{ obj.name }}{% else %}{{ obj }}{% endif %}
{% endmacro %} #}

{% macro insert_work_item(object) %}
{{ linked_name_with_icon(object) | safe }}
{% endmacro %}

{% macro add_class_dependencies(cls, classes) %}
{% if cls and cls.xtype == "org.polarsys.capella.core.data.information:Class" and not cls in classes %}
{% set _none = classes.append(cls) %}
{% if cls.super %}
{{ add_class_dependencies(cls.super, classes) }}
{% endif %}
{% for property in cls.properties %}
{% set type = None %}
{% if "type" in property.__dir__() %}
{% set type = property.type %}
{% elif "abstract_type" in property.__dir__() %}
{% set type = property.abstract_type %}
{% endif %}
{{ add_class_dependencies(type, classes) }}
{% endfor %}
{% endif %}
{% endmacro %}
{% macro insert_or_link(object, inserted) %}
{% if object not in inserted %}
{{ insert_work_item(object) | safe }}
{% set _ = inserted.append(object) %}
{% else %}
<p>{{ linked_name_with_icon(object) }}</p>
{% endif %}
{% endmacro %}

<h1>{{ "Functional Interface Specification " + object.name}}</h1>
<h2>Introduction</h2>
<p>
This Functional Interface Specification (FIS) document specifies functional communications between the sub-systems / components / system elements / actors of the System under Consideration.
</p>
<h2>Interface Partners</h2>
{% set partner_a = object.source.owner %}
{% set partner_b = object.target.owner %}
<p>This document specifies <i>{{ object.name }}</i>, an interface between {{ linked_name_with_icon(partner_a) | safe }} and {{ linked_name_with_icon(partner_b) | safe }}.</p>
<h3>{{ partner_a.name }}</h3>
{{ description(partner_a) | safe }}
<h3>{{ partner_b.name }}</h3>
{{ description(partner_b) | safe }}
<h2>Interface Description</h2>
<p>The interface enables the following functional interactions:</p>
{# todo: handle mesed up model state where a functional exchange was allocated, but then function was re-allocated to another component #}
{% set partner_a_provides = object.allocated_functional_exchanges | selectattr('source.owner.owner.uuid', "equalto", partner_a.uuid) | list %}
{% set partner_a_source_uuids = partner_a_providesmap(attribute="source.owner.uuid") | unique | list %}
{% set partner_b_provides = object.allocated_functional_exchanges | selectattr('source.owner.owner.uuid', "equalto", partner_b.uuid) | list %}
{% set partner_b_source_uuids = partner_b_providesmap(attribute="source.owner.uuid") | unique | list %}

{% macro describe_provided_functional_exchanges(exchanges, source, target, sources) %}
<p>{{ linked_name_with_icon(source) | safe}} may use the interface to interact with (provide exchange items to) {{ linked_name_with_icon(target) | safe}}:</p>
<table>
<thead>
<tr>
<th>Source function</th>
<th>Interaction or Exchange Items</th>
<th>Target function</th>
</tr>
</thead>
<tbody>
{% for src_uuid in sources %}
{% set filtered_exchanges = exchanges | selectattr('source.owner.uuid', "equalto", src_uuid) | list%}
{% for exchange in filtered_exchanges %}
<tr>
{% if loop.first %}
<td rowspan="{{filtered_exchanges | length}}">{{ linked_name_with_icon(exchange.source.owner) | safe }}</td>
{% endif %}
<td>
{% if exchange.exchange_items %}
{% if exchange.exchange_items | length > 1 %}
<ul>
{% for exi in exchange.exchange_items %}
<li><a href="#exi-{{exi.uuid}}">{{exi.name}}</a></li>
{% endfor %}
</ul>
{% else %}
{% set exi = exchange.exchange_items[0] %}
<a href="#exi-{{exi.uuid}}">{{exi.name}}</a>
{% endif %}
{% else %}
{{ linked_name_with_icon(exchange) | safe }}
{% endif %}
</td>
<td>{{ linked_name_with_icon(exchange.target.owner) | safe }}</td>
</tr>
{% endfor %}
{% endfor %}
</table>
{% endmacro %}

{% if partner_a_provides %}
{{ describe_provided_functional_exchanges(partner_a_provides, partner_a, partner_b, partner_a_source_uuids) | safe }}
{% endif %}

{% if partner_b_provides %}
{{ describe_provided_functional_exchanges(partner_b_provides, partner_b, partner_a, partner_b_source_uuids) | safe }}
{% endif %}

<h2>Interface Specification</h2>
<h3>Exchange Item (Message) Catalog</h3>
<p>This section identifies Exchange Items / Messages used within the interface.</p>
{% for exi in object.exchange_items %}
<h4 id="exi-{{exi.uuid}}">Exchange Item {{exi.name}}</h4>
{{ description(exi) | safe }}
{% for el in exi.elements %}
{{ add_class_dependencies(el.abstract_type, classes[direction]) }}
{% endfor %}

{% endfor %}

{# {%- set classes = {} -%}
{%- set inserted = [] -%}
{% for direction, eis in exchange_items_by_direction.items() %}
{% set _ = classes.setdefault(direction, []) %}
{{ heading(4, model.by_uuid(direction[0]).name + " → " + model.by_uuid(direction[1]).name, session) }}
{% for ei in eis | unique %}
{{ heading(5, work_item_field(ei, "id") + " - " + ei.name, session) }}
{{ insert_or_link(ei, inserted) }}
{% for el in ei.elements %}
{{ add_class_dependencies(el.abstract_type, classes[direction]) }}
{% endfor %}
{% endfor %}
{% endfor %} #}
{# {{ heading(3, "Message Description", session)}}
<p>This section provides a detailed description of each message used within the interface.</p>
{% for direction, clss in classes.items() %}
{{ heading(4, model.by_uuid(direction[0]).name + " → " + model.by_uuid(direction[1]).name, session) }}
{% for cl in clss | unique %}
{{ heading(5, work_item_field(cl, "id") + " - " + cl.name, session) }}
{{ insert_or_link(cl, inserted) }}
{% endfor %}
{% endfor %} #}
9 changes: 9 additions & 0 deletions templates/logical-architecture/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ categories:
type: ComponentExchange
below: la

- template: logical-architecture/FIS.html.j2
idx: functional-interface-specification
name: Functional Interface Specification
description: Defines functional interfaces between logical components (subsystems) and actors
isExperimental: true
scope:
type: ComponentExchange
below: la

- template: logical-architecture/logical-function.html.j2
idx: logical-function
name: Logical Functions
Expand Down
64 changes: 60 additions & 4 deletions templates/physical-architecture/phy-component.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,71 @@
Copyright DB InfraGO AG and contributors
SPDX-License-Identifier: Apache-2.0
#}
{% from 'common_macros.html.j2' import show_other_attributes, description %}
{% from 'common_macros.html.j2' import show_other_attributes, description, display_property_values, linked_name_with_icon %}

<h1>{{ object.name }}</h1>
<small style="color: #aaa">UUID: {{ object.uuid }}</small>

{{ description(object) | safe }}
{# what could be interesting to cover:
- component nature: hardware or software
- if it is hardware, list what software runs on it
- if it is software, list what hardware it runs on
show interfaces of the component
describe interfaces
#}
<h2>Context</h2>
<p>The context of {{ object.name }} is summarized by the diagram below:</p>
{{ object.context_diagram.render("svg", display_derived_interfaces=True) | safe }}
{{ object.context_diagram.render("svg", display_derived_interfaces=True, display_port_labels=True) | safe }}

<h2>Deployed software</h2>
<p>No software deployment specified</p>

{# <h2>Network interfaces</h2> #}
{# <p>tbd</p> #}

<h2>Electrical interfaces of {{ object.name }}</h2>

<table>
<thead>
<tr>
<th>Port</th>
{# <th>Port Type</th> #}
<th>Cable ID</th>
<th>Target</th>
<th>Target Port</th>
</tr>
</thead>
<tbody>
{% for port in object.physical_ports %}
{% set cables = port.links %}
{% if cables %}
{% for cable in cables %}
<tr>
{% set other_port = cable.ends | reject("equalto", port) | first %}
{% if loop.first %}
<td rowspan="{{ cables | length }}">{{ linked_name_with_icon(port) | safe }}</td>
{# <td rowspan="{{ cables | length }}">{{ port.property_value_groups["design_for_integration.PortDetails"].type.name | safe }}</td> #}
{% endif %}
<td>{{ linked_name_with_icon(cable) | safe }}</td>
<td>{{ linked_name_with_icon(other_port.owner) | safe }}</td>
<td>{{ linked_name_with_icon(other_port) | safe }}</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td>{{ linked_name_with_icon(port) | safe }}</td>
{# <td>{{ port.property_value_groups["design_for_integration.PortDetails"].type.name | safe }}</td> #}
<td colspan="3">No cable connections planned</td>
</tr>
{% endif %}
{% endfor %}
</table>


{{ display_property_values(object) | safe }}

<h2>Other properties of "{{ object.name }}"</h2>
{% set excluded = ["context_diagram", "description"] %}
{{ show_other_attributes(object, excluded) | safe}}
{% set excluded = ["context_diagram", "description", "physical_ports", "applied_property_value_groups", "property_value_groups", "name", "uuid"] %}
{{ show_other_attributes(object, excluded=excluded) | safe}}
Loading

0 comments on commit 8cc2259

Please sign in to comment.