您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

了解数字孪生对象模型和空间智能图Understand Digital Twins object models and spatial intelligence graph

Azure 数字孪生是一种 Azure IoT 服务,可提供物理环境及相关设备、传感器和人员的全面虚拟呈现形式。Azure Digital Twins is an Azure IoT service that powers comprehensive virtual representations of physical environments and associated devices, sensors, and people. 它通过将特定于域的概念组织成有用的模型来改进开发。It improves development by organizing domain-specific concepts into helpful models. 此后,这些模型位于空间智能图中。The models are then situated within a spatial intelligence graph. 此类概念可如实地为人员、空间和设备之间的关系和交互进行建模。Such concepts faithfully model the relationships and interactions between people, spaces, and devices.

数字孪生对象模型介绍了特定于域的概念、类别和属性。Digital Twins object models describe domain-specific concepts, categories, and properties. 模型是由希望根据其特定需求定制解决方案的用户预定义的。Models are predefined by users who want to tailor the solution to their specific needs. 这些预定义的数字孪生对象模型共同构成“本体” 。Together, these predefined Digital Twins object models make up an ontology. 智能建筑物的本体可描述地区、场所、楼层、办公室、区域、会议室和电话间。A smart building's ontology describes regions, venues, floors, offices, zones, conference rooms, and focus rooms. 能源网格本体可描述各种发电站、变电站、能源资源和客户。An energy grid ontology describes various power stations, substations, energy resources, and customers. 利用数字孪生对象模型和本体,可自定义各种场景和需求。With Digital Twins object models and ontologies, diverse scenarios and needs can be customized.

准备好数字孪生对象模型和本体后,便可以填充空间图 。With Digital Twins object models and an ontology in place, you can populate a spatial graph. 空间图是与 IoT 解决方案相关的空间、设备和人员之间的多种关系的虚拟呈现形式。Spatial graphs are virtual representations of the many relationships between spaces, devices, and people that are relevant to an IoT solution. 此图显示了使用智能建筑物本体的空间图示例。This diagram shows an example of a spatial graph that uses a smart building's ontology.


空间图将空间、设备、传感器和用户汇集在一起。The spatial graph brings together spaces, devices, sensors, and users. 每一个对象均以模拟现实世界的方式链接在一起。Each is linked together in a way that models the real world. 在此示例中,43 会场有四层楼,每层楼都具有许多不同区域。In this sample, venue 43 has four floors, each with many different areas. 用户与其工作站相关联,并且可以访问图形的某些部分。Users are associated with their workstations and given access to portions of the graph. 管理员有权更改空间图,而访问者仅有权查看某些建筑物数据。An administrator has the rights to make changes to the spatial graph, while a visitor has rights to only view certain building data.

数字孪生对象模型Digital Twins object models

数字孪生对象模型支持以下主要对象类别:Digital Twins object models support these main categories of objects:

  • 空间:虚拟或实体位置,例如 TenantCustomerRegionVenueSpaces are virtual or physical locations, for example, Tenant, Customer, Region, and Venue.
  • 设备:虚拟或实体设备,例如 AwesomeCompany DeviceRaspberry Pi 3Devices are virtual or physical pieces of equipment, for example, AwesomeCompany Device and Raspberry Pi 3.
  • 传感器:检测事件的对象,例如 AwesomeCompany Temperature SensorAwesomeCompany Presence SensorSensors are objects that detect events, for example, AwesomeCompany Temperature Sensor and AwesomeCompany Presence Sensor.
  • 用户:标识在位者及其特征 。Users identify occupants and their characteristics.

