Interface ModelAccess
-
- All Known Implementing Classes:
AbstractModelAccess
public interface ModelAccessProvides 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 bygetQSeparator(). 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 annotationMachineConnectorthat 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.Objectcall(java.lang.String qName, java.lang.Object... args)Calls an operation on the model.java.lang.Objectget(java.lang.String qName)Returns a property value.default java.lang.Objectget(java.lang.String qName, int lifetime)Returns a property value.default booleangetBoolean(java.lang.String qName)Returns a byte property value.default bytegetByte(java.lang.String qName)Returns a byte property value.default doublegetDouble(java.lang.String qName)Returns a double property value.default floatgetFloat(java.lang.String qName)Returns a float property value.default ModelInputConvertergetInputConverter()Returns the input converter instance.default intgetInt(java.lang.String qName)Returns an int property value.default longgetLong(java.lang.String qName)Returns a double property value.default ModelOutputConvertergetOutputConverter()Returns the output converter instance.java.lang.StringgetQSeparator()Returns the qualified name separator.default shortgetShort(java.lang.String qName)Returns a short property value.default java.lang.StringgetString(java.lang.String qName)Returns a byte property value.<T> TgetStruct(java.lang.String qName, java.lang.Class<T> type)Returns the "struct" value of a property.java.lang.StringiqName(java.lang.String... names)Composes multiple names to a qualified instance name starting withtopInstancesQName()usinggetQSeparator().voidmonitor(int notificationInterval, java.lang.String... qNames)Monitors the givenqNameelement in the server namespace and upon changes, triggers a reception in the connector.voidmonitor(java.lang.String... qNames)Monitors the givenqNameelement in the server namespace and upon changes, triggers a reception in the connector.voidmonitorModelChanges()Monitors generic model changes, in particular those not covered bymonitor(String...).voidmonitorModelChanges(int notificationInterval)Monitors generic model changes, in particular those not covered bymonitor(String...).java.lang.StringqName(java.lang.String... names)Composes multiple names to a qualified name usinggetQSeparator().voidregisterCustomType(java.lang.Class<?> cls)Registersclsas a custom type, e.g., for structs.voidset(java.lang.String qName, java.lang.Object value)Changes a property value.default voidsetBoolean(java.lang.String qName, boolean value)Changes a boolean property value.default voidsetByte(java.lang.String qName, byte value)Changes a byte property value.voidsetDetailNotifiedItem(boolean detail)Whether the connector shall send detailed information about monitored changes.default voidsetDouble(java.lang.String qName, double value)Changes a double property value.default voidsetFloat(java.lang.String qName, float value)Changes a float property value.default voidsetInt(java.lang.String qName, int value)Changes an int property value.default voidsetLong(java.lang.String qName, long value)Changes a long property value.default voidsetShort(java.lang.String qName, short value)Changes a short property value.default voidsetString(java.lang.String qName, java.lang.String value)Changes a string property value.voidsetStruct(java.lang.String qName, java.lang.Object value)Changes the "struct" value of a property.ModelAccessstepInto(java.lang.String name)Sets the hierarchical substructure denoted bynameas current scope for further resolution.ModelAccessstepOut()Steps out of the actual context set bystepInto(String).java.lang.StringtopInstancesQName()Returns the prefix to be used to access the instances within this model.voiduseNotifications(boolean notifications)Use notifications or polling.
-
-
-
Method Detail
-
topInstancesQName
java.lang.String topInstancesQName()
Returns the prefix to be used to access the instances within this model.- Returns:
- the prefix, may be empty for none
-
getQSeparator
java.lang.String getQSeparator()
Returns the qualified name separator.- Returns:
- the qualified name separator, empty if
MachineConnector.supportsHierarchicalQNames()isfalse
-
qName
java.lang.String qName(java.lang.String... names)
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
java.lang.String iqName(java.lang.String... names)
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
java.lang.Object call(java.lang.String qName, java.lang.Object... args) throws java.io.IOExceptionCalls 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:
java.io.IOException- in case that the call fails or calls are not implemented (seeMachineConnector.supportsModelCalls()isfalse)
-
get
java.lang.Object get(java.lang.String qName) throws java.io.IOExceptionReturns a property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value (may be null for void)
- Throws:
java.io.IOException- in case that the access fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
get
default java.lang.Object get(java.lang.String qName, int lifetime) throws java.io.IOExceptionReturns 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:
java.io.IOException- in case that the access fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getInt
default int getInt(java.lang.String qName) throws java.io.IOExceptionReturns an int property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
java.io.IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getFloat
default float getFloat(java.lang.String qName) throws java.io.IOExceptionReturns a float property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
java.io.IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getDouble
default double getDouble(java.lang.String qName) throws java.io.IOExceptionReturns a double property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
java.io.IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getLong
default long getLong(java.lang.String qName) throws java.io.IOExceptionReturns a double property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
java.io.IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getShort
default short getShort(java.lang.String qName) throws java.io.IOExceptionReturns a short property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
java.io.IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getByte
default byte getByte(java.lang.String qName) throws java.io.IOExceptionReturns a byte property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
java.io.IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getBoolean
default boolean getBoolean(java.lang.String qName) throws java.io.IOExceptionReturns a byte property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
java.io.IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getString
default java.lang.String getString(java.lang.String qName) throws java.io.IOExceptionReturns a byte property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).- Returns:
- the property value
- Throws:
java.io.IOException- in case that the access/conversion fails or reading properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
set
void set(java.lang.String qName, java.lang.Object value) throws java.io.IOExceptionChanges a property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
java.io.IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setInt
default void setInt(java.lang.String qName, int value) throws java.io.IOExceptionChanges an int property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
java.io.IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setLong
default void setLong(java.lang.String qName, long value) throws java.io.IOExceptionChanges a long property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
java.io.IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setByte
default void setByte(java.lang.String qName, byte value) throws java.io.IOExceptionChanges a byte property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
java.io.IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setShort
default void setShort(java.lang.String qName, short value) throws java.io.IOExceptionChanges a short property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
java.io.IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setBoolean
default void setBoolean(java.lang.String qName, boolean value) throws java.io.IOExceptionChanges a boolean property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
java.io.IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setDouble
default void setDouble(java.lang.String qName, double value) throws java.io.IOExceptionChanges a double property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
java.io.IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setFloat
default void setFloat(java.lang.String qName, float value) throws java.io.IOExceptionChanges a float property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
java.io.IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
setString
default void setString(java.lang.String qName, java.lang.String value) throws java.io.IOExceptionChanges a string property value.- Parameters:
qName- the qualified name of the property (composed usinggetQSeparator()).value- the new property value- Throws:
java.io.IOException- in case that the access fails or setting properties is not implemented (seeMachineConnector.supportsModelProperties()isfalse)
-
getStruct
<T> T getStruct(java.lang.String qName, java.lang.Class<T> type) throws java.io.IOExceptionReturns 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:
java.io.IOException- in case that the access fails or structs are not supported (seeMachineConnector.supportsModelStructs()isfalse)- See Also:
registerCustomType(Class)
-
setStruct
void setStruct(java.lang.String qName, java.lang.Object value) throws java.io.IOExceptionChanges 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:
java.io.IOException- in case that the access fails or structs are not supported (seeMachineConnector.supportsModelStructs()isfalse)- See Also:
registerCustomType(Class)
-
registerCustomType
void registerCustomType(java.lang.Class<?> cls) throws java.io.IOExceptionRegistersclsas a custom type, e.g., for structs.- Parameters:
cls- the class representing the custom type- Throws:
java.io.IOException- in case that accessing relevant information onclsfor performing the registration fails or structs are not supported (seeMachineConnector.supportsModelStructs()isfalse)
-
monitor
void monitor(java.lang.String... qNames) throws java.io.IOExceptionMonitors 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:
java.io.IOException- if creating the monitor fails
-
monitor
void monitor(int notificationInterval, java.lang.String... qNames) throws java.io.IOExceptionMonitors the givenqNameelement in the server namespace and upon changes, triggers a reception in the connector. Intended to be used inConnectorOutputTypeTranslator.initializeModelAccess(). [monitoring]- Parameters:
qNames- the qualified names of the elements to monitornotificationInterval- explicit time interval between two notifications (if applicable)- Throws:
java.io.IOException- if creating the monitor fails
-
monitorModelChanges
void monitorModelChanges() throws java.io.IOExceptionMonitors 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:
java.io.IOException- if creating the monitor fails
-
monitorModelChanges
void monitorModelChanges(int notificationInterval) throws java.io.IOExceptionMonitors 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:
java.io.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
default ModelInputConverter getInputConverter()
Returns the input converter instance.- Returns:
- the input converter
-
getOutputConverter
default ModelOutputConverter getOutputConverter()
Returns the output converter instance.- Returns:
- the output converter
-
stepInto
ModelAccess stepInto(java.lang.String name) throws java.io.IOException
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:
java.io.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
-
-