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 [StateSensorToTimeDeltaPieAdapter.java]

nameclass, %method, %block, %line, %
StateSensorToTimeDeltaPieAdapter.java0%   (0/1)0%   (0/3)0%   (0/92)0%   (0/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StateSensorToTimeDeltaPieAdapter0%   (0/1)0%   (0/3)0%   (0/92)0%   (0/20)
StateSensorToTimeDeltaPieAdapter (SensorAndMeasurements): void 0%   (0/1)0%   (0/4)0%   (0/2)
calculateFractions (HashMap): double 0%   (0/1)0%   (0/83)0%   (0/17)
instantiatePie (String): AbstractPie 0%   (0/1)0%   (0/5)0%   (0/1)

1package de.uka.ipd.sdq.sensorframework.adapter;
2 
3import java.util.HashMap;
4 
5import de.uka.ipd.sdq.codegen.simudatavisualisation.datatypes.AbstractPie;
6import de.uka.ipd.sdq.codegen.simudatavisualisation.datatypes.TimeDeltaPie;
7import de.uka.ipd.sdq.sensorframework.entities.Measurement;
8import de.uka.ipd.sdq.sensorframework.entities.SensorAndMeasurements;
9import de.uka.ipd.sdq.sensorframework.entities.State;
10import de.uka.ipd.sdq.sensorframework.entities.StateMeasurement;
11import de.uka.ipd.sdq.sensorframework.entities.StateSensor;
12 
13/**
14 * This adapter provides a time-delta-based calculation of the individual pie
15 * fractions.
16 * 
17 * Used for resource utilization visualization.
18 * 
19 * @author brosch
20 * 
21 */
22public class StateSensorToTimeDeltaPieAdapter extends StateSensorToPieAdapter {
23 
24        /**
25         * Initializes the adapter with the given StateSensor measurements.
26         * 
27         * @param samInformation
28         *            Information about the StateSensor and the measurements
29         */
30        public StateSensorToTimeDeltaPieAdapter(
31                        final SensorAndMeasurements samInformation) {
32                super(samInformation);
33        }
34 
35        /*
36         * (non-Javadoc)
37         * @see de.uka.ipd.sdq.sensorframework.adapter.StateSensorToPieAdapter#calculateFractions(java.util.HashMap)
38         */
39        protected double calculateFractions(final HashMap<String, Double> fractions) {
40                for (State state : ((StateSensor) samInformation.getSensor())
41                                .getSensorStates()) {
42                        fractions.put(state.getStateLiteral(), 0.0);
43                }
44                double lastChangeTime = 0.0;
45                State lastState = ((StateSensor) samInformation.getSensor())
46                                .getInitialState();
47                double sum = 0;
48                for (Measurement m : samInformation.getMeasurements()) {
49                        StateMeasurement sm = (StateMeasurement) m;
50                        double oldValue = fractions.get(lastState.getStateLiteral());
51                        double diff = sm.getEventTime() - lastChangeTime;
52                        double newValue = oldValue + diff;
53                        sum += diff;
54                        fractions.put(lastState.getStateLiteral(), newValue);
55                        lastChangeTime = sm.getEventTime();
56                        lastState = sm.getSensorState();
57                }
58                return sum;
59        }
60 
61        /*
62         * (non-Javadoc)
63         * @see de.uka.ipd.sdq.sensorframework.adapter.StateSensorToPieAdapter#instantiatePie(java.lang.String)
64         */
65        protected AbstractPie instantiatePie(String sensorName) {
66                return new TimeDeltaPie(sensorName);
67        }
68}

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