1 | package de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.List; |
5 | |
6 | import org.eclipse.core.runtime.CoreException; |
7 | |
8 | import de.uka.ipd.sdq.codegen.simucontroller.debug.IDebugListener; |
9 | import de.uka.ipd.sdq.codegen.simucontroller.runconfig.SimuComWorkflowConfiguration; |
10 | import de.uka.ipd.sdq.workflow.IBlackboardInteractingJob; |
11 | import de.uka.ipd.sdq.workflow.LowMemoryFootprintCompositeJob; |
12 | import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard; |
13 | import de.uka.ipd.sdq.workflow.pcm.runconfig.SensitivityAnalysisConfiguration; |
14 | |
15 | public class SensitivityAnalysisJob |
16 | extends LowMemoryFootprintCompositeJob<MDSDBlackboard> |
17 | implements IBlackboardInteractingJob<MDSDBlackboard> { |
18 | |
19 | boolean isFinished = false; |
20 | |
21 | public SensitivityAnalysisJob(SimuComWorkflowConfiguration config, |
22 | IDebugListener listener) throws CoreException { |
23 | |
24 | if (config.isSensitivityAnalysisEnabled()) { |
25 | List<SensitivityAnalysisConfiguration> sconfList = config.getSensitivityAnalysisConfigurations(); |
26 | config = config.copy(sconfList); |
27 | |
28 | while (!isFinished){ |
29 | this.add(new SimuComJob(config, listener)); |
30 | sconfList = getNextSConfigList(sconfList); |
31 | config = config.copy(sconfList); |
32 | } |
33 | } else { |
34 | this.add(new SimuComJob(config, listener)); |
35 | } |
36 | |
37 | } |
38 | |
39 | private List<SensitivityAnalysisConfiguration> getNextSConfigList( |
40 | List<SensitivityAnalysisConfiguration> sconfList) { |
41 | List<SensitivityAnalysisConfiguration> resultList = new ArrayList<SensitivityAnalysisConfiguration>(); |
42 | boolean increased = false; |
43 | for (SensitivityAnalysisConfiguration sconf : sconfList){ |
44 | if(!increased){ |
45 | if(sconf.getCurrent() < sconf.getMax()){ |
46 | increased = true; |
47 | sconf = sconf.getNext(); |
48 | } else { |
49 | sconf = sconf.getFirst(); |
50 | } |
51 | } |
52 | resultList.add(sconf); |
53 | } |
54 | isFinished = !increased; |
55 | |
56 | return resultList; |
57 | } |
58 | } |