1 | package de.uka.ipd.sdq.simucomframework.sensors; |
2 | |
3 | import java.util.Collection; |
4 | import java.util.Observable; |
5 | |
6 | import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun; |
7 | import de.uka.ipd.sdq.sensorframework.entities.Measurement; |
8 | import de.uka.ipd.sdq.sensorframework.entities.ScalabilityMeasurement; |
9 | import de.uka.ipd.sdq.sensorframework.entities.ScalabilitySensor; |
10 | import de.uka.ipd.sdq.sensorframework.entities.Sensor; |
11 | import de.uka.ipd.sdq.sensorframework.entities.SensorAndMeasurements; |
12 | import de.uka.ipd.sdq.sensorframework.entities.State; |
13 | import de.uka.ipd.sdq.sensorframework.entities.StateMeasurement; |
14 | import de.uka.ipd.sdq.sensorframework.entities.StateSensor; |
15 | import de.uka.ipd.sdq.sensorframework.entities.TimeSpanMeasurement; |
16 | import de.uka.ipd.sdq.sensorframework.entities.TimeSpanSensor; |
17 | import de.uka.ipd.sdq.simucomframework.model.SimuComModel; |
18 | |
19 | @Deprecated |
20 | public class SimuComExperimentRunDecorator extends Observable implements |
21 | ExperimentRun { |
22 | |
23 | private ExperimentRun decoratedRun = null; |
24 | private SimuComModel model; |
25 | |
26 | public SimuComExperimentRunDecorator(SimuComModel simuComModel, |
27 | ExperimentRun experimentRun) { |
28 | this.model = simuComModel; |
29 | this.decoratedRun = experimentRun; |
30 | } |
31 | |
32 | public void addMeasurement(Measurement arg0) { |
33 | if (model.getSimulationControl().isRunning()) { |
34 | setChanged(); |
35 | notifyObservers(arg0); |
36 | decoratedRun.addMeasurement(arg0); |
37 | } |
38 | } |
39 | |
40 | public StateMeasurement addStateMeasurement(StateSensor arg0, State arg1, |
41 | double arg2) { |
42 | // Hauck: |
43 | // Changed behaviour here in order to allow adding states after |
44 | // simulation has stopped. This is necessary for the OverallUtlilisationSensor |
45 | |
46 | //if (model.getSimulationControl().isRunning()) { |
47 | StateMeasurement measurement = decoratedRun.addStateMeasurement( |
48 | arg0, arg1, arg2); |
49 | setChanged(); |
50 | notifyObservers(measurement); |
51 | return measurement; |
52 | //} else |
53 | //return null; |
54 | } |
55 | |
56 | public TimeSpanMeasurement addTimeSpanMeasurement(TimeSpanSensor arg0, |
57 | double arg1, double arg2) { |
58 | if (model.getSimulationControl().isRunning()) { |
59 | TimeSpanMeasurement measurement = decoratedRun |
60 | .addTimeSpanMeasurement(arg0, arg1, arg2); |
61 | setChanged(); |
62 | notifyObservers(new DecoratorTimeSpanMeasurement(arg0, arg1, arg2)); |
63 | return measurement; |
64 | } else |
65 | return null; |
66 | } |
67 | |
68 | public StateMeasurement addStateMeasurementAfterRun(StateSensor arg0, |
69 | State arg1, double arg2) { |
70 | StateMeasurement measurement = decoratedRun.addStateMeasurement(arg0, |
71 | arg1, arg2); |
72 | setChanged(); |
73 | notifyObservers(measurement); |
74 | return measurement; |
75 | } |
76 | |
77 | public TimeSpanMeasurement addTimeSpanMeasurementAfterRun( |
78 | TimeSpanSensor sensor, double eventtime, double timespan) { |
79 | TimeSpanMeasurement measurement = decoratedRun.addTimeSpanMeasurement( |
80 | sensor, eventtime, timespan); |
81 | setChanged(); |
82 | notifyObservers(new DecoratorTimeSpanMeasurement(sensor, eventtime, timespan)); |
83 | return measurement; |
84 | } |
85 | |
86 | public ScalabilityMeasurement addScalabilityMeasurement( |
87 | ScalabilitySensor arg0, Double[] arg1, double arg2) { |
88 | if (model.getSimulationControl().isRunning()) { |
89 | ScalabilityMeasurement measurement = decoratedRun |
90 | .addScalabilityMeasurement(arg0, arg1, arg2); |
91 | setChanged(); |
92 | notifyObservers(measurement); |
93 | return measurement; |
94 | } else |
95 | return null; |
96 | } |
97 | |
98 | public String getExperimentDateTime() { |
99 | return decoratedRun.getExperimentDateTime(); |
100 | } |
101 | |
102 | public long getExperimentRunID() { |
103 | return decoratedRun.getExperimentRunID(); |
104 | } |
105 | |
106 | public Collection<Measurement> getMeasurements() { |
107 | return decoratedRun.getMeasurements(); |
108 | } |
109 | |
110 | public SensorAndMeasurements getMeasurementsOfSensor(Sensor arg0) { |
111 | return decoratedRun.getMeasurementsOfSensor(arg0); |
112 | } |
113 | |
114 | public void setExperimentDateTime(String arg0) { |
115 | decoratedRun.setExperimentDateTime(arg0); |
116 | } |
117 | |
118 | public void setExperimentRunID(long arg0) { |
119 | decoratedRun.setExperimentRunID(arg0); |
120 | } |
121 | |
122 | public class DecoratorMeasurement { |
123 | |
124 | protected double eventTime; |
125 | |
126 | protected Sensor sensor; |
127 | |
128 | public DecoratorMeasurement(Sensor sensor, double eventTime) { |
129 | this.eventTime = eventTime; |
130 | this.sensor = sensor; |
131 | } |
132 | |
133 | public double getEventTime() { |
134 | return eventTime; |
135 | } |
136 | |
137 | public void setEventTime(double eventTime) { |
138 | this.eventTime = eventTime; |
139 | } |
140 | |
141 | public Sensor getSensor() { |
142 | return sensor; |
143 | } |
144 | |
145 | public void setSensor(Sensor sensor) { |
146 | this.sensor = sensor; |
147 | } |
148 | |
149 | } |
150 | |
151 | public class DecoratorTimeSpanMeasurement extends DecoratorMeasurement { |
152 | |
153 | private double timeSpan; |
154 | |
155 | public DecoratorTimeSpanMeasurement(Sensor sensor, double eventTime, |
156 | double timeSpan) { |
157 | super(sensor, eventTime); |
158 | this.timeSpan = timeSpan; |
159 | } |
160 | |
161 | public double getTimeSpan() { |
162 | return timeSpan; |
163 | } |
164 | |
165 | public void setTimeSpan(double timeSpan) { |
166 | this.timeSpan = timeSpan; |
167 | } |
168 | |
169 | } |
170 | |
171 | } |