svghmi/scripts.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 19 Apr 2020 10:48:34 +0200
branchsvghmi
changeset 2940 034b6ce4f885
parent 2938 1379cd5c69dd
permissions -rw-r--r--
SVGHMI: Introduced "emit" to simplify producing per-topic code and content from anywhere in code. Applied to debug output, next to JS.
function "scripts"
{
    |
    | id = idstr => document.getElementById(idstr);
    |
    | var hmi_hash = [«$hmitree/@hash»];

    | var hmi_widgets = {
    apply "$hmi_elements", mode="hmi_elements";
    | }
    |
    | var heartbeat_index = «$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index»;
    |
    | var hmitree_types = [

    foreach "$indexed_hmitree/*" {
    |     /* «@index»  «@hmipath» */ "«substring(local-name(), 5)»"`if "position()!=last()" > ,`
    }

    | ]
    |

    | var detachable_elements = {
    foreach "$detachable_elements"{
    |     "«@id»":[id("«@id»"), id("«../@id»")]`if "position()!=last()" > ,`
    }
    | }

    |
    | var page_desc = {
    apply "$hmi_pages", mode="page_desc";
    | }

    | var keypads = {
    foreach "$keypads_descs"{
        const "keypad_id","@id";
        foreach "arg"{
            const "g", "$geometry[@Id = $keypad_id]";
    |     "«@value»":["«$keypad_id»", «$g/@x», «$g/@y»],
        }
    }
    | }


    |
    | var default_page = "«$default_page»";
    | var svg_root = id("«/svg:svg/@id»");
    include text svghmi.js
}