Node-RED 核心概念


    Node
    A Node is the basic building block of a flow.

    节点通过从流程中的前一个节点接收消息,或通过等待某些外部事件(如传入的HTTP请求、定时器或GPIO硬件变化)来触发。它们处理该消息或事件,然后可能会向流程中的下一个节点发送消息。

    一个节点最多可以有一个输入端口和任意数量的输出端口。

    Configuration node
    A Configuration (config) Node is a special type of node that holds reusable configuration that can be shared by regular nodes in a flow.

    例如,MQTT输入和输出节点使用MQTT代理配置节点来表示与MQTT代理的共享连接。

    配置节点不会显示在主工作区中,但可以通过打开配置节点侧边栏查看。

    Flow
    A Flow is represented as a tab within the editor workspace and is the main way to organise nodes.

    术语“flow”也常用于非正式地描述一组相互连接的节点。因此,一个flow(标签页)可以包含多个flows(相互连接的节点组)。

    Context
    Context is a way to store information that can be shared between nodes without using the messages that pass through a flow.

    上下文有三种类型;

    • 节点 - 仅对设置该值的节点可见
    • 流程 - 对同一流程(或编辑器中的标签页)上的所有节点可见
    • 全局 - 对所有节点可见

    默认情况下,Node-RED使用内存中的上下文存储,因此值不会在重启时保存。可以配置为使用基于文件系统的存储,使值持久化。也可以插入替代的存储插件。

    Message
    Messages are what pass between the nodes in a flow. They are plain JavaScript objects that can have any set of properties. They are often referred to as msg within the editor.

    按照惯例,它们有一个payload属性,包含最有用的信息。

    Subflow
    A Subflow is a collection of nodes that are collapsed into a single node in the workspace.

    它们可用于降低流程的视觉复杂度,或将一组节点打包成可在多处重复使用的组件。

    Wire
    Wires connect the nodes and represent how messages pass through the flow.
    Palette
    The Palette is on the left of the editor and lists of the nodes that are available to use in flows.

    可以通过命令行或调色板管理器将额外节点安装到调色板中。

    Workspace
    The Workspace is the main area where flows are developed by dragging nodes from the palette and wiring them together.

    工作区顶部有一排标签页;每个流程以及已打开的任何子流程各有一个标签。

    Sidebar
    The sidebar contains panels that provide a number of useful tools within the editor. These include panels to view more information and help about a node, to view debug message and to view the flow’s configuration nodes.