EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.sensorframework.adapter]

COVERAGE SUMMARY FOR SOURCE FILE [TimeSpanToQuantilAdapter.java]

nameclass, %method, %block, %line, %
TimeSpanToQuantilAdapter.java0%   (0/1)0%   (0/2)0%   (0/108)0%   (0/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TimeSpanToQuantilAdapter0%   (0/1)0%   (0/2)0%   (0/108)0%   (0/25)
TimeSpanToQuantilAdapter (SensorAndMeasurements): void 0%   (0/1)0%   (0/20)0%   (0/5)
getAdaptedObject (): Object 0%   (0/1)0%   (0/88)0%   (0/20)

1package de.uka.ipd.sdq.sensorframework.adapter;
2 
3import de.uka.ipd.sdq.codegen.simudatavisualisation.datatypes.Histogram;
4import de.uka.ipd.sdq.codegen.simudatavisualisation.datatypes.HistogramBucketInformation;
5import de.uka.ipd.sdq.codegen.simudatavisualisation.datatypes.TimeSeries;
6import de.uka.ipd.sdq.sensorframework.entities.SensorAndMeasurements;
7 
8/**Adapter for TimeSpanSensors to Quantiles.
9 * @author groenda
10 */
11public class TimeSpanToQuantilAdapter extends DataAdapter {
12 
13        /** The property "first value below". */
14        private static final String FIRST_VALUE_BELOW = "FIRST_VALUE_BELOW";
15        /** The property "quantile". */
16        private static final String QUANTIL = "QUANTIL";
17        /** Default quantile to use. */
18        private static final double DEFAULT_QUANTIL = 0.9;
19        /** Factor to use for the histogram for correct scaling of qunatiles. */
20        private static final double QUANTILE_FACTOR = 0.001;
21        /** Information about the TimeSpanSensor and the measurements. */
22        private SensorAndMeasurements samInformation;
23 
24        /**Initializes the adapter with the provided TimeSpanSensor.
25         * @param samInformation Information about the TimeSpanSensor and the 
26         *        measurements.
27         */
28        public TimeSpanToQuantilAdapter(
29                        final SensorAndMeasurements samInformation) {
30                super();
31                this.samInformation = samInformation;
32                adapterProperties.put(FIRST_VALUE_BELOW, true);
33                adapterProperties.put(QUANTIL, DEFAULT_QUANTIL);
34        }
35 
36        /** {@inheritDoc}
37         */
38        public Object getAdaptedObject() {
39                TimeSpanToHistogramAdapter tstha = 
40                        new TimeSpanToHistogramAdapter(samInformation);
41                tstha.getProperties().put("HISTOGRAM_WIDTH", 
42                                new Double(QUANTILE_FACTOR));
43                Histogram hist = (Histogram) tstha.getAdaptedObject();
44                
45                TimeSeries series = new TimeSeries(
46                                samInformation.getSensor().getSensorName());
47 
48                int counter = 0;
49                double sum = 0.0;
50                for (HistogramBucketInformation he : hist.getBucketInformation()) {
51                        sum += he.getProbability();
52                        if (sum >= (Double) adapterProperties.get(QUANTIL)) {
53                                if ((Boolean) adapterProperties.get(FIRST_VALUE_BELOW) 
54                                                && counter > 0) {
55                                        // get the former histogram entity
56                                        he = hist.getBucketInformation().get(counter - 1);
57                                }
58                                series.add(samInformation.getSensor().getSensorID(), 
59                                                he.getValue());
60                                return series;
61                        }
62                        counter++;
63                }
64                return series;
65        }
66}

[all classes][de.uka.ipd.sdq.sensorframework.adapter]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov