| 1 | package de.uka.ipd.sdq.simucomframework.probes; |
| 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 | /** |
| 11 | * ProbeStrategy which is able to measure the type of an execution result. |
| 12 | * |
| 13 | * The execution result type is identified through its numeric ID. |
| 14 | * |
| 15 | * @author brosch |
| 16 | * |
| 17 | */ |
| 18 | public class TakeExecutionResultStrategy implements IProbeStrategy { |
| 19 | |
| 20 | /* |
| 21 | * (non-Javadoc) |
| 22 | * |
| 23 | * @see |
| 24 | * de.uka.ipd.sdq.probespec.framework.probes.IProbeStrategy#takeSample(java |
| 25 | * .lang.String, java.lang.Object[]) |
| 26 | */ |
| 27 | public ProbeSample<Integer, Dimensionless> takeSample(String probeId, |
| 28 | Object... o) { |
| 29 | Integer stateId = null; |
| 30 | if (o.length >= 1 && o[0] instanceof Integer) { |
| 31 | stateId = (Integer) o[0]; |
| 32 | } else { |
| 33 | throw new IllegalArgumentException("Expected an argument of type " |
| 34 | + Integer.class.getSimpleName() + "."); |
| 35 | } |
| 36 | Measure<Integer, Dimensionless> stateMeasure = Measure.valueOf(stateId, |
| 37 | Dimensionless.UNIT); |
| 38 | ProbeSample<Integer, Dimensionless> sample = new ProbeSample<Integer, Dimensionless>( |
| 39 | stateMeasure, probeId, ProbeType.EXECUTION_RESULT); |
| 40 | return sample; |
| 41 | } |
| 42 | } |