milo - milo 可以使用 uamodeler/ 生成自定义数据类型吗?
问题描述
我试过milo,但是我发现很难一个一个地创建数据对象。milo可以通过读取xml文件生成相应的代码吗?如何?非常感谢!
解决方案
是的你可以
private void addCustomStructTypeVariable(UaFolderNode rootFolder) throws Exception {
NodeId dataTypeId = CustomStructType.TYPE_ID
.localOrThrow(getServer().getNamespaceTable());
NodeId binaryEncodingId = CustomStructType.BINARY_ENCODING_ID
.localOrThrow(getServer().getNamespaceTable());
UaVariableNode customStructTypeVariable = UaVariableNode.builder(getNodeContext())
.setNodeId(newNodeId("HelloWorld/CustomStructTypeVariable"))
.setAccessLevel(AccessLevel.READ_WRITE)
.setUserAccessLevel(AccessLevel.READ_WRITE)
.setBrowseName(newQualifiedName("CustomStructTypeVariable"))
.setDisplayName(LocalizedText.english("CustomStructTypeVariable"))
.setDataType(dataTypeId)
.setTypeDefinition(Identifiers.BaseDataVariableType)
.build();
CustomStructType value = new CustomStructType(
"foo",
uint(42),
true
);
ExtensionObject xo = ExtensionObject.encodeDefaultBinary(
getServer().getSerializationContext(),
value,
binaryEncodingId
);
customStructTypeVariable.setValue(new DataValue(new Variant(xo)));
getNodeManager().addNode(customStructTypeVariable);
customStructTypeVariable.addReference(new Reference(
customStructTypeVariable.getNodeId(),
Identifiers.Organizes,
rootFolder.getNodeId().expanded(),
false
));
}
推荐阅读
- amazon-dynamodb - 在收到 DynamoDB 流事件后立即查询 GSI - 它可靠吗?
- javascript - NextJS 表单向 MongoDB 发送数据
- vb.net - 使用 VB 窗体执行 Word 文档 VBA 宏
- python - 如何将列表分成两个随机部分
- get - 如何在drupal 8中访问网站时获取用户的IP地址
- java - 如何为需要验证第三方生成的 JWT 令牌且用户没有密码的 rest api 配置 spring http 安全性?
- ibm-doors - DXL 获取源链接的完整路径
- php - 数百个db连续插入,每次查询先读取最新值(同一张表)
- aws-lambda - 问题:尝试添加图层但失败
- optimization - 在 lp 文件 cplex 和 C++ 上编写模型