Class Rrd4jTimedataImpl

    • Constructor Detail

      • Rrd4jTimedataImpl

        public Rrd4jTimedataImpl()
    • Method Detail

      • postProcessData

        protected static double[] postProcessData​(org.rrd4j.core.FetchRequest request,
                                                  long resolution)
                                           throws java.io.IOException,
                                                  java.lang.IllegalArgumentException
        Post-Process the received data.

        This mainly makes sure the data has the correct resolution.

        Parameters:
        request - the RRD4j FetchRequest
        resolution - the resolution in seconds
        Returns:
        the result array
        Throws:
        java.io.IOException - on error
        java.lang.IllegalArgumentException - on error
      • queryHistoricEnergyPerPeriod

        public java.util.SortedMap<java.time.ZonedDateTime,​java.util.SortedMap<ChannelAddress,​com.google.gson.JsonElement>> queryHistoricEnergyPerPeriod​(java.lang.String edgeId,
                                                                                                                                                                     java.time.ZonedDateTime fromDate,
                                                                                                                                                                     java.time.ZonedDateTime toDate,
                                                                                                                                                                     java.util.Set<ChannelAddress> channels,
                                                                                                                                                                     Resolution resolution)
                                                                                                                                                              throws OpenemsError.OpenemsNamedException
        Description copied from interface: CommonTimedataService
        Queries historic energy per period.

        This is for use-cases where you want to get the energy for each period (with Resolution) per Channel, e.g. to visualize energy in a histogram chart. For each period the energy is calculated by subtracting first value of the period from the last value of the period.

        Specified by:
        queryHistoricEnergyPerPeriod in interface CommonTimedataService
        Parameters:
        edgeId - the Edge-ID; or null query all
        fromDate - the From-Date
        toDate - the To-Date
        channels - the Channels
        resolution - the Resolution
        Returns:
        the query result
        Throws:
        OpenemsError.OpenemsNamedException
      • getLatestValue

        public java.util.concurrent.CompletableFuture<java.util.Optional<java.lang.Object>> getLatestValue​(ChannelAddress channelAddress)
        Description copied from interface: Timedata
        Gets the latest known value for the given ChannelAddress.
        Specified by:
        getLatestValue in interface Timedata
        Parameters:
        channelAddress - the ChannelAddress to be queried
        Returns:
        the latest known value or Empty
      • getRrdDb

        protected org.rrd4j.core.RrdDb getRrdDb​(ChannelAddress channelAddress,
                                                Unit channelUnit,
                                                long startTime)
                                         throws java.io.IOException,
                                                java.net.URISyntaxException
        Gets the RRD4j database for the given Channel-Address.

        The predefined RRD4J archives match the requirements of CommonTimedataService.calculateResolution(ZonedDateTime, ZonedDateTime)

        Parameters:
        channelAddress - the Channel-Address
        channelUnit - the Unit
        startTime - the starttime for newly created RrdDbs
        Returns:
        the RrdDb
        Throws:
        java.io.IOException - on error
        java.net.URISyntaxException - on error
      • getExistingRrdDb

        protected org.rrd4j.core.RrdDb getExistingRrdDb​(ChannelAddress channelAddress)
        Gets an existing RrdDb.
        Parameters:
        channelAddress - the ChannelAddress
        Returns:
        the RrdDb or null
        Throws:
        java.io.IOException - on error
        java.net.URISyntaxException - on error
      • logInfo

        protected void logInfo​(org.slf4j.Logger log,
                               java.lang.String message)
        Description copied from class: AbstractOpenemsComponent
        Log an info message including the Component ID.
        Overrides:
        logInfo in class AbstractOpenemsComponent
        Parameters:
        log - the Logger instance
        message - the message
      • logWarn

        protected void logWarn​(org.slf4j.Logger log,
                               java.lang.String message)
        Description copied from class: AbstractOpenemsComponent
        Log a warn message including the Component ID.
        Overrides:
        logWarn in class AbstractOpenemsComponent
        Parameters:
        log - the Logger instance
        message - the message
      • handleEvent

        public void handleEvent​(org.osgi.service.event.Event event)
        Specified by:
        handleEvent in interface org.osgi.service.event.EventHandler