EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.reliability.solver.sensitivity]

COVERAGE SUMMARY FOR SOURCE FILE [FailureTypeSensitivity.java]

nameclass, %method, %block, %line, %
FailureTypeSensitivity.java0%   (0/1)0%   (0/5)0%   (0/186)0%   (0/44)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FailureTypeSensitivity0%   (0/1)0%   (0/5)0%   (0/186)0%   (0/44)
FailureTypeSensitivity (String, List, DoubleParameterVariation): void 0%   (0/1)0%   (0/17)0%   (0/6)
alterModel (): boolean 0%   (0/1)0%   (0/30)0%   (0/6)
extractSensitivityInformation (): void 0%   (0/1)0%   (0/105)0%   (0/23)
getLogHeadingsMulti (): List 0%   (0/1)0%   (0/18)0%   (0/5)
getLogSingleResultsMulti (): List 0%   (0/1)0%   (0/16)0%   (0/4)

1package de.uka.ipd.sdq.reliability.solver.sensitivity;
2 
3import java.util.ArrayList;
4import java.util.List;
5 
6import org.eclipse.emf.common.util.BasicEList;
7import org.eclipse.emf.common.util.EList;
8import org.eclipse.emf.ecore.EObject;
9 
10import de.uka.ipd.sdq.pcm.reliability.InternalFailureOccurrenceDescription;
11import de.uka.ipd.sdq.pcm.reliability.ReliabilityFactory;
12import de.uka.ipd.sdq.pcm.reliability.SoftwareInducedFailureType;
13import de.uka.ipd.sdq.pcm.repository.Repository;
14import de.uka.ipd.sdq.sensitivity.DoubleParameterVariation;
15 
16/**
17 * Provides sensitivity support to alter all software failure-on-demand
18 * probabilities of a given SoftwareInducedFailureType.
19 * 
20 * @author brosch
21 * 
22 */
23public class FailureTypeSensitivity extends MarkovSensitivity {
24 
25        /**
26         * The list of base values of this sensitivity.
27         */
28        private List<Double> baseValues = null;
29 
30        /**
31         * The list of affected internal failure occurrence descriptions.
32         */
33        private List<InternalFailureOccurrenceDescription> descriptions = null;
34 
35        /**
36         * The IDs of the affected software-induced failure type.
37         */
38        private List<String> typeIds = null;
39 
40        /**
41         * The constructor.
42         * 
43         * @param name
44         *            the name of the sensitivity analysis
45         * @param typeIds
46         *            the IDs of the software-induced failure type
47         * @param variation
48         *            the parameter variation
49         */
50        public FailureTypeSensitivity(final String name,
51                        final List<String> typeIds, final DoubleParameterVariation variation) {
52 
53                // Initialize base variables:
54                super(name, variation);
55 
56                // Store further information:
57                this.typeIds = typeIds;
58        }
59 
60        /**
61         * Alters the model according to the next sensitivity analysis step.
62         * 
63         * @return indicates if the model could be successfully altered
64         */
65        protected boolean alterModel() {
66 
67                // Set the failure probability:
68                for (int i = 0; i < descriptions.size(); i++) {
69                        descriptions.get(i).setFailureProbability(
70                                        calculator.calculateCurrentDoubleValue(
71                                                        getDoubleVariation(), getCurrentStepNumber(),
72                                                        baseValues.get(i)));
73                }
74 
75                // Everything ok:
76                return true;
77        }
78 
79        /**
80         * Extracts the relevant sensitivity information from the given model.
81         */
82        protected void extractSensitivityInformation() {
83 
84                // Declare result lists:
85                descriptions = new BasicEList<InternalFailureOccurrenceDescription>();
86                baseValues = new ArrayList<Double>();
87 
88                // Retrieve all InternalActions in the PCM Repository:
89                List<Repository> repositories = getModel().getRepositories();
90                if (repositories.size() == 0) {
91                        // No repository found!
92                        logger.error("No PCM Repositories found.");
93                        return;
94                }
95 
96                // Search for the relevant failure type:
97                for (Repository repository : repositories) {
98                        EList<EObject> failureTypes = helper.getElements(repository,
99                                        ReliabilityFactory.eINSTANCE
100                                                        .createSoftwareInducedFailureType().eClass());
101                        for (EObject object : failureTypes) {
102                                for (String typeId : typeIds) {
103                                        if (((SoftwareInducedFailureType) object).getId().equals(
104                                                        typeId)) {
105                                                for (InternalFailureOccurrenceDescription occurrenceDescription : ((SoftwareInducedFailureType) object)
106                                                                .getInternalFailureOccurrenceDescriptions__SoftwareInducedFailureType()) {
107                                                        descriptions.add(occurrenceDescription);
108                                                        baseValues.add(occurrenceDescription
109                                                                        .getFailureProbability());
110                                                }
111                                                break;
112                                        }
113                                }
114                        }
115                }
116                if (descriptions.size() == 0) {
117                        logger.error("Did not find any FailureOccurrenceDescriptions for "
118                                        + "the specified SoftwareInducedFailureTypes");
119                }
120        }
121 
122        /*
123         * (non-Javadoc)
124         * 
125         * @seede.uka.ipd.sdq.reliability.solver.sensitivity.MarkovSensitivity#
126         * getLogHeadingsMulti()
127         */
128        @Override
129        protected List<List<String>> getLogHeadingsMulti() {
130 
131                // Create a result list:
132                List<List<String>> resultList = new ArrayList<List<String>>();
133 
134                // Create the headings:
135                ArrayList<String> headings = new ArrayList<String>();
136                headings.add("Failure Probability");
137                resultList.add(headings);
138 
139                // Return the result:
140                return resultList;
141        }
142 
143        /*
144         * (non-Javadoc)
145         * 
146         * @seede.uka.ipd.sdq.reliability.solver.sensitivity.MarkovSensitivity#
147         * getLogSingleResultsMulti()
148         */
149        @Override
150        protected List<String> getLogSingleResultsMulti() {
151 
152                // Create a result list:
153                List<String> resultList = new ArrayList<String>();
154 
155                // Create the result strings:
156                resultList.add(calculator.getCurrentLogEntry(getDoubleVariation(),
157                                getCurrentStepNumber()));
158 
159                // Return the result:
160                return resultList;
161        }
162 
163}

[all classes][de.uka.ipd.sdq.reliability.solver.sensitivity]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov