1 | package de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.reports; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.Collection; |
5 | import java.util.Iterator; |
6 | |
7 | import de.uka.ipd.sdq.sensorframework.entities.SensorAndMeasurements; |
8 | import de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.reportitems.IReportItem; |
9 | import de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.reportitems.RCommandRReportItem; |
10 | import de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.reportitems.StaticTextReportItem; |
11 | import de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.utils.RConnection; |
12 | import de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.utils.REngineHelper; |
13 | |
14 | /**Report that displays the total resource demands for sensors. |
15 | * @author groenda |
16 | */ |
17 | public class DemandTimeReport extends RReport { |
18 | |
19 | /**Creates a list of summed up resource demands for each registered sensor. |
20 | * @param c The measurements to sum up. |
21 | * @param t The connection to the R-Engine. |
22 | * @return List of items with statistical information. |
23 | */ |
24 | @Override |
25 | public ArrayList<IReportItem> prepareReportItems( |
26 | final Collection<SensorAndMeasurements> c, final RConnection t) { |
27 | ArrayList<IReportItem> items = new ArrayList<IReportItem>(); |
28 | items.add(new StaticTextReportItem( |
29 | "R-Report about total resource demands", true)); |
30 | |
31 | Iterator<SensorAndMeasurements> it = c.iterator(); |
32 | for (int i = 0; i < c.size(); i++) { |
33 | SensorAndMeasurements sm = it.next(); |
34 | |
35 | String sensorName = REngineHelper.storeMeasurementsInRVector(sm, i, |
36 | TimeseriesData.TIMESPAN, t); |
37 | |
38 | String rCommand = "sum(" + sensorName + ")\n"; |
39 | items.add(new RCommandRReportItem(rCommand, |
40 | "Resource demand of " + sm.getSensor().getSensorName())); |
41 | } |
42 | return items; |
43 | } |
44 | } |