|
@@ -41,16 +41,16 @@ import org.yakindu.sct.simulation.core.sruntime.ExecutionContext
|
|
|
* @author andreas muelder - Initial contribution and API
|
|
|
* @author axel terfloth - minimized changes on execution context
|
|
|
*
|
|
|
- */
|
|
|
- @Singleton
|
|
|
+ */
|
|
|
+@Singleton
|
|
|
class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
|
|
|
|
|
|
@Inject
|
|
|
IStatementInterpreter statementInterpreter
|
|
|
@Inject
|
|
|
ITimingService timingService
|
|
|
- @Inject extension SexecExtensions
|
|
|
- @Inject(optional = true)
|
|
|
+ @Inject extension SexecExtensions
|
|
|
+ @Inject(optional=true)
|
|
|
ITraceStepInterpreter traceInterpreter
|
|
|
|
|
|
ExecutionFlow flow
|
|
@@ -68,45 +68,56 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
|
|
|
executionStack = newLinkedList()
|
|
|
activeStateConfiguration = newArrayOfSize(flow.stateVector.size)
|
|
|
activeStateIndex = 0
|
|
|
- historyStateConfiguration = newHashMap()
|
|
|
- if(!executionContext.snapshot)
|
|
|
+ historyStateConfiguration = newHashMap()
|
|
|
+ if (!executionContext.snapshot)
|
|
|
flow.initSequence.scheduleAndRun
|
|
|
}
|
|
|
|
|
|
- override enter() {
|
|
|
- if(!executionContext.snapshot)
|
|
|
- flow.enterSequences?.defaultSequence?.scheduleAndRun
|
|
|
- else{
|
|
|
- executionContext.activeStates.forEach[state | activeStateConfiguration.set(state.toExecutionState.stateVector.offset, state.toExecutionState)]
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- def ExecutionState toExecutionState(RegularState state){
|
|
|
- return flow.eAllContents.filter[it instanceof ExecutionState && EcoreUtil::equals((it as ExecutionState).sourceElement,state)].head as ExecutionState
|
|
|
+ override enter() {
|
|
|
+ if (!executionContext.snapshot)
|
|
|
+ flow.enterSequences?.defaultSequence?.scheduleAndRun
|
|
|
+ else {
|
|
|
+ executionContext.activeStates.forEach[state|
|
|
|
+ activeStateConfiguration.set(state.toExecutionState.stateVector.offset, state.toExecutionState)]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ def ExecutionState toExecutionState(RegularState state) {
|
|
|
+ return flow.eAllContents.filter[
|
|
|
+ it instanceof ExecutionState && EcoreUtil::equals((it as ExecutionState).sourceElement, state)].head as ExecutionState
|
|
|
}
|
|
|
|
|
|
- override runCycle() {
|
|
|
- //Raise all schedules events
|
|
|
- executionContext.allEvents.filter[scheduled].forEach[raised = true scheduled = false]
|
|
|
+ override runCycle() {
|
|
|
+ raiseScheduledEvents()
|
|
|
activeStateIndex = 0
|
|
|
- if (executionContext.executedElements.size > 0) executionContext.executedElements.clear
|
|
|
- //Clear all out events
|
|
|
- executionContext.allEvents.filter[direction == EventDirection.OUT].forEach[if(raised) raised=false]
|
|
|
+ if(executionContext.executedElements.size > 0) executionContext.executedElements.clear
|
|
|
+ clearOutEvents()
|
|
|
while (activeStateIndex < activeStateConfiguration.size) {
|
|
|
var state = activeStateConfiguration.get(activeStateIndex)
|
|
|
state?.reactSequence?.scheduleAndRun
|
|
|
activeStateIndex = activeStateIndex + 1
|
|
|
}
|
|
|
- //clear all local and in events
|
|
|
+ cleatLocalAndInEvents()
|
|
|
+ }
|
|
|
+
|
|
|
+ def cleatLocalAndInEvents() {
|
|
|
executionContext.allEvents.filter[direction == EventDirection.IN || direction == EventDirection.LOCAL].forEach[
|
|
|
- if(raised) raised=false]
|
|
|
+ if(raised) raised = false]
|
|
|
}
|
|
|
|
|
|
- override resume() {
|
|
|
+ def raiseScheduledEvents() {
|
|
|
+ executionContext.allEvents.filter[scheduled].forEach[raised = true scheduled = false]
|
|
|
+ }
|
|
|
+
|
|
|
+ def clearOutEvents() {
|
|
|
+ executionContext.allEvents.filter[direction == EventDirection.OUT].forEach[if(raised) raised = false]
|
|
|
+ }
|
|
|
+
|
|
|
+ override resume() {
|
|
|
executionContext.suspendedElements.clear
|
|
|
suspended = false
|
|
|
run
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
override suspend() {
|
|
|
suspended = true
|
|
@@ -145,12 +156,11 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
|
|
|
def dispatch Object execute(Step step) {
|
|
|
}
|
|
|
|
|
|
- def dispatch Object execute(Trace trace) {
|
|
|
- traceInterpreter?.evaluate(trace, executionContext)
|
|
|
+ def dispatch Object execute(Trace trace) {
|
|
|
+ traceInterpreter?.evaluate(trace, executionContext)
|
|
|
null
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
def dispatch Object execute(Check check) {
|
|
|
if (check.condition == null)
|
|
|
return true
|
|
@@ -171,7 +181,7 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
|
|
|
|
|
|
def dispatch Object execute(ExitState exitState) {
|
|
|
activeStateConfiguration.set(exitState.state.stateVector.offset, null)
|
|
|
- var activeStates = executionContext.activeStates.filter[EcoreUtil::equals(it,exitState.state.sourceElement)]
|
|
|
+ var activeStates = executionContext.activeStates.filter[EcoreUtil::equals(it, exitState.state.sourceElement)]
|
|
|
executionContext.activeStates.removeAll(activeStates)
|
|
|
null
|
|
|
}
|