其他对象类别包括:Other categories of objects are:

  • 资源:附加到空间,通常表示空间图中的对象要使用的 Azure 资源,例如 IoTHubResources are attached to a space and typically represent Azure resources to be used by objects in the spatial graph, for example, IoTHub.
  • Blob:附加到对象(如空间、设备、传感器和用户) 。Blobs are attached to objects (such as spaces, devices, sensors, and users). 它们用作具有 MIME 类型和元数据的文件,例如 mapspicturesmanualsThey're used as files with mime type and metadata, for example, maps, pictures, and manuals.
  • 扩展类型:可扩展的枚举,用于扩充具有特定特征的实体,例如 SpaceTypeSpaceSubtypeExtended types are extensible enumerations that augment entities with specific characteristics, for example SpaceType and SpaceSubtype.
  • 本体:表示一组扩展的类型,例如 DefaultBuildingBACnetEnergyGridOntologies represent a set of extended types, for example, Default, Building, BACnet, and EnergyGrid.
  • 属性密钥和值:空间、设备、传感器和用户的自定义特征 。Property keys and values are custom characteristics of spaces, devices, sensors, and users. 除了用作内置特征,它们还可以用于其他用途,例如将 DeltaProcessingRefreshTime 作为密钥,将 10 作为值。They can be used along with built-in characteristics, for example, DeltaProcessingRefreshTime as key and 10 as value.
  • 角色:分配给空间图中的用户和设备的权限集,例如 Space AdministratorUser AdministratorDevice AdministratorRoles are sets of permissions assigned to users and devices in the spatial graph, for example, Space Administrator, User Administrator, and Device Administrator.
  • 角色分配:空间图中角色与对象之间的关联 。Role assignments are the association between a role and an object in the spatial graph. 例如,可授予用户或服务主体管理空间图中某个空间的权限。For example, a user or a service principal can be granted permission to manage a space in the spatial graph.
  • 安全密钥存储:为给定空间对象下的层次结构中的所有设备提供安全密钥,以允许设备与数字孪生进行安全通信 。Security key stores provide the security keys for all devices in the hierarchy under a given space object to allow the device to securely communicate with Digital Twins.
  • 用户定义的函数 (UDF):允许在空间图中进行可自定义的传感器遥测处理 。User-defined functions (UDFs) allow customizable sensor telemetry processing within the spatial graph. 例如,UDF 可执行以下操作:For example, a UDF can:
    • 设置传感器值。Set a sensor value.
    • 根据传感器读数执行自定义逻辑,并将输出设置为空间。Perform custom logic based on sensor readings, and set the output to a space.
    • 将元数据附加到空间。Attach metadata to a space.
    • 满足预定义条件时发送通知。Send notifications when predefined conditions are met. 目前,可以用 JavaScript 编写 UDF。Currently, UDFs can be written in JavaScript.
  • 匹配器:用于确定为给定的遥测消息执行哪些 UDF 的对象 。Matchers are objects that determine which UDFs are executed for a given telemetry message.
  • 终结点:可以路由遥测消息和数字孪生事件的位置,例如 Event HubService BusEvent GridEndpoints are the locations where telemetry messages and Digital Twins events can be routed, for example, Event Hub, Service Bus, and Event Grid.

空间智能图Spatial intelligence graph

空间图是数字孪生对象模型中定义的空间、设备和人员的层次结构图。Spatial graph is the hierarchical graph of spaces, devices, and people defined in the Digital Twins object model. 空间图支持继承、筛选、遍历、可伸缩性和扩展性。The spatial graph supports inheritance, filtering, traversing, scalability, and extensibility. 可使用 REST API 集合管理空间图并与其交互。You can manage and interact with your spatial graph with a collection of REST APIs.

如果在订阅中部署数字孪生服务,便可成为根节点的全局管理员。If you deploy a Digital Twins service in your subscription, you become the global administrator of the root node. 然后会自动获得对整个结构的完全访问权限。You're then automatically granted full access to the entire structure. 使用空间 API 预配关系图中的空间。Provision spaces in the graph by using the Space API. 使用设备 API 预配服务,使用传感器 API 预配传感器。Provision services by using the Device API and sensors by using the Sensor API. 用于批量预配关系图的开放源工具也可供使用。Open source tools also are available to provision the graph in bulk.

