{% import "partials/icons.html" as ic %} {# The junction editor: the map's movements, and this scenario's timings. Split the way the document is. `signal_groups` is the road -- which signals change as one, which movements cross -- and is the same for every scenario here. `traffic_signal_controllers` is the timing, which is this scenario's to choose. Every control posts on change and swaps the whole body, like the rest of the inspector, so a rename reaches the lists that offer the name immediately. #} {%- set groups = document.map.signal_groups -%} {%- set controllers = document.map.traffic_signal_controllers -%}

{{ ic.icon('target', 12) }} Traffic signals

Movements belong to the map; timings belong to this scenario. A phase sets every movement at once, which is what keeps a junction consistent.

{# -- the road ---------------------------------------------------------- #}

Signal groups

{% if not groups %}

None yet. A group is the set of signals that change together — one approach, usually.

{% endif %} {% for group in groups %}
{{ group.name or 'unnamed' }} {{ group.lanelet2_regulatory_element_ids|length }} signal{{ '' if group.lanelet2_regulatory_element_ids|length == 1 else 's' }}

The Lanelet2 traffic_light regulatory elements this movement drives.

{% set others = groups|rejectattr('name', 'equalto', group.name)|list %} {% if others %}
{% for other in others %} {% endfor %}

Movements that cross this one. No phase may let both through — the check reads it both ways, so ticking it on either side is enough.

{% endif %}
{% endfor %}
{# -- this scenario's timing -------------------------------------------- #}

Controllers

{% if not controllers %}

None yet. A controller walks its phases in a loop, each for its own duration.

{% endif %} {% for controller in controllers %} {% set ci = loop.index0 %}
{{ controller.name or 'unnamed' }} {{ controller.phases|length }} phase{{ '' if controller.phases|length == 1 else 's' }} {%- if controller.phases %} · {{ controller.phases|sum(attribute='duration_seconds')|round(1) }} s{% endif %}
{% set peers = controllers|rejectattr('name', 'equalto', controller.name)|list %} {% if peers %}
{% if controller.reference %}

Measured from when {{ controller.reference }} began its first phase. A green wave is declared this way, not timed by actions.

{% endif %} {% endif %}
{# -- the cycle ----------------------------------------------------- #}
{% for phase in controller.phases %} {% set pi = loop.index0 %}
{{ phase.name or 'unnamed' }} {{ phase.duration_seconds }} s {% if not loop.first %}
{% endif %} {% if not loop.last %}
{% endif %}
{% if groups %} {%- set shown = {} -%} {%- for state in phase.states if state.group -%} {%- set _ = shown.update({state.group: state.state}) -%} {%- endfor -%} {% for group in groups %}
{% endfor %} {% else %}

Declare a signal group above and this phase will set it.

{% endif %} {%- set by_id = phase.states|rejectattr('group')|list -%} {% if by_id %}

Also sets {{ by_id|length }} signal{{ '' if by_id|length == 1 else 's' }} by regulatory element id ({{ by_id|map(attribute='lanelet2_regulatory_element_id')|join(', ') }}), written by hand in the document. Left untouched by this form.

{% endif %}
{% endfor %}
{% endfor %}