自訂資訊內容與存取 > 在資產、生產線、站台上新增屬性與欄位
在資產、生產線、站台上新增屬性與欄位
您可自訂合適的混搭,即能在 ThingWorx Apps 使用者介面中,針對資產、生產線、站台新增額外的屬性與欄位 (如客戶群組)。
將屬性與欄位新增至 Asset Advisor
欲在 Asset Advisor 的資產詳細資訊頁面上,顯示如客戶群組等額外屬性和欄位,則請完成下列步驟:
1. 修改用於您資產的項目範本,以使得資產具有必要屬性,例如 customerNamegroup
2. 編輯 PTC.SCA.SCO.AssetMonitor.C_AssetDetailContainerMashup_[ReleaseVersion] 混搭。針對包含了 PTC.SCA.SCO.AssetMonitor.C_AssetSummaryMashup_[ReleaseVersion] 的版面配置,應增加 HeaderHeight 以讓內容表格有更多空間可顯示其他屬性。
* 
當您檢視或編輯 ThingWorx Apps 隨附的混搭時,如果顯示一則訊息,詢問您是否要以新小器具取代已被取代的小器具,請按一下「否」
3. PTC.Factory.C_LaunchPointConfigurationThing_[ReleaseVersion]「組態」之下︰
編輯 AssetDetailContainerMashup 輸入項以指向 PTC.SCA.SCO.AssetMonitor.C_AssetDetailContainerMashup_[ReleaseVersion]
EquipmentUserInterfaceSettings 組態表格中,編輯「資產」設備類型的 AssetDetailContainerMashup 輸入項,以指向 PTC.SCA.SCO.AssetMonitor.C_AssetDetailContainerMashup_[ReleaseVersion]
4. PTC.SCA.SCO.AssetMonitor.AssetDetail.AssetDetailServiceController 物件上,取代 GetIdentityInfo 服務,可使用下列程式碼為範例:
var asset = Things[assetId];
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({dataShapeName:"PTC.SCA.SCO.AssetMonitor.AssetList.AssetIdentityDataShape"});
if (asset !== null) {
var newEntry = new Object();
newEntry.name = assetId;
newEntry.displayName = asset.displayName;
newEntry.image = asset.assetImage;
if(asset.assetImage !== null){
newEntry.customClass = "";
}
else{
newEntry.customClass = "defaultImage";
}
var assetAttributes = me.GetAssetAttributes({
assetId: assetId /* THINGNAME */
});
newEntry.attributes = assetAttributes;

var newAttributeEntry = new Object();
newAttributeEntry.name = "Customer:";
newAttributeEntry.baseType = "STRING";
newAttributeEntry.value = asset.customerName;
newEntry.attributes.AddRow(newAttributeEntry);

newAttributeEntry = new Object();
newAttributeEntry.name = "Group:";
newAttributeEntry.baseType = "STRING";
newAttributeEntry.value = asset.group;
newEntry.attributes.AddRow(newAttributeEntry);

result.AddRow(newEntry);
}
對設備的一般資訊頁面新增屬性和欄位
欲在組態與設定 > 設備中的一般資訊頁面顯示額外屬性和欄位,請完成下列步驟:
1. 複製混搭以取代:
針對資產:PTC.Factory.ManufacturingElementGeneralInfo
針對生產線:PTC.SCA.SCO.LineGeneralInfo
針對站台:PTC.Factory.SiteGeneralInfo
2. 必須更新該複製混搭,並以新名稱儲存之。
3. 開啟 PTC.SCA.SCO.UIProvider 項目。
4. 「服務」下,按一下 以取代 GetResourceConfigurationView 服務。
5. 在指令集窗格中,新增如下列的類似內容。根據 mashupName 所設定的地方,以您自訂的重複混搭名稱取代預設值。
var isSite = Resources["PTC.Factory.CommonUtilities"].isSite(
{ thingId: displayId }
);
var isLine = Resources["PTC.Factory.CommonUtilities"].IsLine(
{ thingId: displayId }
);
var isAsset = Resources["PTC.Factory.CommonUtilities"].IsAsset(
{ thingId: displayId }
);
var mashupName = "PTC.Factory.ManufacturingElementGeneralInfo";
if (isSite)
{ mashupName = "PTC.Factory.SiteGeneralInfo"; }
else if (isLine)
{ mashupName = "PTC.SCA.SCO.LineGeneralInfo"; }
else if (isAsset)
{ mashupName = "PTC.Factory.ManufacturingElementGeneralInfo"; }
var result = Resources["InfoTableFunctions"].CreateInfoTable(
{ infoTableName: "infoTable" }
);
var newEntry = new Object();
result.AddField(
{name:"mashup",baseType:"STRING"}
);
result.AddRow(
{mashup:mashupName}
);
6. 按一下「完成」以儲存所取代的服務。
7. 按一下「儲存」以儲存 PTC.SCA.SCO.UIProvider 項目。