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

COVERAGE SUMMARY FOR SOURCE FILE [ExperimentManager.java]

nameclass, %method, %block, %line, %
ExperimentManager.java0%   (0/1)0%   (0/8)0%   (0/210)0%   (0/43)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExperimentManager0%   (0/1)0%   (0/8)0%   (0/210)0%   (0/43)
ExperimentManager (String, IDAOFactory): void 0%   (0/1)0%   (0/31)0%   (0/6)
close (): void 0%   (0/1)0%   (0/4)0%   (0/2)
finalizeAndClose (): void 0%   (0/1)0%   (0/4)0%   (0/2)
getExperiment (String): Experiment 0%   (0/1)0%   (0/20)0%   (0/5)
getTimeSpanSensor (String): TimeSpanSensor 0%   (0/1)0%   (0/45)0%   (0/10)
storeTimeSpan (String, long, long): void 0%   (0/1)0%   (0/55)0%   (0/8)
storeTimeSpans (String, List): void 0%   (0/1)0%   (0/28)0%   (0/6)
storeTimeSpans (String, double [], double [], int): void 0%   (0/1)0%   (0/23)0%   (0/4)

1package de.uka.ipd.sdq.sensorframework.util;
2 
3import java.util.Collection;
4import java.util.Date;
5import java.util.Hashtable;
6import java.util.List;
7 
8import de.uka.ipd.sdq.sensorframework.entities.Experiment;
9import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun;
10import de.uka.ipd.sdq.sensorframework.entities.Sensor;
11import de.uka.ipd.sdq.sensorframework.entities.TimeSpanSensor;
12import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory;
13import de.uka.ipd.sdq.sensorframework.entities.dao.IExperimentDAO;
14 
15/**
16 * TODO this class has no documentation at all!
17 * It is not used by any other class, so there is no need for it, unless it is a "hidden" test class.
18 * 
19 * @author Jens Happe
20 * @author Steffen Becker
21 * 
22 *
23 */
24public class ExperimentManager {
25 
26        public final static double SCALING_FACTOR = 1000000;
27 
28        private Hashtable<String, TimeSpanSensor> timeSpanSensorHash = new Hashtable<String, TimeSpanSensor>();
29        
30        private Experiment experiment;
31        
32        private ExperimentRun run;
33        
34        private IDAOFactory factory;
35        
36        public ExperimentManager(String experimentName, IDAOFactory factory){
37                this.factory = factory;
38                this.experiment = getExperiment(experimentName);
39                run = experiment.addExperimentRun("Run "+new Date().toString());
40        }
41        
42        private Experiment getExperiment(String experimentName) {
43                IExperimentDAO expDAO = factory.createExperimentDAO();
44                Collection<Experiment> experimentColl = expDAO.findByExperimentName(experimentName);
45                if (experimentColl.size() > 0){
46                        return experimentColl.iterator().next();
47                } else {
48                        return expDAO.addExperiment(experimentName);
49                }
50        }
51 
52        public void storeTimeSpan(String sensorName, long startTime, long stopTime){
53                double time = (stopTime - startTime) / SCALING_FACTOR;
54                if (sensorName.equals("ServiceTime") && time < 0.5){
55                        System.out.println("Time: "+time);
56                        System.out.println("startTime: "+startTime);
57                        System.out.println("stopTime: "+stopTime);
58                }
59                TimeSpanSensor sensor = getTimeSpanSensor(sensorName);
60                run.addTimeSpanMeasurement(sensor, startTime, time);
61        }
62        
63        public void storeTimeSpans(String sensorName, double[] durationArray, double[] timeArray, int upperBound) {
64                TimeSpanSensor sensor = getTimeSpanSensor(sensorName);
65                for (int i=0; i<upperBound; i++){
66                        run.addTimeSpanMeasurement(sensor, timeArray[i], durationArray[i]);
67                }
68        }        
69        
70        public void storeTimeSpans(String sensorName, List<Double> elements) {
71                TimeSpanSensor sensor = getTimeSpanSensor(sensorName);
72                int i=0;
73                for (Double d: elements){
74                        run.addTimeSpanMeasurement(sensor, i, d);
75                        i++;
76                }
77        }        
78 
79        public void close(){
80                factory.finalizeAndClose();
81        }
82        
83        
84        private TimeSpanSensor getTimeSpanSensor(String name) {
85                TimeSpanSensor result = timeSpanSensorHash.get(name);
86                if (result == null){
87                        for (Sensor sensor : experiment.getSensors()) {
88                                if ( sensor.getSensorName().equals(name) ) {
89                                        result = (TimeSpanSensor) sensor;
90                                        break;
91                                }
92                        }
93                        if (result == null){
94                                result = experiment.addTimeSpanSensor(name);
95                        }
96                        timeSpanSensorHash.put(name, result);
97                }
98                return result;
99        }
100        
101        public void finalizeAndClose() {
102                factory.finalizeAndClose();
103        }
104 
105}

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