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 ExampleTakePassiveResourceState implements IProbeStrategy { |
11 | |
12 | /** |
13 | * @param o |
14 | * expects a {@link ASimpleActiveResource} |
15 | */ |
16 | @Override |
17 | public ProbeSample<Integer, Dimensionless> takeSample(String probeId, |
18 | Object... o) { |
19 | ASimplePassiveResource res = null; |
20 | if (o[0] instanceof ASimplePassiveResource) { |
21 | res = (ASimplePassiveResource) o[0]; |
22 | } else { |
23 | throw new IllegalArgumentException("Expected an argument of type " |
24 | + ASimplePassiveResource.class.getSimpleName() + "."); |
25 | } |
26 | |
27 | Measure<Integer, Dimensionless> free = Measure.valueOf(res.getFree(), |
28 | Dimensionless.UNIT); |
29 | ProbeSample<Integer, Dimensionless> sample = new ProbeSample<Integer, Dimensionless>( |
30 | free, probeId, ProbeType.RESOURCE_STATE); |
31 | |
32 | return sample; |
33 | } |
34 | |
35 | } |