Bind property tags programatically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Bind property tags programatically
Hi Everyone,
I'm trying to write a service that can bind properties in my thing to data in an edge device. here's my code:
// get all properties from the thing
propertyDefs = Things[assetThing].GetPropertyDefinitions({
category: undefined /* STRING */,
type: undefined /* BASETYPENAME */,
dataShape: undefined /* DATASHAPENAME */
});
numberOfProperties = propertyDefs.getRowCount();
var params = {
infoTableName: "PropertiesToAdd" /* STRING */,
dataShapeName: "PropertyNamesForBindings" /* DATASHAPENAME */
};
var allProperties = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
for each(var property in propertyDefs.rows){
// Only add properties starting with "Fan"
if (property.name.substr(0,3) == "Fan"){
var newRow = new Object();
newRow.name = property.name;
newRow.description = "";//property.description;
allProperties.AddRow(newRow);
}
}
// loop through properties, and add source to each property.
sourceNamePrefix = edgeChannelName + "." + edgeDeviceName + "." ;
for each (var prop in allProperties.rows){
Things[assetThing].SetRemotePropertyBinding({
propertyName: prop.name /* STRING */,
sourcePropertyName: sourceNamePrefix+prop.name /* STRING */,
timeout: undefined /* INTEGER */,
pushType: undefined,
pushThreshold: 0.1 /* NUMBER */,
aspects: undefined /* JSON */,
cacheTime: undefined /* INTEGER */,
foldType: undefined
});
}
Things[assetThing].RestartThing();
Before this, I would go to manage bindings tab on the thing and drag and drop the tags in KepserverEX onto the properties in my thing. Using that method shows the tag like in the screenshot below:
However when I run my service, the tag looks like this and doesnt get the data from the edge:
Any ideas how this can be fixed? The tags are added but the data doesnt come through.
Thanks.
Solved! Go to Solution.
- Labels:
-
Coding
-
Connectivity
-
Troubleshooting
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @HaiderZia , This article will help https://www.ptc.com/en/support/article/CS276903
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @HaiderZia , This article will help https://www.ptc.com/en/support/article/CS276903
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks. This helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @HaiderZia.
If the previous response answered your question, please mark it as the Accepted Solution for the benefit of others with the same question.
Regards.
--Sharon
