Rule Engine
The rule engine supports visual flow orchestration, configuring data processing flows by dragging nodes to implement complex data processing logic. The rule engine adopts an event-driven mode, automatically triggering flow processing when node input data changes.
Core Concepts
Data Flow Mechanism
The rule engine adopts an event-driven data flow mechanism:
- Output triggers propagation: When a node's output property is set, all downstream nodes connected to that output are automatically triggered
- Automatic propagation: Data changes automatically propagate along the node connection chain until all related nodes have completed processing
- Debounce optimization: Uses an intelligent scheduler to prevent high-frequency triggering, ensuring only the last execution runs during rapid changes
Node Lifecycle
Each node instance has a complete lifecycle:
| Lifecycle Phase | Method | Description |
|---|---|---|
| Initialization | InitAsync() | Called once when the node is created, used to initialize internal state |
| Execution | ChangedAsync() | Triggered when input parameters change, executes the node's business logic |
| Output callback | OutputChangedCallback | Triggered when an output property is set, notifies downstream nodes |
Execution Flow

Security Mechanisms
The rule engine has built-in multiple security protections:
1. Circular Dependency Detection
Automatically detects whether node connections have cycles when the flow starts:
- Uses depth-first search (DFS) algorithm to detect cycles in the graph
- Logs a warning when circular dependencies are detected
- Prevents infinite loops caused by flow design errors
2. Execution Count Limit
Each node has a maximum execution count limit (default 100 times):
- Per single propagation chain: The counter is reset each time triggered from the starting node
- Prevents accidental loops: Automatically stops after exceeding 100 times in a single propagation chain
- Does not affect normal usage: Multiple triggers at different time points are not cumulative
- Automatically stops propagation and logs an error when the limit is exceeded
- The limit can be adjusted via
FlowExecutionContext.MaxExecutionCount
Example Explanation:
Timeline:
T1: Temperature sensor triggers → [Temperature processing] executes 1 time → counter=1
T2: Temperature sensor triggers → [Temperature processing] executes 1 time → counter=1 (after reset)
T3: Temperature sensor triggers → [Temperature processing] executes 1 time → counter=1 (after reset)
Circular dependency scenario:
Single trigger: [NodeA]→[NodeB]→[NodeC]→[NodeA]→[NodeB]→...
execute 1 execute 2 execute 3 execute 4 execute 5...
Stops when a node exceeds 100 executions
3. Debounce Mechanism
Uses an intelligent scheduler to prevent high-frequency triggering:
- Only the last execution runs during multiple triggers in a short period
- Avoids repeated calculations caused by rapid data changes
- Improves system performance and stability
Feature Entry
Click "Rule Engine" in the left menu to enter the management page.

Flow List
| Column | Description |
|---|---|
| Flow Name | Identifier name of the rule flow |
| Description | Flow description information |
| Version | Flow version number |
| Status | Enabled/Disabled status |
| NoDebounce | Whether debounce is disabled, debounce is enabled by default |
Operation Functions
| Function | Description |
|---|---|
| New Flow | Create a new rule flow |
| Details | Open the flow editor |
| Enable/Disable | Toggle flow enabled status |
| Delete | Delete the flow |
| Refresh | Refresh the flow list |
Flow Editor
Click the "Details" button to enter the flow editor:

Toolbar Functions
| Function | Description |
|---|---|
| Flow Name | Edit the flow name |
| Flow Description | Edit the flow description |
| Export | Export flow configuration as JSON file |
| Import | Import flow configuration from JSON file |
| Export Excel | Export rule flow to Excel file |
| Import Excel | Import rule flow from Excel file, option to clear existing flow |
| Auto Layout | Automatically arrange flow nodes |
| Delete Selected | Delete selected nodes |
| Save | Save current flow configuration |
Editor Layout
| Area | Description |
|---|---|
| Left | Node panel, displays available node types |
| Center | Canvas area, drag nodes for flow orchestration |
| Right | Properties panel, configure parameters of selected nodes |
Left Node Panel
| Function | Description |
|---|---|
| Node Search | Search nodes by name |
| Category Filter | Filter nodes by category |
| Group Collapse | Nodes are grouped by category, can be collapsed/expanded |
Center Canvas Area
| Function | Description |
|---|---|
| Drag Node | Drag nodes from the left panel to the canvas |
| Connect Nodes | Drag node ports to connect to another node |
| Delete Node | Select a node and press Delete key to delete |
| Minimap | Thumbnail of the canvas in the lower right corner for navigation |
| Node Hover Tooltip | Hover to display real-time parameter values of the node (after the flow is enabled) |

