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

COVERAGE SUMMARY FOR SOURCE FILE [HptSensor.java]

nameclass, %method, %block, %line, %
HptSensor.java0%   (0/1)0%   (0/6)0%   (0/129)0%   (0/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HptSensor0%   (0/1)0%   (0/6)0%   (0/129)0%   (0/38)
HptSensor (SchedulerModel, IActiveProcess, double): void 0%   (0/1)0%   (0/22)0%   (0/8)
getHpt (): double 0%   (0/1)0%   (0/3)0%   (0/1)
getHptStart (): double 0%   (0/1)0%   (0/3)0%   (0/1)
start (): void 0%   (0/1)0%   (0/17)0%   (0/5)
stop (): void 0%   (0/1)0%   (0/30)0%   (0/8)
update (PROCESS_STATE): void 0%   (0/1)0%   (0/54)0%   (0/15)

1package de.uka.ipd.sdq.scheduler.sensors.impl;
2 
3import de.uka.ipd.sdq.scheduler.SchedulerModel;
4import de.uka.ipd.sdq.scheduler.processes.IActiveProcess;
5import de.uka.ipd.sdq.scheduler.processes.PROCESS_STATE;
6import de.uka.ipd.sdq.scheduler.sensors.IProcessStateSensor;
7 
8public class HptSensor implements IProcessStateSensor {
9 
10    private SchedulerModel model; 
11        private PROCESS_STATE last_state;
12        private double lastUpdateTime;
13        private boolean isHpt = false;
14        private double hpt = 0;
15        private double threshold;
16        private double hptStart;
17        
18        public HptSensor(SchedulerModel model, IActiveProcess process, double threshold){
19            this.model = model;
20                this.lastUpdateTime = 0;
21                this.last_state = process.getState();
22                this.threshold = threshold;
23        }
24        
25        public void start(){
26                isHpt = true;
27                hpt = 0.0;
28                hptStart = model.getSimulationControl().getCurrentSimulationTime();
29                lastUpdateTime = hptStart;
30        }
31        
32        public double getHpt() {
33                return hpt;
34        }
35 
36        public double getHptStart() {
37                return hptStart;
38        }
39 
40        public void stop() {
41                double currentTime = model.getSimulationControl().getCurrentSimulationTime();
42                double passedTime = currentTime - lastUpdateTime;
43                
44                if (last_state == PROCESS_STATE.RUNNING){
45                        if (isHpt ){
46                                hpt  += passedTime;
47                        }
48                }
49                lastUpdateTime = currentTime;
50                isHpt = false;
51        }
52 
53        public void update(PROCESS_STATE new_state) {
54                if (isHpt){
55                        double currentTime = model.getSimulationControl().getCurrentSimulationTime();
56                        double passedTime = currentTime - lastUpdateTime;
57                        
58                        // Process was running, but is finished now
59                        if (last_state == PROCESS_STATE.RUNNING &&
60                                new_state != PROCESS_STATE.RUNNING) {
61                                if (isHpt ){
62                                        hpt  += passedTime;
63                                }
64                                lastUpdateTime = currentTime;
65                        }
66 
67                        // Process was not running, but starts now
68                        if (last_state != PROCESS_STATE.RUNNING &&
69                                new_state == PROCESS_STATE.RUNNING) {
70                                if (passedTime > threshold){
71                                        isHpt = false;
72                                }
73                                lastUpdateTime = currentTime;
74                        }
75                        last_state = new_state;
76                }
77        }
78}

[all classes][de.uka.ipd.sdq.scheduler.sensors.impl]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov