DTDL 可写 属性 - Azure 数字孪生

DTDL Writable Property - Azure Digital Twin

创建了一个测试 DTDL 模型 class,其中一个可写 属性 为假,另一个可写 属性 为真,如该模型中所定义

即使 writable 属性 为 false,下面的代码也可以毫无问题地执行。如何使 DTDL 中的属性只可读?

            BasicDigitalTwin twinData = new BasicDigitalTwin();
            twinData.Id = "123Test";
            twinData.Metadata.ModelId = "dtmi:DigitalTwins:test;2";

            twinData.CustomProperties.Add("testprop1", "test1");
            twinData.CustomProperties.Add("testprop2", "test2");
            twinData.CustomProperties.Add("testprop3", "test3");

            await client.CreateDigitalTwinAsync(twinData.Id, JsonSerializer.Serialize(twinData));

可写属性仅在 IoT 中心的设备孪生中起作用,而在 Azure 数字孪生中不起作用。 This document 试图阐明它,但我能理解其中的困惑。

数字孪生定义语言 (DTDL) 用于描述 Azure 数字孪生 (ADT) 中的数字孪生,也是 IoT 即插即用的功能模型。虽然可写属性是 DTDL 语言的一部分,但它在 ADT 中没有发挥作用。