Interface ModelAccess
- All Known Implementing Classes:
AbstractModelAccess,AbstractTypeMappingModelAccess
public interface ModelAccess
Provides access to a model-based protocol such as OPC UA or AAS. This interface shall be implemented by the connector
and provided to the protocol adapter/type translators so that they can access the underlying model in a uniform
manner. This interface is preliminary and not complete. Qualified names (
qName) follow a hierarchical naming
schema separated by getQSeparator().
For now, we assume a simple property/operation-based model with basic support for individual struct/record-based
types. In individual protocols, some operations may not be supported and shall be terminated by an exception.
The assumption is that the respective adapter is either programmed having the protocol in mind or adequately
generated. See the annotation MachineConnector that a connector shall be decorated with to steer the
generation.
Initially we considered having direct access into the connector instance as fallback. However, in the mean time
we believe that we then have to adjust the abstraction accordingly.- Author:
- Holger Eichelberger, SSE
-
Method Summary
Modifier and TypeMethodDescriptionCalls an operation on the model.default voiddispose()Called when this instance is explicitly not needed anymore.Returns a property value.default ObjectReturns a property value.default booleangetBoolean(String qName) Returns a byte property value.default byteReturns a byte property value.default doubleReturns a double property value.default floatReturns a float property value.default ModelInputConverterReturns the input converter instance.default intReturns an int property value.default longReturns a double property value.default <C> List<de.iip_ecosphere.platform.transport.serialization.QualifiedElement<C>> getMultiValue(Class<C> eltCls, String name, boolean enumerated, String... qualifiers) Returns the value of a multi-valued property in IDTA style.default ModelOutputConverterReturns the output converter instance.Returns the qualified name separator.default shortReturns a short property value.default StringReturns a byte property value.<T> TReturns the "struct" value of a property.Composes multiple names to a qualified instance name starting withtopInstancesQName()usinggetQSeparator().voidMonitors the givenqNameelement in the server namespace and upon changes, triggers a reception in the connector.voidMonitors the givenqNameelement in the server namespace and upon changes, triggers a reception in the connector.voidMonitors generic model changes, in particular those not covered bymonitor(String...).voidmonitorModelChanges(int notificationInterval) Monitors generic model changes, in particular those not covered bymonitor(String...).Composes multiple names to a qualified name usinggetQSeparator().voidregisterCustomType(Class<?> cls) Registersclsas a custom type, e.g., for structs.voidChanges a property value.default voidsetBoolean(String qName, boolean value) Changes a boolean property value.default voidChanges a byte property value.voidsetDetailNotifiedItem(boolean detail) Whether the connector shall send detailed information about monitored changes.default voidChanges a double property value.default voidChanges a float property value.default voidChanges an int property value.default voidChanges a long property value.default voidsetMultiValue(String name, boolean enumerated, Object elements) Sets a multi-value represented by multiple entities.default voidsetMultiValue(String name, boolean enumerated, List<de.iip_ecosphere.platform.transport.serialization.QualifiedElement<?>> elements) Sets a multi-value represented by multiple entities.default voidChanges a short property value.default voidChanges a string property value.voidChanges the "struct" value of a property.Sets the hierarchical substructure denoted bynameas current scope for further resolution.stepOut()Steps out of the actual context set bystepInto(String).Returns the prefix to be used to access the instances within this model.voiduseNotifications(boolean notifications) Use notifications or polling.
-
Method Details
-
topInstancesQName
String topInstancesQName()Returns the prefix to be used to access the instances within this model.- Returns:
- the prefix, may be empty for none
-
getQSeparator
String getQSeparator()Returns the qualified name separator.- Returns:
- the qualified name separator, empty if
MachineConnector.supportsHierarchicalQNames()isfalse
-
qName
Composes multiple names to a qualified name usinggetQSeparator().- Parameters:
names- the names (may be empty but shall be ignored then)- Returns:
- the composed qualified name, empty if no
nameswere given
-
iqName
Composes multiple names to a qualified instance name starting withtopInstancesQName()usinggetQSeparator().- Parameters:
names- the names (may be empty but shall be ignored then)- Returns:
- the composed qualified name, empty if no
nameswere given
-
call
Calls an operation on the model.- Parameters:
qName- the qualified name of the operation (composed usinggetQSeparator()).args- the arguments for the call- Returns:
- the return value (may be null for void)
- Throws:
IOException- in case that the call fails or calls are not implemented (seeMachineConnector.supportsModelCalls()isfalse)
-
get
Returns a property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value (may be null for void)
- Throws:
IOException- in case that the access fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
get
Returns a property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).lifetime- cache of a node value in the cache, 0 = no caching, negative = forever, positive = lifetime- Returns:
- the property value (may be null for void)
- Throws:
IOException- in case that the access fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getInt
Returns an int property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getFloat
Returns a float property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getDouble
Returns a double property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getLong
Returns a double property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getShort
Returns a short property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getByte
Returns a byte property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getBoolean
Returns a byte property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getString
Returns a byte property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getMultiValue
default <C> List<de.iip_ecosphere.platform.transport.serialization.QualifiedElement<C>> getMultiValue(Class<C> eltCls, String name, boolean enumerated, String... qualifiers) throws IOException Returns the value of a multi-valued property in IDTA style.- Type Parameters:
C- the type of the element value- Parameters:
eltCls- the class of the element value typename- the (basic, generic) name of the propertyenumerated- whether the name used for identifying multi-values in a sequence or whether their qualifiers shall be usedqualifiers- the qualifier(s) denoting the properties to return ifenumeratedis false- Returns:
- the value(s), may be null for none, may be null at individual positions if casting to
clsfails - Throws:
IOException- an exception if accessing a relevant property/value fails (always, seeMachineConnector.supportsMultiValued())
-
set
Changes a property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setInt
Changes an int property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setLong
Changes a long property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setByte
Changes a byte property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setShort
Changes a short property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setBoolean
Changes a boolean property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setDouble
Changes a double property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setFloat
Changes a float property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setString
Changes a string property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setMultiValue
Sets a multi-value represented by multiple entities.- Parameters:
name- the (basic, generic) name of the propertyenumerated- whether the name used for identifying multi-values in a sequence or whether their qualifiers shall be usedelements- the elements/values to be set- Throws:
IOException- an exception if accessing a relevant property/value fails (always, seeMachineConnector.supportsMultiValued())
-
setMultiValue
default void setMultiValue(String name, boolean enumerated, List<de.iip_ecosphere.platform.transport.serialization.QualifiedElement<?>> elements) throws IOException Sets a multi-value represented by multiple entities.- Parameters:
name- the (basic, generic) name of the propertyenumerated- whether the name used for identifying multi-values in a sequence or whether their qualifiers shall be usedelements- the elements/values to be set- Throws:
IOException- an exception if accessing a relevant property/value fails (always, seeMachineConnector.supportsMultiValued())
-
getStruct
Returns the "struct" value of a property. We assume that there is a type definition for the struct realized as class which also represents the actual values. Usually, such custom datatypes must be registered throughregisterCustomType(Class). Details shall be documented by the implementing connector. [struct]- Type Parameters:
T- the type of the struct- Parameters:
qName- the qualified name of the propertytype- the expected type- Returns:
- the value of the slot
- Throws:
IOException- in case that the access fails or structs are not supported (seeMachineConnector.supportsModelStructs()isfalse)- See Also:
-
setStruct
Changes the "struct" value of a property. We assume that there is a type definition for the struct realized as class which also represents the actual values. Usually, such custom datatypes must be registered throughregisterCustomType(Class). Details shall be documented by the implementing connector. [struct]- Parameters:
qName- the qualified name of the slot in the structvalue- the slot value- Throws:
IOException- in case that the access fails or structs are not supported (seeMachineConnector.supportsModelStructs()isfalse)- See Also:
-
registerCustomType
Registersclsas a custom type, e.g., for structs.- Parameters:
cls- the class representing the custom type- Throws:
IOException- in case that accessing relevant information onclsfor performing the registration fails or structs are not supported (seeMachineConnector.supportsModelStructs()isfalse)
-
monitor
Monitors the givenqNameelement in the server namespace and upon changes, triggers a reception in the connector. Intended to be used inConnectorOutputTypeTranslator.initializeModelAccess().ConnectorParameter.getNotificationInterval()shall be used as default value if applicable. [monitoring]- Parameters:
qNames- the qualified names of the elements to monitor- Throws:
IOException- if creating the monitor fails
-
monitor
Monitors the givenqNameelement in the server namespace and upon changes, triggers a reception in the connector. Intended to be used inConnectorOutputTypeTranslator.initializeModelAccess(). [monitoring]- Parameters:
notificationInterval- explicit time interval between two notifications (if applicable)qNames- the qualified names of the elements to monitor- Throws:
IOException- if creating the monitor fails
-
monitorModelChanges
Monitors generic model changes, in particular those not covered bymonitor(String...). Triggers a reception in the connector. Intended to be used inConnectorOutputTypeTranslator.initializeModelAccess().ConnectorParameter.getNotificationInterval()shall be used as default value if applicable. [monitoring]- Throws:
IOException- if creating the monitor fails
-
monitorModelChanges
Monitors generic model changes, in particular those not covered bymonitor(String...). Triggers a reception in the connector. Intended to be used inConnectorOutputTypeTranslator.initializeModelAccess(). [monitoring]- Parameters:
notificationInterval- explicit time interval between two notifications (if applicable)- Throws:
IOException- if creating the monitor fails
-
setDetailNotifiedItem
void setDetailNotifiedItem(boolean detail) Whether the connector shall send detailed information about monitored changes. Intended to be used inConnectorOutputTypeTranslator.initializeModelAccess(). [monitoring]- Parameters:
detail-truefor details,falsefor null (default)
-
useNotifications
void useNotifications(boolean notifications) Use notifications or polling. This is required here, as the related translator codemonitor(String...)depends on that. [monitoring]- Parameters:
notifications-truefor notifications,falsefor polling
-
getInputConverter
Returns the input converter instance.- Returns:
- the input converter
-
getOutputConverter
Returns the output converter instance.- Returns:
- the output converter
-
stepInto
Sets the hierarchical substructure denoted bynameas current scope for further resolution. When overriding, declare the actual type as result type.- Parameters:
name- non-hierarchical name of contained substructure- Returns:
- the sub parse-result taking
nameas context, use#stepOut()to leave that context - Throws:
IOException- if stepping into fails for some reason
-
stepOut
ModelAccess stepOut()Steps out of the actual context set bystepInto(String). When overriding, declare the actual type as result type.- Returns:
- the actual (parent) context, may be null if this step out was illegal in a non-nested context
-
dispose
default void dispose()Called when this instance is explicitly not needed anymore. May not be called in single-threaded connectors.
-