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

COVERAGE SUMMARY FOR SOURCE FILE [DebugObserver.java]

nameclass, %method, %block, %line, %
DebugObserver.java0%   (0/1)0%   (0/8)0%   (0/174)0%   (0/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DebugObserver0%   (0/1)0%   (0/8)0%   (0/174)0%   (0/47)
<static initializer> 0%   (0/1)0%   (0/5)0%   (0/3)
DebugObserver (EventAdmin, SimulationDockService): void 0%   (0/1)0%   (0/17)0%   (0/6)
postEvent (String): void 0%   (0/1)0%   (0/7)0%   (0/2)
postEvent (String, Hashtable): void 0%   (0/1)0%   (0/25)0%   (0/6)
resume (): void 0%   (0/1)0%   (0/30)0%   (0/8)
step (): void 0%   (0/1)0%   (0/27)0%   (0/6)
suspend (): void 0%   (0/1)0%   (0/18)0%   (0/4)
updateStatus (int, double, long): void 0%   (0/1)0%   (0/45)0%   (0/12)

1package de.uka.ipd.sdq.simucomframework.simulationdock;
2 
3import java.util.Hashtable;
4import java.util.Map;
5 
6import org.apache.log4j.Logger;
7import org.osgi.service.event.Event;
8import org.osgi.service.event.EventAdmin;
9 
10import de.uka.ipd.sdq.simulation.IStatusObserver;
11 
12public class DebugObserver implements IStatusObserver {
13 
14        protected static Logger logger = 
15                Logger.getLogger(DebugObserver.class.getName());
16        
17        private boolean isStepping;
18        private EventAdmin eventAdmin;
19        private SimulationDockService myDock;
20 
21        private Object suspendedBarrier = new Object();
22        private boolean suspended;
23 
24        public DebugObserver(EventAdmin eventAdmin, SimulationDockService myDock) {
25                super();
26                this.eventAdmin = eventAdmin;
27                this.myDock = myDock;
28                this.suspended = true;
29        }
30 
31        public void suspend() {
32                this.suspended = true;
33                synchronized (this.suspendedBarrier) {
34                        this.suspendedBarrier.notifyAll();
35                }
36        }
37 
38        public void resume() {
39                this.suspended = false;
40                postEvent("de/uka/ipd/sdq/simucomframework/simucomdock/SIM_RESUMED");
41 
42                if (this.isStepping) {
43                        isStepping = false;
44                        postEvent("de/uka/ipd/sdq/simucomframework/simucomdock/PERFORMED_STEP");
45                }
46                
47                synchronized (this.suspendedBarrier) {
48                        this.suspendedBarrier.notifyAll();
49                }
50        }
51 
52        public void step() {
53                if (suspended && !isStepping) {
54                        this.isStepping = true;
55                        postEvent("de/uka/ipd/sdq/simucomframework/simucomdock/STARTED_STEP");
56                        synchronized (this.suspendedBarrier) {
57                                this.suspendedBarrier.notifyAll();
58                        }
59                }
60        }
61        
62        public void updateStatus(int percentDone, double currentSimTime,
63                        long measurementsTaken) {
64                
65                if (this.isStepping) {
66                        isStepping = false;
67                        postEvent("de/uka/ipd/sdq/simucomframework/simucomdock/PERFORMED_STEP");
68                }
69 
70                synchronized(this.suspendedBarrier) {
71                        while (this.suspended && !isStepping) {
72                                try {
73                                        postEvent("de/uka/ipd/sdq/simucomframework/simucomdock/SIM_SUSPENDED");
74                                        this.suspendedBarrier.wait();
75                                } catch (InterruptedException e) { }
76                        }
77                }
78                
79                if (this.suspended){
80                        postEvent("de/uka/ipd/sdq/simucomframework/simucomdock/SIM_RESUMED");
81                        logger.debug("------------------------- Simulation Resumed ----------------------------------");
82                }
83        }
84 
85        private void postEvent(String topic) {
86                postEvent(topic, new Hashtable<String,Object>());
87        }
88        
89        private void postEvent(String topic, Hashtable<String,Object> newProperties) {
90                Hashtable<String,Object> properties = new Hashtable<String,Object>();
91                properties.put("DOCK_ID", myDock.getDockId());
92                properties.putAll(newProperties);
93                Event event = new Event(topic, (Map)properties);
94                eventAdmin.sendEvent(event);
95        }
96        
97}

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