Class Aggregator

  • All Implemented Interfaces:
    org.openmuc.framework.driver.spi.Connection, org.openmuc.framework.driver.spi.DriverService

    public class Aggregator
    extends java.lang.Object
    implements org.openmuc.framework.driver.spi.DriverService, org.openmuc.framework.driver.spi.Connection
    Driver which performs aggregation of logged values from a channel. It uses the DriverService and the DataAccessService. It is therefore a kind of OpenMUC driver/application mix. The aggregator is fully configurable through the channel config file. Synopsis
    • driver id = aggregator
    • channelAddress = <sourceChannelId>:<aggregationType>[:<quality>]
      • sourceChannelId = id of channel to be aggregated
      • aggregationType
        • AVG: calculates the average of all values of interval (e.g. for average power)
        • LAST: takes the last value of interval (e.g. for energy)
        • DIFF: calculates difference of first and last value of interval
        • PULS_ENERGY,<pulses per Wh>,<max counter>: calculates energy from pulses of interval (e.g. for pulse counter/meter)
          • Example: PULSE_ENERGY,10,65535
    • quality = Range 0.0 - 1.0. Percentage of the expected valid/available logged records for aggregation. Default value is 1.0. Example: Aggregation of 5s values to 15min. The 15min interval consists of 180 5s values. If quality is 0.9 then at least 162 of 180 values must be valid/available for aggregation. NOTE: The missing/invalid values could appear as block at the beginning or end of the interval, which might be problematic for some aggregation types

    Example:
    Channel A (channelA) is sampled and logged every 10 seconds.

     <channelid="channelA">
       <samplingInterval>10s</samplingInterval>
       <loggingInterval>10s</loggingInterval>
     </channel>
     

    Now you want a channel B (channelB) which contains the same values as channel A but in a 1 minute resolution by using the 'average' as aggregation type. You can achieve this by simply adding the aggregator driver to your channel config file and define a the channel B as follows:

     <driver id="aggregator">
       <device id="aggregatordevice">
         <channelid="channelB">
           <channelAddress>channelA:avg</channelAddress>
           <samplingInterval>60s</samplingInterval>
           <loggingInterval>60s</loggingInterval>
         </channel>
       </device>
     </driver>
     

    The new (aggregated) channel has the id channelB. The channel address consists of the channel id of the original channel and the aggregation type which is channelA:avg in this example. OpenMUC calls the read method of the aggregator every minute. The aggregator then gets all logged records from channelA of the last minute, calculates the average and sets this value for the record of channelB.

    NOTE: It's recommended to specify the samplingTimeOffset for channelB. It should be between samplingIntervalB - samplingIntervalA and samplingIntervalB. In this example: 50 < offset < 60. This constraint ensures that values are AGGREGATED CORRECTLY. At hh:mm:55 the aggregator gets the logged values of channelA and at hh:mm:60 respectively hh:mm:00 the aggregated value is logged.

     <driver id="aggregator">
       <device id="aggregatordevice">
         <channelid="channelB">
           <channelAddress>channelA:avg</channelAddress>
           <samplingInterval>60s</samplingInterval>
           <samplingTimeOffset>55s</samplingTimeOffset>
           <loggingInterval>60s</loggingInterval>
         </channel>
       </device>
     </driver>
     
    • Constructor Summary

      Constructors 
      Constructor Description
      Aggregator()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.openmuc.framework.driver.spi.Connection connect​(java.lang.String deviceAddress, java.lang.String settings)  
      void disconnect()  
      org.openmuc.framework.config.DriverInfo getInfo()  
      void interruptDeviceScan()  
      java.lang.Object read​(java.util.List<org.openmuc.framework.driver.spi.ChannelRecordContainer> containers, java.lang.Object containerListHandle, java.lang.String samplingGroup)  
      java.util.List<org.openmuc.framework.config.ChannelScanInfo> scanForChannels​(java.lang.String settings)  
      void scanForDevices​(java.lang.String settings, org.openmuc.framework.driver.spi.DriverDeviceScanListener listener)  
      protected void setDataAccessService​(org.openmuc.framework.dataaccess.DataAccessService dataAccessService)  
      void startListening​(java.util.List<org.openmuc.framework.driver.spi.ChannelRecordContainer> containers, org.openmuc.framework.driver.spi.RecordsReceivedListener listener)  
      protected void unsetDataAccessService​(org.openmuc.framework.dataaccess.DataAccessService dataAccessService)  
      java.lang.Object write​(java.util.List<org.openmuc.framework.driver.spi.ChannelValueContainer> containers, java.lang.Object containerListHandle)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Aggregator

        public Aggregator()
    • Method Detail

      • getInfo

        public org.openmuc.framework.config.DriverInfo getInfo()
        Specified by:
        getInfo in interface org.openmuc.framework.driver.spi.DriverService
      • read

        public java.lang.Object read​(java.util.List<org.openmuc.framework.driver.spi.ChannelRecordContainer> containers,
                                     java.lang.Object containerListHandle,
                                     java.lang.String samplingGroup)
                              throws java.lang.UnsupportedOperationException,
                                     org.openmuc.framework.driver.spi.ConnectionException
        Specified by:
        read in interface org.openmuc.framework.driver.spi.Connection
        Throws:
        java.lang.UnsupportedOperationException
        org.openmuc.framework.driver.spi.ConnectionException
      • connect

        public org.openmuc.framework.driver.spi.Connection connect​(java.lang.String deviceAddress,
                                                                   java.lang.String settings)
                                                            throws org.openmuc.framework.config.ArgumentSyntaxException,
                                                                   org.openmuc.framework.driver.spi.ConnectionException
        Specified by:
        connect in interface org.openmuc.framework.driver.spi.DriverService
        Throws:
        org.openmuc.framework.config.ArgumentSyntaxException
        org.openmuc.framework.driver.spi.ConnectionException
      • disconnect

        public void disconnect()
        Specified by:
        disconnect in interface org.openmuc.framework.driver.spi.Connection
      • setDataAccessService

        protected void setDataAccessService​(org.openmuc.framework.dataaccess.DataAccessService dataAccessService)
      • unsetDataAccessService

        protected void unsetDataAccessService​(org.openmuc.framework.dataaccess.DataAccessService dataAccessService)
      • startListening

        public void startListening​(java.util.List<org.openmuc.framework.driver.spi.ChannelRecordContainer> containers,
                                   org.openmuc.framework.driver.spi.RecordsReceivedListener listener)
                            throws java.lang.UnsupportedOperationException,
                                   org.openmuc.framework.driver.spi.ConnectionException
        Specified by:
        startListening in interface org.openmuc.framework.driver.spi.Connection
        Throws:
        java.lang.UnsupportedOperationException
        org.openmuc.framework.driver.spi.ConnectionException
      • write

        public java.lang.Object write​(java.util.List<org.openmuc.framework.driver.spi.ChannelValueContainer> containers,
                                      java.lang.Object containerListHandle)
                               throws java.lang.UnsupportedOperationException,
                                      org.openmuc.framework.driver.spi.ConnectionException
        Specified by:
        write in interface org.openmuc.framework.driver.spi.Connection
        Throws:
        java.lang.UnsupportedOperationException
        org.openmuc.framework.driver.spi.ConnectionException
      • scanForDevices

        public void scanForDevices​(java.lang.String settings,
                                   org.openmuc.framework.driver.spi.DriverDeviceScanListener listener)
                            throws java.lang.UnsupportedOperationException,
                                   org.openmuc.framework.config.ArgumentSyntaxException,
                                   org.openmuc.framework.config.ScanException,
                                   org.openmuc.framework.config.ScanInterruptedException
        Specified by:
        scanForDevices in interface org.openmuc.framework.driver.spi.DriverService
        Throws:
        java.lang.UnsupportedOperationException
        org.openmuc.framework.config.ArgumentSyntaxException
        org.openmuc.framework.config.ScanException
        org.openmuc.framework.config.ScanInterruptedException
      • interruptDeviceScan

        public void interruptDeviceScan()
                                 throws java.lang.UnsupportedOperationException
        Specified by:
        interruptDeviceScan in interface org.openmuc.framework.driver.spi.DriverService
        Throws:
        java.lang.UnsupportedOperationException
      • scanForChannels

        public java.util.List<org.openmuc.framework.config.ChannelScanInfo> scanForChannels​(java.lang.String settings)
                                                                                     throws java.lang.UnsupportedOperationException,
                                                                                            org.openmuc.framework.config.ArgumentSyntaxException,
                                                                                            org.openmuc.framework.config.ScanException,
                                                                                            org.openmuc.framework.driver.spi.ConnectionException
        Specified by:
        scanForChannels in interface org.openmuc.framework.driver.spi.Connection
        Throws:
        java.lang.UnsupportedOperationException
        org.openmuc.framework.config.ArgumentSyntaxException
        org.openmuc.framework.config.ScanException
        org.openmuc.framework.driver.spi.ConnectionException