Class DataTypeDictionaryManager
java.lang.Object
test.de.iip_ecosphere.platform.connectors.opcuav1.DataTypeDictionaryManager
- All Implemented Interfaces:
org.eclipse.milo.opcua.sdk.server.Lifecycle
public class DataTypeDictionaryManager
extends Object
implements org.eclipse.milo.opcua.sdk.server.Lifecycle
Implements a data type dictionary manager. Adapted from the Milo examples.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContextprivate final org.eclipse.milo.opcua.stack.core.types.OpcUaBinaryDataTypeDictionaryprivate final org.eclipse.milo.opcua.stack.core.util.Lazy<File> private org.eclipse.milo.opcua.sdk.server.model.nodes.variables.DataTypeDictionaryTypeNodeprivate final Map<org.eclipse.milo.opcua.stack.core.types.builtin.NodeId, org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription> private final de.iip_ecosphere.platform.support.logging.Loggerprivate final Stringprivate final List<org.eclipse.milo.opcua.sdk.server.nodes.UaNode> private final Map<org.eclipse.milo.opcua.stack.core.types.builtin.NodeId, org.eclipse.milo.opcua.stack.core.types.structured.StructureDescription> -
Constructor Summary
ConstructorsConstructorDescriptionDataTypeDictionaryManager(org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext context, String namespaceUri) Create a BinaryDataTypeDictionaryManager for anOpcUaBinaryDataTypeDictionaryinnamespaceUri. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode node) Addnodeto theUaNodeManagerand our own bookkeeping so it can be deleted during shutdown.org.eclipse.milo.opcua.stack.core.types.OpcUaBinaryDataTypeDictionaryReturns the dictionary.private org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShortReturns the namespace index of the namespace URI.private org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContextReturns the node context.private org.eclipse.milo.opcua.sdk.server.UaNodeManagerReturns the node manager.private static org.eclipse.milo.opcua.binaryschema.generator.DataTypeDictionaryGeneratornewDictionaryGenerator(String namespaceUri, org.eclipse.milo.opcua.sdk.server.api.AddressSpaceManager addressSpaceManager) Creates a new dictionary generator.private org.eclipse.milo.opcua.stack.core.types.builtin.NodeIdReturns a new node identification[factory].private org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedNamenewQualifiedName(String name) Returns a new qualified name [factory].voidregisterEnumCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec<?> codec, String description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId) Registers an enum codec.voidregisterEnumDescription(org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription description) Registers an enumeration description.voidregisterOptionSetCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec<?> codec, String description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId binaryEncodingId) Registers an option set codec.voidregisterStructureCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec<?> codec, String description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId binaryEncodingId) Registers a structure codec.voidregisterStructureCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec<?> codec, String description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId binaryEncodingId, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId parentType) Registers a structure codec.voidregisterStructureDescription(org.eclipse.milo.opcua.stack.core.types.structured.StructureDescription description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId binaryEncodingId) Registeres a structure description.voidregisterUnionCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec<?> codec, String description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId binaryEncodingId) Registers a union codec.voidshutdown()voidstartup()private FileWrites the dictionary to a file.private byte[]Writes the dictionary to memory.private voidwriteDictionaryToStream(OutputStream outputStream) Writes the dictionary to a stream.
-
Field Details
-
logger
private final de.iip_ecosphere.platform.support.logging.Logger logger -
nodes
-
dictionaryFile
-
enumDescriptions
private final Map<org.eclipse.milo.opcua.stack.core.types.builtin.NodeId,org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription> enumDescriptions -
structureDescriptions
private final Map<org.eclipse.milo.opcua.stack.core.types.builtin.NodeId,org.eclipse.milo.opcua.stack.core.types.structured.StructureDescription> structureDescriptions -
dictionary
private final org.eclipse.milo.opcua.stack.core.types.OpcUaBinaryDataTypeDictionary dictionary -
dictionaryNode
private org.eclipse.milo.opcua.sdk.server.model.nodes.variables.DataTypeDictionaryTypeNode dictionaryNode -
context
private final org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext context -
namespaceUri
-
-
Constructor Details
-
DataTypeDictionaryManager
public DataTypeDictionaryManager(org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext context, String namespaceUri) Create a BinaryDataTypeDictionaryManager for anOpcUaBinaryDataTypeDictionaryinnamespaceUri.Note that the namespace URI is that of the dictionary, and is not necessarily the same as the namespace the Nodes created by the manager will reside in, i.e. datatype dictionaries are namespaced independently from the namespaces server Nodes reside in.
- Parameters:
context- aUaNodeContext. Nodes will be created and added using this context.namespaceUri- the namespace URI of the dictionary.
-
-
Method Details
-
getNodeContext
private org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext getNodeContext()Returns the node context.- Returns:
- the node context
-
getNodeManager
private org.eclipse.milo.opcua.sdk.server.UaNodeManager getNodeManager()Returns the node manager.- Returns:
- the node manager
-
startup
public void startup()- Specified by:
startupin interfaceorg.eclipse.milo.opcua.sdk.server.Lifecycle
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceorg.eclipse.milo.opcua.sdk.server.Lifecycle
-
getDictionary
public org.eclipse.milo.opcua.stack.core.types.OpcUaBinaryDataTypeDictionary getDictionary()Returns the dictionary.- Returns:
- the dictionary
-
registerEnumCodec
public void registerEnumCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec<?> codec, String description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId) Registers an enum codec.- Parameters:
codec- the codecdescription- the description of the structuredataTypeId- the data type identification- See Also:
-
registerEnumDescription
public void registerEnumDescription(org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription description) Registers an enumeration description.- Parameters:
description- the description of the enum
-
registerOptionSetCodec
public void registerOptionSetCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec<?> codec, String description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId binaryEncodingId) Registers an option set codec.- Parameters:
codec- the codecdescription- the description of the structuredataTypeId- the data type identificationbinaryEncodingId- the binary encoding id- See Also:
-
registerStructureCodec
public void registerStructureCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec<?> codec, String description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId binaryEncodingId) Registers a structure codec.- Parameters:
codec- the codecdescription- the description of the structuredataTypeId- the data type identificationbinaryEncodingId- the binary encoding id- See Also:
-
registerUnionCodec
public void registerUnionCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec<?> codec, String description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId binaryEncodingId) Registers a union codec.- Parameters:
codec- the codecdescription- the description of the structuredataTypeId- the data type identificationbinaryEncodingId- the binary encoding id- See Also:
-
registerStructureCodec
public void registerStructureCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec<?> codec, String description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId binaryEncodingId, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId parentType) Registers a structure codec.- Parameters:
codec- the codecdescription- the description of the structuredataTypeId- the data type identificationbinaryEncodingId- the binary encoding idparentType- the parent type
-
registerStructureDescription
public void registerStructureDescription(org.eclipse.milo.opcua.stack.core.types.structured.StructureDescription description, org.eclipse.milo.opcua.stack.core.types.builtin.NodeId binaryEncodingId) Registeres a structure description.- Parameters:
description- the structure descriptionbinaryEncodingId- the node ID for binary encodings
-
writeDictionaryToFile
Writes the dictionary to a file.- Returns:
- the written file
- Throws:
IOException- if writing fails
-
writeDictionaryToMemory
Writes the dictionary to memory.- Returns:
- the serialized dictionary
- Throws:
IOException- if writing fails
-
writeDictionaryToStream
Writes the dictionary to a stream.- Parameters:
outputStream- the stream to write to- Throws:
IOException- if writing fails
-
getNamespaceIndex
private org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort getNamespaceIndex()Returns the namespace index of the namespace URI.- Returns:
- the namespace index
-
newNodeId
Returns a new node identification[factory].- Parameters:
id- the id to be turned into a node id- Returns:
- the node id
-
newQualifiedName
Returns a new qualified name [factory].- Parameters:
name- the name to be turned into a qualified name- Returns:
- the qualified name
-
addNode
private void addNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode node) Addnodeto theUaNodeManagerand our own bookkeeping so it can be deleted during shutdown.- Parameters:
node- theUaNodeto add.
-
newDictionaryGenerator
private static org.eclipse.milo.opcua.binaryschema.generator.DataTypeDictionaryGenerator newDictionaryGenerator(String namespaceUri, org.eclipse.milo.opcua.sdk.server.api.AddressSpaceManager addressSpaceManager) Creates a new dictionary generator.- Parameters:
namespaceUri- the namespace URIaddressSpaceManager- the address space manager- Returns:
- the dictionary generator
-