Class OpcUaConnector<CO,​CI>

  • Type Parameters:
    CO - the output type to the IIP-Ecosphere platform
    CI - the input type from the IIP-Ecosphere platform
    All Implemented Interfaces:
    de.iip_ecosphere.platform.connectors.Connector<DataItem,​java.lang.Object,​CO,​CI>, de.iip_ecosphere.platform.connectors.events.EventHandlingConnector, de.iip_ecosphere.platform.connectors.model.AbstractModelAccess.NotificationChangedListener

    @MachineConnector
    public class OpcUaConnector<CO,​CI>
    extends de.iip_ecosphere.platform.connectors.AbstractConnector<DataItem,​java.lang.Object,​CO,​CI>
    Implements the generic OPC UA connector. Do not rename, this class is referenced in META-INF/services. For custom types such as structs, the following must apply:
    • A class implements the datatype and its fields.
    • The class declares an accessible static field named BINARY_ENCODING_ID of type ExpandedNodeId.
    • The class declares a top-level inner class called "Codec" of type GenericDataTypeCodec having an accessible no-arg constructor.
    • Value constructor parameters and accessors shall be based on Java types rather than OPC/Milo types
    • Such custom types must be registered through ModelAccess.registerCustomType(Class) in ConnectorOutputTypeTranslator.initializeModelAccess().
    Author:
    Holger Eichelberger, SSE
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.eclipse.milo.opcua.sdk.client.OpcUaClient client  
      private static DataItem DUMMY  
      private static java.lang.String FIELD_BINARY_ENCODING_ID  
      private static org.slf4j.Logger LOGGER  
      static java.lang.String NAME
      The name of this connector.
      private de.iip_ecosphere.platform.connectors.ConnectorParameter params  
      static char SEPARATOR_CHAR
      Denotes the path separator for qualified model names.
      static java.lang.String SEPARATOR_STRING
      Denotes the path separator for qualified model names (as String).
      static java.lang.String TOP_OBJECTS
      Denotes the top-level folder "Objects".
      static java.lang.String TOP_TYPES
      Denotes the top-level folder "Types".
      static java.lang.String TOP_VIEWS
      Denotes the top-level folder "Views".
      • Fields inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector

        DEFAULT_CHANNEL
    • Constructor Summary

      Constructors 
      Constructor Description
      OpcUaConnector​(de.iip_ecosphere.platform.connectors.AdapterSelector<DataItem,​java.lang.Object,​CO,​CI> selector, de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<DataItem,​java.lang.Object,​CO,​CI>... adapter)
      Creates an instance and installs the protocol adapter(s).
      OpcUaConnector​(de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<DataItem,​java.lang.Object,​CO,​CI>... adapter)
      Creates an instance and installs the protocol adapter(s).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfigBuilder configure​(org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfigBuilder configBuilder)
      Does the basic configuration of the OPC UA client.
      protected void connectImpl​(de.iip_ecosphere.platform.connectors.ConnectorParameter params)  
      private org.eclipse.milo.opcua.stack.core.types.builtin.DataValue createWriteDataValue​(org.eclipse.milo.opcua.stack.core.types.builtin.Variant value)
      Creates a data value for write accesses.
      protected void disconnectImpl()  
      void dispose()  
      java.lang.String enabledEncryption()  
      protected java.util.function.Predicate<org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription> endpointFilter​(de.iip_ecosphere.platform.connectors.ConnectorParameter params)
      Provides a filter for OPC UA endpoints in case that multiple are present.
      protected void error​(java.lang.String message, java.lang.Throwable th)  
      private java.lang.String getEndpointUrl​(de.iip_ecosphere.platform.connectors.ConnectorParameter params)
      Construct the endpoint URL.
      protected org.eclipse.milo.opcua.sdk.client.api.identity.IdentityProvider getIdentityProvider​(de.iip_ecosphere.platform.connectors.ConnectorParameter params)
      Returns the identity provider by translating the token information in params to Milo specific token information.
      private de.iip_ecosphere.platform.support.identities.IdentityToken getIdToken​(java.lang.String endpointUrl)
      Returns the id token for an endpoint URL considering ConnectorParameter.ANY_ENDPOINT.
      java.lang.String getName()  
      protected DataItem read()  
      java.lang.String supportedEncryption()  
      void trigger​(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query)  
      protected void writeImpl​(java.lang.Object data)  
      • Methods inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector

        checkCache, configureModelAccess, connect, createTlsContext, disconnect, doPolling, enableNotifications, enablePolling, getCachingStrategy, getCachingStrategyCls, getConnectorInputType, getConnectorOutputType, getConnectorParameter, getInitCachingStrategyCls, getProtocolInputType, getProtocolOutputType, getSelector, initializeModelAccess, initSelector, installPollTask, isPolling, notificationsChanged, notifyReconfigured, received, received, request, request, setReceptionCallback, trigger, uninstallPollTask, useTls, write
      • Methods inherited from class java.lang.Object

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

      • NAME

        public static final java.lang.String NAME
        The name of this connector.
        See Also:
        Constant Field Values
      • TOP_OBJECTS

        public static final java.lang.String TOP_OBJECTS
        Denotes the top-level folder "Objects".
        See Also:
        Constant Field Values
      • TOP_TYPES

        public static final java.lang.String TOP_TYPES
        Denotes the top-level folder "Types".
        See Also:
        Constant Field Values
      • TOP_VIEWS

        public static final java.lang.String TOP_VIEWS
        Denotes the top-level folder "Views".
        See Also:
        Constant Field Values
      • SEPARATOR_CHAR

        public static final char SEPARATOR_CHAR
        Denotes the path separator for qualified model names.
        See Also:
        Constant Field Values
      • SEPARATOR_STRING

        public static final java.lang.String SEPARATOR_STRING
        Denotes the path separator for qualified model names (as String).
        See Also:
        Constant Field Values
      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • DUMMY

        private static final DataItem DUMMY
      • FIELD_BINARY_ENCODING_ID

        private static final java.lang.String FIELD_BINARY_ENCODING_ID
        See Also:
        Constant Field Values
      • client

        private org.eclipse.milo.opcua.sdk.client.OpcUaClient client
      • params

        private de.iip_ecosphere.platform.connectors.ConnectorParameter params
    • Constructor Detail

      • OpcUaConnector

        @SafeVarargs
        public OpcUaConnector​(de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<DataItem,​java.lang.Object,​CO,​CI>... adapter)
        Creates an instance and installs the protocol adapter(s).
        Parameters:
        adapter - the protocol adapter(s)
        Throws:
        java.lang.IllegalArgumentException - if adapter is null or empty or adapters are null
      • OpcUaConnector

        @SafeVarargs
        public OpcUaConnector​(de.iip_ecosphere.platform.connectors.AdapterSelector<DataItem,​java.lang.Object,​CO,​CI> selector,
                              de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<DataItem,​java.lang.Object,​CO,​CI>... adapter)
        Creates an instance and installs the protocol adapter(s).
        Parameters:
        selector - the adapter selector (null leads to a default selector for the first adapter)
        adapter - the protocol adapter(s)
        Throws:
        java.lang.IllegalArgumentException - if adapter is null or empty or adapters are null
    • Method Detail

      • createWriteDataValue

        private org.eclipse.milo.opcua.stack.core.types.builtin.DataValue createWriteDataValue​(org.eclipse.milo.opcua.stack.core.types.builtin.Variant value)
        Creates a data value for write accesses.
        Parameters:
        value - the actual value
        Returns:
        the data value
      • getEndpointUrl

        private java.lang.String getEndpointUrl​(de.iip_ecosphere.platform.connectors.ConnectorParameter params)
        Construct the endpoint URL.
        Parameters:
        params - the connector parameters
        Returns:
        the endpoint URL
      • connectImpl

        protected void connectImpl​(de.iip_ecosphere.platform.connectors.ConnectorParameter params)
                            throws java.io.IOException
        Specified by:
        connectImpl in class de.iip_ecosphere.platform.connectors.AbstractConnector<DataItem,​java.lang.Object,​CO,​CI>
        Throws:
        java.io.IOException
      • endpointFilter

        protected java.util.function.Predicate<org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription> endpointFilter​(de.iip_ecosphere.platform.connectors.ConnectorParameter params)
        Provides a filter for OPC UA endpoints in case that multiple are present.
        Parameters:
        params - the connector parameters
        Returns:
        the endpoint filter
      • configure

        private org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfigBuilder configure​(org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfigBuilder configBuilder)
        Does the basic configuration of the OPC UA client.
        Parameters:
        configBuilder - the configuration builder
        Returns:
        configBuilder
      • getIdToken

        private de.iip_ecosphere.platform.support.identities.IdentityToken getIdToken​(java.lang.String endpointUrl)
        Returns the id token for an endpoint URL considering ConnectorParameter.ANY_ENDPOINT.
        Parameters:
        endpointUrl - the endpoint URL
        Returns:
        the identity token
      • getIdentityProvider

        protected org.eclipse.milo.opcua.sdk.client.api.identity.IdentityProvider getIdentityProvider​(de.iip_ecosphere.platform.connectors.ConnectorParameter params)
        Returns the identity provider by translating the token information in params to Milo specific token information.
        Parameters:
        params - the connector params
        Returns:
        the identity provider
      • disconnectImpl

        protected void disconnectImpl()
                               throws java.io.IOException
        Specified by:
        disconnectImpl in class de.iip_ecosphere.platform.connectors.AbstractConnector<DataItem,​java.lang.Object,​CO,​CI>
        Throws:
        java.io.IOException
      • getName

        public java.lang.String getName()
      • dispose

        public void dispose()
      • writeImpl

        protected void writeImpl​(java.lang.Object data)
                          throws java.io.IOException
        Specified by:
        writeImpl in class de.iip_ecosphere.platform.connectors.AbstractConnector<DataItem,​java.lang.Object,​CO,​CI>
        Throws:
        java.io.IOException
      • read

        protected DataItem read()
                         throws java.io.IOException
        Specified by:
        read in class de.iip_ecosphere.platform.connectors.AbstractConnector<DataItem,​java.lang.Object,​CO,​CI>
        Throws:
        java.io.IOException
      • trigger

        public void trigger​(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query)
        Specified by:
        trigger in interface de.iip_ecosphere.platform.connectors.events.EventHandlingConnector
        Overrides:
        trigger in class de.iip_ecosphere.platform.connectors.AbstractConnector<DataItem,​java.lang.Object,​CO,​CI>
      • error

        protected void error​(java.lang.String message,
                             java.lang.Throwable th)
        Specified by:
        error in class de.iip_ecosphere.platform.connectors.AbstractConnector<DataItem,​java.lang.Object,​CO,​CI>
      • supportedEncryption

        public java.lang.String supportedEncryption()
      • enabledEncryption

        public java.lang.String enabledEncryption()