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

COVERAGE SUMMARY FOR SOURCE FILE [GuardedBranchTransitionHandler.java]

nameclass, %method, %block, %line, %
GuardedBranchTransitionHandler.java0%   (0/1)0%   (0/5)0%   (0/87)0%   (0/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GuardedBranchTransitionHandler0%   (0/1)0%   (0/5)0%   (0/87)0%   (0/23)
<static initializer> 0%   (0/1)0%   (0/5)0%   (0/2)
GuardedBranchTransitionHandler (SeffVisitor): void 0%   (0/1)0%   (0/4)0%   (0/2)
adjustToScope (double): double 0%   (0/1)0%   (0/2)0%   (0/1)
getBranchProbFromExpression (GuardedBranchTransition): double 0%   (0/1)0%   (0/51)0%   (0/12)
handle (GuardedBranchTransition): void 0%   (0/1)0%   (0/25)0%   (0/6)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.pcmsolver.handler;
5 
6import java.util.List;
7 
8import org.apache.log4j.Logger;
9 
10import de.uka.ipd.sdq.pcm.seff.GuardedBranchTransition;
11import de.uka.ipd.sdq.pcmsolver.visitors.ExpressionHelper;
12import de.uka.ipd.sdq.pcmsolver.visitors.SeffVisitor;
13import de.uka.ipd.sdq.probfunction.ProbabilityMassFunction;
14import de.uka.ipd.sdq.probfunction.Sample;
15import de.uka.ipd.sdq.stoex.Expression;
16import de.uka.ipd.sdq.stoex.ProbabilityFunctionLiteral;
17 
18/**
19 * @author Koziolek
20 * 
21 */
22public class GuardedBranchTransitionHandler extends AbstractBranchTransitionHandler{
23 
24        private static Logger logger = Logger.getLogger(GuardedBranchTransitionHandler.class.getName());
25 
26        /**
27         * @param context
28         * @param _visitor
29         * @param nextHandler
30         */
31        public GuardedBranchTransitionHandler(SeffVisitor seffVisitor) {
32                super(seffVisitor);
33        }
34 
35        public void handle(GuardedBranchTransition bt){
36                double solvedBranchProb = getBranchProbFromExpression(bt);
37                logger.debug("SolvedBranchProb:" + solvedBranchProb);
38                
39                storeToUsageContext(bt, solvedBranchProb);
40 
41                // Don't solve branch transitions that can never be reached. This
42                // releases the modeler from the duty to provide all character
43                // parameterizations for branches that are never reached (see Bug 615)
44                if (solvedBranchProb > 0.0) {
45                        visitChildBehaviour(bt);
46                }
47                
48// TODO: recognise scopes
49//                int lastElement = visitor.getContextWrapper().getCurrentEvaluatedBranchConditions().size()-1;
50//                visitor.getContextWrapper().getCurrentEvaluatedBranchConditions().remove(lastElement);
51        }
52        
53        /**
54         * @param bt
55         * @param solvedBranchProb
56         * @return
57         */
58        private double getBranchProbFromExpression(GuardedBranchTransition bt) {
59                String specification = bt.getBranchCondition_GuardedBranchTransition().getSpecification(); 
60                Expression solvedExpression = ExpressionHelper.getSolvedExpression(specification,visitor.getContextWrapper());
61 
62                ProbabilityFunctionLiteral pfl = (ProbabilityFunctionLiteral)solvedExpression;
63                ProbabilityMassFunction pmf = (ProbabilityMassFunction)pfl.getFunction_ProbabilityFunctionLiteral();
64 
65                double solvedBranchProb = 1.0;
66                List<Sample> points = pmf.getSamples();
67                for (Sample point : points) {
68                        String bool = point.getValue().toString();
69                        if (bool.toLowerCase().equals("true")) {
70                                solvedBranchProb = point.getProbability();
71                        }
72                }
73 
74                // integrate already evaluated branch conditions
75                solvedBranchProb = adjustToScope(solvedBranchProb);
76 
77//                visitor.getContextWrapper().getCurrentEvaluatedBranchConditions().add(solvedBranchProb);
78                return solvedBranchProb;
79        }
80 
81        /**
82         * Include already evaluated branch conditions.
83         * 
84         * @param solvedBranchProb
85         * @return
86         */
87        private double adjustToScope(double solvedBranchProb) {
88                //TODO
89//                ArrayList list = myContext.getCurrentEvaluatedBranchConditions(); 
90//                for (Object o : list) solvedBranchProb /= (Double)o;
91                return solvedBranchProb;
92        }
93 
94}

[all classes][de.uka.ipd.sdq.pcmsolver.handler]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov