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

public abstract class TransportToAasConverter<T> extends TransportConverter<T>
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
  • Field Details

  • Constructor Details

    • TransportToAasConverter

      public TransportToAasConverter(String submodelIdShort, String transportStream, Class<T> dataType)
      Creates a service instance.
      Parameters:
      submodelIdShort - the id short of the submodel to be maintained
      transportStream - 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: TransportConverter
      Changes the timeout until trace events are deleted.
      Overrides:
      setTimeout in class TransportConverter<T>
      Parameters:
      timeout - the timeout in ms
    • setCleanupTimeout

      public void setCleanupTimeout(long cleanupTimeout)
      Description copied from class: TransportConverter
      Changes the cleanup timeout, i.e., the time between two cleanups.
      Overrides:
      setCleanupTimeout in class TransportConverter<T>
      Parameters:
      cleanupTimeout - the timeout in ms, disables cleanup if negative
    • getTimeout

      public long getTimeout()
      Returns the timeout.
      Returns:
      the timeout
    • getAasId

      public abstract String getAasId()
      Returns the AAS idShort of the AAS represented by this service/application.
      Returns:
      the idShort
    • getAasUrn

      public abstract String getAasUrn()
      Returns the AAS URN of the AAS represented by this service/application.
      Returns:
      the URN
    • handleNew

      protected void handleNew(T data)
      Description copied from class: TransportConverter
      Handles a new trace record. Called upon arrival. [protected for mocking]
      Specified by:
      handleNew in class TransportConverter<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 value
      data - the data that may be used to create the element
    • getSubmodelElementIdFunction

      protected abstract Function<T,String> getSubmodelElementIdFunction()
      Returns a function turning a data instance into an id of the submodel representing the data instance.
      Returns:
      the function
    • addConverter

      protected void addConverter(Class<?> cls, TransportToAasConverter.TypeConverter converter)
      Adds/overwrites a converter.
      Parameters:
      cls - the class the converter applies to
      converter - 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 builder
      payload - the payload to be presented
    • cleanup

      public boolean cleanup()
      Description copied from class: TransportConverter
      Pursues a cleanup of the internal data structures, if applicable.
      Overrides:
      cleanup in class TransportConverter<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 in handleNew(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

      public abstract TransportToAasConverter.CleanupPredicate getCleanupPredicate()
      Returns the cleanup predicate.
      Returns:
      the predicate
    • isAasStarted

      public boolean isAasStarted()
      Description copied from class: TransportConverter
      Returns whether the AAS was started/startup is done.
      Overrides:
      isAasStarted in class TransportConverter<T>
      Returns:
      true for started, false else
    • start

      public void start(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aasSetup)
      Description copied from class: TransportConverter
      Starts the transport tracer.
      Overrides:
      start in class TransportConverter<T>
      Parameters:
      aasSetup - the AAS setup to use
    • stop

      public void stop()
      Description copied from class: TransportConverter
      Stops the transport, deletes the AAS.
      Overrides:
      stop in class TransportConverter<T>
    • isTraceInAas

      public boolean isTraceInAas()
      Description copied from class: TransportConverter
      Returns whether traced data is directly stored in the AAS or not.
      Overrides:
      isTraceInAas in class TransportConverter<T>
      Returns:
      true for traced data in AAS, false else
    • 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 if AAS enabled supplier signals that there shall not be an AAS.
      Parameters:
      aas - the AAS to clean up
      Returns:
      true for success, false else
    • doWatch

      protected abstract void doWatch(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection coll, long lastRun)
      Used in TransportToAasConverter<T>.AasWatcher to regularly watch the status entires.
      Parameters:
      coll - the collection representing an entry
      lastRun - the last run of the watcher
    • createWatcher

      public TransportConverter.Watcher<T> createWatcher(int period)
      Description copied from class: TransportConverter
      Creates a watcher instance.
      Specified by:
      createWatcher in class TransportConverter<T>
      Parameters:
      period - the watching period in ms
      Returns:
      the watcher