1 | package de.uka.ipd.sdq.probespec.framework.probes.example; |
2 | |
3 | import javax.measure.Measure; |
4 | import javax.measure.quantity.Dimensionless; |
5 | |
6 | import de.uka.ipd.sdq.probespec.framework.ProbeSample; |
7 | import de.uka.ipd.sdq.probespec.framework.ProbeType; |
8 | import de.uka.ipd.sdq.probespec.framework.probes.IProbeStrategy; |
9 | |
10 | public class ExampleTakeStoExStrategy implements IProbeStrategy { |
11 | |
12 | /** |
13 | * @param o |
14 | * expects a {@link SimpleStoEx} |
15 | */ |
16 | @Override |
17 | public ProbeSample<Double, Dimensionless> takeSample(String probeId, |
18 | Object... o) { |
19 | SimpleStoEx ex = null; |
20 | if (o[0] instanceof SimpleStoEx) { |
21 | ex = (SimpleStoEx) o[0]; |
22 | } else { |
23 | throw new IllegalArgumentException("Expected an argument of type " |
24 | + SimpleStoEx.class.getSimpleName() + "."); |
25 | } |
26 | |
27 | Measure<Double, Dimensionless> evalEx = Measure.valueOf(ex |
28 | .evaluateExpression(), Dimensionless.UNIT); |
29 | ProbeSample<Double, Dimensionless> sample = new ProbeSample<Double, Dimensionless>( |
30 | evalEx, probeId, ProbeType.STOEX); |
31 | |
32 | return sample; |
33 | } |
34 | |
35 | } |