Guidelines for Creating Property Rules¶
In Model Management, Property Rules define how data is mapped and transformed between models or within a single model, ensuring accurate data transmission and usage.
This document explains the application scenarios, creation principles, and examples for property rules.
Key Concepts¶
Understanding the following concepts will help clarify the role of property rules:
Device: An entity capable of transmitting data over a network and interacting with the IoT platform. The field names and formats are determined by the device manufacturer.
Model: Abstracts device differences and complex business logic, serving different purposes in various scenarios.
Inheritance Chain: The parent-child relationship between models. For example,
A1is a parent model, andA1-1is its child. All ancestors and descendants of these models belong to the same inheritance chain.Expression: The calculation logic for data mapping. In cross-model property rules, expressions are categorized by data flow direction:
Upstream Expression: Logic for mapping from the mapped model to the current model. For example, mapping device data from an onboarding model to a business model.
Downstream Expression: Logic for mapping from the current model to the mapped model. For example, mapping cloud control commands from a business model to an onboarding model.
For more details, see Property Rule Expression Description.
When to Create Property Rules¶
Property rules fall into two categories:
Default Rules: Rules that are built-in the current model for lightweight calculations and field enhancement.
Example:
power_kW = power_W / 1000converts power from watts to kilowatts.Cross-Model Rules: When multiple models share the same device data, you can perform field mapping and semantic conversion by cross-model property rules.
Example: A device connects via Model A, while an application consumes data from Model B. A mapping between A and B ensures the application uses Model B semantics.
Principles for Creating Cross-Model Rules¶
Follow these principles when creating cross-model property rules:
Parent Models First
Rules between child models must be based on existing rules between their parent models.
Example: : Create A1 → B1 before A1-1 → B1-1.
Once parent models are mapped, devices of source models can be bound to the target models and their child models.
Example: : If A1 → B1 exists, devices bound with A1 can bind B1 or B1-1 in the same time to share device data.
Single-Side Configuration, Two-Way Mapping
Configure mapping rules in the target model, including both upstream and downstream expressions in the same rule to avoid confusion.
Example: To map
A1.temperaturetoB1.roomTemp, configure in B1’s Property Rule page, select A1 as the mapping model, and add both expressions.Avoid Duplicate Mapping
If a model is selected as a mapping model, other models in its inheritance chain cannot be selected again to prevent conflicts.
Example: If B1 maps A1, you cannot also map A1-1 or A1’s ancestors in B1.
Field Compatibility
Field types and semantics must match and respect data direction.
Example: Device reports
power(W), business model requiresPower(kW). You can configure the rulePower = power / 1000.Unique Source
Each target field must have a single upstream source to avoid ambiguity.
Examples¶
Default Rule Example¶
Device fields:
voltage(V)current(A)
Model A fields:
voltagecurrentpower_W(W)
You should configure a default rule in Model A:
power_W = voltage * current
Cross-Model Rule Example¶
Device fields:
voltage(V)current(A)P_set(W, writable)
Model A fields:
voltagecurrentP_set_Wpower_W(W): default rulepower_W = voltage * current
Model B fields:
power_kW(kW)powerSetpoint_kW(kW)
You should configure a cross-model rule in Model B:
Upstream Expression:
power_kW = A.power_W / 1000Downstream Expression:
A.P_set_W = B.powerSetpoint_kW * 1000
Data will flow after configuration like below:
Upstream:
Device reports: voltage = 500 V, current = 10 A
↓
Model A: power_W = 500 * 10 = 5000 W
↓
Model B: power_kW = 5000 / 1000 = 5 kW
Downstream:
Model B: powerSetpoint_kW = 6
↓
Model A: A.P_set_W = 6 * 1000 = 6000 W
↓
Device receives: P_set = 6000 W
By configuring these rules, the system and applications can derive power_kW from device data and send control commands seamlessly.