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

COVERAGE SUMMARY FOR SOURCE FILE [SimulationDebugTarget.java]

nameclass, %method, %block, %line, %
SimulationDebugTarget.java0%   (0/2)0%   (0/29)0%   (0/313)0%   (0/82)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SimulationDebugTarget0%   (0/1)0%   (0/27)0%   (0/302)0%   (0/79)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
SimulationDebugTarget (ILaunch, DockModel): void 0%   (0/1)0%   (0/35)0%   (0/9)
access$0 (SimulationDebugTarget): SimulationDockService 0%   (0/1)0%   (0/3)0%   (0/1)
breakpointAdded (IBreakpoint): void 0%   (0/1)0%   (0/1)0%   (0/1)
breakpointChanged (IBreakpoint, IMarkerDelta): void 0%   (0/1)0%   (0/1)0%   (0/1)
breakpointRemoved (IBreakpoint, IMarkerDelta): void 0%   (0/1)0%   (0/1)0%   (0/1)
canDisconnect (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
canResume (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
canSuspend (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
canTerminate (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
disconnect (): void 0%   (0/1)0%   (0/1)0%   (0/1)
dispose (): void 0%   (0/1)0%   (0/23)0%   (0/6)
getMemoryBlock (long, long): IMemoryBlock 0%   (0/1)0%   (0/2)0%   (0/1)
getName (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getProcess (): IProcess 0%   (0/1)0%   (0/6)0%   (0/1)
getThreads (): IThread [] 0%   (0/1)0%   (0/23)0%   (0/5)
hasThreads (): boolean 0%   (0/1)0%   (0/7)0%   (0/1)
isDisconnected (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
isSuspended (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
isTerminated (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
notifyChanged (Notification): void 0%   (0/1)0%   (0/73)0%   (0/16)
resume (): void 0%   (0/1)0%   (0/9)0%   (0/3)
supportsBreakpoint (IBreakpoint): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
supportsStorageRetrieval (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
suspend (): void 0%   (0/1)0%   (0/4)0%   (0/2)
terminate (): void 0%   (0/1)0%   (0/4)0%   (0/2)
update (Observable, Object): void 0%   (0/1)0%   (0/78)0%   (0/17)
     
class SimulationDebugTarget$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
SimulationDebugTarget$1 (SimulationDebugTarget): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/5)0%   (0/2)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.codegen.simucontroller.debug;
5 
6import java.util.ArrayList;
7import java.util.Observable;
8import java.util.Observer;
9 
10import org.eclipse.core.resources.IMarkerDelta;
11import org.eclipse.debug.core.DebugEvent;
12import org.eclipse.debug.core.DebugException;
13import org.eclipse.debug.core.ILaunch;
14import org.eclipse.debug.core.model.IBreakpoint;
15import org.eclipse.debug.core.model.IDebugTarget;
16import org.eclipse.debug.core.model.IMemoryBlock;
17import org.eclipse.debug.core.model.IProcess;
18import org.eclipse.debug.core.model.IThread;
19import org.eclipse.emf.common.notify.Notification;
20 
21import de.uka.ipd.sdq.codegen.simucontroller.dockmodel.DockModel;
22import de.uka.ipd.sdq.codegen.simucontroller.dockmodel.events.DockEvent;
23import de.uka.ipd.sdq.codegen.simucontroller.dockmodel.events.DockSimulationStartedEvent;
24import de.uka.ipd.sdq.codegen.simucontroller.dockmodel.events.DockSimulationTerminatedEvent;
25import de.uka.ipd.sdq.simucomframework.simucomstatus.Process;
26import de.uka.ipd.sdq.simucomframework.simucomstatus.SimuComStatus;
27import de.uka.ipd.sdq.simucomframework.simucomstatus.SimucomstatusPackage;
28import de.uka.ipd.sdq.simucomframework.simulationdock.SimulationDockService;
29 
30/**
31 * Class to support SimuCom debugging interactions
32 * @author Steffen Becker
33 */
34public class SimulationDebugTarget extends SimulationDebugElement implements IDebugTarget, Observer  {
35 
36        private SimulationDockService simControl;
37        private SimulationDebugThread myEventProcessorThread = null;
38        private DockModel myDock;
39        private boolean isTerminated;
40        private ArrayList<IThread> runningSimThreads = new ArrayList<IThread>();
41        private SimuComStatus simulationStatus;
42 
43        public SimulationDebugTarget(ILaunch launch,
44                        DockModel dock) {
45                super(null,launch);
46                myDebugTarget = this;
47                this.myDock = dock;
48                this.simControl = dock.getService();
49                this.myDock.addObserver(this);
50                myEventProcessorThread = new SimulationDebugThread(this,launch,dock);
51        }
52 
53        /* (non-Javadoc)
54         * @see org.eclipse.debug.core.model.IDebugTarget#getName()
55         */
56        public String getName() throws DebugException {
57                return "SimuCom Simulation Run";
58        }
59 
60        /* (non-Javadoc)
61         * @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
62         */
63        public IProcess getProcess() {
64                return launch.getProcesses()[0];
65        }
66 
67        /* (non-Javadoc)
68         * @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
69         */
70        public IThread[] getThreads() throws DebugException {
71                ArrayList<IThread> result = new ArrayList<IThread>();
72                if (!this.isTerminated) {
73                        result.add(myEventProcessorThread);
74                        result.addAll(runningSimThreads);
75                }
76                return result.toArray(new IThread[]{});
77        }
78 
79        /* (non-Javadoc)
80         * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads()
81         */
82        public boolean hasThreads() throws DebugException {
83                return !isTerminated();
84        }
85 
86        /* (non-Javadoc)
87         * @see org.eclipse.debug.core.model.IDebugTarget#supportsBreakpoint(org.eclipse.debug.core.model.IBreakpoint)
88         */
89        public boolean supportsBreakpoint(IBreakpoint breakpoint) {
90                return false;
91        }
92 
93        /* (non-Javadoc)
94         * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
95         */
96        public boolean canTerminate() {
97                return true;
98        }
99 
100        /* (non-Javadoc)
101         * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
102         */
103        public boolean isTerminated() {
104                return this.isTerminated;
105        }
106 
107        /* (non-Javadoc)
108         * @see org.eclipse.debug.core.model.ITerminate#terminate()
109         */
110        public void terminate() throws DebugException {
111                simControl.stopSimulation();
112        }
113 
114        /* (non-Javadoc)
115         * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
116         */
117        public boolean canResume() {
118                return true;
119        }
120 
121        /* (non-Javadoc)
122         * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
123         */
124        public boolean canSuspend() {
125                return true;
126        }
127 
128        /* (non-Javadoc)
129         * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
130         */
131        public boolean isSuspended() {
132                return this.myDock.isSuspended();
133        }
134 
135        /* (non-Javadoc)
136         * @see org.eclipse.debug.core.model.ISuspendResume#resume()
137         */
138        public void resume() throws DebugException {
139                // Do not execute resume in a UI thread
140                new Thread(new Runnable(){
141 
142                        public void run() {
143                                simControl.resume();
144                        }
145                        
146                }).run();
147        }
148 
149        /* (non-Javadoc)
150         * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
151         */
152        public void suspend() throws DebugException {
153                simControl.suspend();
154        }
155 
156        /* (non-Javadoc)
157         * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint)
158         */
159        public void breakpointAdded(IBreakpoint breakpoint) {
160        }
161 
162        /* (non-Javadoc)
163         * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
164         */
165        public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
166                // TODO Auto-generated method stub
167 
168        }
169 
170        /* (non-Javadoc)
171         * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
172         */
173        public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
174                // TODO Auto-generated method stub
175 
176        }
177 
178        /* (non-Javadoc)
179         * @see org.eclipse.debug.core.model.IDisconnect#canDisconnect()
180         */
181        public boolean canDisconnect() {
182                return false;
183        }
184 
185        /* (non-Javadoc)
186         * @see org.eclipse.debug.core.model.IDisconnect#disconnect()
187         */
188        public void disconnect() throws DebugException {
189        }
190 
191        /* (non-Javadoc)
192         * @see org.eclipse.debug.core.model.IDisconnect#isDisconnected()
193         */
194        public boolean isDisconnected() {
195                return false;
196        }
197 
198        /* (non-Javadoc)
199         * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long)
200         */
201        public IMemoryBlock getMemoryBlock(long startAddress, long length)
202                        throws DebugException {
203                return null;
204        }
205 
206        /* (non-Javadoc)
207         * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval()
208         */
209        public boolean supportsStorageRetrieval() {
210                return false;
211        }
212        
213        public void dispose() {
214                assert isTerminated;
215 
216                this.myEventProcessorThread.dispose();
217 
218                this.simControl = null;
219                this.myDock.deleteObserver(this);
220                this.myDock = null;
221        }
222 
223        public void update(Observable o, Object arg) {
224                if (arg instanceof DockEvent) {
225                        DockEvent dockEvent = (DockEvent) arg;
226                        if (dockEvent.comesFrom(this.myDock)) {
227                                if (dockEvent instanceof DockSimulationTerminatedEvent) {
228                                        this.isTerminated = true;
229                                        if (!this.myDock.isRemote()) {
230                                                this.simulationStatus.eAdapters().remove(this);
231                                                this.simulationStatus.getProcessStatus().eAdapters().remove(this);
232                                                this.simulationStatus.getResourceStatus().eAdapters().remove(this);
233                                        }
234                                        fireEvent(this, DebugEvent.TERMINATE);
235                                }
236                                if (dockEvent instanceof DockSimulationStartedEvent) {
237                                        if (!this.myDock.isRemote()) {
238                                                this.simulationStatus = this.simControl.getSimuComStatus();
239                                                this.simulationStatus.eAdapters().add(this);
240                                                this.simulationStatus.getProcessStatus().eAdapters().add(this);
241                                                this.simulationStatus.getResourceStatus().eAdapters().add(this);
242                                        }
243                                }
244                        }
245                }
246        }
247 
248        @Override
249        public void notifyChanged(Notification notification) {
250                if (notification.getEventType() == Notification.ADD) {
251                        if (notification.getFeature() == SimucomstatusPackage.eINSTANCE.getSimulatedProcesses_Processes()) {
252                                this.runningSimThreads.add(new SimuComProcessDebugThread(this,launch,(Process)notification.getNewValue()));
253                                fireEvent(this, DebugEvent.CHANGE);
254                        }
255                }
256                if (notification.getEventType() == Notification.REMOVE) {
257                        if (notification.getFeature() == SimucomstatusPackage.eINSTANCE.getSimulatedProcesses_Processes()) {
258                                SimuComProcessDebugThread candidate = null;
259                                for (IThread thread : runningSimThreads) {
260                                        if (thread instanceof SimuComProcessDebugThread) {
261                                                candidate = (SimuComProcessDebugThread) thread;
262                                                if (candidate.getProcess() == notification.getOldValue()){
263                                                        break;
264                                                }
265                                        }
266                                }
267                                this.runningSimThreads.remove(candidate);
268                                candidate.dispose();
269                                fireEvent(this, DebugEvent.CHANGE);
270                        }
271                }
272        }
273}

[all classes][de.uka.ipd.sdq.codegen.simucontroller.debug]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov