diff --git a/templates/system-analysis/system-definition.html.j2 b/templates/system-analysis/system-definition.html.j2 index a895dbc..e90cec9 100644 --- a/templates/system-analysis/system-definition.html.j2 +++ b/templates/system-analysis/system-definition.html.j2 @@ -132,142 +132,151 @@ {% endmacro %} +{% macro decorate_own_source(exchange) %} +{{ linked_name_with_icon(exchange.source.owner) | safe }} (own function) +{% endmacro %} + +{% macro decorate_actor_source(exchange) %} +{{ linked_name_with_icon(exchange.source.owner) | safe }}, a function of {{ linked_name_with_icon(exchange.source.owner.owner) | safe }} +{% endmacro %} + +{% macro decorate_actor_target(exchange) %} +{{ linked_name_with_icon(exchange.target.owner) | safe }}, a function of {{ linked_name_with_icon(exchange.target.owner.owner) | safe }} +{% endmacro %} + +{% macro decorate_own_target(exchange) %} +{{ linked_name_with_icon(exchange.target.owner) | safe }} (own function) +{% endmacro %} + {% if object.allocated_functions %} {% for function in object.allocated_functions %}
The function {{ function.name }} may need the following inputs:
- {% set internal_inputs = [] %} - {% set external_inputs = [] %} - {% set undefined_owner_inputs = [] %} - {% set ports_with_no_exchanges = [] %} - - {% for input in function.inputs %} - {% if input.exchanges %} - {% for exchange in input.exchanges %} - {% set partner = exchange.source.owner.owner %} - {% if partner and partner != object %} - {% set external_inputs = external_inputs.append(exchange) %} - {% elif partner == object %} - {% set internal_inputs = internal_inputs.append(exchange) %} - {% else %} - {% set undefined_owner_inputs = undefined_owner_inputs.append(exchange) %} - {% endif %} - {% endfor %} - {% else %} - {% set ports_with_no_exchanges = ports_with_no_exchanges.append(input) %} - {% endif %} - {% endfor %} - + {# Classify Functional IO #} + {%- set internal_inputs = [] -%} + {%- set external_inputs = [] -%} + {%- set undefined_owner_inputs = [] -%} + {%- set input_ports_with_no_exchanges = [] -%} + {%- set internal_outputs = [] -%} + {%- set external_outputs = [] -%} + {%- set undefined_owner_outputs = [] -%} + {%- set output_ports_with_no_exchanges = [] -%} + + {%- if function.inputs -%} + {%- for input in function.inputs -%} + {%- if input.exchanges -%} + {%- for exchange in input.exchanges -%} + {%- set partner = exchange.source.owner.owner -%} + {%- if partner and partner != object -%} + {%- set none_ = external_inputs.append(exchange) -%} + {%- elif partner == object -%} + {%- set none_ = internal_inputs.append(exchange) -%} + {%- else -%} + {%- set none_ = undefined_owner_inputs.append(exchange) -%} + {%- endif -%} + {%- endfor -%} + {%- else -%} + {%- set none_ = input_ports_with_no_exchanges.append(input) -%} + {%- endif -%} + {%- endfor -%} + {%- endif -%} + + {%- if function.outputs -%} + {%- for output in function.outputs -%} + {%- if output.exchanges -%} + {%- for exchange in output.exchanges -%} + {%- set partner = exchange.target.owner.owner -%} + {%- if partner and partner != object -%} + {%- set none_ = external_outputs.append(exchange) -%} + {%- elif partner == object -%} + {%- set none_ = internal_outputs.append(exchange) -%} + {%- else -%} + {%- set none_ = undefined_owner_outputs.append(exchange) -%} + {%- endif -%} + {%- endfor -%} + {%- else -%} + {%- set none_ = output_ports_with_no_exchanges.append(output) -%} + {%- endif -%} + {%- endfor -%} + {%- endif -%} - {% macro decorate_own_source(exchange) %} - {{ linked_name_with_icon(exchange.source.owner) | safe }} (own function) - {% endmacro %} - - {% macro decorate_actor_source(exchange) %} - {{ linked_name_with_icon(exchange.source.owner) | safe }}, a function of {{ linked_name_with_icon(exchange.source.owner.owner) | safe }} - {% endmacro %} + {# Visualize Functional IO #} - {% if external_inputs %} -Inputs from activities of external actors:
- {{ functional_exchanges_table("Input", "Source", external_inputs, decorate_actor_source) | safe }} - {% endif %} - - {% if internal_inputs %} -Inputs from internal activities of {{ object.name }}
-To {{ function.name }} {{object.name}} may need:
- {{ functional_exchanges_table("Input", "Source", internal_inputs, decorate_own_source) | safe }} - {% endif %} + {% if function.inputs %} +The function {{ function.name }} may need the following inputs:
+ + {% if external_inputs %} +Inputs from activities of external actors:
+ {{ functional_exchanges_table("Input", "Source", external_inputs, decorate_actor_source) | safe }} + {% endif %} - {% if undefined_owner_inputs %} -The following exchanges come from functions that are not allocated to any entity:
-Inputs from internal activities of {{ object.name }}
+To {{ function.name }} {{object.name}} may need:
+ {{ functional_exchanges_table("Input", "Source", internal_inputs, decorate_own_source) | safe }} + {% endif %} - {% if ports_with_no_exchanges %} -The following input ports have no incoming exchanges defined:
-The following exchanges come from functions that are not allocated to any entity:
+The following input ports have no incoming exchanges defined:
+{{object.name}} seems to require no inputs to {{function.name}}.
+{{object.name}} seems to require no inputs to {{function.name}}.
{% endif %} {% if function.outputs %} -The function {{ function.name }} may produce the following outputs:
- {% set internal_outputs = [] %} - {% set external_outputs = [] %} - {% set undefined_owner_outputs = [] %} - {% set ports_with_no_exchanges = [] %} - - {% for output in function.outputs %} - {% if output.exchanges %} - {% for exchange in output.exchanges %} - {% set partner = exchange.target.owner.owner %} - {% if partner and partner != object %} - {% set external_outputs = external_outputs.append(exchange) %} - {% elif partner == object %} - {% set internal_outputs = internal_outputs.append(exchange) %} - {% else %} - {% set undefined_owner_outputs = undefined_owner_outputs.append(exchange) %} - {% endif %} - {% endfor %} - {% else %} - {% set ports_with_no_exchanges = ports_with_no_exchanges.append(output) %} +The function {{ function.name }} may produce the following outputs:
+ + {% if external_outputs %} +Outputs to activities of external actors:
+ {{ functional_exchanges_table("Output", "Target", external_outputs, decorate_actor_target) | safe }} {% endif %} - {% endfor %} - - {% macro decorate_actor_target(exchange) %} - {{ linked_name_with_icon(exchange.target.owner) | safe }}, a function of {{ linked_name_with_icon(exchange.target.owner.owner) | safe }} - {% endmacro %} - - {% macro decorate_own_target(exchange) %} - {{ linked_name_with_icon(exchange.target.owner) | safe }} (own function) - {% endmacro %} - {% if external_outputs %} -Outputs to activities of external actors:
- {{ functional_exchanges_table("Output", "Target", external_outputs, decorate_actor_target) | safe }} - {% endif %} + {% if internal_outputs %} +Outputs to internal activities of {{ object.name }}
+From {{ function.name }} {{object.name}} may produce:
+ {{ functional_exchanges_table("Output", "Target", internal_outputs, decorate_own_target) | safe }} + {% endif %} - {% if internal_outputs %} -Outputs to internal activities of {{ object.name }}
-From {{ function.name }} {{object.name}} may produce:
- {{ functional_exchanges_table("Output", "Target", internal_outputs, decorate_own_target) | safe }} - {% endif %} + {% if undefined_owner_outputs %} +The following exchanges go to functions that are not allocated to any entity:
+The following exchanges go to functions that are not allocated to any entity:
-The following output ports have no outgoing exchanges defined:
+{{object.name}} seems to produce no outputs from {{function.name}}.
{% endif %} - {% if ports_with_no_exchanges %} -The following output ports have no outgoing exchanges defined:
-{{object.name}} seems to produce no outputs from {{function.name}}.
+ {% if not function.inputs and not function.outputs %} +{{ object.name }} seem to require no inputs and provide no outputs while performing "{{ function.name }}" which doesn't seem correct. A function should consume inputs and produce observable outputs unless it is a source or sink function.
{% endif %}