<!-- Place a signal (event) into the cyboi system signal memory (event queue). -->
<node name="send_exit_signal" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="signal"/>
    <node name="message" channel="inline" format="live/exit" model=""/>
</node>

<!-- Send a signal that was read from a cybol file before. -->
<node name="send_signal_taken_from_file" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="signal"/>
    <node name="message" channel="file" format="element/part" model="exit/file/exit.cybol"/>
</node>

<!-- Send plain text to terminal. -->
<node name="say_hello" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="terminal"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".var.stdout"/>
    <node name="language" channel="inline" format="meta/language" model="message/tui"/>
    <node name="format" channel="inline" format="meta/format" model="text/plain"/>
    <node name="message" channel="inline" format="text/plain" model="Hello World!"/>
</node>

<!-- Print an http request's uri query action on terminal. -->
<node name="print_query" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="terminal"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".stdout"/>
    <node name="language" channel="inline" format="meta/language" model="message/tui"/>
    <node name="format" channel="inline" format="meta/format" model="text/plain"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".var.request:uri:query.action"/>
</node>

<!-- Print http request as pure ascii data on terminal. -->
<node name="print_request" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="terminal"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".stdout"/>
    <node name="language" channel="inline" format="meta/language" model="message/tui"/>
    <node name="format" channel="inline" format="meta/format" model="application/octet-stream"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".request"/>
</node>

<!-- Send boolean value (flag) to terminal. -->
<node name="log_flag" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="terminal"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".stdout"/>
    <node name="language" channel="inline" format="meta/language" model="message/tui"/>
    <node name="format" channel="inline" format="meta/format" model="logicvalue/boolean"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".result_flag"/>
</node>

<!-- Send integer number to terminal. -->
<node name="print_number" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="terminal"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".stdout"/>
    <node name="language" channel="inline" format="meta/language" model="message/tui"/>
    <node name="format" channel="inline" format="meta/format" model="number/integer"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".index"/>
</node>

<!-- Send decimal fraction number to terminal. -->
<node name="print_adc_value" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="terminal"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".stdout"/>
    <node name="language" channel="inline" format="meta/language" model="message/tui"/>
    <node name="format" channel="inline" format="meta/format" model="number/fraction-decimal"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".settings.adc"/>
</node>

<!-- Send main menu as text user interface (tui) to terminal. -->
<node name="send_menu" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="terminal"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".stdout"/>
    <node name="language" channel="inline" format="meta/language" model="message/tui">
        <node name="clear" channel="inline" format="logicvalue/boolean" model="true"/>
        <node name="positioning" channel="inline" format="logicvalue/boolean" model="true"/>
    </node>
    <node name="format" channel="inline" format="meta/format" model="element/part"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".tui.main"/>
</node>

<node name="set_cursor" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="terminal"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".stdout"/>
    <node name="language" channel="inline" format="meta/language" model="message/tui">
        <!-- The clear flag is false by default and therefore does not have to be added here. -->
        <node name="positioning" channel="inline" format="logicvalue/boolean" model="true"/>
    </node>
    <!-- Use text/plain instead of element/part, since the cursor has just the position property but an empty model. -->
    <node name="format" channel="inline" format="meta/format" model="text/plain"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".tui.cursor"/>
</node>

<!-- Draw graphical user interface (gui) window on display. -->
<node name="refresh_display" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="display"/>
    <!-- This flag is IMPORTANT for finding the correct client entry in the server list. -->
    <node name="server" channel="inline" format="logicvalue/boolean" model="true"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".gui.window_id"/>
    <node name="language" channel="inline" format="meta/language" model="message/gui-response"/>
    <node name="format" channel="inline" format="meta/format" model="element/part"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".gui.window"/>
</node>

<!-- Write runtime knowledge tree into file, which is useful for testing. -->
<node name="open_file" channel="inline" format="dispatch/open" model="">
    <node name="channel" channel="inline" format="meta/channel" model="file"/>
    <node name="identification" channel="inline" format="text/cybol-path" model=".id"/>
    <node name="device" channel="inline" format="text/plain" model="counter/simple/test_counter_simple.txt"/>
    <node name="mode" channel="inline" format="text/plain" model="write"/>
</node>
<node name="send_knowledge_tree_root" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="file"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".id"/>
    <node name="encoding" channel="inline" format="meta/encoding" model="utf-8"/>
    <node name="language" channel="inline" format="meta/language" model="text/model-diagram"/>
    <node name="format" channel="inline" format="meta/format" model="element/part"/>
    <node name="message" channel="inline" format="text/cybol-path" model="."/>
</node>
<node name="close_file" channel="inline" format="dispatch/close" model="">
    <node name="channel" channel="inline" format="meta/channel" model="file"/>
    <node name="identification" channel="inline" format="text/cybol-path" model=".id"/>
</node>

<!-- Write binary data into a file. -->
<node name="test_file_content" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="file"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".id"/>
    <node name="language" channel="inline" format="meta/language" model="message/binary"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".var.file"/>
</node>

<!-- Serialise web user interface (wui) and store it as html file. -->
<node name="generate_html" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="file"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".id"/>
    <node name="encoding" channel="inline" format="meta/encoding" model="utf-8"/>
    <node name="language" channel="inline" format="meta/language" model="text/html">
        <node name="indentation" channel="inline" format="logicvalue/boolean" model="true"/>
    </node>
    <node name="format" channel="inline" format="meta/format" model="element/part"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".wui.index"/>
