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

COVERAGE SUMMARY FOR SOURCE FILE [UtilisationWriteDataStrategy.java]

nameclass, %method, %block, %line, %
UtilisationWriteDataStrategy.java0%   (0/1)0%   (0/3)0%   (0/136)0%   (0/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class UtilisationWriteDataStrategy0%   (0/1)0%   (0/3)0%   (0/136)0%   (0/33)
UtilisationWriteDataStrategy (IDAOFactory, Experiment, ExperimentRun): void 0%   (0/1)0%   (0/11)0%   (0/3)
initialise (MetaDataInit): void 0%   (0/1)0%   (0/46)0%   (0/9)
writeData (PipeData): void 0%   (0/1)0%   (0/79)0%   (0/21)

1package de.uka.ipd.sdq.pipesandfilters.framework.recorder.sensorframework.strategies;
2 
3import java.util.HashMap;
4 
5import javax.measure.Measure;
6import javax.measure.quantity.Dimensionless;
7import javax.measure.quantity.Duration;
8import javax.measure.unit.SI;
9 
10import de.uka.ipd.sdq.pipesandfilters.framework.MetaDataInit;
11import de.uka.ipd.sdq.pipesandfilters.framework.PipeData;
12import de.uka.ipd.sdq.pipesandfilters.framework.recorder.sensorframework.SensorHelper;
13import de.uka.ipd.sdq.sensorframework.entities.Experiment;
14import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun;
15import de.uka.ipd.sdq.sensorframework.entities.Sensor;
16import de.uka.ipd.sdq.sensorframework.entities.State;
17import de.uka.ipd.sdq.sensorframework.entities.StateSensor;
18import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory;
19 
20public class UtilisationWriteDataStrategy extends AbstractWriteDataStrategy {
21 
22        private HashMap<String, State> statesCache = new HashMap<String, State>();
23 
24        private State idleState;
25 
26        private State busyState;
27 
28        public UtilisationWriteDataStrategy(IDAOFactory daoFactory,
29                        Experiment experiment, ExperimentRun run) {
30                super(daoFactory, experiment, run);
31        }        
32 
33        public void initialise(MetaDataInit metaData) {
34                String sensorId = metaData.getMeasurementName();
35                this.idleState = SensorHelper.createOrReuseState(daoFactory, "Idle");
36                this.busyState = SensorHelper.createOrReuseState(daoFactory, "Busy");
37                sensor = SensorHelper.createOrReuseStateSensor(daoFactory, experiment,
38                                sensorId, idleState);
39                if (!((StateSensor) sensor).getSensorStates().contains(idleState)) {
40                        ((StateSensor) sensor).addSensorState(idleState);
41                }
42                ((StateSensor) sensor).addSensorState(busyState);
43        }
44 
45        @SuppressWarnings("unchecked")
46        @Override
47        public void writeData(PipeData data) {
48                Measure<Double, Duration> measurementTimeMeasure = (Measure<Double, Duration>) data
49                                .getTupleElement(0);
50                double measurementTime = measurementTimeMeasure.doubleValue(SI.SECOND);
51                Measure<Integer, Dimensionless> numericStateMeasure = (Measure<Integer, Dimensionless>) data
52                                .getTupleElement(1);
53                int numericState = numericStateMeasure.intValue(Dimensionless.UNIT);
54                State state = null;
55                if (numericState == 0) {
56                        state = idleState;
57                } else {
58                        String stateLiteral = "Busy " + Integer.toString(numericState)
59                                        + " Job(s)";
60                        if (!statesCache.containsKey(stateLiteral)) {
61                                State newState = SensorHelper.createOrReuseState(daoFactory,
62                                                stateLiteral);
63                                statesCache.put(stateLiteral, newState);
64                                if (!((StateSensor) sensor).getSensorStates()
65                                                .contains(newState))
66                                        ((StateSensor) sensor).addSensorState(newState);
67                        }
68                        state = statesCache.get(stateLiteral);
69                }
70                run.addStateMeasurement((StateSensor)sensor, state, measurementTime);
71        }
72 
73}

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