Przeglądaj źródła

C code generator working for the first simple state chart.
A Number of features are still missing

jos.itemis@gmail.com 14 lat temu
rodzic
commit
8add77d860
36 zmienionych plików z 296 dodań i 1394 usunięć
  1. 3 3
      plugins/org.yakindu.sct.generator.c/META-INF/MANIFEST.MF
  2. 0 31
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/CMakeLists.xpt
  3. 0 42
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/CustomEventH.xpt
  4. 0 83
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/CustomRepositoryH.xpt
  5. 0 169
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/CustomStatemachineCPP.xpt
  6. 0 94
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/CustomStatemachineH.xpt
  7. 0 25
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/EventC.xpt
  8. 0 31
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/EventH.xpt
  9. 0 69
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/EventSetC.xpt
  10. 0 43
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/EventSetH.xpt
  11. 0 84
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/Expression.ext
  12. 0 57
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/Main.xpt
  13. 0 44
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/Naming.ext
  14. 0 49
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/StatemachineBaseC.xpt
  15. 0 46
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/StatemachineBaseH.xpt
  16. 0 51
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/StatemachineH.xpt
  17. 0 93
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/Statemachine_cyC.xpt
  18. 0 55
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/Statemachine_cyH.xpt
  19. 0 112
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/TestMain.xpt
  20. 0 33
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/TimerC.xpt
  21. 0 38
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/TimerH.xpt
  22. 0 37
      plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/definitionH.xpt
  23. 12 4
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CMakeLists.xpt
  24. 40 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomEventC.xpt
  25. 7 5
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomEventH.xpt
  26. 34 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomRepositoryC.xpt
  27. 22 14
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomStatemachineC.xpt
  28. 2 2
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomStatemachineH.xpt
  29. 47 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/DummyTimer.xpt
  30. 24 14
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Expression.ext
  31. 7 1
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Main.xpt
  32. 5 4
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Naming.ext
  33. 5 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Statemachine_cyC.xpt
  34. 0 1
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Statemachine_cyH.xpt
  35. 87 59
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/TestMain.xpt
  36. 1 1
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/definitionH.xpt

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

@@ -1,7 +1,7 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
-Bundle-Name: Yakindu SCT C++ Generator
-Bundle-SymbolicName: org.yakindu.sct.generator.cpp; singleton:=true
+Bundle-Name: Yakindu SCT C Generator
+Bundle-SymbolicName: org.yakindu.sct.generator.c;singleton:=true
 Bundle-Version: 1.0.0.qualifier
 Require-Bundle: org.yakindu.sct.model.sexec,
  org.eclipse.jdt.core,
@@ -19,5 +19,5 @@ Require-Bundle: org.yakindu.sct.model.sexec,
  org.eclipse.xtend.typesystem.emf,
  org.yakindu.sct.model.stext
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.yakindu.sct.generator.cpp.templates
+Export-Package: org.yakindu.sct.generator.c.templates
 Bundle-Vendor: YAKINDU

+ 0 - 31
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/CMakeLists.xpt

@@ -1,31 +0,0 @@
-«REM»
-
-Templates for the main statechart cpp file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-«EXTENSION org::yakindu::sct::generator::c::templates::Expression»
-«EXTENSION org::yakindu::sct::generator::c::templates::Naming»
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'CMakeLists.txt'»
-cmake_minimum_required(VERSION 2.8)
-
-set(SRC
-	Statemachine.cpp
-	«StName()».cpp
-	main.cpp
-)
-
-add_definitions( -Wall -O0 -g)
-add_executable(«StName()»Main ${SRC})
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 42
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/CustomEventH.xpt

@@ -1,42 +0,0 @@
-«REM»
-
-Templates for the main statechart cpp file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-«EXTENSION org::yakindu::sct::generator::c::templates::Expression»
-«EXTENSION org::yakindu::sct::generator::c::templates::Naming»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE EvName()+'.h'»
-#ifndef «EVNAME()»_H_
-#define «EVNAME()»_H_
-
-#include "Event.h"
-
-enum EventID {
-«FOREACH this.declaredEvents() AS ev»
-  _«((EventDefinition)ev).name.toLowerCase()»,
-«ENDFOREACH»
-	event_last
-};
-
-«FOREACH this.declaredEvents() AS ev»
-  class «((EventDefinition)ev).name» : public _Event { public: «((EventDefinition)ev).name»() : _Event((uint32_t)_«((EventDefinition)ev).name.toLowerCase()») {} };
-  // internal variables unhandled
-«ENDFOREACH»
- 
-
-#endif /* «name.toUpperCase()»_H_ */
-
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 83
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/CustomRepositoryH.xpt

@@ -1,83 +0,0 @@
-«REM»
-
-Templates for the main statechart cpp file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-«EXTENSION org::yakindu::sct::generator::c::templates::Expression»
-«EXTENSION org::yakindu::sct::generator::c::templates::Naming»
-
-
-«DEFINE interfaces FOR ExecutionFlow»
-«EXPAND scope FOREACH this.scopes»
-«ENDDEFINE»
-
-«DEFINE scope FOR Scope -»
-«ENDDEFINE»
-
-«DEFINE scope FOR InterfaceScope»
-«EXPAND declaration FOREACH this.declarations»
-«ENDDEFINE»
-
-«DEFINE scope FOR InternalScope»
-«EXPAND declaration FOREACH this.declarations»
-«ENDDEFINE»
-
-«DEFINE declaration FOR Declaration -»
-	// unknown declaration «name»
-«ENDDEFINE»
-
-«DEFINE declaration FOR EventDefinition -»
-«ENDDEFINE»
-
-«DEFINE declaration FOR VariableDefinition -»
-	«type» «name»; 
-«ENDDEFINE»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE DRName()+'.h'»
-#ifndef «DRNAME()»_H_
-#define «DRNAME()»_H_
-
-#include "definition.h"
-#include "DataRepository.h"
-
-class «DRName()» : public DataRepository {
-
-«FOREACH this.declaredVariables() AS variable»
-    «((VariableDefinition)variable).type» «((VariableDefinition)variable).name»;
-«ENDFOREACH»
-
-public:
-
-	«DRName()»() : 
-«FOREACH this.declaredVariables() AS variable SEPARATOR ','-»
- «((VariableDefinition)variable).name»(0)«
-ENDFOREACH»
-	{};
-	virtual ~«DRName()»() {};
-	
-«FOREACH this.declaredVariables() AS variable»
-    «((VariableDefinition)variable).type» get_«((VariableDefinition)variable).name»()
-    { «((VariableDefinition)variable).type» value; lock(); value = «((VariableDefinition)variable).name»; unlock(); return value; }
-«ENDFOREACH»
-
-«FOREACH this.declaredVariables() AS variable»
-    void set_«((VariableDefinition)variable).name»(const «((VariableDefinition)variable).type»& value)
-    { lock(); «((VariableDefinition)variable).name» =  value; unlock(); }
-«ENDFOREACH»
-
-};
-
-#endif /* «DRNAME()»_H_ */
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 169
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/CustomStatemachineCPP.xpt

@@ -1,169 +0,0 @@
-«REM»
-
-Templates for the main statechart cpp file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-«IMPORT ecore»
-
-«IMPORT org::yakindu::sct::generator::c::templates»
-
-«EXTENSION org::yakindu::sct::generator::c::templates::Expression»
-«EXTENSION org::yakindu::sct::generator::c::templates::Naming»
-
-«DEFINE ActionCode FOR Step»
-// ActionCode for Step not defined
-«ENDDEFINE»
-
-«DEFINE ActionCode FOR Execution»
-	«this.statement.toCppCode()»
-«ENDDEFINE»
-
-«DEFINE ActionCode FOR Call»
-«this.step.functionName()»();
-«ENDDEFINE»
-
-«DEFINE ActionCode FOR Sequence»
-  «EXPAND ActionCode FOREACH this.steps»
-«ENDDEFINE»
-
-«DEFINE ActionCode FOR Check -»
-  «IF this != null -»
-«this.condition.toCppCode() -»
-  «ELSE -»
- true «
- ENDIF -»«
-  ENDDEFINE»
-
-«DEFINE ActionCode FOR CheckRef -»
-  «IF this.check != null -»
-  «this.check.functionName()»(ev) «
-  ELSE -»
- true «
-  ENDIF -»«
-ENDDEFINE»
-
-«DEFINE ActionCode FOR Reaction»
-  «EXPAND ActionCode FOR this.effect» 
-«ENDDEFINE»
-
-«DEFINE ActionCode FOR If»
-if («EXPAND ActionCode FOR this.check») { 
-  «EXPAND ActionCode FOR this.thenStep»
-}
-else {
-  «EXPAND ActionCode FOR this.elseStep»
-}
-«ENDDEFINE»
-
-«DEFINE ActionCode FOR EnterState»
-state[0] = _«this.state.simpleName»;
-«ENDDEFINE»
-
-«DEFINE ActionCode FOR ExitState»
-state[0] = last_state;
-«ENDDEFINE»
-
-«DEFINE ConditionMethodsImplement FOR ExecutionState»
-  «FOREACH reactions AS r»
-  «IF r.check != null -»
-bool «StName()»::«r.check.functionName()»(const _Event& ev) {
-  return (	«r.check.condition.toCppCode()» );
-}
-  «ENDIF -»
-  «ENDFOREACH»
-«ENDDEFINE»
-
-«DEFINE StatementMethodsImplement FOR ExecutionState»
-  «FOREACH reactions AS r»
-void «this.StName()»::«r.effect.functionName()»() {
-  «EXPAND ActionCode FOR r.effect»
-}
-  «ENDFOREACH»
-«ENDDEFINE»
-
-«DEFINE CycleCode FOR Cycle» 
-«EXPAND ActionCode FOREACH this.steps»
-«ENDDEFINE»
-
-«DEFINE CycleMethodsImplement FOR ExecutionState»
-void «StName()»::cycle_«this.simpleName»(const _Event& ev)
-{
-	«EXPAND CycleCode FOR cycle»
-}
-«ENDDEFINE»
-
-«DEFINE EnterMethodImplement FOR ExecutionState»
-«IF this.entryAction != null»
-void «StName()»::«this.entryAction.entryActionFunctionName()»()
-{
-«EXPAND ActionCode FOR this.entryAction»
-}
-«ENDIF»
-«ENDDEFINE»
-
-«DEFINE ExitMethodImplement FOR ExecutionState»
-«IF this.exitAction != null»
-void «StName()»::«this.exitAction.exitActionFunctionName()»()
-{
-«EXPAND ActionCode FOR this.exitAction»
-}
-«ENDIF»
-«ENDDEFINE»
-
-«DEFINE file FOR ExecutionFlow»
-«FILE StName()+'.cpp'»
-#include <iostream>
-#include "«StName()».h"
-
-«StName()»::«StName()»() : Statemachine(«((ExecutionFlow)this.eRootContainer).stateVector.size») {
-}
-
-«StName()»::~«StName()»() {
-}
-
-«EXPAND ConditionMethodsImplement FOREACH this.states»
-
-«EXPAND StatementMethodsImplement FOREACH this.states»
-
-«EXPAND CycleMethodsImplement FOREACH this.states»
-
-«EXPAND EnterMethodImplement FOREACH this.states»
-
-«EXPAND ExitMethodImplement FOREACH this.states»
-
-
-void «StName()»::init()
-{
-	«EXPAND ActionCode FOREACH this.enterSequence.steps»
-}
-
-/* Yet unimplemented
-void «StName()»::exit()
-{
-}
-*/
-
-void «StName()»::_runCycle(Event ev)
-{
-	for (int i=0; i<MAX_PARALLEL_STATES; ++i) {
-		switch(state[i]) {
-	«FOREACH this.states AS state»
-	    case _«state.simpleName»:
-	        cycle_«state.simpleName»(*ev);
-	        break;
-	«ENDFOREACH»
-		default:
-			/* no state found */
-			break;
-		}
-	}
-}
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 94
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/CustomStatemachineH.xpt

@@ -1,94 +0,0 @@
-«REM»
-
-Templates for the main statechart cpp file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-«EXTENSION org::yakindu::sct::generator::c::templates::Expression»
-«EXTENSION org::yakindu::sct::generator::c::templates::Naming»
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE StName()+'.h'»
-#ifndef «STNAME()»_H_
-#define «STNAME()»_H_
-
-#include "Statemachine.h"
-#include "«DRName()».h"
-#include "«EvName()».h"
-
-
-#define MAX_PARALLEL_STATES «this.stateVector.size»
-
-class «StName()»: public Statemachine, public «DRName()» {
-
-public:
-	enum States {
-	    «FOREACH this.states AS exState-»
-	      _«exState.simpleName»,
-	    «ENDFOREACH»
-		last_state
-	};
-
-protected:
-	/* conditions */
-	«FOREACH states AS state -»
-	  «FOREACH state.reactions AS reaction -»
-	  «IF reaction.check != null -»
-	bool «reaction.check.functionName()»(const _Event& event);
-	  «ENDIF»
-	  «ENDFOREACH»
-	«ENDFOREACH»
-	
-	/* actions */
-	«FOREACH states AS state -»
-	  «FOREACH state.reactions AS reaction -»
-	void «reaction.effect.functionName()»();
-	  «ENDFOREACH»
-	«ENDFOREACH»
-
-	/* cycles */
-	«FOREACH states AS state -»
-	void cycle_«state.simpleName»(const _Event& ev);
-	«ENDFOREACH»
-	
-	/* entrys */
-	«FOREACH states AS state -»
-	«IF state.entryAction != null»
-	void «state.entryAction.entryActionFunctionName()»();
-	«ENDIF»
-	«ENDFOREACH»
-	
-	/*exits */
-	«FOREACH states AS state -»
-	«IF state.exitAction != null»
-	void «state.exitAction.exitActionFunctionName()»();
-	«ENDIF»
-	«ENDFOREACH»
-	
-	virtual void _runCycle(Event ev);
-
-public:
-
-	«StName()»();
-	virtual ~«StName()»();
-
-	virtual void init();
-
-	//virtual void queueEvent(const Event& ev);
-
-};
-
-//}; // namespace
-#endif /* «STNAME()»_H_ */
-
-«ENDFILE»
-
-«ENDDEFINE»
-

+ 0 - 25
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/EventC.xpt

@@ -1,25 +0,0 @@
-«REM»
-
-Templates for the main statechart c file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'Event.c'»
-#include "Event.h"
-
-void _event_init(_Event* handle, uint32_t id)
-{
-	handle->id = id;
-}
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 31
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/EventH.xpt

@@ -1,31 +0,0 @@
-«REM»
-
-Templates for the main statechart c file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'Event.h'»
-#ifndef EVENT_H_
-#define EVENT_H_
-
-#include "definition.h"
-
-typedef struct {
-  uint32_t id;
-} _Event;
-
-extern void _event_init(_Event* handle, uint32_t id);
-
-#endif /* EVENT_H_ */
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 69
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/EventSetC.xpt