</node>

<!-- Serialise a webpage into html within the knowledge tree and afterwards save it as file. -->
<node name="serialise_webpage" channel="inline" format="represent/serialise" model="">
    <node name="destination" channel="inline" format="text/cybol-path" model=".var.webpage"/>
    <node name="source" channel="inline" format="text/cybol-path" model=".wui.index"/>
    <node name="format" channel="inline" format="meta/format" model="element/part"/>
    <node name="language" channel="inline" format="meta/language" model="text/html"/>
</node>
<node name="write_serialised_webpage_into_file" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="file"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".id"/>
    <node name="encoding" channel="inline" format="meta/encoding" model="utf-8"/>
    <node name="language" channel="inline" format="meta/language" model="text/cybol"/>
    <node name="format" channel="inline" format="meta/format" model="text/plain"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".var.webpage"/>
</node>

<!-- Assemble http response with webpage plus metadata and store it as file. -->
<node name="test_http_response" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="file"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".id"/>
    <node name="language" channel="inline" format="meta/language" model="message/http-response"/>
    <node name="format" channel="inline" format="meta/format" model="text/plain"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".var.webpage">
        <node name="Server" channel="inline" format="text/plain" model="CYBOI/0.22.0 (Linux) CYBOL/2.0.0"/>
        <node name="Connection" channel="inline" format="text/plain" model="close"/>
        <node name="Content-Type" channel="inline" format="text/plain" model="text/html"/>
    </node>
</node>

<!-- Send ascii text "Hello World!" as binary data via socket. -->
<node name="send_hello" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="socket"/>
    <node name="server" channel="inline" format="logicvalue/boolean" model="true"/>
    <node name="port" channel="inline" format="number/integer" model="1971"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".client_socket"/>
    <node name="language" channel="inline" format="meta/language" model="message/binary-crlf"/>
    <node name="message" channel="inline" format="application/octet-stream" model="Hello World!"/>
</node>

<!-- Send text data as http response via socket. -->
<node name="send_file" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="socket"/>
    <node name="server" channel="inline" format="logicvalue/boolean" model="true"/>
    <node name="port" channel="inline" format="number/integer" model="1971"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".var.client_socket"/>
    <node name="language" channel="inline" format="meta/language" model="message/http-response"/>
    <node name="format" channel="inline" format="meta/format" model="text/plain"/>
    <node name="message" channel="inline" format="text/cybol-path" model=".var.file"/>
</node>

<!-- Send empty text http-response to indicate end of communication. -->
<node name="send_empty_message" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="socket"/>
    <node name="server" channel="inline" format="logicvalue/boolean" model="true"/>
    <node name="port" channel="inline" format="number/integer" model="1971"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".var.client_socket"/>
    <node name="language" channel="inline" format="meta/language" model="message/http-response"/>
    <node name="format" channel="inline" format="meta/format" model="text/plain"/>
    <node name="message" channel="inline" format="text/plain" model=""/>
</node>

<!-- Send html encapsulated as http-response. -->
<node name="send" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="socket"/>
    <node name="server" channel="inline" format="logicvalue/boolean" model="true"/>
    <node name="port" channel="inline" format="number/integer" model="1971"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".var.client_socket"/>
    <node name="language" channel="inline" format="meta/language" model="message/http-response"/>
    <node name="format" channel="inline" format="meta/format" model="text/plain"/>
    <!--
        For the http response, the following headers are recommended:
        - Date
        - Server
        - Content-Length
        - Content-Type

        CAUTION! An "encoding" is NOT given when using the language "message/http-response",
        since it would cause the WHOLE http message to get encoded.
        But the http header should be ASCII (single-byte characters) only.
        Likewise, binary attachments such as images should NOT get encoded.

        CAUTION! It does NOT work adding the constraint "encoding" right here.
        It does properly appear in the knowledge tree, but is NOT recognised in the operation "send".
        The reason is that the format "text/cybol-path" points to another part ".webpage"
        whose properties are used INSTEAD of those constraints that might be specified here.
        In order to verify this, one might use the format "text/plain" testwise,
        with which the constraints are recognised properly.
        Therefore, the necessary "encoding" is added at the part ".webpage" DIRECTLY.
    -->
    <node name="message" channel="inline" format="text/cybol-path" model=".var.webpage">
        <node name="Connection" channel="inline" format="text/plain" model="keep-alive"/>
        <!--
        <node name="Content-Type" channel="inline" format="text/plain" model="text/html; charset=utf-8"/>
        -->
        <!--
            The client has 300 s == 5 min to make any additional requests before the connection is closed.
            The client can send up to 1000 more requests.
        -->
        <node name="Keep-Alive" channel="inline" format="text/plain" model="timeout=300, max=1000"/>
    </node>
</node>

<!-- Send request on client side to server via socket. -->
<node name="send_request" channel="inline" format="communicate/send" model="">
    <node name="channel" channel="inline" format="meta/channel" model="socket"/>
    <node name="receiver" channel="inline" format="text/cybol-path" model=".server_socket"/>
    <node name="language" channel="inline" format="meta/language" model="message/binary-crlf"/>
    <node name="message" channel="inline" format="application/octet-stream" model="say-hello"/>
</node>