Skip to content

Digital twins under the hood: Twinning and Twinning Rate.

December 28, 2022 | 03:00 PM

Here are some software notes/recommendations,to synchronising Digital twins states.

Table of contents

Open Table of contents

Context

Digital Twin is a digital representation of a real-world entity or system and the bi-directional data connections that feed data from the physical to the virtual representation, and information and processes from the virtual representation to the physical.

diagram-state

Twinning and the Twinning Rate

The implementation of a digital twin is an encapsulated software object or model that mirrors a unique physical object, process, organization, person or other abstraction. In this implementation it’s important to take in account the concepts of Twinning and Twinning Rate.

Twinning and the Twinning Rate are in effect the live connection between the Real World Entity/Environment and the Digital Twin.

Twinning is ‘simply’ the act of synchronising the virtual and physical states. For example measuring the state of the physical entity and realising that state in the virtual environment such that the virtual and physical states are ‘equal’, in that all of the virtual parameters are the same value as physical parameters. When both states are equal, the entities are ‘twinned’

Twinning Rate is then the frequency with which twinning occurs. In literature, this twinning rate is only described as being in ‘real-time’; that is, a change is a physical state will near-instantly be reflected by the same change in the virtual state.

Digital Twin Design Patterns

Using reusable abstraction mechanisms (patterns) to apply design principles to leverage the development of high quality Digital Twin-driven architectures we can describe Twinning process:

diagram-state

Example scenario in Azure Digital Twins

This how-to outlines how to synchronize states from real world entity to Azure Digital Twins, using a function in Azure. There are many possible configurations and matching strategies you can use for sync states.This example describe an implementations with high twinning rate very close to near real-time synchronization.

This scenario is outlined in a diagram below: diagram-state

You can use different matching strategies for sending messages, but the example for this article contains the following parts:

The synchronizer function looks like this:

const { DefaultAzureCredential } = require("@azure/identity");
const { DigitalTwinsClient } = require("@azure/digital-twins-core");

const url = "https://example.api.eus.digitaltwins.azure.net";
const credential = new DefaultAzureCredential();
const serviceClient = new DigitalTwinsClient(url, credential);

module.exports = async function (context, IoTHubMessages) {

    IoTHubMessages.forEach(message => {
        context.log(`Processed message: ${message}`);
        const temperature = message.data.properties.temperature;
        const data = [{
            op: "replace",
            path: "/Temperature",
            value: parseFloat(temperature)
        }];
        const updateDigitalTwinResponse = await serviceClient.updateDigitalTwin(message.data.systemProperties['iothub-connection-device-id'], data);
    });

    context.done();
};

References