@@ -1,69 +0,0 @@
-«REM»
-
-Templates for the main statechart c file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'EventSet.c'»
-#include "EventSet.h"
-#include <stdlib.h>
-
-void eventSet_init(EventSet* handle, const uint32_t _maxEvents) {
-	handle->isStaticData = bool_false;
-	handle->maxEvents = _maxEvents;
-	handle->_set = malloc(sizeof(boolean) * _maxEvents);
-	eventSet_clean(handle);
-}
-
-void eventSet_init_staticData(EventSet* handle, const uint32_t _maxEvents,
-		boolean* _dataSet) {
-	handle->isStaticData = bool_true;
-	handle->maxEvents = _maxEvents;
-	handle->_set = _dataSet;
-}
-
-void eventSet_exit(EventSet* handle) {
-	if (!handle->isStaticData)
-		free(handle->_set);
-	handle->maxEvents = 0;
-}
-
-boolean eventSet_check(EventSet* handle, const uint32_t evid) {
-	if (evid < handle->maxEvents) {
-		return handle->_set[evid];
-	}
-	return (bool_false);
-}
-
-void eventSet_clean(EventSet* handle) {
-	uint32_t i;
-	for (i = 0; i < handle->maxEvents; ++i)
-		handle->_set[i] = bool_false;
-}
-
-void eventSet_set(EventSet* handle, const uint32_t evid) {
-	if (evid < handle->maxEvents) {
-		handle->_set[evid] = bool_true;
-	}
-}
-
-boolean eventSet_isAny(EventSet* handle) {
-	uint32_t i;
-	for (i = 0; i < handle->maxEvents; ++i)
-		if (handle->_set[i])
-			return (bool_true);
-	return (bool_false);
-}
-
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 43
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/EventSetH.xpt

@@ -1,43 +0,0 @@
-«REM»
-
-Templates for the main statechart c file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'EventSet.h'»
-#ifndef EVENTSET_H_
-#define EVENTSET_H_
-
-#include "definition.h"
-
-typedef struct {
-	boolean* _set;
-	uint32_t maxEvents;
-	boolean isStaticData;
-} EventSet;
-
-/* constructor and destructor */
-extern void eventSet_init(EventSet* handle, const uint32_t maxEvents);
-extern void eventSet_init_staticData(EventSet* handle, const uint32_t maxEvents,
-		boolean* _dataSet);
-extern void eventSet_exit(EventSet* handle);
-
-
-extern boolean eventSet_check(EventSet* handle, const uint32_t evid);
-extern void eventSet_clean(EventSet* handle);
-extern void eventSet_set(EventSet* handle, const uint32_t evid);
-extern boolean eventSet_isAny(EventSet* handle);
-
-#endif /* EVENTSET_H_ */
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 84
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/Expression.ext

