Bladeren bron

Pull request for introducing event driven execution semantics for all generators (#1564) (#1571)

* Add Internal Event Queue Support for Simulation and CPP Code Generator (C++11)

Conflicts:
	plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend
	plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/StextStatementInterpreter.xtend

* Extend regular statemachine classes

Conflicts:
	plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend

* Add EventName enum & Event class

* Add event driven logic to core generator

* Fix imports

Conflicts:
	plugins/org.yakindu.sct.generator.cpp/META-INF/MANIFEST.MF

* WIP

Conflicts:
	plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineImplementation.xtend

* Replace ExpressionCode.xtend with master version

* Refactor StatemachineImplementation

* Guice up your life!

* WIP on EventQueue - compiles

* Override Event Raising Code

* ,

* Working implementation of eventqueue.

* Re-add clearInEvents

* Smaller refactorings, cleanups + generated Events are namespaced

* Revert changes unintenionally made to cycle based code

* Add class for time events

* Further WIP on TimeEvents. Does not compile

* Integrated time events into the event queue

* Remove event queue for in events

* Added copyright headers, author tags and todo for future

* removed event queue stuff from generated emf classes

* internal event queue functionality will only be used in event driven case.

* use new API

* extended execution flow interpreter interface to make it backward compatible

* updated module definition

* make injection of IEventRaiser optional

* Basework for event queue

* WIP on C EventQueue

* Add function to Navigation to get all events from ExecutionFlow

* WIP on Event Driven semantics for C

* WIP

* WIP on eventqueue

* C EventQueue seems to work

* Fixed issue with missing run cycle on time events in event driven case.

* Added test models for event driven execution strategy

* added tests for event driven execution strategy

* Add EventDriven statechart

Conflicts:
	test-plugins/org.yakindu.sct.test.models/tests/AllTests.sctunit

* Fix location of clearInEvents

* refactored/moved wrapper class generator to wrappers package

* Java generator module provides different bindings depending on event driven property.

* extracted internal event raiser to make overriding easier

* extracted internal event field templates to make overriding easier

* refactored generation of imports ...

* added runCycle call on in events and time events and added queuing for internal events

* fixed wrong test case

* removed some tests from test suite

* modified/added test gen models for event driven test cases

* Added some disabled tests to test suite

* made test model timed

* refactored and extended sgen files for tests and models

* regenerated test case code for java

* regenerated test model classes for java

* Update MANIFEST.MF

removed version

* Update EventDrivenExpressionCode.xtend

added missing copyright header

* Update EventDrivenStatemachineHeader.xtend

* Update EventDrivenStatemachineSource.xtend

* Add Copyright Headers

* Add author tag

* removed dependency version specification

* removed annoying TODO tag
Axel Terfloth 8 jaren geleden
bovenliggende
commit
822225f85e
100 gewijzigde bestanden met toevoegingen van 4530 en 785 verwijderingen
  1. 6 0
      plugins/org.yakindu.sct.domain.generic.simulation/src/org/yakindu/sct/domain/generic/simulation/GenericSimulationModule.java
  2. 2 1
      plugins/org.yakindu.sct.generator.c/META-INF/MANIFEST.MF
  3. 21 3
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGeneratorModule.java
  4. 13 2
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CGenerator.xtend
  5. 4 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Naming.xtend
  6. 4 4
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Navigation.xtend
  7. 33 19
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineHeader.xtend
  8. 92 64
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineSource.xtend
  9. 40 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/EventDrivenExpressionCode.xtend
  10. 40 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/EventDrivenStatemachineHeader.xtend
  11. 139 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/EventDrivenStatemachineSource.xtend
  12. 75 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/EventNaming.xtend
  13. 147 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/StatechartEventsHeader.xtend
  14. 124 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/StatechartEventsSource.xtend
  15. 2 1
      plugins/org.yakindu.sct.generator.cpp/META-INF/MANIFEST.MF
  16. 21 1
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGeneratorModule.java
  17. 31 16
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppGenerator.xtend
  18. 117 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/EventCode.xtend
  19. 4 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Naming.xtend
  20. 7 2
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Navigation.xtend
  21. 78 40
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend
  22. 85 122
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineImplementation.xtend
  23. 102 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/EventDrivenEventCode.xtend
  24. 57 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/EventDrivenExpressionCode.xtend
  25. 101 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/EventDrivenStatemachineHeader.xtend
  26. 176 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/EventDrivenStatemachineImplementation.xtend
  27. 49 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/EventNaming.xtend
  28. 161 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/StatechartEvents.xtend
  29. 2 1
      plugins/org.yakindu.sct.generator.genmodel.ui/META-INF/MANIFEST.MF
  30. 2 1
      plugins/org.yakindu.sct.generator.java/META-INF/MANIFEST.MF
  31. 2 0
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaGenerator.xtend
  32. 30 1
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaGeneratorModule.java
  33. 75 30
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/Statemachine.xtend
  34. 152 0
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/eventdriven/EventDrivenStatemachine.xtend
  35. 5 1
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/CycleBasedSynchronizedWrapper.xtend
  36. 5 1
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/EventBasedRunnableWrapper.xtend
  37. 9 1
      plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/container/AbstractExecutionFlowSimulationEngine.java
  38. 7 0
      plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/container/EventDrivenSimulationEngine.java
  39. 74 7
      plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/DefaultExecutionFlowInterpreter.xtend
  40. 23 0
      plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/IEventRaiser.java
  41. 1 0
      plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/IExecutionFlowInterpreter.java
  42. 9 5
      plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/StextStatementInterpreter.xtend
  43. 0 1
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/sruntime/ExecutionContext.java
  44. 91 0
      test-plugins/org.yakindu.sct.generator.cpp.test/model/test.sgen
  45. 79 0
      test-plugins/org.yakindu.sct.generator.java.test/model/model.eventdriven.sgen
  46. 54 0
      test-plugins/org.yakindu.sct.generator.java.test/model/test.eventdriven.sgen
  47. 109 0
      test-plugins/org.yakindu.sct.generator.java.test/model/test.executionorder.sgen
  48. 2 2
      test-plugins/org.yakindu.sct.generator.java.test/model/test.sgen
  49. 52 18
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/VirtualTimer.java
  50. 2 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/childfirstexecutionhierarchy/ChildFirstExecutionHierarchyStatemachine.java
  51. 2 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/childfirstlocalreactions/ChildFirstLocalReactionsStatemachine.java
  52. 2 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/childfirstorthogonalreactions/ChildFirstOrthogonalReactionsStatemachine.java
  53. 564 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriveninternalevent/EventDrivenInternalEventStatemachine.java
  54. 29 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriveninternalevent/IEventDrivenInternalEventStatemachine.java
  55. 317 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriventriggeredbyevent/EventDrivenTriggeredByEventStatemachine.java
  56. 20 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriventriggeredbyevent/IEventDrivenTriggeredByEventStatemachine.java
  57. 328 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriventriggeredbytimeevent/EventDrivenTriggeredByTimeEventStatemachine.java
  58. 22 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriventriggeredbytimeevent/IEventDrivenTriggeredByTimeEventStatemachine.java
  59. 2 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/parentfirstexecutionhierarchy/ParentFirstExecutionHierarchyStatemachine.java
  60. 2 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/parentfirstlocalreactions/ParentFirstLocalReactionsStatemachine.java
  61. 2 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/parentfirstorthogonalreactions/ParentFirstOrthogonalReactionsStatemachine.java
  62. 8 10
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/AllTests.java
  63. 13 15
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/AlwaysOncycle.java
  64. 17 19
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/AssignmentAsExpression.java
  65. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/BitExpressions.java
  66. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/BooleanExpressions.java
  67. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/CKeywords.java
  68. 11 13
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/CastExpressions.java
  69. 96 0
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ChildFirstExecutionHierarchy.java
  70. 89 0
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ChildFirstLocalReactions.java
  71. 13 15
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/Choice.java
  72. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ConditionalExpression.java
  73. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ConstOnlyDefaultScope.java
  74. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ConstOnlyInternalScope.java
  75. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ConstOnlyNamedScope.java
  76. 12 14
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ConstantsTests.java
  77. 9 11
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/Declarations.java
  78. 9 11
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/DeepEntry.java
  79. 15 17
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/DeepHistory.java
  80. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/DynamicChoice.java
  81. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EmptyTransition.java
  82. 12 14
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EnterState.java
  83. 11 13
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EntryChoice.java
  84. 13 15
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EntryExitSelfTransition.java
  85. 13 15
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EntryReactionAction.java
  86. 46 0
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EventDrivenInternalEvent.java
  87. 56 0
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EventDrivenTriggeredByEvent.java
  88. 62 0
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EventDrivenTriggeredByTimeEvent.java
  89. 11 13
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ExitOnSelfTransition.java
  90. 13 15
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ExitState.java
  91. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/FeatureCalls.java
  92. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/FinalState.java
  93. 14 16
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/Guard.java
  94. 11 13
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/GuardedEntry.java
  95. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/GuardedExit.java
  96. 14 16
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/HistoryWithExitPoint.java
  97. 16 18
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/HistoryWithoutInitialStep.java
  98. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/InEventLifeCycle.java
  99. 10 12
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/IntegerExpressions.java
  100. 0 0
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/InternalEventLifeCycle.java

+ 6 - 0
plugins/org.yakindu.sct.domain.generic.simulation/src/org/yakindu/sct/domain/generic/simulation/GenericSimulationModule.java

@@ -26,6 +26,7 @@ import org.yakindu.sct.simulation.core.sexec.container.DefaultSimulationEngineFa
 import org.yakindu.sct.simulation.core.sexec.container.IExecutionContextInitializer;
 import org.yakindu.sct.simulation.core.sexec.container.ISimulationEngineFactory;
 import org.yakindu.sct.simulation.core.sexec.interpreter.DefaultExecutionFlowInterpreter;
+import org.yakindu.sct.simulation.core.sexec.interpreter.IEventRaiser;
 import org.yakindu.sct.simulation.core.sexec.interpreter.IExecutionFlowInterpreter;
 import org.yakindu.sct.simulation.core.sexec.interpreter.IOperationMockup;
 import org.yakindu.sct.simulation.core.sexec.interpreter.IStatementInterpreter;
@@ -42,6 +43,7 @@ import com.google.inject.name.Names;
 /**
  * 
  * @author andreas muelder - Initial contribution and API
+ * @author axel terfloth - additions
  * 
  */
 public class GenericSimulationModule extends AbstractGenericModule {
@@ -80,6 +82,10 @@ public class GenericSimulationModule extends AbstractGenericModule {
 		return DefaultExecutionFlowInterpreter.class;
 	}
 
+	public Class<? extends IEventRaiser> bindIEventRaiser() {
+		return DefaultExecutionFlowInterpreter.class;
+	}
+
 	public Class<? extends ITimingService> bindITimingService() {
 		return SuspendableTimingService.class;
 	}

+ 2 - 1
plugins/org.yakindu.sct.generator.c/META-INF/MANIFEST.MF

@@ -8,7 +8,8 @@ Require-Bundle: org.yakindu.sct.model.sexec,
  org.yakindu.sct.generator.core,
  org.yakindu.sct.generator.genmodel,
  org.yakindu.base.types,
- org.yakindu.sct.domain.generic
+ org.yakindu.sct.domain.generic,
+ org.yakindu.sct.model.stext.lib
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Export-Package: org.yakindu.sct.generator.c,
  org.yakindu.sct.generator.c.features,

+ 21 - 3
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGeneratorModule.java

@@ -10,20 +10,26 @@
  */
 package org.yakindu.sct.generator.c;
 
-import static org.yakindu.sct.generator.c.features.ICFeatureConstants.FEATURE_TRACING;
 import static org.yakindu.sct.generator.c.features.ICFeatureConstants.FEATURE_INCLUDES;
+import static org.yakindu.sct.generator.c.features.ICFeatureConstants.FEATURE_TRACING;
+import static org.yakindu.sct.generator.c.features.ICFeatureConstants.PARAMETER_INCLUDES_USE_RELATIVE_PATHS;
 import static org.yakindu.sct.generator.c.features.ICFeatureConstants.PARAMETER_TRACING_ENTER_STATE;
 import static org.yakindu.sct.generator.c.features.ICFeatureConstants.PARAMETER_TRACING_EXIT_STATE;
-import static org.yakindu.sct.generator.c.features.ICFeatureConstants.PARAMETER_INCLUDES_USE_RELATIVE_PATHS;
 import static org.yakindu.sct.model.sexec.transformation.IModelSequencer.ADD_TRACES;
+import static org.yakindu.sct.model.stext.lib.StatechartAnnotations.EVENT_DRIVEN_ANNOTATION;
 
+import org.yakindu.base.types.Annotation;
+import org.yakindu.sct.generator.c.eventdriven.EventDrivenExpressionCode;
+import org.yakindu.sct.generator.c.eventdriven.EventDrivenStatemachineHeader;
+import org.yakindu.sct.generator.c.eventdriven.EventDrivenStatemachineSource;
 import org.yakindu.sct.generator.c.types.CTypeSystemAccess;
-import org.yakindu.sct.generator.core.IGeneratorModule;
 import org.yakindu.sct.generator.core.IExecutionFlowGenerator;
+import org.yakindu.sct.generator.core.IGeneratorModule;
 import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess;
 import org.yakindu.sct.model.sexec.naming.INamingService;
 import org.yakindu.sct.model.sgen.FeatureParameterValue;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgraph.Statechart;
 
 import com.google.inject.Binder;
 import com.google.inject.name.Names;
@@ -42,6 +48,7 @@ public class CCodeGeneratorModule implements IGeneratorModule {
 		binder.bind(ICodegenTypeSystemAccess.class).to(CTypeSystemAccess.class);
 		bindIGenArtifactConfigurations(entry, binder);
 		bindTracingProperty(entry, binder);
+		configureEventDriven(entry, binder);
 	}
 
 	protected void bindTracingProperty(GeneratorEntry entry, Binder binder) {
@@ -64,5 +71,16 @@ public class CCodeGeneratorModule implements IGeneratorModule {
 			binder.bind(IGenArtifactConfigurations.class).to(SimpleGenArtifactConfigurations.class);
 		}
 	}
+	
+	protected void configureEventDriven(GeneratorEntry entry, Binder binder) {
+		Statechart statechart = (Statechart) entry.getElementRef();
+		Annotation eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
+		
+		if(eventDrivenAnnotation != null) {
+			binder.bind(StatemachineHeader.class).to(EventDrivenStatemachineHeader.class);
+			binder.bind(StatemachineSource.class).to(EventDrivenStatemachineSource.class);
+			binder.bind(ExpressionCode.class).to(EventDrivenExpressionCode.class);
+		}
+	}
 
 }

+ 13 - 2
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CGenerator.xtend

@@ -12,13 +12,17 @@ package org.yakindu.sct.generator.c
 
 import com.google.inject.Inject
 import org.eclipse.xtext.generator.IFileSystemAccess
-import org.yakindu.sct.generator.c.DefaultGenArtifactConfigurations.GenArtifactConfiguration
+import org.yakindu.sct.generator.c.IGenArtifactConfigurations.GenArtifactConfiguration
+import org.yakindu.sct.generator.c.eventdriven.StatechartEventsHeader
+import org.yakindu.sct.generator.c.eventdriven.StatechartEventsSource
 import org.yakindu.sct.generator.core.IExecutionFlowGenerator
 import org.yakindu.sct.generator.core.library.ICoreLibraryHelper
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.yakindu.sct.model.sgraph.Statechart
 
 import static org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess.*
+import static org.yakindu.sct.model.stext.lib.StatechartAnnotations.EVENT_DRIVEN_ANNOTATION
 
 /**
  * This is the C code generators main class. 
@@ -31,6 +35,8 @@ class CGenerator implements IExecutionFlowGenerator {
 	@Inject extension StatemachineHeader statemachineHeader
 	@Inject extension StatemachineSource statemachineSource
 	@Inject extension StatemachineRequiredHeader statemachineRequiredHeader
+	@Inject extension StatechartEventsHeader statechartEventsHeader
+	@Inject extension StatechartEventsSource statechartEventsSource
 	@Inject extension Navigation
 	@Inject extension GenmodelEntries
 	@Inject extension Naming
@@ -50,13 +56,18 @@ class CGenerator implements IExecutionFlowGenerator {
 		}
 	}
 	
-	def protected initGenerationArtifacts(ExecutionFlow flow, GeneratorEntry entry, IGenArtifactConfigurations locations) {
+	def protected initGenerationArtifacts(ExecutionFlow it, GeneratorEntry entry, IGenArtifactConfigurations locations) {
 		locations.configure(flow.typesModule.h, entry.libraryOutput, types)
 		locations.configure(flow.module.h, entry.headerOutput, statemachineHeader)
 		locations.configure(flow.module.c, entry.sourceOutput, statemachineSource)
 		if (flow.timed || !flow.operations.empty || entry.tracingEnterState || entry.tracingExitState) {
 			locations.configure(flow.module.client.h, entry.headerOutput, statemachineRequiredHeader)
 		}
+		
+		if((sourceElement as Statechart).getAnnotationOfType(EVENT_DRIVEN_ANNOTATION) !== null) {
+			locations.configure(flow.eventsModule.h, entry.headerOutput, statechartEventsHeader)
+			locations.configure(flow.eventsModule.c, entry.sourceOutput, statechartEventsSource)
+		}
 	}
 	
 	def protected getHeaderOutput(GeneratorEntry entry) {

+ 4 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Naming.xtend

@@ -79,6 +79,10 @@ class Naming {
 	def typesModule(ExecutionFlow it) {
 		'sc_types'
 	}
+	
+	def eventsModule(ExecutionFlow it) {
+		'''«name»_events'''.toString
+	}
 
 	def timerType(ExecutionFlow it) {
 		'SCTimer'

+ 4 - 4
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Navigation.xtend

@@ -22,8 +22,6 @@ import org.yakindu.sct.model.stext.stext.OperationDefinition
 
 class Navigation extends SExecExtensions {
 	
-	
-	
 	def dispatch ExecutionFlow flow(Scope scope) {
 		if (scope.eContainer instanceof ExecutionFlow) scope.eContainer as ExecutionFlow
 		else null
@@ -41,13 +39,15 @@ class Navigation extends SExecExtensions {
 		it
 	}
 	
-	
 	def Scope scope(Declaration it) {
 		if (eContainer instanceof Scope) eContainer as Scope
 		else null
+	}
+	
+	def getAllEvents(ExecutionFlow it) {
+		return scopes.map[declarations.filter(EventDefinition)].reduce[i1, i2 | i1 + i2]
 	}
 	
-	
 	def hasValue (EventDefinition it) {
 		type != null && type.name != 'void'
 	}

+ 33 - 19
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineHeader.xtend

@@ -29,11 +29,11 @@ import static org.eclipse.xtext.util.Strings.*
 
 class StatemachineHeader implements IContentTemplate {
 
-	@Inject extension Naming cNaming
-	@Inject extension Navigation
-	@Inject extension ICodegenTypeSystemAccess
-	@Inject extension GenmodelEntries
-	@Inject extension INamingService
+	@Inject protected extension Naming cNaming
+	@Inject protected extension Navigation
+	@Inject protected extension ICodegenTypeSystemAccess
+	@Inject protected extension GenmodelEntries
+	@Inject protected extension INamingService
 	
 	@Inject
 	IGenArtifactConfigurations defaultConfigs
@@ -64,6 +64,19 @@ class StatemachineHeader implements IContentTemplate {
 		
 		«statemachineTypeDecl»
 		
+		«functions(it)»
+		
+		#ifdef __cplusplus
+		}
+		#endif 
+		
+		#endif /* «module.define»_H_ */
+	'''
+	}
+	
+	protected def CharSequence functions(ExecutionFlow it)
+		'''
+		
 		/*! Initializes the «type» state machine data structures. Must be called before first usage.*/
 		extern void «functionPrefix»init(«scHandleDecl»);
 		
@@ -100,13 +113,8 @@ class StatemachineHeader implements IContentTemplate {
 		/*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
 		extern sc_boolean «stateActiveFctID»(const «scHandleDecl», «statesEnumType» state);
 		
-		#ifdef __cplusplus
-		}
-		#endif 
-		
-		#endif /* «module.define»_H_ */
-	'''
-	}
+		'''
+	
 	/**
 	 * @Deprecated use {@link #includes(ExecutionFlow, ArtifactLocationProvider)} instead
 	 */
@@ -199,16 +207,22 @@ class StatemachineHeader implements IContentTemplate {
 		 */
 		typedef struct
 		{
-			«statesEnumType» stateConfVector[«type.toUpperCase»_MAX_ORTHOGONAL_STATES];
-			«IF hasHistory»«statesEnumType» historyVector[«type.toUpperCase»_MAX_HISTORY_STATES];«ENDIF»
-			sc_ushort stateConfVectorPosition; 
-			
-			«FOR iScope : scopes.filter[!typeRelevantDeclarations.empty]»
-				«iScope.type» «iScope.instance»;
-			«ENDFOR»			
+			«statemachineTypeStructContent»
 		} «type»;
 	'''
 	
+	def statemachineTypeStructContent(ExecutionFlow it) {
+		'''
+		«statesEnumType» stateConfVector[«type.toUpperCase»_MAX_ORTHOGONAL_STATES];
+		«IF hasHistory»«statesEnumType» historyVector[«type.toUpperCase»_MAX_HISTORY_STATES];«ENDIF»
+		sc_ushort stateConfVectorPosition; 
+		
+		«FOR iScope : scopes.filter[!typeRelevantDeclarations.empty]»
+			«iScope.type» «iScope.instance»;
+		«ENDFOR»
+		'''
+	}
+	
 	def stateConfVectorDefines(ExecutionFlow it) '''
 		«FOR state : states»
 		#define «state.stateVectorDefine» «state.stateVector.offset»

+ 92 - 64
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineSource.xtend

@@ -22,16 +22,17 @@ import org.yakindu.sct.model.sexec.naming.INamingService
 import org.yakindu.sct.model.sgen.GeneratorEntry
 import org.yakindu.sct.model.stext.stext.StatechartScope
 import org.yakindu.sct.model.stext.stext.VariableDefinition
+import org.yakindu.sct.model.stext.stext.EventDefinition
 
 class StatemachineSource implements IContentTemplate {
 	
-	@Inject extension Naming
-	@Inject extension GenmodelEntries
-	@Inject extension Navigation
-	@Inject extension ICodegenTypeSystemAccess
-	@Inject extension INamingService
-	@Inject extension FlowCode
-	@Inject extension ConstantInitializationResolver
+	@Inject protected extension Naming
+	@Inject protected extension GenmodelEntries
+	@Inject protected extension Navigation
+	@Inject protected extension ICodegenTypeSystemAccess
+	@Inject protected extension INamingService
+	@Inject protected extension FlowCode
+	@Inject protected extension ConstantInitializationResolver
 	@Inject protected extension StateVectorExtensions
 	
 	override content(ExecutionFlow it, GeneratorEntry entry, extension IGenArtifactConfigurations artifactConfigs) { 
@@ -53,6 +54,11 @@ class StatemachineSource implements IContentTemplate {
 		
 		«constantDefinitions»
 		
+		«functions»
+	'''
+	}
+	
+	def functions(ExecutionFlow it) '''
 		«initFunction»
 		
 		«enterFunction»
@@ -77,35 +83,40 @@ class StatemachineSource implements IContentTemplate {
 		
 		«functionImplementations»
 	'''
-	}
 	
 	def initFunction(ExecutionFlow it) '''
 		void «functionPrefix»init(«scHandleDecl»)
 		{
-			sc_integer i;
-
-			for (i = 0; i < «type.toUpperCase»_MAX_ORTHOGONAL_STATES; ++i)
-			{
-				«scHandle»->stateConfVector[i] = «null_state»;
-			}
-			
-			«IF hasHistory»
-			for (i = 0; i < «type.toUpperCase»_MAX_HISTORY_STATES; ++i)
-			{
-				«scHandle»->historyVector[i] = «null_state»;
-			}
-			«ENDIF»
-			
-			«scHandle»->stateConfVectorPosition = 0;
-		
-			«clearInEventsFctID»(handle);
-			«clearOutEventsFctID»(handle);
-		
-			«initSequence.code»
-		
+			«initFunctionBody(it)»
 		}
 	'''
 	
+	protected def CharSequence initFunctionBody(ExecutionFlow it) {
+		'''
+		sc_integer i;
+	
+		for (i = 0; i < «type.toUpperCase»_MAX_ORTHOGONAL_STATES; ++i)
+		{
+			«scHandle»->stateConfVector[i] = «null_state»;
+		}
+		
+		«IF hasHistory»
+		for (i = 0; i < «type.toUpperCase»_MAX_HISTORY_STATES; ++i)
+		{
+			«scHandle»->historyVector[i] = «null_state»;
+		}
+		«ENDIF»
+		
+		«scHandle»->stateConfVectorPosition = 0;
+	
+		«clearInEventsFctID»(handle);
+		«clearOutEventsFctID»(handle);
+	
+		«initSequence.code»
+		'''
+	}
+	
+	
 	def enterFunction(ExecutionFlow it) '''
 		void «functionPrefix»enter(«scHandleDecl»)
 		{
@@ -157,31 +168,36 @@ class StatemachineSource implements IContentTemplate {
 		{
 			
 			«clearOutEventsFctID»(«scHandle»);
-			
-			for («scHandle»->stateConfVectorPosition = 0;
-				«scHandle»->stateConfVectorPosition < «type.toUpperCase»_MAX_ORTHOGONAL_STATES;
-				«scHandle»->stateConfVectorPosition++)
-				{
-					
-				switch («scHandle»->stateConfVector[handle->stateConfVectorPosition])
+			«runCycleForLoop(it)»
+			«clearInEventsFctID»(«scHandle»);
+		}
+	'''
+	
+	protected def CharSequence runCycleForLoop(ExecutionFlow it)
+		'''
+		for («scHandle»->stateConfVectorPosition = 0;
+			«scHandle»->stateConfVectorPosition < «type.toUpperCase»_MAX_ORTHOGONAL_STATES;
+			«scHandle»->stateConfVectorPosition++)
+			{
+				
+			switch («scHandle»->stateConfVector[handle->stateConfVectorPosition])
+			{
+			«FOR state : states»
+				«IF state.reactSequence !== null»
+				case «state.shortName»:
 				{
-				«FOR state : states»
-					«IF state.reactSequence!=null»
-					case «state.shortName» :
-					{
-						«state.reactSequence.shortName»(«scHandle»);
-						break;
-					}
-					«ENDIF»
-				«ENDFOR»
-				default:
+					«state.reactSequence.shortName»(«scHandle»);
 					break;
 				}
+				«ENDIF»
+			«ENDFOR»
+			default:
+				break;
 			}
-			
-			«clearInEventsFctID»(«scHandle»);
 		}
-	'''
+		
+		'''
+	
 	
 	def raiseTimeEventFunction(ExecutionFlow it) '''
 		«IF timed»
@@ -257,28 +273,40 @@ class StatemachineSource implements IContentTemplate {
 	 * Implementation of interface element accessor functions
 	 */
 	
+	def interfaceIncomingEventRaiser(ExecutionFlow it, EventDefinition event) '''
+		void «event.asRaiser»(«scHandleDecl»«event.valueParams»)
+		{
+			«IF event.hasValue»
+			«event.valueAccess» = value;
+			«ENDIF»
+			«event.access» = bool_true;
+		}
+	'''
+	
+	def interfaceOutgoingEventGetter(ExecutionFlow it, EventDefinition event) '''
+		sc_boolean «event.asRaised»(const «scHandleDecl»)
+		{
+			return «event.access»;
+		}
+	'''
+	
+	def interfaceOutgoingEventValueGetter(ExecutionFlow it, EventDefinition event) '''
+		«event.typeSpecifier.targetLanguageName» «event.asGetter»(const «scHandleDecl»)
+		{
+			return «event.valueAccess»;
+		}
+	'''
+	
 	def interfaceFunctions(ExecutionFlow it) '''
 		«FOR scope : interfaceScopes»
 			«FOR event : scope.incomingEvents»
-				void «event.asRaiser»(«scHandleDecl»«event.valueParams»)
-				{
-					«IF event.hasValue»
-					«event.valueAccess» = value;
-					«ENDIF»
-					«event.access» = bool_true;
-				}
+				«interfaceIncomingEventRaiser(event)»
 			«ENDFOR»
 			
 			«FOR event : scope.outgoingEvents»
-				sc_boolean «event.asRaised»(const «scHandleDecl»)
-				{
-					return «event.access»;
-				}
+				«interfaceOutgoingEventGetter(event)»
 				«IF event.hasValue» 
-					«event.typeSpecifier.targetLanguageName» «event.asGetter»(const «scHandleDecl»)
-					{
-						return «event.valueAccess»;
-					}
+					«interfaceOutgoingEventValueGetter(event)»
 				«ENDIF»
 			«ENDFOR»
 			

+ 40 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/EventDrivenExpressionCode.xtend

@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.c.eventdriven
+
+import com.google.inject.Inject
+import org.yakindu.base.types.Direction
+import org.yakindu.sct.generator.c.ExpressionCode
+import org.yakindu.sct.model.stext.stext.EventRaisingExpression
+
+/**
+ * @author René Beckmann
+ */
+class EventDrivenExpressionCode extends ExpressionCode {
+	@Inject extension EventNaming
+	
+	protected static int valueVarIndex = 0
+	
+	override dispatch CharSequence code(EventRaisingExpression it) {
+		val valueVarName = '''value_«valueVarIndex++»'''
+		'''
+		«IF event.definition.event.direction != Direction::LOCAL»
+			«IF value !== null»
+				«event.definition.event.valueAccess» = «value.code»;
+			«ENDIF»
+			«event.definition.event.access» = bool_true«ELSE»
+			«IF value !== null»
+			«event.definition.event.typeSpecifier.targetLanguageName» «valueVarName» = «value.code»;
+			«functionPrefix(flow)»add_value_event_to_queue(«scHandle», «event.definition.event.eventEnumMemberName», «valueVarName»)
+			«ELSE»
+			«functionPrefix(flow)»add_event_to_queue(«scHandle», «event.definition.event.eventEnumMemberName»)«ENDIF»«ENDIF»'''
+	}
+}

+ 40 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/EventDrivenStatemachineHeader.xtend

@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.c.eventdriven
+
+import com.google.inject.Inject
+import org.yakindu.sct.generator.c.IGenArtifactConfigurations
+import org.yakindu.sct.generator.c.StatemachineHeader
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgen.GeneratorEntry
+
+class EventDrivenStatemachineHeader extends StatemachineHeader {
+	@Inject extension EventNaming
+	
+	override statemachineTypeStructContent(ExecutionFlow it) {
+		'''
+		«super.statemachineTypeStructContent(it)»
+		«eventQueueTypeName» internal_event_queue;
+		'''
+	}
+	
+	override includes(ExecutionFlow it, extension IGenArtifactConfigurations artifactConfigs) {
+		'''
+		«super.includes(it, artifactConfigs)»
+		#include "«eventsModule.h»"
+		'''
+	}
+	
+	override protected functions(ExecutionFlow it) {
+		super.functions(it).toString.replace('''const «scHandleDecl», sc_eventid evid''','''«scHandleDecl», sc_eventid evid''')
+	}
+	
+}

+ 139 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/EventDrivenStatemachineSource.xtend

@@ -0,0 +1,139 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.c.eventdriven
+
+import com.google.inject.Inject
+import org.yakindu.base.types.Direction
+import org.yakindu.sct.generator.c.StatemachineSource
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.stext.StatechartScope
+
+/**
+ * @author René Beckmann
+ */
+class EventDrivenStatemachineSource extends StatemachineSource {
+	@Inject extension EventNaming
+	
+	override protected initFunctionBody(ExecutionFlow it) {
+		'''
+		«super.initFunctionBody(it)»
+		«eventQueueInitFunction»(&(handle->internal_event_queue));
+		'''
+	}
+	
+	override functions(ExecutionFlow it) '''
+		«super.functions(it)»
+		«addToEventQueueFunction»
+		
+		«addToEventQueueValueFunction»
+		
+		«dispatchEventFunction»
+	'''
+	
+	override enterFunction(ExecutionFlow it) '''
+		void «functionPrefix»enter(«scHandleDecl»)
+		{
+			«enterSequences.defaultSequence.code»
+		}
+	'''
+	
+	override interfaceIncomingEventRaiser(ExecutionFlow it, EventDefinition event) '''
+		void «event.asRaiser»(«scHandleDecl»«event.valueParams»)
+		{
+			«IF event.hasValue»
+			«event.valueAccess» = value;
+			«ENDIF»
+			«event.access» = bool_true;
+			
+			«functionPrefix»runCycle(«scHandle»);
+		}
+	'''
+	
+	def dispatchEventFunction(ExecutionFlow it) '''
+		static void «functionPrefix»dispatch_event(«scHandleDecl», const «eventStructTypeName» * event) {
+			switch(event->name) {
+				«FOR s : scopes.filter(StatechartScope)»
+					«FOR e : s.declarations.filter(EventDefinition).filter[direction == Direction::LOCAL]»
+					case «e.eventEnumMemberName»:
+					{
+						«e.access» = bool_true;
+						«IF e.hasValue»
+						«e.valueAccess» = event->value.«e.eventEnumMemberName»_value;
+						«ENDIF»
+						break;
+					}
+					«ENDFOR»
+				«ENDFOR»
+				default:
+					break;
+			}
+		}
+	'''
+	
+	def addToEventQueueFunction(ExecutionFlow it) '''
+	static void «functionPrefix»add_event_to_queue(«scHandleDecl», «eventEnumName» name)
+	{
+		«eventStructTypeName» event;
+		«eventInitFunction»(&event, name);
+		«eventQueuePushFunction»(&(handle->internal_event_queue), event);
+	}
+	'''
+	
+	def addToEventQueueValueFunction(ExecutionFlow it) '''
+	static void «functionPrefix»add_value_event_to_queue(«scHandleDecl», «eventEnumName» name, void * value) 
+	{
+		«eventStructTypeName» event;
+		«valueEventInitFunction»(&event, name, value);
+		«eventQueuePushFunction»(&(handle->internal_event_queue), event);
+	}
+	'''
+	
+	override runCycleFunction(ExecutionFlow it)  '''
+		void «functionPrefix»runCycle(«scHandleDecl»)
+		{
+			«clearOutEventsFctID»(«scHandle»);
+			
+			«eventStructTypeName» currentEvent = «eventQueuePopFunction»(&(«scHandle»->internal_event_queue));
+			
+			do {
+				«functionPrefix»dispatch_event(«scHandle», &currentEvent);
+				«runCycleForLoop»
+				«clearInEventsFctID»(«scHandle»);
+			} while((currentEvent = «eventQueuePopFunction»(&(«scHandle»->internal_event_queue))).name != invalid_event);
+			
+		}
+	'''
+	
+	override raiseTimeEventFunction(ExecutionFlow it) '''
+		«IF timed»
+			void «raiseTimeEventFctID»(«scHandleDecl», sc_eventid evid)
+			{
+				if ( ((sc_intptr_t)evid) >= ((sc_intptr_t)&(«scHandle»->timeEvents))
+					&&  ((sc_intptr_t)evid) < ((sc_intptr_t)&(«scHandle»->timeEvents)) + sizeof(«timeEventScope.type»))
+					{
+					*(sc_boolean*)evid = bool_true;
+					
+					«functionPrefix»runCycle(«scHandle»);
+				}		
+			}
+		«ENDIF»
+		'''
+
+	override functionPrototypes(ExecutionFlow it) {
+		'''
+		«super.functionPrototypes(it)»
+		static void «functionPrefix»add_event_to_queue(«scHandleDecl», «eventEnumName» name);
+		static void «functionPrefix»dispatch_event(«scHandleDecl», const «eventStructTypeName» * event);
+		static void «functionPrefix»add_value_event_to_queue(«scHandleDecl», «eventEnumName» name, void * value);
+		'''
+	}
+}

+ 75 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/EventNaming.xtend

@@ -0,0 +1,75 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.c.eventdriven
+
+import com.google.inject.Inject
+import org.yakindu.base.types.Event
+import org.yakindu.sct.generator.c.Naming
+import org.yakindu.sct.generator.c.Navigation
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.naming.INamingService
+
+/**
+ * @author René Beckmann
+ */
+class EventNaming {
+	@Inject extension Naming
+	@Inject extension Navigation
+	@Inject extension INamingService
+	
+	def eventEnumMemberName(Event it) {
+		'''«scope.functionPrefix»_«name.asIdentifier»'''
+	}
+	
+	def eventEnumName(ExecutionFlow it) {
+		'''«module»_event_name'''.toString.toLowerCase
+	}
+	
+	def eventValueUnionName(ExecutionFlow it) {
+		'''«module»_event_value'''.toString.toLowerCase
+	}
+	
+	def eventStructTypeName(ExecutionFlow it) {
+		'''«name»_event'''.toString.toLowerCase
+	}
+	
+	def eventQueueTypeName(ExecutionFlow it) {
+		'''«name»_eventqueue'''.toString.toLowerCase
+	}
+	
+	def eventInitFunction(ExecutionFlow it) {
+		'''«eventStructTypeName»_init'''
+	}
+	
+	def valueEventInitFunction(ExecutionFlow it) {
+		'''«eventStructTypeName»_value_init'''
+	}
+	
+	def eventQueueInitFunction(ExecutionFlow it) {
+		'''«eventQueueTypeName»_init'''
+	}
+	
+	def eventQueueSizeFunction(ExecutionFlow it) {
+		'''«eventQueueTypeName»_size'''
+	}
+	
+	def eventQueuePopFunction(ExecutionFlow it) {
+		'''«eventQueueTypeName»_pop'''
+	}
+	
+	def eventQueuePushFunction(ExecutionFlow it) {
+		'''«eventQueueTypeName»_push'''
+	}
+	
+	def bufferSize(ExecutionFlow it) {
+		'''«name»_eventqueue_buffersize'''.toString.toUpperCase
+	}
+}

+ 147 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/StatechartEventsHeader.xtend

@@ -0,0 +1,147 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.c.eventdriven
+
+import com.google.inject.Inject
+import org.yakindu.base.types.Direction
+import org.yakindu.sct.generator.c.IContentTemplate
+import org.yakindu.sct.generator.c.IGenArtifactConfigurations
+import org.yakindu.sct.generator.c.Naming
+import org.yakindu.sct.generator.c.Navigation
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.naming.INamingService
+import org.yakindu.sct.model.sgen.GeneratorEntry
+
+/**
+ * @author René Beckmann
+ */
+class StatechartEventsHeader implements IContentTemplate {
+	@Inject protected extension Naming
+	@Inject protected extension Navigation
+	@Inject protected extension ICodegenTypeSystemAccess
+	@Inject protected extension INamingService
+	
+	@Inject extension
+	IGenArtifactConfigurations defaultConfigs
+	
+	@Inject extension EventNaming eventNaming
+	
+	protected GeneratorEntry entry
+	
+	protected static final int BUFFER_SIZE = 20
+	
+	override content(ExecutionFlow it, GeneratorEntry entry, IGenArtifactConfigurations locations) {
+		this.entry = entry
+		'''
+		#ifndef «generateHeaderDefineGuard»
+		#define «generateHeaderDefineGuard»
+		
+		#include "«(typesModule.h).relativeTo(module.h)»"
+		
+		#ifndef «bufferSize»
+		#define «bufferSize» «BUFFER_SIZE»
+		#endif
+		
+		«generateEventsEnum»
+		
+		«generateEventValueUnion»
+		
+		«generateEventStruct»
+		
+		«generateEventQueue»
+		
+		«eventFunctionPrototypes»
+		
+		«eventQueueFunctionPrototypes»
+
+		#endif /* «generateHeaderDefineGuard» */
+		'''
+	}
+	
+	def generateEventsEnum(ExecutionFlow it) {
+		'''
+		/*
+		 * Enum of event names in the statechart.
+		 */
+		typedef enum  {
+			invalid_event,
+			«FOR e : getAllEvents SEPARATOR ","»
+				«eventEnumMemberName(e)»
+			«ENDFOR»
+		} «eventEnumName»;
+		'''
+	}
+	
+	def generateEventValueUnion(ExecutionFlow it) {
+		'''
+		/*
+		 * Union of all possible event value types.
+		 */
+		typedef union {
+			«FOR e : getAllEvents.filter[hasValue && direction != Direction::OUT]»
+			«e.typeSpecifier.targetLanguageName» «eventEnumMemberName(e)»_value;
+			«ENDFOR»
+		} «eventValueUnionName»;
+		'''
+	}
+	
+	def generateEventStruct(ExecutionFlow it) {
+		'''
+		/*
+		 * Struct that represents a single event.
+		 */
+		typedef struct {
+			«eventEnumName» name;
+			sc_boolean has_value;
+			«eventValueUnionName» value;
+		} «eventStructTypeName»;
+		'''
+	}
+
+	def generateEventQueue(ExecutionFlow it) {
+		'''
+		/*
+		 * Queue that holds the raised events.
+		 */
+		typedef struct «eventQueueTypeName»_s {
+			«eventStructTypeName» events[«bufferSize»];
+			sc_integer pop_index;
+			sc_integer push_index;
+			sc_integer size;
+		} «eventQueueTypeName»;
+		'''
+	}
+	
+	def eventFunctionPrototypes(ExecutionFlow it) {
+		'''
+		void «eventInitFunction»(«eventStructTypeName» * ev, «eventEnumName» name);
+
+		void «valueEventInitFunction»(«eventStructTypeName» * ev, «eventEnumName» name, void * value);
+		'''
+	}
+	
+	def eventQueueFunctionPrototypes(ExecutionFlow it) {
+		'''
+		void «eventQueueInitFunction»(«eventQueueTypeName» * eq);
+		
+		sc_integer «eventQueueSizeFunction»(«eventQueueTypeName» * eq);
+		
+		«eventStructTypeName» «eventQueuePopFunction»(«eventQueueTypeName» * eq);
+		
+		sc_boolean «eventQueuePushFunction»(«eventQueueTypeName» * eq, «eventStructTypeName» ev);
+		'''
+	}
+	
+	def generateHeaderDefineGuard(ExecutionFlow it) {
+		'''SCT_EVENTS_«name.toUpperCase»_H'''
+	}
+}

+ 124 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/eventdriven/StatechartEventsSource.xtend

@@ -0,0 +1,124 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.c.eventdriven
+
+import com.google.inject.Inject
+import org.yakindu.sct.generator.c.IContentTemplate
+import org.yakindu.sct.generator.c.IGenArtifactConfigurations
+import org.yakindu.sct.generator.c.Naming
+import org.yakindu.sct.generator.c.Navigation
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgen.GeneratorEntry
+
+/**
+ * @author René Beckmann
+ */
+class StatechartEventsSource implements IContentTemplate {
+	@Inject extension Navigation
+	@Inject extension Naming
+	@Inject extension EventNaming
+	@Inject protected extension ICodegenTypeSystemAccess
+	
+	override content(ExecutionFlow it, GeneratorEntry entry, IGenArtifactConfigurations locations) {
+		'''
+		#include "«eventsModule.h»"
+		
+		«eventFunctions»
+		
+		«eventQueueFunctions»
+		'''
+	}
+	
+	def eventFunctions(ExecutionFlow it) {
+		'''
+		void «eventInitFunction»(«eventStructTypeName» * ev, «eventEnumName» name)
+		{
+			ev->name = name;
+			ev->has_value = false;
+		}
+		
+		void «valueEventInitFunction»(«eventStructTypeName» * ev, «eventEnumName» name, void * value)
+		{
+			ev->name = name;
+			ev->has_value = true;
+			
+			switch(name)
+			{
+				«FOR e : getAllEvents.filter[hasValue]»
+				case «e.eventEnumMemberName»:
+					ev->value.«e.eventEnumMemberName»_value = *((«e.typeSpecifier.targetLanguageName»*)value);
+					break;
+				«ENDFOR»
+				default:
+					break;
+			}
+		}
+		'''
+	}
+	
+	def eventQueueFunctions(ExecutionFlow it) {
+		'''
+		void «eventQueueInitFunction»(«eventQueueTypeName» * eq)
+		{
+			eq->push_index = 0;
+			eq->pop_index = 0;
+			eq->size = 0;
+		}
+		
+		sc_integer «eventQueueSizeFunction»(«eventQueueTypeName» * eq)
+		{
+			return eq->size;
+		}
+		
+		«eventStructTypeName» «eventQueuePopFunction»(«eventQueueTypeName» * eq)
+		{
+			«eventStructTypeName» event;
+			if(«eventQueueSizeFunction»(eq) <= 0) {
+				«eventInitFunction»(&event, invalid_event);
+			}
+			else {
+				event = eq->events[eq->pop_index];
+				
+				if(eq->pop_index < «bufferSize» - 1) {
+					eq->pop_index++;
+				} 
+				else {
+					eq->pop_index = 0;
+				}
+				eq->size--;
+			}
+			return event;
+		}
+		
+		sc_boolean «eventQueuePushFunction»(«eventQueueTypeName» * eq, «eventStructTypeName» ev)
+		{
+			if(«eventQueueSizeFunction»(eq) == «bufferSize») {
+				return false;
+			}
+			else {
+				eq->events[eq->push_index] = ev;
+				
+				if(eq->push_index < «bufferSize» - 1) {
+					eq->push_index++;
+				}
+				else {
+					eq->push_index = 0;
+				}
+				eq->size++;
+				
+				return true;
+			}
+		}
+		'''
+	}
+	
+}

+ 2 - 1
plugins/org.yakindu.sct.generator.cpp/META-INF/MANIFEST.MF

@@ -7,7 +7,8 @@ Require-Bundle: org.yakindu.sct.model.sexec,
  org.yakindu.sct.model.stext,
  org.yakindu.sct.generator.core,
  org.yakindu.sct.generator.genmodel,
- org.yakindu.sct.generator.c
+ org.yakindu.sct.generator.c,
+ org.yakindu.sct.model.stext.lib
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Export-Package: org.yakindu.sct.generator.cpp
 Bundle-Vendor: statecharts.org

+ 21 - 1
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGeneratorModule.java

@@ -12,18 +12,25 @@ package org.yakindu.sct.generator.cpp;
 
 import static org.yakindu.sct.generator.cpp.features.CPPFeatureConstants.FEATURE_INCLUDES;
 import static org.yakindu.sct.generator.cpp.features.CPPFeatureConstants.PARAMETER_INCLUDES_USE_RELATIVE_PATHS;
+import static org.yakindu.sct.model.stext.lib.StatechartAnnotations.EVENT_DRIVEN_ANNOTATION;
 
+import org.yakindu.base.types.Annotation;
 import org.yakindu.base.types.inferrer.ITypeSystemInferrer;
 import org.yakindu.sct.generator.c.DefaultGenArtifactConfigurations;
 import org.yakindu.sct.generator.c.IGenArtifactConfigurations;
 import org.yakindu.sct.generator.c.SimpleGenArtifactConfigurations;
 import org.yakindu.sct.generator.c.types.CTypeSystemAccess;
-import org.yakindu.sct.generator.core.IGeneratorModule;
 import org.yakindu.sct.generator.core.IExecutionFlowGenerator;
+import org.yakindu.sct.generator.core.IGeneratorModule;
 import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess;
+import org.yakindu.sct.generator.cpp.eventdriven.EventDrivenEventCode;
+import org.yakindu.sct.generator.cpp.eventdriven.EventDrivenExpressionCode;
+import org.yakindu.sct.generator.cpp.eventdriven.EventDrivenStatemachineHeader;
+import org.yakindu.sct.generator.cpp.eventdriven.EventDrivenStatemachineImplementation;
 import org.yakindu.sct.model.sexec.naming.INamingService;
 import org.yakindu.sct.model.sgen.FeatureParameterValue;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgraph.Statechart;
 import org.yakindu.sct.model.stext.inferrer.STextTypeInferrer;
 
 import com.google.inject.Binder;
@@ -42,6 +49,7 @@ public class CppCodeGeneratorModule implements IGeneratorModule {
 		binder.bind(ICodegenTypeSystemAccess.class).to(CTypeSystemAccess.class);
 		binder.bind(INamingService.class).to(CppNamingService.class);
 		binder.bind(ITypeSystemInferrer.class).to(STextTypeInferrer.class);
+		bindEventDrivenClasses(entry, binder);
 		bindIGenArtifactConfigurations(entry, binder);
 	}
 	
@@ -55,5 +63,17 @@ public class CppCodeGeneratorModule implements IGeneratorModule {
 			binder.bind(IGenArtifactConfigurations.class).to(SimpleGenArtifactConfigurations.class);
 		}
 	}
+	
+	protected void bindEventDrivenClasses(GeneratorEntry entry, Binder binder) {
+		Statechart statechart = (Statechart) entry.getElementRef();
+		Annotation eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
+		
+		if(eventDrivenAnnotation != null) {
+			binder.bind(StatemachineHeader.class).to(EventDrivenStatemachineHeader.class);
+			binder.bind(StatemachineImplementation.class).to(EventDrivenStatemachineImplementation.class);
+			binder.bind(ExpressionCode.class).to(EventDrivenExpressionCode.class);
+			binder.bind(EventCode.class).to(EventDrivenEventCode.class);
+		}
+	}
 
 }

+ 31 - 16
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppGenerator.xtend

@@ -16,10 +16,13 @@ import org.yakindu.sct.generator.c.IGenArtifactConfigurations
 import org.yakindu.sct.generator.c.IGenArtifactConfigurations.GenArtifactConfiguration
 import org.yakindu.sct.generator.core.IExecutionFlowGenerator
 import org.yakindu.sct.generator.core.library.ICoreLibraryHelper
+import org.yakindu.sct.generator.cpp.eventdriven.StatechartEvents
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.yakindu.sct.model.sgraph.Statechart
 
 import static org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess.*
+import static org.yakindu.sct.model.stext.lib.StatechartAnnotations.*
 
 /**
  * This is the CPP code generators main class. 
@@ -27,46 +30,58 @@ import static org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess.*
  * @author Markus Mühlbrandt
  */
 class CppGenerator implements IExecutionFlowGenerator {
-	 
+
 	@Inject extension Types typesContent
 	@Inject extension TimedStatemachineInterface timedStatemachineInterfaceContent
 	@Inject extension TimerInterface timerInterfaceContent
 	@Inject extension StatemachineInterface statemachineInterfaceContent
 	@Inject extension StatemachineHeader statemachineHeaderContent
 	@Inject extension StatemachineImplementation statemachineSourceContent
+	@Inject extension StatechartEvents statechartEvents
 	@Inject extension Navigation
 	@Inject extension Naming
 	@Inject extension ICoreLibraryHelper
-	
+
 	@Inject
 	IGenArtifactConfigurations locations
-	
+
 	override generate(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
 		initGenerationArtifacts(flow, entry, locations)
 		generateArtifacts(flow, entry, fsa, locations);
 	}
-	
-	def generateArtifacts(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa, IGenArtifactConfigurations locations) {
+
+	def generateArtifacts(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa,
+		IGenArtifactConfigurations locations) {
 		for (GenArtifactConfiguration a : locations.configurations) {
 			fsa.generateFile(a.getName, a.getOutputName, a.getContentTemplate.content(flow, entry, locations))
 		}
 	}
-	
+
 	def initGenerationArtifacts(ExecutionFlow flow, GeneratorEntry entry, IGenArtifactConfigurations locations) {
 		locations.configure(flow.typesModule.h, entry.libraryOutput, typesContent)
 		locations.configure(statemachineInterface.h, entry.libraryOutput, statemachineInterfaceContent)
-		
+
 		if (flow.timed) {
-				locations.configure(timedStatemachineInterface.h, entry.libraryOutput, timedStatemachineInterfaceContent)
-				locations.configure(timerInterface.h, entry.libraryOutput, timerInterfaceContent)
+			locations.configure(timedStatemachineInterface.h, entry.libraryOutput, timedStatemachineInterfaceContent)
+			locations.configure(timerInterface.h, entry.libraryOutput, timerInterfaceContent)
+		}
+
+		if (flow.isEventDriven) {
+			locations.configure(flow.eventClasses.h, entry.sourceOutput, statechartEvents)
 		}
-		
 		locations.configure(flow.module.h, entry.headerOutput, statemachineHeaderContent)
 		locations.configure(flow.module.cpp, entry.sourceOutput, statemachineSourceContent)
 	}
-	
+
+	def isEventDriven(ExecutionFlow it) {
+		val statechart = sourceElement as Statechart
+
+		val eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION)
+		return eventDrivenAnnotation !== null
+	}
+
 	def protected getHeaderOutput(GeneratorEntry entry) {
-		if (entry.apiTargetFolderValue != null) {
+		if (entry.apiTargetFolderValue !== null) {
 			API_TARGET_FOLDER_OUTPUT
 		} else {
 			TARGET_FOLDER_OUTPUT
@@ -74,15 +89,15 @@ class CppGenerator implements IExecutionFlowGenerator {
 	}
 
 	def protected getLibraryOutput(GeneratorEntry entry) {
-		if (entry.libraryTargetFolderValue != null) {
+		if (entry.libraryTargetFolderValue !== null) {
 			LIBRARY_TARGET_FOLDER_OUTPUT
 		} else {
 			entry.headerOutput
 		}
 	}
-	
+
 	def protected getSourceOutput(GeneratorEntry entry) {
 		TARGET_FOLDER_OUTPUT
 	}
-	
-}
+
+}

+ 117 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/EventCode.xtend

@@ -0,0 +1,117 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.cpp
+
+import com.google.inject.Inject
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.stext.StatechartScope
+
+/**
+ * @author René Beckmann
+ */
+class EventCode {
+	@Inject protected extension Naming
+	@Inject protected extension Navigation
+	@Inject protected extension ICodegenTypeSystemAccess
+	
+	def generateEvents(ExecutionFlow it, StatechartScope scope)
+		'''
+			«FOR event : scope.incomingEvents»
+					«generateEventComment(event, scope)»
+					«generateInterfaceEventRaiser(it, event, scope)»
+					«IF scope.defaultInterface»
+						«generateDefaultInterfaceEventRaiser(it, event, scope)»
+					«ENDIF»
+			«ENDFOR»
+			«FOR event : scope.outgoingEvents»
+				«generateEventComment(event, scope)»
+				«generateInterfaceEventRaised(it, event, scope)»
+				«IF scope.defaultInterface»
+					«generateDefaultInterfaceEventRaised(it, event, scope)»
+				«ENDIF»
+				«IF event.hasValue»
+					«generateEventValueGetter(it, event, scope)»
+					«IF scope.defaultInterface»
+						«generateEventGetter(it, event, scope)»
+					«ENDIF»
+				«ENDIF»
+			«ENDFOR»
+			«FOR event : scope.localEvents»
+				«generateEventComment(event, scope)»
+				«generateInterfaceEventRaiser(it, event, scope)»
+				«generateInterfaceEventRaised(it, event, scope)»
+				«IF event.hasValue» 
+					«generateEventValueGetter(it, event, scope)»
+				«ENDIF»
+			«ENDFOR»
+		'''
+		
+	protected def CharSequence generateEventGetter(ExecutionFlow it, EventDefinition event, StatechartScope scope)
+		'''
+			«event.typeSpecifier.targetLanguageName» «module»::«event.asGetter»() const
+			{
+				return «scope.instance».«event.asGetter»();
+			}
+		'''
+	
+	
+	protected def CharSequence generateEventValueGetter(ExecutionFlow it, EventDefinition event, StatechartScope scope)
+		'''
+			«event.typeSpecifier.targetLanguageName» «module»::«scope.interfaceName»::«event.asGetter»() const
+			{
+				return «event.localValueAccess»;
+			}
+		'''
+	
+	
+	protected def CharSequence generateDefaultInterfaceEventRaised(ExecutionFlow it, EventDefinition event, StatechartScope scope)
+		'''
+			sc_boolean «module»::«event.asRaised»() const
+			{
+				return «scope.instance».«event.asRaised»();
+			}
+		'''
+	
+	
+	protected def CharSequence generateInterfaceEventRaised(ExecutionFlow it, EventDefinition event, StatechartScope scope)
+		'''
+			sc_boolean «module»::«scope.interfaceName»::«event.asRaised»() const
+			{
+				return «event.localAccess»;
+			}
+		'''
+		
+	
+	protected def CharSequence generateDefaultInterfaceEventRaiser(ExecutionFlow it, EventDefinition event, StatechartScope scope)
+		'''
+			void «module»::«event.asRaiser»(«event.valueParams»)
+			{
+				«scope.instance».«event.asRaiser»(«IF event.hasValue»value«ENDIF»);
+			}
+		'''
+	
+	
+	protected def CharSequence generateInterfaceEventRaiser(ExecutionFlow it, EventDefinition event, StatechartScope scope)
+		'''
+			void «module»::«scope.interfaceName»::«event.asRaiser»(«event.valueParams»)
+			{
+				«IF event.hasValue»
+				«event.localValueAccess» = value;
+				«ENDIF»
+				«event.localAccess» = true;
+			}
+		'''
+	
+	protected def CharSequence generateEventComment(EventDefinition it, StatechartScope scope)
+		'''/* Functions for event «name» in interface «scope.interfaceName» */'''
+}

+ 4 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Naming.xtend

@@ -59,6 +59,10 @@ class Naming extends org.yakindu.sct.generator.c.Naming {
 	def timerInterface() {
 		'TimerInterface'
 	}
+	
+	def eventClasses(ExecutionFlow it) {
+		'''«name.toFirstUpper»_Events'''.toString
+	}
 
 	def timerInstance() {
 		'timer'

+ 7 - 2
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Navigation.xtend

@@ -10,11 +10,12 @@
 */
 package org.yakindu.sct.generator.cpp
 
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.TimeEvent
 import org.yakindu.sct.model.sgraph.Scope
+import org.yakindu.sct.model.stext.stext.ImportScope
 import org.yakindu.sct.model.stext.stext.OperationDefinition
-import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.stext.stext.StatechartScope
-import org.yakindu.sct.model.sexec.TimeEvent
 
 class Navigation extends org.yakindu.sct.generator.c.Navigation {
 	
@@ -33,4 +34,8 @@ class Navigation extends org.yakindu.sct.generator.c.Navigation {
 	def indexOf(TimeEvent it) {
 		scope.declarations.filter(typeof(TimeEvent)).toList.indexOf(it);
 	}
+	
+	def getInterfaces(ExecutionFlow it) {
+		scopes.filter(typeof(StatechartScope)).filter[!(it instanceof ImportScope)]
+	}
 }

+ 78 - 40
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend

@@ -13,6 +13,7 @@ package org.yakindu.sct.generator.cpp
 import com.google.inject.Inject
 import java.util.List
 import org.eclipse.xtend2.lib.StringConcatenation
+import org.yakindu.base.types.Declaration
 import org.yakindu.base.types.Direction
 import org.yakindu.sct.generator.c.IGenArtifactConfigurations
 import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
@@ -32,35 +33,57 @@ import org.yakindu.sct.model.stext.stext.ImportScope
 
 class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader {
 
-	@Inject extension Naming
-	@Inject extension Navigation
-	@Inject extension ICodegenTypeSystemAccess
-	@Inject extension GenmodelEntriesExtension
-	@Inject extension INamingService
+	@Inject protected extension Naming
+	@Inject protected extension Navigation
+	@Inject protected extension ICodegenTypeSystemAccess
+	@Inject protected extension GenmodelEntriesExtension
+	@Inject protected extension INamingService
 
 	protected GeneratorEntry entry
 
 	override content(ExecutionFlow it, GeneratorEntry entry, extension IGenArtifactConfigurations artifactConfigs) {
 		this.entry = entry
-	'''
-		«entry.licenseText»
-		
-		#ifndef «module().define»_H_
-		#define «module().define»_H_
-		
-		«includes(artifactConfigs)»
-		
-		/*! \file Header of the state machine '«name»'.
-		*/
-		
-		/*! Define indices of states in the StateConfVector */
-		«FOR state : states»
-		#define «state.stateVectorDefine» «state.stateVector.offset»
-		«ENDFOR»
-		
-		class «module» : «interfaceExtensions»
-		{
+		'''
+			«entry.licenseText»
+			
+			#ifndef «module().define»_H_
+			#define «module().define»_H_
+			
+			«includes(artifactConfigs)»
+			#include <deque>
+			#include <functional>
+			
+			/*! \file Header of the state machine '«name»'.
+			*/
+			
+			/*! Define indices of states in the StateConfVector */
+			«FOR state : states»
+				#define «state.stateVectorDefine» «state.stateVector.offset»
+			«ENDFOR»
+			
+			«generateClass(artifactConfigs)»
 			
+			
+			«IF !entry.useStaticOPC»
+				«scopes.filter(typeof(StatechartScope)).map[createInlineOCB_Destructor].filterNullOrEmptyAndJoin»
+			«ENDIF»
+			#endif /* «module().define»_H_ */
+		'''
+	}
+	
+	def protected generateClass(ExecutionFlow it, extension IGenArtifactConfigurations artifactConfigs) {
+		'''
+			class «module» : «interfaceExtensions»
+			{
+				«generatePublicClassmembers»
+				«generateInnerClasses»
+				«generatePrivateClassmembers»
+			};
+		'''
+	}
+
+	def protected generatePublicClassmembers(ExecutionFlow it) {
+		'''
 			public:
 				
 				«module»();
@@ -75,7 +98,12 @@ class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader
 				
 				/*! Checks if the specified state is active (until 2.4.1 the used method for states was calles isActive()). */
 				sc_boolean «stateActiveFctID»(«statesEnumType» state) const;
-			
+				
+		'''
+	}
+
+	def protected generateInnerClasses(ExecutionFlow it) {
+		'''
 			«entry.innerClassVisibility»:
 			
 				«FOR s : scopes.filter(typeof(InternalScope))»«s.createInterface»«ENDFOR»
@@ -83,14 +111,14 @@ class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader
 				«statemachineTypeDecl»
 				
 				«prototypes»
-		};
-		«IF !entry.useStaticOPC»
-			«scopes.filter(typeof(StatechartScope)).map[createInlineOCB_Destructor].filterNullOrEmptyAndJoin»
-		«ENDIF»
-		#endif /* «module().define»_H_ */
-	'''
+				
+		'''
 	}
 	
+	def protected generatePrivateClassmembers(ExecutionFlow it) {
+		''''''
+	}
+
 	override includes(ExecutionFlow it, extension IGenArtifactConfigurations artifactConfigs) '''
 		#include "«(typesModule.h).relativeTo(module.h)»"
 		#include "«(statemachineInterface.h).relativeTo(module.h)»"
@@ -158,20 +186,30 @@ class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader
 				«ENDFOR»
 				
 			«entry.innerClassVisibility»:
-				friend class «scope.execution_flow.module()»;
-				«FOR d : scope.declarations»
-					«d.scopeTypeDeclMember»
-				«ENDFOR»
+				«protectedInnerClassMembers(scope)»
 		};
 	'''
+	
+	protected def CharSequence protectedInnerClassMembers(StatechartScope scope)
+		'''
+			friend class «scope.execution_flow.module()»;
+			«FOR d : scope.declarations»
+				«d.privateFunctionPrototypes»
+				«d.scopeTypeDeclMember»
+			«ENDFOR»
+		'''
+	
 
+	def dispatch privateFunctionPrototypes(Declaration it) {
+		''''''	
+	}
+	
 	override dispatch scopeTypeDeclMember(VariableDefinition it) '''
 		«IF type.name != 'void'»«IF const»static const «ENDIF»«typeSpecifier.targetLanguageName» «name.asEscapedIdentifier»;«ENDIF»
 	'''
 
 	def createOCBInterface(StatechartScope scope) {
 		'''
-			
 			«IF scope.hasOperations»
 				//! Inner class for «scope.simpleName» interface scope operation callbacks.
 				class «scope.interfaceOCBName»
@@ -198,7 +236,7 @@ class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader
 		//! the maximum number of orthogonal states defines the dimension of the state configuration vector.
 		static const sc_integer «orthogonalStatesConst» = «stateVector.size»;
 		«IF hasHistory»
-		//! dimension of the state configuration vector for history states
+			//! dimension of the state configuration vector for history states
 		static const sc_integer «historyStatesConst» = «historyVector.size»;«ENDIF»
 		
 		«IF timed»
@@ -213,12 +251,12 @@ class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader
 		«IF hasHistory»«statesEnumType» historyVector[«historyStatesConst»];«ENDIF»
 		sc_ushort stateConfVectorPosition;
 		
-		«FOR s : scopes.filter(typeof(StatechartScope)).filter[!(it instanceof ImportScope)]»
+		«FOR s : getInterfaces»
 			«s.interfaceName» «s.instance»;
 			«IF s.hasOperations && !entry.useStaticOPC»«s.interfaceOCBName»* «s.OCB_Instance»;«ENDIF»
 		«ENDFOR»
 	'''
-
+	
 	def protected publicFunctionPrototypes(ExecutionFlow it) '''
 		«IStatemachineFunctions»
 		
@@ -252,7 +290,7 @@ class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader
 		*/
 		virtual sc_boolean isFinal() const;
 	'''
-	
+
 	def timedStatemachineFunctions(ExecutionFlow it) '''
 		/*
 		 * Functions inherited from TimedStatemachineInterface
@@ -296,7 +334,7 @@ class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader
 	override dispatch functionPrototypes(VariableDefinition it) '''
 		/*! Gets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */
 		«IF const»const «ENDIF»«typeSpecifier.targetLanguageName» «it.asGetter»() const;
-
+		
 		«IF !readonly && !const»
 			/*! Sets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */
 			void «asSetter»(«typeSpecifier.targetLanguageName» value);

+ 85 - 122
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineImplementation.xtend

@@ -30,14 +30,15 @@ import static org.eclipse.xtext.util.Strings.*
 
 class StatemachineImplementation implements IContentTemplate {
 	
-	@Inject extension Naming
-	@Inject extension Navigation
-	@Inject extension FlowCode
-	@Inject extension GenmodelEntriesExtension
-	@Inject extension ICodegenTypeSystemAccess
-	@Inject extension INamingService
-	@Inject extension ExpressionCode
+	@Inject protected extension Naming
+	@Inject protected extension Navigation
+	@Inject protected extension FlowCode
+	@Inject protected extension GenmodelEntriesExtension
+	@Inject protected extension ICodegenTypeSystemAccess
+	@Inject protected extension INamingService
+	@Inject protected extension ExpressionCode
 	@Inject protected extension StateVectorExtensions
+	@Inject protected extension EventCode
 	
 	protected GeneratorEntry entry
 	
@@ -52,6 +53,8 @@ class StatemachineImplementation implements IContentTemplate {
 		/*! \file Implementation of the state machine '«name»'
 		*/
 		
+		«usingNamespaces»
+		
 		«constructorDefinition»
 		
 		«destructorDefinition»
@@ -81,28 +84,43 @@ class StatemachineImplementation implements IContentTemplate {
 		«interfaceFunctions»
 		
 		«functionImplementations»
+		
+		«additionalFunctions»
 	'''
 	}
 	
+	def protected usingNamespaces(ExecutionFlow it) {
+		''''''
+	}
+	
+	def additionalFunctions(ExecutionFlow it) {
+		/* Hook for child classes */
+		''''''
+	}
+	
 	def constructorDefinition(ExecutionFlow it) '''
 		«module»::«module»()
 		{
-			
-			«scopes.filter(typeof(StatechartScope)).filter[hasOperations && !entry.useStaticOPC].map['''«OCB_Instance» = null;'''].join('\n')»
-			«IF hasHistory»
-				
-				for (int i = 0; i < «historyStatesConst»; ++i)
-					historyVector[i] = «null_state»;
-			«ENDIF»
-			
-			stateConfVectorPosition = 0;
-			
-			«IF timed»
-				«timerInstance» = null;
-			«ENDIF»
+			«constructorBody(it)»
 		}
 	'''
 	
+	protected def CharSequence constructorBody(ExecutionFlow it)
+		'''
+		«scopes.filter(typeof(StatechartScope)).filter[hasOperations && !entry.useStaticOPC].map['''«OCB_Instance» = null;'''].join('\n')»
+		«IF hasHistory»
+			for (int i = 0; i < «historyStatesConst»; ++i)
+				historyVector[i] = «null_state»;
+				
+		«ENDIF»
+		stateConfVectorPosition = 0;
+		
+		«IF timed»
+			«timerInstance» = null;
+		«ENDIF»
+		'''
+	
+	
 	def destructorDefinition(ExecutionFlow it) '''
 		«module»::~«module»()
 		{
@@ -180,31 +198,35 @@ class StatemachineImplementation implements IContentTemplate {
 		{
 			
 			clearOutEvents();
-			
-			for (stateConfVectorPosition = 0;
-				stateConfVectorPosition < «orthogonalStatesConst»;
-				stateConfVectorPosition++)
-				{
-					
-				switch (stateConfVector[stateConfVectorPosition])
+			«runCycleFunctionForLoop»			
+			clearInEvents();
+		}
+	'''
+	
+	def runCycleFunctionForLoop(ExecutionFlow it) {
+		'''
+		for (stateConfVectorPosition = 0;
+			stateConfVectorPosition < «orthogonalStatesConst»;
+			stateConfVectorPosition++)
+			{
+				
+			switch (stateConfVector[stateConfVectorPosition])
+			{
+			«FOR state : states»
+				«IF state.reactSequence!=null»
+				case «state.shortName.asEscapedIdentifier» :
 				{
-				«FOR state : states»
-					«IF state.reactSequence!=null»
-					case «state.shortName.asEscapedIdentifier» :
-					{
-						«state.reactSequence.shortName»();
-						break;
-					}
-					«ENDIF»
-				«ENDFOR»
-				default:
+					«state.reactSequence.shortName»();
 					break;
 				}
+				«ENDIF»
+			«ENDFOR»
+			default:
+				break;
 			}
-			
-			clearInEvents();
 		}
-	'''
+		'''
+	}
 	
 	def timedStatemachineFunctions(ExecutionFlow it) '''
 		«IF timed»
@@ -219,16 +241,20 @@ class StatemachineImplementation implements IContentTemplate {
 				return «timerInstance»;
 			}
 			
-			void «module»::«raiseTimeEventFctID»(sc_eventid evid)
-			{
-				if ((evid >= (sc_eventid)«timeEventsInstance») && (evid < (sc_eventid)(&«timeEventsInstance»[«timeEventsCountConst»])))
-				{
-					*(sc_boolean*)evid = true;
-				}				
-			}
+			«raiseTimeEventFunction»
 		«ENDIF»
 	'''
 	
+	def raiseTimeEventFunction(ExecutionFlow it) '''
+		void «module»::«raiseTimeEventFctID»(sc_eventid evid)
+		{
+			if ((evid >= (sc_eventid)«timeEventsInstance») && (evid < (sc_eventid)(&«timeEventsInstance»[«timeEventsCountConst»])))
+			{
+				*(sc_boolean*)evid = true;
+			}				
+		}
+	'''
+	
 	def isStateActiveFunction(ExecutionFlow it) '''
 		sc_boolean «module»::«stateActiveFctID»(«statesEnumType» state) const
 		{
@@ -291,76 +317,20 @@ class StatemachineImplementation implements IContentTemplate {
 			{
 				return &«scope.instance»;
 			}
-			
 			«ENDIF»
-			«FOR event : scope.incomingEvents»
-				void «module»::«scope.interfaceName»::«event.asRaiser»(«event.valueParams»)
-				{
-					«IF event.hasValue»
-					«event.localValueAccess» = value;
-					«ENDIF»
-					«event.localAccess» = true;
-				}
-				
-				«IF scope.defaultInterface»
-					void «module»::«event.asRaiser»(«event.valueParams»)
-					{
-						«scope.instance».«event.asRaiser»(«IF event.hasValue»value«ENDIF»);
-					}
-					
-				«ENDIF»
-			«ENDFOR»
-			«FOR event : scope.outgoingEvents»
-				sc_boolean «module»::«scope.interfaceName»::«event.asRaised»() const
-				{
-					return «event.localAccess»;
-				}
-				
-				«IF scope.defaultInterface»
-					sc_boolean «module»::«event.asRaised»() const
-					{
-						return «scope.instance».«event.asRaised»();
-					}
-					
-				«ENDIF»
-				«IF event.hasValue»
-					«event.typeSpecifier.targetLanguageName» «module»::«scope.interfaceName»::«event.asGetter»() const
-					{
-						return «event.localValueAccess»;
-					}
-					
-					«IF scope.defaultInterface»
-						«event.typeSpecifier.targetLanguageName» «module»::«event.asGetter»() const
-						{
-							return «scope.instance».«event.asGetter»();
-						}
-						
-					«ENDIF»
-				«ENDIF»
-			«ENDFOR»
-			
-			«FOR event : scope.localEvents»
-				void «module»::«scope.interfaceName»::«event.asRaiser»(«event.valueParams»)
-				{
-					«IF event.hasValue»
-					«event.localValueAccess» = value;
-					«ENDIF»
-					«event.localAccess» = true;
-				}
-				
-				sc_boolean «module»::«scope.interfaceName»::«event.asRaised»() const
+			«generateEvents(scope)»
+			«generateVariables(scope)»
+			«IF scope.hasOperations && !entry.useStaticOPC»
+				«scope.OCB_InterfaceSetterDeclaration(true)»
 				{
-					return «event.localAccess»;
+					«scope.OCB_Instance» = operationCallback;
 				}
-				
-				«IF event.hasValue» 
-					«event.typeSpecifier.targetLanguageName» «module»::«scope.interfaceName»::«event.asGetter»() const
-					{
-						return «event.localValueAccess»;
-					}
-					
-				«ENDIF»
-			«ENDFOR»
+			«ENDIF»
+		«ENDFOR»
+	'''
+	
+	def generateVariables(ExecutionFlow it, StatechartScope scope)
+		'''
 			«FOR variable : scope.variableDefinitions»
 				«IF variable.const»const «ENDIF»«variable.typeSpecifier.targetLanguageName» «module»::«scope.interfaceName»::«variable.asGetter»() const
 				{
@@ -389,14 +359,7 @@ class StatemachineImplementation implements IContentTemplate {
 					«ENDIF»
 				«ENDIF»
 			«ENDFOR»
-			«IF scope.hasOperations && !entry.useStaticOPC»
-				«scope.OCB_InterfaceSetterDeclaration(true)»
-				{
-					«scope.OCB_Instance» = operationCallback;
-				}
-			«ENDIF»
-		«ENDFOR»
-	'''
+		'''
 	
 	/* ===================================================================================
 	 * Handling implementation of internal functions

+ 102 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/EventDrivenEventCode.xtend

@@ -0,0 +1,102 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.cpp.eventdriven
+
+import com.google.inject.Inject
+import org.yakindu.base.types.Direction
+import org.yakindu.sct.generator.cpp.EventCode
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.stext.StatechartScope
+
+/**
+ * @author René Beckmann - Initial contribution and API
+ */
+class EventDrivenEventCode extends EventCode {
+	@Inject extension EventNaming eventNaming
+	
+	
+	override generateEvents(ExecutionFlow it, StatechartScope scope)
+		'''
+			«FOR event : scope.incomingEvents»
+					«generateEventComment(event, scope)»
+					«generateInterfaceEventRaiser(it, event, scope)»
+					«IF scope.defaultInterface»
+						«generateDefaultInterfaceEventRaiser(it, event, scope)»
+					«ENDIF»
+			«ENDFOR»
+			«FOR event : scope.outgoingEvents»
+				«generateEventComment(event, scope)»
+				«generateInterfaceEventRaised(it, event, scope)»
+				«IF scope.defaultInterface»
+					«generateDefaultInterfaceEventRaised(it, event, scope)»
+				«ENDIF»
+				«IF event.hasValue»
+					«generateEventValueGetter(it, event, scope)»
+					«IF scope.defaultInterface»
+						«generateEventGetter(it, event, scope)»
+					«ENDIF»
+				«ENDIF»
+			«ENDFOR»
+			«FOR event : scope.localEvents»
+				«generateEventComment(event, scope)»
+				«generateInterfaceEventRaiser(it, event, scope)»
+				«generateInternalInterfaceEventRaiser(it, event, scope)»
+				«generateInterfaceEventRaised(it, event, scope)»
+				«IF event.hasValue» 
+					«generateEventValueGetter(it, event, scope)»
+				«ENDIF»
+			«ENDFOR»
+		'''
+	
+	
+	protected def CharSequence generateInternalInterfaceEventRaiser(ExecutionFlow it, EventDefinition event, StatechartScope scope)
+		'''
+			void «module»::«scope.interfaceName»::internal_«event.asRaiser»(«event.valueParams»)
+			{
+				«IF event.hasValue»
+				«event.localValueAccess» = value;
+				«ENDIF»
+				«event.localAccess» = true;
+			}
+		'''
+		
+	protected override CharSequence generateInterfaceEventRaiser(ExecutionFlow it, EventDefinition event, StatechartScope scope) {
+		if(event.direction == Direction::IN) {
+			'''
+			void «module»::«scope.interfaceName»::«event.asRaiser»(«event.valueParams»)
+			{
+				«IF event.hasValue»
+				«event.localValueAccess» = value;
+				«ENDIF»
+				«event.localAccess» = true;
+				
+				parent->runCycle();
+			}
+			'''
+		} else if(event.direction == Direction::LOCAL) {
+			'''
+				void «module»::«scope.interfaceName»::«event.asRaiser»(«event.valueParams»)
+				{
+					«IF event.hasValue»
+					parent->internalEventQueue.push_back(new «event.eventClassName»(«event.eventEnumMemberName», value));
+					«ELSE»
+					parent->internalEventQueue.push_back(new «event.eventClassName»(«event.eventEnumMemberName»));
+					«ENDIF»
+					parent->runCycle();
+				}
+			'''
+		}
+	}
+	
+	override CharSequence generateEventComment(EventDefinition it, StatechartScope scope)
+		'''/* Functions for event «name» in interface «scope.interfaceName» */'''
+}

+ 57 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/EventDrivenExpressionCode.xtend

@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+ package org.yakindu.sct.generator.cpp.eventdriven
+
+import com.google.inject.Inject
+import org.yakindu.base.types.Direction
+import org.yakindu.sct.generator.cpp.ExpressionCode
+import org.yakindu.sct.model.stext.stext.EventRaisingExpression
+import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression
+
+/**
+ * @author René Beckmann - Initial contribution and API
+ */
+class EventDrivenExpressionCode extends ExpressionCode {
+	@Inject extension EventNaming eventNaming
+	
+	override dispatch CharSequence code(EventRaisingExpression it) {
+		switch (event.definition.event.direction) {
+			case Direction::IN: {
+				return raiseInEvent
+			}
+			case Direction::OUT: {
+				return raiseOutEvent
+			}
+			case Direction::LOCAL: {
+				return raiseInternalEvent
+			}
+		}
+	}
+	
+	def CharSequence raiseInEvent(EventRaisingExpression it) {
+		return super._code(it)
+	}
+	
+	def CharSequence raiseOutEvent(EventRaisingExpression it) {
+		return super._code(it)
+	}
+	
+	def CharSequence raiseInternalEvent(EventRaisingExpression it) {
+		'''internalEventQueue.push_back(«eventObjectPointer»)'''
+	}
+	
+	def eventObjectPointer(EventRaisingExpression it) {
+		val cls = event.definition.event.eventClassName
+		val enm = event.definition.event.eventEnumMemberName
+		val args = '''«enm»«IF value !== null», «value.code»«ENDIF»'''
+		'''new «cls»(«args»)'''
+	}
+}

+ 101 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/EventDrivenStatemachineHeader.xtend

@@ -0,0 +1,101 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.cpp.eventdriven
+
+import com.google.inject.Inject
+import java.util.List
+import org.yakindu.base.types.Direction
+import org.yakindu.sct.generator.c.IGenArtifactConfigurations
+import org.yakindu.sct.generator.cpp.StatemachineHeader
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.stext.StatechartScope
+
+/**
+ * @author René Beckmann - Initial contribution and API
+ */
+class EventDrivenStatemachineHeader extends StatemachineHeader {
+	@Inject extension EventNaming
+	
+	override protected generatePublicClassmembers(ExecutionFlow it) {
+		'''
+		«super.generatePublicClassmembers(it)»
+		'''
+	}
+	
+	override protected generatePrivateClassmembers(ExecutionFlow it) {
+		'''
+		private:
+			std::deque<«eventNamespaceName»::SctEvent*> internalEventQueue;
+			
+			«eventNamespaceName»::SctEvent* getNextEvent();
+			
+			void dispatch_event(«eventNamespaceName»::SctEvent * event);
+		'''
+	}
+	
+	override includes(ExecutionFlow it, extension IGenArtifactConfigurations artifactConfigs) {
+		'''
+		#include <deque>
+		#include "«eventClasses.h»"
+		«super.includes(it, artifactConfigs)»
+		'''
+	}
+	
+	override CharSequence protectedInnerClassMembers(StatechartScope scope) {
+		'''
+		«super.protectedInnerClassMembers(scope)»
+		«scope.execution_flow.module()» * parent;
+		void dispatch_event(«scope.flow.eventNamespaceName»::SctEvent * event);
+		
+		'''
+	}
+	
+	override protected createInterface(StatechartScope it) {
+		val List<String> toInit = newArrayList
+		for( e : declarations.filter(EventDefinition)) {
+			toInit.add('''«e.name.asIdentifier.raised»(false)''')
+			if (e.hasValue) {
+				toInit.add('''«e.name.asIdentifier.value»()''')
+			}
+		}
+		toInit.add("parent(parent)")
+		return '''
+			//! Inner class for «simpleName» interface scope.
+			class «interfaceName»
+			{
+				
+				public:
+					«interfaceName»(«execution_flow.module()» * parent): 
+					«FOR init : toInit SEPARATOR ","»
+						«init»
+					«ENDFOR»
+					{}
+					«FOR d : declarations»
+						«d.functionPrototypes»
+					«ENDFOR»
+					
+				«entry.innerClassVisibility»:
+					«protectedInnerClassMembers»
+			};
+		'''
+	}
+	
+	def dispatch privateFunctionPrototypes(EventDefinition it) {
+		'''
+		«IF direction == Direction::LOCAL»
+			/*! Raises the in event '«name»' that is defined in the «scope.scopeDescription». */
+			void internal_«asRaiser»(«valueParams»);
+		«ENDIF»
+		'''
+	}
+	
+}

+ 176 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/EventDrivenStatemachineImplementation.xtend

@@ -0,0 +1,176 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.cpp.eventdriven
+
+import com.google.inject.Inject
+import java.util.List
+import org.yakindu.base.types.Direction
+import org.yakindu.sct.generator.cpp.StatemachineImplementation
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgraph.Scope
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.stext.StatechartScope
+
+/*
+ * To restore the event queue for in events, revert commit 235659d
+ */
+/**
+ * @author René Beckmann - Initial contribution and API
+ */
+class EventDrivenStatemachineImplementation extends StatemachineImplementation {
+	@Inject extension EventNaming eventNaming
+	
+	override additionalFunctions(ExecutionFlow it) {
+		'''
+		«nextEventFunction»
+		
+		«generateInternalDispatchEventFunction»
+		
+		«generateInterfaceDispatchFunctions»
+		'''
+	}
+	
+	override protected usingNamespaces(ExecutionFlow it) {
+		'''using namespace «eventNamespaceName»;'''
+	}
+	
+	
+	override raiseTimeEventFunction(ExecutionFlow it) '''
+		void «module»::«raiseTimeEventFctID»(sc_eventid evid)
+		{
+			if ((evid >= (sc_eventid)«timeEventsInstance») && (evid < (sc_eventid)(&«timeEventsInstance»[«timeEventsCountConst»])))
+			{
+				*(sc_boolean*)evid = true;
+				runCycle();
+			}				
+		}
+	'''
+	
+	override runCycleFunction(ExecutionFlow it) { 
+	'''
+		void «module»::runCycle()
+		{
+			clearOutEvents();
+			
+			SctEvent * currentEvent = getNextEvent();
+			
+			do
+			{
+				/* Set event flags as usual */
+				dispatch_event(currentEvent);
+				
+				«runCycleFunctionForLoop»
+				
+				/* Delete event from memory */
+				delete currentEvent;
+				clearInEvents();
+			} while((currentEvent = getNextEvent()));
+		}
+	'''
+	}
+	
+	def getNextEventFunction(ExecutionFlow it) {
+		'''
+		SctEvent* «module»::getNextEvent()
+		{
+			SctEvent* nextEvent = 0;
+			
+			if(!internalEventQueue.empty()) {
+				nextEvent = internalEventQueue.front();
+				internalEventQueue.pop_front();
+			}
+			
+			return nextEvent;
+		}
+		'''
+	}
+	
+	override constructorDefinition(ExecutionFlow it) {
+	val List<String> toInit = newArrayList
+	toInit.addAll(getInterfaces.map[instance].map[i|'''«i»(this)'''])
+	'''
+		«module»::«module»() :
+			«FOR init : toInit SEPARATOR ","»
+				«init»
+			«ENDFOR»
+		{
+			«constructorBody(it)»
+		}
+	'''
+	}
+	
+	override constructorBody(ExecutionFlow it)
+		'''
+		«super.constructorBody(it)»
+		
+		'''
+	
+	
+	def generateInterfaceDispatchFunctions(ExecutionFlow it) {
+		'''
+		«FOR s : statechartScopes»
+		«generateInterfaceDispatchFunction(s)»
+		«ENDFOR»
+		'''
+	}
+	
+	def generateInterfaceDispatchFunction(ExecutionFlow it, Scope s) {
+		'''
+		void «module»::«s.interfaceName»::dispatch_event(SctEvent * event)
+		{
+			switch(event->name)
+			{
+				«FOR e: s.declarations.filter(EventDefinition).filter[direction == Direction::LOCAL]»
+					case «e.eventEnumMemberName»:
+					{
+						«IF e.hasValue»
+						«e.eventClassName» * e = dynamic_cast<«e.eventClassName»*>(event);
+						if(e != 0) {
+							internal_«e.asRaiser»(e->value);
+						}
+						«ELSE»
+						internal_«e.asRaiser»();
+						«ENDIF»
+						break;
+					}
+				«ENDFOR»
+				default:
+					break;
+			}
+		}
+		'''
+	}
+	
+	def generateInternalDispatchEventFunction(ExecutionFlow it) {
+		'''
+		void «module»::dispatch_event(SctEvent * event)
+		{
+			if(event == 0) {
+				return;
+			}
+			switch(event->name)
+			{
+				«FOR s : scopes.filter(StatechartScope)»
+					«FOR e : s.declarations.filter(EventDefinition).filter[direction == Direction::LOCAL]»
+						case «e.eventEnumMemberName»:
+					«ENDFOR»
+					{
+							«s.instance».dispatch_event(event);
+							break;
+					}
+				«ENDFOR»
+				default:
+					break;
+			}
+		}
+		'''
+	}
+}

+ 49 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/EventNaming.xtend

@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.cpp.eventdriven
+
+import com.google.inject.Inject
+import org.yakindu.base.types.Event
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
+import org.yakindu.sct.generator.cpp.Naming
+import org.yakindu.sct.generator.cpp.Navigation
+import org.yakindu.sct.generator.cpp.features.GenmodelEntriesExtension
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.naming.INamingService
+import org.yakindu.sct.model.sgen.GeneratorEntry
+/**
+ * @author René Beckmann - Initial contribution and API
+ */
+class EventNaming {
+	@Inject extension Naming
+	@Inject extension Navigation
+	@Inject extension INamingService
+	
+	def eventEnumMemberName(Event it) {
+		'''«scope.interfaceName»_«name.asIdentifier»'''
+	}
+	
+	def eventEnumName(ExecutionFlow it) {
+		'''«module»EventName'''
+	}
+	
+	def timeEventEnumName() {
+		'''TimeEvent'''
+	}
+	
+	def eventClassName(Event it) {
+		'''SctEvent_«scope.interfaceName»_«it.name.asIdentifier»'''
+	}
+	
+	def eventNamespaceName(ExecutionFlow it) {
+		'''«name.toLowerCase»_events'''
+	}
+}

+ 161 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/eventdriven/StatechartEvents.xtend

@@ -0,0 +1,161 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.cpp.eventdriven
+
+import com.google.inject.Inject
+import org.yakindu.base.types.Direction
+import org.yakindu.sct.generator.c.IContentTemplate
+import org.yakindu.sct.generator.c.IGenArtifactConfigurations
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
+import org.yakindu.sct.generator.cpp.Naming
+import org.yakindu.sct.generator.cpp.Navigation
+import org.yakindu.sct.generator.cpp.features.GenmodelEntriesExtension
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.naming.INamingService
+import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.yakindu.sct.model.stext.stext.EventDefinition
+/**
+ * @author René Beckmann - Initial contribution and API
+ */
+class StatechartEvents implements IContentTemplate {
+	@Inject protected extension Naming
+	@Inject protected extension Navigation
+	@Inject protected extension ICodegenTypeSystemAccess
+	@Inject protected extension GenmodelEntriesExtension
+	@Inject protected extension INamingService
+	
+	@Inject extension EventNaming eventNaming
+	
+	protected GeneratorEntry entry
+	protected ExecutionFlow flow
+	
+	override content(ExecutionFlow it, GeneratorEntry entry, extension IGenArtifactConfigurations locations) {
+		this.entry = entry;
+		this.flow = it;
+		'''
+		#ifndef «generateHeaderDefineGuard»
+		#define «generateHeaderDefineGuard»
+		
+		#include "«(typesModule.h).relativeTo(module.h)»"
+		
+		namespace «eventNamespaceName»
+		{
+		«generateEventsEnum»
+		
+		«generateEventBaseClasses»
+		
+		«generateEvents»
+		
+		}
+		#endif /* «generateHeaderDefineGuard» */
+		'''
+	}
+	
+	def generateEventsEnum(ExecutionFlow it) {
+		val enumMembers = scopes
+			.map[declarations.filter(EventDefinition)] // map list of declarations to scope
+			.reduce[i1, i2 | i1 + i2] // reduce multiple lists of declarations into one
+			.filter[direction == Direction::LOCAL]
+			.map[eventEnumMemberName] // generate enumMemberNames for each
+			.toList
+		if(timed) {
+			enumMembers.add(timeEventEnumName)
+		}
+		'''
+		typedef enum  {
+			«FOR e : enumMembers SEPARATOR ","»
+				«e»
+			«ENDFOR»
+		} «eventEnumName»;
+		'''
+	}
+	
+	def generateHeaderDefineGuard(ExecutionFlow it) {
+		'''SCT_EVENTS_«name.toUpperCase»_H'''
+	}
+	
+	def generateEventBaseClasses(ExecutionFlow it) {
+		'''
+		class SctEvent
+		{
+			public:
+				SctEvent(«eventEnumName» name) : name(name){}
+				virtual ~SctEvent(){}
+				const «eventEnumName» name;
+				
+		};
+				
+		template <typename T>
+		class TypedSctEvent : public SctEvent
+		{
+			public:
+				TypedSctEvent(«eventEnumName» name, T value) :
+					SctEvent(name),
+					value(value)
+					{}
+				virtual ~TypedSctEvent(){}
+				const T value;
+		};
+		'''
+	}
+	
+	def generateEvents(ExecutionFlow it) {
+		'''
+		«FOR s : scopes»
+			«FOR e : s.declarations.filter(EventDefinition).filter[direction == Direction::LOCAL]»
+				«generateEventClass(e, it)»
+			«ENDFOR»
+		«ENDFOR»
+		'''
+	}
+	
+	def generateEventClass(EventDefinition it, ExecutionFlow flow) {
+		'''
+		«IF hasValue»
+		«generateTypedEventClass(flow)»
+		«ELSE»
+		«generateNormalEventClass(flow)»
+		«ENDIF»
+		'''
+	}
+	
+	def generateTypedEventClass(EventDefinition it, ExecutionFlow flow) {
+		val type = typeSpecifier.targetLanguageName
+		'''
+		class «eventClassName» : public TypedSctEvent<«type»>
+		{
+			public:
+				«eventClassName»(«flow.eventEnumName» name, «type» value) :
+					TypedSctEvent(name, value) {};
+		};
+		'''
+	}
+	
+	def generateNormalEventClass(EventDefinition it, ExecutionFlow flow) {
+		'''
+		class «eventClassName» : public SctEvent
+		{
+			public:
+				«eventClassName»(«flow.eventEnumName» name) : SctEvent(name){};
+		};
+		'''
+	}
+	
+	def getBaseClass(EventDefinition it) {
+		'''
+		«IF hasValue»
+		TypedSctEvent
+		«ELSE»
+		SctEvent
+		«ENDIF»
+		'''
+	}
+}

+ 2 - 1
plugins/org.yakindu.sct.generator.genmodel.ui/META-INF/MANIFEST.MF

@@ -38,6 +38,7 @@ Export-Package: org.yakindu.sct.generator.genmodel.ui,
  org.yakindu.sct.generator.genmodel.ui.help,
  org.yakindu.sct.generator.genmodel.ui.internal,
  org.yakindu.sct.generator.genmodel.ui.quickfix,
- org.yakindu.sct.generator.genmodel.ui.wizard
+ org.yakindu.sct.generator.genmodel.ui.wizard,
+ org.yakindu.sct.generator.genmodel.ui.contentassist.antlr.internal
 Bundle-Activator: org.yakindu.sct.generator.genmodel.ui.internal.SGenActivator
 Bundle-ActivationPolicy: lazy

+ 2 - 1
plugins/org.yakindu.sct.generator.java/META-INF/MANIFEST.MF

@@ -5,7 +5,8 @@ Bundle-SymbolicName: org.yakindu.sct.generator.java;singleton:=true
 Bundle-Version: 3.0.0.qualifier
 Require-Bundle: org.yakindu.sct.model.stext,
  org.yakindu.sct.generator.core,
- org.yakindu.sct.generator.genmodel
+ org.yakindu.sct.generator.genmodel,
+ org.yakindu.sct.model.stext.lib
 Bundle-Vendor: statecharts.org
 Export-Package: org.yakindu.sct.generator.java,
  org.yakindu.sct.generator.java.features,

+ 2 - 0
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaGenerator.xtend

@@ -17,6 +17,8 @@ import org.yakindu.sct.generator.java.features.EventBasedRunnableFeature
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sexec.naming.INamingService
 import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.yakindu.sct.generator.java.wrappers.EventBasedRunnableWrapper
+import org.yakindu.sct.generator.java.wrappers.CycleBasedSynchronizedWrapper
 
 /**
  * This is the Java code generators main class.

+ 30 - 1
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaGeneratorModule.java

@@ -11,12 +11,18 @@
 package org.yakindu.sct.generator.java;
 
 import org.yakindu.sct.generator.core.IGeneratorModule;
+
+import static org.yakindu.sct.model.stext.lib.StatechartAnnotations.EVENT_DRIVEN_ANNOTATION;
+
+import org.yakindu.base.types.Annotation;
 import org.yakindu.sct.generator.core.IExecutionFlowGenerator;
 import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess;
+import org.yakindu.sct.generator.java.eventdriven.EventDrivenStatemachine;
 import org.yakindu.sct.generator.java.types.JavaTypeSystemAccess;
 import org.yakindu.sct.generator.java.types.OldJavaTypeSystemAccess;
 import org.yakindu.sct.model.sexec.naming.INamingService;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgraph.Statechart;
 
 import com.google.inject.Binder;
 import com.google.inject.Scopes;
@@ -24,19 +30,42 @@ import com.google.inject.Scopes;
 /**
  * 
  * @author andreas muelder - Initial contribution and API
+ * @author terfloth - extensions for event driven execution
  * 
  */
 public class JavaGeneratorModule implements IGeneratorModule {
 
 	@Override
 	public void configure(GeneratorEntry entry, Binder binder) {
+		
+		configureGeneratorRoot(entry, binder);
+		configureForExecutionStyle(entry, binder);
+		configureServices(entry, binder);
+	}
+
+	
+	public void configureGeneratorRoot(GeneratorEntry entry, Binder binder) {
 		binder.bind(IExecutionFlowGenerator.class).to(JavaGenerator.class);
+	}
+
+	public void configureForExecutionStyle(GeneratorEntry entry, Binder binder) {
+		Statechart statechart = (Statechart) entry.getElementRef();
+		Annotation eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
+
+		if ( eventDrivenAnnotation != null ) {
+			binder.bind(Statemachine.class).to(EventDrivenStatemachine.class);
+		}
+	}
+
+	public void configureServices(GeneratorEntry entry, Binder binder) {
+		
 		final GenmodelEntries entries = new GenmodelEntries();
 		if (entries.useJavaInt(entry)) {
 			binder.bind(ICodegenTypeSystemAccess.class).to(OldJavaTypeSystemAccess.class);
 		} else {
 			binder.bind(ICodegenTypeSystemAccess.class).to(JavaTypeSystemAccess.class);
 		}
-		binder.bind(INamingService.class).to(JavaNamingService.class).in(Scopes.SINGLETON);
+		binder.bind(INamingService.class).to(JavaNamingService.class).in(Scopes.SINGLETON);		
 	}
+	
 }

+ 75 - 30
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/Statemachine.xtend

@@ -28,6 +28,9 @@ import org.yakindu.sct.model.stext.stext.InterfaceScope
 import org.yakindu.sct.model.stext.stext.VariableDefinition
 
 import static org.eclipse.xtext.util.Strings.*
+import org.yakindu.base.types.Event
+import java.util.Set
+import java.util.TreeSet
 
 class Statemachine {
 	
@@ -72,16 +75,31 @@ class Statemachine {
 		}
 	'''
 	
+	
+	
 	def protected createImports(ExecutionFlow flow, GeneratorEntry entry) '''
-		«IF entry.createInterfaceObserver && flow.hasOutgoingEvents»
-			import java.util.LinkedList;
-			import java.util.List;
-		«ENDIF»
-		«IF flow.timed»
-			import «entry.getBasePackageName()».ITimer;
-		«ENDIF»
+		«FOR importEntry : flow.imports(entry)»
+			import «importEntry»;
+		«ENDFOR»
 	'''
 	
+	def protected imports(ExecutionFlow it, GeneratorEntry entry) {
+		// we need a sorted set for the imports
+		val Set<String> importSet = new TreeSet<String>()	
+		
+		if (entry.createInterfaceObserver && hasOutgoingEvents) {
+			importSet += "java.util.List"
+			importSet += "java.util.LinkedList"
+		}
+		
+		if (timed) {
+			importSet += "" + entry.getBasePackageName() + ".ITimer"
+		}
+		
+		return importSet
+	}
+	
+	
 	def protected createFieldDeclarations(ExecutionFlow flow, GeneratorEntry entry) '''
 		«FOR scope : flow.interfaceScopes»
 		«scope.toImplementation(entry)»
@@ -109,14 +127,9 @@ class Statemachine {
 		
 		private final boolean[] timeEvents = new boolean[«flow.timeEvents.size»];
 		«ENDIF»
-		«FOR event : flow.internalScopeEvents»
-			private boolean «event.identifier»;
-			
-			«IF event.type != null && !isSame(event.type, getType(GenericTypeSystem.VOID))»
-				private «event.typeSpecifier.targetLanguageName» «event.valueIdentifier»;
-
-			«ENDIF»
-		«ENDFOR»
+		
+		«flow.internalEventFields»		
+		
 		«FOR variable : flow.internalScopeVariables SEPARATOR newLine AFTER newLine»
 			«IF !variable.const»
 				«variable.fieldDeclaration»
@@ -141,6 +154,29 @@ class Statemachine {
 			«ENDIF»
 		«ENDFOR»
 	'''
+	
+	def protected internalEventFields(ExecutionFlow flow) '''
+		«FOR event : flow.internalScopeEvents»
+
+			«event.internalEventField»	
+			«event.internalEventValueField»
+		«ENDFOR»
+	'''
+	
+	def protected internalEventField(EventDefinition it) '''
+			private boolean «event.identifier»;
+	'''
+	
+	def protected internalEventValueField(EventDefinition it) '''
+		«IF hasPayload»
+			private «typeSpecifier.targetLanguageName» «valueIdentifier»;
+		«ENDIF»
+	'''
+	
+	def hasInternalEvents(ExecutionFlow it) {
+		! flow.internalScopeEvents.empty
+	}
+	
 	//reused by interfaces
 	def protected fieldDeclaration(VariableDefinition variable) {
 		'''private «variable.typeSpecifier.targetLanguageName» «variable.identifier»;
@@ -481,23 +517,10 @@ class Statemachine {
 	
 	def protected internalScopeFunctions (ExecutionFlow flow) '''
 		«FOR event : flow.internalScopeEvents»
-			«IF event.type != null && !isSame(event.type, getType(GenericTypeSystem.VOID))»
-				private void raise«event.name.asEscapedName»(«event.typeSpecifier.targetLanguageName» value) {
-					«event.valueIdentifier» = value;
-					«event.identifier» = true;
-				}
-				
-				private «event.typeSpecifier.targetLanguageName» get«event.name.asEscapedName»Value() {
-					«event.getIllegalAccessValidation()»
-					return «event.valueIdentifier»;
-				}
+			«event.internalEventRaiser»
 
-			«ELSE»
-				private void raise«event.name.asEscapedName»() {
-					«event.identifier» = true;
-				}
+			«event.internalEventValueAccess»
 
-			«ENDIF»
 		«ENDFOR»
 		«FOR internal : flow.internalScopes»
 			«IF internal.hasOperations»
@@ -510,6 +533,28 @@ class Statemachine {
 		«ENDFOR»
 	'''
 	
+	def protected internalEventRaiser(EventDefinition it) '''
+		private void raise«name.asEscapedName»(«IF hasPayload»«typeSpecifier.targetLanguageName» value«ENDIF») {
+			«IF hasPayload»«valueIdentifier» = value;«ENDIF»
+			«identifier» = true;
+		}
+	'''
+
+	def protected internalEventValueAccess(EventDefinition it) '''
+		«IF hasPayload»
+			private «typeSpecifier.targetLanguageName» get«name.asEscapedName»Value() {
+				«getIllegalAccessValidation()»
+				return «valueIdentifier»;
+			}
+		«ENDIF»
+	'''
+
+
+	def hasPayload(Event it) {
+		type !== null && !isSame(type, getType(GenericTypeSystem.VOID))
+	} 
+	
+	
 	def protected defaultInterfaceFunctions(ExecutionFlow flow, GeneratorEntry entry) '''
 		«IF flow.defaultScope != null»
 			«var InterfaceScope scope = flow.defaultScope»

+ 152 - 0
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/eventdriven/EventDrivenStatemachine.xtend

@@ -0,0 +1,152 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.java.eventdriven
+
+import java.util.Set
+import org.yakindu.base.types.typesystem.GenericTypeSystem
+import org.yakindu.sct.generator.java.Statemachine
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.yakindu.sct.model.stext.stext.EventDefinition
+
+/**
+ * @author terfloth
+ */
+class EventDrivenStatemachine extends Statemachine {
+
+	/** Adds imports for the internal event queue if neccessary. */
+	override protected imports(ExecutionFlow it, GeneratorEntry entry) {
+
+		val Set<String> importSet = super.imports(it, entry);	
+		
+		if (hasInternalEvents) {
+			importSet += "java.util.Queue"
+			importSet += "java.util.LinkedList"
+		}
+		
+		return importSet
+	}
+	
+
+	protected override generateInEventDefinition(EventDefinition event) '''
+		«IF event.type !== null && !isSame(event.type, getType(GenericTypeSystem.VOID))»
+			public void raise«event.name.asName»(«event.typeSpecifier.targetLanguageName» value) {
+				«event.identifier» = true;
+				«event.valueIdentifier» = value;
+				runCycle();
+			}
+			
+			protected «event.typeSpecifier.targetLanguageName» get«event.name.asName»Value() {
+				«event.getIllegalAccessValidation()»
+				return «event.valueIdentifier»;
+			}
+		«ELSE»
+			public void raise«event.name.asName»() {
+				«event.identifier» = true;
+				runCycle();
+			}
+		«ENDIF»
+
+	'''
+
+	override protected timingFunctions(ExecutionFlow flow) '''
+		«IF flow.timed»
+			/**
+			* Set the {@link ITimer} for the state machine. It must be set
+			* externally on a timed state machine before a run cycle can be correct
+			* executed.
+			* 
+			* @param timer
+			*/
+			public void setTimer(ITimer timer) {
+				this.timer = timer;
+			}
+
+			/**
+			* Returns the currently used timer.
+			* 
+			* @return {@link ITimer}
+			*/
+			public ITimer getTimer() {
+				return timer;
+			}
+			
+			public void timeElapsed(int eventID) {
+				timeEvents[eventID] = true;
+				runCycle();
+			}
+
+		«ENDIF»
+	'''
+
+	override protected internalEventFields(ExecutionFlow flow) '''
+		«IF flow.hasInternalEvents»
+			private Queue<Runnable> internalEventQueue = new LinkedList<Runnable>();
+		«ENDIF»
+		«super.internalEventFields(flow)»
+	'''
+
+	override protected internalEventRaiser(EventDefinition it) '''
+		private void raise«name.asEscapedName»(«IF hasPayload»final «typeSpecifier.targetLanguageName» value«ENDIF») {
+
+			internalEventQueue.add( new Runnable() {
+				@Override public void run() {
+					«IF hasPayload»«valueIdentifier» = value;«ENDIF»
+					«identifier» = true;					
+					runCycle();
+				}
+			});
+		}
+	'''
+
+	override protected runCycleFunction(ExecutionFlow flow) '''
+		public void runCycle() {
+			if (!initialized)
+				throw new IllegalStateException(
+						"The state machine needs to be initialized first by calling the init() function.");
+		
+			clearOutEvents();
+			singleCycle();
+			clearEvents();
+			
+			«IF flow.hasInternalEvents»
+			// process queued events
+			while (internalEventQueue.size() > 0) {
+				internalEventQueue.poll().run();
+				singleCycle();
+				clearEvents();
+			}
+			«ENDIF»
+		}
+		
+		«flow.singelCycle»
+	'''
+	
+	def protected singelCycle(ExecutionFlow flow) '''
+		protected void singleCycle() {
+			for (nextStateIndex = 0; nextStateIndex < stateVector.length; nextStateIndex++) {
+				switch (stateVector[nextStateIndex]) {
+				«FOR state : flow.states»
+					«IF state.reactSequence !== null»
+						case «state.stateName.asEscapedIdentifier»:
+							«state.reactSequence.functionName»();
+							break;
+				«ENDIF»
+				«ENDFOR»
+				default:
+					// «getNullStateName()»
+				}
+			}
+		}
+	'''
+	
+
+}

+ 5 - 1
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/CycleBasedSynchronizedWrapper.xtend

@@ -8,7 +8,7 @@
  *   	Markus Mühlbrandt - Initial contribution and API
  */
 
-package org.yakindu.sct.generator.java
+package org.yakindu.sct.generator.java.wrappers
 
 import com.google.inject.Inject
 import org.eclipse.xtext.generator.IFileSystemAccess
@@ -22,6 +22,10 @@ import org.yakindu.sct.model.sgen.GeneratorEntry
 import org.yakindu.sct.model.stext.stext.InterfaceScope
 
 import static org.eclipse.xtext.util.Strings.*
+import org.yakindu.sct.generator.java.GenmodelEntries
+import org.yakindu.sct.generator.java.JavaNamingService
+import org.yakindu.sct.generator.java.Naming
+import org.yakindu.sct.generator.java.Navigation
 
 /**
  * Generates the cycle bases synchronized wrapper for the state machine.

+ 5 - 1
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/EventBasedRunnableWrapper.xtend

@@ -10,7 +10,7 @@
   	
 */
 
-package org.yakindu.sct.generator.java
+package org.yakindu.sct.generator.java.wrappers
 
 import com.google.inject.Inject
 import org.eclipse.xtext.generator.IFileSystemAccess
@@ -23,6 +23,10 @@ import org.yakindu.sct.generator.java.features.EventBasedRunnableFeature
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sgen.GeneratorEntry
 import org.yakindu.sct.model.stext.stext.InterfaceScope
+import org.yakindu.sct.generator.java.GenmodelEntries
+import org.yakindu.sct.generator.java.Naming
+import org.yakindu.sct.generator.java.JavaNamingService
+import org.yakindu.sct.generator.java.Navigation
 
 /**
  * Generates the runnable wrapper for the state machine. This wrapper implies event based execution semantics.

+ 9 - 1
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/container/AbstractExecutionFlowSimulationEngine.java

@@ -85,7 +85,7 @@ public abstract class AbstractExecutionFlowSimulationEngine extends AbstractSimu
 		if (!context.isSnapshot()) {
 			contextInitializer.initialize(context, flow);
 		}
-		interpreter.initialize(flow, context);
+		interpreter.initialize(flow, context, useInternalEventQueue());
 	}
 
 	public void start() {
@@ -142,5 +142,13 @@ public abstract class AbstractExecutionFlowSimulationEngine extends AbstractSimu
 	public IExecutionControl getExecutionControl() {
 		return this;
 	}
+	
+	/**
+	 * Can be overriden to configure the use of an internal event queue.
+	 * @return false
+	 */
+	protected boolean useInternalEventQueue() {
+		return false;
+	}
 
 }

+ 7 - 0
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/container/EventDrivenSimulationEngine.java

@@ -53,4 +53,11 @@ public class EventDrivenSimulationEngine extends AbstractExecutionFlowSimulation
 			}
 		}
 	}
+
+	@Override
+	protected boolean useInternalEventQueue() {
+		return true;
+	}
+	
+	
 }

+ 74 - 7
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/DefaultExecutionFlowInterpreter.xtend

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2013 committers of YAKINDU and others.
+ * Copyright (c) 2013-2017 committers of YAKINDU and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -36,6 +36,10 @@ import org.yakindu.sct.model.sexec.transformation.SexecExtensions
 import org.yakindu.sct.model.sgraph.FinalState
 import org.yakindu.sct.model.sgraph.RegularState
 import org.yakindu.sct.simulation.core.sruntime.ExecutionContext
+import org.yakindu.sct.simulation.core.sruntime.ExecutionEvent
+import java.util.Queue
+import org.eclipse.xtend.lib.annotations.Data
+import java.util.LinkedList
 
 /**
  * 
@@ -44,7 +48,21 @@ import org.yakindu.sct.simulation.core.sruntime.ExecutionContext
  * 
  */
 @Singleton
-class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
+class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter, IEventRaiser {
+
+	@Data static class Event
+	{
+		
+		public ExecutionEvent event;
+		public Object value; 
+
+		new(ExecutionEvent ev, Object value) {
+			this.event = ev
+			this.value = value
+		}
+	}
+	
+	protected Queue<Event> internalEventQueue = new LinkedList<Event>()
 
 	@Inject
 	protected IStatementInterpreter statementInterpreter
@@ -63,16 +81,24 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
 	protected Map<Integer, ExecutionState> historyStateConfiguration
 	protected List<Step> executionStack
 	protected int activeStateIndex
+	protected boolean useInternalEventQueue 
 
 	boolean suspended = false
 
+
 	override initialize(ExecutionFlow flow, ExecutionContext context) {
+		initialize(flow, context, false)
+	}
+	
+	override initialize(ExecutionFlow flow, ExecutionContext context, boolean useInternalEventQueue) {
 		this.flow = flow
 		executionContext = context
 		executionStack = newLinkedList()
 		activeStateConfiguration = newArrayOfSize(flow.stateVector.size)
 		activeStateIndex = 0
 		historyStateConfiguration = newHashMap()
+		this.useInternalEventQueue = useInternalEventQueue
+		
 		if (!executionContext.snapshot){
 			flow.staticInitSequence.scheduleAndRun
 			flow.initSequence.scheduleAndRun
@@ -115,6 +141,30 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
 	}
 
 	override runCycle() {
+		
+		var Event event = null
+		
+		do {
+
+			// activate an event if there is one
+			if ( event !== null ) {			
+				event.event.raised = true
+				event.event.value = event.value	
+				event = null		
+			}
+			
+			// perform a run to completion step
+			rtcStep
+			
+			// get next event if available
+			if ( ! internalEventQueue.empty ) event = internalEventQueue.poll
+			
+		} while (event !== null)
+
+	}
+
+
+	def rtcStep() {
 		executionContext.raiseScheduledEvents
 		activeStateIndex = 0
 		if(executionContext.executedElements.size > 0) executionContext.executedElements.clear
@@ -126,7 +176,8 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
 		}
 		executionContext.clearLocalAndInEvents
 	}
-
+	
+	
 	override resume() {
 		timingService.resume
 		executionContext.suspendedElements.clear
@@ -178,7 +229,7 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
 	}
 
 	def dispatch Object execute(Check check) {
-		if (check.condition == null)
+		if (check.condition === null)
 			return true
 		return statementInterpreter.evaluateStatement(check.condition, executionContext)
 
@@ -206,7 +257,7 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
 		var check = execute(ifStep.check)
 		if (check as Boolean) {
 			ifStep.thenStep.schedule
-		} else if (ifStep.elseStep != null) {
+		} else if (ifStep.elseStep !== null) {
 			ifStep.elseStep.schedule
 		}
 		null
@@ -224,7 +275,7 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
 	}
 
 	def dispatch Object execute(HistoryEntry entry) {
-		if (historyStateConfiguration.get(entry.region.historyVector.offset) != null) {
+		if (historyStateConfiguration.get(entry.region.historyVector.offset) !== null) {
 			entry.historyStep?.execute
 		} else {
 			entry.initialStep?.execute
@@ -234,7 +285,7 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
 
 	def dispatch Object execute(StateSwitch stateSwitch) {
 		val historyRegion = stateSwitch.historyRegion
-		if (historyRegion != null) {
+		if (historyRegion !== null) {
 			val historyState = historyStateConfiguration.get(historyRegion.historyVector.offset)
 			stateSwitch.cases.filter[it.state == historyState].forEach[step.schedule]
 		} else {
@@ -255,6 +306,22 @@ class DefaultExecutionFlowInterpreter implements IExecutionFlowInterpreter {
 		null
 	}
 	
+	
+	override raise(ExecutionEvent ev, Object value) {
+			
+			if (useInternalEventQueue) {
+				
+				internalEventQueue.add(new Event(ev, value));	
+				
+			} else {
+			
+				ev.raised = true
+				ev.value = value
+			
+			}
+	}
+
+	
 	override boolean isActive() {
 		var List<RegularState> activeStates = executionContext.getAllActiveStates()
 		

+ 23 - 0
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/IEventRaiser.java

@@ -0,0 +1,23 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.simulation.core.sexec.interpreter;
+
+import org.yakindu.sct.simulation.core.sruntime.ExecutionEvent;
+
+/**
+ * 
+ * @author terfloth
+ */
+public interface IEventRaiser {
+	
+	void raise(ExecutionEvent ev, Object value);
+
+}

+ 1 - 0
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/IExecutionFlowInterpreter.java

@@ -22,6 +22,7 @@ import org.yakindu.sct.simulation.core.sruntime.ExecutionContext;
 public interface IExecutionFlowInterpreter {
 
 	public void initialize(final ExecutionFlow flow, final ExecutionContext context);
+	public void initialize(final ExecutionFlow flow, final ExecutionContext context, boolean useInternalEventQueue);
 
 	public void tearDown();
 

+ 9 - 5
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/StextStatementInterpreter.xtend

@@ -11,6 +11,7 @@
 package org.yakindu.sct.simulation.core.sexec.interpreter
 
 import com.google.inject.Inject
+import java.util.List
 import org.eclipse.emf.ecore.EObject
 import org.eclipse.xtext.naming.IQualifiedNameProvider
 import org.yakindu.base.expressions.expressions.AssignmentExpression
@@ -54,7 +55,6 @@ import org.yakindu.sct.simulation.core.sruntime.ExecutionContext
 import org.yakindu.sct.simulation.core.sruntime.ExecutionEvent
 import org.yakindu.sct.simulation.core.sruntime.ExecutionVariable
 import org.yakindu.sct.simulation.core.sruntime.ReferenceSlot
-import java.util.List
 
 /**
  * 
@@ -68,6 +68,8 @@ class StextStatementInterpreter extends AbstractStatementInterpreter {
 	extension IQualifiedNameProvider provider
 	@Inject(optional=true)
 	protected IOperationMockup operationDelegate
+	@Inject(optional=true)
+	protected extension IEventRaiser eventRaiser	
 	@Inject
 	protected extension IExecutionSlotResolver resolver
 	@Inject
@@ -156,12 +158,14 @@ class StextStatementInterpreter extends AbstractStatementInterpreter {
 
 	def dispatch Object execute(EventRaisingExpression eventRaising) {
 		var event = context.resolve(eventRaising.event)
-		if (eventRaising.value != null) {
-			event.value = eventRaising.value.execute
-		}
+
 		if (event instanceof ExecutionEvent) {
-			(event as ExecutionEvent).raised = true
+			
+			val value = eventRaising.value?.execute	
+		
+			if (eventRaiser != null) event.raise(value) 
 		}
+		
 		null
 	}
 

+ 0 - 1
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/sruntime/ExecutionContext.java

@@ -11,7 +11,6 @@
 package org.yakindu.sct.simulation.core.sruntime;
 
 import java.util.List;
-
 import org.eclipse.emf.ecore.EObject;
 
 import org.yakindu.base.base.NamedElement;

+ 91 - 0
test-plugins/org.yakindu.sct.generator.cpp.test/model/test.sgen

@@ -620,6 +620,97 @@ GeneratorModel for sctunit::cpp {
 		}
 	}
 	
+
+	test EventDrivenInternalEvent {
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.cpp.test" 
+			targetFolder = "gtests/EventDrivenInternalEvent"			
+		}	
+		
+		feature JUnitWrapper {
+			WrapToJUnit =  "true"
+		}	
+				
+		feature FunctionInlining {
+			inlineReactions = false
+			inlineEntryActions = false
+			inlineExitActions = false
+			inlineEnterSequences = false
+			inlineExitSequences = false
+			inlineChoices = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
+			inlineEntries = false
+		}
+		
+		feature SGenModel {
+			GenerateSGen = "true"
+		}
+	}
+	
+
+
+	test EventDrivenTriggeredByEvent {
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.cpp.test" 
+			targetFolder = "gtests/EventDrivenTriggeredByEvent"			
+		}	
+		
+		feature JUnitWrapper {
+			WrapToJUnit =  "true"
+		}	
+				
+		feature FunctionInlining {
+			inlineReactions = false
+			inlineEntryActions = false
+			inlineExitActions = false
+			inlineEnterSequences = false
+			inlineExitSequences = false
+			inlineChoices = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
+			inlineEntries = false
+		}
+		
+		feature SGenModel {
+			GenerateSGen = "true"
+		}
+	}
+	
+
+
+	test EventDrivenTriggeredByTimeEvent {
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.cpp.test" 
+			targetFolder = "gtests/EventDrivenTriggeredByTimeEvent"			
+		}	
+		
+		feature JUnitWrapper {
+			WrapToJUnit =  "true"
+		}	
+				
+		feature FunctionInlining {
+			inlineReactions = false
+			inlineEntryActions = false
+			inlineExitActions = false
+			inlineEnterSequences = false
+			inlineExitSequences = false
+			inlineChoices = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
+			inlineEntries = false
+		}
+		
+		feature SGenModel {
+			GenerateSGen = "true"
+		}
+	}
+	
+
+
 	test ExitOnSelfTransition{
 		
 		feature Outlet{ 

+ 79 - 0
test-plugins/org.yakindu.sct.generator.java.test/model/model.eventdriven.sgen

@@ -0,0 +1,79 @@
+GeneratorModel for yakindu::java {
+
+	statechart eventdriven.EventDrivenInternalEvent {
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "src-gen"
+		}
+
+		feature GeneralFeatures {
+			TimerService = true
+			RuntimeService = true
+		}
+
+		feature FunctionInlining {
+			inlineReactions = false
+			inlineEntryActions = false
+			inlineExitActions = false
+			inlineEnterSequences = false
+			inlineExitSequences = false
+			inlineChoices = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
+			inlineEntries = false
+		}
+	}
+
+	statechart eventdriven.EventDrivenTriggeredByEvent {
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "src-gen"
+		}
+
+		feature GeneralFeatures {
+			TimerService = true
+			RuntimeService = true
+		}
+
+		feature FunctionInlining {
+			inlineReactions = false
+			inlineEntryActions = false
+			inlineExitActions = false
+			inlineEnterSequences = false
+			inlineExitSequences = false
+			inlineChoices = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
+			inlineEntries = false
+		}
+	}
+
+
+
+	statechart eventdriven.EventDrivenTriggeredByTimeEvent {
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "src-gen"
+		}
+
+		feature GeneralFeatures {
+			TimerService = true
+			RuntimeService = true
+		}
+
+		feature FunctionInlining {
+			inlineReactions = false
+			inlineEntryActions = false
+			inlineExitActions = false
+			inlineEnterSequences = false
+			inlineExitSequences = false
+			inlineChoices = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
+			inlineEntries = false
+		}
+	}
+
+
+
+}

+ 54 - 0
test-plugins/org.yakindu.sct.generator.java.test/model/test.eventdriven.sgen

@@ -0,0 +1,54 @@
+GeneratorModel for sctunit::java {
+	
+	
+	test EventDrivenInternalEvent {
+		feature Naming {
+			basePackage = "org.yakindu.sct.generator.java.test"
+		}
+
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "test-gen"
+		}
+		
+		feature StatechartNaming {
+			basePackage = "org.yakindu.scr"
+			libraryTargetFolder = "src-gen"
+		}
+	}
+
+
+	test EventDrivenTriggeredByEvent {
+		feature Naming {
+			basePackage = "org.yakindu.sct.generator.java.test"
+		}
+
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "test-gen"
+		}
+		
+		feature StatechartNaming {
+			basePackage = "org.yakindu.scr"
+			libraryTargetFolder = "src-gen"
+		}
+	}
+
+
+	test EventDrivenTriggeredByTimeEvent {
+		feature Naming {
+			basePackage = "org.yakindu.sct.generator.java.test"
+		}
+
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "test-gen"
+		}
+		
+		feature StatechartNaming {
+			basePackage = "org.yakindu.scr"
+			libraryTargetFolder = "src-gen"
+		}
+	}
+	
+}

+ 109 - 0
test-plugins/org.yakindu.sct.generator.java.test/model/test.executionorder.sgen

@@ -0,0 +1,109 @@
+GeneratorModel for sctunit::java {
+	
+	
+	test ChildFirstExecutionHierarchy {
+		feature Naming {
+			basePackage = "org.yakindu.sct.generator.java.test"
+		}
+
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "test-gen"
+		}
+		
+		feature StatechartNaming {
+			basePackage = "org.yakindu.scr"
+			libraryTargetFolder = "src-gen"
+		}
+	}
+
+
+	test ChildFirstLocalReactions {
+		feature Naming {
+			basePackage = "org.yakindu.sct.generator.java.test"
+		}
+
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "test-gen"
+		}
+		
+		feature StatechartNaming {
+			basePackage = "org.yakindu.scr"
+			libraryTargetFolder = "src-gen"
+		}
+	}
+
+
+//	test ChildFirstOrthogonalReactions {
+//		feature Naming {
+//			basePackage = "org.yakindu.sct.generator.java.test"
+//		}
+//
+//		feature Outlet {
+//			targetProject = "org.yakindu.sct.generator.java.test"
+//			targetFolder = "test-gen"
+//		}
+//		
+//		feature StatechartNaming {
+//			basePackage = "org.yakindu.scr"
+//			libraryTargetFolder = "src-gen"
+//		}
+//	}
+
+
+
+	test ParentFirstExecutionHierarchy {
+		feature Naming {
+			basePackage = "org.yakindu.sct.generator.java.test"
+		}
+
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "test-gen"
+		}
+		
+		feature StatechartNaming {
+			basePackage = "org.yakindu.scr"
+			libraryTargetFolder = "src-gen"
+		}
+	}
+
+
+	test ParentFirstLocalReactions {
+		feature Naming {
+			basePackage = "org.yakindu.sct.generator.java.test"
+		}
+
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "test-gen"
+		}
+		
+		feature StatechartNaming {
+			basePackage = "org.yakindu.scr"
+			libraryTargetFolder = "src-gen"
+		}
+	}
+
+//	test ParentFirstOrthogonalReactions {
+//		feature Naming {
+//			basePackage = "org.yakindu.sct.generator.java.test"
+//		}
+//
+//		feature Outlet {
+//			targetProject = "org.yakindu.sct.generator.java.test"
+//			targetFolder = "test-gen"
+//		}
+//		
+//		feature StatechartNaming {
+//			basePackage = "org.yakindu.scr"
+//			libraryTargetFolder = "src-gen"
+//		}
+//	}
+
+
+
+
+	
+}

+ 2 - 2
test-plugins/org.yakindu.sct.generator.java.test/model/test.sgen

@@ -75,7 +75,7 @@ GeneratorModel for sctunit::java {
 		}
 	}
 
-	test Choice {
+	test CastExpressions {
 		feature Naming {
 			basePackage = "org.yakindu.sct.generator.java.test"
 		}
@@ -91,7 +91,7 @@ GeneratorModel for sctunit::java {
 		}
 	}
 
-	test CastExpressions {
+	test Choice {
 		feature Naming {
 			basePackage = "org.yakindu.sct.generator.java.test"
 		}

+ 52 - 18
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/VirtualTimer.java

@@ -1,3 +1,4 @@
+/* Generated by YAKINDU Statechart Tools code generator. */
 package org.yakindu.scr;
 
 import java.util.PriorityQueue;
@@ -6,8 +7,11 @@ import org.yakindu.scr.ITimer;
 import org.yakindu.scr.ITimerCallback;
 
 public class VirtualTimer implements ITimer {
-
-	private long virtualTime = 0;
+	
+	private long stopTime = 0;
+	protected long currentTime = 0;
+	protected long cyclePeriod = 0;
+	protected long scheduleCount = 0;
 
 	private Queue<VirtualTimeTask> tasks;
 
@@ -16,10 +20,20 @@ public class VirtualTimer implements ITimer {
 		long nextExecutionTime = 0;
 		long interval = 0;
 		long period = -1;
+		long scheduleOrder = 0;
 		boolean isCanceled = false;
 
 		public int compareTo(VirtualTimeTask o) {
-			return (int) (nextExecutionTime - o.nextExecutionTime);
+			if (nextExecutionTime != o.nextExecutionTime) {
+				return (int) (nextExecutionTime - o.nextExecutionTime);
+			} else if (o instanceof CycleTimeEventTask && !(this instanceof CycleTimeEventTask)) {
+				return -1;
+			} else if (!(o instanceof CycleTimeEventTask) && this instanceof CycleTimeEventTask) {
+				return 1;
+			} else if (period != o.period) {				
+				return (int) (period - o.period);
+			}
+			return (int) (scheduleOrder - o.scheduleOrder);
 		}
 
 		public boolean isCanceled() {
@@ -50,15 +64,40 @@ public class VirtualTimer implements ITimer {
 		}
 
 	}
+	
+	public static class CycleTimeEventTask extends VirtualTimeTask {
+
+		private IStatemachine statemachine;
+
+		public CycleTimeEventTask(IStatemachine statemachine) {
+			this.statemachine = statemachine;
+		}
+
+		public void run() {
+			statemachine.runCycle();
+		}
+
+	}
 
 	public VirtualTimer() {
 		tasks = new PriorityQueue<VirtualTimeTask>();
 	}
+	
+	public VirtualTimer(long cyclePeriod) {
+		tasks = new PriorityQueue<VirtualTimeTask>();
+		this.cyclePeriod = cyclePeriod;
+	}
 
 	public void timeLeap(long ms) {
-		virtualTime += ms;
+		stopTime = currentTime + ms;
 		processTasks();
 	}
+	
+	public void cycleLeap(long cycles){
+		for(int i = 1; i<=cycles; i++){
+			timeLeap(cyclePeriod);
+		}
+	}
 
 	@Override
 	public void setTimer(ITimerCallback callback, int eventID, long duration, boolean isPeriodical) {
@@ -81,17 +120,18 @@ public class VirtualTimer implements ITimer {
 
 	public void scheduleTask(VirtualTimeTask task, long interval) {
 		task.interval = interval;
-		scheduleInternal(task, virtualTime + interval, -1);
+		scheduleInternal(task, currentTime + interval, -1);
 	}
 
 	public void schedulePeriodicalTask(VirtualTimeTask task, long interval, long period) {
-		task.interval = interval;
-		scheduleInternal(task, virtualTime + interval, period);
+		scheduleInternal(task, currentTime + interval, period);
 	}
 
 	private void scheduleInternal(VirtualTimeTask task, long time, long period) {
 		task.nextExecutionTime = time;
 		task.period = period;
+		task.scheduleOrder = scheduleCount;
+		scheduleCount++;
 		tasks.add(task);
 	}
 
@@ -115,27 +155,21 @@ public class VirtualTimer implements ITimer {
 				tasks.remove();
 				continue;
 			}
-			long executionTime = task.nextExecutionTime;
-			if (executionTime <= virtualTime) {
+
+			if (task.nextExecutionTime <= stopTime) {
+				currentTime = task.nextExecutionTime;
 				task = tasks.poll();
 				task.run();
 				if (task.period > -1) {
-					schedulePeriodicalTask(task, task.interval, task.period);
+					schedulePeriodicalTask(task, task.period, task.period);
 				}
 			} else {
+				currentTime = stopTime;
 				processTasks = false;
 			}
 		}
 	}
 
-	public synchronized void pause() {
-		throw new RuntimeException("Implement me");
-	}
-
-	public synchronized void resume() {
-		throw new RuntimeException("Implement me");
-	}
-
 	public synchronized void stop() {
 		for (VirtualTimeTask timerTask : tasks) {
 			timerTask.cancel();

+ 2 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/childfirstexecutionhierarchy/ChildFirstExecutionHierarchyStatemachine.java

@@ -121,6 +121,8 @@ public class ChildFirstExecutionHierarchyStatemachine implements IChildFirstExec
 	
 	private int nextStateIndex;
 	
+	
+	
 	public ChildFirstExecutionHierarchyStatemachine() {
 		sCInterface = new SCInterfaceImpl();
 	}

+ 2 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/childfirstlocalreactions/ChildFirstLocalReactionsStatemachine.java

@@ -117,6 +117,8 @@ public class ChildFirstLocalReactionsStatemachine implements IChildFirstLocalRea
 	
 	private int nextStateIndex;
 	
+	
+	
 	public ChildFirstLocalReactionsStatemachine() {
 		sCInterface = new SCInterfaceImpl();
 	}

+ 2 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/childfirstorthogonalreactions/ChildFirstOrthogonalReactionsStatemachine.java

@@ -162,6 +162,8 @@ public class ChildFirstOrthogonalReactionsStatemachine implements IChildFirstOrt
 	
 	private int nextStateIndex;
 	
+	
+	
 	public ChildFirstOrthogonalReactionsStatemachine() {
 		sCInterface = new SCInterfaceImpl();
 	}

+ 564 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriveninternalevent/EventDrivenInternalEventStatemachine.java

@@ -0,0 +1,564 @@
+package org.yakindu.scr.eventdriveninternalevent;
+import java.util.LinkedList;
+import java.util.Queue;
+
+public class EventDrivenInternalEventStatemachine implements IEventDrivenInternalEventStatemachine {
+
+	protected class SCInterfaceImpl implements SCInterface {
+	
+		private boolean start;
+		
+		public void raiseStart() {
+			start = true;
+			runCycle();
+		}
+		
+		private boolean reset;
+		
+		public void raiseReset() {
+			reset = true;
+			runCycle();
+		}
+		
+		private long x;
+		
+		public long getX() {
+			return x;
+		}
+		
+		public void setX(long value) {
+			this.x = value;
+		}
+		
+		private long i1_sequence;
+		
+		public long getI1_sequence() {
+			return i1_sequence;
+		}
+		
+		public void setI1_sequence(long value) {
+			this.i1_sequence = value;
+		}
+		
+		private long i2_sequence;
+		
+		public long getI2_sequence() {
+			return i2_sequence;
+		}
+		
+		public void setI2_sequence(long value) {
+			this.i2_sequence = value;
+		}
+		
+		protected void clearEvents() {
+			start = false;
+			reset = false;
+		}
+	}
+	
+	protected SCInterfaceImpl sCInterface;
+	
+	private boolean initialized = false;
+	
+	public enum State {
+		eventDrivenInternalEvent_r1_A,
+		eventDrivenInternalEvent_r1_B,
+		eventDrivenInternalEvent_r2_C,
+		eventDrivenInternalEvent_r2_D,
+		eventDrivenInternalEvent_check_VALID,
+		eventDrivenInternalEvent_check_MULTIPLEEVENTS,
+		$NullState$
+	};
+	
+	private final State[] stateVector = new State[3];
+	
+	private int nextStateIndex;
+	
+	
+	private Queue<Runnable> internalEventQueue = new LinkedList<Runnable>();
+	
+	private boolean i1;
+	
+	private boolean i2;
+	
+	public EventDrivenInternalEventStatemachine() {
+		sCInterface = new SCInterfaceImpl();
+	}
+	
+	public void init() {
+		this.initialized = true;
+		for (int i = 0; i < 3; i++) {
+			stateVector[i] = State.$NullState$;
+		}
+		clearEvents();
+		clearOutEvents();
+		sCInterface.setX(0);
+		
+		sCInterface.setI1_sequence(0);
+		
+		sCInterface.setI2_sequence(0);
+	}
+	
+	public void enter() {
+		if (!initialized) {
+			throw new IllegalStateException(
+					"The state machine needs to be initialized first by calling the init() function.");
+		}
+		enterSequence_EventDrivenInternalEvent_r1_default();
+		enterSequence_EventDrivenInternalEvent_r2_default();
+		enterSequence_EventDrivenInternalEvent_check_default();
+	}
+	
+	public void exit() {
+		exitSequence_EventDrivenInternalEvent_r1();
+		exitSequence_EventDrivenInternalEvent_r2();
+		exitSequence_EventDrivenInternalEvent_check();
+	}
+	
+	/**
+	 * @see IStatemachine#isActive()
+	 */
+	public boolean isActive() {
+		return stateVector[0] != State.$NullState$||stateVector[1] != State.$NullState$||stateVector[2] != State.$NullState$;
+	}
+	
+	/** 
+	* Always returns 'false' since this state machine can never become final.
+	*
+	* @see IStatemachine#isFinal()
+	*/
+	public boolean isFinal() {
+		return false;
+	}
+	/**
+	* This method resets the incoming events (time events included).
+	*/
+	protected void clearEvents() {
+		sCInterface.clearEvents();
+		i1 = false;
+		i2 = false;
+	}
+	
+	/**
+	* This method resets the outgoing events.
+	*/
+	protected void clearOutEvents() {
+	}
+	
+	/**
+	* Returns true if the given state is currently active otherwise false.
+	*/
+	public boolean isStateActive(State state) {
+	
+		switch (state) {
+		case eventDrivenInternalEvent_r1_A:
+			return stateVector[0] == State.eventDrivenInternalEvent_r1_A;
+		case eventDrivenInternalEvent_r1_B:
+			return stateVector[0] == State.eventDrivenInternalEvent_r1_B;
+		case eventDrivenInternalEvent_r2_C:
+			return stateVector[1] == State.eventDrivenInternalEvent_r2_C;
+		case eventDrivenInternalEvent_r2_D:
+			return stateVector[1] == State.eventDrivenInternalEvent_r2_D;
+		case eventDrivenInternalEvent_check_VALID:
+			return stateVector[2] == State.eventDrivenInternalEvent_check_VALID;
+		case eventDrivenInternalEvent_check_MULTIPLEEVENTS:
+			return stateVector[2] == State.eventDrivenInternalEvent_check_MULTIPLEEVENTS;
+		default:
+			return false;
+		}
+	}
+	
+	public SCInterface getSCInterface() {
+		return sCInterface;
+	}
+	
+	private void raiseI1() {
+	
+		internalEventQueue.add( new Runnable() {
+			@Override public void run() {
+				i1 = true;					
+				runCycle();
+			}
+		});
+	}
+	
+	
+	private void raiseI2() {
+	
+		internalEventQueue.add( new Runnable() {
+			@Override public void run() {
+				i2 = true;					
+				runCycle();
+			}
+		});
+	}
+	
+	
+	public void raiseStart() {
+		sCInterface.raiseStart();
+	}
+	
+	public void raiseReset() {
+		sCInterface.raiseReset();
+	}
+	
+	public long getX() {
+		return sCInterface.getX();
+	}
+	
+	public void setX(long value) {
+		sCInterface.setX(value);
+	}
+	
+	public long getI1_sequence() {
+		return sCInterface.getI1_sequence();
+	}
+	
+	public void setI1_sequence(long value) {
+		sCInterface.setI1_sequence(value);
+	}
+	
+	public long getI2_sequence() {
+		return sCInterface.getI2_sequence();
+	}
+	
+	public void setI2_sequence(long value) {
+		sCInterface.setI2_sequence(value);
+	}
+	
+	private boolean check__lr0() {
+		return true;
+	}
+	
+	private boolean check_EventDrivenInternalEvent_r1_A_lr0_lr0() {
+		return sCInterface.start;
+	}
+	
+	private boolean check_EventDrivenInternalEvent_r1_A_tr0_tr0() {
+		return i2;
+	}
+	
+	private boolean check_EventDrivenInternalEvent_r1_B_lr0_lr0() {
+		return (i2) && (sCInterface.getI2_sequence()<10);
+	}
+	
+	private boolean check_EventDrivenInternalEvent_r1_B_tr0_tr0() {
+		return sCInterface.reset;
+	}
+	
+	private boolean check_EventDrivenInternalEvent_r2_C_tr0_tr0() {
+		return i1;
+	}
+	
+	private boolean check_EventDrivenInternalEvent_r2_D_lr0_lr0() {
+		return (i1) && (sCInterface.getI1_sequence()<10);
+	}
+	
+	private boolean check_EventDrivenInternalEvent_r2_D_tr0_tr0() {
+		return sCInterface.reset;
+	}
+	
+	private boolean check_EventDrivenInternalEvent_check_VALID_tr0_tr0() {
+		return (sCInterface.start && i1) || (sCInterface.start && i2) || (i1 && i2);
+	}
+	
+	private boolean check_EventDrivenInternalEvent_check_MULTIPLEEVENTS_tr0_tr0() {
+		return sCInterface.reset;
+	}
+	
+	private void effect__lr0() {
+		sCInterface.setX(sCInterface.getX() + 1);
+	}
+	
+	private void effect_EventDrivenInternalEvent_r1_A_lr0_lr0() {
+		raiseI1();
+	}
+	
+	private void effect_EventDrivenInternalEvent_r1_A_tr0() {
+		exitSequence_EventDrivenInternalEvent_r1_A();
+		sCInterface.setI2_sequence(sCInterface.x);
+		
+		enterSequence_EventDrivenInternalEvent_r1_B_default();
+	}
+	
+	private void effect_EventDrivenInternalEvent_r1_B_lr0_lr0() {
+		sCInterface.setI2_sequence(sCInterface.getI2_sequence() + 1);
+	}
+	
+	private void effect_EventDrivenInternalEvent_r1_B_tr0() {
+		exitSequence_EventDrivenInternalEvent_r1_B();
+		enterSequence_EventDrivenInternalEvent_r1_A_default();
+	}
+	
+	private void effect_EventDrivenInternalEvent_r2_C_tr0() {
+		exitSequence_EventDrivenInternalEvent_r2_C();
+		sCInterface.setI1_sequence(sCInterface.x);
+		
+		raiseI2();
+		
+		enterSequence_EventDrivenInternalEvent_r2_D_default();
+	}
+	
+	private void effect_EventDrivenInternalEvent_r2_D_lr0_lr0() {
+		sCInterface.setI1_sequence(sCInterface.getI1_sequence() + 1);
+	}
+	
+	private void effect_EventDrivenInternalEvent_r2_D_tr0() {
+		exitSequence_EventDrivenInternalEvent_r2_D();
+		enterSequence_EventDrivenInternalEvent_r2_C_default();
+	}
+	
+	private void effect_EventDrivenInternalEvent_check_VALID_tr0() {
+		exitSequence_EventDrivenInternalEvent_check_VALID();
+		enterSequence_EventDrivenInternalEvent_check_MULTIPLEEVENTS_default();
+	}
+	
+	private void effect_EventDrivenInternalEvent_check_MULTIPLEEVENTS_tr0() {
+		exitSequence_EventDrivenInternalEvent_check_MULTIPLEEVENTS();
+		enterSequence_EventDrivenInternalEvent_check_VALID_default();
+	}
+	
+	/* 'default' enter sequence for state A */
+	private void enterSequence_EventDrivenInternalEvent_r1_A_default() {
+		nextStateIndex = 0;
+		stateVector[0] = State.eventDrivenInternalEvent_r1_A;
+	}
+	
+	/* 'default' enter sequence for state B */
+	private void enterSequence_EventDrivenInternalEvent_r1_B_default() {
+		nextStateIndex = 0;
+		stateVector[0] = State.eventDrivenInternalEvent_r1_B;
+	}
+	
+	/* 'default' enter sequence for state C */
+	private void enterSequence_EventDrivenInternalEvent_r2_C_default() {
+		nextStateIndex = 1;
+		stateVector[1] = State.eventDrivenInternalEvent_r2_C;
+	}
+	
+	/* 'default' enter sequence for state D */
+	private void enterSequence_EventDrivenInternalEvent_r2_D_default() {
+		nextStateIndex = 1;
+		stateVector[1] = State.eventDrivenInternalEvent_r2_D;
+	}
+	
+	/* 'default' enter sequence for state VALID */
+	private void enterSequence_EventDrivenInternalEvent_check_VALID_default() {
+		nextStateIndex = 2;
+		stateVector[2] = State.eventDrivenInternalEvent_check_VALID;
+	}
+	
+	/* 'default' enter sequence for state MULTIPLEEVENTS */
+	private void enterSequence_EventDrivenInternalEvent_check_MULTIPLEEVENTS_default() {
+		nextStateIndex = 2;
+		stateVector[2] = State.eventDrivenInternalEvent_check_MULTIPLEEVENTS;
+	}
+	
+	/* 'default' enter sequence for region r1 */
+	private void enterSequence_EventDrivenInternalEvent_r1_default() {
+		react_EventDrivenInternalEvent_r1__entry_Default();
+	}
+	
+	/* 'default' enter sequence for region r2 */
+	private void enterSequence_EventDrivenInternalEvent_r2_default() {
+		react_EventDrivenInternalEvent_r2__entry_Default();
+	}
+	
+	/* 'default' enter sequence for region check */
+	private void enterSequence_EventDrivenInternalEvent_check_default() {
+		react_EventDrivenInternalEvent_check__entry_Default();
+	}
+	
+	/* Default exit sequence for state A */
+	private void exitSequence_EventDrivenInternalEvent_r1_A() {
+		nextStateIndex = 0;
+		stateVector[0] = State.$NullState$;
+	}
+	
+	/* Default exit sequence for state B */
+	private void exitSequence_EventDrivenInternalEvent_r1_B() {
+		nextStateIndex = 0;
+		stateVector[0] = State.$NullState$;
+	}
+	
+	/* Default exit sequence for state C */
+	private void exitSequence_EventDrivenInternalEvent_r2_C() {
+		nextStateIndex = 1;
+		stateVector[1] = State.$NullState$;
+	}
+	
+	/* Default exit sequence for state D */
+	private void exitSequence_EventDrivenInternalEvent_r2_D() {
+		nextStateIndex = 1;
+		stateVector[1] = State.$NullState$;
+	}
+	
+	/* Default exit sequence for state VALID */
+	private void exitSequence_EventDrivenInternalEvent_check_VALID() {
+		nextStateIndex = 2;
+		stateVector[2] = State.$NullState$;
+	}
+	
+	/* Default exit sequence for state MULTIPLEEVENTS */
+	private void exitSequence_EventDrivenInternalEvent_check_MULTIPLEEVENTS() {
+		nextStateIndex = 2;
+		stateVector[2] = State.$NullState$;
+	}
+	
+	/* Default exit sequence for region r1 */
+	private void exitSequence_EventDrivenInternalEvent_r1() {
+		switch (stateVector[0]) {
+		case eventDrivenInternalEvent_r1_A:
+			exitSequence_EventDrivenInternalEvent_r1_A();
+			break;
+		case eventDrivenInternalEvent_r1_B:
+			exitSequence_EventDrivenInternalEvent_r1_B();
+			break;
+		default:
+			break;
+		}
+	}
+	
+	/* Default exit sequence for region r2 */
+	private void exitSequence_EventDrivenInternalEvent_r2() {
+		switch (stateVector[1]) {
+		case eventDrivenInternalEvent_r2_C:
+			exitSequence_EventDrivenInternalEvent_r2_C();
+			break;
+		case eventDrivenInternalEvent_r2_D:
+			exitSequence_EventDrivenInternalEvent_r2_D();
+			break;
+		default:
+			break;
+		}
+	}
+	
+	/* Default exit sequence for region check */
+	private void exitSequence_EventDrivenInternalEvent_check() {
+		switch (stateVector[2]) {
+		case eventDrivenInternalEvent_check_VALID:
+			exitSequence_EventDrivenInternalEvent_check_VALID();
+			break;
+		case eventDrivenInternalEvent_check_MULTIPLEEVENTS:
+			exitSequence_EventDrivenInternalEvent_check_MULTIPLEEVENTS();
+			break;
+		default:
+			break;
+		}
+	}
+	
+	/* The reactions of state A. */
+	private void react_EventDrivenInternalEvent_r1_A() {
+		effect__lr0();
+		if (check_EventDrivenInternalEvent_r1_A_tr0_tr0()) {
+			effect_EventDrivenInternalEvent_r1_A_tr0();
+		} else {
+			if (check_EventDrivenInternalEvent_r1_A_lr0_lr0()) {
+				effect_EventDrivenInternalEvent_r1_A_lr0_lr0();
+			}
+		}
+	}
+	
+	/* The reactions of state B. */
+	private void react_EventDrivenInternalEvent_r1_B() {
+		effect__lr0();
+		if (check_EventDrivenInternalEvent_r1_B_tr0_tr0()) {
+			effect_EventDrivenInternalEvent_r1_B_tr0();
+		} else {
+			if (check_EventDrivenInternalEvent_r1_B_lr0_lr0()) {
+				effect_EventDrivenInternalEvent_r1_B_lr0_lr0();
+			}
+		}
+	}
+	
+	/* The reactions of state C. */
+	private void react_EventDrivenInternalEvent_r2_C() {
+		if (check_EventDrivenInternalEvent_r2_C_tr0_tr0()) {
+			effect_EventDrivenInternalEvent_r2_C_tr0();
+		}
+	}
+	
+	/* The reactions of state D. */
+	private void react_EventDrivenInternalEvent_r2_D() {
+		if (check_EventDrivenInternalEvent_r2_D_tr0_tr0()) {
+			effect_EventDrivenInternalEvent_r2_D_tr0();
+		} else {
+			if (check_EventDrivenInternalEvent_r2_D_lr0_lr0()) {
+				effect_EventDrivenInternalEvent_r2_D_lr0_lr0();
+			}
+		}
+	}
+	
+	/* The reactions of state VALID. */
+	private void react_EventDrivenInternalEvent_check_VALID() {
+		if (check_EventDrivenInternalEvent_check_VALID_tr0_tr0()) {
+			effect_EventDrivenInternalEvent_check_VALID_tr0();
+		}
+	}
+	
+	/* The reactions of state MULTIPLEEVENTS. */
+	private void react_EventDrivenInternalEvent_check_MULTIPLEEVENTS() {
+		if (check_EventDrivenInternalEvent_check_MULTIPLEEVENTS_tr0_tr0()) {
+			effect_EventDrivenInternalEvent_check_MULTIPLEEVENTS_tr0();
+		}
+	}
+	
+	/* Default react sequence for initial entry  */
+	private void react_EventDrivenInternalEvent_r1__entry_Default() {
+		enterSequence_EventDrivenInternalEvent_r1_A_default();
+	}
+	
+	/* Default react sequence for initial entry  */
+	private void react_EventDrivenInternalEvent_r2__entry_Default() {
+		enterSequence_EventDrivenInternalEvent_r2_C_default();
+	}
+	
+	/* Default react sequence for initial entry  */
+	private void react_EventDrivenInternalEvent_check__entry_Default() {
+		enterSequence_EventDrivenInternalEvent_check_VALID_default();
+	}
+	
+	public void runCycle() {
+		if (!initialized)
+			throw new IllegalStateException(
+					"The state machine needs to be initialized first by calling the init() function.");
+	
+		clearOutEvents();
+		singleCycle();
+		clearEvents();
+		
+		// process queued events
+		while (internalEventQueue.size() > 0) {
+			internalEventQueue.poll().run();
+			singleCycle();
+			clearEvents();
+		}
+	}
+	
+	protected void singleCycle() {
+		for (nextStateIndex = 0; nextStateIndex < stateVector.length; nextStateIndex++) {
+			switch (stateVector[nextStateIndex]) {
+			case eventDrivenInternalEvent_r1_A:
+				react_EventDrivenInternalEvent_r1_A();
+				break;
+			case eventDrivenInternalEvent_r1_B:
+				react_EventDrivenInternalEvent_r1_B();
+				break;
+			case eventDrivenInternalEvent_r2_C:
+				react_EventDrivenInternalEvent_r2_C();
+				break;
+			case eventDrivenInternalEvent_r2_D:
+				react_EventDrivenInternalEvent_r2_D();
+				break;
+			case eventDrivenInternalEvent_check_VALID:
+				react_EventDrivenInternalEvent_check_VALID();
+				break;
+			case eventDrivenInternalEvent_check_MULTIPLEEVENTS:
+				react_EventDrivenInternalEvent_check_MULTIPLEEVENTS();
+				break;
+			default:
+				// $NullState$
+			}
+		}
+	}
+}

+ 29 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriveninternalevent/IEventDrivenInternalEventStatemachine.java

@@ -0,0 +1,29 @@
+package org.yakindu.scr.eventdriveninternalevent;
+
+import org.yakindu.scr.IStatemachine;
+
+public interface IEventDrivenInternalEventStatemachine extends IStatemachine {
+
+	public interface SCInterface {
+	
+		public void raiseStart();
+		
+		public void raiseReset();
+		
+		public long getX();
+		
+		public void setX(long value);
+		
+		public long getI1_sequence();
+		
+		public void setI1_sequence(long value);
+		
+		public long getI2_sequence();
+		
+		public void setI2_sequence(long value);
+		
+	}
+	
+	public SCInterface getSCInterface();
+	
+}

+ 317 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriventriggeredbyevent/EventDrivenTriggeredByEventStatemachine.java

@@ -0,0 +1,317 @@
+package org.yakindu.scr.eventdriventriggeredbyevent;
+import org.yakindu.scr.ITimer;
+
+public class EventDrivenTriggeredByEventStatemachine implements IEventDrivenTriggeredByEventStatemachine {
+
+	protected class SCInterfaceImpl implements SCInterface {
+	
+		private boolean e;
+		
+		public void raiseE() {
+			e = true;
+			runCycle();
+		}
+		
+		private long x;
+		
+		public long getX() {
+			return x;
+		}
+		
+		public void setX(long value) {
+			this.x = value;
+		}
+		
+		protected void clearEvents() {
+			e = false;
+		}
+	}
+	
+	protected SCInterfaceImpl sCInterface;
+	
+	private boolean initialized = false;
+	
+	public enum State {
+		eventDrivenTriggeredByEvent_main_region_A,
+		eventDrivenTriggeredByEvent_main_region_B,
+		$NullState$
+	};
+	
+	private final State[] stateVector = new State[1];
+	
+	private int nextStateIndex;
+	
+	private ITimer timer;
+	
+	private final boolean[] timeEvents = new boolean[1];
+	
+	
+	public EventDrivenTriggeredByEventStatemachine() {
+		sCInterface = new SCInterfaceImpl();
+	}
+	
+	public void init() {
+		this.initialized = true;
+		if (timer == null) {
+			throw new IllegalStateException("timer not set.");
+		}
+		for (int i = 0; i < 1; i++) {
+			stateVector[i] = State.$NullState$;
+		}
+		clearEvents();
+		clearOutEvents();
+		sCInterface.setX(0);
+	}
+	
+	public void enter() {
+		if (!initialized) {
+			throw new IllegalStateException(
+					"The state machine needs to be initialized first by calling the init() function.");
+		}
+		if (timer == null) {
+			throw new IllegalStateException("timer not set.");
+		}
+		enterSequence_EventDrivenTriggeredByEvent_main_region_default();
+	}
+	
+	public void exit() {
+		exitSequence_EventDrivenTriggeredByEvent_main_region();
+	}
+	
+	/**
+	 * @see IStatemachine#isActive()
+	 */
+	public boolean isActive() {
+		return stateVector[0] != State.$NullState$;
+	}
+	
+	/** 
+	* Always returns 'false' since this state machine can never become final.
+	*
+	* @see IStatemachine#isFinal()
+	*/
+	public boolean isFinal() {
+		return false;
+	}
+	/**
+	* This method resets the incoming events (time events included).
+	*/
+	protected void clearEvents() {
+		sCInterface.clearEvents();
+		for (int i=0; i<timeEvents.length; i++) {
+			timeEvents[i] = false;
+		}
+	}
+	
+	/**
+	* This method resets the outgoing events.
+	*/
+	protected void clearOutEvents() {
+	}
+	
+	/**
+	* Returns true if the given state is currently active otherwise false.
+	*/
+	public boolean isStateActive(State state) {
+	
+		switch (state) {
+		case eventDrivenTriggeredByEvent_main_region_A:
+			return stateVector[0] == State.eventDrivenTriggeredByEvent_main_region_A;
+		case eventDrivenTriggeredByEvent_main_region_B:
+			return stateVector[0] == State.eventDrivenTriggeredByEvent_main_region_B;
+		default:
+			return false;
+		}
+	}
+	
+	/**
+	* Set the {@link ITimer} for the state machine. It must be set
+	* externally on a timed state machine before a run cycle can be correct
+	* executed.
+	* 
+	* @param timer
+	*/
+	public void setTimer(ITimer timer) {
+		this.timer = timer;
+	}
+	
+	/**
+	* Returns the currently used timer.
+	* 
+	* @return {@link ITimer}
+	*/
+	public ITimer getTimer() {
+		return timer;
+	}
+	
+	public void timeElapsed(int eventID) {
+		timeEvents[eventID] = true;
+		runCycle();
+	}
+	
+	public SCInterface getSCInterface() {
+		return sCInterface;
+	}
+	
+	public void raiseE() {
+		sCInterface.raiseE();
+	}
+	
+	public long getX() {
+		return sCInterface.getX();
+	}
+	
+	public void setX(long value) {
+		sCInterface.setX(value);
+	}
+	
+	private boolean check_EventDrivenTriggeredByEvent_main_region_A_lr0_lr0() {
+		return true;
+	}
+	
+	private boolean check_EventDrivenTriggeredByEvent_main_region_A_tr0_tr0() {
+		return sCInterface.e;
+	}
+	
+	private boolean check_EventDrivenTriggeredByEvent_main_region_B_lr0_lr0() {
+		return true;
+	}
+	
+	private boolean check_EventDrivenTriggeredByEvent_main_region_B_lr1_lr1() {
+		return timeEvents[0];
+	}
+	
+	private boolean check_EventDrivenTriggeredByEvent_main_region_B_tr0_tr0() {
+		return sCInterface.e;
+	}
+	
+	private void effect_EventDrivenTriggeredByEvent_main_region_A_lr0_lr0() {
+		sCInterface.setX(sCInterface.getX() + 1);
+	}
+	
+	private void effect_EventDrivenTriggeredByEvent_main_region_A_tr0() {
+		exitSequence_EventDrivenTriggeredByEvent_main_region_A();
+		enterSequence_EventDrivenTriggeredByEvent_main_region_B_default();
+	}
+	
+	private void effect_EventDrivenTriggeredByEvent_main_region_B_lr0_lr0() {
+		sCInterface.setX(sCInterface.getX() + 1);
+	}
+	
+	private void effect_EventDrivenTriggeredByEvent_main_region_B_lr1_lr1() {
+		sCInterface.setX(sCInterface.getX() + 0);
+	}
+	
+	private void effect_EventDrivenTriggeredByEvent_main_region_B_tr0() {
+		exitSequence_EventDrivenTriggeredByEvent_main_region_B();
+		enterSequence_EventDrivenTriggeredByEvent_main_region_A_default();
+	}
+	
+	/* Entry action for state 'B'. */
+	private void entryAction_EventDrivenTriggeredByEvent_main_region_B() {
+		timer.setTimer(this, 0, 100000 * 1000, false);
+	}
+	
+	/* Exit action for state 'B'. */
+	private void exitAction_EventDrivenTriggeredByEvent_main_region_B() {
+		timer.unsetTimer(this, 0);
+	}
+	
+	/* 'default' enter sequence for state A */
+	private void enterSequence_EventDrivenTriggeredByEvent_main_region_A_default() {
+		nextStateIndex = 0;
+		stateVector[0] = State.eventDrivenTriggeredByEvent_main_region_A;
+	}
+	
+	/* 'default' enter sequence for state B */
+	private void enterSequence_EventDrivenTriggeredByEvent_main_region_B_default() {
+		entryAction_EventDrivenTriggeredByEvent_main_region_B();
+		nextStateIndex = 0;
+		stateVector[0] = State.eventDrivenTriggeredByEvent_main_region_B;
+	}
+	
+	/* 'default' enter sequence for region main region */
+	private void enterSequence_EventDrivenTriggeredByEvent_main_region_default() {
+		react_EventDrivenTriggeredByEvent_main_region__entry_Default();
+	}
+	
+	/* Default exit sequence for state A */
+	private void exitSequence_EventDrivenTriggeredByEvent_main_region_A() {
+		nextStateIndex = 0;
+		stateVector[0] = State.$NullState$;
+	}
+	
+	/* Default exit sequence for state B */
+	private void exitSequence_EventDrivenTriggeredByEvent_main_region_B() {
+		nextStateIndex = 0;
+		stateVector[0] = State.$NullState$;
+		
+		exitAction_EventDrivenTriggeredByEvent_main_region_B();
+	}
+	
+	/* Default exit sequence for region main region */
+	private void exitSequence_EventDrivenTriggeredByEvent_main_region() {
+		switch (stateVector[0]) {
+		case eventDrivenTriggeredByEvent_main_region_A:
+			exitSequence_EventDrivenTriggeredByEvent_main_region_A();
+			break;
+		case eventDrivenTriggeredByEvent_main_region_B:
+			exitSequence_EventDrivenTriggeredByEvent_main_region_B();
+			break;
+		default:
+			break;
+		}
+	}
+	
+	/* The reactions of state A. */
+	private void react_EventDrivenTriggeredByEvent_main_region_A() {
+		if (check_EventDrivenTriggeredByEvent_main_region_A_tr0_tr0()) {
+			effect_EventDrivenTriggeredByEvent_main_region_A_tr0();
+		} else {
+			effect_EventDrivenTriggeredByEvent_main_region_A_lr0_lr0();
+		}
+	}
+	
+	/* The reactions of state B. */
+	private void react_EventDrivenTriggeredByEvent_main_region_B() {
+		if (check_EventDrivenTriggeredByEvent_main_region_B_tr0_tr0()) {
+			effect_EventDrivenTriggeredByEvent_main_region_B_tr0();
+		} else {
+			effect_EventDrivenTriggeredByEvent_main_region_B_lr0_lr0();
+			if (check_EventDrivenTriggeredByEvent_main_region_B_lr1_lr1()) {
+				effect_EventDrivenTriggeredByEvent_main_region_B_lr1_lr1();
+			}
+		}
+	}
+	
+	/* Default react sequence for initial entry  */
+	private void react_EventDrivenTriggeredByEvent_main_region__entry_Default() {
+		enterSequence_EventDrivenTriggeredByEvent_main_region_A_default();
+	}
+	
+	public void runCycle() {
+		if (!initialized)
+			throw new IllegalStateException(
+					"The state machine needs to be initialized first by calling the init() function.");
+	
+		clearOutEvents();
+		singleCycle();
+		clearEvents();
+		
+	}
+	
+	protected void singleCycle() {
+		for (nextStateIndex = 0; nextStateIndex < stateVector.length; nextStateIndex++) {
+			switch (stateVector[nextStateIndex]) {
+			case eventDrivenTriggeredByEvent_main_region_A:
+				react_EventDrivenTriggeredByEvent_main_region_A();
+				break;
+			case eventDrivenTriggeredByEvent_main_region_B:
+				react_EventDrivenTriggeredByEvent_main_region_B();
+				break;
+			default:
+				// $NullState$
+			}
+		}
+	}
+}

+ 20 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriventriggeredbyevent/IEventDrivenTriggeredByEventStatemachine.java

@@ -0,0 +1,20 @@
+package org.yakindu.scr.eventdriventriggeredbyevent;
+
+import org.yakindu.scr.IStatemachine;
+import org.yakindu.scr.ITimerCallback;
+
+public interface IEventDrivenTriggeredByEventStatemachine extends ITimerCallback,IStatemachine {
+
+	public interface SCInterface {
+	
+		public void raiseE();
+		
+		public long getX();
+		
+		public void setX(long value);
+		
+	}
+	
+	public SCInterface getSCInterface();
+	
+}

+ 328 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriventriggeredbytimeevent/EventDrivenTriggeredByTimeEventStatemachine.java

@@ -0,0 +1,328 @@
+package org.yakindu.scr.eventdriventriggeredbytimeevent;
+import org.yakindu.scr.ITimer;
+
+public class EventDrivenTriggeredByTimeEventStatemachine implements IEventDrivenTriggeredByTimeEventStatemachine {
+
+	protected class SCInterfaceImpl implements SCInterface {
+	
+		private long x;
+		
+		public long getX() {
+			return x;
+		}
+		
+		public void setX(long value) {
+			this.x = value;
+		}
+		
+		private long transition_count;
+		
+		public long getTransition_count() {
+			return transition_count;
+		}
+		
+		public void setTransition_count(long value) {
+			this.transition_count = value;
+		}
+		
+	}
+	
+	protected SCInterfaceImpl sCInterface;
+	
+	private boolean initialized = false;
+	
+	public enum State {
+		eventDrivenTriggeredByTimeEvent_r_A,
+		eventDrivenTriggeredByTimeEvent_r_B,
+		$NullState$
+	};
+	
+	private final State[] stateVector = new State[1];
+	
+	private int nextStateIndex;
+	
+	private ITimer timer;
+	
+	private final boolean[] timeEvents = new boolean[2];
+	
+	
+	public EventDrivenTriggeredByTimeEventStatemachine() {
+		sCInterface = new SCInterfaceImpl();
+	}
+	
+	public void init() {
+		this.initialized = true;
+		if (timer == null) {
+			throw new IllegalStateException("timer not set.");
+		}
+		for (int i = 0; i < 1; i++) {
+			stateVector[i] = State.$NullState$;
+		}
+		clearEvents();
+		clearOutEvents();
+		sCInterface.setX(0);
+		
+		sCInterface.setTransition_count(0);
+	}
+	
+	public void enter() {
+		if (!initialized) {
+			throw new IllegalStateException(
+					"The state machine needs to be initialized first by calling the init() function.");
+		}
+		if (timer == null) {
+			throw new IllegalStateException("timer not set.");
+		}
+		enterSequence_EventDrivenTriggeredByTimeEvent_r_default();
+	}
+	
+	public void exit() {
+		exitSequence_EventDrivenTriggeredByTimeEvent_r();
+	}
+	
+	/**
+	 * @see IStatemachine#isActive()
+	 */
+	public boolean isActive() {
+		return stateVector[0] != State.$NullState$;
+	}
+	
+	/** 
+	* Always returns 'false' since this state machine can never become final.
+	*
+	* @see IStatemachine#isFinal()
+	*/
+	public boolean isFinal() {
+		return false;
+	}
+	/**
+	* This method resets the incoming events (time events included).
+	*/
+	protected void clearEvents() {
+		for (int i=0; i<timeEvents.length; i++) {
+			timeEvents[i] = false;
+		}
+	}
+	
+	/**
+	* This method resets the outgoing events.
+	*/
+	protected void clearOutEvents() {
+	}
+	
+	/**
+	* Returns true if the given state is currently active otherwise false.
+	*/
+	public boolean isStateActive(State state) {
+	
+		switch (state) {
+		case eventDrivenTriggeredByTimeEvent_r_A:
+			return stateVector[0] == State.eventDrivenTriggeredByTimeEvent_r_A;
+		case eventDrivenTriggeredByTimeEvent_r_B:
+			return stateVector[0] == State.eventDrivenTriggeredByTimeEvent_r_B;
+		default:
+			return false;
+		}
+	}
+	
+	/**
+	* Set the {@link ITimer} for the state machine. It must be set
+	* externally on a timed state machine before a run cycle can be correct
+	* executed.
+	* 
+	* @param timer
+	*/
+	public void setTimer(ITimer timer) {
+		this.timer = timer;
+	}
+	
+	/**
+	* Returns the currently used timer.
+	* 
+	* @return {@link ITimer}
+	*/
+	public ITimer getTimer() {
+		return timer;
+	}
+	
+	public void timeElapsed(int eventID) {
+		timeEvents[eventID] = true;
+		runCycle();
+	}
+	
+	public SCInterface getSCInterface() {
+		return sCInterface;
+	}
+	
+	public long getX() {
+		return sCInterface.getX();
+	}
+	
+	public void setX(long value) {
+		sCInterface.setX(value);
+	}
+	
+	public long getTransition_count() {
+		return sCInterface.getTransition_count();
+	}
+	
+	public void setTransition_count(long value) {
+		sCInterface.setTransition_count(value);
+	}
+	
+	private boolean check_EventDrivenTriggeredByTimeEvent_r_A_lr0_lr0() {
+		return true;
+	}
+	
+	private boolean check_EventDrivenTriggeredByTimeEvent_r_A_tr0_tr0() {
+		return timeEvents[0];
+	}
+	
+	private boolean check_EventDrivenTriggeredByTimeEvent_r_B_lr0_lr0() {
+		return true;
+	}
+	
+	private boolean check_EventDrivenTriggeredByTimeEvent_r_B_tr0_tr0() {
+		return timeEvents[1];
+	}
+	
+	private void effect_EventDrivenTriggeredByTimeEvent_r_A_lr0_lr0() {
+		sCInterface.setX(sCInterface.getX() + 1);
+	}
+	
+	private void effect_EventDrivenTriggeredByTimeEvent_r_A_tr0() {
+		exitSequence_EventDrivenTriggeredByTimeEvent_r_A();
+		sCInterface.setTransition_count(sCInterface.getTransition_count() + 1);
+		
+		enterSequence_EventDrivenTriggeredByTimeEvent_r_B_default();
+	}
+	
+	private void effect_EventDrivenTriggeredByTimeEvent_r_B_lr0_lr0() {
+		sCInterface.setX(sCInterface.getX() + 1);
+	}
+	
+	private void effect_EventDrivenTriggeredByTimeEvent_r_B_tr0() {
+		exitSequence_EventDrivenTriggeredByTimeEvent_r_B();
+		sCInterface.setTransition_count(sCInterface.getTransition_count() + 1);
+		
+		enterSequence_EventDrivenTriggeredByTimeEvent_r_A_default();
+	}
+	
+	/* Entry action for state 'A'. */
+	private void entryAction_EventDrivenTriggeredByTimeEvent_r_A() {
+		timer.setTimer(this, 0, 1 * 1000, false);
+	}
+	
+	/* Entry action for state 'B'. */
+	private void entryAction_EventDrivenTriggeredByTimeEvent_r_B() {
+		timer.setTimer(this, 1, 1 * 1000, false);
+	}
+	
+	/* Exit action for state 'A'. */
+	private void exitAction_EventDrivenTriggeredByTimeEvent_r_A() {
+		timer.unsetTimer(this, 0);
+	}
+	
+	/* Exit action for state 'B'. */
+	private void exitAction_EventDrivenTriggeredByTimeEvent_r_B() {
+		timer.unsetTimer(this, 1);
+	}
+	
+	/* 'default' enter sequence for state A */
+	private void enterSequence_EventDrivenTriggeredByTimeEvent_r_A_default() {
+		entryAction_EventDrivenTriggeredByTimeEvent_r_A();
+		nextStateIndex = 0;
+		stateVector[0] = State.eventDrivenTriggeredByTimeEvent_r_A;
+	}
+	
+	/* 'default' enter sequence for state B */
+	private void enterSequence_EventDrivenTriggeredByTimeEvent_r_B_default() {
+		entryAction_EventDrivenTriggeredByTimeEvent_r_B();
+		nextStateIndex = 0;
+		stateVector[0] = State.eventDrivenTriggeredByTimeEvent_r_B;
+	}
+	
+	/* 'default' enter sequence for region r */
+	private void enterSequence_EventDrivenTriggeredByTimeEvent_r_default() {
+		react_EventDrivenTriggeredByTimeEvent_r__entry_Default();
+	}
+	
+	/* Default exit sequence for state A */
+	private void exitSequence_EventDrivenTriggeredByTimeEvent_r_A() {
+		nextStateIndex = 0;
+		stateVector[0] = State.$NullState$;
+		
+		exitAction_EventDrivenTriggeredByTimeEvent_r_A();
+	}
+	
+	/* Default exit sequence for state B */
+	private void exitSequence_EventDrivenTriggeredByTimeEvent_r_B() {
+		nextStateIndex = 0;
+		stateVector[0] = State.$NullState$;
+		
+		exitAction_EventDrivenTriggeredByTimeEvent_r_B();
+	}
+	
+	/* Default exit sequence for region r */
+	private void exitSequence_EventDrivenTriggeredByTimeEvent_r() {
+		switch (stateVector[0]) {
+		case eventDrivenTriggeredByTimeEvent_r_A:
+			exitSequence_EventDrivenTriggeredByTimeEvent_r_A();
+			break;
+		case eventDrivenTriggeredByTimeEvent_r_B:
+			exitSequence_EventDrivenTriggeredByTimeEvent_r_B();
+			break;
+		default:
+			break;
+		}
+	}
+	
+	/* The reactions of state A. */
+	private void react_EventDrivenTriggeredByTimeEvent_r_A() {
+		if (check_EventDrivenTriggeredByTimeEvent_r_A_tr0_tr0()) {
+			effect_EventDrivenTriggeredByTimeEvent_r_A_tr0();
+		} else {
+			effect_EventDrivenTriggeredByTimeEvent_r_A_lr0_lr0();
+		}
+	}
+	
+	/* The reactions of state B. */
+	private void react_EventDrivenTriggeredByTimeEvent_r_B() {
+		if (check_EventDrivenTriggeredByTimeEvent_r_B_tr0_tr0()) {
+			effect_EventDrivenTriggeredByTimeEvent_r_B_tr0();
+		} else {
+			effect_EventDrivenTriggeredByTimeEvent_r_B_lr0_lr0();
+		}
+	}
+	
+	/* Default react sequence for initial entry  */
+	private void react_EventDrivenTriggeredByTimeEvent_r__entry_Default() {
+		enterSequence_EventDrivenTriggeredByTimeEvent_r_A_default();
+	}
+	
+	public void runCycle() {
+		if (!initialized)
+			throw new IllegalStateException(
+					"The state machine needs to be initialized first by calling the init() function.");
+	
+		clearOutEvents();
+		singleCycle();
+		clearEvents();
+		
+	}
+	
+	protected void singleCycle() {
+		for (nextStateIndex = 0; nextStateIndex < stateVector.length; nextStateIndex++) {
+			switch (stateVector[nextStateIndex]) {
+			case eventDrivenTriggeredByTimeEvent_r_A:
+				react_EventDrivenTriggeredByTimeEvent_r_A();
+				break;
+			case eventDrivenTriggeredByTimeEvent_r_B:
+				react_EventDrivenTriggeredByTimeEvent_r_B();
+				break;
+			default:
+				// $NullState$
+			}
+		}
+	}
+}

+ 22 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/eventdriventriggeredbytimeevent/IEventDrivenTriggeredByTimeEventStatemachine.java

@@ -0,0 +1,22 @@
+package org.yakindu.scr.eventdriventriggeredbytimeevent;
+
+import org.yakindu.scr.IStatemachine;
+import org.yakindu.scr.ITimerCallback;
+
+public interface IEventDrivenTriggeredByTimeEventStatemachine extends ITimerCallback,IStatemachine {
+
+	public interface SCInterface {
+	
+		public long getX();
+		
+		public void setX(long value);
+		
+		public long getTransition_count();
+		
+		public void setTransition_count(long value);
+		
+	}
+	
+	public SCInterface getSCInterface();
+	
+}

+ 2 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/parentfirstexecutionhierarchy/ParentFirstExecutionHierarchyStatemachine.java

@@ -121,6 +121,8 @@ public class ParentFirstExecutionHierarchyStatemachine implements IParentFirstEx
 	
 	private int nextStateIndex;
 	
+	
+	
 	public ParentFirstExecutionHierarchyStatemachine() {
 		sCInterface = new SCInterfaceImpl();
 	}

+ 2 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/parentfirstlocalreactions/ParentFirstLocalReactionsStatemachine.java

@@ -117,6 +117,8 @@ public class ParentFirstLocalReactionsStatemachine implements IParentFirstLocalR
 	
 	private int nextStateIndex;
 	
+	
+	
 	public ParentFirstLocalReactionsStatemachine() {
 		sCInterface = new SCInterfaceImpl();
 	}

+ 2 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/parentfirstorthogonalreactions/ParentFirstOrthogonalReactionsStatemachine.java

@@ -162,6 +162,8 @@ public class ParentFirstOrthogonalReactionsStatemachine implements IParentFirstO
 	
 	private int nextStateIndex;
 	
+	
+	
 	public ParentFirstOrthogonalReactionsStatemachine() {
 		sCInterface = new SCInterfaceImpl();
 	}

+ 8 - 10
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/AllTests.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 import org.junit.runner.RunWith;
@@ -28,6 +19,8 @@ import org.junit.runners.Suite.SuiteClasses;
 	ConstOnlyDefaultScope.class,
 	ConstOnlyInternalScope.class,
 	ConstOnlyNamedScope.class,
+	ChildFirstExecutionHierarchy.class,
+	ChildFirstLocalReactions.class,
 	Declarations.class,
 	DeepEntry.class,
 	DeepHistory.class,
@@ -37,6 +30,9 @@ import org.junit.runners.Suite.SuiteClasses;
 	EntryChoice.class,
 	EntryExitSelfTransition.class,
 	EntryReactionAction.class,
+	EventDrivenInternalEvent.class,
+	EventDrivenTriggeredByEvent.class,
+	EventDrivenTriggeredByTimeEvent.class,
 	ExitOnSelfTransition.class,
 	ExitState.class,
 	FeatureCalls.class,
@@ -56,6 +52,8 @@ import org.junit.runners.Suite.SuiteClasses;
 	OperationsTest.class,
 	OutEventLifeCycle.class,
 	Parenthesis.class,
+	ParentFirstExecutionHierarchy.class,
+	ParentFirstLocalReactions.class,
 	PriorityValues.class,
 	RaiseEvent.class,
 	ReadOnlyVariable.class,

+ 13 - 15
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/AlwaysOncycle.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.alwaysoncycle.AlwaysOncycleStatemachine;
 import org.yakindu.scr.alwaysoncycle.AlwaysOncycleStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for AlwaysOncycle
@@ -23,18 +17,22 @@ import org.yakindu.scr.alwaysoncycle.AlwaysOncycleStatemachine.State;
 public class AlwaysOncycle {
 	
 	private AlwaysOncycleStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void alwaysOncycle_setUp() {
 		statemachine = new AlwaysOncycleStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void alwaysOncycle_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -42,16 +40,16 @@ public class AlwaysOncycle {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.main_region_StateA));
 		while (statemachine.getValue() < 5l) {
-			statemachine.runCycle();
+			timer.cycleLeap(1);
 			assertTrue(statemachine.isStateActive(State.main_region_StateA));
 		}
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_StateB));
 		while (statemachine.getValue() < 5l) {
-			statemachine.runCycle();
+			timer.cycleLeap(1);
 			assertTrue(statemachine.isStateActive(State.main_region_StateB));
 		}
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_StateA));
 	}
 }

+ 17 - 19
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/AssignmentAsExpression.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.assignmentasexpression.AssignmentAsExpressionStatemachine;
 import org.yakindu.scr.assignmentasexpression.AssignmentAsExpressionStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for AssignmentAsExpression
@@ -23,18 +17,22 @@ import org.yakindu.scr.assignmentasexpression.AssignmentAsExpressionStatemachine
 public class AssignmentAsExpression {
 	
 	private AssignmentAsExpressionStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void assignmentAsExpression_setUp() {
 		statemachine = new AssignmentAsExpressionStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void assignmentAsExpression_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -43,29 +41,29 @@ public class AssignmentAsExpression {
 		assertTrue(statemachine.isStateActive(State.main_region_Add));
 		assertTrue(statemachine.getB() == 5l);
 		assertTrue(statemachine.getA() == 9l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_Subtract));
 		assertTrue(statemachine.getD() == 6l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_Multiply));
 		assertTrue(statemachine.getE() == 15l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_Divide));
 		assertTrue(statemachine.getG() == 1l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_Modulo));
 		assertTrue(statemachine.getI() == 1l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_Shift));
 		assertTrue(statemachine.getJ() == 16l);
 		assertTrue(statemachine.getK() == 4l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_boolean_And));
 		assertTrue(statemachine.getL() == 1l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_boolean_Or));
 		assertTrue(statemachine.getP() == 15l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_boolean_Xor));
 		assertTrue(statemachine.getU() == 12l);
 		statemachine.exit();

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/BitExpressions.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.bitexpressions.BitExpressionsStatemachine;
 import org.yakindu.scr.bitexpressions.BitExpressionsStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for BitExpressions
@@ -23,18 +17,22 @@ import org.yakindu.scr.bitexpressions.BitExpressionsStatemachine.State;
 public class BitExpressions {
 	
 	private BitExpressionsStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void bitExpressions_setUp() {
 		statemachine = new BitExpressionsStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void bitExpressions_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -44,7 +42,7 @@ public class BitExpressions {
 		assertTrue(statemachine.getMyBit1() == 5l);
 		assertTrue(statemachine.getMyBit2() == 7l);
 		statemachine.raiseE1();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_StateB));
 		assertTrue(statemachine.getLeftBitshift() == 10l);
 		assertTrue(statemachine.getRightBitshift() == 2l);

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/BooleanExpressions.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.booleanexpressions.BooleanExpressionsStatemachine;
 import org.yakindu.scr.booleanexpressions.BooleanExpressionsStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for BooleanExpressions
@@ -23,18 +17,22 @@ import org.yakindu.scr.booleanexpressions.BooleanExpressionsStatemachine.State;
 public class BooleanExpressions {
 	
 	private BooleanExpressionsStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void booleanExpressions_setUp() {
 		statemachine = new BooleanExpressionsStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void booleanExpressions_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -44,7 +42,7 @@ public class BooleanExpressions {
 		assertTrue(statemachine.getMyBool1() == true);
 		assertTrue(statemachine.getMyBool2() == false);
 		statemachine.raiseE1();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_StateB));
 		assertTrue(statemachine.getAnd() == false);
 		assertTrue(statemachine.getOr() == true);

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/CKeywords.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.ckeywords.CKeywordsStatemachine;
 import org.yakindu.scr.ckeywords.CKeywordsStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for CKeywords
@@ -23,18 +17,22 @@ import org.yakindu.scr.ckeywords.CKeywordsStatemachine.State;
 public class CKeywords {
 	
 	private CKeywordsStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void cKeywords_setUp() {
 		statemachine = new CKeywordsStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void cKeywords_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -42,7 +40,7 @@ public class CKeywords {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.auto_char));
 		statemachine.raiseAuto();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.auto_loop));
 		assertTrue(statemachine.isStateActive(State.auto_loop_switch_case));
 		assertTrue(statemachine.isStateActive(State.auto_loop_switch_case_enum_asm));

+ 11 - 13
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/CastExpressions.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.castexpressions.CastExpressionsStatemachine;
 import org.yakindu.scr.castexpressions.CastExpressionsStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for CastExpressions
@@ -23,18 +17,22 @@ import org.yakindu.scr.castexpressions.CastExpressionsStatemachine.State;
 public class CastExpressions {
 	
 	private CastExpressionsStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void castExpressions_setUp() {
 		statemachine = new CastExpressionsStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void castExpressions_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -42,9 +40,9 @@ public class CastExpressions {
 		statemachine.enter();
 		assertTrue(statemachine.getRealValue() == 5l);
 		assertTrue(statemachine.getIntValue() == 5l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.getRealValue() == 15l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_C));
 		assertTrue(statemachine.getRealValue() == 757l);
 	}

+ 96 - 0
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ChildFirstExecutionHierarchy.java

@@ -0,0 +1,96 @@
+/* Generated by YAKINDU Statechart Tools code generator. */
+
+package org.yakindu.sct.generator.java.test;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+import org.yakindu.scr.childfirstexecutionhierarchy.ChildFirstExecutionHierarchyStatemachine;
+import org.yakindu.scr.childfirstexecutionhierarchy.ChildFirstExecutionHierarchyStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
+
+/**
+ * Unit TestCase for ChildFirstExecutionHierarchy
+ */
+@SuppressWarnings("all")
+public class ChildFirstExecutionHierarchy {
+	
+	private ChildFirstExecutionHierarchyStatemachine statemachine;	
+	private VirtualTimer timer;
+	
+	
+	@Before
+	public void childFirstExecutionHierarchy_setUp() {
+		statemachine = new ChildFirstExecutionHierarchyStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
+		statemachine.init();
+	}
+
+	@After
+	public void childFirstExecutionHierarchy_tearDown() {
+		statemachine = null;
+		
+		timer = null;
+	}
+	
+	@Test
+	public void childShouldTakeTransition() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.childFirstExecutionHierarchy_r_A_r_AA_r_AAA));
+		statemachine.raiseE();
+		timer.cycleLeap(1);
+		assertTrue(statemachine.isStateActive(State.childFirstExecutionHierarchy_r_B));
+		assertTrue(!statemachine.getA_reacted());
+		assertTrue(!statemachine.getAa_reacted());
+		assertTrue(statemachine.getAaa_reacted());
+		assertNoLocalReaction();
+	}
+	@Test
+	public void parentShouldTakeTransition() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.childFirstExecutionHierarchy_r_A_r_AA_r_AAA));
+		statemachine.setDisable_aaa(true);
+		statemachine.raiseE();
+		timer.cycleLeap(1);
+		assertTrue(statemachine.isStateActive(State.childFirstExecutionHierarchy_r_B));
+		assertTrue(!statemachine.getA_reacted());
+		assertTrue(statemachine.getAa_reacted());
+		assertTrue(!statemachine.getAaa_reacted());
+		assertTrue(!statemachine.getA_local());
+		assertTrue(!statemachine.getAa_local());
+		assertTrue(statemachine.getAaa_local());
+	}
+	@Test
+	public void grandparentShouldTakeTransition() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.childFirstExecutionHierarchy_r_A_r_AA_r_AAA));
+		statemachine.setDisable_aa(true);
+		statemachine.setDisable_aaa(true);
+		statemachine.raiseE();
+		timer.cycleLeap(1);
+		assertTrue(statemachine.isStateActive(State.childFirstExecutionHierarchy_r_B));
+		assertTrue(statemachine.getA_reacted());
+		assertTrue(!statemachine.getAa_reacted());
+		assertTrue(!statemachine.getAaa_reacted());
+		assertTrue(!statemachine.getA_local());
+		assertTrue(statemachine.getAa_local());
+		assertTrue(statemachine.getAaa_local());
+	}
+	@Test
+	public void expectLocalReactrionsExecuteWithNoTransition() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.childFirstExecutionHierarchy_r_A_r_AA_r_AAA));
+		timer.cycleLeap(1);
+		assertTrue(statemachine.isStateActive(State.childFirstExecutionHierarchy_r_A_r_AA_r_AAA));
+		assertTrue(statemachine.getA_local());
+		assertTrue(statemachine.getAa_local());
+		assertTrue(statemachine.getAaa_local());
+	}
+	public void assertNoLocalReaction() {
+		assertTrue(!statemachine.getA_local());
+		assertTrue(!statemachine.getAa_local());
+		assertTrue(!statemachine.getAaa_local());
+	}
+}

+ 89 - 0
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ChildFirstLocalReactions.java

@@ -0,0 +1,89 @@
+/* Generated by YAKINDU Statechart Tools code generator. */
+
+package org.yakindu.sct.generator.java.test;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+import org.yakindu.scr.childfirstlocalreactions.ChildFirstLocalReactionsStatemachine;
+import org.yakindu.scr.childfirstlocalreactions.ChildFirstLocalReactionsStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
+
+/**
+ * Unit TestCase for ChildFirstLocalReactions
+ */
+@SuppressWarnings("all")
+public class ChildFirstLocalReactions {
+	
+	private ChildFirstLocalReactionsStatemachine statemachine;	
+	private VirtualTimer timer;
+	
+	protected long counter = 0l;
+	
+	@Before
+	public void childFirstLocalReactions_setUp() {
+		statemachine = new ChildFirstLocalReactionsStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
+		statemachine.init();
+	}
+
+	@After
+	public void childFirstLocalReactions_tearDown() {
+		statemachine = null;
+		
+		timer = null;
+	}
+	
+	@Test
+	public void expectBottomUpLocalReactionOrder() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.childFirstLocalReactions_r_A_r_AA_r_AAA));
+		timer.cycleLeap(1);
+		assertTrue(statemachine.isStateActive(State.childFirstLocalReactions_r_A_r_AA_r_AAA));
+		assertTrue(statemachine.getAaa_local() == 1l);
+		assertTrue(statemachine.getAa_local() == 2l);
+		assertTrue(statemachine.getA_local() == 3l);
+		assertTrue(statemachine.getSm_local() == 4l);
+	}
+	@Test
+	public void expectParentLocalReactionOnChildLocalTransition() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.childFirstLocalReactions_r_A_r_AA_r_AAA));
+		statemachine.raiseE();
+		timer.cycleLeap(1);
+		assertTrue(statemachine.isStateActive(State.childFirstLocalReactions_r_A_r_AA_r_AAB));
+		assertTrue(statemachine.getAaa_local() == 0l);
+		assertTrue(statemachine.getAa_local() == 1l);
+		assertTrue(statemachine.getA_local() == 2l);
+		assertTrue(statemachine.getSm_local() == 3l);
+	}
+	@Test
+	public void expectGrandparentLocalReactionOnParentLocalTransition() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.childFirstLocalReactions_r_A_r_AA_r_AAA));
+		statemachine.setDisable_aaa(true);
+		statemachine.raiseE();
+		timer.cycleLeap(1);
+		assertTrue(statemachine.isStateActive(State.childFirstLocalReactions_r_A_r_AB));
+		assertTrue(statemachine.getAaa_local() == 1l);
+		assertTrue(statemachine.getAa_local() == 0l);
+		assertTrue(statemachine.getA_local() == 2l);
+		assertTrue(statemachine.getSm_local() == 3l);
+	}
+	@Test
+	public void expectNoLocalReactionOnGrandparentTransition() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.childFirstLocalReactions_r_A_r_AA_r_AAA));
+		statemachine.setDisable_aaa(true);
+		statemachine.setDisable_aa(true);
+		statemachine.raiseE();
+		timer.cycleLeap(1);
+		assertTrue(statemachine.isStateActive(State.childFirstLocalReactions_r_B));
+		assertTrue(statemachine.getAaa_local() == 1l);
+		assertTrue(statemachine.getAa_local() == 2l);
+		assertTrue(statemachine.getA_local() == 0l);
+		assertTrue(statemachine.getSm_local() == 3l);
+	}
+}

