fix:opcda协议读写
This commit is contained in:
@@ -1481,7 +1481,13 @@ public class ApiTest {
|
||||
public void opcDaReadTest() {
|
||||
// 构建OPC DA连接对象
|
||||
JSONObject properties = new JSONObject();
|
||||
properties.put("clsId", "{F8582CF2-88FB-11D0-B850-00C0F0104305}"); // 示例CLSID,需要根据实际OPC服务器修改
|
||||
|
||||
// 常见的OPC DA服务器CLSID示例(需要根据实际服务器修改):
|
||||
// Kepware: "7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729"
|
||||
// Matrikon: "F8582CF2-88FB-11D0-B850-00C0F0104305"
|
||||
// RSLinx: "A06B0CF6-4E1F-11D3-8F4D-00104B33C6E8"
|
||||
// 注意:CLSID格式不要包含花括号
|
||||
properties.put("clsId", "7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729"); // Kepware OPC Server CLSID
|
||||
properties.put("username", "administrator");
|
||||
properties.put("password", "P@ssw0rd.");
|
||||
|
||||
@@ -1496,17 +1502,17 @@ public class ApiTest {
|
||||
.description("测试OPC DA连接")
|
||||
.build();
|
||||
|
||||
// 构建配置对象 - 写入操作,设置为可写
|
||||
// 构建配置对象
|
||||
IotConfig config = IotConfig.builder()
|
||||
.id(2)
|
||||
.connectId(3)
|
||||
.alias("action1")
|
||||
.aliasName("标签2")
|
||||
.registerAddress("ns=4;s=|var|HCFA-PLC.Application.B_CBJ01.action1") // OPC DA标签地址
|
||||
.aliasName("标签1")
|
||||
.registerAddress("Channel1.Device1.Tag1") // OPC DA标签地址,格式:通道.设备.标签
|
||||
.dataType("WORD")
|
||||
.readonly(false) // 设置为可写
|
||||
.readonly(true)
|
||||
.enabled(true)
|
||||
.description("测试OPC DA写入")
|
||||
.description("测试OPC DA读取")
|
||||
.build();
|
||||
|
||||
// 执行读取操作
|
||||
@@ -1529,7 +1535,7 @@ public class ApiTest {
|
||||
|
||||
// 转换为SiteBO
|
||||
SiteBO siteBO = SiteBO.builder()
|
||||
.deviceCode("B_CBJ01")
|
||||
.deviceCode("B_CBJ01.B_CBJ01")
|
||||
.alias(config.getAlias())
|
||||
.aliasName(config.getAliasName())
|
||||
.registerAddress(config.getRegisterAddress())
|
||||
@@ -1554,7 +1560,13 @@ public class ApiTest {
|
||||
public void opcDaWriteTest() {
|
||||
// 构建OPC DA连接对象
|
||||
JSONObject properties = new JSONObject();
|
||||
properties.put("clsId", "{F8582CF2-88FB-11D0-B850-00C0F0104305}"); // 示例CLSID,需要根据实际OPC服务器修改
|
||||
|
||||
// 常见的OPC DA服务器CLSID示例(需要根据实际服务器修改):
|
||||
// Kepware: "7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729"
|
||||
// Matrikon: "F8582CF2-88FB-11D0-B850-00C0F0104305"
|
||||
// RSLinx: "A06B0CF6-4E1F-11D3-8F4D-00104B33C6E8"
|
||||
// 注意:CLSID格式不要包含花括号
|
||||
properties.put("clsId", "7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729"); // Kepware OPC Server CLSID
|
||||
properties.put("username", "administrator");
|
||||
properties.put("password", "P@ssw0rd.");
|
||||
|
||||
@@ -1575,7 +1587,7 @@ public class ApiTest {
|
||||
.connectId(3)
|
||||
.alias("tag2")
|
||||
.aliasName("标签2")
|
||||
.registerAddress("B_CBJ01.B_CBJ01") // OPC DA标签地址
|
||||
.registerAddress("Channel1.Device1.Tag2") // OPC DA标签地址,格式:通道.设备.标签
|
||||
.dataType("INT")
|
||||
.readonly(false) // 设置为可写
|
||||
.enabled(true)
|
||||
|
||||
Reference in New Issue
Block a user