Class TransportToAasConverter<T>
java.lang.Object
de.iip_ecosphere.platform.services.environment.services.TransportConverter<T>
de.iip_ecosphere.platform.services.environment.services.TransportToAasConverter<T>
- Type Parameters:
T- the data type
- Direct Known Subclasses:
TraceToAasService.Converter
Implements a generic converter from transport stream entries to AAS. Specific types may require an own
type/value converter to AAS which can be attached to the converter instance. The actual implementation relies on
dedicated entries in a given submodel, which may be resource consuming and cause conflicts with the
AAS server when regularly cleaning up the entries. Thus, it is not recommended to use this until the
underlying AAS implementation offers application-specific AAS events. The related
TransportConverter.Watcher
ignores the attachable consumer and uses doWatch(SubmodelElementCollection, long) instead to
avoid converting submodel elements back to instances of the data type T.
Recommendation: If adequate, use TransportToWsConverter instead.- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA regular AAS watcher.static interfacePredicate to determine whether a submodel elements collection shall be deleted.static classEncapsulates a Java-to-AAS type converter.static interfaceConverts a Java value to an AAS value.Nested classes/interfaces inherited from class de.iip_ecosphere.platform.services.environment.services.TransportConverter
TransportConverter.ConverterInstances<T>, TransportConverter.Watcher<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate de.iip_ecosphere.platform.support.aas.Aasprivate longprivate longprivate de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetupprivate booleanprivate longprivate Map<Class<?>, TransportToAasConverter.TypeConverter> private static final Map<Class<?>, TransportToAasConverter.TypeConverter> static final TransportToAasConverter.ValueConverterstatic final TransportToAasConverter.ValueConverterstatic final TransportToAasConverter.ValueConverterprivate longstatic final TransportToAasConverter.ValueConverterstatic final TransportToAasConverter.ValueConverterprivate Stringprivate longFields inherited from class de.iip_ecosphere.platform.services.environment.services.TransportConverter
NAME_COLL_ENDPOINTS, NAME_PROP_HOST, NAME_PROP_PATH, NAME_PROP_PORT, NAME_PROP_SCHEMA, NAME_PROP_URI, PREFIX_GETTER -
Constructor Summary
ConstructorsConstructorDescriptionTransportToAasConverter(String submodelIdShort, String transportStream, Class<T> dataType) Creates a service instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddConverter(Class<?> cls, TransportToAasConverter.TypeConverter converter) Adds/overwrites a converter.booleancleanup()Pursues a cleanup of the internal data structures, if applicable.booleancleanup(de.iip_ecosphere.platform.support.aas.Aas aas) Cleans up outdated trace entries.protected booleancleanUpAas(de.iip_ecosphere.platform.support.aas.Aas aas) Cleans up the AAS.protected voidcreatePayloadEntries(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder payloadBuilder, Object payload) Creates the generic properties and contents for the given payload object.createWatcher(int period) Creates a watcher instance.protected abstract voiddoWatch(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection coll, long lastRun) Used inTransportToAasConverter<T>.AasWatcherto regularly watch the status entires.abstract StringgetAasId()Returns the AAS idShort of the AAS represented by this service/application.abstract StringReturns the AAS URN of the AAS represented by this service/application.Returns the cleanup predicate.Returns a function turning a data instance into an id of the submodel representing the data instance.longReturns the timeout.protected voidHandles a new trace record.booleanReturns whether the AAS was started/startup is done.booleanReturns whether traced data is directly stored in the AAS or not.protected abstract voidpopulateSubmodelElementCollection(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder smcBuilder, T data) Creates the submodel element representing a single received data value.voidsetCleanupTimeout(long cleanupTimeout) Changes the cleanup timeout, i.e., the time between two cleanups.voidsetTimeout(long timeout) Changes the timeout until trace events are deleted.voidstart(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aasSetup) Starts the transport tracer.voidstop()Stops the transport, deletes the AAS.Methods inherited from class de.iip_ecosphere.platform.services.environment.services.TransportConverter
addEndpointToAas, addNotifier, getEndpoint, getEndpoint, getEndpoint, getExcludedFieldsArray, getType, getValue, initializeSubmodel, isAasEnabled, isExcludedField, isGetter, mapPayloadType, setAasEnabledSupplier, setExcludedFields, setHandleNewFilter, toAasEndpointId
-
Field Details
-
IDENTITY_CONVERTER
-
JSON_CONVERTER
-
SHORT2INT_CONVERTER
-
STRING_CONVERTER
-
ENUM_NAME_CONVERTER
-
DEFAULT_CONVERTERS
-
METHODS_TO_IGNORE
-
converters
-
timeout
private long timeout -
lastCleanup
private long lastCleanup -
cleanupTimeout
private long cleanupTimeout -
aasFailedTimestamp
private long aasFailedTimestamp -
aasFailedTimeout
private long aasFailedTimeout -
submodelIdShort
-
aasSetup
private de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aasSetup -
aasStarted
private boolean aasStarted -
aas
private transient de.iip_ecosphere.platform.support.aas.Aas aas
-
-
Constructor Details
-
TransportToAasConverter
Creates a service instance.- Parameters:
submodelIdShort- the id short of the submodel to be maintainedtransportStream- the transport stream to be observed (name of the stream)dataType- the type of the data in the transport stream
-
-
Method Details
-
setTimeout
public void setTimeout(long timeout) Description copied from class:TransportConverterChanges the timeout until trace events are deleted.- Overrides:
setTimeoutin classTransportConverter<T>- Parameters:
timeout- the timeout in ms
-
setCleanupTimeout
public void setCleanupTimeout(long cleanupTimeout) Description copied from class:TransportConverterChanges the cleanup timeout, i.e., the time between two cleanups.- Overrides:
setCleanupTimeoutin classTransportConverter<T>- Parameters:
cleanupTimeout- the timeout in ms, disables cleanup if negative
-
getTimeout
public long getTimeout()Returns the timeout.- Returns:
- the timeout
-
getAasId
Returns the AAS idShort of the AAS represented by this service/application.- Returns:
- the idShort
-
getAasUrn
Returns the AAS URN of the AAS represented by this service/application.- Returns:
- the URN
-
handleNew
Description copied from class:TransportConverterHandles a new trace record. Called upon arrival. [protected for mocking]- Specified by:
handleNewin classTransportConverter<T>- Parameters:
data- the trace record data
-
populateSubmodelElementCollection
protected abstract void populateSubmodelElementCollection(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder smcBuilder, T data) Creates the submodel element representing a single received data value.- Parameters:
smcBuilder- the builder for the submodel element collection representing the data valuedata- the data that may be used to create the element
-
getSubmodelElementIdFunction
Returns a function turning a data instance into an id of the submodel representing the data instance.- Returns:
- the function
-
addConverter
Adds/overwrites a converter.- Parameters:
cls- the class the converter applies toconverter- the converter instance
-
createPayloadEntries
protected void createPayloadEntries(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder payloadBuilder, Object payload) Creates the generic properties and contents for the given payload object.- Parameters:
payloadBuilder- the payload builderpayload- the payload to be presented
-
cleanup
public boolean cleanup()Description copied from class:TransportConverterPursues a cleanup of the internal data structures, if applicable.- Overrides:
cleanupin classTransportConverter<T>- Returns:
- whether a cleanup process was executed (not whether elements were deleted)
-
cleanup
public boolean cleanup(de.iip_ecosphere.platform.support.aas.Aas aas) Cleans up outdated trace entries. Called inhandleNew(Object)if regular input is expected, may be called regularly by an external timer.- Parameters:
aas- the AAS to clean up- Returns:
- whether a cleanup process was executed (not whether elements were deleted)
- See Also:
-
getCleanupPredicate
Returns the cleanup predicate.- Returns:
- the predicate
-
isAasStarted
public boolean isAasStarted()Description copied from class:TransportConverterReturns whether the AAS was started/startup is done.- Overrides:
isAasStartedin classTransportConverter<T>- Returns:
truefor started,falseelse
-
start
public void start(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aasSetup) Description copied from class:TransportConverterStarts the transport tracer.- Overrides:
startin classTransportConverter<T>- Parameters:
aasSetup- the AAS setup to use
-
stop
public void stop()Description copied from class:TransportConverterStops the transport, deletes the AAS.- Overrides:
stopin classTransportConverter<T>
-
isTraceInAas
public boolean isTraceInAas()Description copied from class:TransportConverterReturns whether traced data is directly stored in the AAS or not.- Overrides:
isTraceInAasin classTransportConverter<T>- Returns:
truefor traced data in AAS,falseelse
-
cleanUpAas
protected boolean cleanUpAas(de.iip_ecosphere.platform.support.aas.Aas aas) Cleans up the AAS. Last action, may delete the AAS itself. May not be called ifAAS enabled suppliersignals that there shall not be an AAS.- Parameters:
aas- the AAS to clean up- Returns:
truefor success,falseelse
-
doWatch
protected abstract void doWatch(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection coll, long lastRun) Used inTransportToAasConverter<T>.AasWatcherto regularly watch the status entires.- Parameters:
coll- the collection representing an entrylastRun- the last run of the watcher
-
createWatcher
Description copied from class:TransportConverterCreates a watcher instance.- Specified by:
createWatcherin classTransportConverter<T>- Parameters:
period- the watching period in ms- Returns:
- the watcher
-