1
- package org .eclipse .gemoc .execution .sequential .javaengine .headless ;
1
+ package org .eclipse .gemoc .execution .sequential .javaengine .headless . mep ;
2
2
3
3
import java .io .EOFException ;
4
4
import java .io .IOException ;
11
11
import java .util .concurrent .Semaphore ;
12
12
13
13
import org .eclipse .emf .ecore .resource .Resource ;
14
+ import org .eclipse .gemoc .execution .sequential .javaengine .headless .AbstractHeadlessExecutionContext ;
15
+ import org .eclipse .gemoc .execution .sequential .javaengine .headless .HeadlessExecutionPlatform ;
16
+ import org .eclipse .gemoc .execution .sequential .javaengine .headless .HeadlessExecutionWorkspace ;
17
+ import org .eclipse .gemoc .execution .sequential .javaengine .headless .HeadlessPlainK3ExecutionEngine ;
18
+ import org .eclipse .gemoc .execution .sequential .javaengine .headless .StackFrame ;
14
19
import org .eclipse .gemoc .execution .sequential .javaengine .headless .commands .ClearBreakpointsCommand ;
15
20
import org .eclipse .gemoc .execution .sequential .javaengine .headless .commands .ContinueCommand ;
16
21
import org .eclipse .gemoc .execution .sequential .javaengine .headless .commands .DoStepCommand ;
21
26
import org .eclipse .gemoc .execution .sequential .javaengine .headless .commands .StopCommand ;
22
27
import org .eclipse .gemoc .execution .sequential .javaengine .headless .commands .StopCondition ;
23
28
import org .eclipse .gemoc .execution .sequential .javaengine .headless .commands .StopEvent ;
29
+ import org .eclipse .gemoc .execution .sequential .javaengine .headless .commands .StopReason ;
24
30
import org .eclipse .gemoc .execution .sequential .javaengine .headless .commands .ToggleBreakpointCommand ;
25
31
import org .eclipse .gemoc .executionframework .engine .commons .EngineContextException ;
32
+ import org .eclipse .gemoc .executionframework .engine .commons .sequential .HeadlessJavaEngineSequentialRunConfiguration ;
26
33
import org .eclipse .gemoc .executionframework .engine .commons .sequential .ISequentialRunConfiguration ;
27
34
import org .eclipse .gemoc .executionframework .mep .engine .IMEPEngine ;
28
35
import org .eclipse .gemoc .executionframework .mep .engine .IMEPEventListener ;
@@ -102,11 +109,14 @@ public void run() {
102
109
readData = gemocServerOutput .readObject ();
103
110
if (readData instanceof OutputEvent ) {
104
111
for (IMEPEventListener eventListener : mepEventListeners ) {
105
- eventListener .outputReceived (new org .eclipse .gemoc .executionframework .mep .events .Output (currentEngine , ((OutputEvent ) readData ).output ));
112
+ eventListener .outputReceived (new org .eclipse .gemoc .executionframework .mep .events .Output (currentEngine ,
113
+ ((OutputEvent ) readData ).output ));
106
114
}
107
115
} else if (readData instanceof StopEvent ) {
108
116
for (IMEPEventListener eventListener : mepEventListeners ) {
109
- eventListener .stopReceived (new org .eclipse .gemoc .executionframework .mep .events .Stopped (currentEngine , ((StopEvent ) readData ).stopReason ));
117
+
118
+ eventListener .stopReceived (new org .eclipse .gemoc .executionframework .mep .events .Stopped (currentEngine ,
119
+ engineToMepStopReason (((StopEvent ) readData ).stopReason )));
110
120
}
111
121
} else {
112
122
serverOutputBuffer .add (readData );
@@ -140,6 +150,22 @@ public void initializeResourceModel() {
140
150
};
141
151
}
142
152
153
+ private StoppedReason engineToMepStopReason (StopReason engineStopReason ) {
154
+ StoppedReason mepStoppedReason = null ;
155
+ switch (engineStopReason ) {
156
+ case REACHED_BREAKPOINT :
157
+ mepStoppedReason = StoppedReason .REACHED_BREAKPOINT ;
158
+ break ;
159
+ case REACHED_NEXT_LOGICAL_STEP :
160
+ mepStoppedReason = StoppedReason .REACHED_NEXT_LOGICAL_STEP ;
161
+ break ;
162
+ case REACHED_SIMULATION_END :
163
+ mepStoppedReason = StoppedReason .REACHED_SIMULATION_END ;
164
+ break ;
165
+ }
166
+ return mepStoppedReason ;
167
+ }
168
+
143
169
@ Override
144
170
public StoppedReason internalNext () {
145
171
return internalDoStep (StepKind .NEXT );
@@ -162,7 +188,7 @@ private StoppedReason internalDoStep(StepKind stepKind) {
162
188
gemocServerInput .writeObject (command );
163
189
serverOutputBufferSem .acquire ();
164
190
Object output = serverOutputBuffer .remove (0 );
165
- return (((StopCondition ) output ).stopReason );
191
+ return engineToMepStopReason (((( StopCondition ) output ).stopReason ) );
166
192
} catch (IOException | InterruptedException e ) {
167
193
e .printStackTrace ();
168
194
return null ;
@@ -193,6 +219,7 @@ public void internalTerminate() {
193
219
gemocServerInput .writeObject (stopCommand );
194
220
serverOutputBufferSem .acquire ();
195
221
serverOutputBuffer .remove (0 );
222
+ gemocServer .close ();
196
223
} catch (IOException | InterruptedException e ) {
197
224
e .printStackTrace ();
198
225
}
0 commit comments