use of org.eclipse.milo.opcua.sdk.core.Reference in project plc4x by apache.
the class Plc4xNamespace method addNodes.
private void addNodes() {
for (DeviceConfiguration c : config.getDevices()) {
NodeId folderNodeId = newNodeId(c.getName());
UaFolderNode folderNode = new UaFolderNode(getNodeContext(), folderNodeId, newQualifiedName(c.getName()), LocalizedText.english(c.getName()));
getNodeManager().addNode(folderNode);
folderNode.addReference(new Reference(folderNode.getNodeId(), Identifiers.Organizes, Identifiers.ObjectsFolder.expanded(), false));
addConfiguredNodes(folderNode, c);
}
}
use of org.eclipse.milo.opcua.sdk.core.Reference in project milo by eclipse.
the class DataTypeDictionaryManager method registerStructureDescription.
public void registerStructureDescription(StructureDescription description, NodeId binaryEncodingId) {
structureDescriptions.put(description.getDataTypeId(), description);
// Add a DataTypeDescriptionTypeNode with a ComponentOf reference to
// dictionaryNode.
DataTypeDescriptionTypeNode descriptionNode = new DataTypeDescriptionTypeNode(getNodeContext(), newNodeId(String.format("%s.Description", description.getName())), newQualifiedName(description.getName().getName()), LocalizedText.english(description.getName().getName()), LocalizedText.NULL_VALUE, uint(0), uint(0));
descriptionNode.setValue(new DataValue(new Variant(description.getName().getName())));
descriptionNode.setDataType(Identifiers.String);
descriptionNode.addReference(new Reference(descriptionNode.getNodeId(), Identifiers.HasTypeDefinition, Identifiers.DataTypeDescriptionType.expanded(), Direction.FORWARD));
descriptionNode.addReference(new Reference(descriptionNode.getNodeId(), Identifiers.HasComponent, dictionaryNode.getNodeId().expanded(), Direction.INVERSE));
addNode(descriptionNode);
// Add a DataTypeEncodingTypeNode with a HasDescription reference to
// descriptionNode and an EncodingOf reference to the DataTypeNode.
DataTypeEncodingTypeNode dataTypeEncodingNode = new DataTypeEncodingTypeNode(getNodeContext(), binaryEncodingId, new QualifiedName(0, "Default Binary"), LocalizedText.english("Default Binary"), LocalizedText.NULL_VALUE, uint(0), uint(0));
dataTypeEncodingNode.addReference(new Reference(dataTypeEncodingNode.getNodeId(), Identifiers.HasTypeDefinition, Identifiers.DataTypeEncodingType.expanded(), Direction.FORWARD));
dataTypeEncodingNode.addReference(new Reference(dataTypeEncodingNode.getNodeId(), Identifiers.HasDescription, descriptionNode.getNodeId().expanded(), Direction.FORWARD));
dataTypeEncodingNode.addReference(new Reference(dataTypeEncodingNode.getNodeId(), Identifiers.HasEncoding, description.getDataTypeId().expanded(), Direction.INVERSE));
addNode(dataTypeEncodingNode);
dictionaryFile.reset();
}
use of org.eclipse.milo.opcua.sdk.core.Reference in project milo by eclipse.
the class DataTypeDictionaryManager method registerEnumCodec.
public void registerEnumCodec(OpcUaBinaryDataTypeCodec<?> codec, String description, NodeId dataTypeId) {
dictionary.registerEnumCodec(codec, description, dataTypeId);
// Add a custom DataTypeNode with a SubtypeOf reference to Enumeration
UaDataTypeNode dataTypeNode = new UaDataTypeNode(getNodeContext(), dataTypeId, newQualifiedName(description), LocalizedText.english(description), LocalizedText.NULL_VALUE, uint(0), uint(0), false);
dataTypeNode.addReference(new Reference(dataTypeId, Identifiers.HasSubtype, Identifiers.Enumeration.expanded(), Direction.INVERSE));
addNode(dataTypeNode);
// TODO figure out a way to not require re-registration every time...
getNodeContext().getServer().getDataTypeManager().registerTypeDictionary(dictionary);
}
use of org.eclipse.milo.opcua.sdk.core.Reference in project milo by eclipse.
the class ExampleNamespace method createAndAddNodes.
private void createAndAddNodes() {
// Create a "HelloWorld" folder and add it to the node manager
NodeId folderNodeId = newNodeId("HelloWorld");
UaFolderNode folderNode = new UaFolderNode(getNodeContext(), folderNodeId, newQualifiedName("HelloWorld"), LocalizedText.english("HelloWorld"));
getNodeManager().addNode(folderNode);
// Make sure our new folder shows up under the server's Objects folder.
folderNode.addReference(new Reference(folderNode.getNodeId(), Identifiers.Organizes, Identifiers.ObjectsFolder.expanded(), false));
// Add the rest of the nodes
addVariableNodes(folderNode);
addSqrtMethod(folderNode);
addGenerateEventMethod(folderNode);
try {
registerCustomEnumType();
addCustomEnumTypeVariable(folderNode);
} catch (Exception e) {
logger.warn("Failed to register custom enum type", e);
}
try {
registerCustomStructType();
addCustomStructTypeVariable(folderNode);
} catch (Exception e) {
logger.warn("Failed to register custom struct type", e);
}
try {
registerCustomUnionType();
addCustomUnionTypeVariable(folderNode);
} catch (Exception e) {
logger.warn("Failed to register custom struct type", e);
}
addCustomObjectTypeAndInstance(folderNode);
}
use of org.eclipse.milo.opcua.sdk.core.Reference in project milo by eclipse.
the class ExampleNamespace method addCustomUnionTypeVariable.
private void addCustomUnionTypeVariable(UaFolderNode rootFolder) throws Exception {
NodeId dataTypeId = CustomUnionType.TYPE_ID.toNodeIdOrThrow(getServer().getNamespaceTable());
NodeId binaryEncodingId = CustomUnionType.BINARY_ENCODING_ID.toNodeIdOrThrow(getServer().getNamespaceTable());
UaVariableNode customUnionTypeVariable = UaVariableNode.builder(getNodeContext()).setNodeId(newNodeId("HelloWorld/CustomUnionTypeVariable")).setAccessLevel(AccessLevel.READ_WRITE).setUserAccessLevel(AccessLevel.READ_WRITE).setBrowseName(newQualifiedName("CustomUnionTypeVariable")).setDisplayName(LocalizedText.english("CustomUnionTypeVariable")).setDataType(dataTypeId).setTypeDefinition(Identifiers.BaseDataVariableType).build();
CustomUnionType value = CustomUnionType.ofBar("hello");
ExtensionObject xo = ExtensionObject.encodeDefaultBinary(getServer().getSerializationContext(), value, binaryEncodingId);
customUnionTypeVariable.setValue(new DataValue(new Variant(xo)));
getNodeManager().addNode(customUnionTypeVariable);
customUnionTypeVariable.addReference(new Reference(customUnionTypeVariable.getNodeId(), Identifiers.Organizes, rootFolder.getNodeId().expanded(), false));
}
Aggregations