Skip to Content
On this page

Custom Node Types

Custom node types are used to extend the orchestrated nodes of the rule engine. Users create nodes, maintain processing logic, and define parameters; after successful compilation, they can be dragged into the rule flow for use.

Before creating a node

First, look at the terminology

TerminologyOn-site understanding
Custom node typeCustom rule function blocks for on-site or project purposes can be dragged into the rule flow after successful compilation.
Node instanceThe node actually dragged into a rule flow canvas and used node. It references a node type.
Input parametersData passed from upstream nodes to the current node.
Output parametersData passed to downstream nodes after processing by the current node.
Input/Output ParametersCan receive upstream data and continue to pass data after modifications within the node.
CompileBuilds the node code and parameter definitions. Check registration and reload the consuming flow before verifying the new behavior.
ClassificationGrouped nodes in the rule node panel for quick on-site search.

Page Entry

After logging into TGateway Web, click the “Develop Configuration → Custom Node” menu on the left.

Custom Node Management Page

Prerequisites

  • Define the inputs, outputs, error handling, and permitted side effects before writing the node.
  • Choose a name and category distinguishable from loaded nodes, and identify the flows that will consume it.
  • Export the affected flows and arrange a verification window before changing a node used in production.

Configure and compile the node

Page Structure

AreaDescription
Local nodesManage saved custom node types, supporting addition, editing, compilation, deletion, and batch operations.
Loaded nodesView the types of nodes already available in the rule flow, suitable for confirming whether the compilation result is effective.
Name SearchFilter by node name.
Filter by categoryFilter by node classification.
Tool buttonsOrder: Add, batch compile, batch delete, and refresh; For batch operations, you need to check the node first.

List Field

FieldDescription
Node NameNode Type Name, which is used in the rule flow to find and use this name.
ClassificationNode classification makes it easier to organize nodes during rule orchestration.
Input ParametersNumber of input parameters defined by the current node.
Output parametersNumber of output parameters defined by the current node.
Input/Output ParametersThe number of parameters that can be both input and output.
Update TimeLast saved or compiled time.
OperationsEdit, compile, or delete the current node.

Create a new node

Click the ‘Add Node’ button at the top right of the list to open the “New Custom Node” pop-up.

New Node Dialog

Configuration ItemsDescription
Node NameRequired name used to find the node in the palette. Recompile after renaming and check consuming flows.
ClassificationOptional. Used to organize nodes by business or processing type.
Descriptionoptional. Record node usage, input/output agreements, and maintenance precautions.

After clicking “OK,” the system will create a node and automatically enter the node editor.

Node Editor

The node editor includes the top operation bar, code editing area, and bottom information panel.

AreaDescription
Back ButtonReturns a custom node list.
Node Name TagDisplays the current node name and classification.
Top toolbarRoslyn Service, undo, redo, and compilation share one row. Connection settings are hidden by default; click Roslyn Service to expand or collapse them.
Compile and SaveTop-right action that saves node information and logic before compiling.
Code editingMaintaining node processing logic.
Bottom panelcontains the “Compilation” tabs, “Node Information,” and “Parameter Definitions.”

Type this. to complete user methods, fields, and generated parameter properties in the node. Signature help follows the call’s parentheses and commas. Add /// XML comments to describe methods, fields, and properties in suggestions and hover. The default service is https://roslyn.thingsgateway.cn; a self-hosted Studio is also supported. See Code Completion, Documentation, and Diagnostics.

Node Information

The “Node Information” tab is used to maintain basic information.

FieldsDescription
Node NameDisplay name. Recompile after renaming and check consuming flows.
ClassificationNode classification.
DescriptionNode purpose, input/output contract, and maintenance notes.

Parameter Definition

The “Parameter Definition” tab maintains three types of parameters: input, output, and input/output. Parameter definitions affect node connections and data transfer in the rule flow.

Parameter TypeDescription
Input ParameterPassed from the upstream node and read internally by the node.
Output parametersProcessed by nodes and output for downstream nodes.
Input/Output ParametersServes as both input and output, suitable for values that need to be passed after internal node modification.
Parameter fieldDescription
Parameter nameParameter identifier, It is recommended to use clear English or pinyin for the name.
Data TypeParameter Value Type. For numbers, select integer or decimal type; for switches, select boolean type; for text, select strings; and when passing structured content, select object type.
DescriptionParameter Usage Description.
Event input / outputEach arrival represents an occurrence, including repeated equal payloads. Events have no state initial value; switching to an event clears it.
Object full type nameUse a resolvable full type name when a custom object type is required, and verify compilation and the port contract.
Initial Value ExpressionC# starting expression for a state parameter, such as Decimal 1m; instance input and upstream connections are configured separately.

