Class TraceToAasService

  • All Implemented Interfaces:
    ParameterConfigurerProvider, Service, ServiceBase

    public class TraceToAasService
    extends AbstractService
    Implements a generic service that maps TraceRecord to an (application) AAS. This service is in development/preliminary. The service does not take any data or produce data, it is just meant to create up the trace record AAS entries. It can be used as a sink. Currently, the service builds up the AAS of an application. However, this functionality shall be moved that the platform is providing the AAS and the service just hooks the traces submodel into.
    Author:
    Holger Eichelberger, SSE
    • Constructor Detail

      • TraceToAasService

        public TraceToAasService​(de.iip_ecosphere.platform.support.iip_aas.ApplicationSetup app,
                                 YamlService yaml)
        Creates a service instance.
        Parameters:
        app - static information about the application
        yaml - the service description
      • TraceToAasService

        public TraceToAasService​(java.lang.String serviceId,
                                 java.io.InputStream ymlFile)
        Creates a service instance from a service id and a YAML artifact.
        Parameters:
        serviceId - the service id
        ymlFile - the YML file containing the YAML artifact with the service descriptor
      • TraceToAasService

        public TraceToAasService​(YamlArtifact artifact,
                                 java.lang.String serviceId)
        Creates a service instance.
        Parameters:
        artifact - static information about the artifact this service is member of
        serviceId - the id of the service
    • Method Detail

      • createConverter

        protected TraceToAasService.Converter createConverter()
        Creates the actual converter instance.
        Returns:
        the converter
      • setTimeout

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

        public de.iip_ecosphere.platform.support.iip_aas.ApplicationSetup getApplicationSetup()
        Returns the application setup.
        Returns:
        the application setup
      • addParameterConfigurer

        protected <T> void addParameterConfigurer​(ParameterConfigurer<T> configurer)
        Adds a parameter configurer.
        Type Parameters:
        T - the type of the parameter
        Parameters:
        configurer - the configurer instance, ignored if null
      • 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 java.lang.String getAasId()
        Returns the AAS idShort of the AAS represented by this service/application.
        Returns:
        the idShort
      • getAasUrn

        public java.lang.String getAasUrn()
        Returns the AAS URN of the AAS represented by this service/application.
        Returns:
        the URN
      • 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
      • start

        protected ServiceState start()
                              throws java.util.concurrent.ExecutionException
        Description copied from class: AbstractService
        Starts the service and the background process.
        Overrides:
        start in class AbstractService
        Returns:
        the state to transition to, may be null for none
        Throws:
        java.util.concurrent.ExecutionException - if starting the process fails
      • stop

        protected ServiceState stop()
        Description copied from class: AbstractService
        Stops the service and the background process.
        Overrides:
        stop in class AbstractService
        Returns:
        the state to transition to, may be null for none
      • augmentServicesSubmodel

        private void augmentServicesSubmodel​(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smBuilder)
        Adds elements to the services submodel if available.
        Parameters:
        smBuilder - the submodel builder
      • augmentCommandsSubmodel

        protected void augmentCommandsSubmodel​(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smBuilder)
        Allows adding application-specific elements to the command submodel, e.g., operations.
        Parameters:
        smBuilder - the builder, do not call Builder.build() in here!
      • migrate

        public void migrate​(java.lang.String resourceId)
                     throws java.util.concurrent.ExecutionException
        Description copied from interface: Service
        Migrates a service. However, it may be required to migrate/move the containing artifact. [adaptation]
        Parameters:
        resourceId - the target resource id, e.g., a device
        Throws:
        java.util.concurrent.ExecutionException - if migration fails
      • update

        public void update​(java.net.URI location)
                    throws java.util.concurrent.ExecutionException
        Description copied from interface: Service
        Updates the service by the service in the given location. This operation is responsible for stopping the running service (if needed), replacing it, starting the new service.
        Parameters:
        location - the location of the new service, e.g., an URL
        Throws:
        java.util.concurrent.ExecutionException - if the given service cannot be updated for some reason, e.g., because the replacement service is not an evolved version of the running service
      • switchTo

        public void switchTo​(java.lang.String targetId)
                      throws java.util.concurrent.ExecutionException
        Description copied from interface: Service
        Switches to an interface-compatible service. This method cares for stopping the old service, performing a handover if adequate, starting the target service. [adaptation]
        Parameters:
        targetId - the id of the target service
        Throws:
        java.util.concurrent.ExecutionException - if switching the service cannot be performed for some reason
      • getParameterConfigurer

        public ParameterConfigurer<?> getParameterConfigurer​(java.lang.String paramName)
        Description copied from interface: ParameterConfigurerProvider
        Returns the parameter configurer for a given parameter. We need this generic approach to ease code generation and initial setting of parameter values.
        Parameters:
        paramName - the name of the parameter
        Returns:
        the associated parameter configurer or null if there is none