gpt4 book ai didi

opc - 如何创建 OPC 变量运行时

转载 作者:行者123 更新时间:2023-12-04 21:15:49 30 4
gpt4 key购买 nike

我有一个 Kepware OPC 服务器,我能够连接到我的客户端(OPC Foundation UA lib)。我在 Kepware 中创建了一个设备,并在其中创建了一个组。我想从数据库中读取 opc 标签并动态创建它们。

如何在 PLC 中动态创建带地址的项目?

最佳答案

我可以推荐你看看 KepServerEX Configuration API .基本上,它为您提供了对所有 KEPServerEX 实例的完整远程管理和配置控制。在您的情况下,您可以在从数据库中读取所需信息(例如标签名称、标签地址、标签数据类型)后,通过简单的 RESTful API 调用在设备级别动态生成标签。

请引用this guide获取更多信息以启用和测试配置 API。

我还从 Kepware 的示例项目中复制了以下代码来给您一个想法:

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!");
}
});
}

关于opc - 如何创建 OPC 变量运行时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49364162/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com