The Web editor offers Int16, Int32, Int64, UInt16, UInt32, UInt64, Byte, Float, Double, Decimal, Boolean, String, Object, and DateTime. Define the type separately for each input, output, and input/output port. Renaming a parameter also requires updating its code references and every consuming flow.

Initial Value Expression is C#, for example Decimal 1m + 1m. An explicit instance input or upstream connection overrides that starting value. Validate integer ranges, use an explicit timezone for dates, and preserve object structure. Event parameters have no state initial value.

Loaded-node details show state/event semantics, nullability, array and unit contracts, and node configuration parameters without ports. Use explicit converters for mismatched semantics or numeric types. Reordering parameters preserves named-port identity; renaming requires updating code and consuming flows before validation.

Compilation Log

After clicking “Compile and Save” at the top, the “Compilation Log” at the bottom will display the saving and compilation process.

Log entriesDescription:
Saving nodesSave current node information, code, and parameter definitions before compilation.
Node saves successfullyCompilation begins after successful save.
Compilation successfulCustom node code is compiled.
OutputDisplays compiled output information for easy troubleshooting of loading issues.
Error/Warning StatisticsThe right side of the bottom panel displays the current number of errors and warnings.

When a compilation error occurs, first handle the first red error; Click the error item to locate the corresponding code location.

Node saved successfully means the draft was saved; compilation can still fail afterward. Reopen a failed draft to edit it while the previous valid version remains available. After successful compilation, check Loaded Nodes, then reload and verify consuming flows as described below.

If another editor has changed the node, preserve your draft before reading the current revision and comparing changes. Do not overwrite another maintainer’s update.

Common Operations

OperationsSteps
Edit NodesClick “Edit” in the list to enter the editor for maintaining code, node information, or parameter definitions.
Single CompilationClick “Compile” in the list to verify whether the current node can compile.
Batch compileAfter checking multiple nodes, click batch compile. Suitable for unified verification after upgrades.
Delete the nodeClick “Delete” and confirm. Before deletion, confirm that the rule flow no longer references this node.
View Loaded NodesSwitch to “Loaded Nodes” to view nodes available at runtime.

Verify node behavior

Initial values, state, and event ports

Enter only class members in the Web node editor. Do not wrap them in a complete class or redeclare properties already defined in the parameter table. Compile complete C# node classes through the Full Source script type in Script Management. See Custom Node Development for examples.

Inputs receive upstream values; without a connection use the instance input. State outputs propagate only when their value changes by default. Event ports represent occurrences and can propagate equal payloads repeatedly; do not enter state initial values for event parameters. For inputs 10.1 and 10.2 both rounded to 10, a state receiver may run once while an event receiver runs twice. Check execution and downstream counts.

Test a conversion node in a flow

  1. Define a Decimal input Input and output Output in the Web node. Use gain 2 and offset 5; see the Web node example for member code.
  2. Compile and save, then confirm the name, category, and ports in Loaded Nodes.
  3. Create a disabled test flow connecting a scoped variable notification, numeric extraction, this node, and a downstream receiver.
  4. Save and enable it. Input 10 should produce 25, then 20 should produce 45. Check the node output, downstream input, and execution result separately.
  5. If the node has state or counters, verify their initial state after reenabling. Design explicit persistence if values must survive restarts.

Verify a revised node

  1. Compile/save and check name, category, and port types in Loaded Nodes.
  2. Use a disabled test flow with scoped input, numeric extraction, this node, and a downstream receiver. For gain 2 and offset 5, verify 10 → 25 and 20 → 45.
  3. After same-name recompilation, existing flows can retain old instances. Save/reload the consumer and test an input distinguishing the formulas.
  4. Recheck every connection after parameter changes. Disabling stops consumption; reenabling creates fresh state and counters unless persistence is explicitly designed.
  5. Remove all flow references before deletion. A disabled flow still contains references.

Use the node in production after its output values, parameter types, and error handling match the design.

Troubleshooting and maintenance

ScenariosRecommended
Parameter ModificationAfter modifying parameters, the rule flow connection referencing the node should be checked simultaneously.
Category maintenanceClassification affects node search efficiency; it is recommended to classify by business domain or function type.
Compilation failureFirst check the save log, then check the compilation diagnosis; If a save fails, the actual compile will not begin.
node does not appear in the ruleConfirm the node has been successfully compiled and refresh the rule engine page or reopen the flow editor.
Production deletionExport or back up the rule flow before deleting to avoid leaving unresolved node references.