DESY ACOP Beans Home

com.cosylab.gui.adapters
Class DataInterceptor

java.lang.Object
  extended by com.cosylab.gui.adapters.DataInterceptor
All Implemented Interfaces:
DataConsumer, DoubleConsumer

public class DataInterceptor
extends java.lang.Object
implements DoubleConsumer

DataInterceptor filters data that belongs to DoubleConsumer. DataInterceptor saves a certain amount of data (defined with timeInterval in constructor). After that time elapses average value and standard deviation are calculated. Interceptor than updates consumer with four values: average value at the begining and end of the interval that all data belongs too, min and max value on this interval.

DataInterceptor can be used with chart consumers when great ammount of data needs to be displayed.

Since:
VERSION
Version:
$Id: DataInterceptor.java,v 1.6 2008-04-22 12:31:02 jbobnar Exp $
Author:
Jaka Bobnar

Constructor Summary
DataInterceptor()
          Default constructor.
DataInterceptor(DoubleConsumer consumer, long timeInterval)
          Constructor.
 
Method Summary
 double getAverage()
          Returns the average value on the interval of the last dispatched data.
 DataConsumer getDataConsumer(java.lang.Class type)
           Returns data consumer for requested data consumer type.
 DataConsumer getDefaultDataConsumer()
          Returns the implementation of default consumer type supported by this data consumer.
 double getDeviation()
          Returns the value of standard deviation for the last dispatched data.
 java.lang.String getName()
          Returns name of this data consumer.
 java.lang.String[] getSupportedCharacteristics()
          Resturns array with names of supported characteristics.
 java.lang.Class[] getSupportedConsumerTypes()
          Returns array of supported data consumer types, which can be used as parameter and returnned with getDataCosnumer(Class) method.
 long getTimeInterval()
          Returns the time interval set for this interceptor.
 void setCharacteristics(java.util.Map characteristics)
          Sets new dynamic value characteristics to this data consumer.
 void setConsumer(DoubleConsumer newConsumer)
          Sets consumer of which this DataInterceptor intercepts data.
 void setTimeInterval(long timeInterval)
          Sets the time interval for calculating average and deviation.
 void updateDataState(DataState datastate)
          Push data state (quality) update change for dynamic value.
 void updateValue(long timestamp, double value)
          Notifys this consumer about new dynamic value update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataInterceptor

public DataInterceptor()
Default constructor.


DataInterceptor

public DataInterceptor(DoubleConsumer consumer,
                       long timeInterval)
Constructor.

Parameters:
consumer - consumers that sends data to displayer
timeInterval - time interval in millis
Method Detail

setTimeInterval

public void setTimeInterval(long timeInterval)
Sets the time interval for calculating average and deviation.

Parameters:
timeInterval -

getTimeInterval

public long getTimeInterval()
Returns the time interval set for this interceptor.

Returns:
time interval

getDeviation

public double getDeviation()
Returns the value of standard deviation for the last dispatched data.

Returns:
standard deviation

getAverage

public double getAverage()
Returns the average value on the interval of the last dispatched data.

Returns:
average

updateValue

public void updateValue(long timestamp,
                        double value)
                 throws CommonException
Description copied from interface: DoubleConsumer
Notifys this consumer about new dynamic value update.

Specified by:
updateValue in interface DoubleConsumer
Parameters:
timestamp - the time of dynamic value event
value - new value
Throws:
CommonException

setConsumer

public void setConsumer(DoubleConsumer newConsumer)
Sets consumer of which this DataInterceptor intercepts data.

Parameters:
newConsumer -

getDataConsumer

public DataConsumer getDataConsumer(java.lang.Class type)
Description copied from interface: DataConsumer

Returns data consumer for requested data consumer type. If this data consumer does not support required data consumer, null is returned.

If this data cosnumer does not support specific data consumer type, then it means, that it is not desirable to cast data of that type to any by this consumer supported data consumer types.

Specified by:
getDataConsumer in interface DataConsumer
Parameters:
type - Class of specific data consumer (e.g. DoubleConsumer)
Returns:
implementation of required data consumer or null if not supported

getDefaultDataConsumer

public DataConsumer getDefaultDataConsumer()
Description copied from interface: DataConsumer
Returns the implementation of default consumer type supported by this data consumer.

Specified by:
getDefaultDataConsumer in interface DataConsumer
Returns:
the implementation of default consumer type supported by this data consumer

updateDataState

public void updateDataState(DataState datastate)
Description copied from interface: DataConsumer
Push data state (quality) update change for dynamic value. Usually called by data source.

Specified by:
updateDataState in interface DataConsumer
Parameters:
datastate - new data state(quality) descriptor

setCharacteristics

public void setCharacteristics(java.util.Map characteristics)
Description copied from interface: DataConsumer
Sets new dynamic value characteristics to this data consumer. This is usually called only at initializaation, before first data state or value is updated. Usually carries characteristics such as value minimum or maximum. Name and meaning of atributes is defined with contract betwean data consumer and source implementation.

Specified by:
setCharacteristics in interface DataConsumer
Parameters:
characteristics - the Map with attri

getName

public java.lang.String getName()
Description copied from interface: DataConsumer
Returns name of this data consumer.

Specified by:
getName in interface DataConsumer
Returns:
the name of this data consumer

getSupportedCharacteristics

public java.lang.String[] getSupportedCharacteristics()
Description copied from interface: DataConsumer
Resturns array with names of supported characteristics. Data source can use this method to optimize setting characteristics to this data consumer. If arrray of length 0 is return, then consumer does not need or support any characteristic. If null is returned, than consumer expect all existing characteristics from data source.

Specified by:
getSupportedCharacteristics in interface DataConsumer
Returns:
array with names of supported characteristics

getSupportedConsumerTypes

public java.lang.Class[] getSupportedConsumerTypes()
Description copied from interface: DataConsumer
Returns array of supported data consumer types, which can be used as parameter and returnned with getDataCosnumer(Class) method.

Specified by:
getSupportedConsumerTypes in interface DataConsumer
Returns:
array of supported data consumer types


Copyright © 2010. All Rights Reserved.