匯入中繼資料範 - AWS IoT SiteWise

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

匯入中繼資料範

本節說明如何建立中繼資料檔案,以便透過單一大量匯入作業匯入資產模型和資產。

大量匯入的範例

您可以透過單一大量匯入作業匯入許多資產模型和資產。下列範例會示範如何建立中繼資料檔案來執行此作業。

在此範例案例中,您在工作單元中有包含工業機器人的各種工作場所。

此範例定義了兩個資產模型:

  • 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 具有資產和資產模型的模型。

下列螢幕擷取畫面是在您執行前一個程式碼範例 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 主控台 之後,顯示在中的模型、資產和階層。

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" } ] }