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 [ResourceMTTFSensitivity.java]

nameclass, %method, %block, %line, %
ResourceMTTFSensitivity.java0%   (0/1)0%   (0/5)0%   (0/206)0%   (0/58)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResourceMTTFSensitivity0%   (0/1)0%   (0/5)0%   (0/206)0%   (0/58)
ResourceMTTFSensitivity (String, String, String, DoubleParameterVariation): void 0%   (0/1)0%   (0/14)0%   (0/5)
alterModel (): boolean 0%   (0/1)0%   (0/19)0%   (0/5)
extractSensitivityInformation (): void 0%   (0/1)0%   (0/99)0%   (0/27)
getLogHeadingsMulti (): List 0%   (0/1)0%   (0/34)0%   (0/9)
getLogSingleResultsMulti (): List 0%   (0/1)0%   (0/40)0%   (0/12)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.reliability.solver.sensitivity;
5 
6import java.util.ArrayList;
7import java.util.List;
8 
9import org.eclipse.emf.common.util.EList;
10import org.eclipse.emf.ecore.EObject;
11 
12import de.uka.ipd.sdq.pcm.resourceenvironment.ProcessingResourceSpecification;
13import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer;
14import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentFactory;
15import de.uka.ipd.sdq.sensitivity.DoubleParameterVariation;
16 
17/**
18 * This class provides rudimentary support for sensitivity analysis of a
19 * hardware resource MTTF value.
20 * 
21 * Further refactorings required.
22 * 
23 * @author brosch
24 * 
25 */
26public class ResourceMTTFSensitivity extends MarkovSensitivity {
27 
28        /**
29         * The base value.
30         */
31        private double baseValue;
32 
33        /**
34         * The resource type to alter.
35         */
36        private String processingResourceTypeId;
37 
38        /**
39         * The resource container to alter.
40         */
41        private String resourceContainerId;
42 
43        /**
44         * The affected processing resource specification.
45         */
46        private ProcessingResourceSpecification specification = null;
47 
48        /**
49         * The constructor.
50         * 
51         * @param name
52         *            the name of the sensitivity analysis
53         * @param resourceContainerId
54         *            the resource container to alter
55         * @param processingResourceTypeId
56         *            the resource type to alter
57         * @param variation
58         *            the parameter variation
59         */
60        public ResourceMTTFSensitivity(final String name,
61                        final String resourceContainerId,
62                        final String processingResourceTypeId,
63                        final DoubleParameterVariation variation) {
64 
65                // Initialize basic variables:
66                super(name, variation);
67 
68                // Further initializations:
69                this.resourceContainerId = resourceContainerId;
70                this.processingResourceTypeId = processingResourceTypeId;
71        }
72 
73        /**
74         * Alters the model according to the next sensitivity analysis step.
75         * 
76         * @return indicates if the model could be successfully altered
77         */
78        protected boolean alterModel() {
79 
80                // Check validity:
81                if (specification == null) {
82                        return false;
83                }
84 
85                // Set the failure probability:
86                specification.setMTTF(calculator.calculateCurrentDoubleValue(
87                                getDoubleVariation(), getCurrentStepNumber(), baseValue));
88 
89                // Everything ok:
90                return true;
91        }
92 
93        /**
94         * Extracts the relevant sensitivity information from the given model.
95         */
96        protected void extractSensitivityInformation() {
97 
98                // Retrieve the PCM resource environment:
99                if (getModel().getResourceEnvironment() == null) {
100                        // No resource environment found!
101                        logger.error("No PCM ResourceEnvironment found.");
102                        return;
103                }
104 
105                // Search for the relevant resource container:
106                ResourceContainer resourceContainer = null;
107                EList<EObject> resourceContainers = helper.getElements(getModel()
108                                .getResourceEnvironment(), ResourceenvironmentFactory.eINSTANCE
109                                .createResourceContainer().eClass());
110                for (EObject object : resourceContainers) {
111                        if (((ResourceContainer) object).getId()
112                                        .equals(resourceContainerId)) {
113                                resourceContainer = (ResourceContainer) object;
114                                break;
115                        }
116                }
117                if (resourceContainer == null) {
118                        // No corresponding resource container found!
119                        logger.error("Did not find any ResourceContainer with ID \""
120                                        + resourceContainerId + "\"");
121                        return;
122                }
123 
124                // Search for the relevant processing resource specification:
125                for (ProcessingResourceSpecification resourceSpecification : resourceContainer
126                                .getActiveResourceSpecifications_ResourceContainer()) {
127                        if (resourceSpecification
128                                        .getActiveResourceType_ActiveResourceSpecification()
129                                        .getId().equals(processingResourceTypeId)) {
130                                specification = resourceSpecification;
131                                return;
132                        }
133                }
134                if(specification == null){
135                        logger.error("Did not find any ProcessingResourceSpecification with ID \""
136                                        + processingResourceTypeId + "\"");
137                }
138        }
139 
140        /**
141         * Builds the headings strings for logging.
142         * 
143         * @return the log headings strings
144         */
145        protected List<List<String>> getLogHeadingsMulti() {
146 
147                // Create a result list:
148                List<List<String>> resultList = new ArrayList<List<String>>();
149 
150                // Create the headings:
151                ArrayList<String> headings = new ArrayList<String>();
152                headings.add("Resource Container Name");
153                headings.add("Resource Container ID");
154                headings.add("Resource Type Name");
155                headings.add("Resourcce Type ID");
156                headings.add("Mean Time To Failure");
157                resultList.add(headings);
158 
159                // Return the result:
160                return resultList;
161        }
162 
163        /**
164         * Builds the results strings for sensitivity logging.
165         * 
166         * @return the results strings
167         */
168        protected List<String> getLogSingleResultsMulti() {
169 
170                // Create a result list:
171                List<String> resultList = new ArrayList<String>();
172 
173                // Create the result strings:
174                resultList.add(specification
175                                .getResourceContainer_ProcessingResourceSpecification()
176                                .getEntityName());
177                resultList.add(resourceContainerId);
178                resultList.add(specification
179                                .getActiveResourceType_ActiveResourceSpecification()
180                                .getEntityName());
181                resultList.add(processingResourceTypeId);
182                resultList.add(calculator.getCurrentLogEntry(getDoubleVariation(),
183                                getCurrentStepNumber()));
184 
185                // Return the result:
186                return resultList;
187        }
188}

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