@@ -1,84 +0,0 @@
-import stext;
-import sexec;
-import ecore;
-import sgraph;
-toCppCode(Void void) :
-	"/*toCppCode() called with NULL element. Polymorphic resolver could not match callable method!*/";
-String toCppCode(Void o, String statechartReference) : 
-	""; //polymorphic placeholder (abstract rule)
-
-String toCppCode(Expression statement) : 
-	null; //polymorphic placeholder (abstract rule)
- 
-String toCppCode(Statement statement) : 
-	null; //polymorphic placeholder (abstract rule)
- 
-String toCppCode(PrimitiveValueExpression primValue) :
-	primValue.value;
-
-/* Assignment */
-String toCppCode(Assignment assignment) :
-  switch (assignment.operator) {
-  case (AssignmentOperator::assign) : "set_" + assignment.varRef.name + "(" + assignment.expression.toCppCode() + ");"  
-  case (AssignmentOperator::multAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() * (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::divAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() / (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::modAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() % (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::addAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() + (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::subAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() - (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::leftShiftAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() << ("+ assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::rightShiftAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() >> (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::andAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() & (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::xorAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() ^ (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::orAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() ^ (" + assignment.expression.toCppCode() + "));"
-  default : ""
-  };
-		
-/* EventRaising */
-
-/* Logical Expressions */
-String toCppCode(LogicalOrExpression expression) :
-  	expression.leftOperand.toCppCode() + " || " + expression.rightOperand.toCppCode();
-  	
-String toCppCode(LogicalAndExpression expression) :
-  	expression.leftOperand.toCppCode() + " && " + expression.rightOperand.toCppCode();
-
-String toCppCode(LogicalNotExpression expression) :
-  	" ^" + expression.operand.toCppCode();
-
-String toCppCode(LogicalRelationExpression expression) :
-   expression.leftOperand.toCppCode() + " ??? " + expression.rightOperand.toCppCode();
-    
-String toCppCode(BitwiseAndExpression expression) :
-  	expression.leftOperand.toCppCode() + " & " + expression.rightOperand.toCppCode();
-
-String toCppCode(BitwiseOrExpression expression) :
-  	expression.leftOperand.toCppCode() + " | " + expression.rightOperand.toCppCode();
-
-String toCppCode(BitwiseXorExpression expression) :
-  	expression.leftOperand.toCppCode() + " ^ " + expression.rightOperand.toCppCode();
-
-String toCppCode(NumericalAddSubtractExpression expression) :
-  	expression.leftOperand.toCppCode() + getOperator(expression.operator) + expression.rightOperand.toCppCode();
-  	
-String toCppCode(NumericalMultiplyDivideExpression expression) :
-  	expression.leftOperand.toCppCode() + getOperator(expression.operator) + expression.rightOperand.toCppCode();
-
-// is this just relevant for events?
-String toCppCode(ElementReferenceExpression ev) :
-    " ( _" + ev.value.name.toLowerCase() + " == ev.getID() ) ";
-
-String getOperator(AdditiveOperator operator) : 
-    switch(operator) {
-    	case(AdditiveOperator::plus) : " + "
-    	case(AdditiveOperator::minus) : " - "
-    	default : ""
-    };
-
-String getOperator(MultiplicativeOperator operator) : 
-    switch(operator) {
-    	case(MultiplicativeOperator::mul) : " * "
-    	case(MultiplicativeOperator::div) : " / "
-    	case(MultiplicativeOperator::mod) : " % "
-    	default : ""
-    };
-

+ 0 - 57
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/Main.xpt

@@ -1,57 +0,0 @@
-«REM»
-
-Contais the root templates that call the different file templates.
-
-@author andreas muelder
-@auther axel terfloth
-@author joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-«IMPORT org::yakindu::sct::generator::c::templates»
-
-«DEFINE main FOR ExecutionFlow»
-
-	«REM» basis files «ENDREM»
-	«EXPAND EventH::file FOR this»
-	«EXPAND EventC::file FOR this»
-
-	«EXPAND TimerH::file FOR this»
-	«EXPAND TimerC::file FOR this»
-
-	«EXPAND EventSetH::file FOR this»
-	«EXPAND EventSetC::file FOR this»
-
-	«EXPAND StatemachineBaseH::file FOR this»
-	«EXPAND StatemachineBaseC::file FOR this»
-
-	«EXPAND Statemachine_cyH::file FOR this»
-	«EXPAND Statemachine_cyC::file FOR this»
-
-
-
-    «REM» code that is created by the model «ENDREM»
-	«EXPAND definitionH::file FOR this»
-
-	«EXPAND EventPoolH::file FOR this»
-	«EXPAND EventPoolC::file FOR this»
-
-	«EXPAND CustomStatemachineH::file FOR this»
-	«EXPAND CustomStatemachineCPP::file FOR this»
-	«EXPAND CustomRepositoryH::file FOR this»
-	«EXPAND CustomEventH::file FOR this»
-	
-	«EXPAND CMakeLists::file FOR this»
-	«EXPAND TestMain::file FOR this»
-
-
-	«EXPAND Dump::file FOR this»
-	
-«ENDDEFINE»
-
-
-

+ 0 - 44
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/Naming.ext

@@ -1,44 +0,0 @@
-import stext;
-import sexec;
-import ecore;
-import sgraph;
-
-
-String scName(Expression statement) : ((ExecutionFlow)statement.eRootContainer).name ;
-
-List declaredEvents(ExecutionFlow flow) : flow.scopes.declarations.typeSelect(EventDefinition);
-
-List declaredVariables(ExecutionFlow flow) : flow.scopes.declarations.typeSelect(VariableDefinition);
-
-String test(NamedElement obj) :  "";
-String StName(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toFirstUpper() + "Statemachine";
-String STNAME(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toUpperCase() + "STATEMACHINE";
-
-String DRName(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toFirstUpper() + "DataRepository";
-String DRNAME(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toUpperCase() + "DATAREPOSITORY";
-
-String EvName(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toFirstUpper() + "Event";
-String EVNAME(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toUpperCase() + "EVENT";
-
-cached String functionName(Step step) : 
-	(step.isEffect()) ? step.actionFunctionName() : (
-	(step.isReactionCheck()) ? step.checkFunctionName() : (
-	(step.isEntryAction()) ? step.entryActionFunctionName() : ( 
-	(step.isExitAction()) ? step.exitActionFunctionName() : 
-	" !! unknown function type !!" )));
- 
-String actionFunctionName(Step this) : "actions_" + this.reaction().state().simpleName + "_" + this.reaction().name; 
-String checkFunctionName(Step this) : "condition_" + this.reaction().state().simpleName + "_" + this.reaction().name; 
-String entryActionFunctionName(Step this) : "entryActions_" + this.state().simpleName; 
-String exitActionFunctionName(Step this) : "exitActions_" + this.state().simpleName; 
-
-boolean isEffect(Step step) : (! Check.isInstance(step)) && Reaction.isInstance(step.eContainer) ;
-boolean isReactionCheck(Step step) : Reaction.isInstance(step.eContainer) && Check.isInstance(step);
-boolean isEntryAction(Step step) : ExecutionState.isInstance(step.eContainer) && step.state().entryAction == step;
-boolean isExitAction(Step step) : ExecutionState.isInstance(step.eContainer) && step.state().exitAction == step;
-
-Reaction reaction(Step this) : (Reaction) this.eContainer ;
-ExecutionState state(Reaction this) : (ExecutionState) eContainer;
-ExecutionState state(Step this) : (ExecutionState) eContainer;
-
-

+ 0 - 49
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/StatemachineBaseC.xpt

@@ -1,49 +0,0 @@
-«REM»
-
-Templates for the main statechart c file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'StatemachineBase.c'»
-#include "StatemachineBase.h"
-#include <stdlib.h>
-
-void statemachineBase_init(StatemachineBase* handle, uint16_t maxStates, Timer* _timer)
-{
-	handle->isStaticData = bool_false;
-	handle->timer = _timer;
-	handle->state = malloc(sizeof(uint32_t)*maxStates); /* memory allocation for all states */
-	handle->statePtr = 0; /* actual state referencer */
-}
-
-void statemachineBase_init_staticData(StatemachineBase* handle, uint32_t* staticData, Timer* _timer)
-{
-	handle->isStaticData = bool_true;
-	handle->timer = _timer;
-	handle->state = staticData;
-	handle->statePtr = 0; /* actual state referencer */
-}
-
-void statemachineBase_exit(StatemachineBase* handle) {
-	if (!handle->isStaticData)
-		free(handle->state);
-	if (handle->timer)
-		timer_exit(handle->timer);
-}
-
-uint32_t statemachineBase_getState(StatemachineBase* handle, uint16_t pos)
-{
-    return (handle->state[pos]);
-}
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 46
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/StatemachineBaseH.xpt

@@ -1,46 +0,0 @@
-«REM»
-
-Templates for the main statechart c file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'StatemachineBase.h'»
-#ifndef STATEMACHINEBASE_H_
-#define STATEMACHINEBASE_H_
-
-#include "definition.h"
-#include "Timer.h"
-
-typedef struct {
-
-	uint32_t* state;
-	uint16_t statePtr;
-
-	Timer* timer;
-	boolean isStaticData;
-
-} StatemachineBase;
-
-
-extern void statemachineBase_init(StatemachineBase* handle, uint16_t maxStates, Timer* timer);
-extern void statemachineBase_init_staticData(StatemachineBase* handle,
-		uint32_t* staticData, Timer* timer);
-
-extern void statemachineBase_exit(StatemachineBase* handle);
-
-extern uint32_t statemachineBase_getState(StatemachineBase* handle, uint16_t pos);
-
-
-#endif /* STATEMACHINEBASE_H_ */
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 51
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/StatemachineH.xpt

@@ -1,51 +0,0 @@
-«REM»
-
-Templates for the main statechart cpp file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'Statemachine.h'»
-#ifndef STATEMACHINE_H_
-#define STATEMACHINE_H_
-
-#include <deque>
-#include "Event.h"
-
-class Statemachine {
-
-protected:
-	uint32_t* state;
-	uint16_t statePtr;
-
-	std::deque<Event> eventList;
-
-	Event getEvent();
-
-	virtual void _runCycle(Event ev) = 0;
-
-public:
-	Statemachine(uint16_t maxStates);
-	virtual ~Statemachine();
-
-	virtual void init() = 0;
-	void runCycle();
-	void queueEvent(Event ev);
-	bool eventWaiting() const;
-
-	uint32_t getState(uint16_t pos) { return(state[pos]); }
-
-};
-
-#endif /* STATEMACHINE_H_ */
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 93
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/Statemachine_cyC.xpt

@@ -1,93 +0,0 @@
-«REM»
-
-Templates for the main statechart c file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'Statemachine_cy.c'»
-#include <stdlib.h>
-#include "definition.h"
-#include "Statemachine_cy.h"
-
-void statemachine_cy_init(Statemachine_cy* handle, uint16_t maxStates,
-		uint16_t maxEvents, Timer* timer, EventPool* eventPool) {
-
-	statemachineBase_init((StatemachineBase*) handle, maxStates, timer);
-	eventSet_init(&handle->eventSet, maxEvents);
-
-	/* This is only a place for the pointers to the actual Events */
-	handle->eventList = malloc(sizeof(_Event*) * maxEvents);
-
-	/* eventPool must be initialized at this point */
-	handle->eventPool = eventPool;
-
-}
-
-
-void statemachine_cy_init_staticData(Statemachine_cy* handle,
-		uint16_t maxEvents, Timer* timer, uint32_t* staticStateData,
-		boolean* staticEventSet, _Event** staticListPtr, EventPool* eventPool) {
-	statemachineBase_init_staticData((StatemachineBase*) handle,
-			staticStateData, timer);
-	eventSet_init_staticData(&handle->eventSet, maxEvents, staticEventSet);
-
-	/* Hand out event List */
-	handle->eventList = staticListPtr;
-
-	/* eventPool must be initialized at this point */
-	handle->eventPool = eventPool;
-
-}
-
-void statemachine_cy_exit(Statemachine_cy* handle) {
-
-	uint32_t i;
-	// the active events, which are not been handled need to be freed
-	for (i = 0; i < handle->eventSet.maxEvents; ++i) {
-		if (eventSet_check(&handle->eventSet, i))
-			eventPool_freeEvent(handle->eventPool, handle->eventList[i]);
-	}
-
-	if (handle->base.isStaticData == bool_false)
-		free(handle->eventList);
-
-	eventSet_exit(&handle->eventSet);
-	statemachineBase_exit((StatemachineBase*) handle);
-
-}
-
-void statemachine_cy_runCycle(Statemachine_cy* handle) {
-
-	/* call internal cycle */
-	statemachine_cy__runCycle(handle);
-
-	/* cleanup all events */
-	eventSet_clean(&handle->eventSet);
-
-}
-
-void statemachine_cy_setEvent(Statemachine_cy* handle, _Event* ev) {
-
-	eventSet_set(&handle->eventSet,ev->id);
-	handle->eventList[ev->id] = ev;
-
-}
-
-boolean statemachine_cy_eventWaiting(Statemachine_cy* handle) {
-
-	return eventSet_isAny(&handle->eventSet);
-}
-
-
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 55
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/Statemachine_cyH.xpt

@@ -1,55 +0,0 @@
-«REM»
-
-Templates for the main statechart c file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'Statemachine_cy.h'»
-#ifndef STATEMACHINE_CY_H_
-#define STATEMACHINE_CY_H_
-
-#include "EventSet.h"
-#include "StatemachineBase.h"
-#include "generatedSource/VariableData.h"
-#include "Timer.h"
-#include "EventPool.h"
-
-typedef struct {
-  StatemachineBase base;
-  EventSet eventSet;
-  _Event** eventList;
-  EventPool* eventPool;
-} Statemachine_cy ;
-
-extern void statemachine_cy_init(Statemachine_cy* handle, uint16_t maxStates,
-		uint16_t maxEvents,	Timer* timer, EventPool* eventPool);
-
-extern void statemachine_cy_init_staticData(Statemachine_cy* handle,
-		uint16_t maxEvents, Timer* timer, uint32_t* staticStateData,
-		boolean* staticEventSet, _Event** staticListPtr, EventPool* eventPool);
-
-extern void statemachine_cy_exit(Statemachine_cy* handle);
-
-/* implement me */
-extern void statemachine_cy_runCycle(Statemachine_cy* handle);
-
-extern void statemachine_cy_setEvent(Statemachine_cy* handle, _Event* ev);
-extern boolean statemachine_cy_eventWaiting(Statemachine_cy* handle);
-
-/* implement me in derived codegeneration */
-extern void statemachine_cy__runCycle(Statemachine_cy* handle);
-
-#endif /* STATEMACHINE_CY_H_ */
-
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 112
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/TestMain.xpt

@@ -1,112 +0,0 @@
-«REM»
-
-Templates for the main statechart cpp file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-«EXTENSION org::yakindu::sct::generator::c::templates::Expression»
-«EXTENSION org::yakindu::sct::generator::c::templates::Naming»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'main.cpp'»
-
-/*
- * main.cpp
- *
- *  Created on: 10.09.2011
- *      Author: seger
- */
-
-#include <cstdio>
-#include <iostream>
-#include "«StName()».h"
-// #include "«DRName()».h"
-#include "«EvName()».h"
-
-int main()
-{
-
-	char* stateName[6] = {"State1", "State2", "State3", "State4", "State5", "State6"};
-	«StName()» machine;
-
-	// initialize the initial states 
-	machine.init();
-	
-	/* Example code 
-	// create one event and enqueue it 
-	Event e = createEvent<Event1>();
-	machine.queueEvent(e);
-
-	// run the cycle 
-	machine.runCycle();
-
-	// check the state 
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State3") == 0);
-
-	e = createEvent<Event2>();
-	machine.queueEvent(e);
-
-	machine.runCycle();
-
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State1") == 0);
-
-	// does event queuing work?
-	e = createEvent<Event1>();
-	machine.queueEvent(e);
-	e = createEvent<Event3>();
-	machine.queueEvent(e);
-
-	machine.runCycle();
-
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State3") == 0);
-
-	// run second cycle
-	machine.runCycle();
-
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State4") == 0);
-
-	e = createEvent<Event4>();
-	machine.queueEvent(e);
-
-	machine.runCycle();
-
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State3") == 0);
-
-	e = createEvent<Event3>();
-	machine.queueEvent(e);
-
-	machine.runCycle();
-
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State4") == 0);
-
-	e = createEvent<Event5>();
-	machine.queueEvent(e);
-
-	machine.runCycle();
-
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State1") == 0);
-
-	*/
-	
-	return(0);
-	
-}
-
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 33
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/TimerC.xpt

@@ -1,33 +0,0 @@
-«REM»
-
-Templates for the main statechart c file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'Timer.c'»
-#include "Timer.h"
-
-void timer_setFPtr(Timer* handle, setTimerFPtr stfptr, unsetTimerFPtr utfptr)
-{
-
-	handle->setTimer = stfptr;
-	handle->unsetTimer = utfptr;
-
-}
-
-void timer_exit(Timer* handle)
-{
-
-}
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 38
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/TimerH.xpt

@@ -1,38 +0,0 @@
-«REM»
-
-Templates for the main statechart c file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'Timer.h'»
-#ifndef TIMER_H_
-#define TIMER_H_
-
-#include "definition.h"
-
-typedef void(*setTimerFPtr)(uint32_t evid, const uint32_t time_ms, boolean periodic);
-typedef void(*unsetTimerFPtr)(const uint32_t evid);
-
-typedef struct {
-
-	/* callback functions */
-	setTimerFPtr   setTimer;
-	unsetTimerFPtr unsetTimer;
-
-}  Timer;
-
-extern void timer_setFPtr(Timer* handle, setTimerFPtr stfptr, unsetTimerFPtr utfptr);
-extern void timer_exit(Timer* handle);
-#endif /* TIMER_H_ */
-«ENDFILE»
-
-«ENDDEFINE»

+ 0 - 37
plugins/org.yakindu.sct.generator.c/bin/org/yakindu/sct/generator/c/templates/definitionH.xpt

@@ -1,37 +0,0 @@
-«REM»
-
-Templates for the main statechart cpp file.
-
-@auther joern seger
-
-«ENDREM»
-
-«IMPORT sexec»
-«IMPORT stext»
-«IMPORT sgraph»
-
-
-«DEFINE file FOR ExecutionFlow»
-
-«FILE 'definition.h'»
-#ifndef DEFINITION_H_
-#define DEFINITION_H_
-
-/* platform/compiler specific additions (#includes) */
-/* temporarly set to fix values */ 
-
-typedef unsigned int uint32_t;
-typedef unsigned short uint16_t;
-
-typedef int int32_t;
-typedef short int16_t;
-
-typedef int32_t integer; 
-typedef bool boolean;
-typedef float real;
-//typedef string char*;
- 
-#endif /* DEFINITION_H_ */
-«ENDFILE»
-
-«ENDDEFINE»

+ 12 - 4
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CMakeLists.xpt

@@ -18,10 +18,18 @@ Templates for the main statechart cpp file.
 «FILE 'CMakeLists.txt'»
 cmake_minimum_required(VERSION 2.8)
 
-set(SRC
-	Statemachine.cpp
-	«StName()».cpp
-	main.cpp
+set( SRC
+	Statemachine_cy.c
+	StatemachineBase.c
+	Event.c
+	EventSet.c
+	EventPool.c
+	«StName()».c
+	«EvName()».c
+	«DRName()».c
+	Timer.c
+	DummyTimer.c
+	main.c
 )
 
 add_definitions( -Wall -O0 -g)

+ 40 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomEventC.xpt

@@ -0,0 +1,40 @@
+«REM»
+
+Templates for the main statechart cpp file.
+
+@auther joern seger
+
+«ENDREM»
+
+«IMPORT sexec»
+«IMPORT stext»
+«IMPORT sgraph»
+
+«EXTENSION org::yakindu::sct::generator::c::templates::Expression»
+«EXTENSION org::yakindu::sct::generator::c::templates::Naming»
+
+
+«DEFINE file FOR ExecutionFlow»
+
+«FILE EvName()+'.c'»
+#include "«EvName()».h"
+
+/* This is needed by the EventPool */
+uint32_t getSizeofEvent(uint32_t evid)
+{
+	switch((EventID) evid) {
+
+«FOREACH this.declaredEvents() AS ev -»
+  case ev_«((EventDefinition)ev).name.toLowerCase()»:
+    return sizeof(«((EventDefinition)ev).name»);
+«ENDFOREACH -»
+	default:
+		break;
+	}
+
+	return(0);
+}
+
+«ENDFILE»
+
+«ENDDEFINE»

+ 7 - 5
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomEventH.xpt

@@ -22,16 +22,18 @@ Templates for the main statechart cpp file.
 
 #include "Event.h"
 
-enum EventID {
+typedef enum {
 «FOREACH this.declaredEvents() AS ev»
-  _«((EventDefinition)ev).name.toLowerCase()»,
+  ev_«((EventDefinition)ev).name.toLowerCase()»,
 «ENDFOREACH»
 	event_last
-};
+} EventID;
 
 «FOREACH this.declaredEvents() AS ev»
-  class «((EventDefinition)ev).name» : public _Event { public: «((EventDefinition)ev).name»() : _Event((uint32_t)_«((EventDefinition)ev).name.toLowerCase()») {} };
-  // internal variables unhandled
+typedef struct { 
+  _Event baseEvent;
+  «REM» event variables go here «ENDREM»
+} «((EventDefinition)ev).name»;
 «ENDFOREACH»
  
 

+ 34 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomRepositoryC.xpt

@@ -0,0 +1,34 @@
+«REM»
+
+Templates for the main statechart c file.
+
+@auther joern seger
+
+«ENDREM»
+
+«IMPORT sexec»
+«IMPORT stext»
+«IMPORT sgraph»
+
+«EXTENSION org::yakindu::sct::generator::c::templates::Expression»
+«EXTENSION org::yakindu::sct::generator::c::templates::Naming»
+
+«DEFINE file FOR ExecutionFlow»
+
+«FILE DRName()+'.c'»
+#ifndef «DRNAME()»_H_
+#define «DRNAME()»_H_
+
+#include "«DRName()».h"
+
+void «DRName().toFirstLower()»_init(«DRName()»* handle)
+{}
+
+void «DRName().toFirstLower()»_exit(«DRName()»* handle)
+{}
+
+
+#endif /* «DRNAME()»_H_ */
+«ENDFILE»
+
+«ENDDEFINE»

+ 22 - 14
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomStatemachineC.xpt

@@ -36,7 +36,7 @@ Templates for the main statechart cpp file.
   «IF this != null -»
 «this.condition.toCppCode() -»
   «ELSE -»
- true «
+ bool_true «
  ENDIF -»«
   ENDDEFINE»
 
@@ -44,7 +44,7 @@ Templates for the main statechart cpp file.
   «IF this.check != null -»
   «this.check.functionName()»(handle) «
   ELSE -»
- true «
+ bool_true «
   ENDIF -»«
 ENDDEFINE»
 
@@ -62,18 +62,22 @@ else {
 «ENDDEFINE»
 
 «DEFINE ActionCode FOR EnterState»
-state[0] = _«this.state.simpleName»;
+((StatemachineBase*)handle)->state[0] = _«this.state.simpleName»;
 «ENDDEFINE»
 
 «DEFINE ActionCode FOR ExitState»
-state[0] = last_state;
+((StatemachineBase*)handle)->state[0] = last_state;
 «ENDDEFINE»
 
 «DEFINE ConditionMethodsImplement FOR ExecutionState»
   «FOREACH reactions AS r»
   «IF r.check != null -»
-bool «StName().toFirstLower()»_«r.check.functionName()»(«StName()»* handle) {
-  return (	«r.check.condition.toCppCode()» );
+boolean «r.check.functionName()»(«StName()»* handle) {
+  boolean retValue = bool_false;
+  if («r.check.condition.toCppCode()»)
+    retValue = bool_true;
+  
+  return retValue;
 }
   «ENDIF -»
   «ENDFOREACH»
@@ -81,7 +85,10 @@ bool 
 
 «DEFINE StatementMethodsImplement FOR ExecutionState»
   «FOREACH reactions AS r»
-void «this.StName().toFirstLower()»_«r.effect.functionName()»(«StName()»* handle) {
+void «r.effect.functionName()»(«StName()»* handle) {
+ 
+  «DRName()»* variable = &handle->variableData;
+  
   «EXPAND ActionCode FOR r.effect»
 }
   «ENDFOREACH»
@@ -131,7 +138,7 @@ void 
 «EXPAND ExitMethodImplement FOREACH this.states»
 
 
-void «StName().toFirstLower()»_init(«StName()»* handle)
+void «stName()»_init(«StName()»* handle, Timer* timer, EventPool* eventPool)
 {
 	statemachine_cy_init(&handle->base, MAX_PARALLEL_STATES,
 			event_last, timer, eventPool);
@@ -143,18 +150,19 @@ void 
 	«EXPAND ActionCode FOREACH this.enterSequence.steps»
 }
 
-void «StName().toFirstLower()»_exit(«StName()»* handle)
+void «stName()»_exit(«StName()»* handle)
 {
 	statemachine_cy_exit(&handle->base);
-	variableData_exit(&handle->variableData);
+//	variableData_exit(&handle->variableData);
 
 }
 
-void «StName().toFirstLower()»_runCycle(«StName()»* handle)
+void «stName()»_runCycle(«StName()»* handle)
 {
+	statemachine_cy_runCycle(&handle->base);
 }
 
-void «StName().toFirstLower()»_setEvent(«StName()»* handle, _Event* ev)
+void «stName()»_setEvent(«StName()»* handle, _Event* ev)
 {
 	statemachine_cy_setEvent(&handle->base, ev);
 }
@@ -169,10 +177,10 @@ void statemachine_cy__runCycle(Statemachine_cy* handle)
 {
 	uint32_t i;
 	for (i=0; i<MAX_PARALLEL_STATES; ++i) {
-		switch(state[i]) {
+		switch(((StatemachineBase*)handle)->state[i]) {
 	«FOREACH this.states AS state»
 	    case _«state.simpleName»:
-	        cycle_«state.simpleName»((«StName()»*) handle);
+	        «stName()»_cycle_«state.simpleName»((«StName()»*) handle);
 	        break;
 	«ENDFOREACH»
 		default:

+ 2 - 2
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomStatemachineH.xpt

@@ -23,12 +23,12 @@ Templates for the main statechart cpp file.
 #include "«DRName()».h"
 #include "«EvName()».h"
 
-enum States {
+typedef enum {
     «FOREACH this.states AS exState-»
       _«exState.simpleName», 
     «ENDFOREACH»
 	last_state
-};
+} States;
 
 #define MAX_PARALLEL_STATES «this.stateVector.size»
 

+ 47 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/DummyTimer.xpt

@@ -0,0 +1,47 @@
+«REM»
+
+Templates for the main statechart c file.
+
+@auther joern seger
+
+«ENDREM»
+
+«IMPORT sexec»
+«IMPORT stext»
+«IMPORT sgraph»
+
+
+«DEFINE file FOR ExecutionFlow»
+
+«FILE 'DummyTimer.h'»
+#ifndef DUMMYTIMER_H_
+#define DUMMYTIMER_H_
+
+#include "Timer.h"
+
+extern void setTimer(const uint32_t evid, const uint32_t time_ms,
+		boolean periodic);
+
+extern void unsetTimer(const uint32_t evid);
+
+extern void dummyTimer_init(Timer* handle);
+
+#endif /* DUMMYTIMER_H_ */
+«ENDFILE»
+
+«FILE 'DummyTimer.c'»
+#include "DummyTimer.h"
+
+void setTimer(const uint32_t evid, const uint32_t time_ms, boolean periodic)
+{}
+
+void unsetTimer(const uint32_t evid)
+{}
+
+void dummyTimer_init(Timer* handle)
+{
+	timer_setFPtr(handle, &setTimer, unsetTimer);
+}
+«ENDFILE»
+
+«ENDDEFINE»

+ 24 - 14
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Expression.ext

@@ -19,17 +19,17 @@ String toCppCode(PrimitiveValueExpression primValue) :
 /* Assignment */
 String toCppCode(Assignment assignment) :
   switch (assignment.operator) {
-  case (AssignmentOperator::assign) : "set_" + assignment.varRef.name + "(" + assignment.expression.toCppCode() + ");"  
-  case (AssignmentOperator::multAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() * (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::divAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() / (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::modAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() % (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::addAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() + (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::subAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() - (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::leftShiftAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() << ("+ assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::rightShiftAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() >> (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::andAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() & (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::xorAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() ^ (" + assignment.expression.toCppCode() + "));"
-  case (AssignmentOperator::orAssign) : "set_" + assignment.varRef.name + "(get_"+ assignment.varRef.name+ "() ^ (" + assignment.expression.toCppCode() + "));"
+  case (AssignmentOperator::assign) : "variable->" + assignment.varRef.name + " = " + assignment.expression.toCppCode() + ";"  
+  case (AssignmentOperator::multAssign) : "variable->" + assignment.varRef.name + " *= " + assignment.expression.toCppCode() + ";"
+  case (AssignmentOperator::divAssign) : "variable->" + assignment.varRef.name + " /= " + assignment.expression.toCppCode() + ";"
+  case (AssignmentOperator::modAssign) : "variable->" + assignment.varRef.name + " %= " + assignment.expression.toCppCode() + ";"
+  case (AssignmentOperator::addAssign) : "variable->" + assignment.varRef.name + " += " + assignment.expression.toCppCode() + ";"
+  case (AssignmentOperator::subAssign) : "variable->" + assignment.varRef.name + " -= " + assignment.expression.toCppCode() + ";"
+  case (AssignmentOperator::leftShiftAssign) : "variable->" + assignment.varRef.name + " <<= "+ assignment.expression.toCppCode() + ";"
+  case (AssignmentOperator::rightShiftAssign) : "variable->" + assignment.varRef.name + " >>= " + assignment.expression.toCppCode() + ";"
+  case (AssignmentOperator::andAssign) : "variable->" + assignment.varRef.name + " &= " + assignment.expression.toCppCode() + ";"
+  case (AssignmentOperator::xorAssign) : "variable->" + assignment.varRef.name + " ^= " + assignment.expression.toCppCode() + ";"
+  case (AssignmentOperator::orAssign) : "variable->" + assignment.varRef.name + " |= " + assignment.expression.toCppCode() + ";"
   default : ""
   };
 		
@@ -43,10 +43,10 @@ String toCppCode(LogicalAndExpression expression) :
   	expression.leftOperand.toCppCode() + " && " + expression.rightOperand.toCppCode();
 
 String toCppCode(LogicalNotExpression expression) :
-  	" ^" + expression.operand.toCppCode();
+  	" ~" + expression.operand.toCppCode();
 
 String toCppCode(LogicalRelationExpression expression) :
-   expression.leftOperand.toCppCode() + " ??? " + expression.rightOperand.toCppCode();
+   expression.leftOperand.toCppCode() + getOperator(expression.operator) + expression.rightOperand.toCppCode();
     
 String toCppCode(BitwiseAndExpression expression) :
   	expression.leftOperand.toCppCode() + " & " + expression.rightOperand.toCppCode();
@@ -65,7 +65,7 @@ String toCppCode(NumericalMultiplyDivideExpression expression) :
 
 // is this just relevant for events?
 String toCppCode(ElementReferenceExpression ev) :
-    " ( _" + ev.value.name.toLowerCase() + " == ev.getID() ) ";
+    " ( eventSet_check( &handle->base.eventSet, ev_" + ev.value.name.toLowerCase() + ") ) ";
 
 String getOperator(AdditiveOperator operator) : 
     switch(operator) {
@@ -82,3 +82,13 @@ String getOperator(MultiplicativeOperator operator) :
     	default : ""
     };
 
+String getOperator(RelationalOperator operator) :
+	switch (operator) {
+	  case (RelationalOperator::greater) : " > "
+	  case (RelationalOperator::greaterEqual) : " >= "
+	  case (RelationalOperator::smaller) : " < "
+	  case (RelationalOperator::smallerEqual) : " <= "
+	  case (RelationalOperator::equals) : " == "
+	  case (RelationalOperator::notEquals) : " != "
+	  default : ""
+	};

+ 7 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Main.xpt

@@ -33,7 +33,6 @@ Contais the root templates that call the different file templates.
 	«EXPAND Statemachine_cyC::file FOR this»
 
 
-
     «REM» code that is created by the model «ENDREM»
 	«EXPAND definitionH::file FOR this»
 
@@ -42,11 +41,18 @@ Contais the root templates that call the different file templates.
 
 	«EXPAND CustomStatemachineH::file FOR this»
 	«EXPAND CustomStatemachineC::file FOR this»
+	
 	«EXPAND CustomRepositoryH::file FOR this»
+	«EXPAND CustomRepositoryC::file FOR this»
+
 	«EXPAND CustomEventH::file FOR this»
+	«EXPAND CustomEventC::file FOR this»
 	
 	«EXPAND CMakeLists::file FOR this»
+	
+	«REM» Test Code «ENDREM»
 	«EXPAND TestMain::file FOR this»
+	«EXPAND DummyTimer::file FOR this»
 
 «ENDDEFINE»
 

+ 5 - 4
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Naming.ext

@@ -13,6 +13,7 @@ List declaredVariables(ExecutionFlow flow) : flow.scopes.declarations.typeSelect
 String test(NamedElement obj) :  "";
 String StName(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toFirstUpper() + "Statemachine";
 String STNAME(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toUpperCase() + "STATEMACHINE";
+String stName(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toFirstLower() + "Statemachine";
 
 String DRName(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toFirstUpper() + "DataRepository";
 String DRNAME(Object this) : ((ExecutionFlow)((EObject)this).eRootContainer).name.toUpperCase() + "DATAREPOSITORY";
@@ -27,10 +28,10 @@ cached String functionName(Step step) :
 	(step.isExitAction()) ? step.exitActionFunctionName() : 
 	" !! unknown function type !!" )));
  
-String actionFunctionName(Step this) : "actions_" + this.reaction().state().simpleName + "_" + this.reaction().name; 
-String checkFunctionName(Step this) : "condition_" + this.reaction().state().simpleName + "_" + this.reaction().name; 
-String entryActionFunctionName(Step this) : "entryActions_" + this.state().simpleName; 
-String exitActionFunctionName(Step this) : "exitActions_" + this.state().simpleName; 
+String actionFunctionName(Step this) :  this.stName() + "_actions_" + this.reaction().state().simpleName + "_" + this.reaction().name; 
+String checkFunctionName(Step this) : this.stName() + "_condition_" + this.reaction().state().simpleName + "_" + this.reaction().name; 
+String entryActionFunctionName(Step this) : this.stName() + "_entryActions_" + this.state().simpleName; 
+String exitActionFunctionName(Step this) : this.stName() + "_exitActions_" + this.state().simpleName; 
 
 boolean isEffect(Step step) : (! Check.isInstance(step)) && Reaction.isInstance(step.eContainer) ;
 boolean isReactionCheck(Step step) : Reaction.isInstance(step.eContainer) && Check.isInstance(step);

+ 5 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Statemachine_cyC.xpt

@@ -21,6 +21,8 @@ Templates for the main statechart c file.
 void statemachine_cy_init(Statemachine_cy* handle, uint16_t maxStates,
 		uint16_t maxEvents, Timer* timer, EventPool* eventPool) {
 
+	uint32_t i;
+	
 	statemachineBase_init((StatemachineBase*) handle, maxStates, timer);
 	eventSet_init(&handle->eventSet, maxEvents);
 
@@ -55,6 +57,7 @@ void statemachine_cy_init_staticData(Statemachine_cy* handle,
 void statemachine_cy_exit(Statemachine_cy* handle) {
 
 	uint32_t i;
+
 	// the active events, which are not been handled need to be freed
 	for (i = 0; i < handle->eventSet.maxEvents; ++i) {
 		if (eventSet_check(&handle->eventSet, i))
@@ -71,6 +74,8 @@ void statemachine_cy_exit(Statemachine_cy* handle) {
 
 void statemachine_cy_runCycle(Statemachine_cy* handle) {
 
+	uint32_t i;
+
 	/* call internal cycle */
 	statemachine_cy__runCycle(handle);
 

+ 0 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Statemachine_cyH.xpt

@@ -19,7 +19,6 @@ Templates for the main statechart c file.
 
 #include "EventSet.h"
 #include "StatemachineBase.h"
-#include "generatedSource/VariableData.h"
 #include "Timer.h"
 #include "EventPool.h"
 

+ 87 - 59
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/TestMain.xpt

@@ -16,95 +16,123 @@ Templates for the main statechart cpp file.
 
 «DEFINE file FOR ExecutionFlow»
 
-«FILE 'main.cpp'»
-
-/*
- * main.cpp
- *
- *  Created on: 10.09.2011
- *      Author: seger
- */
-
-#include <cstdio>
-#include <iostream>
+«FILE 'main.c'»
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+#include "Timer.h"
+#include "DummyTimer.h"
 #include "«StName()».h"
-// #include "«DRName()».h"
 #include "«EvName()».h"
 
+#define MAXEVENTSPERTYPE 4
 int main()
 {
+	const char* stateName[6] = {"State1", "State2", "State3", "State4", "State5", "State6"};
 
-	char* stateName[6] = {"State1", "State2", "State3", "State4", "State5", "State6"};
 	«StName()» machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+    _Event* ev;
+    Event2* e2;
+
+	/* set up dummy Timer */
+	dummyTimer_init(&dummyTimer);
+
+	/* Set up Event Pool */
+	eventPool_init_heap(&eventPool, event_last, MAXEVENTSPERTYPE);
+
+	/* initialize state machine */
+	«stName()»_init(&machine, &dummyTimer, &eventPool);
 
-	// initialize the initial states 
-	machine.init();
+	/* check the state */
+	printf("%s\n", stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)]);
+	assert( strcmp(stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)], "State1") == 0);
+
+	/* create one event */
 	
-	/* Example code 
-	// create one event and enqueue it 
-	Event e = createEvent<Event1>();
-	machine.queueEvent(e);
+	ev = eventPool_createEvent(&eventPool, ev_event1);
 
-	// run the cycle 
-	machine.runCycle();
+	// The following would work as well
+	// This can be used, if you want to set some information within Event1
+	// e1 = ((Event1*)(eventPool_createEvent(&eventPool, ev_event1)));
 
-	// check the state 
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State3") == 0);
+	/* set the event */
+	«stName()»_setEvent(&machine, ev);
 
-	e = createEvent<Event2>();
-	machine.queueEvent(e);
+	/* run the cycle */
+	«stName()»_runCycle(&machine);
 
-	machine.runCycle();
+	/* check the state */
+	printf("%s\n", stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)]);
+	assert( strcmp(stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)], "State3") == 0);
 
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State1") == 0);
 
-	// does event queuing work?
-	e = createEvent<Event1>();
-	machine.queueEvent(e);
-	e = createEvent<Event3>();
-	machine.queueEvent(e);
+	e2 = ((Event2*)(eventPool_createEvent(&eventPool, ev_event2)));
+	«stName()»_setEvent(&machine, e2);
 
-	machine.runCycle();
+	«stName()»_runCycle(&machine);
 
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State3") == 0);
+	printf("%s\n", stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)]);
+	assert( strcmp(stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)], "State1") == 0);
 
-	// run second cycle
-	machine.runCycle();
+	/* does event queuing work? */
+	ev = eventPool_createEvent(&eventPool, ev_event1);
+	«stName()»_setEvent(&machine, ev);
 
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State4") == 0);
+	ev = eventPool_createEvent(&eventPool, ev_event3);
+	«stName()»_setEvent(&machine, ev);
 
-	e = createEvent<Event4>();
-	machine.queueEvent(e);
+	«stName()»_runCycle(&machine);
 
-	machine.runCycle();
+	printf("%s\n", stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)]);
+	assert( strcmp(stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)], "State3") == 0);
 
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State3") == 0);
+	assert( «stName()»_eventWaiting(&machine) == bool_false );
 
-	e = createEvent<Event3>();
-	machine.queueEvent(e);
 
-	machine.runCycle();
+	ev = eventPool_createEvent(&eventPool, ev_event3);
+	«stName()»_setEvent(&machine, ev);
 
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State4") == 0);
+	assert( «stName()»_eventWaiting(&machine) == bool_true );
 
-	e = createEvent<Event5>();
-	machine.queueEvent(e);
+	«stName()»_runCycle(&machine);
 
-	machine.runCycle();
+	printf("%s\n", stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)]);
+	assert( strcmp(stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)], "State4") == 0);
 
-	std::cout << stateName[machine.getState(0)] << "\n";
-	assert( strcmp(stateName[machine.getState(0)], "State1") == 0);
 
-	*/
-	
+	ev = eventPool_createEvent(&eventPool, ev_event4);
+	«stName()»_setEvent(&machine, ev);
+
+	«stName()»_runCycle(&machine);
+
+	printf("%s\n", stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)]);
+	assert( strcmp(stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)], "State3") == 0);
+
+
+	ev = eventPool_createEvent(&eventPool, ev_event3);
+	«stName()»_setEvent(&machine, ev);
+
+	«stName()»_runCycle(&machine);
+
+	printf("%s\n", stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)]);
+	assert( strcmp(stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)], "State4") == 0);
+
+
+	ev = eventPool_createEvent(&eventPool, ev_event5);
+	«stName()»_setEvent(&machine, ev);
+
+	«stName()»_runCycle(&machine);
+
+	printf("%s\n", stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)]);
+	assert( strcmp(stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)], "State1") == 0);
+
+	«stName()»_exit(&machine);
+	timer_exit(&dummyTimer);
+	eventPool_exit(&eventPool);
+
 	return(0);
-	
 }
 
 «ENDFILE»

+ 1 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/definitionH.xpt

@@ -27,7 +27,7 @@ typedef int int32_t;
 typedef short int16_t;
 
 typedef int32_t integer; 
-typedef bool boolean;
+typedef enum { bool_false = 0, bool_true = 1 } boolean;
 typedef float real;
 //typedef string char*;