本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
导入元数据示例
本节介绍如何创建元数据文件以通过单个批量导入操作导入资产模型和资产。
批量导入示例
您可以通过一次批量导入操作导入许多资产模型和资产。以下示例说明如何创建元数据文件来执行此操作。
在此示例场景中,您有各种工作场所,在工作单元中包含工业机器人。
该示例定义了两种资产模型:
-
RobotModel1
:此资产模型代表您在工作场所拥有的一种特定类型的机器人。机器人具有测量属性Temperature
。 -
WorkCell
:此资产模型代表您的一个工作场所中的一组机器人。资产模型定义了一个层次结构robotHierarchyOEM1
,以表示工作单元包含机器人的关系。
该示例还定义了一些资产:
-
WorkCell1
: 波士顿基地内的工作单元 -
RobotArm123456
: 该工作单元中的一个机器人 -
RobotArm987654
: 那个工作单元里有另一个机器人
以下JSON元数据文件定义了这些资产模型和资产。使用此元数据进行批量导入会在其中创建资产模型和资产 AWS IoT SiteWise,包括它们的层次关系。
{ "assetModels": [ { "assetModelExternalId": "Robot.OEM1.3536", "assetModelName": "RobotModel1", "assetModelProperties": [ { "dataType": "DOUBLE", "externalId": "Temperature", "name": "Temperature", "type": { "measurement": { "processingConfig": { "forwardingConfig": { "state": "ENABLED" } } } }, "unit": "fahrenheit" } ] }, { "assetModelExternalId": "ISA95.WorkCell", "assetModelName": "WorkCell", "assetModelProperties": [], "assetModelHierarchies": [ { "externalId": "workCellHierarchyWithOEM1Robot", "name": "robotHierarchyOEM1", "childAssetModelExternalId": "Robot.OEM1.3536" } ] } ], "assets": [ { "assetExternalId": "Robot.OEM1.3536.123456", "assetName": "RobotArm123456", "assetModelExternalId": "Robot.OEM1.3536" }, { "assetExternalId": "Robot.OEM1.3536.987654", "assetName": "RobotArm987654", "assetModelExternalId": "Robot.OEM1.3536" }, { "assetExternalId": "BostonSite.Area1.Line1.WorkCell1", "assetName": "WorkCell1", "assetModelExternalId": "ISA95.WorkCell", "assetHierarchies": [ { "externalId": "workCellHierarchyWithOEM1Robot", "childAssetExternalId": "Robot.OEM1.3536.123456" }, { "externalId": "workCellHierarchyWithOEM1Robot", "childAssetExternalId": "Robot.OEM1.3536.987654" } ] } ] }
模型和资产的初始加载示例
在此示例场景中,您的公司中有多个包含工业机器人的工作场所。
该示例定义了多个资产模型:
-
Sample_Enterprise
— 此资产模型代表了这些网站所属的公司。资产模型定义了一个层次结构Enterprise to Site
,以表示站点与企业的关系。 -
Sample_Site
— 此资产模型代表公司内部的制造基地。资产模型定义了一个层次结构Site to Line
,以表示线条与网站的关系。 -
Sample_Welding Line
— 此资产模型代表工作场所内的装配线。资产模型定义了一个层次结构Line to Robot
,以表示机器人与生产线的关系。 -
Sample_Welding Robot
— 此资产模型代表您的工作场所中的一种特定类型的机器人。
该示例还根据资产模型定义资产。
-
Sample_AnyCompany Motor
— 此资产是根据Sample_Enterprise
资产模型创建的。 -
Sample_Chicago
— 此资产是根据Sample_Site
资产模型创建的。 -
Sample_Welding Line 1
— 此资产是根据Sample_Welding Line
资产模型创建的。 -
Sample_Welding Robot 1
— 此资产是根据Sample_Welding Robot
资产模型创建的。 -
Sample_Welding Robot 2
— 此资产是根据Sample_Welding Robot
资产模型创建的。
以下JSON元数据文件定义了这些资产模型和资产。使用此元数据进行批量导入会在其中创建资产模型和资产 AWS IoT SiteWise,包括它们的层次关系。
{ "assetModels": [ { "assetModelExternalId": "External_Id_Welding_Robot", "assetModelName": "Sample_Welding Robot", "assetModelProperties": [ { "dataType": "STRING", "externalId": "External_Id_Welding_Robot_Serial_Number", "name": "Serial Number", "type": { "attribute": { "defaultValue": "-" } }, "unit": "-" }, { "dataType": "DOUBLE", "externalId": "External_Id_Welding_Robot_Cycle_Count", "name": "CycleCount", "type": { "measurement": {} }, "unit": "EA" }, { "dataType": "DOUBLE", "externalId": "External_Id_Welding_Robot_Joint_1_Current", "name": "Joint 1 Current", "type": { "measurement": {} }, "unit": "Amps" }, { "dataType": "DOUBLE", "externalId": "External_Id_Welding_Robot_Joint_1_Max_Current", "name": "Max Joint 1 Current", "type": { "metric": { "expression": "max(joint1current)", "variables": [ { "name": "joint1current", "value": { "propertyExternalId": "External_Id_Welding_Robot_Joint_1_Current" } } ], "window": { "tumbling": { "interval": "5m" } } } }, "unit": "Amps" } ] }, { "assetModelExternalId": "External_Id_Welding_Line", "assetModelName": "Sample_Welding Line", "assetModelProperties": [ { "dataType": "DOUBLE", "externalId": "External_Id_Welding_Line_Availability", "name": "Availability", "type": { "measurement": {} }, "unit": "%" } ], "assetModelHierarchies": [ { "externalId": "External_Id_Welding_Line_TO_Robot", "name": "Line to Robot", "childAssetModelExternalId": "External_Id_Welding_Robot" } ] }, { "assetModelExternalId": "External_Id_Site", "assetModelName": "Sample_Site", "assetModelProperties": [ { "dataType": "STRING", "externalId": "External_Id_Site_Street_Address", "name": "Street Address", "type": { "attribute": { "defaultValue": "-" } }, "unit": "-" } ], "assetModelHierarchies": [ { "externalId": "External_Id_Site_TO_Line", "name": "Site to Line", "childAssetModelExternalId": "External_Id_Welding_Line" } ] }, { "assetModelExternalId": "External_Id_Enterprise", "assetModelName": "Sample_Enterprise", "assetModelProperties": [ { "dataType": "STRING", "name": "Company Name", "externalId": "External_Id_Enterprise_Company_Name", "type": { "attribute": { "defaultValue": "-" } }, "unit": "-" } ], "assetModelHierarchies": [ { "externalId": "External_Id_Enterprise_TO_Site", "name": "Enterprise to Site", "childAssetModelExternalId": "External_Id_Site" } ] } ], "assets": [ { "assetExternalId": "External_Id_Welding_Robot_1", "assetName": "Sample_Welding Robot 1", "assetModelExternalId": "External_Id_Welding_Robot", "assetProperties": [ { "externalId": "External_Id_Welding_Robot_Serial_Number", "attributeValue": "S1000" }, { "externalId": "External_Id_Welding_Robot_Cycle_Count", "alias": "AnyCompany/Chicago/Welding Line/S1000/Count" }, { "externalId": "External_Id_Welding_Robot_Joint_1_Current", "alias": "AnyCompany/Chicago/Welding Line/S1000/1/Current" } ] }, { "assetExternalId": "External_Id_Welding_Robot_2", "assetName": "Sample_Welding Robot 2", "assetModelExternalId": "External_Id_Welding_Robot", "assetProperties": [ { "externalId": "External_Id_Welding_Robot_Serial_Number", "attributeValue": "S2000" }, { "externalId": "External_Id_Welding_Robot_Cycle_Count", "alias": "AnyCompany/Chicago/Welding Line/S2000/Count" }, { "externalId": "External_Id_Welding_Robot_Joint_1_Current", "alias": "AnyCompany/Chicago/Welding Line/S2000/1/Current" } ] }, { "assetExternalId": "External_Id_Welding_Line_1", "assetName": "Sample_Welding Line 1", "assetModelExternalId": "External_Id_Welding_Line", "assetProperties": [ { "externalId": "External_Id_Welding_Line_Availability", "alias": "AnyCompany/Chicago/Welding Line/Availability" } ], "assetHierarchies": [ { "externalId": "External_Id_Welding_Line_TO_Robot", "childAssetExternalId": "External_Id_Welding_Robot_1" }, { "externalId": "External_Id_Welding_Line_TO_Robot", "childAssetExternalId": "External_Id_Welding_Robot_2" } ] }, { "assetExternalId": "External_Id_Site_Chicago", "assetName": "Sample_Chicago", "assetModelExternalId": "External_Id_Site", "assetHierarchies": [ { "externalId": "External_Id_Site_TO_Line", "childAssetExternalId": "External_Id_Welding_Line_1" } ] }, { "assetExternalId": "External_Id_Enterprise_AnyCompany", "assetName": "Sample_AnyEnterprise Motor", "assetModelExternalId": "External_Id_Enterprise", "assetHierarchies": [ { "externalId": "External_Id_Enterprise_TO_Site", "childAssetExternalId": "External_Id_Site_Chicago" } ] } ] }
以下屏幕截图显示的是运行前面的代码示例 AWS IoT SiteWise 控制台 之后显示的模型。
以下屏幕截图显示了运行上一个代码示例 AWS IoT SiteWise 控制台 之后显示在中的模型、资产和层次结构。
新增额外资产的示例
此示例定义了要导入到您账户中现有资产模型的其他资产:
-
Sample_Welding Line 2
— 此资产是根据Sample_Welding Line
资产模型创建的。 -
Sample_Welding Robot 3
— 此资产是根据Sample_Welding Robot
资产模型创建的。 -
Sample_Welding Robot 4
— 此资产是根据Sample_Welding Robot
资产模型创建的。
要为本示例创建初始资产,请参阅模型和资产的初始加载示例。
以下JSON元数据文件定义了这些资产模型和资产。使用此元数据进行批量导入会在其中创建资产模型和资产 AWS IoT SiteWise,包括它们的层次关系。
{ "assets": [ { "assetExternalId": "External_Id_Welding_Robot_3", "assetName": "Sample_Welding Robot 3", "assetModelExternalId": "External_Id_Welding_Robot", "assetProperties": [ { "externalId": "External_Id_Welding_Robot_Serial_Number", "attributeValue": "S3000" }, { "externalId": "External_Id_Welding_Robot_Cycle_Count", "alias": "AnyCompany/Chicago/Welding Line/S3000/Count" }, { "externalId": "External_Id_Welding_Robot_Joint_1_Current", "alias": "AnyCompany/Chicago/Welding Line/S3000/1/Current" } ] }, { "assetExternalId": "External_Id_Welding_Robot_4", "assetName": "Sample_Welding Robot 4", "assetModelExternalId": "External_Id_Welding_Robot", "assetProperties": [ { "externalId": "External_Id_Welding_Robot_Serial_Number", "attributeValue": "S4000" }, { "externalId": "External_Id_Welding_Robot_Cycle_Count", "alias": "AnyCompany/Chicago/Welding Line/S4000/Count" }, { "externalId": "External_Id_Welding_Robot_Joint_1_Current", "alias": "AnyCompany/Chicago/Welding Line/S4000/1/Current" } ] }, { "assetExternalId": "External_Id_Welding_Line_1", "assetName": "Sample_Welding Line 1", "assetModelExternalId": "External_Id_Welding_Line", "assetHierarchies": [ { "externalId": "External_Id_Welding_Line_TO_Robot", "childAssetExternalId": "External_Id_Welding_Robot_1" }, { "externalId": "External_Id_Welding_Line_TO_Robot", "childAssetExternalId": "External_Id_Welding_Robot_2" }, { "externalId": "External_Id_Welding_Line_TO_Robot", "childAssetExternalId": "External_Id_Welding_Robot_3" } ] }, { "assetExternalId": "External_Id_Welding_Line_2", "assetName": "Sample_Welding Line 2", "assetModelExternalId": "External_Id_Welding_Line", "assetHierarchies": [ { "externalId": "External_Id_Welding_Line_TO_Robot", "childAssetExternalId": "External_Id_Welding_Robot_4" } ] }, { "assetExternalId": "External_Id_Site_Chicago", "assetName": "Sample_Chicago", "assetModelExternalId": "External_Id_Site", "assetHierarchies": [ { "externalId": "External_Id_Site_TO_Line", "childAssetExternalId": "External_Id_Welding_Line_1" }, { "externalId": "External_Id_Site_TO_Line", "childAssetExternalId": "External_Id_Welding_Line_2" } ] } ] }
以下屏幕截图显示了运行上一个代码示例 AWS IoT SiteWise 控制台 之后显示在中的模型、资产和层次结构。
新房产上线示例
此示例定义了现有资产模型上的新属性。请参阅新增额外资产的示例,以载入其他资产和模型。
-
Joint 1 Temperature
— 此属性已添加到Sample_Welding Robot
资产模型中。此新属性还将传播到根据资产模型创建的每个Sample_Welding Robot
资产。
要向现有资产模型添加新属性,请参阅以下JSON元数据文件示例。如中所示JSON,必须随新属性一起提供完整的现有Sample_Welding Robot
资产模型定义。如果未提供现有定义中的整个属性列表,则 AWS IoT SiteWise 删除省略的属性。
此示例向资产模型添加了一个新属性Joint 1 Temperature
。
{ "assetModels": [ { "assetModelExternalId": "External_Id_Welding_Robot", "assetModelName": "Sample_Welding Robot", "assetModelProperties": [ { "dataType": "STRING", "externalId": "External_Id_Welding_Robot_Serial_Number", "name": "Serial Number", "type": { "attribute": { "defaultValue": "-" } }, "unit": "-" }, { "dataType": "DOUBLE", "externalId": "External_Id_Welding_Robot_Cycle_Count", "name": "CycleCount", "type": { "measurement": {} }, "unit": "EA" }, { "dataType": "DOUBLE", "externalId": "External_Id_Welding_Robot_Joint_1_Current", "name": "Joint 1 Current", "type": { "measurement": {} }, "unit": "Amps" }, { "dataType": "DOUBLE", "externalId": "External_Id_Welding_Robot_Joint_1_Max_Current", "name": "Max Joint 1 Current", "type": { "metric": { "expression": "max(joint1current)", "variables": [ { "name": "joint1current", "value": { "propertyExternalId": "External_Id_Welding_Robot_Joint_1_Current" } } ], "window": { "tumbling": { "interval": "5m" } } } }, "unit": "Amps" }, { "dataType": "DOUBLE", "externalId": "External_Id_Welding_Robot_Joint_1_Temperature", "name": "Joint 1 Temperature", "type": { "measurement": {} }, "unit": "degC" } ] } ] }
管理数据流的示例
此示例显示了两种管理与资产属性关联的数据流的方法。重命名资产属性的别名时,当前存储在资产属性的数据流中的历史数据有两个选项。
-
选项一 — 保留当前数据流并单独重命名别名,允许使用新别名访问历史数据。
在JSON元数据文件示例中,带有 ID 的资产属性将其别名
External_Id_Welding_Robot_Cycle_Count
更改为AnyCompany/Chicago/Welding Line/S3000/Count-Updated
。此次更改后,该资产属性的历史数据保持不变。 -
选项二 — 为资产属性分配新的数据流,该数据流可使用新别名进行访问。旧数据流及其历史数据仍可使用旧别名进行访问,但不与任何资产属性关联。
在JSON元数据文件示例中,带有 ID 的资产属性将其别名
External_Id_Welding_Robot_Joint_1_Current
更改为AnyCompany/Chicago/Welding Line/S4999/1/Current
。这次retainDataOnAliasChange
是附加值存在并设置为False
。使用此设置,原始数据流将与资产属性断开关联,并创建一个不包含历史数据的新数据流。
要使用原始历史数据访问旧数据流,请在中 AWS Console Home,转到 “数据流” 页面并搜索旧别名AnyCompany/Chicago/Welding Line/S3000/1/Current
。
{ "assetExternalId": "External_Id_Welding_Robot_3", "assetName": "Sample_Welding Robot 3", "assetModelExternalId": "External_Id_Welding_Robot", "assetProperties": [ { "externalId": "External_Id_Welding_Robot_Serial_Number", "attributeValue": "S3000" }, { "externalId": "External_Id_Welding_Robot_Cycle_Count", "alias": "AnyCompany/Chicago/Welding Line/S3000/Count-Updated" }, { "externalId": "External_Id_Welding_Robot_Joint_1_Current", "alias": "AnyCompany/Chicago/Welding Line/S4999/1/Current", "retainDataOnAliasChange": "FALSE" } ] }