1 | package de.uka.ipd.sdq.sensorframework.adapter; |
2 | |
3 | import de.uka.ipd.sdq.codegen.simudatavisualisation.datatypes.TimeSeries; |
4 | import de.uka.ipd.sdq.sensorframework.entities.Measurement; |
5 | import de.uka.ipd.sdq.sensorframework.entities.SensorAndMeasurements; |
6 | import de.uka.ipd.sdq.sensorframework.entities.TimeSpanMeasurement; |
7 | |
8 | /**Adapter for TimeSpanSensor to TimeSeries. |
9 | * @author groenda |
10 | */ |
11 | public class TimeSpanToTimeSeriesAdapter extends DataAdapter { |
12 | |
13 | // private FilteredMeasurementsCollection measurements; |
14 | // private static final String ACTIVEDE_FILTERS = "ACTIVEDE_FILTERS"; |
15 | /** Information about the TimeSpanSensor and the measurements. */ |
16 | private SensorAndMeasurements samInformation; |
17 | |
18 | /** Initializes the adapter with the provided TimeSpanSensor. |
19 | * @param samInformation Information about the TimeSpanSensor |
20 | * and the measurements. |
21 | */ |
22 | public TimeSpanToTimeSeriesAdapter( |
23 | final SensorAndMeasurements samInformation) { |
24 | super(); |
25 | this.samInformation = samInformation; |
26 | } |
27 | |
28 | /** {@inheritDoc} |
29 | */ |
30 | public Object getAdaptedObject() { |
31 | TimeSeries series = |
32 | new TimeSeries(samInformation.getSensor().getSensorName()); |
33 | for (Measurement m : samInformation.getMeasurements()) { |
34 | series.add(m.getMeasurementID(), ((TimeSpanMeasurement) m) |
35 | .getTimeSpan()); |
36 | } |
37 | return series; |
38 | } |
39 | } |