Digital Twin
To reference data from other Things from a given Thing’s calculations and alerts, the following keys provide a way of traversing your Digital Twin hierarchy. From any of the following keys, you can define a role-path to the role which you are interested in.
Available Keys
$self
Retrieve a reference to another component with respect to “myself”.
Usage
// Get Reference to My Child's Child
$self.child_A.childs_child
// Get Reference to My Child's Child
// **Note** this is illustrative only, as you can access sensors /
// calculations / directly without this
$self
// Use reference to access the aggregated value of `sensorA`
$self.child_A.childs_child.sensor.sensorA
$parent
Retrieve a reference to another component with respect to “my parent”.
Usage
// Get Reference to My Sibling
$parent.sibling_A
// Get Reference to My Parent directly
$parent
// Use reference to access the aggregated value of `sensorA`
$parent.sibling_A.sensor.sensorA
$root
Retrieve a reference to another component with respect to “my top-level root”.
Usage
// Get Reference to My Family Member
$root.someRole.subassembly
// Get Reference to My Root directly
$root
// Use reference to access the aggregated value of `sensorA`
$root.someRole.subassembly.sensor.sensorA
$context
Retrieve a reference to another component by referencing an External ID defined
in a Context Field. When using the $context key, you must supply a context
field name. Formula processing will assume the referenced field is the External
ID to another Thing and attempt to access its data.
Usage
// Get Reference to an arbitrary Thing's child
$context.contextFieldName.child_A
// Get Reference to an arbitrary Thing directly
$context.contextFieldName
// Use reference to access the aggregated value of `sensorA`
$context.contextFieldName.sensor.sensorA
Examples
Digital Twin Definition
Let’s assume we have the following Digital Twin Role Hierarchy:
(role : thingType)
bike : Bicycle
├ rearWheel : Wheel
│ ├ brake : Brake
│ └ tire : Tire
│
├ frontWheel : Wheel
│ ├ brake : Brake
│ └ tire : Tire
│
└ bottomBracket : BottomBracket
├ crank : Crank
├ bearing : Bearing
├ leftPedal : Pedal
└ rightPedal : Pedal
Digital Twin Instantiation
Let’s then assume the following instance of this Digital Twin:
(externalID : role)
BIKE001 : bike
├ WHEEL001 : rearWheel
| ├ BRAKE001 : brake
| └ TIRE001 : tire
|
├ WHEEL002 : frontWheel
| ├ BRAKE002 : brake
| └ TIRE002 : tire
|
└ BRACKET001 : bottomBracket
├ CRANK001 : crank
├ BEARING001 : bearing
├ PEDAL001 : leftPedal
└ PEDAL002 : rightPedal
Referencing Data
On the Bicycle thing type let’s write the formula for a Calculation named
tirePressureDifference:
$self.frontWheel.tire.sensor.pressure - $self.rearWheel.tire.sensor.pressure
Then in the Tire Thing Type (which will execute for each tire) let’s add
the following formula for an Alert named tirePressureAbnormal:
if ($root.calculation.tirePressureDifference > 10) {
// if parent is 'rearWheel', sibling is 'frontWheel' else sibling is 'rearWheel'
const siblingPressure = ($parent.twin.role === 'rearWheel') ?
$root.frontWheel.sensor.pressure :
$root.rearWheel.sensor.pressure;
// check if I'm the "low" one
return (sensor.pressure < siblingPressure)
} else {
return false;
}
Some further examples of traversing this Digital Twin:
- From
PEDAL001
$parent // BRACKET001
$parent.bearing // BEARING001
$parent.$parent.frontWheel // WHEEL002
$root.frontWheel // WHEEL002
- From
WHEEL002
$root.bottomBracket // BRACKET001
$self.tire // TIRE002