Right Properties Panel
| Function | Description |
|---|---|
| Node Name | Edit node display name |
| Node Type | Display node type (read-only) |
| Real-time Parameter Values | Display real-time parameter values of the node after the flow is enabled |
| Input Parameters | Configure initial values of node input parameters |
| Output Parameters | Display node output parameters |
| Input/Output Parameters | Configure input/output parameters |
Flow Debounce Configuration
Each rule flow can be configured whether to enable the debounce mechanism:
| Configuration | Description |
|---|---|
| NoDebounce | Whether to disable debounce. Debounce is enabled by default, only the last execution runs during multiple triggers in a short period; when disabled, every trigger will execute |
- By default, the rule engine uses debounce mechanism to prevent high-frequency triggering
- For scenarios where every trigger needs to execute (such as counters, accumulators), set NoDebounce to true
- Disabling debounce may increase system load during high-frequency triggering, use with caution
Node Types
| Type | Description |
|---|---|
| Input Node | Data input source |
| Processing Node | Data processing logic |
| Output Node | Data output target |
| Custom Node | User-defined processing node |
Node Parameter Types
Each node can define three types of parameters:
| Parameter Type | Attribute | Description | Data Flow Direction |
|---|---|---|---|
| Input Parameter | [ExpressionInput] | Input data of the node | Receives from upstream nodes or configures initial values |
| Output Parameter | [ExpressionOutput] | Output data of the node | Automatically triggers downstream nodes when changed |
| Input/Output Parameter | [ExpressionInOut] | Both input and output | Can receive upstream data, and triggers downstream when changed |
- Input Parameter: Can only receive data from upstream nodes, will not trigger downstream nodes
- Output Parameter: Can only output data, automatically triggers all connected downstream nodes when changed
- Input/Output Parameter: Has both input and output characteristics, suitable for parameters that need to be modified during processing
Data Propagation Examples
Simple Flow Example
The following is a simple temperature unit conversion flow:
[Temperature Input] → [Celsius to Fahrenheit] → [Result Output]
(25°C) (Formula calculation) (77°F)
Execution Process:
-
Initialization Phase:
- Create all node instances
- Call each node's
InitAsync()method
-
First Execution:
- Temperature input node executes
ChangedAsync(), output value set to 25 - Output change triggers the downstream "Celsius to Fahrenheit" node
- The "Celsius to Fahrenheit" node's input parameter receives 25
- Executes
ChangedAsync(), calculates result 77 - Output change triggers the "Result Output" node
- Temperature input node executes
-
Subsequent Changes:
- When the temperature input changes to 30
- Automatically triggers the entire chain to re-execute
- Final output updates to 86
Branch Flow Example
One output can connect to multiple downstream nodes to achieve data distribution:
┌→ [Alarm Judgment] → [Alarm Output]
[Temperature Sensor] → [Temperature Processing] ┤
└→ [Data Logging] → [Database Write]
Execution Process:
- Temperature sensor data changes
- Triggers the temperature processing node
- The output of the temperature processing node simultaneously triggers two downstream nodes:
- Alarm judgment node
- Data logging node
- Both branches execute in parallel without blocking each other
Merge Flow Example
Multiple upstream outputs can connect to different input parameters of the same downstream node:
[Temperature Sensor] → [Temperature Processing] ┐
├→ [Comprehensive Judgment] → [Result Output]
[Humidity Sensor] → [Humidity Processing] ┘
Execution Process:
- When either temperature or humidity changes, the "Comprehensive Judgment" node is triggered
- The "Comprehensive Judgment" node simultaneously receives two input parameters
- Makes a judgment based on the comprehensive situation of both parameters
Circular Dependency Example
The following example demonstrates circular dependency, such designs should be avoided in actual use!
[Node A] → [Node B] → [Node C]
↑ ↓
└───────────────────┘
System Protection Mechanism:
- Startup Detection: Automatically detects circular dependency when the flow starts
- Log Warning: Records "circular dependency detected" in the log
- Execution Limit: Each node automatically stops after a maximum of 100 executions in a single propagation chain
- Error Log: Logs an error and stops propagation when the limit is exceeded
Execution Process Example:
Trigger start node → Node A executes (1st time) → Node B executes (1st time) → Node C executes (1st time)
→ Node A executes (2nd time) → Node B executes (2nd time) → Node C executes (2nd time)
→ ... (loop continues)
→ Node A executes (101st time) → ❌ Exceeds limit, stops propagation
Correct Approach: Avoid designing flows with circular dependencies, use conditional nodes or state machines instead.
Flow Management
Enable/Disable Flow
- Enable Flow: The flow starts executing immediately after being enabled, nodes enter running state
- Disable Flow: Stops flow execution, releases all node resources
After modifying the flow configuration, the system will automatically restart the flow, and all nodes will be reinitialized. The system will:
- Stop the current flow execution
- Reload the flow configuration
- Re-detect circular dependencies
- Reinitialize all nodes
- Reset the execution counter (automatically resets at the start of each trigger chain)
Flow Logs
Each flow has an independent log file, recording node execution status and exception information:
- Log path:
Logs/RuleEngine/{FlowName}.db - Log level: Info for routine operation / Trace for temporary troubleshooting
- Supports log query and export
Log Content Includes:
- Flow start/stop events
- Circular dependency detection results
- Node execution count limit exceeded warnings
- Node execution exception information
- Data propagation path tracing
Related Links
- Data Management - Channel, device, variable configuration
- Custom Nodes - Custom node management
- Script Management - Script development and management