关系图继承Graph inheritance. 继承适用于来源于父节点及其以下所有节点的权限和属性。Inheritance applies to the permissions and properties that descend from a parent node to all nodes beneath it. 例如,为给定节点上的用户分配角色时,该用户会获得该角色对给定节点及其以下每个节点所拥有的权限。For example, when a role is assigned to a user on a given node, the user has that role's permissions to the given node and every node below it. 该节点下的所有节点会继承为给定节点定义的每个属性密钥和扩展类型。Each property key and extended type defined for a given node is inherited by all the nodes beneath that node.

关系图筛选Graph filtering. 筛选用于缩小请求结果范围。Filtering is used to narrow down request results. 可按照 ID、名称、类型、子类型、父空间和关联空间进行筛选。You can filter by IDs, name, types, subtypes, parent space, and associated spaces. 也可按照传感器数据类型、属性密钥和值、raverse、minLevel、maxLevel 以及其他 OData 筛选器参数进行筛选 。You also can filter by sensor data types, property keys and values, traverse, minLevel, maxLevel, and other OData filter parameters.

关系图遍历Graph traversing. 可从其深度和广度遍历空间图。You can traverse the spatial graph through its depth and breadth. 对于深度,可使用 traverse、minLevel、maxLevel 等参数自上而下或自下而上遍历关系图 。For depth, traverse the graph top-down or bottom-up by using the parameters traverse, minLevel, and maxLevel. 对于广度,可以遍历关系图以使同级节点直接连接到父空间或它的某个后代。Traverse the graph to get sibling nodes directly attached to a parent space or one of its descendants for breadth. 查询对象时,可以使用 GET API 的 includes 参数获取与该对象有关系的所有相关对象 。When you query an object, you can get all related objects that have relationships to that object by using the includes parameter of the GET APIs.

关系图可伸缩性Graph scalability. 数字孪生确保关系图具有可伸缩性,以便它能处理实际工作负荷。Digital Twins guarantees graph scalability, so it can handle your real-world workloads. 数字孪生可以用于表示房地产、基础设施、设备、传感器、遥测等大型项目组合。Digital Twins can be used to represent large portfolios of real estate, infrastructure, devices, sensors, telemetry, and more.

关系图扩展性Graph extensibility. 使用扩展性并通过新类型和本体来自定义基础数字孪生对象模型。Use extensibility to customize the underlying Digital Twins object models with new types and ontologies. 也可以使用可扩展的属性和值扩充数字孪生数据。Your Digital Twins data also can be enriched with extensible properties and values.

空间智能图管理 APISpatial intelligence graph Management APIs

Azure 门户部署数字孪生后,系统会自动生成管理 API 的 Swagger URL。After you deploy Digital Twins from the Azure portal, the Swagger URL of the Management APIs is automatically generated. 这会在 Azure 门户的概述部分中显示,其格式如下 。It's displayed in the Azure portal in the Overview section with the following format.

名称Name 替换为Replace with
YOUR_INSTANCE_NAMEYOUR_INSTANCE_NAME 数字孪生实例的名称The name of your Digital Twins instance
YOUR_LOCATIONYOUR_LOCATION 托管实例的服务器区域Which server region your instance is hosted on

此图中显示了完整的 URL 格式。The full URL format appears in this image.

数字孪生门户管理 API

有关使用空间智能图的详细信息,请访问 Azure 数字孪生管理 API 非公开预览版。For more details on how to use spatial intelligence graphs, visit the Azure Digital Twins Management APIs sneak preview.


我们提供了 Swagger 非公开预览版来演示 API 功能集。A Swagger sneak preview is provided to demonstrate the API feature set. 它托管在 docs.westcentralus.azuresmartspaces.net/management/swagger 中。It's hosted at docs.westcentralus.azuresmartspaces.net/management/swagger.

详细了解如何使用 SwaggerLearn more about how to use Swagger.

所有 API 调用必须使用 OAuth 进行身份验证。All API calls must be authenticated by using OAuth. API 遵循 Microsoft REST API 准则约定The APIs follow Microsoft REST API Guidelines conventions. 大多数返回集合的 API 支持 OData 系统查询选项。Most of the APIs that return collections support OData system query options.

后续步骤Next steps