Class OpcUaConnector<CO,CI>
- java.lang.Object
-
- de.iip_ecosphere.platform.connectors.AbstractConnector<DataItem,java.lang.Object,CO,CI>
-
- de.iip_ecosphere.platform.connectors.opcuav1.OpcUaConnector<CO,CI>
-
- Type Parameters:
CO- the output type to the IIP-Ecosphere platformCI- 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 inMETA-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_IDof typeExpandedNodeId. - The class declares a top-level inner class called "Codec" of type
GenericDataTypeCodechaving 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)inConnectorOutputTypeTranslator.initializeModelAccess().
- Author:
- Holger Eichelberger, SSE
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOpcUaConnector.DescriptorThe descriptor of this connector (see META-INF/services).private classOpcUaConnector.FallbackIdentityProderA fallback identity provider.private static classOpcUaConnector.NodeCacheEntryRealizes a node cache entry with value lifetime.private static classOpcUaConnector.OpcInputConverterSpecialized model input converter.private static classOpcUaConnector.OpcOutputConverterSpecialized model output converter.protected classOpcUaConnector.OpcUaModelAccessImplements the model access for OPC UA.
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.milo.opcua.sdk.client.OpcUaClientclientprivate static DataItemDUMMYprivate static java.lang.StringFIELD_BINARY_ENCODING_IDprivate static org.slf4j.LoggerLOGGERstatic java.lang.StringNAMEThe name of this connector.private de.iip_ecosphere.platform.connectors.ConnectorParameterparamsstatic charSEPARATOR_CHARDenotes the path separator for qualified model names.static java.lang.StringSEPARATOR_STRINGDenotes the path separator for qualified model names (as String).static java.lang.StringTOP_OBJECTSDenotes the top-level folder "Objects".static java.lang.StringTOP_TYPESDenotes the top-level folder "Types".static java.lang.StringTOP_VIEWSDenotes the top-level folder "Views".
-
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.OpcUaClientConfigBuilderconfigure(org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfigBuilder configBuilder)Does the basic configuration of the OPC UA client.protected voidconnectImpl(de.iip_ecosphere.platform.connectors.ConnectorParameter params)private org.eclipse.milo.opcua.stack.core.types.builtin.DataValuecreateWriteDataValue(org.eclipse.milo.opcua.stack.core.types.builtin.Variant value)Creates a data value for write accesses.protected voiddisconnectImpl()voiddispose()java.lang.StringenabledEncryption()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 voiderror(java.lang.String message, java.lang.Throwable th)private java.lang.StringgetEndpointUrl(de.iip_ecosphere.platform.connectors.ConnectorParameter params)Construct the endpoint URL.protected org.eclipse.milo.opcua.sdk.client.api.identity.IdentityProvidergetIdentityProvider(de.iip_ecosphere.platform.connectors.ConnectorParameter params)Returns the identity provider by translating the token information inparamsto Milo specific token information.private de.iip_ecosphere.platform.support.identities.IdentityTokengetIdToken(java.lang.String endpointUrl)Returns the id token for an endpoint URL consideringConnectorParameter.ANY_ENDPOINT.java.lang.StringgetName()protected DataItemread()java.lang.StringsupportedEncryption()voidtrigger(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query)protected voidwriteImpl(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
-
-
-
-
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- ifadapteris 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- ifadapteris 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
-
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 consideringConnectorParameter.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 inparamsto Milo specific token information.- Parameters:
params- the connector params- Returns:
- the identity provider
-
disconnectImpl
protected void disconnectImpl() 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
-
read
protected DataItem read() throws java.io.IOException
-
trigger
public void trigger(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query)
-
error
protected void error(java.lang.String message, java.lang.Throwable th)
-
supportedEncryption
public java.lang.String supportedEncryption()
-
enabledEncryption
public java.lang.String enabledEncryption()
-
-