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

nameclass, %method, %block, %line, %
RunTimeSensor.java0%   (0/1)0%   (0/5)0%   (0/131)0%   (0/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RunTimeSensor0%   (0/1)0%   (0/5)0%   (0/131)0%   (0/35)
RunTimeSensor (SchedulerModel, IActiveProcess): void 0%   (0/1)0%   (0/18)0%   (0/7)
getNotRunTime (): double 0%   (0/1)0%   (0/27)0%   (0/6)
getRunTime (): double 0%   (0/1)0%   (0/27)0%   (0/6)
reset (): void 0%   (0/1)0%   (0/13)0%   (0/4)
update (PROCESS_STATE): void 0%   (0/1)0%   (0/46)0%   (0/12)

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 RunTimeSensor implements IProcessStateSensor {
9 
10    private SchedulerModel model;
11        private PROCESS_STATE last_state;
12        private double lastUpdateTime;
13        private double otherTime;
14        private double runTime;
15        private IActiveProcess process;
16 
17        public RunTimeSensor(SchedulerModel model, IActiveProcess process) {
18            this.model = model;
19                this.lastUpdateTime = 0;
20                this.process = process;
21                this.last_state = process.getState();
22                reset();
23        }
24 
25        public void reset() {
26                runTime = 0;
27                otherTime = 0;
28                this.lastUpdateTime = model.getSimulationControl().getCurrentSimulationTime();
29        }
30        
31        public double getRunTime(){
32                if (process.getState() == PROCESS_STATE.RUNNING){
33                        double currentTime = model.getSimulationControl().getCurrentSimulationTime();
34                        double passedTime = currentTime - lastUpdateTime;
35                        runTime += passedTime;
36                        lastUpdateTime = currentTime;
37                }
38                return runTime;
39        }
40        
41        public double getNotRunTime(){
42                if (process.getState() != PROCESS_STATE.RUNNING){
43                        double currentTime = model.getSimulationControl().getCurrentSimulationTime();
44                        double passedTime = currentTime - lastUpdateTime;
45                        otherTime += passedTime;
46                        lastUpdateTime = currentTime;
47                }
48                return otherTime;
49        }
50 
51        public void update(PROCESS_STATE new_state) {
52                double currentTime = model.getSimulationControl().getCurrentSimulationTime();
53                double passedTime = currentTime - lastUpdateTime;
54 
55                // Process was running, but is finished now
56                if (last_state == PROCESS_STATE.RUNNING
57                                && new_state != PROCESS_STATE.RUNNING) {
58                        runTime += passedTime;
59                        lastUpdateTime = currentTime;
60                }
61 
62                // Process was not running, but starts now
63                if (last_state != PROCESS_STATE.RUNNING
64                                && new_state == PROCESS_STATE.RUNNING) {
65                        otherTime += passedTime;
66                        lastUpdateTime = currentTime;
67                }
68                last_state = new_state;
69        }
70}

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