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

    Fields 
    Modifier and Type Field Description
    private org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext context  
    private org.eclipse.milo.opcua.stack.core.types.OpcUaBinaryDataTypeDictionary dictionary  
    private org.eclipse.milo.opcua.stack.core.util.Lazy<File> dictionaryFile  
    private org.eclipse.milo.opcua.sdk.server.model.nodes.variables.DataTypeDictionaryTypeNode dictionaryNode  
    private Map<org.eclipse.milo.opcua.stack.core.types.builtin.NodeId,​org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription> enumDescriptions  
    private org.slf4j.Logger logger  
    private String namespaceUri  
    private List<org.eclipse.milo.opcua.sdk.server.nodes.UaNode> nodes  
    private Map<org.eclipse.milo.opcua.stack.core.types.builtin.NodeId,​org.eclipse.milo.opcua.stack.core.types.structured.StructureDescription> structureDescriptions  
  • Constructor Summary

    Constructors 
    Constructor Description
    DataTypeDictionaryManager​(org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext context, String namespaceUri)
    Create a BinaryDataTypeDictionaryManager for an OpcUaBinaryDataTypeDictionary in namespaceUri.
  • Method Summary

    Modifier and Type Method Description
    private void addNode​(org.eclipse.milo.opcua.sdk.server.nodes.UaNode node)
    Add node to the UaNodeManager and our own bookkeeping so it can be deleted during shutdown.
    org.eclipse.milo.opcua.stack.core.types.OpcUaBinaryDataTypeDictionary getDictionary()
    Returns the dictionary.
    private org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort getNamespaceIndex()
    Returns the namespace index of the namespace URI.
    private org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext getNodeContext()
    Returns the node context.
    private org.eclipse.milo.opcua.sdk.server.UaNodeManager getNodeManager()
    Returns the node manager.
    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.
    private org.eclipse.milo.opcua.stack.core.types.builtin.NodeId newNodeId​(String id)
    Returns a new node identification[factory].
    private org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName newQualifiedName​(String name)
    Returns a new qualified name [factory].
    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.
    void registerEnumDescription​(org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription description)
    Registers an enumeration description.
    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.
    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.
    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.
    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.
    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.
    void shutdown()  
    void startup()  
    private File writeDictionaryToFile()
    Writes the dictionary to a file.
    private byte[] writeDictionaryToMemory()
    Writes the dictionary to memory.
    private void writeDictionaryToStream​(OutputStream outputStream)
    Writes the dictionary to a stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      private final org.slf4j.Logger logger
    • nodes

      private final List<org.eclipse.milo.opcua.sdk.server.nodes.UaNode> nodes
    • dictionaryFile

      private final org.eclipse.milo.opcua.stack.core.util.Lazy<File> 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

      private final String namespaceUri
  • Constructor Details

    • DataTypeDictionaryManager

      public DataTypeDictionaryManager​(org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext context, String namespaceUri)
      Create a BinaryDataTypeDictionaryManager for an OpcUaBinaryDataTypeDictionary in namespaceUri.

      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 - a UaNodeContext. 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:
      startup in interface org.eclipse.milo.opcua.sdk.server.Lifecycle
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface org.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 codec
      description - the description of the structure
      dataTypeId - the data type identification
      See Also:
      registerStructureCodec(OpcUaBinaryDataTypeCodec, String, NodeId, NodeId, NodeId)
    • 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 codec
      description - the description of the structure
      dataTypeId - the data type identification
      binaryEncodingId - the binary encoding id
      See Also:
      registerStructureCodec(OpcUaBinaryDataTypeCodec, String, NodeId, NodeId, NodeId)
    • 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 codec
      description - the description of the structure
      dataTypeId - the data type identification
      binaryEncodingId - the binary encoding id
      See Also:
      registerStructureCodec(OpcUaBinaryDataTypeCodec, String, NodeId, NodeId, NodeId)
    • 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 codec
      description - the description of the structure
      dataTypeId - the data type identification
      binaryEncodingId - the binary encoding id
      See Also:
      registerStructureCodec(OpcUaBinaryDataTypeCodec, String, NodeId, NodeId, NodeId)
    • 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 codec
      description - the description of the structure
      dataTypeId - the data type identification
      binaryEncodingId - the binary encoding id
      parentType - 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 description
      binaryEncodingId - the node ID for binary encodings
    • writeDictionaryToFile

      private File writeDictionaryToFile() throws IOException
      Writes the dictionary to a file.
      Returns:
      the written file
      Throws:
      IOException - if writing fails
    • writeDictionaryToMemory

      private byte[] writeDictionaryToMemory() throws IOException
      Writes the dictionary to memory.
      Returns:
      the serialized dictionary
      Throws:
      IOException - if writing fails
    • writeDictionaryToStream

      private void writeDictionaryToStream​(OutputStream outputStream) throws IOException
      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

      private org.eclipse.milo.opcua.stack.core.types.builtin.NodeId newNodeId​(String id)
      Returns a new node identification[factory].
      Parameters:
      id - the id to be turned into a node id
      Returns:
      the node id
    • newQualifiedName

      private org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName newQualifiedName​(String name)
      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)
      Add node to the UaNodeManager and our own bookkeeping so it can be deleted during shutdown.
      Parameters:
      node - the UaNode to 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 URI
      addressSpaceManager - the address space manager
      Returns:
      the dictionary generator