自定义信息内容和访问 > 对资产、生产线和站点添加属性和字段
对资产、生产线和站点添加属性和字段
通过自定义相应的混搭,可将“客户”“组”等其他属性和字段添加到 ThingWorx Apps 用户界面中的资产、生产线和站点。
在 Asset Advisor 中添加属性和字段
要在 Asset Advisor 资产详细信息页面上显示其他属性和字段,如“客户”“组”,请完成以下步骤:
1. 修改资产使用的事物模板,使资产具有必要的属性,如 customerNamegroup
2. 编辑 PTC.SCA.SCO.AssetMonitor.C_AssetDetailContainerMashup_[发布版本] 混搭。对于包含 PTC.SCA.SCO.AssetMonitor.C_AssetSummaryMashup_[发布版本] 的布局,可提高 HeaderHeight 以使属性表有更多空间显示其他属性。
* 
在查看或编辑随 ThingWorx Apps 提供的混搭时,如果出现一条消息,询问您是否要用新的小组件替换已弃用的小组件,请单击“否”
3. PTC.Factory.C_LaunchPointConfigurationThing_[发布版本] 中的 “配置”下:
编辑 AssetDetailContainerMashup 条目以指向 PTC.SCA.SCO.AssetMonitor.C_AssetDetailContainerMashup_[发布版本]
EquipmentUserInterfaceSettings 配置表中,编辑“资产”设备类型的 AssetDetailContainerMashup 条目以指向 PTC.SCA.SCO.AssetMonitor.C_AssetDetailContainerMashup_[发布版本]
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 事物。