Class TransportToAasConverter<T>

  • Type Parameters:
    T - the data type
    Direct Known Subclasses:
    TraceToAasService.Converter

    public abstract class TransportToAasConverter<T>
    extends java.lang.Object
    Implements a generic converter from transport stream entries to AAS.
    Author:
    Holger Eichelberger, SSE
    • Constructor Detail

      • TransportToAasConverter

        public TransportToAasConverter​(java.lang.String submodelIdShort,
                                       java.lang.String transportStream,
                                       java.lang.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 Detail

      • setTimeout

        public void setTimeout​(long timeout)
        Changes the timeout until trace events are deleted.
        Parameters:
        timeout - the timeout in ms
      • getTimeout

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

        protected void addConverter​(java.lang.Class<?> cls,
                                    TransportToAasConverter.TypeConverter converter)
        Adds/overwrites a converter.
        Parameters:
        cls - the class the converter applies to
        converter - the converter instance
      • getAasId

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

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

        protected abstract void populateSubmodelElementCollection​(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder 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 java.util.function.Function<T,​java.lang.String> getSubmodelElementIdFunction()
        Returns a function turning a data instance into an id of the submodel representing the data instance.
        Returns:
        the function
      • createPayloadEntries

        protected void createPayloadEntries​(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder payloadBuilder,
                                            java.lang.Object payload)
        Creates the generic properties and contents for the given payload object.
        Parameters:
        payloadBuilder - the payload builder
        payload - the payload to be presented
      • getValue

        private java.lang.Object getValue​(java.lang.Object object,
                                          java.lang.reflect.Method method,
                                          java.lang.String field)
        Obtains the value return by method on payload.
        Parameters:
        object - the object to call the method on
        method - the method to call
        field - the represented field (for logging)
        Returns:
        the value of field via method
      • mapPayloadType

        protected java.lang.String mapPayloadType​(java.lang.Class<?> cls)
        Allows for application specific payload type names.
        Parameters:
        cls - the type
        Returns:
        the mapped name
      • isGetter

        private static boolean isGetter​(java.lang.reflect.Method method)
        Returns whether method is an usual getter.
        Parameters:
        method - the method to analyze
        Returns:
        true for getter, false else
      • cleanup

        public void 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
        See Also:
        getCleanupPredicate()
      • start

        public boolean start​(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aasSetup,
                             boolean deploy)
        Starts the transport tracer.
        Parameters:
        aasSetup - the AAS setup to use
        deploy - whether the AAS represented by this converter shall be deployed
        Returns:
        true for success, false else
      • buildUpAas

        protected boolean buildUpAas​(de.iip_ecosphere.platform.support.aas.Aas.AasBuilder aasBuilder)
        Builds up the AAS.
        Parameters:
        aasBuilder - the aas builder to use
        Returns:
        true for success, false else
      • stop

        public boolean stop()
        Stops the transport, deletes the AAS.
        Returns:
        true for success, 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.
        Parameters:
        aas - the AAS to clean up
        Returns:
        true for success, false else