+ 13 - 15
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/Choice.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.choice.ChoiceStatemachine;
 import org.yakindu.scr.choice.ChoiceStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for Choice
@@ -23,18 +17,22 @@ import org.yakindu.scr.choice.ChoiceStatemachine.State;
 public class Choice {
 	
 	private ChoiceStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void choice_setUp() {
 		statemachine = new ChoiceStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void choice_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -77,27 +75,27 @@ public class Choice {
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.setC(valueForC);
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 	}
 	public void initForEventF(boolean valueForC) {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.setC(valueForC);
 		statemachine.raiseF();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 	}
 	public void initForEventG(boolean valueForC) {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.setC(valueForC);
 		statemachine.raiseG();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 	}
 	public void initForEventH(boolean valueForC) {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.setC(valueForC);
 		statemachine.raiseH();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 	}
 }

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ConditionalExpression.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.conditionalexpressions.ConditionalExpressionsStatemachine;
 import org.yakindu.scr.conditionalexpressions.ConditionalExpressionsStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for ConditionalExpressions
@@ -23,18 +17,22 @@ import org.yakindu.scr.conditionalexpressions.ConditionalExpressionsStatemachine
 public class ConditionalExpression {
 	
 	private ConditionalExpressionsStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void conditionalExpression_setUp() {
 		statemachine = new ConditionalExpressionsStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void conditionalExpression_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -43,7 +41,7 @@ public class ConditionalExpression {
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		assertTrue(statemachine.getCondition() == 1l);
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_B));
 		assertTrue(statemachine.getCondition() == 2l);
 	}

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ConstOnlyDefaultScope.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.constonlydefaultscope.ConstOnlyDefaultScopeStatemachine;
 import org.yakindu.scr.constonlydefaultscope.ConstOnlyDefaultScopeStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for ConstOnlyDefaultScope
@@ -23,18 +17,22 @@ import org.yakindu.scr.constonlydefaultscope.ConstOnlyDefaultScopeStatemachine.S
 public class ConstOnlyDefaultScope {
 	
 	private ConstOnlyDefaultScopeStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void constOnlyDefaultScope_setUp() {
 		statemachine = new ConstOnlyDefaultScopeStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void constOnlyDefaultScope_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -46,7 +44,7 @@ public class ConstOnlyDefaultScope {
 	public void stateTransition() {
 		statemachine.enter();
 		statemachine.getSCIA().raiseE(1l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.constOnlyDefaultScope_main_region_B));
 	}
 }

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ConstOnlyInternalScope.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.constonlyinternalscope.ConstOnlyInternalScopeStatemachine;
 import org.yakindu.scr.constonlyinternalscope.ConstOnlyInternalScopeStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for ConstOnlyInternalScope
@@ -23,18 +17,22 @@ import org.yakindu.scr.constonlyinternalscope.ConstOnlyInternalScopeStatemachine
 public class ConstOnlyInternalScope {
 	
 	private ConstOnlyInternalScopeStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void constOnlyInternalScope_setUp() {
 		statemachine = new ConstOnlyInternalScopeStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void constOnlyInternalScope_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -46,7 +44,7 @@ public class ConstOnlyInternalScope {
 	public void stateTransition() {
 		statemachine.enter();
 		statemachine.raiseE(1l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.constOnlyInternalScope_main_region_B));
 	}
 }

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ConstOnlyNamedScope.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.constonlynamedscope.ConstOnlyNamedScopeStatemachine;
 import org.yakindu.scr.constonlynamedscope.ConstOnlyNamedScopeStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for ConstOnlyNamedScope
@@ -23,18 +17,22 @@ import org.yakindu.scr.constonlynamedscope.ConstOnlyNamedScopeStatemachine.State
 public class ConstOnlyNamedScope {
 	
 	private ConstOnlyNamedScopeStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void constOnlyNamedScope_setUp() {
 		statemachine = new ConstOnlyNamedScopeStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void constOnlyNamedScope_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -46,7 +44,7 @@ public class ConstOnlyNamedScope {
 	public void stateTransition() {
 		statemachine.enter();
 		statemachine.raiseE(1l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.constOnlyNamedScope_main_region_B));
 	}
 }

+ 12 - 14
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ConstantsTests.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.constants.ConstantsStatemachine;
 import org.yakindu.scr.constants.ConstantsStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for Constants
@@ -23,18 +17,22 @@ import org.yakindu.scr.constants.ConstantsStatemachine.State;
 public class ConstantsTests {
 	
 	private ConstantsStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void constantsTests_setUp() {
 		statemachine = new ConstantsStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void constantsTests_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -45,14 +43,14 @@ public class ConstantsTests {
 		assertTrue(statemachine.getY() == 20l);
 		assertTrue(statemachine.getSCINamed().getY().equals("Hello World"));
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.getResult() == 20l);
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_C));
 		assertTrue(statemachine.getResult() == 100l);
 		statemachine.raiseE2(statemachine.getX());
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.getResult() == 1000l);
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 	}

+ 9 - 11
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/Declarations.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.declarations.DeclarationsStatemachine;
 import org.yakindu.scr.declarations.DeclarationsStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for Declarations
@@ -23,18 +17,22 @@ import org.yakindu.scr.declarations.DeclarationsStatemachine.State;
 public class Declarations {
 	
 	private DeclarationsStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void declarations_setUp() {
 		statemachine = new DeclarationsStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void declarations_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test

+ 9 - 11
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/DeepEntry.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.deepentry.DeepEntryStatemachine;
 import org.yakindu.scr.deepentry.DeepEntryStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for DeepEntry
@@ -23,18 +17,22 @@ import org.yakindu.scr.deepentry.DeepEntryStatemachine.State;
 public class DeepEntry {
 	
 	private DeepEntryStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void deepEntry_setUp() {
 		statemachine = new DeepEntryStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void deepEntry_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test

+ 15 - 17
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/DeepHistory.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.deephistory.DeepHistoryStatemachine;
 import org.yakindu.scr.deephistory.DeepHistoryStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for DeepHistory
@@ -23,39 +17,43 @@ import org.yakindu.scr.deephistory.DeepHistoryStatemachine.State;
 public class DeepHistory {
 	
 	private DeepHistoryStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void deepHistory_setUp() {
 		statemachine = new DeepHistoryStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void deepHistory_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
 	public void deepHistoryTest() {
 		statemachine.enter();
 		statemachine.raiseEvent1();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		statemachine.raiseEvent3();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		statemachine.raiseEvent5();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		statemachine.raiseEvent7();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(!statemachine.isStateActive(State.mainRegion_State1));
 		assertTrue(statemachine.isStateActive(State.mainRegion_State2__region0_State4__region0_State7__region0_State9));
 		statemachine.raiseEvent2();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.mainRegion_State1));
 		assertTrue(!statemachine.isStateActive(State.mainRegion_State2__region0_State4__region0_State7__region0_State9));
 		statemachine.raiseEvent1();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(!statemachine.isStateActive(State.mainRegion_State1));
 		assertTrue(statemachine.isStateActive(State.mainRegion_State2__region0_State4__region0_State7__region0_State9));
 	}

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/DynamicChoice.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.dynamicchoice.DynamicChoiceStatemachine;
 import org.yakindu.scr.dynamicchoice.DynamicChoiceStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for DynamicChoice
@@ -23,25 +17,29 @@ import org.yakindu.scr.dynamicchoice.DynamicChoiceStatemachine.State;
 public class DynamicChoice {
 	
 	private DynamicChoiceStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void dynamicChoice_setUp() {
 		statemachine = new DynamicChoiceStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void dynamicChoice_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
 	public void dynamicChoiceTest() {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.main_region_Start));
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 	}
 }

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EmptyTransition.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.emptytransition.EmptyTransitionStatemachine;
 import org.yakindu.scr.emptytransition.EmptyTransitionStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for EmptyTransition
@@ -23,24 +17,28 @@ import org.yakindu.scr.emptytransition.EmptyTransitionStatemachine.State;
 public class EmptyTransition {
 	
 	private EmptyTransitionStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void emptyTransition_setUp() {
 		statemachine = new EmptyTransitionStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void emptyTransition_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
 	public void emptyTransitionTest() {
 		statemachine.enter();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(!statemachine.isStateActive(State.main_region_B));
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 	}

+ 12 - 14
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EnterState.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.enterstate.EnterStateStatemachine;
 import org.yakindu.scr.enterstate.EnterStateStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for EnterState
@@ -23,18 +17,22 @@ import org.yakindu.scr.enterstate.EnterStateStatemachine.State;
 public class EnterState {
 	
 	private EnterStateStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void enterState_setUp() {
 		statemachine = new EnterStateStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void enterState_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -42,7 +40,7 @@ public class EnterState {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.r_A));
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.r_B_r_E));
 	}
 	@Test
@@ -50,7 +48,7 @@ public class EnterState {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.r_A));
 		statemachine.raiseF();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.r_B_r_F));
 	}
 	@Test
@@ -58,7 +56,7 @@ public class EnterState {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.r_A));
 		statemachine.raiseG();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.r_B_r_E));
 	}
 }

+ 11 - 13
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EntryChoice.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.entrychoice.EntryChoiceStatemachine;
 import org.yakindu.scr.entrychoice.EntryChoiceStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for EntryChoice
@@ -23,25 +17,29 @@ import org.yakindu.scr.entrychoice.EntryChoiceStatemachine.State;
 public class EntryChoice {
 	
 	private EntryChoiceStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void entryChoice_setUp() {
 		statemachine = new EntryChoiceStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void entryChoice_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
 	public void entryChoiceTest() {
 		statemachine.enter();
-		statemachine.runCycle();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 	}
 }

+ 13 - 15
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EntryExitSelfTransition.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.entryexitselftransition.EntryExitSelfTransitionStatemachine;
 import org.yakindu.scr.entryexitselftransition.EntryExitSelfTransitionStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for EntryExitSelfTransition
@@ -23,25 +17,29 @@ import org.yakindu.scr.entryexitselftransition.EntryExitSelfTransitionStatemachi
 public class EntryExitSelfTransition {
 	
 	private EntryExitSelfTransitionStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void entryExitSelfTransition_setUp() {
 		statemachine = new EntryExitSelfTransitionStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void entryExitSelfTransition_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
 	public void selfTransitionToChildState() {
 		init();
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.getEntries() == 1l);
 		assertTrue(statemachine.getExits() == 1l);
 		assertTrue(statemachine.isStateActive(State.main_region_A__region0_C));
@@ -51,12 +49,12 @@ public class EntryExitSelfTransition {
 	public void selfTransitionFromChildState() {
 		init();
 		statemachine.raiseE1();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.getEntries() == 0l);
 		assertTrue(statemachine.getExits() == 0l);
 		assertTrue(statemachine.isStateActive(State.main_region_A__region0_C));
 		statemachine.raiseE1();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_A__region0_B));
 		assertTrue(statemachine.getEntries() == 1l);
 		assertTrue(statemachine.getExits() == 1l);
@@ -64,7 +62,7 @@ public class EntryExitSelfTransition {
 	}
 	public void init() {
 		statemachine.enter();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.getEntries() == 1l);
 		assertTrue(statemachine.isStateActive(State.main_region_A__region0_B));
 		statemachine.setEntries(0l);

+ 13 - 15
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EntryReactionAction.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.entryreactionaction.EntryReactionActionStatemachine;
 import org.yakindu.scr.entryreactionaction.EntryReactionActionStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for EntryReactionAction
@@ -23,18 +17,22 @@ import org.yakindu.scr.entryreactionaction.EntryReactionActionStatemachine.State
 public class EntryReactionAction {
 	
 	private EntryReactionActionStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void entryReactionAction_setUp() {
 		statemachine = new EntryReactionActionStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void entryReactionAction_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -49,7 +47,7 @@ public class EntryReactionAction {
 	public void entryOnRTS() {
 		init();
 		statemachine.raiseB();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(!statemachine.getEnteredR1());
 		assertTrue(!statemachine.getEnteredR2());
 		assertTrue(!statemachine.getEnteredBdefault());
@@ -59,7 +57,7 @@ public class EntryReactionAction {
 	public void noEntryTransitionActionOnHistory() {
 		init();
 		statemachine.raiseD();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(!statemachine.getEnteredR1());
 		assertTrue(!statemachine.getEnteredR2());
 		assertTrue(!statemachine.getEnteredBdefault());
@@ -68,9 +66,9 @@ public class EntryReactionAction {
 	public void init() {
 		statemachine.enter();
 		statemachine.raiseB();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		statemachine.raiseD();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		statemachine.setEnteredR1(false);
 		statemachine.setEnteredR2(false);
 		statemachine.setEnteredBdefault(false);

+ 46 - 0
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EventDrivenInternalEvent.java

@@ -0,0 +1,46 @@
+/* Generated by YAKINDU Statechart Tools code generator. */
+
+package org.yakindu.sct.generator.java.test;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+import org.yakindu.scr.eventdriveninternalevent.EventDrivenInternalEventStatemachine;
+import org.yakindu.scr.eventdriveninternalevent.EventDrivenInternalEventStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+
+/**
+ * Unit TestCase for EventDrivenInternalEvent
+ */
+@SuppressWarnings("all")
+public class EventDrivenInternalEvent {
+	
+	private EventDrivenInternalEventStatemachine statemachine;	
+	
+	
+	@Before
+	public void eventDrivenInternalEvent_setUp() {
+		statemachine = new EventDrivenInternalEventStatemachine();
+		statemachine.init();
+	}
+
+	@After
+	public void eventDrivenInternalEvent_tearDown() {
+		statemachine = null;
+		
+	}
+	
+	@Test
+	public void checkInternlEventQueueing() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.eventDrivenInternalEvent_r1_A));
+		assertTrue(statemachine.isStateActive(State.eventDrivenInternalEvent_r2_C));
+		assertTrue(statemachine.isStateActive(State.eventDrivenInternalEvent_check_VALID));
+		statemachine.raiseStart();
+		assertTrue(statemachine.isStateActive(State.eventDrivenInternalEvent_r1_B));
+		assertTrue(statemachine.isStateActive(State.eventDrivenInternalEvent_r2_D));
+		assertTrue(statemachine.isStateActive(State.eventDrivenInternalEvent_check_VALID));
+		assertTrue(statemachine.getI1_sequence() == 2l);
+		assertTrue(statemachine.getI2_sequence() == 3l);
+		statemachine.exit();
+	}
+}

+ 56 - 0
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EventDrivenTriggeredByEvent.java

@@ -0,0 +1,56 @@
+/* Generated by YAKINDU Statechart Tools code generator. */
+
+package org.yakindu.sct.generator.java.test;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+import org.yakindu.scr.eventdriventriggeredbyevent.EventDrivenTriggeredByEventStatemachine;
+import org.yakindu.scr.eventdriventriggeredbyevent.EventDrivenTriggeredByEventStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+
+/**
+ * Unit TestCase for EventDrivenTriggeredByEvent
+ */
+@SuppressWarnings("all")
+public class EventDrivenTriggeredByEvent {
+	
+	private EventDrivenTriggeredByEventStatemachine statemachine;	
+	private VirtualTimer timer;
+	
+	
+	@Before
+	public void eventDrivenTriggeredByEvent_setUp() {
+		statemachine = new EventDrivenTriggeredByEventStatemachine();
+		timer = new VirtualTimer(200);
+		statemachine.setTimer(timer);
+		statemachine.init();
+	}
+
+	@After
+	public void eventDrivenTriggeredByEvent_tearDown() {
+		statemachine = null;
+		
+		timer = null;
+	}
+	
+	@Test
+	public void internalEventTriggersRunCycle() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.eventDrivenTriggeredByEvent_main_region_A));
+		statemachine.raiseE();
+		assertTrue(statemachine.isStateActive(State.eventDrivenTriggeredByEvent_main_region_B));
+		assertTrue(statemachine.getX() == 0l);
+		statemachine.raiseE();
+		assertTrue(statemachine.isStateActive(State.eventDrivenTriggeredByEvent_main_region_A));
+		assertTrue(statemachine.getX() == 0l);
+		statemachine.exit();
+	}
+	@Test
+	public void proceedTimeDoesNotTriggerRunCycle() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.eventDrivenTriggeredByEvent_main_region_A));
+		timer.timeLeap(120000);
+		assertTrue(statemachine.getX() == 0l);
+		statemachine.exit();
+	}
+}

+ 62 - 0
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EventDrivenTriggeredByTimeEvent.java

@@ -0,0 +1,62 @@
+/* Generated by YAKINDU Statechart Tools code generator. */
+
+package org.yakindu.sct.generator.java.test;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+import org.yakindu.scr.eventdriventriggeredbytimeevent.EventDrivenTriggeredByTimeEventStatemachine;
+import org.yakindu.scr.eventdriventriggeredbytimeevent.EventDrivenTriggeredByTimeEventStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+
+/**
+ * Unit TestCase for EventDrivenTriggeredByTimeEvent
+ */
+@SuppressWarnings("all")
+public class EventDrivenTriggeredByTimeEvent {
+	
+	private EventDrivenTriggeredByTimeEventStatemachine statemachine;	
+	private VirtualTimer timer;
+	
+	
+	@Before
+	public void eventDrivenTriggeredByTimeEvent_setUp() {
+		statemachine = new EventDrivenTriggeredByTimeEventStatemachine();
+		timer = new VirtualTimer(200);
+		statemachine.setTimer(timer);
+		statemachine.init();
+	}
+
+	@After
+	public void eventDrivenTriggeredByTimeEvent_tearDown() {
+		statemachine = null;
+		
+		timer = null;
+	}
+	
+	@Test
+	public void timeEventTriggersRunCycle() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.eventDrivenTriggeredByTimeEvent_r_A));
+		assertTrue(statemachine.getX() == 0l);
+		timer.timeLeap(999);
+		assertTrue(statemachine.isStateActive(State.eventDrivenTriggeredByTimeEvent_r_A));
+		assertTrue(statemachine.getX() == 0l);
+		timer.timeLeap(1);
+		assertTrue(statemachine.isStateActive(State.eventDrivenTriggeredByTimeEvent_r_B));
+		assertTrue(statemachine.getX() == 0l);
+		assertTrue(statemachine.getTransition_count() == 1l);
+		timer.timeLeap(1000);
+		assertTrue(statemachine.isStateActive(State.eventDrivenTriggeredByTimeEvent_r_A));
+		assertTrue(statemachine.getX() == 0l);
+		assertTrue(statemachine.getTransition_count() == 2l);
+		timer.timeLeap(999000);
+		assertTrue(statemachine.isStateActive(State.eventDrivenTriggeredByTimeEvent_r_B));
+		assertTrue(statemachine.getX() == 0l);
+		assertTrue(statemachine.getTransition_count() == 1001l);
+		timer.timeLeap(999000);
+		assertTrue(statemachine.isStateActive(State.eventDrivenTriggeredByTimeEvent_r_A));
+		assertTrue(statemachine.getX() == 0l);
+		assertTrue(statemachine.getTransition_count() == 2000l);
+		statemachine.exit();
+	}
+}

+ 11 - 13
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ExitOnSelfTransition.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.exitonselftransition.ExitOnSelfTransitionStatemachine;
 import org.yakindu.scr.exitonselftransition.ExitOnSelfTransitionStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for ExitOnSelfTransition
@@ -23,18 +17,22 @@ import org.yakindu.scr.exitonselftransition.ExitOnSelfTransitionStatemachine.Sta
 public class ExitOnSelfTransition {
 	
 	private ExitOnSelfTransitionStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void exitOnSelfTransition_setUp() {
 		statemachine = new ExitOnSelfTransitionStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void exitOnSelfTransition_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -44,11 +42,11 @@ public class ExitOnSelfTransition {
 		assertTrue(statemachine.getEntryCount() == 1l);
 		assertTrue(statemachine.getExitCount() == 0l);
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.getEntryCount() == 2l);
 		assertTrue(statemachine.getExitCount() == 1l);
 		statemachine.raiseF();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.getEntryCount() == 2l);
 		assertTrue(statemachine.getExitCount() == 2l);
 	}

+ 13 - 15
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/ExitState.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.exitstate.ExitStateStatemachine;
 import org.yakindu.scr.exitstate.ExitStateStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for ExitState
@@ -23,18 +17,22 @@ import org.yakindu.scr.exitstate.ExitStateStatemachine.State;
 public class ExitState {
 	
 	private ExitStateStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void exitState_setUp() {
 		statemachine = new ExitStateStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void exitState_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -42,7 +40,7 @@ public class ExitState {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.r_A));
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.r_E));
 	}
 	@Test
@@ -50,7 +48,7 @@ public class ExitState {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.r_A));
 		statemachine.raiseF();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.r_F));
 	}
 	@Test
@@ -58,14 +56,14 @@ public class ExitState {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.r_A));
 		statemachine.raiseG();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.r_E));
 	}
 	@Test
 	public void remainInA() {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.r_A));
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.r_A));
 	}
 }

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/FeatureCalls.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.featurecalls.FeatureCallsStatemachine;
 import org.yakindu.scr.featurecalls.FeatureCallsStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for FeatureCalls
@@ -23,25 +17,29 @@ import org.yakindu.scr.featurecalls.FeatureCallsStatemachine.State;
 public class FeatureCalls {
 	
 	private FeatureCallsStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void featureCalls_setUp() {
 		statemachine = new FeatureCallsStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void featureCalls_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
 	public void featureCalls() {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.main_region_A));
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 	}
 }

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/FinalState.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.finalstate.FinalStateStatemachine;
 import org.yakindu.scr.finalstate.FinalStateStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for FinalState
@@ -23,24 +17,28 @@ import org.yakindu.scr.finalstate.FinalStateStatemachine.State;
 public class FinalState {
 	
 	private FinalStateStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void finalState_setUp() {
 		statemachine = new FinalStateStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void finalState_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
 	public void statechartNameTest() {
 		statemachine.enter();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isFinal());
 	}
 }

+ 14 - 16
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/Guard.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.guard.GuardStatemachine;
 import org.yakindu.scr.guard.GuardStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for Guard
@@ -23,18 +17,22 @@ import org.yakindu.scr.guard.GuardStatemachine.State;
 public class Guard {
 	
 	private GuardStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void guard_setUp() {
 		statemachine = new GuardStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void guard_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -42,19 +40,19 @@ public class Guard {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.raiseEvent1();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.raiseEvent2();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_B));
 		statemachine.raiseReturn();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.raiseEvent1();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_B));
 		statemachine.raiseReturn();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 	}
 }

+ 11 - 13
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/GuardedEntry.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.guardedentry.GuardedEntryStatemachine;
 import org.yakindu.scr.guardedentry.GuardedEntryStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for GuardedEntry
@@ -23,18 +17,22 @@ import org.yakindu.scr.guardedentry.GuardedEntryStatemachine.State;
 public class GuardedEntry {
 	
 	private GuardedEntryStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void guardedEntry_setUp() {
 		statemachine = new GuardedEntryStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void guardedEntry_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -65,12 +63,12 @@ public class GuardedEntry {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_B));
 		statemachine.setGuard(guardVar);
 		statemachine.setDone(doneVar);
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 	}
 }

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/GuardedExit.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.guardedexit.GuardedExitStatemachine;
 import org.yakindu.scr.guardedexit.GuardedExitStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for GuardedExit
@@ -23,18 +17,22 @@ import org.yakindu.scr.guardedexit.GuardedExitStatemachine.State;
 public class GuardedExit {
 	
 	private GuardedExitStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void guardedExit_setUp() {
 		statemachine = new GuardedExitStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void guardedExit_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -53,7 +51,7 @@ public class GuardedExit {
 	}
 	public void checkDone(boolean shouldBeDone) {
 		statemachine.raiseE();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_B));
 		assertTrue(shouldBeDone ? statemachine.getDone()  : !statemachine.getDone());
 	}

+ 14 - 16
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/HistoryWithExitPoint.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.historywithexitpoint.HistoryWithExitPointStatemachine;
 import org.yakindu.scr.historywithexitpoint.HistoryWithExitPointStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for HistoryWithExitPoint
@@ -23,18 +17,22 @@ import org.yakindu.scr.historywithexitpoint.HistoryWithExitPointStatemachine.Sta
 public class HistoryWithExitPoint {
 	
 	private HistoryWithExitPointStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void historyWithExitPoint_setUp() {
 		statemachine = new HistoryWithExitPointStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void historyWithExitPoint_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -42,19 +40,19 @@ public class HistoryWithExitPoint {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.mr_A_r_X1));
 		statemachine.raisePush();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.mr_B));
 		statemachine.raiseBack();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.mr_A_r_X1));
 		statemachine.raiseNext();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.mr_A_r_X2));
 		statemachine.raisePush();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.mr_B));
 		statemachine.raiseBack();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.mr_A_r_X2));
 	}
 }

+ 16 - 18
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/HistoryWithoutInitialStep.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.historywithoutinitialstep.HistoryWithoutInitialStepStatemachine;
 import org.yakindu.scr.historywithoutinitialstep.HistoryWithoutInitialStepStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for HistoryWithoutInitialStep
@@ -23,18 +17,22 @@ import org.yakindu.scr.historywithoutinitialstep.HistoryWithoutInitialStepStatem
 public class HistoryWithoutInitialStep {
 	
 	private HistoryWithoutInitialStepStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void historyWithoutInitialStep_setUp() {
 		statemachine = new HistoryWithoutInitialStepStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void historyWithoutInitialStep_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -42,7 +40,7 @@ public class HistoryWithoutInitialStep {
 		init();
 		assertTrue(statemachine.isStateActive(State.main_region_B_r1_C));
 		statemachine.raiseNext();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_B_r1_D));
 	}
 	@Test
@@ -50,29 +48,29 @@ public class HistoryWithoutInitialStep {
 		init();
 		assertTrue(statemachine.isStateActive(State.main_region_B_r1_C));
 		statemachine.raiseToA();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.raiseToHistory();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_B_r1_C));
 	}
 	@Test
 	public void enterDThroughHistory() {
 		init();
 		statemachine.raiseNext();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_B_r1_D));
 		statemachine.raiseToA();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.raiseToHistory();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.isStateActive(State.main_region_B_r1_D));
 	}
 	public void init() {
 		statemachine.enter();
 		assertTrue(statemachine.isStateActive(State.main_region_A));
 		statemachine.raiseToB();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 	}
 }

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/InEventLifeCycle.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.ineventlifecycle.InEventLifeCycleStatemachine;
 import org.yakindu.scr.ineventlifecycle.InEventLifeCycleStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for InEventLifeCycle
@@ -23,18 +17,22 @@ import org.yakindu.scr.ineventlifecycle.InEventLifeCycleStatemachine.State;
 public class InEventLifeCycle {
 	
 	private InEventLifeCycleStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void inEventLifeCycle_setUp() {
 		statemachine = new InEventLifeCycleStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void inEventLifeCycle_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -42,7 +40,7 @@ public class InEventLifeCycle {
 		statemachine.enter();
 		statemachine.raiseE();
 		assertTrue(statemachine.getI() == 0l);
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.getI() == 1l);
 	}
 }

+ 10 - 12
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/IntegerExpressions.java

@@ -1,13 +1,4 @@
-/**
-* Copyright (c) 2017 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
+/* Generated by YAKINDU Statechart Tools code generator. */
 
 package org.yakindu.sct.generator.java.test;
 
@@ -15,6 +6,9 @@ import org.junit.*;
 import static org.junit.Assert.*;
 import org.yakindu.scr.integerexpressions.IntegerExpressionsStatemachine;
 import org.yakindu.scr.integerexpressions.IntegerExpressionsStatemachine.State;	
+import org.yakindu.scr.VirtualTimer;
+import org.yakindu.scr.VirtualTimer.VirtualTimeTask;
+import org.yakindu.scr.VirtualTimer.CycleTimeEventTask;
 
 /**
  * Unit TestCase for IntegerExpressions
@@ -23,18 +17,22 @@ import org.yakindu.scr.integerexpressions.IntegerExpressionsStatemachine.State;
 public class IntegerExpressions {
 	
 	private IntegerExpressionsStatemachine statemachine;	
-	
+	private VirtualTimer timer;
 	
 	
 	@Before
 	public void integerExpressions_setUp() {
 		statemachine = new IntegerExpressionsStatemachine();
+		timer = new VirtualTimer(200);
+		timer.schedulePeriodicalTask(new CycleTimeEventTask(statemachine), 200, 200);
 		statemachine.init();
 	}
 
 	@After
 	public void integerExpressions_tearDown() {
 		statemachine = null;
+		
+		timer = null;
 	}
 	
 	@Test
@@ -44,7 +42,7 @@ public class IntegerExpressions {
 		assertTrue(statemachine.getMyInt1() == 10l);
 		assertTrue(statemachine.getMyInt2() == 5l);
 		statemachine.raiseE1();
-		statemachine.runCycle();
+		timer.cycleLeap(1);
 		assertTrue(statemachine.getLess() == false);
 		assertTrue(statemachine.getGreater() == true);
 		assertTrue(statemachine.getEqualOrLess() == false);

+ 0 - 0
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/InternalEventLifeCycle.java


Some files were not shown because too many files changed in this diff