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

COVERAGE SUMMARY FOR SOURCE FILE [StateCalculator.java]

nameclass, %method, %block, %line, %
StateCalculator.java0%   (0/1)0%   (0/3)0%   (0/134)0%   (0/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StateCalculator0%   (0/1)0%   (0/3)0%   (0/134)0%   (0/41)
StateCalculator (ProbeSpecContext, Integer): void 0%   (0/1)0%   (0/5)0%   (0/2)
calculate (ProbeSetSample): Vector 0%   (0/1)0%   (0/74)0%   (0/19)
getConcreteMeasurementMetrics (): Vector 0%   (0/1)0%   (0/55)0%   (0/20)

1package de.uka.ipd.sdq.probespec.framework.calculator;
2 
3import java.util.Vector;
4 
5import javax.measure.Measure;
6import javax.measure.quantity.Dimensionless;
7import javax.measure.quantity.Quantity;
8import javax.measure.unit.SI;
9 
10import de.uka.ipd.sdq.pipesandfilters.framework.CaptureType;
11import de.uka.ipd.sdq.pipesandfilters.framework.MeasurementMetric;
12import de.uka.ipd.sdq.pipesandfilters.framework.Scale;
13import de.uka.ipd.sdq.probespec.framework.ProbeSample;
14import de.uka.ipd.sdq.probespec.framework.ProbeSetSample;
15import de.uka.ipd.sdq.probespec.framework.ProbeSpecContext;
16import de.uka.ipd.sdq.probespec.framework.ProbeType;
17import de.uka.ipd.sdq.probespec.framework.exceptions.CalculatorException;
18import de.uka.ipd.sdq.probespec.framework.matching.IMatchRule;
19import de.uka.ipd.sdq.probespec.framework.matching.ProbeTypeMatchRule;
20 
21/**
22 * This class is a specific Calculator which composes a 2-tuple containing a
23 * time stamp (first tuple element) and the state of a resource (second tuple
24 * element). It needs one ProbeSet containing at least a CURRENT_TIME probe and
25 * an {@link ProbeType#RESOURCE_STATE} probe.
26 * 
27 * @author Faber, Philipp Merkle
28 * 
29 */
30public class StateCalculator extends UnaryCalculator {
31 
32        private static Vector<MeasurementMetric> concreteMeasurementMetrics;
33 
34    /**
35     * Constructor. It takes a reference of the blackboard and the ID of the probe set element taken
36     * from the model.
37     * 
38     * @param ctx
39     *            the {@link ProbeSpecContext}
40     * @param probeSetID
41     *            ID of the probe set element from the model
42     */
43        public StateCalculator(ProbeSpecContext ctx, Integer probeSetID) {
44                super(ctx, probeSetID);
45        }
46 
47        @Override
48        protected Vector<Measure<?, ? extends Quantity>> calculate(
49                        ProbeSetSample sample) throws CalculatorException {
50                // Obtain measuring time
51                IMatchRule[] rules = new IMatchRule[1];
52                rules[0] = new ProbeTypeMatchRule(ProbeType.CURRENT_TIME);
53                Vector<ProbeSample<?, ? extends Quantity>> result = sample
54                                .getProbeSamples(rules);
55                ProbeSample<?, ? extends Quantity> time = null;
56                if (result != null && result.size() > 0)
57                        time = result.get(0);
58 
59                // Obtain measured state
60                rules[0] = new ProbeTypeMatchRule(ProbeType.RESOURCE_STATE);
61                result = sample.getProbeSamples(rules);
62                ProbeSample<?, ? extends Quantity> resourceState = null;
63                if (result != null && result.size() > 0)
64                        resourceState = result.get(0);
65 
66                if (time != null && resourceState != null) {
67                        // Create result tuple
68                        Vector<Measure<?, ? extends Quantity>> resultTuple = new Vector<Measure<?, ? extends Quantity>>();
69                        resultTuple.add(time.getMeasure());
70                        resultTuple.add(resourceState.getMeasure());
71 
72                        return resultTuple;
73                } else {
74                        throw new CalculatorException(
75                                        "Could not access all needed probe samples.");
76                }
77 
78        }
79 
80        /**
81         * Initializes the metric information for the result of this calculator
82         * type. The method is called by the constructor of the super class.
83         */
84        @Override
85        protected synchronized Vector<MeasurementMetric> getConcreteMeasurementMetrics() {
86                if (concreteMeasurementMetrics == null) {
87                        concreteMeasurementMetrics = new Vector<MeasurementMetric>();
88                        MeasurementMetric mm = new MeasurementMetric(
89                                        CaptureType.NATURAL_NUMBER, SI.MILLI(SI.SECOND),
90                                        Scale.ORDINAL);
91                        mm
92                                        .setDescription("This meausre represents the point of time when the value is taken");
93                        mm.setMonotonic(false);
94                        mm.setName("Point of time");
95                        mm.setStrongMonotonic(false);
96                        concreteMeasurementMetrics.add(mm);
97 
98                        mm = new MeasurementMetric(CaptureType.NATURAL_NUMBER,
99                                        Dimensionless.UNIT, Scale.ORDINAL);
100                        mm
101                                        .setDescription("This measure represents the state of the CPU resource");
102                        mm.setMonotonic(false);
103                        mm.setName("State of the CPU resource");
104                        mm.setStrongMonotonic(false);
105                        concreteMeasurementMetrics.add(mm);
106                }
107                return concreteMeasurementMetrics;
108        }
109 
110}

[all classes][de.uka.ipd.sdq.probespec.framework.calculator]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov