Reputation: 1692
I have a Kepware OPC server and I am able to connect with my client (OPC Foundation UA lib). I created a device in Kepware and a group inside. I would like to read opc tags from the database and create them dynamically.
How do I create an item with address in PLC dynamically ?
Upvotes: 4
Views: 2334
Reputation: 665
Within the Kepware Configuration, only certain drivers have the ability to dynamically create tags. For example, most of the Allen-Bradley suite can dynamically search and add tags while lower level drivers like Modbus can not. So it always depends on what driver the device in Kepware is using. To find individual configuration manuals for each driver, search here:
https://www.kepware.com/en-us/products/kepserverex/product-search/
Upvotes: 1
Reputation: 1457
I can recommend you take a look at KepServerEX Configuration API. Basically, it gives you complete remote management and configuration control over all your KEPServerEX instances. In your case, you can dynamically generate tags through a simple RESTful API call at the device level after reading required information (e.g. tag name, tag address, tag datatype) from your database.
Please refer to this guide for more information in order to enable and test Configuration API.
I also copied the following piece of code from Kepware's sample project to give you an idea:
function createTag(inputServer, inputChannel, inputDevice, inputTag, inputTagAddr) {
console.log("Creating " + inputTag + " with address " + inputTagAddr);
$.ajax({
type: 'POST',
url: 'http://' + inputServer + '/config/v1/project/channels/' + inputChannel + '/devices/' + inputDevice + '/tags',
data: '{"common.ALLTYPES_NAME":"' + inputTag + '","servermain.TAG_ADDRESS":"' + inputTagAddr + '","servermain.TAG_DATA_TYPE":' + inputTagType + '}',
contentType: 'application/json',
xhrFields: {
withCredentials: false
},
headers: {
'Authorization': 'Basic ' + encodeAuth
},
success: function(JSON, status, xhr) {
console.log(inputTag + " created under " + inputDevice);
},
error: function(JSON, status, xhr) {
console.log("Creation of " + inputTag + " failed!");
}
});
}
Upvotes: 2