Bläddra i källkod

* Operation support for C code generator
* C Tests and generator corrected (Multi instance and singelton)
* Split sgen model for C code

benjamin.schwertfeger@gmail.com 13 år sedan
förälder
incheckning
f53092d943

+ 11 - 0
TestScenarios/C-Test.txt

@@ -0,0 +1,11 @@
+For all tests, the sources have to be generated before.
+Then:
+
+mkdir build
+cd build
+
+#Testing singleton 
+cmake -DCOMPILE_SINGLETON=true .. ; make && ctest
+
+#Testing multi instances
+cmake -DCOMPILE_SINGLETON=false .. ; make && ctest

+ 215 - 0
TestScenarios/GenModelC-sgltn.sgen

@@ -0,0 +1,215 @@
+GeneratorModel for yakindu::c {
+	statechart InterfaceTest {
+		feature	Outlet {
+			targetProject = "TestScenarios"
+			targetFolder = "src-gen-c-sgltn/InterfaceTest"
+		}
+		feature CCodeFeature {
+			InterfaceEventListener = true
+			Singleton = true
+			DebugType = ""
+		}
+		feature LicenseHeader {
+			licenseText = "
+ # Copyright (c) 2011 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
+ "
+		}
+	}
+	statechart Test_DeepHistory {
+		feature Outlet {
+			targetProject = "TestScenarios"
+			targetFolder = "src-gen-c-sgltn/Test_DeepHistory"
+		}
+		feature CCodeFeature {
+			InterfaceEventListener = true
+			Singleton = true
+			DebugType = ""
+		}
+		feature LicenseHeader {
+			licenseText = "
+ # Copyright (c) 2011 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
+ "
+		}
+		
+	}
+	statechart Test_Expression {
+		feature Outlet {
+			targetProject = "TestScenarios"
+			targetFolder = "src-gen-c-sgltn/Test_Expression"
+		}
+		feature CCodeFeature {
+			InterfaceEventListener = true
+			Singleton = true
+			DebugType = ""
+		}
+		feature LicenseHeader {
+			licenseText = "
+ # Copyright (c) 2011 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
+ "
+		}
+
+	}
+	statechart Test_Hierarchy {
+		feature Outlet {
+			targetProject = "TestScenarios"
+			targetFolder = "src-gen-c-sgltn/Test_Hierarchy"
+		}
+		feature CCodeFeature {
+			InterfaceEventListener = true
+			Singleton = true
+			DebugType = ""
+		}
+		feature LicenseHeader {
+			licenseText = "
+ # Copyright (c) 2011 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
+ "
+		}
+	}
+	statechart Test_LocalActions {
+		feature Outlet {
+			targetProject = "TestScenarios"
+			targetFolder = "src-gen-c-sgltn/Test_LocalActions"
+		}
+		feature CCodeFeature {
+			InterfaceEventListener = true
+			Singleton = true
+			DebugType = ""
+		}
+		feature LicenseHeader {
+			licenseText = "
+ # Copyright (c) 2011 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
+ "
+		}
+	}
+	statechart Test_ParallelRegions {
+		feature Outlet {
+			targetProject = "TestScenarios"
+			targetFolder = "src-gen-c-sgltn/Test_ParallelRegions"
+		}
+		feature CCodeFeature {
+			InterfaceEventListener = true
+			Singleton = true
+			DebugType = ""
+		}
+		feature LicenseHeader {
+			licenseText = "
+ # Copyright (c) 2011 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
+ "
+		}
+	}
+	statechart Test_ShallowHistory {
+		feature Outlet {
+			targetProject = "TestScenarios"
+			targetFolder = "src-gen-c-sgltn/Test_ShallowHistory"
+		}
+		feature CCodeFeature {
+			InterfaceEventListener = true
+			Singleton = true
+			DebugType = ""
+		}
+		feature LicenseHeader {
+			licenseText = "
+ # Copyright (c) 2011 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
+ "
+		}
+	}
+	statechart Test_DeepHistory {
+		feature Outlet {
+			targetProject = "TestScenarios"
+			targetFolder = "src-gen-c-sgltn/Test_DeepHistory"
+		}
+		feature Debug {
+			dumpSexec = true
+		}
+		feature CCodeFeature {
+			DebugType = ""
+			InterfaceEventListener = true
+			Singleton = true
+		}
+		feature LicenseHeader {
+			licenseText = "
+ # Copyright (c) 2011 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
+ "
+		}
+	}
+	
+	statechart Test_Transition {
+		feature Outlet {
+			targetProject = "TestScenarios"
+			targetFolder = "src-gen-c-sgltn/Test_Transition"
+		}
+		feature CCodeFeature {
+			InterfaceEventListener = true
+			Singleton = true
+			DebugType = ""
+		}
+		feature LicenseHeader {
+			licenseText = "
+ # Copyright (c) 2011 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
+ "
+		}
+	}
+}

+ 28 - 229
TestScenarios/GenModelC.sgen

