1 | package de.uka.ipd.sdq.pipesandfilters.framework.recorder.sensorframework.strategies; |
2 | |
3 | import javax.measure.Measure; |
4 | import javax.measure.quantity.Duration; |
5 | import javax.measure.unit.SI; |
6 | |
7 | import de.uka.ipd.sdq.pipesandfilters.framework.PipeData; |
8 | import de.uka.ipd.sdq.sensorframework.entities.Experiment; |
9 | import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun; |
10 | import de.uka.ipd.sdq.sensorframework.entities.TimeSpanSensor; |
11 | import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory; |
12 | |
13 | public class DemandedTimeWriteDataStrategy extends AbstractWriteDataStrategy { |
14 | |
15 | public DemandedTimeWriteDataStrategy(IDAOFactory daoFactory, |
16 | Experiment experiment, ExperimentRun run) { |
17 | super(daoFactory, experiment, run); |
18 | } |
19 | |
20 | @SuppressWarnings("unchecked") |
21 | @Override |
22 | public void writeData(PipeData data) { |
23 | Measure<Double, Duration> measurementTimeMeasure = (Measure<Double, Duration>) data |
24 | .getTupleElement(0); |
25 | Measure<Double, Duration> demandedTimeMeasure = (Measure<Double, Duration>) data |
26 | .getTupleElement(1); |
27 | double measurementTime = measurementTimeMeasure.doubleValue(SI.SECOND); |
28 | double demandedTime = demandedTimeMeasure.doubleValue(SI.SECOND); |
29 | run.addTimeSpanMeasurement((TimeSpanSensor)sensor, measurementTime, demandedTime); |
30 | } |
31 | |
32 | } |