@@ -1,28 +1,18 @@
 GeneratorModel for yakindu::c {
 	statechart InterfaceTest {
 		feature Debug { 
-			dumpSexec = false
+			dumpSexec = true
 		} 
 		feature	Outlet {
 			targetProject = "TestScenarios"
 			targetFolder = "src-gen-c/InterfaceTest"
 		}    
-		feature FunctionInlining {
-			inlineReactions = true
-			inlineChoices = true
-			inlineEnterSequences = true
-			inlineEntryActions = true
-			inlineExitActions = true
-			inlineExitSequences = true
-		}
 		feature CCodeFeature {
 			InterfaceEventListener = true
 			Singleton = false
+			DebugType = ""
 		}
-		feature YacopFeature {
-			withYacop = true
-		}
-	feature licenseHeader {
+	feature LicenseHeader {
 			licenseText = "
  # Copyright (c) 2011 committers of YAKINDU and others.
  # All rights reserved. This program and the accompanying materials
@@ -51,8 +41,9 @@ GeneratorModel for yakindu::c {
 		feature CCodeFeature {
 			InterfaceEventListener = true
 			Singleton = false
+			DebugType = ""
 		}
-		feature licenseHeader {
+		feature LicenseHeader {
 			licenseText = "
  # Copyright (c) 2011 committers of YAKINDU and others.
  # All rights reserved. This program and the accompanying materials
@@ -71,11 +62,15 @@ GeneratorModel for yakindu::c {
 			targetProject = "TestScenarios"
 			targetFolder = "src-gen-c/Test_Expression"
 		}
+		feature Debug {
+			dumpSexec = true 
+		}
 		feature CCodeFeature {
+			DebugType = "none"
 			InterfaceEventListener = true
 			Singleton = false
 		}
-		feature licenseHeader {
+		feature LicenseHeader {
 			licenseText = "
  # Copyright (c) 2011 committers of YAKINDU and others.
  # All rights reserved. This program and the accompanying materials
@@ -97,8 +92,15 @@ GeneratorModel for yakindu::c {
 		feature CCodeFeature {
 			InterfaceEventListener = true
 			Singleton = false
+			DebugType = ""
+		}
+				feature FunctionInlining {
+			inlineEnterSequences = false
+			inlineExitSequences = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
 		}
-		feature licenseHeader {
+		feature LicenseHeader {
 			licenseText = "
  # Copyright (c) 2011 committers of YAKINDU and others.
  # All rights reserved. This program and the accompanying materials
@@ -122,8 +124,9 @@ GeneratorModel for yakindu::c {
 		feature CCodeFeature {
 			InterfaceEventListener = true
 			Singleton = false
+			DebugType = ""
 		}
-		feature licenseHeader {
+		feature LicenseHeader {
 			licenseText = "
  # Copyright (c) 2011 committers of YAKINDU and others.
  # All rights reserved. This program and the accompanying materials
@@ -144,8 +147,9 @@ GeneratorModel for yakindu::c {
 		feature CCodeFeature {
 			InterfaceEventListener = true
 			Singleton = false
+			DebugType = ""
 		}
-		feature licenseHeader {
+		feature LicenseHeader {
 			licenseText = "
  # Copyright (c) 2011 committers of YAKINDU and others.
  # All rights reserved. This program and the accompanying materials
@@ -166,8 +170,9 @@ GeneratorModel for yakindu::c {
 		feature CCodeFeature {
 			InterfaceEventListener = true
 			Singleton = false
+			DebugType = ""
 		}
-		feature licenseHeader {
+		feature LicenseHeader {
 			licenseText = "
  # Copyright (c) 2011 committers of YAKINDU and others.
  # All rights reserved. This program and the accompanying materials
@@ -188,11 +193,12 @@ GeneratorModel for yakindu::c {
 		feature CCodeFeature {
 			InterfaceEventListener = true
 			Singleton = false
+			DebugType = ""
 		}
 				feature Debug { 
 			dumpSexec = true
 		} 
-		feature licenseHeader {
+		feature LicenseHeader {
 			licenseText = "
  # Copyright (c) 2011 committers of YAKINDU and others.
  # All rights reserved. This program and the accompanying materials
@@ -213,216 +219,9 @@ GeneratorModel for yakindu::c {
 		feature CCodeFeature {
 			InterfaceEventListener = true
 			Singleton = false
+			DebugType = ""
 		}
-		feature licenseHeader {
-			licenseText = "
- # Copyright (c) 2011 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
- "
-		}
-	}
-
-
-
-
-
-
-
-	statechart InterfaceTest {
-		feature	Outlet {
-			targetProject = "TestScenarios"
-			targetFolder = "src-gen-c-sgltn/InterfaceTest"
-		}
-		feature CCodeFeature {
-			InterfaceEventListener = true
-			Singleton = true
-		}
-		feature licenseHeader {
-			licenseText = "
- # Copyright (c) 2011 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
- "
-		}
-	}
-	statechart Test_DeepHistory {
-		feature Outlet {
-			targetProject = "TestScenarios"
-			targetFolder = "src-gen-c-sgltn/Test_DeepHistory"
-		}
-		feature CCodeFeature {
-			InterfaceEventListener = true
-			Singleton = true
-		}
-		feature licenseHeader {
-			licenseText = "
- # Copyright (c) 2011 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
- "
-		}
-		
-	}
-	statechart Test_Expression {
-		feature Outlet {
-			targetProject = "TestScenarios"
-			targetFolder = "src-gen-c-sgltn/Test_Expression"
-		}
-		feature CCodeFeature {
-			InterfaceEventListener = true
-			Singleton = true
-		}
-		feature licenseHeader {
-			licenseText = "
- # Copyright (c) 2011 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
- "
-		}
-
-	}
-	statechart Test_Hierarchy {
-		feature Outlet {
-			targetProject = "TestScenarios"
-			targetFolder = "src-gen-c-sgltn/Test_Hierarchy"
-		}
-		feature CCodeFeature {
-			InterfaceEventListener = true
-			Singleton = true
-		}
-		feature licenseHeader {
-			licenseText = "
- # Copyright (c) 2011 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
- "
-		}
-	}
-	statechart Test_LocalActions {
-		feature Outlet {
-			targetProject = "TestScenarios"
-			targetFolder = "src-gen-c-sgltn/Test_LocalActions"
-		}
-		feature CCodeFeature {
-			InterfaceEventListener = true
-			Singleton = true
-		}
-		feature licenseHeader {
-			licenseText = "
- # Copyright (c) 2011 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
- "
-		}
-	}
-	statechart Test_ParallelRegions {
-		feature Outlet {
-			targetProject = "TestScenarios"
-			targetFolder = "src-gen-c-sgltn/Test_ParallelRegions"
-		}
-		feature CCodeFeature {
-			InterfaceEventListener = true
-			Singleton = true
-		}
-		feature licenseHeader {
-			licenseText = "
- # Copyright (c) 2011 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
- "
-		}
-	}
-	statechart Test_ShallowHistory {
-		feature Outlet {
-			targetProject = "TestScenarios"
-			targetFolder = "src-gen-c-sgltn/Test_ShallowHistory"
-		}
-		feature CCodeFeature {
-			InterfaceEventListener = true
-			Singleton = true
-		}
-		feature licenseHeader {
-			licenseText = "
- # Copyright (c) 2011 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
- "
-		}
-	}
-	statechart Test_DeepHistory {
-		feature Outlet {
-			targetProject = "TestScenarios"
-			targetFolder = "src-gen-c-sgltn/Test_DeepHistory"
-		}
-		feature CCodeFeature {
-			InterfaceEventListener = true
-			Singleton = true
-		}
-		feature licenseHeader {
-			licenseText = "
- # Copyright (c) 2011 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
- "
-		}
-	}
-	
-	statechart Test_Transition {
-		feature Outlet {
-			targetProject = "TestScenarios"
-			targetFolder = "src-gen-c-sgltn/Test_Transition"
-		}
-		feature CCodeFeature {
-			InterfaceEventListener = true
-			Singleton = true
-		}
-		feature licenseHeader {
+		feature LicenseHeader {
 			licenseText = "
  # Copyright (c) 2011 committers of YAKINDU and others.
  # All rights reserved. This program and the accompanying materials

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 17 - 5
TestScenarios/TestModels/Test_Expression.sct


+ 2 - 2
TestScenarios/test-c-sgltn/InterfaceTest/main.c

@@ -277,7 +277,7 @@ int test_third_interface_good()
 	InterfaceTestStatemachine* machine;
 	Timer dummyTimer;
 	EventPool eventPool;
-	boolean retVal = bool_false;
+	sc_boolean retVal = bool_false;
 
 	/*@Desc: setup initial statemachine */
 	setupStatemachine(&dummyTimer, &eventPool);
@@ -340,7 +340,7 @@ int test_third_interface_bad()
 	Timer dummyTimer;
 	EventPool eventPool;
 
-	boolean retVal = bool_false;
+	sc_boolean retVal = bool_false;
 
 	/*@Desc: setup initial statemachine */
 	setupStatemachine(&dummyTimer, &eventPool);

+ 8 - 0
TestScenarios/test-c-sgltn/Test_DeepHistory/CMakeLists.txt

@@ -0,0 +1,8 @@
+include_directories(../../src-gen-c-sgltn/Test_DeepHistory)
+
+add_executable(TestDeepHistoryMain main.c)
+target_link_libraries(TestDeepHistoryMain Test_DeepHistoryStatemachine)
+
+add_test(initialJumpToState3 TestDeepHistoryMain "1")
+add_test(initialJumpToState5 TestDeepHistoryMain "2")
+

+ 206 - 0
TestScenarios/test-c-sgltn/Test_DeepHistory/main.c

@@ -0,0 +1,206 @@
+/*
+ * main.c
+ *
+ *  Created on: 16.11.2011
+ *      Author: showcase
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include "Timer.h"
+#include "DummyTimer.h"
+#include "Test_DeepHistoryStatemachine.h"
+
+/*@DTestSuite: ShallowHistory Statechart Test (Test_ShallowHistory.sct) */
+
+#define MAXEVENTSPERTYPE 4
+const char* stateName[10] = {"State1", "State2", "State3", "State4", "State5", "State6", "State7", "State8", "State9", "noState"};
+const int EnumTostateStr[10] = { _Test_DeepHistory_mainRegion_State1,
+		_Test_DeepHistory_mainRegion_State2,
+		_Test_DeepHistory_mainRegion_State2_region0_State3,
+		_Test_DeepHistory_mainRegion_State2_region0_State4,
+		_Test_DeepHistory_mainRegion_State2_region0_State5,
+		_Test_DeepHistory_mainRegion_State2_region0_State4_region0_State6,
+		_Test_DeepHistory_mainRegion_State2_region0_State4_region0_State7,
+		_Test_DeepHistory_mainRegion_State2_region0_State4_region0_State7_region0_State8,
+		_Test_DeepHistory_mainRegion_State2_region0_State4_region0_State7_region0_State9,
+		last_state };
+
+const char* getStateString(uint32_t index)
+{
+	int i;
+	for (i=0; i<10; ++i)
+		if (EnumTostateStr[i] == index)
+			return stateName[i];
+	return stateName[last_state];
+}
+
+void setupStatemachine(Timer* dummyTimer, EventPool* eventPool)
+{
+	/* set up dummy Timer */
+	dummyTimer_init(dummyTimer);
+
+	/* Set up Event Pool */
+	test_DeepHistory_eventPool_init_heap(eventPool, MAXEVENTSPERTYPE);
+
+	/* initialize state machine */
+	test_DeepHistoryStatemachine_init(dummyTimer, eventPool);
+
+	/* call all necessary enter functions */
+	test_DeepHistoryStatemachine_enter();
+
+}
+
+void teardownStatemachine(Timer* dummyTimer, EventPool* eventPool)
+{
+	/* call all exit actions for this state machine */
+	test_DeepHistoryStatemachine_exit();
+
+	/* free all internal memory for this state machine */
+	test_DeepHistoryStatemachine_destruct();
+
+	/* free the timer */
+	timer_exit(dummyTimer);
+
+	/* free all events in the event pool */
+	eventPool_exit(eventPool);
+
+}
+
+/*@Test: test_default_var1 test behavior of var1 in default interface */
+int test_initialization()
+{
+
+	return 0;
+}
+
+
+/*@Test: initialJumpToState3 test, if the initial state in state2 is activated */
+int initialJumpToState3()
+{
+	Test_DeepHistoryStatemachine* machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+	Test_DeepHistoryIf* iface;
+
+	/*@Desc: setup initial statemachine */
+	setupStatemachine(&dummyTimer, &eventPool);
+
+	/* get the handle only for getting the state name */
+	machine = test_DeepHistory_get_handle();
+
+	iface = test_DeepHistoryStatemachine_get_iface();
+
+	/*@Desc: check the initial state at position 0 to be State1 */
+	printf("%s\n", getStateString(statemachineBase_getState((StatemachineBase*)machine,0)));
+	assert( strcmp(getStateString(statemachineBase_getState((StatemachineBase*)machine,0)), "State1") == 0);
+
+	test_DeepHistory_if_raise_event1(iface);
+
+	test_DeepHistoryStatemachine_runCycle();
+
+	/*@Desc: check the initial state at position 1 to be no State */
+	printf("%s\n", getStateString(statemachineBase_getState((StatemachineBase*)machine,0)));
+	assert( strcmp(getStateString(statemachineBase_getState((StatemachineBase*)machine,0)), "State3") == 0);
+
+	test_DeepHistory_if_raise_event2(iface);
+
+	test_DeepHistoryStatemachine_runCycle();
+
+	/*@Desc: check the initial state at position 2 to be no State */
+	printf("%s\n", getStateString(statemachineBase_getState((StatemachineBase*)machine,0)));
+	assert( strcmp(getStateString(statemachineBase_getState((StatemachineBase*)machine,0)), "State1") == 0);
+
+
+	/*@Desc: teardown statemachine */
+	teardownStatemachine(&dummyTimer, &eventPool);
+
+	return 0;
+}
+
+/*@Test: test_default_var1 test behavior of var1 in default and other interface */
+int initialJumpToState5()
+{
+	Test_DeepHistoryStatemachine* machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+	Test_DeepHistoryIf* iface;
+
+	/*@Desc: setup initial statemachine */
+	setupStatemachine(&dummyTimer, &eventPool);
+
+	/* get the handle only for getting the state name */
+	machine = test_DeepHistory_get_handle();
+
+	iface = test_DeepHistoryStatemachine_get_iface();
+
+	/*@Desc: check the initial state at position 0 to be State1 */
+	printf("%s\n", getStateString(statemachineBase_getState((StatemachineBase*)machine,0)));
+	assert( strcmp(getStateString(statemachineBase_getState((StatemachineBase*)machine,0)), "State1") == 0);
+
+	test_DeepHistory_if_raise_event1(iface);
+
+	test_DeepHistoryStatemachine_runCycle();
+
+	/*@Desc: check the initial state at position 1 to be no State */
+	printf("%s\n", getStateString(statemachineBase_getState((StatemachineBase*)machine,0)));
+	assert( strcmp(getStateString(statemachineBase_getState((StatemachineBase*)machine,0)), "State3") == 0);
+
+	test_DeepHistory_if_raise_event3(iface);
+
+	test_DeepHistoryStatemachine_runCycle();
+
+	test_DeepHistory_if_raise_event4(iface);
+
+	test_DeepHistoryStatemachine_runCycle();
+
+	/*@Desc: check the initial state at position 2 to be no State */
+	printf("%s\n", getStateString(statemachineBase_getState((StatemachineBase*)machine,0)));
+	assert( strcmp(getStateString(statemachineBase_getState((StatemachineBase*)machine,0)), "State5") == 0);
+
+	test_DeepHistory_if_raise_event2(iface);
+
+	test_DeepHistoryStatemachine_runCycle();
+
+	/*@Desc: check the initial state at position 0 to be State1 */
+	printf("%s\n", getStateString(statemachineBase_getState((StatemachineBase*)machine,0)));
+	assert( strcmp(getStateString(statemachineBase_getState((StatemachineBase*)machine,0)), "State1") == 0);
+
+	test_DeepHistory_if_raise_event1(iface);
+
+	test_DeepHistoryStatemachine_runCycle();
+
+	/*@Desc: check the initial state at position 2 to be no State */
+	printf("%s\n", getStateString(statemachineBase_getState((StatemachineBase*)machine,0)));
+	assert( strcmp(getStateString(statemachineBase_getState((StatemachineBase*)machine,0)), "State5") == 0);
+
+
+	/*@Desc: teardown statemachine */
+	teardownStatemachine(&dummyTimer, &eventPool);
+
+	return 0;
+}
+
+
+
+
+
+
+int main(int argc, char** argv)
+{
+	if (argc != 2)
+		return -1;
+
+	switch (atoi(argv[1])) {
+	case 1:
+		return initialJumpToState3();
+	case 2:
+		return initialJumpToState5();
+	}
+
+	return -1;
+
+}

+ 5 - 1
TestScenarios/test-c-sgltn/Test_Hierarchy/main.c

@@ -18,7 +18,11 @@
 
 #define MAXEVENTSPERTYPE 4
 const char* stateName[13] = {"State1", "State2", "State3", "State4", "State5", "State6", "State7", "State8", "State9", "State10", "State11", "State12", "none"};
-const int EnumTostateStr[10] = { _State1, _State2, _State3, _State4, _State5, _State6, _State7, _State8, _State9, _State10 };
+const int EnumTostateStr[10] = { _Test_Hierarchy_mainRegion_State1, _Test_Hierarchy_mainRegion_State2, _Test_Hierarchy_mainRegion_State2_Region2_State3, _Test_Hierarchy_mainRegion_State2_Region2_State4,
+		_Test_Hierarchy_mainRegion_State2_Region2_State4_Region4_State5, _Test_Hierarchy_mainRegion_State2_Region2_State4_Region4_State6,
+		_Test_Hierarchy_mainRegion_State2_Region2_State4_Region4_State6_Region6_State7,
+		_Test_Hierarchy_mainRegion_State2_Region2_State4_Region4_State6_Region6_State8,
+		_Test_Hierarchy_mainRegion_State1_Region1_State9, _Test_Hierarchy_mainRegion_State1_Region1_State10 };
 
 const char* getStateString(uint32_t index)
 {

+ 10 - 1
TestScenarios/test-c/Test_DeepHistory/main.c

@@ -18,7 +18,16 @@
 
 #define MAXEVENTSPERTYPE 4
 const char* stateName[10] = {"State1", "State2", "State3", "State4", "State5", "State6", "State7", "State8", "State9", "noState"};
-const int EnumTostateStr[10] = { _State1, _State2, _State3, _State4, _State5, _State6, _State7, _State8, _State9, last_state };
+const int EnumTostateStr[10] = { _Test_DeepHistory_mainRegion_State1,
+		_Test_DeepHistory_mainRegion_State2,
+		_Test_DeepHistory_mainRegion_State2_region0_State3,
+		_Test_DeepHistory_mainRegion_State2_region0_State4,
+		_Test_DeepHistory_mainRegion_State2_region0_State5,
+		_Test_DeepHistory_mainRegion_State2_region0_State4_region0_State6,
+		_Test_DeepHistory_mainRegion_State2_region0_State4_region0_State7,
+		_Test_DeepHistory_mainRegion_State2_region0_State4_region0_State7_region0_State8,
+		_Test_DeepHistory_mainRegion_State2_region0_State4_region0_State7_region0_State9,
+		last_state };
 
 const char* getStateString(uint32_t index)
 {

+ 5 - 1
TestScenarios/test-c/Test_Hierarchy/main.c

@@ -18,7 +18,11 @@
 
 #define MAXEVENTSPERTYPE 4
 const char* stateName[13] = {"State1", "State2", "State3", "State4", "State5", "State6", "State7", "State8", "State9", "State10", "State11", "State12", "none"};
-const int EnumTostateStr[10] = { _State1, _State2, _State3, _State4, _State5, _State6, _State7, _State8, _State9, _State10 };
+const int EnumTostateStr[10] = { _Test_Hierarchy_mainRegion_State1, _Test_Hierarchy_mainRegion_State2, _Test_Hierarchy_mainRegion_State2_Region2_State3, _Test_Hierarchy_mainRegion_State2_Region2_State4,
+		_Test_Hierarchy_mainRegion_State2_Region2_State4_Region4_State5, _Test_Hierarchy_mainRegion_State2_Region2_State4_Region4_State6,
+		_Test_Hierarchy_mainRegion_State2_Region2_State4_Region4_State6_Region6_State7,
+		_Test_Hierarchy_mainRegion_State2_Region2_State4_Region4_State6_Region6_State8,
+		_Test_Hierarchy_mainRegion_State1_Region1_State9, _Test_Hierarchy_mainRegion_State1_Region1_State10 , last_state };
 
 const char* getStateString(uint32_t index)
 {

+ 1 - 1
TestScenarios/test-c/Test_LocalActions/main.c

@@ -18,7 +18,7 @@
 
 #define MAXEVENTSPERTYPE 4
 const char* stateName[3] = {"State1", "State2", "noState"};
-const int EnumTostateStr[3] = { _State1, _State2, last_state };
+const int EnumTostateStr[3] = { _Test_LocalActions_mainRegion_State1, _Test_LocalActions_mainRegion_State2, last_state };
 
 const char* getStateString(uint32_t index)
 {

+ 8 - 1
TestScenarios/test-c/Test_ParallelRegions/main.c

@@ -18,7 +18,14 @@
 
 #define MAXEVENTSPERTYPE 4
 const char* stateName[10] = {"State1", "State2", "State3", "State4", "State5", "State6", "State7", "State8", "State9", "noState"};
-const int EnumTostateStr[10] = { _State1, _State2, _State3, _State4, _State5, _State6, _State7, _State8, _State9, last_state };
+const int EnumTostateStr[10] = { _Test_ParallelRegions_mainRegion_State1, _Test_ParallelRegions_mainRegion_State2,
+		_Test_ParallelRegions_mainRegion_State2_Region1_State3,
+		_Test_ParallelRegions_mainRegion_State2_Region1_State4,
+		_Test_ParallelRegions_mainRegion_State2_Region1_State4_Region2_State5,
+		_Test_ParallelRegions_mainRegion_State2_Region1_State4_Region2_State6,
+		_Test_ParallelRegions_mainRegion_State2_Region3_State7,
+		_Test_ParallelRegions_mainRegion_State2_Region3_State8,
+		_Test_ParallelRegions_mainRegion_State2_Region1_State4_Region4_State9, last_state };
 
 const char* getStateString(uint32_t index)
 {

+ 1 - 1
TestScenarios/test-c/Test_Transition/main.c

@@ -18,7 +18,7 @@
 
 #define MAXEVENTSPERTYPE 4
 const char* stateName[3] = {"State1", "State2", "noState"};
-const int EnumTostateStr[3] = { _State1, _State2, last_state };
+const int EnumTostateStr[3] = { _Test_Transition_region0_State1, _Test_Transition_region0_State2, last_state };
 
 const char* getStateString(uint32_t index)
 {

+ 1 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/GeneratorEntryAccess.java

@@ -51,7 +51,7 @@ public class GeneratorEntryAccess {
 		}
 
 		public boolean isAdapterForType(Object type) {
-			return false;
+			return type == ProxyAdapter.class;
 		}
 	}
 }

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

@@ -75,7 +75,7 @@ if (
 «ENDDEFINE»
 
 «DEFINE ActionCode FOR Execution»
-	«this.statement.toCCode()»
+	«this.statement.toCCode()»;
 «ENDDEFINE»
 
 «DEFINE ActionCode FOR Call»
@@ -285,6 +285,7 @@ void 
 
 #include "«StName()».h"
 #include <stdlib.h>
+#include <string.h>
 
 «IF this.isSingleton() == true»
 /* singleton handle and singleton handle pointer declaration */
@@ -366,12 +367,11 @@ void 
 «IF this.isSingleton() == true»
 «StName()»* «scName()»_get_handle()
 { return «statemachineHandleName()»; } 
-«ELSE»
+«ENDIF»
 «FOREACH this.scopes.typeSelect(InterfaceScope) AS interface»
-extern «interface.interfaceClassName()»* «stName()»_get_«interface.interfaceObjectName().toFirstLower()»(«handleAddition()»)
+extern «interface.interfaceClassName()»* «stName()»_get_«interface.interfaceObjectName()»(«handleAddition()»)
 {  return &«statemachineHandleName()»->«interface.interfaceObjectName()»; }
 «ENDFOREACH»
-«ENDIF»
 
 void «stName()»_enter(«handleAddition()»)
 {

+ 17 - 16
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Expression.ext

@@ -45,17 +45,17 @@ String toCCode(PrimitiveValueExpression primValue) :
 /* Assignment */
 String toCCode(AssignmentExpression assignment) :
   switch (assignment.operator) {
-  case (AssignmentOperator::assign) : assignment.varRef.toCCode() + " = " + assignment.expression.toCCode() + ";"  
-  case (AssignmentOperator::multAssign) : assignment.varRef.toCCode() + " *= " + assignment.expression.toCCode() + ";"
-  case (AssignmentOperator::divAssign) : assignment.varRef.toCCode() + " /= " + assignment.expression.toCCode() + ";"
-  case (AssignmentOperator::modAssign) : assignment.varRef.toCCode() + " %= " + assignment.expression.toCCode() + ";"
-  case (AssignmentOperator::addAssign) : assignment.varRef.toCCode() + " += " + assignment.expression.toCCode() + ";"
-  case (AssignmentOperator::subAssign) : assignment.varRef.toCCode() + " -= " + assignment.expression.toCCode() + ";"
-  case (AssignmentOperator::leftShiftAssign) : assignment.varRef.toCCode() + " <<= "+ assignment.expression.toCCode() + ";"
-  case (AssignmentOperator::rightShiftAssign) : assignment.varRef.toCCode() + " >>= " + assignment.expression.toCCode() + ";"
-  case (AssignmentOperator::andAssign) : assignment.varRef.toCCode() + " &= " + assignment.expression.toCCode() + ";"
-  case (AssignmentOperator::xorAssign) : assignment.varRef.toCCode() + " ^= " + assignment.expression.toCCode() + ";"
-  case (AssignmentOperator::orAssign) : assignment.varRef.toCCode() + " |= " + assignment.expression.toCCode() + ";"
+  case (AssignmentOperator::assign) : assignment.varRef.toCCode() + " = " + assignment.expression.toCCode() 
+  case (AssignmentOperator::multAssign) : assignment.varRef.toCCode() + " *= " + assignment.expression.toCCode()
+  case (AssignmentOperator::divAssign) : assignment.varRef.toCCode() + " /= " + assignment.expression.toCCode()
+  case (AssignmentOperator::modAssign) : assignment.varRef.toCCode() + " %= " + assignment.expression.toCCode()
+  case (AssignmentOperator::addAssign) : assignment.varRef.toCCode() + " += " + assignment.expression.toCCode()
+  case (AssignmentOperator::subAssign) : assignment.varRef.toCCode() + " -= " + assignment.expression.toCCode()
+  case (AssignmentOperator::leftShiftAssign) : assignment.varRef.toCCode() + " <<= "+ assignment.expression.toCCode()
+  case (AssignmentOperator::rightShiftAssign) : assignment.varRef.toCCode() + " >>= " + assignment.expression.toCCode()
+  case (AssignmentOperator::andAssign) : assignment.varRef.toCCode() + " &= " + assignment.expression.toCCode()
+  case (AssignmentOperator::xorAssign) : assignment.varRef.toCCode() + " ^= " + assignment.expression.toCCode()
+  case (AssignmentOperator::orAssign) : assignment.varRef.toCCode() + " |= " + assignment.expression.toCCode()
   default : ""
   };
 		
@@ -112,9 +112,6 @@ String toCCode(NumericalUnaryExpression expression) :
 ExecutionFlow getExecutionFlow(InterfaceScope this) : ((ExecutionFlow)this.eContainer);
 String interfaceObjectName(InterfaceScope this) : "iface" + ((this.name == null)?"":this.name.toFirstUpper());
 
-String getInterface(VariableDefinition var) :
-	((InterfaceScope)var.eContainer).interfaceObjectName();
-
 String getOperator(AdditiveOperator operator) : 
     switch(operator) {
     	case(AdditiveOperator::plus) : " + "
@@ -178,17 +175,21 @@ Set[EventDefinition] getLocalEvents(InternalScope interface) :
 
 // is this just relevant for events?
 String toCCode(ElementReferenceExpression ref) :
-	ref.reference.toCCode();
+	ref.reference.toCCode()+ (if (ref.operationCall) then "("+ref.getInterfaceCallComma()+ref.args.toCCode().toString(",")+")" else "");
+
 String toCCode(EObject ref) :
 	"/* toCode not defined for: "+ref+" */";
 String toCCode(Feature ref) :
 	"/* toCode not defined for: "+ref+" */";
 String toCCode(FeatureCall ref) :
-	ref.feature.toCCode();
+	ref.feature.toCCode()+ (if (ref.operationCall) then "("+ref.getInterfaceCallComma()+ref.args.toCCode().toString(",")+")" else "");
 
 String toCCode(Declaration dec) :
 	"Declartion type not specified";
 
+String toCCode(OperationDefinition dec) :
+	" " +dec.getMethodName();
+
 String toCCode(TimeEvent time_ev) :
     " ( eventSet_check( &"+time_ev.statemachineHandleName()+"->base.eventSet, " + time_ev.getEventEnumName() + ") ) ";
 

+ 19 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Interfaces.xpt

@@ -69,6 +69,10 @@ extern void 
 «ENDIF»
 «ENDFOREACH» 
 
+«FOREACH interface.declarations.typeSelect(OperationDefinition) AS operation -»
+extern «asCType(operation.type)» «operation.getMethodName()»(«handleInterfaceAddition(interface)»«IF !isSingleton()», «ENDIF»«
+	FOREACH operation.parameters AS param ITERATOR iter»«IF iter.counter0>0», «ENDIF»«asCType(param.type)» «param.name»«ENDFOREACH»);
+«ENDFOREACH» 
 
 extern void «interface.interfaceName()»_reset_event(«handleInterfaceAddition(interface)»);
 
@@ -109,6 +113,7 @@ IF !event.type.isVoid() -
 «this.getLicenseHeader()»
 #include "«interface.interfaceClassName()».h"
 #include <stdlib.h>
+#include <string.h>
 
 «IF this.isSingleton()»
 static «interfaceClassName(interface)»* handle;
@@ -140,6 +145,7 @@ void 
 «ENDFOREACH-»
 «ENDIF-»
 «ENDLET-»
+
 	/* */ 
 	«interface.interfaceName()»_reset_event(handle);
 
@@ -155,6 +161,19 @@ void 
 
 }
 
+«IF !interface.declarations.typeSelect(OperationDefinition).isEmpty-»
+#ifndef USE_MANUAL_OPERATION_IMPLEMENTATION
+«FOREACH interface.declarations.typeSelect(OperationDefinition) AS operation -»
+«asCType(operation.type)» «operation.getMethodName()»(«handleInterfaceAddition(interface)»«IF !isSingleton()», «ENDIF»«
+	FOREACH operation.parameters AS param ITERATOR iter»«IF iter.counter0>0», «ENDIF»«asCType(param.type)» «param.name»«ENDFOREACH»)
+{
+	/** Default implementation of operation «operation.getMethodName()» */
+	return«IF !operation.type.isVoid()» «operation.type.defaultType()»«ENDIF-»;
+}
+«ENDFOREACH-» 
+#endif //USE_MANUAL_OPERATION_IMPLEMENTATION
+«ENDIF»
+
 «IF this.isSingleton()»
 void «interface.interfaceName()»_set_interface_singleton(«interfaceClassName(interface)»* _handle)
 { handle = _handle; }

+ 16 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Naming.ext

@@ -163,6 +163,11 @@ String reactFunction(ExecutionNode this) :
 	  this.reactFunctionName() + "("+ handleAddition() + ")";
 
 String getName(VariableDefinition this): name.toFirstLower();
+String getName(OperationDefinition this): name.toFirstLower();
+
+String getMethodName(OperationDefinition def): getMethodName(def, def.eContainer);
+String getMethodName(OperationDefinition def, InterfaceScope scope): ((ExecutionFlow)def.eRootContainer).name.toFirstLower()+"_if"+(scope.name != null? "_"+scope.name:"")+"_"+def.name;
+String getMethodName(OperationDefinition def, emf::EObject scope): ((ExecutionFlow)def.eRootContainer).name.toFirstLower()+"_if"+"_"+def.name;
 
 String getStateName(Step this) : this.eContainer.getStateName(); 
 String getStateName(emf::EObject this) : (this.eContainer != null)?this.eContainer.getStateName():"unkown";
@@ -235,9 +240,20 @@ String getEventName(types::Event this) : this.eContainer.getScopeName().toFirstU
 String getEventName(types::Feature this) : "/* Event expected, but got Feature: "+this+" */";
 String getEventName(Expression this) : "/* Event expected, but got Expression: "+this+" */";
 
+String getInterface(VariableDefinition var) : ((InterfaceScope)var.eContainer).interfaceObjectName();
+
+String getInterface(OperationDefinition var) : ((InterfaceScope)var.eContainer).interfaceObjectName();
+
 String getInterfaceName(EventRaisingExpression this) :
 	"iface" + (( this.event.getEvent().eContainer.getScopeName() == "default")?"":this.event.getEvent().eContainer.getScopeName().toFirstUpper());
 
+String getInterfaceCallComma(emf::EObject ref):  ref.getInterfaceCall()==""?"":ref.getInterfaceCall()+", ";
+String getInterfaceCallComma(EObject ref): ref.getInterfaceCall()==""?"":ref.getInterfaceCall()+", ";
+String getInterfaceCall(EObject ref): "";
+String getInterfaceCall(ElementReferenceExpression ref): ref.reference.getInterfaceCall();
+String getInterfaceCall(FeatureCall ref): ref.feature.getInterfaceCall();
+String getInterfaceCall(OperationDefinition ref): ref.isSingleton()?"":"&"+ref.statemachineHandleName() + "->" + ref.getInterface();
+
 EventDefinition getEvent(Expression e) : null;
 EventDefinition getEvent(EObject e) : null;
 EventDefinition getEvent(FeatureCall this) : feature.getEvent();

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

@@ -77,8 +77,6 @@ void statemachine_cy_destruct(Statemachine_cy* handle) {
 
 void statemachine_cy_runCycle(Statemachine_cy* handle) {
 
-	uint32_t i;
-
 	/* delete all outgoing events */
 	eventSet_clean_output(&handle->eventSet);