Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-12-12 15:14:00 +0000
committerJuergen Haug2012-12-12 15:14:00 +0000
commit5d9b58598e7ca37940afb777337975f4afad4dbf (patch)
treeba83942b8814e1658a73b7b243e9982f72441fab
parent72802f3f5250f6632ed0a4e6dc3bedcb9c5ffee4 (diff)
parent7d084613b6dc6ea496e51f70e511126081cdd307 (diff)
downloadorg.eclipse.etrice-5d9b58598e7ca37940afb777337975f4afad4dbf.tar.gz
org.eclipse.etrice-5d9b58598e7ca37940afb777337975f4afad4dbf.tar.xz
org.eclipse.etrice-5d9b58598e7ca37940afb777337975f4afad4dbf.zip
Merge remote-tracking branch 'origin/master' into change/8995/1
Conflicts: plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip Change-Id: Iec86201d19ab068e6f2eb9b667e05d3bc3e78786
-rw-r--r--examples/org.eclipse.etrice.tutorials.java/buckminster.cspec2
-rw-r--r--plugins/org.eclipse.etrice.core.etphys/.gitignore1
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel/.settings/edu.umd.cs.findbugs.core.prefs132
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilder.java21
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/ExpandedActorClassImpl.java58
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/RootImpl.java2
-rw-r--r--plugins/org.eclipse.etrice.core.room/.checkstyle11
-rw-r--r--plugins/org.eclipse.etrice.core.room/.settings/edu.umd.cs.findbugs.core.prefs132
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java24
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/RoomScopeProvider.java2
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java37
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java78
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend7
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CTranslationProvider.java20
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend6
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java20
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java18
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/.classpath8
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/.gitignore2
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/.project34
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF25
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/build.properties4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/GeneratorOptions.java30
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/Main.java189
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend255
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.xtend179
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend224
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.java60
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend268
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Initialization.xtend100
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend52
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend430
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend93
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend289
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend105
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Validator.java49
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.java51
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java412
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java846
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java60
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java1394
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend1
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaTranslationProvider.java15
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/Activator.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorMainTab.java5
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/.classpath7
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/.gitignore2
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/.project28
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/META-INF/MANIFEST.MF22
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/build.properties6
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/icons/eTrice-launch.gifbin0 -> 894 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/plugin.xml32
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/Activator.java53
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorConfigTab.java67
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorLaunchConfigurationDelegate.java65
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorLaunchConfigurationTabGroup.java24
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorMainTab.java35
-rw-r--r--plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java23
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java2
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DefaultTranslationProvider.java15
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DetailCodeTranslator.java4
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend178
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java9
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java731
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/PortMessageSelectionDialog.java8
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java6
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zipbin14616 -> 14622 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zipbin0 -> 17976 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zipbin46855 -> 46865 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zipbin3524828 -> 3525671 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zipbin0 -> 38801 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zipbin37337 -> 37692 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zipbin100394 -> 100404 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/create_contents.xml2
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/plugin.xml34
-rw-r--r--runtime/org.eclipse.etrice.modellib.c/buckminster.cspec3
-rw-r--r--runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c5
-rw-r--r--runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h1
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/.cproject143
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/.gitignore2
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/.project33
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs9
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/buckminster.cspec1
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/cpp_gen_modellib.launch13
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/model/Language.room3
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room301
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/model/Types.room21
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/model/diagrams/room.basic.service.timing.ATimingService.behavior146
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/model/diagrams/room.basic.service.timing.ATimingService.structure35
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/src-gen/readme.txt4
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp259
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h263
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp242
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.h139
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/buckminster.cspec2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/about.html28
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/buckminster.cspec3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c16
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.c2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/.cproject148
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/.gitignore2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/.project71
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.codan.core.prefs67
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs9
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/about.html28
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/buckminster.cspec1
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp70
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h62
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.cpp43
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.h43
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.cpp99
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.h63
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h43
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp82
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h46
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.cpp18
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.h29
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp16
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h30
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp28
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h54
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp73
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h42
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp59
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h44
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp119
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h77
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp120
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h65
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp54
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h36
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.cpp39
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.h45
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp215
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h145
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp54
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h73
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp16
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h34
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.cpp18
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.h26
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp35
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h53
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.cpp27
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h33
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp153
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h71
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp65
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h41
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp16
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h43
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/platform/etTimer.h46
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/config/etRuntimeConfig.h33
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etDatatypes.h77
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/buckminster.cspec3
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/IRTObject.java1
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageDispatcher.java15
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java24
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTObject.java38
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java5
-rw-r--r--tests/org.eclipse.etrice.core.room.tests/models/TestBindings.room104
-rw-r--r--tests/org.eclipse.etrice.core.room.tests/src/org/eclipse/etrice/core/TestBindings.java83
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/buckminster.cspec3
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/buckminster.cspec3
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/.classpath8
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/.gitignore6
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/.project17
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/.settings/org.eclipse.jdt.core.prefs11
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/about.html28
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/buckminster.cspec11
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/make.xml360
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/buckminster.cspec3
-rw-r--r--tests/org.eclipse.etrice.runtime.java.tests/buckminster.cspec2
-rw-r--r--tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/messaging/DummyMessageReceiver.java7
-rw-r--r--tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java8
-rw-r--r--tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java13
185 files changed, 12307 insertions, 364 deletions
diff --git a/examples/org.eclipse.etrice.tutorials.java/buckminster.cspec b/examples/org.eclipse.etrice.tutorials.java/buckminster.cspec
index 68a3e94d1..3d656533e 100644
--- a/examples/org.eclipse.etrice.tutorials.java/buckminster.cspec
+++ b/examples/org.eclipse.etrice.tutorials.java/buckminster.cspec
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
-<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.tutorials.java" componentType="buckminster" version="1.0.0"/>
+<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.tutorials.java" componentType="buckminster" version="0.3.0.qualifier"/>
diff --git a/plugins/org.eclipse.etrice.core.etphys/.gitignore b/plugins/org.eclipse.etrice.core.etphys/.gitignore
index 092357e47..d1b2f933f 100644
--- a/plugins/org.eclipse.etrice.core.etphys/.gitignore
+++ b/plugins/org.eclipse.etrice.core.etphys/.gitignore
@@ -1 +1,2 @@
bin
+*._trace
diff --git a/plugins/org.eclipse.etrice.core.genmodel/.settings/edu.umd.cs.findbugs.core.prefs b/plugins/org.eclipse.etrice.core.genmodel/.settings/edu.umd.cs.findbugs.core.prefs
new file mode 100644
index 000000000..a8786022b
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.genmodel/.settings/edu.umd.cs.findbugs.core.prefs
@@ -0,0 +1,132 @@
+#FindBugs User Preferences
+#Thu Nov 29 18:46:28 CET 2012
+cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud
+detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
+detectorAtomicityProblem=AtomicityProblem|true
+detectorBadAppletConstructor=BadAppletConstructor|false
+detectorBadResultSetAccess=BadResultSetAccess|true
+detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
+detectorBadUseOfReturnValue=BadUseOfReturnValue|true
+detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true
+detectorBooleanReturnNull=BooleanReturnNull|true
+detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false
+detectorCheckExpectedWarnings=CheckExpectedWarnings|false
+detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
+detectorCheckTypeQualifiers=CheckTypeQualifiers|true
+detectorCloneIdiom=CloneIdiom|true
+detectorComparatorIdiom=ComparatorIdiom|true
+detectorConfusedInheritance=ConfusedInheritance|true
+detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true
+detectorCrossSiteScripting=CrossSiteScripting|true
+detectorDefaultEncodingDetector=DefaultEncodingDetector|true
+detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true
+detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true
+detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true
+detectorDontUseEnum=DontUseEnum|true
+detectorDroppedException=DroppedException|true
+detectorDumbMethodInvocations=DumbMethodInvocations|true
+detectorDumbMethods=DumbMethods|true
+detectorDuplicateBranches=DuplicateBranches|true
+detectorEmptyZipFileEntry=EmptyZipFileEntry|true
+detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true
+detectorExplicitSerialization=ExplicitSerialization|true
+detectorFinalizerNullsFields=FinalizerNullsFields|true
+detectorFindBadCast2=FindBadCast2|true
+detectorFindBadForLoop=FindBadForLoop|true
+detectorFindCircularDependencies=FindCircularDependencies|false
+detectorFindDeadLocalStores=FindDeadLocalStores|true
+detectorFindDoubleCheck=FindDoubleCheck|true
+detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true
+detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true
+detectorFindFinalizeInvocations=FindFinalizeInvocations|true
+detectorFindFloatEquality=FindFloatEquality|true
+detectorFindHEmismatch=FindHEmismatch|true
+detectorFindInconsistentSync2=FindInconsistentSync2|true
+detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true
+detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true
+detectorFindMaskedFields=FindMaskedFields|true
+detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true
+detectorFindNakedNotify=FindNakedNotify|true
+detectorFindNonShortCircuit=FindNonShortCircuit|true
+detectorFindNullDeref=FindNullDeref|true
+detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true
+detectorFindOpenStream=FindOpenStream|true
+detectorFindPuzzlers=FindPuzzlers|true
+detectorFindRefComparison=FindRefComparison|true
+detectorFindReturnRef=FindReturnRef|true
+detectorFindRunInvocations=FindRunInvocations|true
+detectorFindSelfComparison=FindSelfComparison|true
+detectorFindSelfComparison2=FindSelfComparison2|true
+detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true
+detectorFindSpinLoop=FindSpinLoop|true
+detectorFindSqlInjection=FindSqlInjection|true
+detectorFindTwoLockWait=FindTwoLockWait|true
+detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true
+detectorFindUnconditionalWait=FindUnconditionalWait|true
+detectorFindUninitializedGet=FindUninitializedGet|true
+detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true
+detectorFindUnreleasedLock=FindUnreleasedLock|true
+detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true
+detectorFindUnsyncGet=FindUnsyncGet|true
+detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true
+detectorFindUselessControlFlow=FindUselessControlFlow|true
+detectorFormatStringChecker=FormatStringChecker|true
+detectorHugeSharedStringConstants=HugeSharedStringConstants|true
+detectorIDivResultCastToDouble=IDivResultCastToDouble|true
+detectorIncompatMask=IncompatMask|true
+detectorInconsistentAnnotations=InconsistentAnnotations|true
+detectorInefficientMemberAccess=InefficientMemberAccess|false
+detectorInefficientToArray=InefficientToArray|true
+detectorInfiniteLoop=InfiniteLoop|true
+detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true
+detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
+detectorInitializationChain=InitializationChain|true
+detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true
+detectorInstantiateStaticClass=InstantiateStaticClass|true
+detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true
+detectorInvalidJUnitTest=InvalidJUnitTest|true
+detectorIteratorIdioms=IteratorIdioms|true
+detectorLazyInit=LazyInit|true
+detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true
+detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true
+detectorMethodReturnCheck=MethodReturnCheck|true
+detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true
+detectorMutableLock=MutableLock|true
+detectorMutableStaticFields=MutableStaticFields|true
+detectorNaming=Naming|true
+detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true
+detectorNumberConstructor=NumberConstructor|true
+detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true
+detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true
+detectorPublicSemaphores=PublicSemaphores|false
+detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true
+detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true
+detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true
+detectorRedundantInterfaces=RedundantInterfaces|true
+detectorRepeatedConditionals=RepeatedConditionals|true
+detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true
+detectorSerializableIdiom=SerializableIdiom|true
+detectorStartInConstructor=StartInConstructor|true
+detectorStaticCalendarDetector=StaticCalendarDetector|true
+detectorStringConcatenation=StringConcatenation|true
+detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true
+detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true
+detectorSwitchFallthrough=SwitchFallthrough|true
+detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true
+detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true
+detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true
+detectorURLProblems=URLProblems|true
+detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true
+detectorUnnecessaryMath=UnnecessaryMath|true
+detectorUnreadFields=UnreadFields|true
+detectorUselessSubclassMethod=UselessSubclassMethod|false
+detectorVarArgsProblems=VarArgsProblems|true
+detectorVolatileUsage=VolatileUsage|true
+detectorWaitInLoop=WaitInLoop|true
+detectorWrongMapIterator=WrongMapIterator|true
+detectorXMLFactoryBypass=XMLFactoryBypass|true
+detector_threshold=2
+effort=default
+filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MT_CORRECTNESS,PERFORMANCE,STYLE|false|15
+filter_settings_neg=MALICIOUS_CODE,NOISE,I18N,SECURITY,EXPERIMENTAL|
+run_at_full_build=false
diff --git a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilder.java b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilder.java
index d4bef235e..ca828f358 100644
--- a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilder.java
+++ b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilder.java
@@ -103,6 +103,8 @@ public class GeneratorModelBuilder {
*/
private IDiagnostician diagnostician;
+ private boolean debug;
+
/**
* the only constructor takes a logger and a diagnostician as arguments
* @param logger
@@ -113,7 +115,9 @@ public class GeneratorModelBuilder {
this.diagnostician = diagnostician;
}
- // TODOHRR: combine a RoomProject (.room_proj) with RoomModels (.room)
+ public Root createGeneratorModel(List<RoomModel> models, boolean asLibrary) {
+ return createGeneratorModel(models, asLibrary, false);
+ }
/**
* Creates a model of all instances for all sub systems.
@@ -131,12 +135,15 @@ public class GeneratorModelBuilder {
* are removed and their contents is relocated.
*
* @param models
+ * @param asLibrary
+ * @param debug if true more output is produced
* @return the root of the newly created instance model
*/
- public Root createGeneratorModel(List<RoomModel> models, boolean asLibrary) {
+ public Root createGeneratorModel(List<RoomModel> models, boolean asLibrary, boolean debug) {
Root root = ETriceGenFactory.eINSTANCE.createRoot();
root.getModels().addAll(models);
root.setLibrary(asLibrary);
+ this.debug = debug;
if (!root.isLibrary()) {
// create instance model
@@ -476,7 +483,7 @@ public class GeneratorModelBuilder {
* @return the newly created hierarchy of instances
*/
private SubSystemInstance createSubSystemInstance(SubSystemClass ssc) {
- logger.logInfo("GeneratorModelBuilder: creating subsystem class from "+ssc.getName());
+ logger.logInfo("GeneratorModelBuilder: creating subsystem instance from "+ssc.getName());
SubSystemInstance instance = ETriceGenFactory.eINSTANCE.createSubSystemInstance();
allObjects.add(instance);
@@ -519,7 +526,8 @@ public class GeneratorModelBuilder {
if (idx>=0)
name += "_"+idx;
- logger.logInfo("GeneratorModelBuilder: creating actor instance "+name+" from "+aref.getType().getName());
+ if (debug)
+ logger.logInfo("GeneratorModelBuilder: creating actor instance "+name+" from "+aref.getType().getName());
ActorInstance ai = ETriceGenFactory.eINSTANCE.createActorInstance();
allObjects.add(ai);
@@ -1108,8 +1116,9 @@ public class GeneratorModelBuilder {
* @return - the newly created expanded actor class
*/
public ExpandedActorClass createExpandedActorClass(ActorClass ac) {
- logger.logInfo("GeneratorModelBuilder: creating expanded actor class from "+ac.getName()
- +" of "+((RoomModel)ac.eContainer()).getName());
+ if (debug)
+ logger.logInfo("GeneratorModelBuilder: creating expanded actor class from "+ac.getName()
+ +" of "+((RoomModel)ac.eContainer()).getName());
ExpandedActorClass xpac = ETriceGenFactory.eINSTANCE.createExpandedActorClass();
xpac.setActorClass(ac);
diff --git a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/ExpandedActorClassImpl.java b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/ExpandedActorClassImpl.java
index b8750fe50..39846e4a4 100644
--- a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/ExpandedActorClassImpl.java
+++ b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/ExpandedActorClassImpl.java
@@ -57,7 +57,6 @@ import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.MessageFromIf;
import org.eclipse.etrice.core.room.NonInitialTransition;
import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.RefinedState;
import org.eclipse.etrice.core.room.RefinedTransition;
@@ -540,7 +539,7 @@ public class ExpandedActorClassImpl extends EObjectImpl implements ExpandedActor
for (TrPoint tp : sg.getTrPoints()) {
NodeData data = node2data.get(tp);
- int idx = sg.getChPoints().indexOf(tp);
+ int idx = sg.getTrPoints().indexOf(tp);
if (data==null) {
if (!getActorClass(tp).isAbstract())
@@ -698,23 +697,11 @@ public class ExpandedActorClassImpl extends EObjectImpl implements ExpandedActor
private void fillTriggerStringMap() {
// improve performance using maps name2ifitem and name2msgs
HashMap<String, InterfaceItem> name2ifitem = new HashMap<String, InterfaceItem>();
- HashMap<String, EList<Message>> name2msgs = new HashMap<String, EList<Message>>();
- ActorClass ac = getActorClass();
- while (ac!=null) {
- for (Port ip : ac.getIntPorts()) {
- mapPort(ip, name2ifitem, name2msgs);
- }
- for (ExternalPort ep : ac.getExtPorts()) {
- mapPort(ep.getIfport(), name2ifitem, name2msgs);
- }
- for (SAPRef sap : ac.getStrSAPs()) {
- mapSAP(sap, name2ifitem, name2msgs);
- }
- for (ServiceImplementation spp : ac.getServiceImplementations()) {
- mapSPP(spp.getSpp(), name2ifitem, name2msgs);
- }
-
- ac = ac.getBase();
+ HashMap<String, List<Message>> name2msgs = new HashMap<String, List<Message>>();
+ List<InterfaceItem> items = RoomHelpers.getAllInterfaceItems(getActorClass());
+ for (InterfaceItem item : items) {
+ name2ifitem.put(item.getName(), item);
+ name2msgs.put(item.getName(),RoomHelpers.getMessageListDeep(item, false));
}
// compute a set of all trigger strings
@@ -738,7 +725,7 @@ public class ExpandedActorClassImpl extends EObjectImpl implements ExpandedActor
// this should always hold true
assert(ii!=null): "The name '"+parts[0]+"' did not match an interface item (in name2ifitem)!";
- EList<Message> msgs = name2msgs.get(parts[0]);
+ List<Message> msgs = name2msgs.get(parts[0]);
// this should always hold true
assert(msgs!=null): "The name '"+parts[0]+"' did not match an interface item (in name2msgs)!";
@@ -758,36 +745,7 @@ public class ExpandedActorClassImpl extends EObjectImpl implements ExpandedActor
triggerstring2mif.put(trig, mif);
}
}
-
- private void mapPort(Port p, HashMap<String, InterfaceItem> name2ifitem,
- HashMap<String, EList<Message>> name2msgs) {
- name2ifitem.put(p.getName(), p);
-
- if (!(p.getProtocol() instanceof ProtocolClass))
- return;
-
- if (p.isConjugated())
- name2msgs.put(p.getName(), ((ProtocolClass)p.getProtocol()).getOutgoingMessages());
- else
- name2msgs.put(p.getName(), ((ProtocolClass)p.getProtocol()).getIncomingMessages());
- }
-
- private void mapSAP(SAPRef sap, HashMap<String, InterfaceItem> name2ifitem,
- HashMap<String, EList<Message>> name2msgs) {
- name2ifitem.put(sap.getName(), sap);
-
- // sap is conjugated wrt to the protocol
- name2msgs.put(sap.getName(), sap.getProtocol().getOutgoingMessages());
- }
-
- private void mapSPP(SPPRef spp, HashMap<String, InterfaceItem> name2ifitem,
- HashMap<String, EList<Message>> name2msgs) {
- name2ifitem.put(spp.getName(), spp);
-
- // spp is regular wrt to the protocol
- name2msgs.put(spp.getName(), spp.getProtocol().getIncomingMessages());
- }
-
+
private void addTransitionChain(Transition t) {
TransitionChain tc = ETriceGenFactory.eINSTANCE.createTransitionChain();
tc.setTransition(t);
diff --git a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/RootImpl.java b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/RootImpl.java
index a5bdbbeb5..4819eea17 100644
--- a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/RootImpl.java
+++ b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/RootImpl.java
@@ -795,7 +795,7 @@ public class RootImpl extends EObjectImpl implements Root {
private void getOperationDataClasses(HashSet<DataClass> dataClasses, EList<? extends Operation> operations) {
for (Operation op : operations) {
if (op.getReturntype()!=null) {
- DataClass dc = name2dc.get(op.getReturntype());
+ DataClass dc = name2dc.get(op.getReturntype().getType().getName());
if (dc!=null)
dataClasses.add(dc);
}
diff --git a/plugins/org.eclipse.etrice.core.room/.checkstyle b/plugins/org.eclipse.etrice.core.room/.checkstyle
new file mode 100644
index 000000000..d417d3b25
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.room/.checkstyle
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+ <fileset name="all" enabled="true" check-config-name="eTrice checks" local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+ <filter name="WriteProtectedFiles" enabled="true"/>
+ <filter name="FilesFromPackage" enabled="true">
+ <filter-data value="src-gen"/>
+ </filter>
+</fileset-config>
diff --git a/plugins/org.eclipse.etrice.core.room/.settings/edu.umd.cs.findbugs.core.prefs b/plugins/org.eclipse.etrice.core.room/.settings/edu.umd.cs.findbugs.core.prefs
new file mode 100644
index 000000000..878b3e299
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.room/.settings/edu.umd.cs.findbugs.core.prefs
@@ -0,0 +1,132 @@
+#FindBugs User Preferences
+#Thu Nov 29 18:45:51 CET 2012
+cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud
+detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
+detectorAtomicityProblem=AtomicityProblem|true
+detectorBadAppletConstructor=BadAppletConstructor|false
+detectorBadResultSetAccess=BadResultSetAccess|true
+detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
+detectorBadUseOfReturnValue=BadUseOfReturnValue|true
+detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true
+detectorBooleanReturnNull=BooleanReturnNull|true
+detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false
+detectorCheckExpectedWarnings=CheckExpectedWarnings|false
+detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
+detectorCheckTypeQualifiers=CheckTypeQualifiers|true
+detectorCloneIdiom=CloneIdiom|true
+detectorComparatorIdiom=ComparatorIdiom|true
+detectorConfusedInheritance=ConfusedInheritance|true
+detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true
+detectorCrossSiteScripting=CrossSiteScripting|true
+detectorDefaultEncodingDetector=DefaultEncodingDetector|true
+detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true
+detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true
+detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true
+detectorDontUseEnum=DontUseEnum|true
+detectorDroppedException=DroppedException|true
+detectorDumbMethodInvocations=DumbMethodInvocations|true
+detectorDumbMethods=DumbMethods|true
+detectorDuplicateBranches=DuplicateBranches|true
+detectorEmptyZipFileEntry=EmptyZipFileEntry|true
+detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true
+detectorExplicitSerialization=ExplicitSerialization|true
+detectorFinalizerNullsFields=FinalizerNullsFields|true
+detectorFindBadCast2=FindBadCast2|true
+detectorFindBadForLoop=FindBadForLoop|true
+detectorFindCircularDependencies=FindCircularDependencies|false
+detectorFindDeadLocalStores=FindDeadLocalStores|true
+detectorFindDoubleCheck=FindDoubleCheck|true
+detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true
+detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true
+detectorFindFinalizeInvocations=FindFinalizeInvocations|true
+detectorFindFloatEquality=FindFloatEquality|true
+detectorFindHEmismatch=FindHEmismatch|true
+detectorFindInconsistentSync2=FindInconsistentSync2|true
+detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true
+detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true
+detectorFindMaskedFields=FindMaskedFields|true
+detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true
+detectorFindNakedNotify=FindNakedNotify|true
+detectorFindNonShortCircuit=FindNonShortCircuit|true
+detectorFindNullDeref=FindNullDeref|true
+detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true
+detectorFindOpenStream=FindOpenStream|true
+detectorFindPuzzlers=FindPuzzlers|true
+detectorFindRefComparison=FindRefComparison|true
+detectorFindReturnRef=FindReturnRef|true
+detectorFindRunInvocations=FindRunInvocations|true
+detectorFindSelfComparison=FindSelfComparison|true
+detectorFindSelfComparison2=FindSelfComparison2|true
+detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true
+detectorFindSpinLoop=FindSpinLoop|true
+detectorFindSqlInjection=FindSqlInjection|true
+detectorFindTwoLockWait=FindTwoLockWait|true
+detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true
+detectorFindUnconditionalWait=FindUnconditionalWait|true
+detectorFindUninitializedGet=FindUninitializedGet|true
+detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true
+detectorFindUnreleasedLock=FindUnreleasedLock|true
+detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true
+detectorFindUnsyncGet=FindUnsyncGet|true
+detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true
+detectorFindUselessControlFlow=FindUselessControlFlow|true
+detectorFormatStringChecker=FormatStringChecker|true
+detectorHugeSharedStringConstants=HugeSharedStringConstants|true
+detectorIDivResultCastToDouble=IDivResultCastToDouble|true
+detectorIncompatMask=IncompatMask|true
+detectorInconsistentAnnotations=InconsistentAnnotations|true
+detectorInefficientMemberAccess=InefficientMemberAccess|false
+detectorInefficientToArray=InefficientToArray|true
+detectorInfiniteLoop=InfiniteLoop|true
+detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true
+detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
+detectorInitializationChain=InitializationChain|true
+detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true
+detectorInstantiateStaticClass=InstantiateStaticClass|true
+detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true
+detectorInvalidJUnitTest=InvalidJUnitTest|true
+detectorIteratorIdioms=IteratorIdioms|true
+detectorLazyInit=LazyInit|true
+detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true
+detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true
+detectorMethodReturnCheck=MethodReturnCheck|true
+detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true
+detectorMutableLock=MutableLock|true
+detectorMutableStaticFields=MutableStaticFields|true
+detectorNaming=Naming|true
+detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true
+detectorNumberConstructor=NumberConstructor|true
+detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true
+detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true
+detectorPublicSemaphores=PublicSemaphores|false
+detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true
+detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true
+detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true
+detectorRedundantInterfaces=RedundantInterfaces|true
+detectorRepeatedConditionals=RepeatedConditionals|true
+detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true
+detectorSerializableIdiom=SerializableIdiom|true
+detectorStartInConstructor=StartInConstructor|true
+detectorStaticCalendarDetector=StaticCalendarDetector|true
+detectorStringConcatenation=StringConcatenation|true
+detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true
+detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true
+detectorSwitchFallthrough=SwitchFallthrough|true
+detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true
+detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true
+detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true
+detectorURLProblems=URLProblems|true
+detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true
+detectorUnnecessaryMath=UnnecessaryMath|true
+detectorUnreadFields=UnreadFields|true
+detectorUselessSubclassMethod=UselessSubclassMethod|false
+detectorVarArgsProblems=VarArgsProblems|true
+detectorVolatileUsage=VolatileUsage|true
+detectorWaitInLoop=WaitInLoop|true
+detectorWrongMapIterator=WrongMapIterator|true
+detectorXMLFactoryBypass=XMLFactoryBypass|true
+detector_threshold=2
+effort=default
+filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MT_CORRECTNESS,PERFORMANCE,STYLE|false|15
+filter_settings_neg=MALICIOUS_CODE,NOISE,I18N,SECURITY,EXPERIMENTAL|
+run_at_full_build=false
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
index 125855a98..88709415e 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
@@ -814,7 +814,7 @@ public class RoomHelpers {
return true;
}
- public static List<Message> getMessageList(InterfaceItem item, boolean outgoing) {
+ public static List<Message> getMessageListDeep(InterfaceItem item, boolean outgoing) {
ProtocolClass protocol = null;
if (item instanceof Port) {
if (!(((Port) item).getProtocol() instanceof ProtocolClass)) {
@@ -839,7 +839,7 @@ public class RoomHelpers {
return null;
}
- return outgoing? protocol.getOutgoingMessages():protocol.getIncomingMessages();
+ return outgoing? RoomHelpers.getAllMessages(protocol,false):RoomHelpers.getAllMessages(protocol,true);
}
public static PortClass getPortClass(InterfaceItem item) {
@@ -1332,4 +1332,24 @@ public class RoomHelpers {
return null;
}
+
+ /**
+ * checks whether pc1 is derived from (but not equal) pc2
+ *
+ * @param pc1 potential sub class
+ * @param pc2 potential super class
+ *
+ * @return true if pc1 is derived from pc2
+ */
+ public static boolean isDerivedFrom(ProtocolClass pc1, ProtocolClass pc2) {
+ if (pc1==pc2)
+ return false;
+
+ while (pc1!=null) {
+ if (pc1==pc2)
+ return true;
+ pc1 = pc1.getBase();
+ }
+ return false;
+ }
}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/RoomScopeProvider.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/RoomScopeProvider.java
index 689611478..8e343182f 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/RoomScopeProvider.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/RoomScopeProvider.java
@@ -337,7 +337,7 @@ public class RoomScopeProvider extends AbstractDeclarativeScopeProvider {
}
if (protocol!=null)
- for (Message msg : conjugated?protocol.getOutgoingMessages():protocol.getIncomingMessages()) {
+ for (Message msg : conjugated?RoomHelpers.getAllMessages(protocol,false):RoomHelpers.getAllMessages(protocol,true)) {
scopes.add(EObjectDescription.create(msg.getName(), msg));
}
}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
index 2787a79bc..6b57788f5 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
@@ -139,9 +139,9 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
@Check
public void checkRefHasFixedMultiplicityPorts(ActorRef ar) {
- if (ar.getSize()>1) {
+ if (ar!=null) {
ActorClass ac = ar.getType();
- if (ar!=null) {
+ if (ar.getSize()>1) {
for (Port p : ac.getIfPorts()) {
if (p.getMultiplicity()<0) {
int idx = ((ActorContainerClass)ar.eContainer()).getActorRefs().indexOf(ar);
@@ -398,6 +398,9 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
@Check
public void checkProtocol(ProtocolClass pc) {
+ if (ValidationUtil.isCircularClassHierarchy(pc))
+ return;
+
switch (pc.getCommType()) {
case DATA_DRIVEN:
if (pc.getBase()!=null && pc.getBase().getCommType()!=CommunicationType.DATA_DRIVEN)
@@ -418,6 +421,36 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
break;
default:
}
+
+ if (pc.getBase()!=null) {
+ // derived protocol
+ if (pc.getIncomingMessages().size()>0 && pc.getOutgoingMessages().size()>0)
+ warning("a derived protocol should add either incoming or outgoing messages, not both", RoomPackage.Literals.PROTOCOL_CLASS__OUTGOING_MESSAGES);
+
+ {
+ List<Message> incoming = RoomHelpers.getAllMessages(pc, true);
+ HashSet<String> inNames = new HashSet<String>();
+ for (Message in : incoming) {
+ if (!inNames.add(in.getName())) {
+ int idx = pc.getIncomingMessages().indexOf(in);
+ if (idx>=0)
+ error("duplicate message name", pc, RoomPackage.Literals.PROTOCOL_CLASS__INCOMING_MESSAGES, idx);
+ }
+ }
+ }
+
+ {
+ List<Message> outgoing = RoomHelpers.getAllMessages(pc, true);
+ HashSet<String> outNames = new HashSet<String>();
+ for (Message out : outgoing) {
+ if (!outNames.add(out.getName())) {
+ int idx = pc.getOutgoingMessages().indexOf(out);
+ if (idx>=0)
+ error("duplicate message name", pc, RoomPackage.Literals.PROTOCOL_CLASS__OUTGOING_MESSAGES, idx);
+ }
+ }
+ }
+ }
}
@Check
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java
index 8eebd878f..17ee618c2 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java
@@ -286,6 +286,10 @@ public class ValidationUtil {
return Result.error("ports are already bound");
// check protocol compatibility
+ boolean pc1extendsIncoming = false;
+ boolean pc1extendsOutgoing = false;
+ boolean pc2extendsIncoming = false;
+ boolean pc2extendsOutgoing = false;
{
GeneralProtocolClass pc1 = p1.getProtocol();
GeneralProtocolClass pc2 = p2.getProtocol();
@@ -315,8 +319,32 @@ public class ValidationUtil {
}
}
else {
- if (pc1!=pc2)
- return Result.error("protocols don't match");
+ if (pc1!=pc2) {
+ if (compoundInvolved) {
+ return Result.error("protocols don't match");
+ }
+ else {
+ if (RoomHelpers.isDerivedFrom((ProtocolClass)pc1, (ProtocolClass)pc2)) {
+ if (RoomHelpers.getAllMessages((ProtocolClass)pc1,true).size() > RoomHelpers.getAllMessages((ProtocolClass)pc2,true).size())
+ pc1extendsIncoming = true;
+ if (RoomHelpers.getAllMessages((ProtocolClass)pc1,false).size()>RoomHelpers.getAllMessages((ProtocolClass)pc2,false).size())
+ pc1extendsOutgoing = true;
+ if (pc1extendsIncoming && pc1extendsOutgoing)
+ return Result.error("derived protocols not connectable (both directions extended)");
+
+ }
+ else if (RoomHelpers.isDerivedFrom((ProtocolClass)pc2, (ProtocolClass)pc1)) {
+ if (RoomHelpers.getAllMessages((ProtocolClass)pc2,true).size()>RoomHelpers.getAllMessages((ProtocolClass)pc1,true).size())
+ pc2extendsIncoming = true;
+ if (RoomHelpers.getAllMessages((ProtocolClass)pc2,false).size()>RoomHelpers.getAllMessages((ProtocolClass)pc1,false).size())
+ pc2extendsOutgoing = true;
+ if (pc2extendsIncoming && pc2extendsOutgoing)
+ return Result.error("derived protocols not connectable (both directions extended)");
+ }
+ else
+ return Result.error("protocols don't match");
+ }
+ }
}
if (checkCompound || !compoundInvolved) {
@@ -330,8 +358,9 @@ public class ValidationUtil {
spc2 = (ProtocolClass) pc2;
else if (sub2.getProtocol() instanceof ProtocolClass)
spc2 = (ProtocolClass) sub2.getProtocol();
- if (spc1.getCommType()!=spc2.getCommType())
- return Result.error("protocol communication types don't match");
+ if (spc1!=null && spc2!=null)
+ if (spc1.getCommType()!=spc2.getCommType())
+ return Result.error("protocol communication types don't match");
}
if (compoundInvolved) {
List<Match> matches = CompoundProtocolHelpers.getMatches(p1, ref1, p2, ref2, sc, exclude);
@@ -359,6 +388,15 @@ public class ValidationUtil {
if (p1.isConjugated()==p2.isConjugated())
return Result.error("connected sub component ports must be conjugated to each other");
+ if (p1.isConjugated() && pc1extendsIncoming)
+ return Result.error("protocol extends incoming");
+ if (p2.isConjugated() && pc2extendsIncoming)
+ return Result.error("protocol extends incoming");
+ if (!p1.isConjugated() && pc1extendsOutgoing)
+ return Result.error("protocol extends outgoing");
+ if (!p2.isConjugated() && pc2extendsOutgoing)
+ return Result.error("protocol extends outgoing");
+
Result result = isConnectable(p1, ref1, sc, exclude);
if (!result.isOk())
return result;
@@ -377,6 +415,26 @@ public class ValidationUtil {
if (local.isConjugated()!=sub.isConjugated())
return Result.error("relay port must have same direction as local port");
+ if (local==p1) {
+ if (!p1.isConjugated() && pc1extendsIncoming)
+ return Result.error("protocol extends incoming");
+ if (p2.isConjugated() && pc2extendsIncoming)
+ return Result.error("protocol extends incoming");
+ if (p1.isConjugated() && pc1extendsOutgoing)
+ return Result.error("protocol extends outgoing");
+ if (!p2.isConjugated() && pc2extendsOutgoing)
+ return Result.error("protocol extends outgoing");
+ }
+ else {
+ if (p1.isConjugated() && pc1extendsIncoming)
+ return Result.error("protocol extends incoming");
+ if (!p2.isConjugated() && pc2extendsIncoming)
+ return Result.error("protocol extends incoming");
+ if (!p1.isConjugated() && pc1extendsOutgoing)
+ return Result.error("protocol extends outgoing");
+ if (p2.isConjugated() && pc2extendsOutgoing)
+ return Result.error("protocol extends outgoing");
+ }
Result result = isConnectable(local, null, acc, exclude);
if (!result.isOk())
return result;
@@ -389,6 +447,15 @@ public class ValidationUtil {
if (local.isConjugated()==sub.isConjugated())
return Result.error("internal end port must have opposite direction");
+
+ if (p1.isConjugated() && pc1extendsIncoming)
+ return Result.error("protocol extends incoming");
+ if (p2.isConjugated() && pc2extendsIncoming)
+ return Result.error("protocol extends incoming");
+ if (!p1.isConjugated() && pc1extendsOutgoing)
+ return Result.error("protocol extends outgoing");
+ if (!p2.isConjugated() && pc2extendsOutgoing)
+ return Result.error("protocol extends outgoing");
Result result = isConnectable(sub, ref, sc, exclude);
if (!result.isOk())
@@ -951,7 +1018,8 @@ public class ValidationUtil {
tr.eContainer(),
RoomPackage.eINSTANCE.getStateGraph_Transitions(),
((StateGraph)tr.eContainer()).getTransitions().indexOf(tr));
- } }
+ }
+ }
return Result.ok();
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
index 5e3ab435e..3fe054f81 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
@@ -28,12 +28,13 @@ import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.GenericActorClassGenerator
-
+import org.eclipse.etrice.generator.generic.ILanguageExtension
@Singleton
class ActorClassGen extends GenericActorClassGenerator {
@Inject JavaIoFileSystemAccess fileAccess
+ @Inject extension ILanguageExtension langExt
@Inject extension CExtensions
@Inject extension RoomExtensions
@@ -231,7 +232,7 @@ class ActorClassGen extends GenericActorClassGenerator {
ET_MSC_LOGGER_SYNC_ENTRY("«ac.name»", "_receiveMessage")
«IF !xpac.stateMachine.empty»
- receiveEvent(self«IF handleEvents», (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))«ENDIF»);
+ «langExt.operationScope(ac.name, false)»receiveEvent(self«IF handleEvents», (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))«ENDIF»);
«ENDIF»
ET_MSC_LOGGER_SYNC_EXIT
@@ -242,7 +243,7 @@ class ActorClassGen extends GenericActorClassGenerator {
ET_MSC_LOGGER_SYNC_ENTRY("«ac.name»", "_execute")
«IF !xpac.stateMachine.empty»
- receiveEvent(self«IF handleEvents», NULL, 0, NULL«ENDIF»);
+ «langExt.operationScope(ac.name, false)»receiveEvent(self«IF handleEvents», NULL, 0, NULL«ENDIF»);
«ENDIF»
ET_MSC_LOGGER_SYNC_EXIT
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
index b32c9f089..a22a032ba 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
@@ -111,6 +111,10 @@ class CExtensions implements ILanguageExtension {
return false
}
+ override boolean usesPointers() {
+ return true
+ }
+
override String genEnumeration(String name, List<Pair<String, String>> entries) {
if (entries.empty)
return "/* empty enum not generated */"
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CTranslationProvider.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CTranslationProvider.java
index 87e6bf130..22f534b08 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CTranslationProvider.java
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CTranslationProvider.java
@@ -14,7 +14,6 @@ package org.eclipse.etrice.generator.c.gen;
import java.util.ArrayList;
-import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.CommunicationType;
@@ -27,17 +26,15 @@ import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RoomClass;
import org.eclipse.etrice.core.room.SAPRef;
import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.generator.base.ITranslationProvider;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.base.DefaultTranslationProvider;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
import com.google.inject.Inject;
-public class CTranslationProvider implements ITranslationProvider {
+public class CTranslationProvider extends DefaultTranslationProvider {
@Inject private RoomExtensions roomExt;
- @Inject ILogger logger;
@Inject ILanguageExtension langExt;
@Override
@@ -144,15 +141,8 @@ public class CTranslationProvider implements ITranslationProvider {
public String translateTag(String tag, DetailCode code) {
if (tag.equals("ifitem.index"))
return "((etReplSubPort*)ifitem)->index";
-
- if (tag.equals("MODEL_LOCATION")) {
- return RoomNameProvider.getDetailCodeLocation(code);
- }
-
- logger.logInfo("unrecognized tag '"+tag+"' in "
- +RoomNameProvider.getDetailCodeLocation(code)+" of "
- +RoomNameProvider.getClassLocation(RoomNameProvider.getModelClass(code)));
- return TAG_START+"?"+tag+"?"+TAG_END;
+
+ return super.translateTag(tag, code);
}
private String getOrigComment(String orig) {
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
index 252bd0214..00384db6e 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
@@ -50,7 +50,7 @@ class StateMachineGen extends GenericStateMachineGenerator {
for (i=0; i<«ac.name.toUpperCase»_HISTORY_SIZE; ++i)
self->history[i] = NO_STATE;
}
- executeInitTransition(self);
+ «langExt.operationScope(ac.name, false)»executeInitTransition(self);
'''}
override genExtra(ExpandedActorClass xpac) {
@@ -60,6 +60,10 @@ class StateMachineGen extends GenericStateMachineGenerator {
«langExt.accessLevelPrivate»void setState(«ac.name»* self, int new_state) {
self->state = new_state;
}
+
+ «langExt.accessLevelPrivate»int getState(«ac.name»* self) {
+ return self->state;
+ }
'''
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
index 110a5cc24..f0d78acb6 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
@@ -27,6 +27,7 @@ import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.c.gen.CExtensions;
import org.eclipse.etrice.generator.c.gen.StateMachineGen;
import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
@@ -41,6 +42,9 @@ public class ActorClassGen extends GenericActorClassGenerator {
private JavaIoFileSystemAccess fileAccess;
@Inject
+ private ILanguageExtension langExt;
+
+ @Inject
private CExtensions _cExtensions;
@Inject
@@ -683,6 +687,9 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
+ String _name_6 = ac.getName();
+ String _operationScope = this.langExt.operationScope(_name_6, false);
+ _builder.append(_operationScope, " ");
_builder.append("receiveEvent(self");
{
if (handleEvents) {
@@ -710,17 +717,17 @@ public class ActorClassGen extends GenericActorClassGenerator {
}
if (_or_1) {
_builder.append("void ");
- String _name_6 = ac.getName();
- _builder.append(_name_6, "");
- _builder.append("_execute(");
String _name_7 = ac.getName();
_builder.append(_name_7, "");
+ _builder.append("_execute(");
+ String _name_8 = ac.getName();
+ _builder.append(_name_8, "");
_builder.append("* self) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- String _name_8 = ac.getName();
- _builder.append(_name_8, " ");
+ String _name_9 = ac.getName();
+ _builder.append(_name_9, " ");
_builder.append("\", \"_execute\")");
_builder.newLineIfNotEmpty();
{
@@ -731,6 +738,9 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
+ String _name_10 = ac.getName();
+ String _operationScope_1 = this.langExt.operationScope(_name_10, false);
+ _builder.append(_operationScope_1, " ");
_builder.append("receiveEvent(self");
{
if (handleEvents) {
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
index 0222f3312..892b86f47 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -151,6 +151,10 @@ public class CExtensions implements ILanguageExtension {
return false;
}
+ public boolean usesPointers() {
+ return true;
+ }
+
public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
String _xblockexpression = null;
{
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
index de6d18f93..aeb1f86f4 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
@@ -85,8 +85,11 @@ public class StateMachineGen extends GenericStateMachineGenerator {
_builder.newLine();
_builder.append("}");
_builder.newLine();
+ String _name_1 = ac.getName();
+ String _operationScope = this.langExt.operationScope(_name_1, false);
+ _builder.append(_operationScope, "");
_builder.append("executeInitTransition(self);");
- _builder.newLine();
+ _builder.newLineIfNotEmpty();
_xblockexpression = (_builder);
}
return _xblockexpression;
@@ -110,6 +113,19 @@ public class StateMachineGen extends GenericStateMachineGenerator {
_builder.newLine();
_builder.append("}");
_builder.newLine();
+ _builder.newLine();
+ String _accessLevelPrivate_1 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_1, "");
+ _builder.append("int getState(");
+ String _name_1 = ac.getName();
+ _builder.append(_name_1, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return self->state;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
_xblockexpression = (_builder);
}
return _xblockexpression;
diff --git a/plugins/org.eclipse.etrice.generator.cpp/.classpath b/plugins/org.eclipse.etrice.generator.cpp/.classpath
new file mode 100644
index 000000000..54357e36e
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="xtend-gen"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.etrice.generator.cpp/.gitignore b/plugins/org.eclipse.etrice.generator.cpp/.gitignore
new file mode 100644
index 000000000..ba3724425
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/.gitignore
@@ -0,0 +1,2 @@
+bin
+*._trace \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/.project b/plugins/org.eclipse.etrice.generator.cpp/.project
new file mode 100644
index 000000000..0732648ac
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.generator.cpp</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..f287d53cf
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..6ae65af02
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: C++ Generator
+Bundle-SymbolicName: org.eclipse.etrice.generator.cpp
+Require-Bundle: org.eclipse.etrice.core.room.ui;bundle-version="0.1.0",
+ org.eclipse.etrice.generator;bundle-version="0.1.0",
+ org.eclipse.etrice.core.config;bundle-version="0.2.0",
+ org.eclipse.etrice.generator.doc;bundle-version="0.1.0",
+ org.eclipse.etrice.core.genmodel,
+ org.eclipse.core.resources;bundle-version="3.6.0",
+ org.eclipse.core.runtime;bundle-version="3.6.0",
+ org.eclipse.ui;bundle-version="3.7.0",
+ org.eclipse.ui.ide;bundle-version="3.7.0",
+ org.eclipse.xtext;bundle-version="2.1.1",
+ org.eclipse.xtend.lib,
+ com.google.guava,
+ org.eclipse.xtext.xbase.lib,
+ org.eclipse.etrice.core.etmap,
+ org.eclipse.etrice.core.etphys,
+ org.eclipse.etrice.generator.config
+Bundle-Version: 0.2.0.qualifier
+Bundle-Vendor: eTrice (Incubation)
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.etrice.generator.cpp
+
diff --git a/plugins/org.eclipse.etrice.generator.cpp/build.properties b/plugins/org.eclipse.etrice.generator.cpp/build.properties
new file mode 100644
index 000000000..41eb6ade2
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/GeneratorOptions.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/GeneratorOptions.java
new file mode 100644
index 000000000..9bbfb89ca
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/GeneratorOptions.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.cpp;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class GeneratorOptions {
+
+ static private boolean useEtUnit = false;
+
+ public static boolean isUseEtUnit() {
+ return useEtUnit;
+ }
+
+ public static void setUseEtUnit(boolean useEtUnit) {
+ GeneratorOptions.useEtUnit = useEtUnit;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/Main.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/Main.java
new file mode 100644
index 000000000..377ef86b9
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/Main.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.cpp;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.etmap.eTMap.MappingModel;
+import org.eclipse.etrice.core.etmap.util.ETMapUtil;
+import org.eclipse.etrice.core.etphys.eTPhys.PhysicalModel;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
+import org.eclipse.etrice.generator.base.IResourceURIAcceptor;
+import org.eclipse.etrice.generator.cpp.gen.Validator;
+import org.eclipse.etrice.generator.cpp.setup.GeneratorModule;
+import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.scoping.impl.ImportUriResolver;
+
+import com.google.inject.Inject;
+
+public class Main extends AbstractGenerator {
+
+ public static final String OPTION_LIB = "-lib";
+ public static final String OPTION_NOEXIT = "-noexit";
+ public static final String OPTION_DOCUMENTATION = "-genDocu";
+ public static final String OPTION_SAVE_GEN_MODEL = "-saveGenModel";
+ public static final String OPTION_DEBUG = "-debug";
+ public static final String OPTION_ETUNIT = "-etunit";
+
+ /**
+ * print usage message to stderr
+ */
+ private static void printUsage() {
+ output.println(Main.class.getName()+" [-saveGenModel <genmodel path>] [-genInstDiag] [-lib] <list of model file paths>");
+ output.println(" <list of model file paths> # model file paths may be specified as");
+ output.println(" # e.g. C:\\path\\to\\model\\mymodel.room");
+ output.println(" -saveGenModel <genmodel path> # if specified the generator model will be saved to this location");
+ output.println(" -genDocu # if specified documentation is created");
+ output.println(" -lib # if specified all classes are generated and no instances");
+ output.println(" -noexit # if specified the JVM is not exited");
+ output.println(" -debug # if specified create debug output");
+ }
+
+ public static void main(String[] args) {
+ int ret = createAndRunGenerator(new GeneratorModule(), args);
+ if (isTerminateOnError() && ret!=GENERATOR_OK)
+ System.exit(ret);
+ }
+
+ @Inject
+ private IGenerator mainGenerator;
+
+ @Inject
+ protected org.eclipse.etrice.generator.doc.gen.MainGen mainDocGenerator;
+
+ @Inject
+ private Validator validator;
+
+ @Inject
+ protected IDataConfiguration dataConfig;
+
+ @Inject
+ protected ImportUriResolver uriResolver;
+
+ public int runGenerator(String[] args) {
+ if (args.length == 0) {
+ logger.logError(Main.class.getName()+" - aborting: no arguments!", null);
+ printUsage();
+ return GENERATOR_ERROR;
+ }
+
+ // parsing arguments
+ String genModelPath = null;
+ List<String> uriList = new ArrayList<String>();
+ boolean genDocumentation = false;
+ boolean asLibrary = false;
+ boolean debug = false;
+ for (int i=0; i<args.length; ++i) {
+ if (args[i].equals(OPTION_SAVE_GEN_MODEL)) {
+ if (++i<args.length) {
+ genModelPath = args[i]+"/genmodel.egm";
+ }
+ }
+ else if (args[i].equals(OPTION_DOCUMENTATION)) {
+ genDocumentation = true;
+ }
+ else if (args[i].equals(OPTION_LIB)) {
+ asLibrary = true;
+ }
+ else if (args[i].equals(OPTION_NOEXIT)) {
+ setTerminateOnError(false);
+ }
+ else if (args[i].equals(OPTION_DEBUG)) {
+ debug = true;
+ }
+ else if (args[i].equals(OPTION_ETUNIT)) {
+ GeneratorOptions.setUseEtUnit(true);
+ }
+ else {
+ uriList.add(args[i]);
+ }
+ }
+
+ setupRoomModel();
+ dataConfig.doSetup();
+
+ if (!runGenerator(uriList, genModelPath, genDocumentation, asLibrary, debug))
+ return GENERATOR_ERROR;
+
+ return GENERATOR_OK;
+ }
+
+ protected boolean runGenerator(List<String> uriList, String genModelPath, boolean genDocumentation, boolean asLibrary, boolean debug) {
+ loadModels(uriList);
+
+ if (!validateModels())
+ return false;
+
+ if(!dataConfig.setResources(getResourceSet(), logger))
+ return false;
+
+ Root genModel = createGeneratorModel(asLibrary, genModelPath);
+ if (genModel==null)
+ return false;
+
+ if (!validator.validate(genModel))
+ return false;
+
+ ETMapUtil.processModels(genModel, getResourceSet());
+ if (debug) {
+ logger.logInfo("-- begin dump of mappings");
+ logger.logInfo(ETMapUtil.dumpMappings());
+ logger.logInfo("-- end dump of mappings");
+ }
+
+ logger.logInfo("-- starting code generation");
+ fileAccess.setOutputPath("src-gen/");
+ mainGenerator.doGenerate(genModel.eResource(), fileAccess);
+
+ if (genDocumentation) {
+ mainDocGenerator.doGenerate(genModel);
+ }
+
+ if (diagnostician.isFailed()) {
+ logger.logInfo("validation failed during build of generator model");
+ logger.logError("-- terminating", null);
+ return false;
+ }
+ logger.logInfo("-- finished code generation");
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.generator.base.AbstractGenerator#addReferencedModels(org.eclipse.emf.ecore.resource.Resource, java.util.List)
+ */
+ @Override
+ protected void addReferencedModels(EObject root, IResourceURIAcceptor acceptor) {
+ super.addReferencedModels(root, acceptor);
+
+ if (root instanceof PhysicalModel) {
+ for (org.eclipse.etrice.core.etphys.eTPhys.Import imp : ((PhysicalModel)root).getImports()) {
+ String importURI = uriResolver.resolve(imp);
+ acceptor.addResourceURI(importURI);
+ }
+ }
+ else if (root instanceof MappingModel) {
+ for (org.eclipse.etrice.core.etmap.eTMap.Import imp : ((MappingModel)root).getImports()) {
+ String importURI = uriResolver.resolve(imp);
+ acceptor.addResourceURI(importURI);
+ }
+ }
+ else {
+ dataConfig.addReferencedModels(acceptor, root);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
new file mode 100644
index 000000000..f97c69698
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
@@ -0,0 +1,255 @@
+
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import java.util.ArrayList
+import org.eclipse.etrice.core.genmodel.base.ILogger
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.generator.base.AbstractGenerator
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.cpp.GeneratorOptions
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
+import org.eclipse.etrice.core.room.ActorCommunicationType
+
+@Singleton
+class ActorClassGen extends GenericActorClassGenerator {
+
+ @Inject JavaIoFileSystemAccess fileAccess
+ @Inject extension CppExtensions
+ @Inject extension RoomExtensions
+ @Inject extension Initialization
+ @Inject extension ProcedureHelpers
+ @Inject extension StateMachineGen
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (xpac: root.xpActorClasses) {
+ var path = xpac.actorClass.generationTargetPath+xpac.actorClass.getPath
+
+ logger.logInfo("generating ActorClass header '"+xpac.actorClass.getCppHeaderFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(xpac.actorClass.getCppHeaderFileName, root.generateHeaderFile(xpac, xpac.actorClass))
+
+ logger.logInfo("generating ActorClass source '"+xpac.actorClass.getCppSourceFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(xpac.actorClass.getCppSourceFileName, root.generateSourceFile(xpac, xpac.actorClass))
+ }
+ }
+
+ def private generateHeaderFile(Root root, ExpandedActorClass xpac, ActorClass ac) {
+ val ctor = ac.operations.filter(op|op.constructor).head
+ val dtor = ac.operations.filter(op|op.destructor).head
+
+ '''
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of ActorClass «ac.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(ac.name)»
+
+ #include "platforms/generic/etDatatypes.h"
+ #include "common/messaging/IRTObject.h"
+ #include "common/modelbase/PortBase.h"
+ #include "common/modelbase/InterfaceItemBase.h"
+ #include "common/modelbase/ActorClassBase.h"
+ #include "common/modelbase/SubSystemClassBase.h"
+ #include "common/messaging/Address.h"
+ #include "common/messaging/IMessageReceiver.h"
+ #include "common/debugging/DebuggingService.h"
+ «IF GeneratorOptions::useEtUnit»
+ extern "C" {
+ #include "etUnit.h"
+ }
+ «ENDIF»
+ #include <string>
+ #include <vector>
+
+ «FOR model : root.getReferencedModels(ac)»
+««« #include "«model.name».h"
+ «ENDFOR»
+
+ «FOR pc : root.getReferencedProtocolClasses(ac)»
+ #include "«pc.path»«pc.name».h"
+ «ENDFOR»
+ «FOR dc : root.getReferencedDataClasses(ac)»
+ #include "«dc.path»«dc.name».h"
+ «ENDFOR»
+
+
+ «ac.userCode(1)»
+
+
+ class «ac.name» : public «IF ac.base!=null»«ac.base.name»«ELSE»etRuntime::ActorClassBase«ENDIF» {
+
+
+ protected:
+ //--------------------- ports
+ «ac.endPorts.map(port | '''«port.portClassName» «port.name»;''').join("\n")»
+ //--------------------- saps
+ «ac.strSAPs.map(sap | '''«sap.portClassName» «sap.name»;''').join("\n")»
+ //--------------------- services
+ «ac.serviceImplementations.map(svc | '''«svc.portClassName» «svc.spp.name»;''').join("\n")»
+
+ //--------------------- interface item IDs
+ «genInterfaceItemConstants(xpac, ac)»
+
+ «ac.attributes.attributes»
+
+ «ac.operationsImplementation»
+
+ public:
+ //--------------------- construction
+ «ac.name»(etRuntime::IRTObject* parent, std::string name, const std::vector<std::vector<etRuntime::Address> >& port_addr,
+ const std::vector<std::vector<etRuntime::Address> >& peer_addr);
+
+««« TODO: check whether attribute setters/getters are necessary at all, if yes own cpp implementation is needed for *,[],& variables
+««« «attributeSettersGettersImplementation(ac.attributes, ac.name)»
+ //--------------------- port getters
+ «FOR ep : ac.getEndPorts()»
+ «ep.portClassName.getterImplementation(ep.name, ac.name)»
+ «ENDFOR»
+ «FOR sap : ac.strSAPs»
+ «sap.portClassName.getterImplementation(sap.name, ac.name)»
+ «ENDFOR»
+ «FOR svc : ac.serviceImplementations»
+ «svc.portClassName.getterImplementation(svc.spp.name, ac.name)»
+ «ENDFOR»
+
+ //--------------------- lifecycle functions
+ virtual void init();
+ virtual void start();
+ «IF !ac.overridesStop()»
+ virtual void stop();
+ «ENDIF»
+ virtual void destroy();
+ «IF ac.hasNonEmptyStateMachine»
+ «xpac.genStateMachineMethodDeclarations()»
+ «ELSEIF !xpac.hasStateMachine()»
+ public:
+ //--------------------- no state machine
+ virtual void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data);
+ virtual void executeInitTransition();
+ «ENDIF»
+
+ «ac.userCode(2)»
+
+ };
+
+
+ «generateIncludeGuardEnd(ac.name)»
+ '''
+ }
+ def private generateConstructorInitalizerList(ActorClass ac) {
+ var initializerList = new ArrayList<CharSequence>();
+ if (ac.base==null) {
+ initializerList.add('''ActorClassBase( parent, name, port_addr[0][0], peer_addr[0][0])''')
+ }
+ else {
+ initializerList.add('''«ac.base.name»(*this, parent, name, port_addr, peer_addr)''')
+ }
+ // own ports
+ for ( ep : ac.getEndPorts() ) {
+ initializerList.add('''«ep.name»(*this, this, "«ep.name»", IFITEM_«ep.name», «IF ep.multiplicity==1»0, «ENDIF»port_addr[IFITEM_«ep.name»]«IF ep.multiplicity==1»[0]«ENDIF», peer_addr[IFITEM_«ep.name»]«IF ep.multiplicity==1»[0]«ENDIF»)''');
+ }
+ // own saps
+ for ( sap : ac.strSAPs ) {
+ initializerList.add('''«sap.name»(*this, this, "«sap.name»", IFITEM_«sap.name», 0, port_addr[IFITEM_«sap.name»][0], peer_addr[IFITEM_«sap.name»][0])''');
+ }
+ // own service implementations
+ for (svc : ac.serviceImplementations) {
+ initializerList.add('''«svc.spp.name»(*this, this, "«svc.spp.name»", IFITEM_«svc.spp.name», port_addr[IFITEM_«svc.spp.name»], peer_addr[IFITEM_«svc.spp.name»])''');
+ }
+ for (attrib: ac.attributes) {
+ initializerList.add(attrib.attributeInitialization(false))
+ }
+ return
+ '''
+ «initializerList.join(',\n')»
+ '''
+ }
+
+
+ def private generateSourceFile(Root root, ExpandedActorClass xpac, ActorClass ac) {
+ val ctor = ac.operations.filter(op|op.constructor).head
+ val dtor = ac.operations.filter(op|op.destructor).head
+ val async = xpac.actorClass.commType==ActorCommunicationType::ASYNCHRONOUS
+
+ '''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of ActorClass «ac.name»
+ *
+ */
+
+ #include "«ac.getCppHeaderFileName»"
+ #include "common/debugging/DebuggingService.h"
+ #include <iostream>
+
+ using namespace etRuntime;
+
+
+ «ac.name»::«ac.name»(etRuntime::IRTObject* parent, std::string name, const std::vector<std::vector<etRuntime::Address> >& port_addr,
+ const std::vector<std::vector<etRuntime::Address> >& peer_addr)
+ : «ac.generateConstructorInitalizerList»
+ {
+ setClassName("«ac.name»");
+ «ac.attributes.attributeInitialization(false)»
+
+ «IF async»
+ getMsgsvc()->addAsyncActor(*this);
+ «ENDIF»
+ «IF ctor!=null»
+ // user defined constructor body
+ «AbstractGenerator::getInstance().getTranslatedCode(ctor.detailCode)»
+ «ENDIF»
+ }
+
+ void «ac.name»::init(){
+ initUser();
+ }
+
+ void «ac.name»::start(){
+ startUser();
+ }
+
+ «IF !ac.overridesStop()»
+ void «ac.name»::stop(){
+ stopUser();
+ }
+ «ENDIF»
+
+ void «ac.name»::destroy(){
+ «IF dtor!=null»
+
+ // user defined destructor body
+ «AbstractGenerator::getInstance().getTranslatedCode(dtor.detailCode)»
+ «ENDIF»
+ }
+
+ «IF ac.hasNonEmptyStateMachine»
+ «xpac.genStateMachine(false)»
+ «ELSEIF !xpac.hasStateMachine()»
+ //--------------------- no state machine
+ void «ac.name»::receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data) {
+ handleSystemEvent(ifitem, evt, data);
+ }
+
+ void «ac.name»::executeInitTransition(){
+ }
+ «ENDIF»
+ '''
+ }
+
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.xtend
new file mode 100644
index 000000000..adcb47143
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.xtend
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Juergen Haug
+ * 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:
+ * Juergen Haug
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import java.util.ArrayList
+import java.util.List
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.core.room.Attribute
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.core.room.GeneralProtocolClass
+import org.eclipse.etrice.core.room.InterfaceItem
+import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.core.room.ExternalType
+
+class ConfigGenAddon {
+
+ @Inject extension CppExtensions stdExt
+ @Inject extension TypeHelpers typeHelpers
+ @Inject extension ProcedureHelpers helpers
+ @Inject IDataConfiguration dataConfigExt
+ @Inject extension RoomExtensions
+
+ // For SubSystemClassGen
+
+ def public genActorInstanceConfig(ActorInstance ai, String aiVariableName){'''
+ «FOR a : ai.actorClass.attributes»
+ «applyInstanceConfig(ai, null, aiVariableName, new ArrayList<Attribute>().union(a))»
+ «ENDFOR»
+ «FOR p : ai.actorClass.allEndPorts»
+ «FOR a : getAttributes(p.protocol, !p.conjugated)»
+ «applyInstanceConfig(ai, p, aiVariableName+"."+invokeGetter(p.name, null), new ArrayList<Attribute>().union(a))»
+ «ENDFOR»
+ «ENDFOR»
+ «FOR sap : ai.actorClass.allSAPs»
+ «FOR a : getAttributes(sap.protocol, true)»
+ «applyInstanceConfig(ai, sap, aiVariableName+"."+invokeGetter(sap.name, null), new ArrayList<Attribute>().union(a))»
+ «ENDFOR»
+ «ENDFOR»
+ '''
+ }
+
+ def private List<Attribute> getAttributes(GeneralProtocolClass gpc, boolean regular){
+ var result = new ArrayList<Attribute>
+ if(gpc instanceof ProtocolClass){
+ var protocol = gpc as ProtocolClass
+ if(regular && protocol.regular?.attributes != null)
+ result.addAll(protocol.regular.attributes)
+ else if(!regular && protocol.conjugate?.attributes != null)
+ result.addAll(protocol.conjugate.attributes)
+ }
+ return result
+ }
+
+ def private applyInstanceConfig(ActorInstance ai, InterfaceItem port, String invokes, List<Attribute> path){
+ var a = path.last
+ var aType = a.refType.type
+ if(aType.primitive){
+ var value = if(port==null)dataConfigExt.getAttrInstanceConfigValue(ai, path)
+ else dataConfigExt.getAttrInstanceConfigValue(ai, port, path)
+ if(value == null)
+ ''''''
+ else if(a.size == 0 || aType.characterType)
+ '''«invokes».«a.name.invokeSetter(null, (aType as PrimitiveType).toValueLiteral(value))»;'''
+ else if(a.size == value.split(",").size){
+ var arrayExpr = '''{ «FOR s : value.split(",") SEPARATOR ', '»«(aType as PrimitiveType).toValueLiteral(s.trim)»«ENDFOR» }'''
+ '''«invokes».«a.name.invokeSetter(null, '''new «aType.typeName»[] «arrayExpr»'''.toString)»;'''
+ } else '''
+ {
+ «aType.typeName»[] array = «invokes».«a.name.invokeGetter(null)»;
+ for (int i=0;i<«a.size»;i++){
+ array[i] = «(aType as PrimitiveType).toValueLiteral(value)»;
+ }'''
+ }
+ else if (aType.dataClass)'''
+ «FOR e : (aType as DataClass).attributes»
+ «applyInstanceConfig(ai, port, invokes+"."+a.name.invokeGetter(null), path.union(e))»
+ «ENDFOR»
+ '''
+ }
+
+ // For ActorClassGen
+
+ def public genDynConfigGetterSetter(ActorClass ac){'''
+ «FOR a : dataConfigExt.getDynConfigReadAttributes(ac)»
+ public «a.refType.type.typeName»«IF a.size>0»[]«ENDIF» get«a.name.toFirstUpper»(){
+ if(lock_«a.name» == null)
+ return «a.name»;
+ else
+ synchronized(lock_«a.name»){
+ return «a.name»;
+ }
+ }
+ public void set«a.name.toFirstUpper»(«a.refType.type.typeName»«IF a.size>0»[]«ENDIF» «a.name»){
+ if(lock_«a.name» == null)
+ this.«a.name» = «a.name»;
+ else
+ synchronized(lock_«a.name»){
+ this.«a.name» = «a.name»;
+ }
+ }
+ public DynConfigLock get«a.name.toFirstUpper»Lock(){
+ return lock_«a.name»;
+ }
+ «ENDFOR»
+ «FOR a : dataConfigExt.getDynConfigWriteAttributes(ac)»
+ public void setAndWrite«a.name.toFirstUpper»(«a.refType.type.typeName»«IF a.size>0»[]«ENDIF» «a.name»){
+ set«a.name.toFirstUpper»(«a.name»);
+ variableService.write(this.getInstancePath()+"/«a.name»", «a.name»);
+ }
+ «ENDFOR»
+ '''}
+
+ def public genMinMaxConstants(ActorClass ac){
+ var result = '''
+ «FOR a : ac.attributes»
+ «genMinMaxConstantsRec(ac, a.name, new ArrayList<Attribute>().union(a))»
+ «ENDFOR»
+ '''
+ if(result.length != 0)
+ result = result+'''//--------------------- Attribute Specifications'''
+ return result
+ }
+
+ def private genMinMaxConstantsRec(ActorClass ac, String varNamePath, List<Attribute> path){
+ var temp = null as String
+ if (path.last.refType.type.dataClass)
+ '''
+ «FOR e : (path.last.refType.type as DataClass).allAttributes»
+ «genMinMaxConstantsRec(ac, varNamePath+"_"+e.name, path.union(e))»
+ «ENDFOR»
+ '''
+ else if (path.last.refType.type instanceof ExternalType) {
+ // do nothing
+ }
+ else
+ {
+ var aType = (path.last.refType.type as PrimitiveType)
+ '''
+ «IF (temp = dataConfigExt.getAttrClassConfigMinValue(ac, path)) != null»
+ public static «aType.minMaxType» MIN_«varNamePath» = «aType.toValueLiteral(temp)»;
+ «ENDIF»
+ «IF (temp = dataConfigExt.getAttrClassConfigMaxValue(ac, path)) != null»
+ public static «aType.minMaxType» MAX_«varNamePath» = «aType.toValueLiteral(temp)»;
+ «ENDIF»
+ '''
+ }
+ }
+
+ def private getMinMaxType(PrimitiveType type){
+ return switch(type.typeName){
+ case "byte":
+ "int"
+ case "short":
+ "int"
+ case "float":
+ "double"
+ default:
+ type.typeName
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
new file mode 100644
index 000000000..11b69b548
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+/*
+ collection of convenience functions for code generation
+*/
+
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import java.util.List
+import org.eclipse.etrice.core.genmodel.etricegen.IDiagnostician
+import org.eclipse.etrice.core.room.DataType
+import org.eclipse.etrice.core.room.ExternalType
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.core.room.RoomClass
+import org.eclipse.etrice.core.room.VarDecl
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.generator.generic.ILanguageExtension
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.xtext.util.Pair
+
+@Singleton
+class CppExtensions implements ILanguageExtension {
+
+ @Inject IDiagnostician diagnostician
+ @Inject extension TypeHelpers
+
+
+ override String getTypedDataDefinition(Message m) {
+ generateArglistAndTypedData(m.data).get(1)
+ }
+
+
+ def String getCppHeaderFileName(RoomClass rc) {rc.name+".h"}
+ def String getCppSourceFileName(RoomClass rc) {rc.name+".cpp"}
+ def String getInstSourceFileName(RoomClass rc) {rc.name+"_Inst.h"}
+ def String getDispSourceFileName(RoomClass rc) {rc.name+"_Disp.h"}
+
+ override String accessLevelPrivate() {""}
+ override String accessLevelProtected() {""}
+ override String accessLevelPublic() {""}
+
+ override String memberAccess() {"this->"}
+ override String selfPointer(String classname, boolean hasArgs) {""}
+ override String selfPointer(boolean hasArgs) { "" }
+
+ override String operationScope(String classname, boolean isDeclaration) {
+ if (isDeclaration)
+ ""
+ else
+ classname+"::"
+ }
+
+
+ override String memberInDeclaration(String namespace, String member) {
+ return member
+ }
+
+ override String memberInUse(String namespace, String member) {
+ return namespace+"."+member
+ }
+
+ override boolean usesInheritance() {
+ return true
+ }
+
+ override boolean usesPointers() {
+ return true
+ }
+
+ override String genEnumeration(String name, List<Pair<String, String>> entries) {
+ '''
+ typedef enum {
+ «FOR entry: entries»
+ «entry.first» = «entry.second»,
+ «ENDFOR»
+ } «name»;'''.toString
+ }
+
+ override String booleanConstant(boolean b) {
+ b.toString
+ }
+
+ override String pointerLiteral() { "*" }
+ override String nullPointer() { "0" }
+ override String voidPointer() { "void*" }
+
+ override String arrayDeclaration(String type, int size, String name, boolean isRef) {
+ type+" "+name+"["+size+"]";
+ }
+
+ override String constructorName(String cls) {
+ cls
+ }
+ override String destructorName(String cls) {
+ cls+"_dtor"
+ }
+ override String constructorReturnType() {
+ ""
+ }
+ override String destructorReturnType() {
+ "void"
+ }
+
+ def getIncludeGuardString(String filename){
+ '''_«filename.replaceAll("\\/.", "_").toUpperCase»_H_'''
+ }
+
+ def generateIncludeGuardBegin(String filename){'''
+ #ifndef «filename.getIncludeGuardString»
+ #define «filename.getIncludeGuardString»
+ '''
+ }
+
+ def generateIncludeGuardEnd(String filename){'''
+ #endif /* «filename.getIncludeGuardString» */
+ '''
+ }
+
+
+
+ override superCall(String baseClassName, String method, String arguments) {
+ baseClassName+"::"+method+"("+arguments+");"
+ }
+
+
+ override String toValueLiteral(PrimitiveType type, String value){
+ throw new UnsupportedOperationException("TODO Config for Cpp");
+ }
+
+ override String defaultValue(DataType dt) {
+ if (dt instanceof PrimitiveType) {
+ return (dt as PrimitiveType).getDefaultValueLiteral
+ }
+ else if (dt instanceof ExternalType) {
+ diagnostician.warning("initialize external type with default constructor"+dt.name, dt.eContainer, dt.eContainingFeature)
+ return dt.typeName + "()"
+ }
+ else {
+ val dc = dt as DataClass
+
+ '''
+ {
+ «FOR att : dc.attributes SEPARATOR ","»
+ «att.refType.type.initializationWithDefaultValues(att.size)»
+ «ENDFOR»
+ }
+ '''
+ }
+ }
+
+ override initializationWithDefaultValues(DataType dt, int size) {
+ val dv = dt.defaultValue
+ if (size>1) {
+ var res = "{"
+ var i = 0
+ while (i<size) {
+ res = res + dv
+ i = i+1
+ if (i<size)
+ res = res + ","
+ }
+ res+"}"
+ }
+ else
+ dv
+ }
+
+ override generateArglistAndTypedData(VarDecl data) {
+ var deref = "*"
+ if (data==null)
+ return newArrayList("", "", "")
+
+ var typeName = if (data.getRefType().getType() instanceof PrimitiveType)
+ (data.getRefType().getType() as PrimitiveType).getTargetName()
+ else
+ data.getRefType().getType().getName()
+
+ var castTypeName = if (data.getRefType().getType() instanceof PrimitiveType) {
+ val ct = (data.getRefType().getType() as PrimitiveType).getCastName()
+ if (ct!=null && !ct.isEmpty())
+ ct
+ else
+ typeName
+ }
+ else
+ typeName
+ castTypeName = castTypeName+"*"
+
+ if (data.getRefType().isRef()) {
+ typeName = typeName+"*"
+ castTypeName = castTypeName+"*"
+ }
+ else if (!(data.getRefType().getType() instanceof PrimitiveType)) {
+ typeName = typeName+"*"
+ castTypeName = castTypeName+"*"
+ }
+ else {
+ castTypeName = typeName
+ deref = ""
+ }
+
+ val typedData = typeName+" "+data.getName() + " = " + deref + "(("+castTypeName+") generic_data);\n"
+
+ val dataArg = ", "+data.getName()
+ val typedArgList = ", "+typeName+" "+data.getName()
+
+ return newArrayList(dataArg, typedData, typedArgList);
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.java
new file mode 100644
index 000000000..79d54f867
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.cpp.gen;
+
+import java.util.ArrayList;
+
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.generator.base.DefaultTranslationProvider;
+
+/**
+ * @author hrentz
+ *
+ */
+public class CppTranslationProvider extends DefaultTranslationProvider {
+
+ @Override
+ public boolean translateMembers() {
+ return true;
+ }
+
+ @Override
+ public boolean translateTags() {
+ return true;
+ }
+
+ @Override
+ public String getInterfaceItemMessageText(InterfaceItem item, Message msg, ArrayList<String> args, String index, String orig) {
+ if (index==null)
+ return orig;
+
+ StringBuilder argtext = new StringBuilder();
+ for (String arg : args) {
+ argtext.append(", "+arg);
+ }
+
+ // TODO: overload operator[] ???
+ return item.getName()+".get("+index+")."+msg.getName()+"("+argtext.toString()+")";
+ }
+
+ @Override
+ public String translateTag(String tag, DetailCode code) {
+ if (tag.equals("ifitem.index"))
+ return "ifitem.getIdx()";
+
+ return super.translateTag(tag, code);
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
new file mode 100644
index 000000000..ed88dc3be
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
@@ -0,0 +1,268 @@
+
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import java.util.List
+import org.eclipse.etrice.core.genmodel.base.ILogger
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.room.Attribute
+import org.eclipse.etrice.core.room.ComplexType
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.cpp.gen.Initialization
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.cpp.GeneratorOptions
+
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
+
+
+@Singleton
+class DataClassGen {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension CppExtensions stdExt
+ @Inject extension RoomExtensions roomExt
+ @Inject extension ProcedureHelpers helpers
+ @Inject extension TypeHelpers typeHelpers
+ @Inject extension Initialization
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ logger.logInfo("generating code")
+ for (dc: root.usedDataClasses) {
+ var path = dc.generationTargetPath + dc.getPath
+
+ // header file
+ logger.logInfo("generating DataClass header '"+dc.getCppHeaderFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(dc.getCppHeaderFileName, root.generateHeaderFile(dc))
+
+ // source file
+ logger.logInfo("generating DataClass source '"+dc.getCppSourceFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(dc.getCppSourceFileName, root.generateSourceFile(dc))
+
+ }
+
+ }
+
+ def generateHeaderFile(Root root, DataClass dc) {
+ val ctor = dc.operations.filter(op|op.constructor).head
+ val dtor = dc.operations.filter(op|op.destructor).head
+ //TODO: getReferencedDataClasses does not contain a base class of the own package
+ '''
+ «generateIncludeGuardBegin(dc.path + dc.name)»
+
+ «IF dc.base!=null»
+ #include "«dc.base.path»«dc.base.name».h"
+ «ENDIF»
+ «FOR classes : root.getReferencedDataClasses(dc)»
+ #include "«classes.path»«classes.name».h"
+ «ENDFOR»
+ «var models = root.getReferencedModels(dc)»
+ «FOR model : models»
+ «FOR classes : model.dataClasses»
+ #include "«classes.path»«classes.name».h"
+ «ENDFOR»
+ «ENDFOR»
+
+ «helpers.userCode(dc.userCode1)»
+
+
+ class «dc.name»«IF dc.base!=null» : public «dc.base.name»«ENDIF» {
+
+ public:
+ «helpers.userCode(dc.userCode2)»
+
+ «helpers.attributes(dc.attributes)»
+
+ «helpers.attributeSettersGettersImplementation(dc.attributes, dc.name)»
+
+ «helpers.operationsDeclaration(dc.operations, dc.name)»
+
+ // default constructor, copy constructor and assignment operator
+ «dc.name»();
+ «dc.name»(const «dc.name»& rhs);
+ «dc.name»& operator=(const «dc.name»& rhs);
+
+ // constructor using fields
+ «dc.name»(«dc.argList»);
+
+ «IF dc.base!=null»
+ // constructor using base class constructor
+ «dc.name»(«dc.base.name» _super, «dc.attributes.argListConstructor.toString»);
+ «ENDIF»
+
+ };
+
+ «generateIncludeGuardEnd(dc.name)»
+
+ '''
+ }
+
+ def generateSourceFile(Root root, DataClass dc) {
+ val ctor = dc.operations.filter(op|op.constructor).head
+ val dtor = dc.operations.filter(op|op.destructor).head
+
+ '''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of DataClass «dc.name»
+ */
+
+ #include "«dc.getCppHeaderFileName»"
+ «IF GeneratorOptions::useEtUnit»
+ extern "C" {
+ #include "etUnit.h"
+ }
+ «ENDIF»
+
+ «helpers.userCode(dc.userCode3)»
+
+
+ // default constructor
+ «dc.name»::«dc.name»()
+ «IF dc.base!=null»
+ :«dc.base.name»()
+ «ENDIF»
+ {
+ «dc.attributes.attributeInitialization(false)»
+ «IF ctor!=null»
+ {
+ // user defined constructor body
+ «FOR l : ctor.detailCode.commands»
+ «l»
+ «ENDFOR»
+ }
+ «ENDIF»
+ }
+
+ // copy constructor
+ «dc.name»::«dc.name»(const «dc.name»& rhs)
+ :
+ «IF dc.base!=null»
+ «dc.base.name»(rhs),
+ «ENDIF»
+ «FOR a : dc.attributes SEPARATOR ","»
+ «a.name»(rhs.«a.name»)
+ «ENDFOR»
+ {
+ }
+
+ // constructor using fields
+ «dc.name»::«dc.name»(«dc.argList»)
+ :
+ «IF dc.base!=null»
+ «dc.base.name»(«dc.base.paramList»),
+ «ENDIF»
+ «FOR a : dc.attributes SEPARATOR ","»
+ «a.name»(«a.name»_)
+ «ENDFOR»
+ {
+ }
+
+ «IF dc.base!=null»
+ // constructor using base class constructor
+ «dc.name»::«dc.name»(«dc.base.name» _super, «dc.attributes.argListConstructor.toString»)
+ :
+ «dc.base.name»(_super),
+ «FOR a : dc.attributes SEPARATOR ","»
+ «a.name»(«a.name»_)
+ «ENDFOR»
+ {
+ }
+ «ENDIF»
+
+ // assignment operator
+ «dc.name»& «dc.name»::operator=(const «dc.name»& rhs)
+ {
+ if (this == &rhs) { return *this; };
+ «IF dc.base!=null»
+ «dc.base.name»::operator=(rhs);
+ «ENDIF»
+ «FOR a : dc.attributes»
+ «a.name»= rhs.«a.name»;
+ «ENDFOR»
+ return *this;
+ }
+
+ «helpers.operationsImplementation(dc.operations, dc.name)»
+
+ '''}
+
+ def paramList(DataClass _dc) {
+ var result = ""
+ var dc = _dc
+ while (dc!=null) {
+ result = dc.attributes.paramList.toString + result
+ dc = dc.base
+ if (dc!=null)
+ result = ", "+result
+ }
+ return result
+ }
+
+ def paramList(List<Attribute> attributes) {
+ '''«FOR a: attributes SEPARATOR ", "»«a.name»_«ENDFOR»'''
+ }
+
+ def argList(DataClass _dc) {
+ var result = ""
+ var dc = _dc
+ while (dc!=null) {
+ result = dc.attributes.argListConstructor.toString + result
+ dc = dc.base
+ if (dc!=null)
+ result = ", "+result
+ }
+ return result
+ }
+
+ def argListConstructor(List<Attribute> attributes) {
+ '''«FOR a : attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»_«ENDFOR»'''
+ }
+
+
+
+ def deepCopy(DataClass _dc) {
+ var result = ""
+ var dc = _dc
+ while (dc!=null) {
+ result = deepCopy(dc.attributes).toString + result
+ dc = dc.base
+ }
+ return result
+ }
+
+ def deepCopy(List<Attribute> attributes) {
+ '''
+ «FOR a : attributes»
+ «IF a.refType.type instanceof ComplexType»
+ if («a.name»!=null) {
+ «IF a.size==0»
+ copy.«a.name» = «a.name».deepCopy();
+ «ELSE»
+ for (int i=0;i<«a.name».length;i++){
+ copy.«a.name»[i] = «a.name»[i].deepCopy();
+ }
+ «ENDIF»
+ }
+ «ELSE»
+ «IF a.size==0»
+ copy.«a.name» = «a.name»;
+ «ELSE»
+ for (int i=0;i<«a.name».length;i++){
+ copy.«a.name»[i] = «a.name»[i];
+ }
+ «ENDIF»
+ «ENDIF»
+ «ENDFOR»
+ '''
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Initialization.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Initialization.xtend
new file mode 100644
index 000000000..96199a1e4
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Initialization.xtend
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import java.util.List
+import org.eclipse.etrice.core.room.Attribute
+import org.eclipse.etrice.core.room.ComplexType
+import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.generator.generic.ILanguageExtension
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.TypeHelpers
+
+@Singleton
+class Initialization {
+
+ @Inject extension TypeHelpers
+ @Inject extension RoomExtensions
+ @Inject ILanguageExtension languageExt
+ @Inject IDataConfiguration dataConfigExt
+ @Inject ProcedureHelpers procedureHelpers
+
+ def attributeInitialization(List<Attribute> attribs, boolean useClassDefaultsOnly) {
+ '''
+ // initialize attributes
+ «FOR a : attribs»
+ «var aType = a.refType.type»
+ «var value = a.defaultValueLiteral»
+ «IF value!=null»
+ «IF a.size == 0 || aType.characterType»
+ «ELSEIF value.startsWith("{")»
+ «initializeArrayWithValues(a.name, value.replace("{", "").replace("}", "").split(","))»
+ «ELSE»
+ for (int i=0;i<«a.size»;i++){
+ «a.name»[i] = «value»;
+ }
+ «ENDIF»
+ «ELSEIF aType instanceof ComplexType || a.size>1 || !useClassDefaultsOnly»
+ «IF a.size==0»
+ «ELSE»
+ «IF !useClassDefaultsOnly»
+ for (int i=0;i<«a.size»;i++){
+ «a.name»[i] = «IF a.refType.isRef»«languageExt.nullPointer()»«ELSE»«languageExt.defaultValue(aType)»«ENDIF»;
+ }
+ «ENDIF»
+ «ENDIF»
+ «ENDIF»
+ «ENDFOR»
+ '''
+ }
+
+ def initializeArrayWithValues(String varName, String[] values) {
+ '''
+ «values.map(v | varName + "[" + values.indexOf(v) + "] = " + v + ";" ).join("\r\n")»
+ '''
+ }
+
+ def attributeInitialization(Attribute a, boolean useClassDefaultsOnly) {
+ var aType = a.refType.type
+ var value = a.defaultValueLiteral
+ if (value != null) {
+ if (a.size == 0 || aType.characterType) {
+ if (a.refType.isRef)
+ '''«a.name»(new «aType.name»(«value»))'''
+ else
+ '''«a.name»(«value»)'''
+ }
+ else if (value.startsWith("{")) {
+ '''«a.name»()'''
+ }
+ else {
+ '''«a.name»()'''
+ }
+ }
+ else if (aType instanceof ComplexType || a.size>1 || !useClassDefaultsOnly) {
+ if (a.size==0) {
+ if (a.refType.isRef)
+ '''«a.name»(«languageExt.nullPointer()»)'''
+ else
+ '''«a.name»(«languageExt.defaultValue(aType)»)'''
+ }
+ else
+ '''«a.name»()'''
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
new file mode 100644
index 000000000..87658c1e4
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.generator.generic.PrepareFileSystem
+import org.eclipse.xtext.generator.IFileSystemAccess
+import org.eclipse.xtext.generator.IGenerator
+
+@Singleton
+class MainGen implements IGenerator {
+
+ @Inject DataClassGen dataClassGen
+ @Inject ProtocolClassGen protocolClassGen
+ @Inject ActorClassGen actorClassGen
+ @Inject SubSystemClassGen subsystemClassGen
+ @Inject SubSystemRunnerGen subsystemRunnerGen
+ @Inject PrepareFileSystem prepFS
+
+ override void doGenerate(Resource resource, IFileSystemAccess fsa) {
+ prepFS.prepare(resource)
+ for (e: resource.contents){
+ if (e instanceof Root) {
+ doGenerate(e as Root)
+ }
+ }
+ }
+
+ def void doGenerate(Root e) {
+ dataClassGen.doGenerate(e);
+ protocolClassGen.doGenerate(e);
+ actorClassGen.doGenerate(e);
+ subsystemClassGen.doGenerate(e);
+
+ if (!e.library) {
+ subsystemRunnerGen.doGenerate(e);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
new file mode 100644
index 000000000..e32101d4f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -0,0 +1,430 @@
+
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import java.util.ArrayList
+import org.eclipse.etrice.core.genmodel.base.ILogger
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.room.CommunicationType
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.core.room.InterfaceItem
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.Port
+import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.core.room.SAPRef
+import org.eclipse.etrice.core.room.SPPRef
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.core.room.PortClass
+import org.eclipse.etrice.generator.cpp.GeneratorOptions
+
+
+@Singleton
+class ProtocolClassGen extends GenericProtocolClassGenerator {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension CppExtensions stdExt
+ @Inject extension RoomExtensions roomExt
+ @Inject extension ProcedureHelpers helpers
+ @Inject extension TypeHelpers
+ @Inject extension Initialization
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (pc: root.usedProtocolClasses) {
+ var path = pc.generationTargetPath+pc.getPath
+
+ logger.logInfo("generating ProtocolClass header '"+pc.getCppHeaderFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(pc.getCppHeaderFileName, root.generateHeaderFile(pc))
+
+ logger.logInfo("generating ProtocolClass source '"+pc.getCppSourceFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(pc.getCppSourceFileName, root.generateSourceFile(pc))
+ }
+ }
+
+
+ def private generateHeaderFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of ProtocolClass «pc.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(pc.name)»
+
+ #include "platforms/generic/etDatatypes.h"
+ #include "common/messaging/IRTObject.h"
+ #include "common/modelbase/PortBase.h"
+ #include "common/modelbase/InterfaceItemBase.h"
+ #include "common/messaging/Address.h"
+ #include "common/messaging/Message.h"
+ #include <vector>
+ #include <string>
+
+ namespace etRuntime {
+ class IEventReceiver;
+
+ }
+
+ «helpers.userCode(pc.userCode1)»
+
+ «FOR dataClass : root.getReferencedDataClasses(pc)»
+ #include "«dataClass.path»«dataClass.name».h"
+ «ENDFOR»
+
+ class «pc.name» {
+ public:
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN» /* message IDs */
+ «genMessageIDs(pc)»
+ static bool isValidEvtID(int evtId) {
+ return ((MSG_MIN < evtId) && (evtId < MSG_MAX));
+ };
+ static bool isValidOutgoingEvtID(int evtId) {
+ return ((MSG_MIN < evtId) && (evtId < «IF pc.incomingMessages.size == 0»MSG_MAX«ELSE»IN_«pc.incomingMessages.get(0).name»«ENDIF»));
+ };
+ static bool isValidIncomingEvtID(int evtId) {
+ return ((«IF pc.incomingMessages.size == 0»MSG_MAX«ELSE»IN_«pc.incomingMessages.get(0).name»«ENDIF» <= evtId) && (evtId < MSG_MAX));
+ };
+ static std::string getMessageString(int msg_id);
+
+ private:
+ static std::string s_messageStrings[];
+ «ENDIF»
+ «helpers.userCode(pc.userCode2)»
+ };
+
+ «portClassDeclaration(pc, false)»
+ «portClassDeclaration(pc, true)»
+ «generateIncludeGuardEnd(pc.name)»
+ '''
+ }
+
+ def portClassDeclaration(ProtocolClass pc, Boolean conj) {
+ var pclass = pc.getPortClass(conj)
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ '''
+ //------------------------------------------------------------------------------------------------------------
+ // «IF conj»conjugated «ENDIF»port class
+ //------------------------------------------------------------------------------------------------------------
+ class «portClassName» : public etRuntime::PortBase {
+ «IF pclass!=null»
+ «helpers.userCode(pclass.userCode)»
+ «ENDIF»
+ public:
+ // constructors
+ «portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true);
+ «portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true);
+
+ virtual void receive(etRuntime::Message* m);
+ «IF pclass!=null»
+ «helpers.attributes(pclass.attributes)»
+ «helpers.operationsDeclaration(pclass.operations, portClassName)»
+ «ENDIF»
+
+ // outgoing messages
+ «FOR m : pc.getOutgoing(conj)»
+ «sendMessageDeclaration(m,conj)»
+ «ENDFOR»
+ };
+
+ //------------------------------------------------------------------------------------------------------------
+ // «IF conj»conjugated «ENDIF»replicated port class
+ //------------------------------------------------------------------------------------------------------------
+ class «replPortClassName» {
+ private:
+ int m_replication;
+ «portClassName»* m_ports; //dynamic array used instead of vector to avoid copy construction
+
+ public:
+ «replPortClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<etRuntime::Address> addr, std::vector<etRuntime::Address> peerAddress);
+ virtual ~«replPortClassName»() {};
+
+ int getReplication() { return m_replication; }
+ int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx(); }
+ «portClassName» get(int i) {return m_ports[i];}
+
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN»
+ // outgoing messages
+ «FOR m : pc.getOutgoing(conj)»
+ «sendMessageDeclaration(m,conj)»
+ «ENDFOR»
+ «ENDIF»
+
+ };
+ '''
+ }
+
+ def private generateSourceFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass «pc.name»
+ *
+ */
+
+ #include "«pc.getCppHeaderFileName»"
+ #include "common/debugging/DebuggingService.h"
+ #include <iostream>
+ «IF GeneratorOptions::useEtUnit»
+ extern "C" {
+ #include "etUnit.h"
+ }
+ «ENDIF»
+
+ using namespace etRuntime;
+
+ «helpers.userCode(pc.userCode3)»
+
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN»
+ «helpers.userCode(pc.userCode2)»
+
+ «portClassImplementation(pc, false)»
+ «portClassImplementation(pc, true)»
+
+ /*--------------------- debug helpers */
+ «generateDebugHelpersImplementation(root, pc)»
+ «ENDIF»
+
+
+ '''
+ }
+
+
+ def portClassImplementation(ProtocolClass pc, Boolean conj) {
+ var pclass = pc.getPortClass(conj)
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ '''
+ //------------------------------------------------------------------------------------------------------------
+ // «IF conj»conjugated «ENDIF»port class
+ //------------------------------------------------------------------------------------------------------------
+
+ «portClassName»::«portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, Address addr, Address peerAddress, bool doRegistration)
+ : «pclass.generateConstructorInitalizerList("0")»
+ {
+ «IF pclass!=null»«pclass.attributes.attributeInitialization(false)»«ENDIF»
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+ }
+
+ «portClassName»::«portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, Address addr, Address peerAddress, bool doRegistration)
+ : «pclass.generateConstructorInitalizerList("idx")»
+ {
+ «IF pclass!=null»«pclass.attributes.attributeInitialization(false)»«ENDIF»
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+ }
+
+ void «portClassName»::receive(Message* msg) {
+ if (! «pc.name»::«IF conj»isValidOutgoingEvtID«ELSE»isValidIncomingEvtID«ENDIF»(msg->getEvtId())) {
+ std::cout << "unknown" << std::endl;
+ }
+ else {
+ if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), «pc.name»::getMessageString(msg->getEvtId()));
+ }
+
+ «IF pc.handlesReceive(conj)»
+ switch (msg->getEvtId()) {
+ «FOR hdlr : pc.getReceiveHandlers(conj)»
+ case «pc.name»::«hdlr.msg.getCodeName()»:
+ {
+ «FOR command : hdlr.detailCode.commands»
+ «command»
+ «ENDFOR»
+ }
+ break;
+ «ENDFOR»
+ default:
+ «ENDIF»
+ getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ «IF pc.handlesReceive(conj)»
+ break;
+ }
+ «ENDIF»
+ }
+ };
+
+ «IF pclass!=null»
+ «helpers.operationsImplementation(pclass.operations, portClassName)»
+ «ENDIF»
+
+ // sent messages
+ «FOR m : pc.getOutgoing(conj)»
+ «sendMessage(m, pc.name, portClassName, conj)»
+ «ENDFOR»
+
+ //------------------------------------------------------------------------------------------------------------
+ // «IF conj»conjugated «ENDIF»replicated port class
+ //------------------------------------------------------------------------------------------------------------
+ «replPortClassName»::«replPortClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<Address> addr, std::vector<Address> peerAddress)
+ : m_replication(addr.size()),
+ m_ports()
+ {
+ char numstr[10]; // enough to hold all numbers up to 32-bits
+
+ m_ports = reinterpret_cast<«portClassName»*> (new char[sizeof(«portClassName») * addr.size()]);
+ for (int i = 0; i < m_replication; ++i) {
+ snprintf(numstr, sizeof(numstr), "%d", i);
+ //placement new to avoid copy construction, therefore no vector is used
+ new (&m_ports[i]) «portClassName»(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);
+ }
+ };
+
+
+ // outgoing messages
+ «FOR m : pc.getOutgoing(conj)»
+ «messageSignatureDefinition(m, replPortClassName)»{
+ for (int i=0; i<m_replication; ++i) {
+ m_ports[i].«messageCall(m)»;
+ }
+ }
+ «ENDFOR»
+ '''
+ }
+
+ def generateConstructorInitalizerList(PortClass pc, String index) {
+ var initializerList = new ArrayList<CharSequence>();
+ initializerList.add('''PortBase(actor, parent, name, localId, «index», addr, peerAddress)''')
+ if (pc != null) {
+ for (attrib: pc.attributes) {
+ initializerList.add(attrib.attributeInitialization(false))
+ }
+ }
+ return
+ '''
+ «initializerList.join(',\n')»
+ '''
+ }
+
+
+
+
+ def private messageCall(Message m) {
+ '''«m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)'''
+ }
+
+
+
+ def private generateDebugHelpersImplementation(Root root, ProtocolClass pc){'''
+
+««« TODO: make this optional or different for smaller footprint
+ /* message names as strings for debugging (generate MSC) */
+ std::string «pc.name»::s_messageStrings[]
+ = {"MIN",
+ «FOR m : pc.getAllOutgoingMessages()»
+ "«m.name»",
+ «ENDFOR»
+ «FOR m : pc.getAllIncomingMessages()»
+ "«m.name»",
+ «ENDFOR»
+ "MAX"};
+
+ std::string «pc.name»::getMessageString(int msg_id) {
+ if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {
+ return s_messageStrings[msg_id];
+ } else {
+ // id out of range
+ return "Message ID out of range";
+ }
+ }
+
+ '''
+ }
+
+
+ def messageSignature(Message m) {
+ '''«IF m.priv»private:«ELSE»public:«ENDIF» void «m.name»(«IF m.data!=null»«m.data.refType.type.typeName» «m.data.name»«ENDIF»)'''
+ }
+
+ def messageSignatureExplicit(Message m) {
+ var dc = (m.data.refType.type as DataClass)
+ '''public: void «m.name»(«IF dc.base!=null»«dc.base.typeName» _super, «ENDIF»«FOR a : dc.attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»«ENDFOR»)'''
+ }
+
+ def messageSignatureDefinition(Message m, String classPrefix) {
+ '''void «classPrefix»::«m.name»(«IF m.data!=null»«m.data.refType.type.typeName» «m.data.name»«ENDIF»)'''
+ }
+
+ def messageSignatureExplicitDefinition(Message m, String classPrefix) {
+ var dc = (m.data.refType.type as DataClass)
+ '''void «classPrefix»::«m.name»(«IF dc.base!=null»«dc.base.typeName» _super, «ENDIF»«FOR a : dc.attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»«ENDFOR»)'''
+ }
+
+// def messageCall(Message m) {
+// '''«m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)'''
+// }
+
+ def sendMessageDeclaration(Message m, boolean conj) {
+ '''
+ «messageSignature(m)»;
+ «IF m.data!=null && m.data.refType.type instanceof DataClass»
+ «messageSignatureExplicit(m)»;
+ «ENDIF»
+ '''
+ }
+
+ def sendMessage(Message m, String portClassName, String classPrefix, boolean conj) {
+ var dir = if (conj) "IN" else "OUT"
+ var hdlr = m.getSendHandler(conj)
+ '''
+ «messageSignatureDefinition(m, classPrefix)» {
+ «IF hdlr!=null»
+ «FOR command : hdlr.detailCode.commands» «command»
+ «ENDFOR»
+ «ELSE»
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ «portClassName»::getMessageString(«portClassName»::«dir»_«m.name»));
+ if (getPeerAddress().isValid()){
+ «IF m.data==null»getPeerMsgReceiver()->receive(new Message(getPeerAddress(), «portClassName»::«dir»_«m.name»));
+ «ELSE»getPeerMsgReceiver()->receive(new Message(getPeerAddress(),«portClassName»::«dir»_«m.name»,
+ reinterpret_cast<void*>(«IF (!m.data.refType.ref && !(m.data.refType.type instanceof PrimitiveType))»&«ENDIF»«m.data.name»),
+ sizeof(«m.data.refType.type.typeName»)));
+ «ENDIF»
+ }
+ «ENDIF»
+ }
+
+ «IF m.data!=null && m.data.refType.type instanceof DataClass»
+ «messageSignatureExplicitDefinition(m, classPrefix)» {
+ «m.name»(«m.data.refType.type.name»(«IF (m.data.refType.type as DataClass).base!=null»_super, «ENDIF»«FOR a : (m.data.refType.type as DataClass).attributes SEPARATOR ", "»«a.name»«ENDFOR»));
+ }
+ «ENDIF»
+ '''
+ //TODO derived data classes are not yet handled correctly
+ }
+
+ override getMessageID(Message msg, InterfaceItem item) {
+ if (item instanceof Port) {
+ var p = item as Port;
+ var direction = if (p.isConjugated())"OUT_" else "IN_"
+ return enumInUse(p.getProtocol().getName(), direction+msg.getName())
+ }
+ else if (item instanceof SAPRef) {
+ var sap = item as SAPRef;
+ return enumInUse(sap.getProtocol().getName(), "OUT_"+msg.getName())
+ }
+ else if (item instanceof SPPRef) {
+ var spp = item as SPPRef;
+ return enumInUse(spp.getProtocol().getName(), "IN_"+msg.getName())
+ }
+
+ return "unknown interface item";
+ }
+
+ def String enumInUse(String namespace, String member) {
+ return namespace+"::"+member
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
new file mode 100644
index 000000000..5c998149f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import java.util.ArrayList
+import org.eclipse.xtext.util.Pair
+import static org.eclipse.xtext.util.Tuples.*
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator
+import org.eclipse.etrice.generator.generic.RoomExtensions
+
+@Singleton
+class StateMachineGen extends GenericStateMachineGenerator {
+
+ @Inject extension RoomExtensions
+ @Inject ProtocolClassGen cppProtGen
+
+ override genExtraDecl(ExpandedActorClass xpac) {
+// val ac = xpac.actorClass
+ '''
+ protected:
+ static std::string s_stateStrings[];
+
+««« TODOHRR: history defined in ActorClassBase, init in constructor
+««« history = new int[5];
+««« for (int i = 0; i < history.length; i++) {
+««« history[i] = NO_STATE;
+««« }
+ int history[];
+
+ private:
+ void setState(int new_state);
+ '''}
+
+ override genExtra(ExpandedActorClass xpac) {
+ val ac = xpac.actorClass
+ '''
+ std::string «ac.name»::s_stateStrings[] = {"<no state>","<top>",«FOR state : ac.getAllBaseStatesLeavesLast() SEPARATOR ","»"«state.getStatePathName()»"
+ «ENDFOR»};
+
+««« TODOHRR: history defined in ActorClassBase, init in constructor
+««« history = new int[5];
+««« for (int i = 0; i < history.length; i++) {
+««« history[i] = NO_STATE;
+««« }
+
+ void «ac.name»::setState(int new_state) {
+ DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state]);
+ if (s_stateStrings[new_state]!="Idle") {
+««« TODOTS: model switch for activation
+ std::cout << getInstancePath() << " -> " << s_stateStrings[new_state] << std::endl;
+ }
+ m_state = new_state;
+ }
+ '''}
+
+ override genTriggerConstants(ExpandedActorClass xpac) {
+ val triggers = if (langExt.usesInheritance)
+ xpac.getOwnTriggers() else xpac.triggers
+
+ val list = new ArrayList<Pair<String, String>>()
+ list.add(pair("POLLING", "0"));
+ for (mif : triggers) {
+ list.add(pair(xpac.getTriggerCodeName(mif), "IFITEM_"+mif.from.name+" + EVT_SHIFT*"+cppProtGen.getMessageID(mif)))
+ }
+
+ return langExt.genEnumeration("triggers", list)
+ }
+
+ override constPointer(String classname) {
+ return "const " + classname + "*"
+ }
+
+ override boolType() {
+ return "bool"
+ }
+
+
+
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend
new file mode 100644
index 000000000..4f48ae6d4
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend
@@ -0,0 +1,289 @@
+
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.genmodel.base.ILogger
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
+import org.eclipse.etrice.core.room.SubSystemClass
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+
+import static extension org.eclipse.etrice.generator.base.Indexed.*
+import org.eclipse.etrice.generator.base.IDataConfiguration
+
+
+@Singleton
+class SubSystemClassGen {
+
+ @Inject JavaIoFileSystemAccess fileAccess
+ @Inject extension CppExtensions
+ @Inject extension RoomExtensions
+ @Inject extension ProcedureHelpers
+ @Inject IDataConfiguration dataConfigExt
+ @Inject ConfigGenAddon configGenAddon
+ @Inject ConfigGenAddon configAddon
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (ssi: root.subSystemInstances) {
+ var path = ssi.subSystemClass.generationTargetPath+ssi.subSystemClass.getPath
+ var file = ssi.subSystemClass.getCppHeaderFileName
+ logger.logInfo("generating SubSystemClass declaration: '"+file+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(file, root.generateHeaderFile(ssi, ssi.subSystemClass))
+
+ file = ssi.subSystemClass.getCppSourceFileName
+ logger.logInfo("generating SubSystemClass implementation: '"+file+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(file, root.generateSourceFile(ssi, ssi.subSystemClass))
+
+// file = ssi.subSystemClass.getInstSourceFileName
+// logger.logInfo("generating SubSystemClass instance file: '"+file+"' in '"+path+"'")
+// fileAccess.setOutputPath(path)
+// fileAccess.generateFile(file, root.generateInstanceFile(ssi, ssi.subSystemClass))
+//
+// file = ssi.subSystemClass.getDispSourceFileName
+// logger.logInfo("generating SubSystemClass dispatcher file: '"+file+"' in '"+path+"'")
+// fileAccess.setOutputPath(path)
+// fileAccess.generateFile(file, root.generateDispatcherFile(ssi, ssi.subSystemClass))
+ }
+ }
+
+ def generateHeaderFile(Root root, SubSystemInstance comp, SubSystemClass cc) {'''
+
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of SubSystemClass «cc.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(cc.name)»
+
+ #include "platforms/generic/etDatatypes.h"
+ #include "common/messaging/IRTObject.h"
+ #include "common/modelbase/PortBase.h"
+ #include "common/modelbase/InterfaceItemBase.h"
+ #include "common/modelbase/ActorClassBase.h"
+ #include "common/modelbase/SubSystemClassBase.h"
+ #include "common/messaging/Address.h"
+ #include "common/messaging/IMessageReceiver.h"
+ #include "common/debugging/DebuggingService.h"
+ #include <string>
+ #include <vector>
+
+ «FOR model : root.getReferencedModels(cc)»
+««« #include "«model.name».h"
+ «ENDFOR»
+
+
+ «cc.userCode(1)»
+
+ class «cc.name» : public etRuntime::SubSystemClassBase{
+
+ «cc.userCode(2)»
+
+ public:
+ «cc.name»(IRTObject* parent, std::string name)
+ : etRuntime::SubSystemClassBase(parent, name)
+ {
+ }
+
+ virtual void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data);
+ virtual void instantiateMessageServices();
+ virtual void instantiateActors();
+
+ private:
+ std::vector<etRuntime::MessageService*> m_msgServices;
+ };
+
+ «generateIncludeGuardEnd(cc.name)»
+ '''
+ }
+
+ def generateSourceFile(Root root, SubSystemInstance comp, SubSystemClass cc) {'''
+
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of SubsystemClass «cc.name»
+ *
+ */
+
+ #include "«cc.getCppHeaderFileName»"
+ #include "common/debugging/DebuggingService.h"
+ #include "common/messaging/RTSystemServicesProtocol.h"
+ «FOR ai : comp.allContainedInstances»
+ #include "«ai.actorClass.path»«ai.actorClass.name».h"
+ «ENDFOR»
+ #include <iostream>
+
+ using namespace etRuntime;
+
+ void «cc.name»::receiveEvent(InterfaceItemBase* ifitem, int evt, void* data){
+ }
+
+ void «cc.name»::instantiateMessageServices(){
+
+ m_msgServices.push_back( new MessageService(this, Address(0, 0, 0),"MessageService_Main") );
+ «FOR thread : cc.threads»
+ m_msgServices.push_back(new MessageService(this, Address(0, «cc.threads.indexOf(thread)+1», 0),"MessageService_«thread.name»", /* threadprio */ 0));
+ «ENDFOR»
+ for (std::vector<MessageService*>::iterator it=m_msgServices.begin(); it != m_msgServices.end(); ++it) {
+ RTServices::getInstance().getMsgSvcCtrl().addMsgSvc( *(*it));
+ }
+ }
+
+ void «cc.name»::instantiateActors(){
+ // all addresses
+ // Addresses for the Subsystem Systemport
+ «FOR ai : comp.allContainedInstances.indexed(comp.maxObjId)»
+ Address addr_item_SystemPort_«comp.allContainedInstances.indexOf(ai.value)»(0,0,«ai.index1»);
+ «ENDFOR»
+
+ «FOR ai : comp.allContainedInstances»
+ // actor instance «ai.path» itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item_«ai.path.getPathName()»(0,«ai.threadId»,«ai.objId»);
+ // interface items of «ai.path»
+ «FOR pi : ai.orderedIfItemInstances»
+ «IF pi.replicated»
+ «FOR peer : pi.peers»
+ «var i = pi.peers.indexOf(peer)»
+ Address addr_item_«pi.path.getPathName()»_«i»(0,«pi.threadId»,«pi.objId+i»);
+ «ENDFOR»
+ «ELSE»
+ Address addr_item_«pi.path.getPathName()»(0,«ai.threadId»,«pi.objId»);
+ «ENDIF»
+ «ENDFOR»
+ «ENDFOR»
+
+ // instantiate all actor instances
+ m_instances.reserve(«comp.allContainedInstances.size»);
+ «FOR ai : comp.allContainedInstances»
+ //----------------------------------------------------------------------------------------------
+ // addresses for actor instance: «ai.name»
+ //----------------------------------------------------------------------------------------------
+ «generateOwnInterfaceItemAddresses(ai)»
+ «generatePeerInterfaceItemAddresses(ai, comp)»
+
+ m_instances[«comp.allContainedInstances.indexOf(ai)»] = new «ai.actorClass.name»(
+ «IF ai.eContainer instanceof SubSystemInstance»
+ this,
+ «ELSE»
+ m_instances[«comp.allContainedInstances.indexOf(ai.eContainer)»],
+ «ENDIF»
+ "«ai.name»",
+ «ai.name»_ownInterfaceItemAddresses,
+ «ai.name»_peerInterfaceItemAddresses
+ );
+ «ENDFOR»
+
+««« // apply instance attribute configurations
+««« «FOR ai : comp.allContainedInstances»
+««« «IF !(ai.configAttributes.empty && ai.getConfigPorts.empty)»
+««« {
+««« «ai.actorClass.name» inst = («ai.actorClass.name») instances[«comp.allContainedInstances.indexOf(ai)»];
+««« «configAddon.applyInstanceConfig("inst", ai.actorClass.name, ai.configAttributes)»
+««« «FOR portConfig : ai.configPorts»
+««« «configAddon.applyInstanceConfig(("inst."+portConfig.item.name.invokeGetter(ai.actorClass.name)), portConfig.item.portClassName, portConfig.attributes)»
+««« «ENDFOR»
+««« }
+««« «ENDIF»
+««« «ENDFOR»
+
+ // apply instance attribute configurations
+ «FOR ai: comp.allContainedInstances»
+ «val cfg = configGenAddon.genActorInstanceConfig(ai, "inst")»
+ «IF cfg.length>0»
+ {
+ «ai.actorClass.name» inst = («ai.actorClass.name») instances[«comp.allContainedInstances.indexOf(ai)»];
+ «cfg»
+ }
+ «ENDIF»
+ «ENDFOR»
+
+ //----------------------------------------------------------------------------------------------
+ // addresses for the subsystem system port
+ //----------------------------------------------------------------------------------------------
+
+ std::vector<Address> ownAddresses(«comp.allContainedInstances.size»);
+ «FOR ai : comp.allContainedInstances»
+ ownAddresses[«comp.allContainedInstances.indexOf(ai)»] = addr_item_SystemPort_«comp.allContainedInstances.indexOf(ai)»;
+ «ENDFOR»
+ std::vector<Address> peerAddresses(«comp.allContainedInstances.size»);
+ «FOR ai : comp.allContainedInstances»
+ peerAddresses[«comp.allContainedInstances.indexOf(ai)»] = addr_item_«ai.path.getPathName()»;
+ «ENDFOR»
+
+
+ // create the subsystem system port
+ m_RTSystemPort = new RTSystemServicesProtocolConjPortRepl(*this, this, "RTSystemPort",
+ 0, //local ID
+ ownAddresses,
+ peerAddresses);
+
+ }
+
+
+ '''
+ }
+ def generateOwnInterfaceItemAddresses(ActorInstance ai) '''
+ std::vector<std::vector<Address> > «ai.name»_ownInterfaceItemAddresses;
+
+ std::vector<Address> «ai.name»_actorInstanceAddresses(1);
+ «ai.name»_actorInstanceAddresses[0] = addr_item_«ai.path.getPathName()»;
+
+ «ai.name»_ownInterfaceItemAddresses.push_back(«ai.name»_actorInstanceAddresses);
+ «FOR pi : ai.orderedIfItemInstances»
+ «IF pi.replicated»
+ «IF pi.peers.empty»
+ std::vector<Address> «ai.name»_«pi.name»Addresses;
+ «ELSE»
+ std::vector<Address> «ai.name»_«pi.name»Addresses(«pi.peers.size»);
+ «FOR peer : pi.peers»
+ «ai.name»_«pi.name»Addresses[«pi.peers.indexOf(peer)»] = addr_item_«pi.path.getPathName()»_«pi.peers.indexOf(peer)»;
+ «ENDFOR»
+ «ENDIF»
+ «ELSE»
+ std::vector<Address> «ai.name»_«pi.name»Addresses(1);
+ «ai.name»_«pi.name»Addresses[0] = addr_item_«pi.path.getPathName()»;
+ «ENDIF»
+ «ai.name»_ownInterfaceItemAddresses.push_back(«ai.name»_«pi.name»Addresses);
+
+ «ENDFOR»
+ '''
+
+ def generatePeerInterfaceItemAddresses(ActorInstance ai, SubSystemInstance comp) '''
+ std::vector<std::vector<Address> > «ai.name»_peerInterfaceItemAddresses;
+
+ std::vector<Address> «ai.name»_systemPortAddresses(1);
+ «ai.name»_systemPortAddresses[0] = addr_item_SystemPort_«comp.allContainedInstances.indexOf(ai)»;
+
+ «ai.name»_peerInterfaceItemAddresses.push_back(«ai.name»_systemPortAddresses);
+ «FOR pi : ai.orderedIfItemInstances »
+ «IF pi.replicated && pi.peers.isEmpty»
+ «ELSE»
+ «IF pi.peers.empty»
+ std::vector<Address> «ai.name»_«pi.name»PeerAddresses;
+ «ELSE»
+ std::vector<Address> «ai.name»_«pi.name»PeerAddresses(«pi.peers.size»);
+ «FOR pp : pi.peers»
+ «IF pp.replicated»
+ «ai.name»_«pi.name»PeerAddresses[«pi.peers.indexOf(pp)»] = addr_item_«pp.path.getPathName()»_«pp.peers.indexOf(pi)»;
+ «ELSE»
+ «ai.name»_«pi.name»PeerAddresses[«pi.peers.indexOf(pp)»] = addr_item_«pp.path.getPathName()»;
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+ «ai.name»_peerInterfaceItemAddresses.push_back(«ai.name»_«pi.name»PeerAddresses);
+ «ENDIF»
+ «ENDFOR»
+ '''
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend
new file mode 100644
index 000000000..bb050760c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend
@@ -0,0 +1,105 @@
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.SubSystemClass
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.generic.RoomExtensions
+
+@Singleton
+class SubSystemRunnerGen {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension CppExtensions
+ @Inject extension RoomExtensions roomExt
+
+ def doGenerate(Root root) {
+ for (sc: root.subSystemInstances) {
+ fileAccess.setOutputPath(sc.subSystemClass.generationTargetPath+sc.subSystemClass.getPath)
+ fileAccess.generateFile( sc.subSystemClass.name+"_Runner.h", root.generateHeaderFile(sc, sc.subSystemClass))
+
+ fileAccess.setOutputPath(sc.subSystemClass.generationTargetPath+sc.subSystemClass.getPath)
+ fileAccess.generateFile( sc.subSystemClass.name+"_Runner.cpp", root.generateSourceFile(sc, sc.subSystemClass))
+ }
+ }
+
+ def generateHeaderFile(Root root, SubSystemInstance ssc, SubSystemClass cc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * this class contains the main function running component «cc.name»
+ * it instantiates «cc.name» and starts and ends the lifecycle
+ */
+
+ «generateIncludeGuardBegin(cc.name+"_Runner")»
+
+ #include "common/modelbase/SubSystemRunnerBase.h"
+
+ class «cc.name+"Runner"» :public etRuntime::SubSystemRunnerBase {
+
+ /**
+ * main function
+ * creates component and starts and stops the lifecycle
+ */
+ public:
+ static void run();
+ };
+
+ «generateIncludeGuardEnd(cc.name+"_Runner")»
+ '''
+ }
+
+ def generateSourceFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * this class contains the main function running component «ssc.name»
+ * it instantiates «ssc.name» and starts and ends the lifecycle
+ */
+
+
+ #include "«ssc.name».h"
+ #include "«ssc.name»_Runner.h"
+
+ #include <iostream>
+
+
+ /**
+ * main function
+ * creates component and starts and stops the lifecycle
+ */
+
+ int main(void) {
+ «ssc.name+"Runner"»::run();
+ return 0;
+ }
+
+
+ void «ssc.name+"Runner"»::run() {
+ «ssc.name» main_component(0, "«ssc.name»");
+
+ //etUserEntry(); /* platform specific */
+
+ std::cout << "*** T H E B E G I N ***" << std::endl;
+
+ main_component.init(); // lifecycle init
+ main_component.start(); // lifecycle start
+
+ // application runs until quit
+ waitForQuit(main_component);
+
+ // end the lifecycle
+ main_component.stop(); // lifecycle stop
+ main_component.destroy(); // lifecycle destroy
+
+ std::cout << "*** T H E E N D ***" << std::endl;
+
+ //etUserExit(); /* platform specific */
+ }
+
+ '''
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Validator.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Validator.java
new file mode 100644
index 000000000..0a6a77ef3
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Validator.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.cpp.gen;
+
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+
+import com.google.inject.Inject;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class Validator {
+
+ @Inject
+ private ILogger logger;
+
+ public boolean validate(Root genModel) {
+
+// currently unused
+
+ int errorCount = 0;
+// for (RoomModel mdl : genModel.getUsedRoomModels()) {
+// TreeIterator<EObject> it = mdl.eAllContents();
+// while (it.hasNext()) {
+// EObject obj = it.next();
+//
+// }
+// }
+
+ if (errorCount>0) {
+ logger.logError("C++ generator detected "+errorCount+" error(s) - terminating", null);
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.java
new file mode 100644
index 000000000..09e946137
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.cpp.setup;
+
+import org.eclipse.etrice.core.scoping.PlatformRelativeUriResolver;
+import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.generator.base.GeneratorBaseModule;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
+import org.eclipse.etrice.generator.base.ITranslationProvider;
+import org.eclipse.etrice.generator.cpp.Main;
+import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
+import org.eclipse.etrice.generator.cpp.gen.CppTranslationProvider;
+import org.eclipse.etrice.generator.cpp.gen.MainGen;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.scoping.impl.ImportUriResolver;
+
+import com.google.inject.Binder;
+
+public class GeneratorModule extends GeneratorBaseModule {
+
+// @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+
+ binder.bind(AbstractGenerator.class).to(Main.class);
+ binder.bind(IGenerator.class).to(MainGen.class);
+
+ // bind language specific code to generic Interfaces
+ binder.bind(ILanguageExtension.class).to(CppExtensions.class);
+
+ binder.bind(ITranslationProvider.class).to(CppTranslationProvider.class);
+
+ binder.bind(IDataConfiguration.class).to(org.eclipse.etrice.generator.config.DataConfiguration.class);
+
+ binder.bind(ImportUriResolver.class).to(PlatformRelativeUriResolver.class);
+
+
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
new file mode 100644
index 000000000..fff0cfc07
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
@@ -0,0 +1,412 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.etrice.core.genmodel.etricegen.IDiagnostician;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.ExternalType;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.RoomClass;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Conversions;
+
+@Singleton
+@SuppressWarnings("all")
+public class CppExtensions implements ILanguageExtension {
+ @Inject
+ private IDiagnostician diagnostician;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ public String getTypedDataDefinition(final Message m) {
+ VarDecl _data = m.getData();
+ String[] _generateArglistAndTypedData = this.generateArglistAndTypedData(_data);
+ String _get = ((List<String>)Conversions.doWrapArray(_generateArglistAndTypedData)).get(1);
+ return _get;
+ }
+
+ public String getCppHeaderFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _plus = (_name + ".h");
+ return _plus;
+ }
+
+ public String getCppSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _plus = (_name + ".cpp");
+ return _plus;
+ }
+
+ public String getInstSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _plus = (_name + "_Inst.h");
+ return _plus;
+ }
+
+ public String getDispSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _plus = (_name + "_Disp.h");
+ return _plus;
+ }
+
+ public String accessLevelPrivate() {
+ return "";
+ }
+
+ public String accessLevelProtected() {
+ return "";
+ }
+
+ public String accessLevelPublic() {
+ return "";
+ }
+
+ public String memberAccess() {
+ return "this->";
+ }
+
+ public String selfPointer(final String classname, final boolean hasArgs) {
+ return "";
+ }
+
+ public String selfPointer(final boolean hasArgs) {
+ return "";
+ }
+
+ public String operationScope(final String classname, final boolean isDeclaration) {
+ String _xifexpression = null;
+ if (isDeclaration) {
+ _xifexpression = "";
+ } else {
+ String _plus = (classname + "::");
+ _xifexpression = _plus;
+ }
+ return _xifexpression;
+ }
+
+ public String memberInDeclaration(final String namespace, final String member) {
+ return member;
+ }
+
+ public String memberInUse(final String namespace, final String member) {
+ String _plus = (namespace + ".");
+ return (_plus + member);
+ }
+
+ public boolean usesInheritance() {
+ return true;
+ }
+
+ public boolean usesPointers() {
+ return true;
+ }
+
+ public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("typedef enum {");
+ _builder.newLine();
+ {
+ for(final Pair<String,String> entry : entries) {
+ String _first = entry.getFirst();
+ _builder.append(_first, "");
+ _builder.append(" = ");
+ String _second = entry.getSecond();
+ _builder.append(_second, "");
+ _builder.append(",");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("} ");
+ _builder.append(name, "");
+ _builder.append(";");
+ String _string = _builder.toString();
+ return _string;
+ }
+
+ public String booleanConstant(final boolean b) {
+ String _string = Boolean.valueOf(b).toString();
+ return _string;
+ }
+
+ public String pointerLiteral() {
+ return "*";
+ }
+
+ public String nullPointer() {
+ return "0";
+ }
+
+ public String voidPointer() {
+ return "void*";
+ }
+
+ public String arrayDeclaration(final String type, final int size, final String name, final boolean isRef) {
+ String _plus = (type + " ");
+ String _plus_1 = (_plus + name);
+ String _plus_2 = (_plus_1 + "[");
+ String _plus_3 = (_plus_2 + Integer.valueOf(size));
+ String _plus_4 = (_plus_3 + "]");
+ return _plus_4;
+ }
+
+ public String constructorName(final String cls) {
+ return cls;
+ }
+
+ public String destructorName(final String cls) {
+ String _plus = (cls + "_dtor");
+ return _plus;
+ }
+
+ public String constructorReturnType() {
+ return "";
+ }
+
+ public String destructorReturnType() {
+ return "void";
+ }
+
+ public CharSequence getIncludeGuardString(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("_");
+ String _replaceAll = filename.replaceAll("\\/.", "_");
+ String _upperCase = _replaceAll.toUpperCase();
+ _builder.append(_upperCase, "");
+ _builder.append("_H_");
+ return _builder;
+ }
+
+ public CharSequence generateIncludeGuardBegin(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#ifndef ");
+ CharSequence _includeGuardString = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#define ");
+ CharSequence _includeGuardString_1 = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString_1, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public CharSequence generateIncludeGuardEnd(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#endif /* ");
+ CharSequence _includeGuardString = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public String superCall(final String baseClassName, final String method, final String arguments) {
+ String _plus = (baseClassName + "::");
+ String _plus_1 = (_plus + method);
+ String _plus_2 = (_plus_1 + "(");
+ String _plus_3 = (_plus_2 + arguments);
+ String _plus_4 = (_plus_3 + ");");
+ return _plus_4;
+ }
+
+ public String toValueLiteral(final PrimitiveType type, final String value) {
+ UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("TODO Config for Cpp");
+ throw _unsupportedOperationException;
+ }
+
+ public String defaultValue(final DataType dt) {
+ String _xifexpression = null;
+ if ((dt instanceof PrimitiveType)) {
+ return ((PrimitiveType) dt).getDefaultValueLiteral();
+ } else {
+ String _xifexpression_1 = null;
+ if ((dt instanceof ExternalType)) {
+ String _name = dt.getName();
+ String _plus = ("initialize external type with default constructor" + _name);
+ EObject _eContainer = dt.eContainer();
+ EStructuralFeature _eContainingFeature = dt.eContainingFeature();
+ this.diagnostician.warning(_plus, _eContainer, _eContainingFeature);
+ String _typeName = this._typeHelpers.typeName(dt);
+ return (_typeName + "()");
+ } else {
+ String _xblockexpression = null;
+ {
+ final DataClass dc = ((DataClass) dt);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("{");
+ _builder.newLine();
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ boolean _hasElements = false;
+ for(final Attribute att : _attributes) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ RefableType _refType = att.getRefType();
+ DataType _type = _refType.getType();
+ int _size = att.getSize();
+ String _initializationWithDefaultValues = this.initializationWithDefaultValues(_type, _size);
+ _builder.append(_initializationWithDefaultValues, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _xblockexpression = (_builder.toString());
+ }
+ _xifexpression_1 = _xblockexpression;
+ }
+ _xifexpression = _xifexpression_1;
+ }
+ return _xifexpression;
+ }
+
+ public String initializationWithDefaultValues(final DataType dt, final int size) {
+ String _xblockexpression = null;
+ {
+ final String dv = this.defaultValue(dt);
+ String _xifexpression = null;
+ boolean _greaterThan = (size > 1);
+ if (_greaterThan) {
+ String _xblockexpression_1 = null;
+ {
+ String res = "{";
+ int i = 0;
+ boolean _lessThan = (i < size);
+ boolean _while = _lessThan;
+ while (_while) {
+ {
+ String _plus = (res + dv);
+ res = _plus;
+ int _plus_1 = (i + 1);
+ i = _plus_1;
+ boolean _lessThan_1 = (i < size);
+ if (_lessThan_1) {
+ String _plus_2 = (res + ",");
+ res = _plus_2;
+ }
+ }
+ boolean _lessThan_1 = (i < size);
+ _while = _lessThan_1;
+ }
+ String _plus = (res + "}");
+ _xblockexpression_1 = (_plus);
+ }
+ _xifexpression = _xblockexpression_1;
+ } else {
+ _xifexpression = dv;
+ }
+ _xblockexpression = (_xifexpression);
+ }
+ return _xblockexpression;
+ }
+
+ public String[] generateArglistAndTypedData(final VarDecl data) {
+ String deref = "*";
+ boolean _equals = Objects.equal(data, null);
+ if (_equals) {
+ return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("", "", ""), String.class));
+ }
+ String _xifexpression = null;
+ RefableType _refType = data.getRefType();
+ DataType _type = _refType.getType();
+ if ((_type instanceof PrimitiveType)) {
+ RefableType _refType_1 = data.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _targetName = ((PrimitiveType) _type_1).getTargetName();
+ _xifexpression = _targetName;
+ } else {
+ RefableType _refType_2 = data.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ String _name = _type_2.getName();
+ _xifexpression = _name;
+ }
+ String typeName = _xifexpression;
+ String _xifexpression_1 = null;
+ RefableType _refType_3 = data.getRefType();
+ DataType _type_3 = _refType_3.getType();
+ if ((_type_3 instanceof PrimitiveType)) {
+ String _xblockexpression = null;
+ {
+ RefableType _refType_4 = data.getRefType();
+ DataType _type_4 = _refType_4.getType();
+ final String ct = ((PrimitiveType) _type_4).getCastName();
+ String _xifexpression_2 = null;
+ boolean _and = false;
+ boolean _notEquals = (!Objects.equal(ct, null));
+ if (!_notEquals) {
+ _and = false;
+ } else {
+ boolean _isEmpty = ct.isEmpty();
+ boolean _not = (!_isEmpty);
+ _and = (_notEquals && _not);
+ }
+ if (_and) {
+ _xifexpression_2 = ct;
+ } else {
+ _xifexpression_2 = typeName;
+ }
+ _xblockexpression = (_xifexpression_2);
+ }
+ _xifexpression_1 = _xblockexpression;
+ } else {
+ _xifexpression_1 = typeName;
+ }
+ String castTypeName = _xifexpression_1;
+ String _plus = (castTypeName + "*");
+ castTypeName = _plus;
+ RefableType _refType_4 = data.getRefType();
+ boolean _isRef = _refType_4.isRef();
+ if (_isRef) {
+ String _plus_1 = (typeName + "*");
+ typeName = _plus_1;
+ String _plus_2 = (castTypeName + "*");
+ castTypeName = _plus_2;
+ } else {
+ RefableType _refType_5 = data.getRefType();
+ DataType _type_4 = _refType_5.getType();
+ boolean _not = (!(_type_4 instanceof PrimitiveType));
+ if (_not) {
+ String _plus_3 = (typeName + "*");
+ typeName = _plus_3;
+ String _plus_4 = (castTypeName + "*");
+ castTypeName = _plus_4;
+ } else {
+ castTypeName = typeName;
+ deref = "";
+ }
+ }
+ String _plus_5 = (typeName + " ");
+ String _name_1 = data.getName();
+ String _plus_6 = (_plus_5 + _name_1);
+ String _plus_7 = (_plus_6 + " = ");
+ String _plus_8 = (_plus_7 + deref);
+ String _plus_9 = (_plus_8 + "((");
+ String _plus_10 = (_plus_9 + castTypeName);
+ final String typedData = (_plus_10 + ") generic_data);\n");
+ String _name_2 = data.getName();
+ final String dataArg = (", " + _name_2);
+ String _plus_11 = (", " + typeName);
+ String _plus_12 = (_plus_11 + " ");
+ String _name_3 = data.getName();
+ final String typedArgList = (_plus_12 + _name_3);
+ return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList(dataArg, typedData, typedArgList), String.class));
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
new file mode 100644
index 000000000..8aff81f59
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
@@ -0,0 +1,846 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.ComplexType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.cpp.GeneratorOptions;
+import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
+import org.eclipse.etrice.generator.cpp.gen.Initialization;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class DataClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CppExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers typeHelpers;
+
+ @Inject
+ private Initialization _initialization;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ this.logger.logInfo("generating code");
+ EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
+ for (final DataClass dc : _usedDataClasses) {
+ {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
+ String _path = this.roomExt.getPath(dc);
+ String path = (_generationTargetPath + _path);
+ String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(dc);
+ String _plus = ("generating DataClass header \'" + _cppHeaderFileName);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ String _cppHeaderFileName_1 = this.stdExt.getCppHeaderFileName(dc);
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, dc);
+ this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
+ String _cppSourceFileName = this.stdExt.getCppSourceFileName(dc);
+ String _plus_4 = ("generating DataClass source \'" + _cppSourceFileName);
+ String _plus_5 = (_plus_4 + "\' in \'");
+ String _plus_6 = (_plus_5 + path);
+ String _plus_7 = (_plus_6 + "\'");
+ this.logger.logInfo(_plus_7);
+ this.fileAccess.setOutputPath(path);
+ String _cppSourceFileName_1 = this.stdExt.getCppSourceFileName(dc);
+ CharSequence _generateSourceFile = this.generateSourceFile(root, dc);
+ this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public CharSequence generateHeaderFile(final Root root, final DataClass dc) {
+ CharSequence _xblockexpression = null;
+ {
+ EList<StandardOperation> _operations = dc.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isConstructor = RoomHelpers.isConstructor(op);
+ return Boolean.valueOf(_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
+ EList<StandardOperation> _operations_1 = dc.getOperations();
+ final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isDestructor = op.isDestructor();
+ return Boolean.valueOf(_isDestructor);
+ }
+ };
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
+ final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
+ StringConcatenation _builder = new StringConcatenation();
+ String _path = this.roomExt.getPath(dc);
+ String _name = dc.getName();
+ String _plus = (_path + _name);
+ CharSequence _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_plus);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ DataClass _base = dc.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ _builder.append("#include \"");
+ DataClass _base_1 = dc.getBase();
+ String _path_1 = this.roomExt.getPath(_base_1);
+ _builder.append(_path_1, "");
+ DataClass _base_2 = dc.getBase();
+ String _name_1 = _base_2.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
+ for(final DataClass classes : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _path_2 = this.roomExt.getPath(classes);
+ _builder.append(_path_2, "");
+ String _name_2 = classes.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ EList<RoomModel> models = root.getReferencedModels(dc);
+ _builder.newLineIfNotEmpty();
+ {
+ for(final RoomModel model : models) {
+ {
+ EList<DataClass> _dataClasses = model.getDataClasses();
+ for(final DataClass classes_1 : _dataClasses) {
+ _builder.append("#include \"");
+ String _path_3 = this.roomExt.getPath(classes_1);
+ _builder.append(_path_3, "");
+ String _name_3 = classes_1.getName();
+ _builder.append(_name_3, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode1 = dc.getUserCode1();
+ CharSequence _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class ");
+ String _name_4 = dc.getName();
+ _builder.append(_name_4, "");
+ {
+ DataClass _base_3 = dc.getBase();
+ boolean _notEquals_1 = (!Objects.equal(_base_3, null));
+ if (_notEquals_1) {
+ _builder.append(" : public ");
+ DataClass _base_4 = dc.getBase();
+ String _name_5 = _base_4.getName();
+ _builder.append(_name_5, "");
+ }
+ }
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode2 = dc.getUserCode2();
+ CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _attributes_1 = this.helpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes_2 = dc.getAttributes();
+ String _name_6 = dc.getName();
+ CharSequence _attributeSettersGettersImplementation = this.helpers.attributeSettersGettersImplementation(_attributes_2, _name_6);
+ _builder.append(_attributeSettersGettersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<StandardOperation> _operations_2 = dc.getOperations();
+ String _name_7 = dc.getName();
+ CharSequence _operationsDeclaration = this.helpers.operationsDeclaration(_operations_2, _name_7);
+ _builder.append(_operationsDeclaration, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// default constructor, copy constructor and assignment operator");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_8 = dc.getName();
+ _builder.append(_name_8, " ");
+ _builder.append("();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_9 = dc.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("(const ");
+ String _name_10 = dc.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("& rhs);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_11 = dc.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("& operator=(const ");
+ String _name_12 = dc.getName();
+ _builder.append(_name_12, " ");
+ _builder.append("& rhs);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// constructor using fields");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_13 = dc.getName();
+ _builder.append(_name_13, " ");
+ _builder.append("(");
+ String _argList = this.argList(dc);
+ _builder.append(_argList, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ DataClass _base_5 = dc.getBase();
+ boolean _notEquals_2 = (!Objects.equal(_base_5, null));
+ if (_notEquals_2) {
+ _builder.append("\t");
+ _builder.append("// constructor using base class constructor");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_14 = dc.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("(");
+ DataClass _base_6 = dc.getBase();
+ String _name_15 = _base_6.getName();
+ _builder.append(_name_15, " ");
+ _builder.append(" _super, ");
+ EList<Attribute> _attributes_3 = dc.getAttributes();
+ CharSequence _argListConstructor = this.argListConstructor(_attributes_3);
+ String _string = _argListConstructor.toString();
+ _builder.append(_string, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_16 = dc.getName();
+ CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_16);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence generateSourceFile(final Root root, final DataClass dc) {
+ CharSequence _xblockexpression = null;
+ {
+ EList<StandardOperation> _operations = dc.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isConstructor = RoomHelpers.isConstructor(op);
+ return Boolean.valueOf(_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
+ EList<StandardOperation> _operations_1 = dc.getOperations();
+ final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isDestructor = op.isDestructor();
+ return Boolean.valueOf(_isDestructor);
+ }
+ };
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
+ final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of DataClass ");
+ String _name = dc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(dc);
+ _builder.append(_cppHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isUseEtUnit = GeneratorOptions.isUseEtUnit();
+ if (_isUseEtUnit) {
+ _builder.append("extern \"C\" {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"etUnit.h\"");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode3 = dc.getUserCode3();
+ CharSequence _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("// default constructor");
+ _builder.newLine();
+ String _name_1 = dc.getName();
+ _builder.append(_name_1, "");
+ _builder.append("::");
+ String _name_2 = dc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("() ");
+ _builder.newLineIfNotEmpty();
+ {
+ DataClass _base = dc.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ _builder.append("\t");
+ _builder.append(":");
+ DataClass _base_1 = dc.getBase();
+ String _name_3 = _base_1.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("()");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes, false);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals_1 = (!Objects.equal(ctor, null));
+ if (_notEquals_1) {
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("// user defined constructor body");
+ _builder.newLine();
+ {
+ DetailCode _detailCode = ctor.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String l : _commands) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(l, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("// copy constructor");
+ _builder.newLine();
+ String _name_4 = dc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("::");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, "");
+ _builder.append("(const ");
+ String _name_6 = dc.getName();
+ _builder.append(_name_6, "");
+ _builder.append("& rhs)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(":");
+ _builder.newLine();
+ {
+ DataClass _base_2 = dc.getBase();
+ boolean _notEquals_2 = (!Objects.equal(_base_2, null));
+ if (_notEquals_2) {
+ _builder.append("\t");
+ DataClass _base_3 = dc.getBase();
+ String _name_7 = _base_3.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("(rhs),");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<Attribute> _attributes_1 = dc.getAttributes();
+ boolean _hasElements = false;
+ for(final Attribute a : _attributes_1) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, " ");
+ _builder.append("(rhs.");
+ String _name_9 = a.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("// constructor using fields");
+ _builder.newLine();
+ String _name_10 = dc.getName();
+ _builder.append(_name_10, "");
+ _builder.append("::");
+ String _name_11 = dc.getName();
+ _builder.append(_name_11, "");
+ _builder.append("(");
+ String _argList = this.argList(dc);
+ _builder.append(_argList, "");
+ _builder.append(") ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(":");
+ _builder.newLine();
+ {
+ DataClass _base_4 = dc.getBase();
+ boolean _notEquals_3 = (!Objects.equal(_base_4, null));
+ if (_notEquals_3) {
+ _builder.append("\t");
+ DataClass _base_5 = dc.getBase();
+ String _name_12 = _base_5.getName();
+ _builder.append(_name_12, " ");
+ _builder.append("(");
+ DataClass _base_6 = dc.getBase();
+ String _paramList = this.paramList(_base_6);
+ _builder.append(_paramList, " ");
+ _builder.append("),");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<Attribute> _attributes_2 = dc.getAttributes();
+ boolean _hasElements_1 = false;
+ for(final Attribute a_1 : _attributes_2) {
+ if (!_hasElements_1) {
+ _hasElements_1 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _name_13 = a_1.getName();
+ _builder.append(_name_13, " ");
+ _builder.append("(");
+ String _name_14 = a_1.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("_)");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ DataClass _base_7 = dc.getBase();
+ boolean _notEquals_4 = (!Objects.equal(_base_7, null));
+ if (_notEquals_4) {
+ _builder.append("// constructor using base class constructor");
+ _builder.newLine();
+ String _name_15 = dc.getName();
+ _builder.append(_name_15, "");
+ _builder.append("::");
+ String _name_16 = dc.getName();
+ _builder.append(_name_16, "");
+ _builder.append("(");
+ DataClass _base_8 = dc.getBase();
+ String _name_17 = _base_8.getName();
+ _builder.append(_name_17, "");
+ _builder.append(" _super, ");
+ EList<Attribute> _attributes_3 = dc.getAttributes();
+ CharSequence _argListConstructor = this.argListConstructor(_attributes_3);
+ String _string = _argListConstructor.toString();
+ _builder.append(_string, "");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(":");
+ _builder.newLine();
+ _builder.append("\t");
+ DataClass _base_9 = dc.getBase();
+ String _name_18 = _base_9.getName();
+ _builder.append(_name_18, " ");
+ _builder.append("(_super),");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<Attribute> _attributes_4 = dc.getAttributes();
+ boolean _hasElements_2 = false;
+ for(final Attribute a_2 : _attributes_4) {
+ if (!_hasElements_2) {
+ _hasElements_2 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _name_19 = a_2.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("(");
+ String _name_20 = a_2.getName();
+ _builder.append(_name_20, " ");
+ _builder.append("_)");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ _builder.append("// assignment operator");
+ _builder.newLine();
+ String _name_21 = dc.getName();
+ _builder.append(_name_21, "");
+ _builder.append("& ");
+ String _name_22 = dc.getName();
+ _builder.append(_name_22, "");
+ _builder.append("::operator=(const ");
+ String _name_23 = dc.getName();
+ _builder.append(_name_23, "");
+ _builder.append("& rhs)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("{\t\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (this == &rhs) { return *this; };");
+ _builder.newLine();
+ {
+ DataClass _base_10 = dc.getBase();
+ boolean _notEquals_5 = (!Objects.equal(_base_10, null));
+ if (_notEquals_5) {
+ _builder.append("\t");
+ DataClass _base_11 = dc.getBase();
+ String _name_24 = _base_11.getName();
+ _builder.append(_name_24, " ");
+ _builder.append("::operator=(rhs);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<Attribute> _attributes_5 = dc.getAttributes();
+ for(final Attribute a_3 : _attributes_5) {
+ _builder.append("\t");
+ String _name_25 = a_3.getName();
+ _builder.append(_name_25, " ");
+ _builder.append("= rhs.");
+ String _name_26 = a_3.getName();
+ _builder.append(_name_26, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("return *this;");
+ _builder.newLine();
+ _builder.append("}\t\t\t");
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations_2 = dc.getOperations();
+ String _name_27 = dc.getName();
+ CharSequence _operationsImplementation = this.helpers.operationsImplementation(_operations_2, _name_27);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public String paramList(final DataClass _dc) {
+ String result = "";
+ DataClass dc = _dc;
+ boolean _notEquals = (!Objects.equal(dc, null));
+ boolean _while = _notEquals;
+ while (_while) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _paramList = this.paramList(_attributes);
+ String _string = _paramList.toString();
+ String _plus = (_string + result);
+ result = _plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ if (_notEquals_1) {
+ String _plus_1 = (", " + result);
+ result = _plus_1;
+ }
+ }
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ _while = _notEquals_1;
+ }
+ return result;
+ }
+
+ public CharSequence paramList(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _hasElements = false;
+ for(final Attribute a : attributes) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ String _name = a.getName();
+ _builder.append(_name, "");
+ _builder.append("_");
+ }
+ }
+ return _builder;
+ }
+
+ public String argList(final DataClass _dc) {
+ String result = "";
+ DataClass dc = _dc;
+ boolean _notEquals = (!Objects.equal(dc, null));
+ boolean _while = _notEquals;
+ while (_while) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _argListConstructor = this.argListConstructor(_attributes);
+ String _string = _argListConstructor.toString();
+ String _plus = (_string + result);
+ result = _plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ if (_notEquals_1) {
+ String _plus_1 = (", " + result);
+ result = _plus_1;
+ }
+ }
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ _while = _notEquals_1;
+ }
+ return result;
+ }
+
+ public CharSequence argListConstructor(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _hasElements = false;
+ for(final Attribute a : attributes) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this.typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ {
+ int _size = a.getSize();
+ boolean _greaterThan = (_size > 1);
+ if (_greaterThan) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name = a.getName();
+ _builder.append(_name, "");
+ _builder.append("_");
+ }
+ }
+ return _builder;
+ }
+
+ public String deepCopy(final DataClass _dc) {
+ String result = "";
+ DataClass dc = _dc;
+ boolean _notEquals = (!Objects.equal(dc, null));
+ boolean _while = _notEquals;
+ while (_while) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _deepCopy = this.deepCopy(_attributes);
+ String _string = _deepCopy.toString();
+ String _plus = (_string + result);
+ result = _plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ }
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ _while = _notEquals_1;
+ }
+ return result;
+ }
+
+ public CharSequence deepCopy(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Attribute a : attributes) {
+ {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ if ((_type instanceof ComplexType)) {
+ _builder.append("if (");
+ String _name = a.getName();
+ _builder.append(_name, "");
+ _builder.append("!=null) {");
+ _builder.newLineIfNotEmpty();
+ {
+ int _size = a.getSize();
+ boolean _equals = (_size == 0);
+ if (_equals) {
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" = ");
+ String _name_2 = a.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(".deepCopy();");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("for (int i=0;i<");
+ String _name_3 = a.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(".length;i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_4 = a.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("[i] = ");
+ String _name_5 = a.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("[i].deepCopy();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ {
+ int _size_1 = a.getSize();
+ boolean _equals_1 = (_size_1 == 0);
+ if (_equals_1) {
+ _builder.append("copy.");
+ String _name_6 = a.getName();
+ _builder.append(_name_6, "");
+ _builder.append(" = ");
+ String _name_7 = a.getName();
+ _builder.append(_name_7, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("for (int i=0;i<");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, "");
+ _builder.append(".length;i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_9 = a.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("[i] = ");
+ String _name_10 = a.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("[i];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
new file mode 100644
index 000000000..f2df9e05c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
@@ -0,0 +1,60 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.generator.cpp.gen.ActorClassGen;
+import org.eclipse.etrice.generator.cpp.gen.DataClassGen;
+import org.eclipse.etrice.generator.cpp.gen.ProtocolClassGen;
+import org.eclipse.etrice.generator.cpp.gen.SubSystemClassGen;
+import org.eclipse.etrice.generator.cpp.gen.SubSystemRunnerGen;
+import org.eclipse.etrice.generator.generic.PrepareFileSystem;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@Singleton
+@SuppressWarnings("all")
+public class MainGen implements IGenerator {
+ @Inject
+ private DataClassGen dataClassGen;
+
+ @Inject
+ private ProtocolClassGen protocolClassGen;
+
+ @Inject
+ private ActorClassGen actorClassGen;
+
+ @Inject
+ private SubSystemClassGen subsystemClassGen;
+
+ @Inject
+ private SubSystemRunnerGen subsystemRunnerGen;
+
+ @Inject
+ private PrepareFileSystem prepFS;
+
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ this.prepFS.prepare(resource);
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ this.doGenerate(((Root) e));
+ }
+ }
+ }
+
+ public void doGenerate(final Root e) {
+ this.dataClassGen.doGenerate(e);
+ this.protocolClassGen.doGenerate(e);
+ this.actorClassGen.doGenerate(e);
+ this.subsystemClassGen.doGenerate(e);
+ boolean _isLibrary = e.isLibrary();
+ boolean _not = (!_isLibrary);
+ if (_not) {
+ this.subsystemRunnerGen.doGenerate(e);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
new file mode 100644
index 000000000..f08d2faa3
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
@@ -0,0 +1,1394 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageHandler;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PortOperation;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.cpp.GeneratorOptions;
+import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
+import org.eclipse.etrice.generator.cpp.gen.Initialization;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CppExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private Initialization _initialization;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for (final ProtocolClass pc : _usedProtocolClasses) {
+ {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(pc);
+ String _path = this.roomExt.getPath(pc);
+ String path = (_generationTargetPath + _path);
+ String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc);
+ String _plus = ("generating ProtocolClass header \'" + _cppHeaderFileName);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ String _cppHeaderFileName_1 = this.stdExt.getCppHeaderFileName(pc);
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, pc);
+ this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
+ String _cppSourceFileName = this.stdExt.getCppSourceFileName(pc);
+ String _plus_4 = ("generating ProtocolClass source \'" + _cppSourceFileName);
+ String _plus_5 = (_plus_4 + "\' in \'");
+ String _plus_6 = (_plus_5 + path);
+ String _plus_7 = (_plus_6 + "\'");
+ this.logger.logInfo(_plus_7);
+ this.fileAccess.setOutputPath(path);
+ String _cppSourceFileName_1 = this.stdExt.getCppSourceFileName(pc);
+ CharSequence _generateSourceFile = this.generateSourceFile(root, pc);
+ this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ private CharSequence generateHeaderFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = pc.getName();
+ CharSequence _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"platforms/generic/etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/messaging/IRTObject.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/modelbase/PortBase.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/modelbase/InterfaceItemBase.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/messaging/Address.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/messaging/Message.h\"");
+ _builder.newLine();
+ _builder.append("#include <vector>");
+ _builder.newLine();
+ _builder.append("#include <string>");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("namespace etRuntime {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("class IEventReceiver;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode1 = pc.getUserCode1();
+ CharSequence _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _path = this.roomExt.getPath(dataClass);
+ _builder.append(_path, "");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("class ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("public:");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_equals) {
+ _builder.append("\t /* message IDs */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("static bool isValidEvtID(int evtId) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return ((MSG_MIN < evtId) && (evtId < MSG_MAX));");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("};");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("static bool isValidOutgoingEvtID(int evtId) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return ((MSG_MIN < evtId) && (evtId < ");
+ {
+ EList<Message> _incomingMessages = pc.getIncomingMessages();
+ int _size = _incomingMessages.size();
+ boolean _equals_1 = (_size == 0);
+ if (_equals_1) {
+ _builder.append("MSG_MAX");
+ } else {
+ _builder.append("IN_");
+ EList<Message> _incomingMessages_1 = pc.getIncomingMessages();
+ Message _get = _incomingMessages_1.get(0);
+ String _name_4 = _get.getName();
+ _builder.append(_name_4, " ");
+ }
+ }
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("};");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("static bool isValidIncomingEvtID(int evtId) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return ((");
+ {
+ EList<Message> _incomingMessages_2 = pc.getIncomingMessages();
+ int _size_1 = _incomingMessages_2.size();
+ boolean _equals_2 = (_size_1 == 0);
+ if (_equals_2) {
+ _builder.append("MSG_MAX");
+ } else {
+ _builder.append("IN_");
+ EList<Message> _incomingMessages_3 = pc.getIncomingMessages();
+ Message _get_1 = _incomingMessages_3.get(0);
+ String _name_5 = _get_1.getName();
+ _builder.append(_name_5, " ");
+ }
+ }
+ _builder.append(" <= evtId) && (evtId < MSG_MAX));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("};");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("static std::string getMessageString(int msg_id);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("private:");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("static std::string s_messageStrings[];");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ DetailCode _userCode2 = pc.getUserCode2();
+ CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ CharSequence _portClassDeclaration = this.portClassDeclaration(pc, Boolean.valueOf(false));
+ _builder.append(_portClassDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ CharSequence _portClassDeclaration_1 = this.portClassDeclaration(pc, Boolean.valueOf(true));
+ _builder.append(_portClassDeclaration_1, "");
+ _builder.newLineIfNotEmpty();
+ String _name_6 = pc.getName();
+ CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_6);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public CharSequence portClassDeclaration(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ PortClass pclass = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ String portClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue(), true);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("// ");
+ {
+ if ((conj).booleanValue()) {
+ _builder.append("conjugated ");
+ }
+ }
+ _builder.append("port class");
+ _builder.newLineIfNotEmpty();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("class ");
+ _builder.append(portClassName, "");
+ _builder.append(" : public etRuntime::PortBase {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(pclass, null));
+ if (_notEquals) {
+ _builder.append("\t");
+ DetailCode _userCode = pclass.getUserCode();
+ CharSequence _userCode_1 = this.helpers.userCode(_userCode);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append(" ");
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// constructors");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append(portClassName, " ");
+ _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true); ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append(portClassName, " ");
+ _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("virtual void receive(etRuntime::Message* m);");
+ _builder.newLine();
+ {
+ boolean _notEquals_1 = (!Objects.equal(pclass, null));
+ if (_notEquals_1) {
+ _builder.append("\t");
+ EList<Attribute> _attributes = pclass.getAttributes();
+ CharSequence _attributes_1 = this.helpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<PortOperation> _operations = pclass.getOperations();
+ CharSequence _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
+ _builder.append(_operationsDeclaration, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("// outgoing messages");
+ _builder.newLine();
+ {
+ List<Message> _outgoing = this.roomExt.getOutgoing(pc, (conj).booleanValue());
+ for(final Message m : _outgoing) {
+ _builder.append("\t");
+ CharSequence _sendMessageDeclaration = this.sendMessageDeclaration(m, (conj).booleanValue());
+ _builder.append(_sendMessageDeclaration, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("// ");
+ {
+ if ((conj).booleanValue()) {
+ _builder.append("conjugated ");
+ }
+ }
+ _builder.append("replicated port class");
+ _builder.newLineIfNotEmpty();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("class ");
+ _builder.append(replPortClassName, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("private:");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("int m_replication;");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append(portClassName, " ");
+ _builder.append("* m_ports; //dynamic array used instead of vector to avoid copy construction");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append(replPortClassName, " ");
+ _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<etRuntime::Address> addr, std::vector<etRuntime::Address> peerAddress);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("virtual ~");
+ _builder.append(replPortClassName, " ");
+ _builder.append("() {};");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("int getReplication() {\treturn m_replication; }");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx();\t}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append(portClassName, " ");
+ _builder.append(" get(int i) {return m_ports[i];}");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_equals) {
+ _builder.append("\t\t");
+ _builder.append(" ");
+ _builder.append("// outgoing messages");
+ _builder.newLine();
+ {
+ List<Message> _outgoing_1 = this.roomExt.getOutgoing(pc, (conj).booleanValue());
+ for(final Message m_1 : _outgoing_1) {
+ _builder.append("\t\t");
+ CharSequence _sendMessageDeclaration_1 = this.sendMessageDeclaration(m_1, (conj).booleanValue());
+ _builder.append(_sendMessageDeclaration_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence generateSourceFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* Source File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"");
+ String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc);
+ _builder.append(_cppHeaderFileName, " ");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("#include \"common/debugging/DebuggingService.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include <iostream>");
+ _builder.newLine();
+ {
+ boolean _isUseEtUnit = GeneratorOptions.isUseEtUnit();
+ if (_isUseEtUnit) {
+ _builder.append("\t");
+ _builder.append("extern \"C\" {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("#include \"etUnit.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("using namespace etRuntime;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode3 = pc.getUserCode3();
+ CharSequence _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_equals) {
+ _builder.append("\t");
+ DetailCode _userCode2 = pc.getUserCode2();
+ CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _portClassImplementation = this.portClassImplementation(pc, Boolean.valueOf(false));
+ _builder.append(_portClassImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ CharSequence _portClassImplementation_1 = this.portClassImplementation(pc, Boolean.valueOf(true));
+ _builder.append(_portClassImplementation_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
+ _builder.append(_generateDebugHelpersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence portClassImplementation(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ PortClass pclass = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ String portClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue(), true);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("// ");
+ {
+ if ((conj).booleanValue()) {
+ _builder.append("conjugated ");
+ }
+ }
+ _builder.append("port class");
+ _builder.newLineIfNotEmpty();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append(portClassName, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, Address addr, Address peerAddress, bool doRegistration)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(": ");
+ CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(pclass, "0");
+ _builder.append(_generateConstructorInitalizerList, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ {
+ boolean _notEquals = (!Objects.equal(pclass, null));
+ if (_notEquals) {
+ EList<Attribute> _attributes = pclass.getAttributes();
+ CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes, false);
+ _builder.append(_attributeInitialization, " ");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (doRegistration) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append(portClassName, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, Address addr, Address peerAddress, bool doRegistration)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(": ");
+ CharSequence _generateConstructorInitalizerList_1 = this.generateConstructorInitalizerList(pclass, "idx");
+ _builder.append(_generateConstructorInitalizerList_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ {
+ boolean _notEquals_1 = (!Objects.equal(pclass, null));
+ if (_notEquals_1) {
+ EList<Attribute> _attributes_1 = pclass.getAttributes();
+ CharSequence _attributeInitialization_1 = this._initialization.attributeInitialization(_attributes_1, false);
+ _builder.append(_attributeInitialization_1, " ");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (doRegistration) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("::receive(Message* msg) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (! ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.append("::");
+ {
+ if ((conj).booleanValue()) {
+ _builder.append("isValidOutgoingEvtID");
+ } else {
+ _builder.append("isValidIncomingEvtID");
+ }
+ }
+ _builder.append("(msg->getEvtId())) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("std::cout << \"unknown\" << std::endl;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("else {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("if (msg->hasDebugFlagSet()) {\t\t\t// TODO: model switch for activation of this flag");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), ");
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("::getMessageString(msg->getEvtId()));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive) {
+ _builder.append("\t\t");
+ _builder.append("switch (msg->getEvtId()) {");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, (conj).booleanValue());
+ for(final MessageHandler hdlr : _receiveHandlers) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("case ");
+ String _name_2 = pc.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("::");
+ Message _msg = hdlr.getMsg();
+ String _codeName = this.roomExt.getCodeName(_msg);
+ _builder.append(_codeName, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("default:");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("getActor().receiveEvent(this, msg->getEvtId(),\tmsg->getData());");
+ _builder.newLine();
+ {
+ boolean _handlesReceive_1 = this.roomExt.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive_1) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _notEquals_2 = (!Objects.equal(pclass, null));
+ if (_notEquals_2) {
+ EList<PortOperation> _operations = pclass.getOperations();
+ CharSequence _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("// sent messages");
+ _builder.newLine();
+ {
+ List<Message> _outgoing = this.roomExt.getOutgoing(pc, (conj).booleanValue());
+ for(final Message m : _outgoing) {
+ String _name_3 = pc.getName();
+ CharSequence _sendMessage = this.sendMessage(m, _name_3, portClassName, (conj).booleanValue());
+ _builder.append(_sendMessage, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("// ");
+ {
+ if ((conj).booleanValue()) {
+ _builder.append("conjugated ");
+ }
+ }
+ _builder.append("replicated port class");
+ _builder.newLineIfNotEmpty();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append(replPortClassName, "");
+ _builder.append("::");
+ _builder.append(replPortClassName, "");
+ _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<Address> addr, std::vector<Address> peerAddress) ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(": m_replication(addr.size()),");
+ _builder.newLine();
+ _builder.append(" \t ");
+ _builder.append("m_ports()");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("char numstr[10]; // enough to hold all numbers up to 32-bits");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("m_ports = reinterpret_cast<");
+ _builder.append(portClassName, " ");
+ _builder.append("*> (new char[sizeof(");
+ _builder.append(portClassName, " ");
+ _builder.append(") * addr.size()]);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (int i = 0; i < m_replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("snprintf(numstr, sizeof(numstr), \"%d\", i);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("//placement new to avoid copy construction, therefore no vector is used");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("new (&m_ports[i]) ");
+ _builder.append(portClassName, " ");
+ _builder.append("(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("// outgoing messages");
+ _builder.newLine();
+ {
+ List<Message> _outgoing_1 = this.roomExt.getOutgoing(pc, (conj).booleanValue());
+ for(final Message m_1 : _outgoing_1) {
+ CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m_1, replPortClassName);
+ _builder.append(_messageSignatureDefinition, "");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<m_replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("m_ports[i].");
+ CharSequence _messageCall = this.messageCall(m_1);
+ _builder.append(_messageCall, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence generateConstructorInitalizerList(final PortClass pc, final String index) {
+ ArrayList<CharSequence> _arrayList = new ArrayList<CharSequence>();
+ ArrayList<CharSequence> initializerList = _arrayList;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("PortBase(actor, parent, name, localId, ");
+ _builder.append(index, "");
+ _builder.append(", addr, peerAddress)");
+ initializerList.add(_builder);
+ boolean _notEquals = (!Objects.equal(pc, null));
+ if (_notEquals) {
+ EList<Attribute> _attributes = pc.getAttributes();
+ for (final Attribute attrib : _attributes) {
+ CharSequence _attributeInitialization = this._initialization.attributeInitialization(attrib, false);
+ initializerList.add(_attributeInitialization);
+ }
+ }
+ StringConcatenation _builder_1 = new StringConcatenation();
+ String _join = IterableExtensions.join(initializerList, ",\n");
+ _builder_1.append(_join, "");
+ _builder_1.newLineIfNotEmpty();
+ return _builder_1;
+ }
+
+ private CharSequence messageCall(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ if (_notEquals) {
+ _builder.append(" ");
+ VarDecl _data_1 = m.getData();
+ String _name_1 = _data_1.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
+
+ private CharSequence generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* message names as strings for debugging (generate MSC) */");
+ _builder.newLine();
+ _builder.append("std::string ");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("::s_messageStrings[] ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("= {\"MIN\", ");
+ _builder.newLine();
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\t\t ");
+ _builder.append("\"");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("\",");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\t\t ");
+ _builder.append("\"");
+ String _name_2 = m_1.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("\",");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t ");
+ _builder.append("\"MAX\"};");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("std::string ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("::getMessageString(int msg_id) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return s_messageStrings[msg_id];");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("} else {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// id out of range");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence messageSignature(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isPriv = m.isPriv();
+ if (_isPriv) {
+ _builder.append("private:");
+ } else {
+ _builder.append("public:");
+ }
+ }
+ _builder.append(" void ");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ if (_notEquals) {
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ _builder.append(" ");
+ VarDecl _data_2 = m.getData();
+ String _name_1 = _data_2.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
+
+ public CharSequence messageSignatureExplicit(final Message m) {
+ CharSequence _xblockexpression = null;
+ {
+ VarDecl _data = m.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ DataClass dc = ((DataClass) _type);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("public: void ");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ DataClass _base = dc.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ DataClass _base_1 = dc.getBase();
+ String _typeName = this._typeHelpers.typeName(_base_1);
+ _builder.append(_typeName, "");
+ _builder.append(" _super, ");
+ }
+ }
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ boolean _hasElements = false;
+ for(final Attribute a : _attributes) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_1);
+ _builder.append(_typeName_1, "");
+ {
+ int _size = a.getSize();
+ boolean _greaterThan = (_size > 1);
+ if (_greaterThan) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence messageSignatureDefinition(final Message m, final String classPrefix) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("void ");
+ _builder.append(classPrefix, "");
+ _builder.append("::");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ if (_notEquals) {
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ _builder.append(" ");
+ VarDecl _data_2 = m.getData();
+ String _name_1 = _data_2.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
+
+ public CharSequence messageSignatureExplicitDefinition(final Message m, final String classPrefix) {
+ CharSequence _xblockexpression = null;
+ {
+ VarDecl _data = m.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ DataClass dc = ((DataClass) _type);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("void ");
+ _builder.append(classPrefix, "");
+ _builder.append("::");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ DataClass _base = dc.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ DataClass _base_1 = dc.getBase();
+ String _typeName = this._typeHelpers.typeName(_base_1);
+ _builder.append(_typeName, "");
+ _builder.append(" _super, ");
+ }
+ }
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ boolean _hasElements = false;
+ for(final Attribute a : _attributes) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_1);
+ _builder.append(_typeName_1, "");
+ {
+ int _size = a.getSize();
+ boolean _greaterThan = (_size > 1);
+ if (_greaterThan) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence sendMessageDeclaration(final Message m, final boolean conj) {
+ StringConcatenation _builder = new StringConcatenation();
+ CharSequence _messageSignature = this.messageSignature(m);
+ _builder.append(_messageSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _and = false;
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ if (!_notEquals) {
+ _and = false;
+ } else {
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ _and = (_notEquals && (_type instanceof DataClass));
+ }
+ if (_and) {
+ CharSequence _messageSignatureExplicit = this.messageSignatureExplicit(m);
+ _builder.append(_messageSignatureExplicit, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence sendMessage(final Message m, final String portClassName, final String classPrefix, final boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String _xifexpression = null;
+ if (conj) {
+ _xifexpression = "IN";
+ } else {
+ _xifexpression = "OUT";
+ }
+ String dir = _xifexpression;
+ MessageHandler hdlr = this.roomExt.getSendHandler(m, conj);
+ StringConcatenation _builder = new StringConcatenation();
+ CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m, classPrefix);
+ _builder.append(_messageSignatureDefinition, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(hdlr, null));
+ if (_notEquals) {
+ _builder.append("\t");
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t");
+ _builder.append("DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t\t\t\t\t\t\t\t\t\t\t\t ");
+ _builder.append(portClassName, " ");
+ _builder.append("::getMessageString(");
+ _builder.append(portClassName, " ");
+ _builder.append("::");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name = m.getName();
+ _builder.append(_name, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (getPeerAddress().isValid()){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ VarDecl _data = m.getData();
+ boolean _equals = Objects.equal(_data, null);
+ if (_equals) {
+ _builder.append("getPeerMsgReceiver()->receive(new Message(getPeerAddress(), ");
+ _builder.append(portClassName, " ");
+ _builder.append("::");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ } else {
+ _builder.append("getPeerMsgReceiver()->receive(new Message(getPeerAddress(),");
+ _builder.append(portClassName, " ");
+ _builder.append("::");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_2 = m.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(", ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(" ");
+ _builder.append("reinterpret_cast<void*>(");
+ {
+ boolean _and = false;
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ boolean _isRef = _refType.isRef();
+ boolean _not = (!_isRef);
+ if (!_not) {
+ _and = false;
+ } else {
+ VarDecl _data_2 = m.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ DataType _type = _refType_1.getType();
+ boolean _not_1 = (!(_type instanceof PrimitiveType));
+ _and = (_not && _not_1);
+ }
+ if (_and) {
+ _builder.append("&");
+ }
+ }
+ VarDecl _data_3 = m.getData();
+ String _name_3 = _data_3.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("),");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(" ");
+ _builder.append("sizeof(");
+ VarDecl _data_4 = m.getData();
+ RefableType _refType_2 = _data_4.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ String _typeName = this._typeHelpers.typeName(_type_1);
+ _builder.append(_typeName, " ");
+ _builder.append(")));");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _and_1 = false;
+ VarDecl _data_5 = m.getData();
+ boolean _notEquals_1 = (!Objects.equal(_data_5, null));
+ if (!_notEquals_1) {
+ _and_1 = false;
+ } else {
+ VarDecl _data_6 = m.getData();
+ RefableType _refType_3 = _data_6.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ _and_1 = (_notEquals_1 && (_type_2 instanceof DataClass));
+ }
+ if (_and_1) {
+ CharSequence _messageSignatureExplicitDefinition = this.messageSignatureExplicitDefinition(m, classPrefix);
+ _builder.append(_messageSignatureExplicitDefinition, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_4 = m.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("(");
+ VarDecl _data_7 = m.getData();
+ RefableType _refType_4 = _data_7.getRefType();
+ DataType _type_3 = _refType_4.getType();
+ String _name_5 = _type_3.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("(");
+ {
+ VarDecl _data_8 = m.getData();
+ RefableType _refType_5 = _data_8.getRefType();
+ DataType _type_4 = _refType_5.getType();
+ DataClass _base = ((DataClass) _type_4).getBase();
+ boolean _notEquals_2 = (!Objects.equal(_base, null));
+ if (_notEquals_2) {
+ _builder.append("_super, ");
+ }
+ }
+ {
+ VarDecl _data_9 = m.getData();
+ RefableType _refType_6 = _data_9.getRefType();
+ DataType _type_5 = _refType_6.getType();
+ EList<Attribute> _attributes = ((DataClass) _type_5).getAttributes();
+ boolean _hasElements = false;
+ for(final Attribute a : _attributes) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(", ", " ");
+ }
+ String _name_6 = a.getName();
+ _builder.append(_name_6, " ");
+ }
+ }
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public String getMessageID(final Message msg, final InterfaceItem item) {
+ if ((item instanceof Port)) {
+ Port p = ((Port) item);
+ String _xifexpression = null;
+ boolean _isConjugated = p.isConjugated();
+ if (_isConjugated) {
+ _xifexpression = "OUT_";
+ } else {
+ _xifexpression = "IN_";
+ }
+ String direction = _xifexpression;
+ GeneralProtocolClass _protocol = p.getProtocol();
+ String _name = _protocol.getName();
+ String _name_1 = msg.getName();
+ String _plus = (direction + _name_1);
+ return this.enumInUse(_name, _plus);
+ } else {
+ if ((item instanceof SAPRef)) {
+ SAPRef sap = ((SAPRef) item);
+ ProtocolClass _protocol_1 = sap.getProtocol();
+ String _name_2 = _protocol_1.getName();
+ String _name_3 = msg.getName();
+ String _plus_1 = ("OUT_" + _name_3);
+ return this.enumInUse(_name_2, _plus_1);
+ } else {
+ if ((item instanceof SPPRef)) {
+ SPPRef spp = ((SPPRef) item);
+ ProtocolClass _protocol_2 = spp.getProtocol();
+ String _name_4 = _protocol_2.getName();
+ String _name_5 = msg.getName();
+ String _plus_2 = ("IN_" + _name_5);
+ return this.enumInUse(_name_4, _plus_2);
+ }
+ }
+ }
+ return "unknown interface item";
+ }
+
+ public String enumInUse(final String namespace, final String member) {
+ String _plus = (namespace + "::");
+ return (_plus + member);
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
index 73db99e0d..f128e3e86 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
@@ -26,6 +26,7 @@ import org.eclipse.etrice.generator.base.IDataConfiguration
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.core.room.ExternalType
class ConfigGenAddon {
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
index 2055f5b32..4e6a81443 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
@@ -77,6 +77,10 @@ class JavaExtensions implements ILanguageExtension {
return true
}
+ override boolean usesPointers() {
+ return false
+ }
+
override String genEnumeration(String name, List<Pair<String, String>> entries) {
'''
«FOR entry: entries»
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaTranslationProvider.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaTranslationProvider.java
index be430db18..fb6e088cb 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaTranslationProvider.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaTranslationProvider.java
@@ -14,15 +14,11 @@ package org.eclipse.etrice.generator.java.gen;
import java.util.ArrayList;
-import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.DetailCode;
import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.generator.base.DefaultTranslationProvider;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-
-import com.google.inject.Inject;
/**
* @author hrentz
@@ -30,8 +26,6 @@ import com.google.inject.Inject;
*/
public class JavaTranslationProvider extends DefaultTranslationProvider {
- @Inject ILogger logger;
-
@Override
public boolean translateMembers() {
return true;
@@ -71,14 +65,7 @@ public class JavaTranslationProvider extends DefaultTranslationProvider {
if (tag.equals("ifitem.index"))
return "ifitem.getIdx()";
- if (tag.equals("MODEL_LOCATION")) {
- return RoomNameProvider.getDetailCodeLocation(code);
- }
-
- logger.logInfo("unrecognized tag '"+tag+"' in "
- +RoomNameProvider.getDetailCodeLocation(code)+" of "
- +RoomNameProvider.getClassLocation(RoomNameProvider.getModelClass(code)));
- return TAG_START+"?"+tag+"?"+TAG_END;
+ return super.translateTag(tag, code);
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
index 38208cb91..69889bc26 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
@@ -18,8 +18,10 @@ import org.eclipse.etrice.core.room.Message
import org.eclipse.etrice.core.room.ProtocolClass
import org.eclipse.etrice.core.room.PrimitiveType
import org.eclipse.etrice.core.room.DataClass
+
import org.eclipse.etrice.core.genmodel.base.ILogger
import org.eclipse.etrice.core.genmodel.etricegen.Root
+
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.generator.generic.RoomExtensions
@@ -265,4 +267,4 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«ENDIF»
'''
}
-} \ No newline at end of file
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
index 0b820434e..a9ab1274e 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -128,6 +128,10 @@ public class JavaExtensions implements ILanguageExtension {
return true;
}
+ public boolean usesPointers() {
+ return false;
+ }
+
public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
StringConcatenation _builder = new StringConcatenation();
{
diff --git a/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/Activator.java b/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/Activator.java
index 1f897b7e5..abd7e0bd9 100644
--- a/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/Activator.java
+++ b/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/Activator.java
@@ -9,7 +9,7 @@ import org.osgi.framework.BundleContext;
public class Activator extends AbstractUIPlugin {
// The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.etrice.generator.launch.java"; //$NON-NLS-1$
+ public static final String PLUGIN_ID = "org.eclipse.etrice.generator.launch.c"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
diff --git a/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorMainTab.java b/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorMainTab.java
index 9d39aef9d..b67abc2d8 100644
--- a/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorMainTab.java
+++ b/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorMainTab.java
@@ -26,7 +26,10 @@ public class CGeneratorMainTab extends GeneratorMainTab {
*/
@Override
protected boolean isValidModelFile(IResource resource) {
- return resource.getName().endsWith(".room");
+ return resource.getName().endsWith(".room")
+ || resource.getName().endsWith(".config")
+ || resource.getName().endsWith(".etphys")
+ || resource.getName().endsWith(".etmap");
}
}
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/.classpath b/plugins/org.eclipse.etrice.generator.launch.cpp/.classpath
new file mode 100644
index 000000000..8a8f1668c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/.gitignore b/plugins/org.eclipse.etrice.generator.launch.cpp/.gitignore
new file mode 100644
index 000000000..f68b3dddc
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/.gitignore
@@ -0,0 +1,2 @@
+bin
+
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/.project b/plugins/org.eclipse.etrice.generator.launch.cpp/.project
new file mode 100644
index 000000000..1b237126a
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.generator.launch.cpp</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.etrice.generator.launch.cpp/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..dcfadd03c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Tue Aug 30 16:50:14 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.launch.cpp/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..bcc82534f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: eTrice Cpp Generator Launcher
+Bundle-SymbolicName: org.eclipse.etrice.generator.launch.cpp;singleton:=true
+Bundle-Version: 0.2.0.qualifier
+Bundle-Activator: org.eclipse.etrice.generator.launch.cpp.Activator
+Require-Bundle: org.eclipse.etrice.generator;bundle-version="0.1.0",
+ org.eclipse.etrice.generator.cpp;bundle-version="0.1.0",
+ org.eclipse.etrice.generator.launch;bundle-version="0.1.0",
+ org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.jdt.ui;bundle-version="3.7.0",
+ org.eclipse.jdt.core;bundle-version="3.7.0",
+ org.eclipse.core.variables;bundle-version="3.2.500",
+ org.eclipse.etrice.core.genmodel;bundle-version="0.2.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.eclipse.jdt.launching,
+ org.eclipse.ui.dialogs
+Bundle-Vendor: eTrice (Incubation)
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/build.properties b/plugins/org.eclipse.etrice.generator.launch.cpp/build.properties
new file mode 100644
index 000000000..285b8bf47
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/icons/eTrice-launch.gif b/plugins/org.eclipse.etrice.generator.launch.cpp/icons/eTrice-launch.gif
new file mode 100644
index 000000000..ca3906465
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/icons/eTrice-launch.gif
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/plugin.xml b/plugins/org.eclipse.etrice.generator.launch.cpp/plugin.xml
new file mode 100644
index 000000000..7e7991e15
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/plugin.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.eclipse.etrice.generator.launch.cpp.CppGeneratorLaunchConfigurationDelegate"
+ delegateDescription="Generates C++ source code from ROOM models"
+ delegateName="eTrice C++ Generator Delegate"
+ id="org.eclipse.etrice.generator.launch.cpp.launchConfigurationType"
+ modes="run,debug"
+ name="eTrice C++ Generator">
+ </launchConfigurationType>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ configTypeID="org.eclipse.etrice.generator.launch.cpp.launchConfigurationType"
+ icon="icons/eTrice-launch.gif"
+ id="org.eclipse.etrice.generator.launch.cpp.launchConfigurationTypeImage">
+ </launchConfigurationTypeImage>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ class="org.eclipse.etrice.generator.launch.cpp.CppGeneratorLaunchConfigurationTabGroup"
+ description="Tab Group for eTrice C++ Generator Launch Configurations"
+ id="org.eclipse.etrice.generator.launch.cpp.launchConfigurationTabGroup"
+ type="org.eclipse.etrice.generator.launch.cpp.launchConfigurationType">
+ </launchConfigurationTabGroup>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/Activator.java b/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/Activator.java
new file mode 100644
index 000000000..54a7a8b98
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/Activator.java
@@ -0,0 +1,53 @@
+package org.eclipse.etrice.generator.launch.cpp;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.etrice.generator.launch.cpp"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public void log(Exception e) {
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorConfigTab.java b/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorConfigTab.java
new file mode 100644
index 000000000..5ae373e25
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorConfigTab.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.launch.cpp;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.etrice.generator.launch.GeneratorConfigTab;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class CppGeneratorConfigTab extends GeneratorConfigTab {
+
+ public static final String ETUNIT = "etUnit";
+
+ private Button useEtUnit;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ @Override
+ public String getName() {
+ return "C++ Generator";
+ }
+
+ protected void addFurtherControls(Composite mainComposite) {
+
+ useEtUnit = createCheckButton(mainComposite, "use etUnit");
+ useEtUnit.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));
+ useEtUnit.addSelectionListener(new UpdateConfig());
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ super.initializeFrom(configuration);
+
+ try {
+ useEtUnit.setSelection(configuration.getAttribute(ETUNIT, false));
+ }
+ catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ super.performApply(configuration);
+
+ configuration.setAttribute(ETUNIT, useEtUnit.getSelection());
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorLaunchConfigurationDelegate.java b/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorLaunchConfigurationDelegate.java
new file mode 100644
index 000000000..b7906d526
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorLaunchConfigurationDelegate.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.launch.cpp;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.etrice.generator.base.ILineOutput;
+import org.eclipse.etrice.generator.cpp.Main;
+import org.eclipse.etrice.generator.launch.GeneratorLaunchConfigurationDelegate;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class CppGeneratorLaunchConfigurationDelegate extends GeneratorLaunchConfigurationDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.generator.launch.GeneratorLaunchConfigurationDelegate#addArguments(org.eclipse.debug.core.ILaunchConfiguration, java.lang.StringBuffer)
+ */
+ @SuppressWarnings("deprecation")
+ @Override
+ protected void addArguments(ILaunchConfiguration configuration, StringBuffer argString) throws CoreException {
+ if (configuration.getAttribute(CppGeneratorConfigTab.LIB, false)) {
+ argString.append(" "+Main.OPTION_LIB);
+ }
+ if (configuration.getAttribute(CppGeneratorConfigTab.SAVE_GEN_MODEL, false)) {
+ argString.append(" "+Main.OPTION_SAVE_GEN_MODEL);
+ argString.append(" "+configuration.getAttribute(CppGeneratorConfigTab.GEN_MODEL_PATH, "?"));
+ }
+ if (configuration.getAttribute(CppGeneratorConfigTab.GEN_DOCUMENTATION, false)
+ || configuration.getAttribute(CppGeneratorConfigTab.GEN_INSTANCE_DIAGRAM, false))
+ argString.append(" "+Main.OPTION_DOCUMENTATION);
+ if (configuration.getAttribute(CppGeneratorConfigTab.ETUNIT, false))
+ argString.append(" "+Main.OPTION_ETUNIT);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.generator.launch.GeneratorLaunchConfigurationDelegate#runGenerator(java.lang.String[], org.eclipse.etrice.generator.launch.ILineOutput)
+ */
+ @Override
+ protected void runGenerator(String[] args, ILineOutput out) {
+ org.eclipse.etrice.generator.cpp.Main.setOutput(out);
+ org.eclipse.etrice.generator.cpp.Main.setTerminateOnError(false);
+ org.eclipse.etrice.generator.cpp.Main.main(args);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.generator.launch.GeneratorLaunchConfigurationDelegate#getConsoleName()
+ */
+ @Override
+ protected String getConsoleName() {
+ return "eTrice C++ Generator Console";
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorLaunchConfigurationTabGroup.java b/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorLaunchConfigurationTabGroup.java
new file mode 100644
index 000000000..930e2fd32
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorLaunchConfigurationTabGroup.java
@@ -0,0 +1,24 @@
+package org.eclipse.etrice.generator.launch.cpp;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.EnvironmentTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.debug.ui.RefreshTab;
+
+public class CppGeneratorLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+ @Override
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new CppGeneratorMainTab(),
+ new CppGeneratorConfigTab(),
+ new RefreshTab(),
+ new EnvironmentTab(),
+ new CommonTab()
+ };
+ setTabs(tabs);
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorMainTab.java b/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorMainTab.java
new file mode 100644
index 000000000..052b62a5f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/src/org/eclipse/etrice/generator/launch/cpp/CppGeneratorMainTab.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.launch.cpp;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.etrice.generator.launch.GeneratorMainTab;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class CppGeneratorMainTab extends GeneratorMainTab {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.generator.launch.GeneratorMainTab#isValidModelFile(org.eclipse.core.resources.IResource)
+ */
+ @Override
+ protected boolean isValidModelFile(IResource resource) {
+ return resource.getName().endsWith(".room")
+ || resource.getName().endsWith(".config")
+ || resource.getName().endsWith(".etphys")
+ || resource.getName().endsWith(".etmap");
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java
index 71b8cb415..a77348eec 100644
--- a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java
+++ b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java
@@ -38,6 +38,9 @@ import org.eclipse.ui.dialogs.ContainerSelectionDialog;
public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab {
protected class UpdateConfig implements SelectionListener {
+ public UpdateConfig() {
+ }
+
@Override
public void widgetSelected(SelectionEvent e) {
validate();
@@ -63,12 +66,12 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
public static final String LIB = "Lib";
public static final String DEBUG = "Debug";
- protected Button libButton;
- protected Button documentationButton;
- protected Button saveGenModel;
- protected Text genModelPath;
- protected Button browsePath;
- protected Button debugButton;
+ private Button libButton;
+ private Button documentationButton;
+ private Button saveGenModel;
+ private Text genModelPath;
+ private Button browsePath;
+ private Button debugButton;
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
@@ -131,6 +134,14 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
debugButton = createCheckButton(mainComposite, "debug output");
debugButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));
debugButton.addSelectionListener(new UpdateConfig());
+
+ addFurtherControls(mainComposite);
+ }
+
+ /**
+ * @param mainComposite
+ */
+ protected void addFurtherControls(Composite mainComposite) {
}
/**
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
index 8a27bec09..433555bbb 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
@@ -161,7 +161,7 @@ public abstract class AbstractGenerator implements IResourceURIAcceptor {
GeneratorModelBuilder gmb = new GeneratorModelBuilder(logger, diagnostician);
Root gmRoot = gmb.createGeneratorModel(rml, asLibrary);
if (diagnostician.isFailed()) {
- logger.logInfo("validation failed during build of generator model");
+ logger.logError("validation failed during build of generator model", null);
logger.logError("-- terminating", null);
return null;
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DefaultTranslationProvider.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DefaultTranslationProvider.java
index 16de1af80..9fabb14c7 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DefaultTranslationProvider.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DefaultTranslationProvider.java
@@ -14,6 +14,8 @@ package org.eclipse.etrice.generator.base;
import java.util.ArrayList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.DetailCode;
@@ -21,8 +23,12 @@ import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.Operation;
+import com.google.inject.Inject;
+
public class DefaultTranslationProvider implements ITranslationProvider {
+ @Inject ILogger logger;
+
@Override
public boolean translateMembers() {
return false;
@@ -60,7 +66,14 @@ public class DefaultTranslationProvider implements ITranslationProvider {
@Override
public String translateTag(String tag, DetailCode code) {
- return TAG_START+tag+TAG_END;
+ if (tag.equals("MODEL_LOCATION")) {
+ return RoomNameProvider.getDetailCodeLocation(code);
+ }
+
+ logger.logInfo("unrecognized tag '"+tag+"' in "
+ +RoomNameProvider.getDetailCodeLocation(code)+" of "
+ +RoomNameProvider.getClassLocation(RoomNameProvider.getModelClass(code)));
+ return TAG_START+"?"+tag+"?"+TAG_END;
}
@Override
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DetailCodeTranslator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DetailCodeTranslator.java
index 72ff3648a..c721f8dbb 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DetailCodeTranslator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DetailCodeTranslator.java
@@ -129,7 +129,7 @@ public class DetailCodeTranslator {
}
else {
Operation operation = name2op.get(token);
- if (operation!=null) {
+ if (operation!=null && operation.eContainer() instanceof ActorClass) {
ArrayList<String> args = getArgs(text, curr);
if (args!=null && operation.getArguments().size()==args.size()) {
// recursively apply this algorithm to each argument
@@ -270,7 +270,7 @@ public class DetailCodeTranslator {
String token = getToken(text, curr);
- List<Message> messages = RoomHelpers.getMessageList(item, outgoing);
+ List<Message> messages = RoomHelpers.getMessageListDeep(item, outgoing);
for (Message message : messages) {
if (message.getName().equals(token))
return message;
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
index 3a69c5856..05bb562d9 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
@@ -78,7 +78,7 @@ class GenericStateMachineGenerator {
return langExt.genEnumeration("chain_ids", list)
}
- def private genTriggerConstants(ExpandedActorClass xpac) {
+ def genTriggerConstants(ExpandedActorClass xpac) {
val triggers = if (langExt.usesInheritance)
xpac.getOwnTriggers() else xpac.triggers
@@ -92,13 +92,41 @@ class GenericStateMachineGenerator {
}
def genStateMachine(ExpandedActorClass xpac) {
+ xpac.genStateMachine(true)
+ }
+
+ def genStateMachine(ExpandedActorClass xpac, boolean shallGenerateOneFile) {
val ac = xpac.actorClass
val async = ac.commType==ActorCommunicationType::ASYNCHRONOUS
val eventDriven = ac.commType==ActorCommunicationType::EVENT_DRIVEN
val handleEvents = async || eventDriven
-
+ val opScope = langExt.operationScope(ac.name, false)
+ val opScopePriv = if (langExt.usesInheritance)
+ opScope
+ else
+ ""
+ val publicIf = if (langExt.usesInheritance)
+ langExt.accessLevelPublic
+ else
+ langExt.accessLevelPrivate
+ val privAccess = langExt.accessLevelPrivate
+ val self = langExt.selfPointer(ac.name, true)
+ val selfOnly = langExt.selfPointer(ac.name, false)
+ val getLocalId = if (langExt.usesInheritance) {
+ if (langExt.usesPointers)
+ "->getLocalId()"
+ else
+ ".getLocalId()"
+ }
+ else
+ "->localId"
+ val ifItemPtr = "InterfaceItemBase"+langExt.pointerLiteral()
+ val constIfItemPtr = if (langExt.usesPointers)
+ "const "+ifItemPtr
+ else
+ ifItemPtr
'''
-
+ «IF shallGenerateOneFile»
/* state IDs */
«xpac.genStateIdConstants»
@@ -107,6 +135,7 @@ class GenericStateMachineGenerator {
/* triggers */
«xpac.genTriggerConstants»
+ «ENDIF»
«genExtra(xpac)»
@@ -122,7 +151,7 @@ class GenericStateMachineGenerator {
«IF (!langExt.usesInheritance || xpac.isOwnObject(tr)) && tr.hasActionCode()»
«var start = xpac.getChain(tr).transition»
«var hasArgs = start instanceof NonInitialTransition && !(start instanceof GuardedTransition)»
- «langExt.accessLevelProtected»void «tr.getActionCodeOperationName()»(«langExt.selfPointer(ac.name, hasArgs)»«IF hasArgs»InterfaceItemBase ifitem«transitionChainGenerator.generateArgumentList(xpac, tr)»«ENDIF») {
+ «langExt.accessLevelProtected»void «opScopePriv»«tr.getActionCodeOperationName()»(«langExt.selfPointer(ac.name, hasArgs)»«IF hasArgs»«constIfItemPtr» ifitem«transitionChainGenerator.generateArgumentList(xpac, tr)»«ENDIF») {
«AbstractGenerator::getInstance().getTranslatedCode(tr.action)»
}
«ENDIF»
@@ -135,7 +164,7 @@ class GenericStateMachineGenerator {
* @param to - the final parent state
* @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
*/
- «langExt.accessLevelPrivate»void exitTo(«langExt.selfPointer(ac.name, true)»int current, int to, boolean handler) {
+ «privAccess»void «opScopePriv»exitTo(«self»int current, int to, «boolType» handler) {
while (current!=to) {
switch (current) {
«FOR state : xpac.stateMachine.getBaseStateList()»
@@ -156,7 +185,7 @@ class GenericStateMachineGenerator {
* @param generic_data - the generic data pointer
* @return the ID of the final state
*/
- «langExt.accessLevelPrivate»int executeTransitionChain(«langExt.selfPointer(ac.name, true)»int chain«IF handleEvents», InterfaceItemBase ifitem, «langExt.voidPointer» generic_data«ENDIF») {
+ «privAccess»int «opScopePriv»executeTransitionChain(«self»int chain«IF handleEvents», «constIfItemPtr» ifitem, «langExt.voidPointer» generic_data«ENDIF») {
switch (chain) {
«var allchains = xpac.getTransitionChains()»
«FOR tc : allchains»
@@ -175,7 +204,7 @@ class GenericStateMachineGenerator {
* @param handler - entry code is executed if not handler
* @return - the ID of the final leaf state
*/
- «langExt.accessLevelPrivate»int enterHistory(«langExt.selfPointer(ac.name, true)»int state, boolean handler, boolean skip_entry) {
+ «privAccess»int «opScopePriv»enterHistory(«self»int state, «boolType» handler, «boolType» skip_entry) {
while («langExt.booleanConstant(true)») {
switch (state) {
«FOR state : xpac.stateMachine.getBaseStateList()»
@@ -211,25 +240,25 @@ class GenericStateMachineGenerator {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- «IF langExt.usesInheritance»«langExt.accessLevelPublic»«ELSE»«langExt.accessLevelPrivate»«ENDIF»void executeInitTransition(«langExt.selfPointer(ac.name, false)») {
+ «publicIf»void «opScope»executeInitTransition(«selfOnly») {
«var initt = xpac.stateMachine.getInitTransition()»
int chain = «xpac.getChain(initt).getChainId()»;
- int next = executeTransitionChain(«langExt.selfPointer(true)»chain«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
- next = enterHistory(«langExt.selfPointer(true)»next, «langExt.booleanConstant(false)», «langExt.booleanConstant(false)»);
+ int next = «opScopePriv»executeTransitionChain(«langExt.selfPointer(true)»chain«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
+ next = «opScopePriv»enterHistory(«langExt.selfPointer(true)»next, «langExt.booleanConstant(false)», «langExt.booleanConstant(false)»);
setState(«langExt.selfPointer(true)»next);
}
/* receiveEvent contains the main implementation of the FSM */
- «IF langExt.usesInheritance»«langExt.accessLevelPublic»«ELSE»«langExt.accessLevelPrivate»«ENDIF»void receiveEvent(«langExt.selfPointer(ac.name, handleEvents)»«IF handleEvents»InterfaceItemBase ifitem, int evt, «langExt.voidPointer» generic_data«ENDIF») {
+ «publicIf»void «opScope»receiveEvent(«langExt.selfPointer(ac.name, handleEvents)»«IF handleEvents»«ifItemPtr» ifitem, int evt, «langExt.voidPointer» generic_data«ENDIF») {
«IF async»
- int trigger = (ifitem==«langExt.nullPointer»)? POLLING : «IF langExt.usesInheritance»ifitem.getLocalId()«ELSE»ifitem->localId«ENDIF» + EVT_SHIFT*evt;
+ int trigger = (ifitem==«langExt.nullPointer»)? POLLING : ifitem«getLocalId» + EVT_SHIFT*evt;
«ELSEIF eventDriven»
- int trigger = «IF langExt.usesInheritance»ifitem.getLocalId()«ELSE»ifitem->localId«ENDIF» + EVT_SHIFT*evt;
+ int trigger = ifitem«getLocalId» + EVT_SHIFT*evt;
«ENDIF»
int chain = NOT_CAUGHT;
int catching_state = NO_STATE;
- boolean is_handler = «langExt.booleanConstant(false)»;
- boolean skip_entry = «langExt.booleanConstant(false)»;
+ «boolType» is_handler = «langExt.booleanConstant(false)»;
+ «boolType» skip_entry = «langExt.booleanConstant(false)»;
«IF handleEvents»
if (!handleSystemEvent(ifitem, evt, generic_data)) {
@@ -239,9 +268,9 @@ class GenericStateMachineGenerator {
«genStateSwitch(xpac)»
«ENDIF»
if (chain != NOT_CAUGHT) {
- exitTo(«langExt.selfPointer(true)»«langExt.memberAccess»state, catching_state, is_handler);
- int next = executeTransitionChain(«langExt.selfPointer(true)»chain«IF handleEvents», ifitem, generic_data«ENDIF»);
- next = enterHistory(«langExt.selfPointer(true)»next, is_handler, skip_entry);
+ «opScopePriv»exitTo(«langExt.selfPointer(true)»getState(«langExt.selfPointer(false)»), catching_state, is_handler);
+ int next = «opScopePriv»executeTransitionChain(«langExt.selfPointer(true)»chain«IF handleEvents», ifitem, generic_data«ENDIF»);
+ next = «opScopePriv»enterHistory(«langExt.selfPointer(true)»next, is_handler, skip_entry);
setState(«langExt.selfPointer(true)»next);
}
}
@@ -256,7 +285,7 @@ class GenericStateMachineGenerator {
var eventDriven = xpac.actorClass.commType==ActorCommunicationType::EVENT_DRIVEN
var dataDriven = xpac.actorClass.commType==ActorCommunicationType::DATA_DRIVEN
'''
- switch («langExt.memberAccess»state) {
+ switch (getState(«langExt.selfPointer(false)»)) {
«FOR state : xpac.stateMachine.getLeafStateList()»
case «state.getStateId()»:
«IF async»
@@ -329,6 +358,7 @@ class GenericStateMachineGenerator {
'''
}
def genExtra(ExpandedActorClass xpac) {''''''}
+ def genExtraDecl(ExpandedActorClass xpac) {''''''}
def private dispatch guard(TriggeredTransition tt, String trigger, ExpandedActorClass ac) {
var tr = tt.triggers.findFirst(e|ac.isMatching(e, trigger))
@@ -347,7 +377,7 @@ class GenericStateMachineGenerator {
def private genDoCodes(State state) {'''
«IF state.hasDoCode()»
- «state.getDoCodeOperationName()»(self);
+ «state.getDoCodeOperationName()»(«langExt.selfPointer(false)»);
«ENDIF»
«IF state.eContainer.eContainer instanceof State»
«genDoCodes(state.eContainer.eContainer as State)»
@@ -355,7 +385,17 @@ class GenericStateMachineGenerator {
'''}
def private genActionCodeMethods(ExpandedActorClass xpac, State state) {
+ genActionCodeMethods(xpac, state, true);
+ }
+
+ def private genActionCodeMethods(ExpandedActorClass xpac, State state, boolean generateImplementation) {
+ val ac = xpac.actorClass
val selfPtr = langExt.selfPointer(xpac.actorClass.name, false)
+ val opScope = langExt.operationScope(ac.name, false)
+ val opScopePriv = if (langExt.usesInheritance)
+ opScope
+ else
+ ""
val entryOp = state.getEntryCodeOperationName()
val exitOp = state.getExitCodeOperationName()
val doOp = state.getDoCodeOperationName()
@@ -386,21 +426,113 @@ class GenericStateMachineGenerator {
}
'''
«IF !entry.empty»
- «langExt.accessLevelProtected»void «entryOp»(«selfPtr») {
+ «IF generateImplementation»
+ «langExt.accessLevelProtected»void «opScopePriv»«entryOp»(«selfPtr») {
«entry»
}
+ «ELSE»
+ «langExt.accessLevelProtected»void «entryOp»(«selfPtr»);
+ «ENDIF»
«ENDIF»
«IF !exit.empty»
- «langExt.accessLevelProtected»void «exitOp»(«selfPtr») {
+ «IF generateImplementation»
+ «langExt.accessLevelProtected»void «opScopePriv»«exitOp»(«selfPtr») {
«exit»
}
+ «ELSE»
+ «langExt.accessLevelProtected»void «exitOp»(«selfPtr»);
+ «ENDIF»
«ENDIF»
«IF !docode.empty»
- «langExt.accessLevelProtected» void «doOp»(«selfPtr») {
+ «IF generateImplementation»
+ «langExt.accessLevelProtected» void «opScopePriv»«doOp»(«selfPtr») {
«docode»
}
+ «ELSE»
+ «langExt.accessLevelProtected»void «doOp»(«selfPtr»);
+ «ENDIF»
«ENDIF»
'''
}
+ def constPointer(String classname) {
+ return classname
+ }
+
+ def boolType() {
+ return "boolean"
+ }
+
+ def genStateMachineMethodDeclarations(ExpandedActorClass xpac)
+ {
+ val ac = xpac.actorClass
+ val async = ac.commType==ActorCommunicationType::ASYNCHRONOUS
+ val eventDriven = ac.commType==ActorCommunicationType::EVENT_DRIVEN
+ val handleEvents = async || eventDriven
+ val self = langExt.selfPointer(ac.name, true)
+
+ '''
+
+ /* state IDs */
+ «xpac.genStateIdConstants»
+
+ /* transition chains */
+ «xpac.genTransitionChainConstants»
+
+ /* triggers */
+ «xpac.genTriggerConstants»
+
+ «genExtraDecl(xpac)»
+
+ /* Entry and Exit Codes */
+ «FOR state : xpac.stateMachine.getStateList()»
+ «IF !langExt.usesInheritance || xpac.isOwnObject(state)»
+ «xpac.genActionCodeMethods(state, false)»
+ «ENDIF»
+ «ENDFOR»
+
+ /* Action Codes */
+ «FOR tr : xpac.stateMachine.getTransitionList()»
+ «IF (!langExt.usesInheritance || xpac.isOwnObject(tr)) && tr.hasActionCode()»
+ «var start = xpac.getChain(tr).transition»
+ «var hasArgs = start instanceof NonInitialTransition && !(start instanceof GuardedTransition)»
+ «langExt.accessLevelProtected»void «tr.getActionCodeOperationName()»(«langExt.selfPointer(ac.name, hasArgs)»«IF hasArgs»«constPointer("etRuntime::InterfaceItemBase")» ifitem«transitionChainGenerator.generateArgumentList(xpac, tr)»«ENDIF»);
+ «ENDIF»
+ «ENDFOR»
+
+ private:
+ /**
+ * calls exit codes while exiting from the current state to one of its
+ * parent states while remembering the history
+ * @param current - the current state
+ * @param to - the final parent state
+ * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
+ */
+ void exitTo(«self»int current, int to, «boolType» handler);
+
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @param chain - the chain ID
+ * @param generic_data - the generic data pointer
+ * @return the ID of the final state
+ */
+ int executeTransitionChain(«self»int chain«IF handleEvents», «constPointer("etRuntime::InterfaceItemBase")» ifitem, «langExt.voidPointer» generic_data«ENDIF»);
+
+ /**
+ * calls entry codes while entering a state's history. The ID of the final leaf state is returned
+ * @param state - the state which is entered
+ * @param handler - entry code is executed if not handler
+ * @return - the ID of the final leaf state
+ */
+ int enterHistory(«self»int state, «boolType» handler, «boolType» skip_entry);
+
+ public:
+
+ void executeInitTransition(«langExt.selfPointer(ac.name, false)»);
+
+ /* receiveEvent contains the main implementation of the FSM */
+ void receiveEvent(«langExt.selfPointer(ac.name, handleEvents)»«IF handleEvents»etRuntime::InterfaceItemBase* ifitem, int evt, «langExt.voidPointer» generic_data«ENDIF»);
+ '''
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
index 1f6fb9c51..6cb771773 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
@@ -96,6 +96,13 @@ public interface ILanguageExtension {
boolean usesInheritance();
/**
+ * does the target language use pointers
+ *
+ * @return true for C++ and C, false for Java
+ */
+ boolean usesPointers();
+
+ /**
* generate an enumeration (enum in C, int constants in Java)
* @param name the enumeration name
* @param entries a list of name/value pairs
@@ -213,4 +220,4 @@ public interface ILanguageExtension {
* @return the array initializer
*/
String initializationWithDefaultValues(DataType dt, int size);
-} \ No newline at end of file
+}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
index cdef50228..8fb7879b4 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
@@ -137,7 +137,7 @@ public class GenericStateMachineGenerator {
return this.langExt.genEnumeration("chain_ids", list);
}
- private String genTriggerConstants(final ExpandedActorClass xpac) {
+ public String genTriggerConstants(final ExpandedActorClass xpac) {
EList<MessageFromIf> _xifexpression = null;
boolean _usesInheritance = this.langExt.usesInheritance();
if (_usesInheritance) {
@@ -167,6 +167,11 @@ public class GenericStateMachineGenerator {
}
public CharSequence genStateMachine(final ExpandedActorClass xpac) {
+ CharSequence _genStateMachine = this.genStateMachine(xpac, true);
+ return _genStateMachine;
+ }
+
+ public CharSequence genStateMachine(final ExpandedActorClass xpac, final boolean shallGenerateOneFile) {
CharSequence _xblockexpression = null;
{
final ActorClass ac = xpac.getActorClass();
@@ -181,25 +186,79 @@ public class GenericStateMachineGenerator {
_or = (async || eventDriven);
}
final boolean handleEvents = _or;
+ String _name = ac.getName();
+ final String opScope = this.langExt.operationScope(_name, false);
+ String _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ _xifexpression = opScope;
+ } else {
+ _xifexpression = "";
+ }
+ final String opScopePriv = _xifexpression;
+ String _xifexpression_1 = null;
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ if (_usesInheritance_1) {
+ String _accessLevelPublic = this.langExt.accessLevelPublic();
+ _xifexpression_1 = _accessLevelPublic;
+ } else {
+ String _accessLevelPrivate = this.langExt.accessLevelPrivate();
+ _xifexpression_1 = _accessLevelPrivate;
+ }
+ final String publicIf = _xifexpression_1;
+ final String privAccess = this.langExt.accessLevelPrivate();
+ String _name_1 = ac.getName();
+ final String self = this.langExt.selfPointer(_name_1, true);
+ String _name_2 = ac.getName();
+ final String selfOnly = this.langExt.selfPointer(_name_2, false);
+ String _xifexpression_2 = null;
+ boolean _usesInheritance_2 = this.langExt.usesInheritance();
+ if (_usesInheritance_2) {
+ String _xifexpression_3 = null;
+ boolean _usesPointers = this.langExt.usesPointers();
+ if (_usesPointers) {
+ _xifexpression_3 = "->getLocalId()";
+ } else {
+ _xifexpression_3 = ".getLocalId()";
+ }
+ _xifexpression_2 = _xifexpression_3;
+ } else {
+ _xifexpression_2 = "->localId";
+ }
+ final String getLocalId = _xifexpression_2;
+ String _pointerLiteral = this.langExt.pointerLiteral();
+ final String ifItemPtr = ("InterfaceItemBase" + _pointerLiteral);
+ String _xifexpression_4 = null;
+ boolean _usesPointers_1 = this.langExt.usesPointers();
+ if (_usesPointers_1) {
+ String _plus = ("const " + ifItemPtr);
+ _xifexpression_4 = _plus;
+ } else {
+ _xifexpression_4 = ifItemPtr;
+ }
+ final String constIfItemPtr = _xifexpression_4;
StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("/* state IDs */");
- _builder.newLine();
- String _genStateIdConstants = this.genStateIdConstants(xpac);
- _builder.append(_genStateIdConstants, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* transition chains */");
- _builder.newLine();
- String _genTransitionChainConstants = this.genTransitionChainConstants(xpac);
- _builder.append(_genTransitionChainConstants, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* triggers */");
- _builder.newLine();
- String _genTriggerConstants = this.genTriggerConstants(xpac);
- _builder.append(_genTriggerConstants, "");
- _builder.newLineIfNotEmpty();
+ {
+ if (shallGenerateOneFile) {
+ _builder.append("/* state IDs */");
+ _builder.newLine();
+ String _genStateIdConstants = this.genStateIdConstants(xpac);
+ _builder.append(_genStateIdConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* transition chains */");
+ _builder.newLine();
+ String _genTransitionChainConstants = this.genTransitionChainConstants(xpac);
+ _builder.append(_genTransitionChainConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* triggers */");
+ _builder.newLine();
+ String _genTriggerConstants = this.genTriggerConstants(xpac);
+ _builder.append(_genTriggerConstants, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.newLine();
CharSequence _genExtra = this.genExtra(xpac);
_builder.append(_genExtra, "");
@@ -213,8 +272,8 @@ public class GenericStateMachineGenerator {
for(final State state : _stateList) {
{
boolean _or_1 = false;
- boolean _usesInheritance = this.langExt.usesInheritance();
- boolean _not = (!_usesInheritance);
+ boolean _usesInheritance_3 = this.langExt.usesInheritance();
+ boolean _not = (!_usesInheritance_3);
if (_not) {
_or_1 = true;
} else {
@@ -239,8 +298,8 @@ public class GenericStateMachineGenerator {
{
boolean _and = false;
boolean _or_2 = false;
- boolean _usesInheritance_1 = this.langExt.usesInheritance();
- boolean _not_1 = (!_usesInheritance_1);
+ boolean _usesInheritance_4 = this.langExt.usesInheritance();
+ boolean _not_1 = (!_usesInheritance_4);
if (_not_1) {
_or_2 = true;
} else {
@@ -269,15 +328,17 @@ public class GenericStateMachineGenerator {
String _accessLevelProtected = this.langExt.accessLevelProtected();
_builder.append(_accessLevelProtected, "");
_builder.append("void ");
+ _builder.append(opScopePriv, "");
String _actionCodeOperationName = CodegenHelpers.getActionCodeOperationName(tr);
_builder.append(_actionCodeOperationName, "");
_builder.append("(");
- String _name = ac.getName();
- String _selfPointer = this.langExt.selfPointer(_name, hasArgs);
+ String _name_3 = ac.getName();
+ String _selfPointer = this.langExt.selfPointer(_name_3, hasArgs);
_builder.append(_selfPointer, "");
{
if (hasArgs) {
- _builder.append("InterfaceItemBase ifitem");
+ _builder.append(constIfItemPtr, "");
+ _builder.append(" ifitem");
String _generateArgumentList = this.transitionChainGenerator.generateArgumentList(xpac, tr);
_builder.append(_generateArgumentList, "");
}
@@ -317,13 +378,15 @@ public class GenericStateMachineGenerator {
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
- String _accessLevelPrivate = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate, "");
- _builder.append("void exitTo(");
- String _name_1 = ac.getName();
- String _selfPointer_1 = this.langExt.selfPointer(_name_1, true);
- _builder.append(_selfPointer_1, "");
- _builder.append("int current, int to, boolean handler) {");
+ _builder.append(privAccess, "");
+ _builder.append("void ");
+ _builder.append(opScopePriv, "");
+ _builder.append("exitTo(");
+ _builder.append(self, "");
+ _builder.append("int current, int to, ");
+ String _boolType = this.boolType();
+ _builder.append(_boolType, "");
+ _builder.append(" handler) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("while (current!=to) {");
@@ -350,8 +413,8 @@ public class GenericStateMachineGenerator {
String _exitCodeOperationName = CodegenHelpers.getExitCodeOperationName(state_1);
_builder.append(_exitCodeOperationName, " ");
_builder.append("(");
- String _selfPointer_2 = this.langExt.selfPointer(false);
- _builder.append(_selfPointer_2, " ");
+ String _selfPointer_1 = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer_1, " ");
_builder.append(");");
}
}
@@ -410,16 +473,17 @@ public class GenericStateMachineGenerator {
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
- String _accessLevelPrivate_1 = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate_1, "");
- _builder.append("int executeTransitionChain(");
- String _name_2 = ac.getName();
- String _selfPointer_3 = this.langExt.selfPointer(_name_2, true);
- _builder.append(_selfPointer_3, "");
+ _builder.append(privAccess, "");
+ _builder.append("int ");
+ _builder.append(opScopePriv, "");
+ _builder.append("executeTransitionChain(");
+ _builder.append(self, "");
_builder.append("int chain");
{
if (handleEvents) {
- _builder.append(", InterfaceItemBase ifitem, ");
+ _builder.append(", ");
+ _builder.append(constIfItemPtr, "");
+ _builder.append(" ifitem, ");
String _voidPointer = this.langExt.voidPointer();
_builder.append(_voidPointer, "");
_builder.append(" generic_data");
@@ -480,13 +544,18 @@ public class GenericStateMachineGenerator {
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
- String _accessLevelPrivate_2 = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate_2, "");
- _builder.append("int enterHistory(");
- String _name_3 = ac.getName();
- String _selfPointer_4 = this.langExt.selfPointer(_name_3, true);
- _builder.append(_selfPointer_4, "");
- _builder.append("int state, boolean handler, boolean skip_entry) {");
+ _builder.append(privAccess, "");
+ _builder.append("int ");
+ _builder.append(opScopePriv, "");
+ _builder.append("enterHistory(");
+ _builder.append(self, "");
+ _builder.append("int state, ");
+ String _boolType_1 = this.boolType();
+ _builder.append(_boolType_1, "");
+ _builder.append(" handler, ");
+ String _boolType_2 = this.boolType();
+ _builder.append(_boolType_2, "");
+ _builder.append(" skip_entry) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("while (");
@@ -516,8 +585,8 @@ public class GenericStateMachineGenerator {
String _entryCodeOperationName = CodegenHelpers.getEntryCodeOperationName(state_2);
_builder.append(_entryCodeOperationName, " ");
_builder.append("(");
- String _selfPointer_5 = this.langExt.selfPointer(false);
- _builder.append(_selfPointer_5, " ");
+ String _selfPointer_2 = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer_2, " ");
_builder.append(");");
}
}
@@ -569,8 +638,8 @@ public class GenericStateMachineGenerator {
_builder.append("\t");
_builder.append("\t");
_builder.append("state = executeTransitionChain(");
- String _selfPointer_6 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_6, " ");
+ String _selfPointer_3 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_3, " ");
TransitionChain _chain_1 = xpac.getChain(sub_initt);
String _chainId_1 = this._roomExtensions.getChainId(_chain_1);
_builder.append(_chainId_1, " ");
@@ -664,20 +733,11 @@ public class GenericStateMachineGenerator {
_builder.append("}");
_builder.newLine();
_builder.newLine();
- {
- boolean _usesInheritance_2 = this.langExt.usesInheritance();
- if (_usesInheritance_2) {
- String _accessLevelPublic = this.langExt.accessLevelPublic();
- _builder.append(_accessLevelPublic, "");
- } else {
- String _accessLevelPrivate_3 = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate_3, "");
- }
- }
- _builder.append("void executeInitTransition(");
- String _name_4 = ac.getName();
- String _selfPointer_7 = this.langExt.selfPointer(_name_4, false);
- _builder.append(_selfPointer_7, "");
+ _builder.append(publicIf, "");
+ _builder.append("void ");
+ _builder.append(opScope, "");
+ _builder.append("executeInitTransition(");
+ _builder.append(selfOnly, "");
_builder.append(") {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -692,9 +752,11 @@ public class GenericStateMachineGenerator {
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("int next = executeTransitionChain(");
- String _selfPointer_8 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_8, " ");
+ _builder.append("int next = ");
+ _builder.append(opScopePriv, " ");
+ _builder.append("executeTransitionChain(");
+ String _selfPointer_4 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_4, " ");
_builder.append("chain");
{
if (handleEvents) {
@@ -709,9 +771,11 @@ public class GenericStateMachineGenerator {
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("next = enterHistory(");
- String _selfPointer_9 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_9, " ");
+ _builder.append("next = ");
+ _builder.append(opScopePriv, " ");
+ _builder.append("enterHistory(");
+ String _selfPointer_5 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_5, " ");
_builder.append("next, ");
String _booleanConstant_2 = this.langExt.booleanConstant(false);
_builder.append(_booleanConstant_2, " ");
@@ -722,8 +786,8 @@ public class GenericStateMachineGenerator {
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("setState(");
- String _selfPointer_10 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_10, " ");
+ String _selfPointer_6 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_6, " ");
_builder.append("next);");
_builder.newLineIfNotEmpty();
_builder.append("}");
@@ -731,23 +795,17 @@ public class GenericStateMachineGenerator {
_builder.newLine();
_builder.append("/* receiveEvent contains the main implementation of the FSM */");
_builder.newLine();
- {
- boolean _usesInheritance_3 = this.langExt.usesInheritance();
- if (_usesInheritance_3) {
- String _accessLevelPublic_1 = this.langExt.accessLevelPublic();
- _builder.append(_accessLevelPublic_1, "");
- } else {
- String _accessLevelPrivate_4 = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate_4, "");
- }
- }
- _builder.append("void receiveEvent(");
- String _name_5 = ac.getName();
- String _selfPointer_11 = this.langExt.selfPointer(_name_5, handleEvents);
- _builder.append(_selfPointer_11, "");
+ _builder.append(publicIf, "");
+ _builder.append("void ");
+ _builder.append(opScope, "");
+ _builder.append("receiveEvent(");
+ String _name_4 = ac.getName();
+ String _selfPointer_7 = this.langExt.selfPointer(_name_4, handleEvents);
+ _builder.append(_selfPointer_7, "");
{
if (handleEvents) {
- _builder.append("InterfaceItemBase ifitem, int evt, ");
+ _builder.append(ifItemPtr, "");
+ _builder.append(" ifitem, int evt, ");
String _voidPointer_1 = this.langExt.voidPointer();
_builder.append(_voidPointer_1, "");
_builder.append(" generic_data");
@@ -761,29 +819,15 @@ public class GenericStateMachineGenerator {
_builder.append("int trigger = (ifitem==");
String _nullPointer_4 = this.langExt.nullPointer();
_builder.append(_nullPointer_4, " ");
- _builder.append(")? POLLING : ");
- {
- boolean _usesInheritance_4 = this.langExt.usesInheritance();
- if (_usesInheritance_4) {
- _builder.append("ifitem.getLocalId()");
- } else {
- _builder.append("ifitem->localId");
- }
- }
+ _builder.append(")? POLLING : ifitem");
+ _builder.append(getLocalId, " ");
_builder.append(" + EVT_SHIFT*evt;");
_builder.newLineIfNotEmpty();
} else {
if (eventDriven) {
_builder.append("\t");
- _builder.append("int trigger = ");
- {
- boolean _usesInheritance_5 = this.langExt.usesInheritance();
- if (_usesInheritance_5) {
- _builder.append("ifitem.getLocalId()");
- } else {
- _builder.append("ifitem->localId");
- }
- }
+ _builder.append("int trigger = ifitem");
+ _builder.append(getLocalId, " ");
_builder.append(" + EVT_SHIFT*evt;");
_builder.newLineIfNotEmpty();
}
@@ -796,13 +840,17 @@ public class GenericStateMachineGenerator {
_builder.append("int catching_state = NO_STATE;");
_builder.newLine();
_builder.append("\t");
- _builder.append("boolean is_handler = ");
+ String _boolType_3 = this.boolType();
+ _builder.append(_boolType_3, " ");
+ _builder.append(" is_handler = ");
String _booleanConstant_4 = this.langExt.booleanConstant(false);
_builder.append(_booleanConstant_4, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("boolean skip_entry = ");
+ String _boolType_4 = this.boolType();
+ _builder.append(_boolType_4, " ");
+ _builder.append(" skip_entry = ");
String _booleanConstant_5 = this.langExt.booleanConstant(false);
_builder.append(_booleanConstant_5, " ");
_builder.append(";");
@@ -833,17 +881,21 @@ public class GenericStateMachineGenerator {
_builder.append("if (chain != NOT_CAUGHT) {");
_builder.newLine();
_builder.append("\t\t");
+ _builder.append(opScopePriv, " ");
_builder.append("exitTo(");
- String _selfPointer_12 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_12, " ");
- String _memberAccess_5 = this.langExt.memberAccess();
- _builder.append(_memberAccess_5, " ");
- _builder.append("state, catching_state, is_handler);");
+ String _selfPointer_8 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_8, " ");
+ _builder.append("getState(");
+ String _selfPointer_9 = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer_9, " ");
+ _builder.append("), catching_state, is_handler);");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
- _builder.append("int next = executeTransitionChain(");
- String _selfPointer_13 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_13, " ");
+ _builder.append("int next = ");
+ _builder.append(opScopePriv, " ");
+ _builder.append("executeTransitionChain(");
+ String _selfPointer_10 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_10, " ");
_builder.append("chain");
{
if (handleEvents) {
@@ -853,15 +905,17 @@ public class GenericStateMachineGenerator {
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
- _builder.append("next = enterHistory(");
- String _selfPointer_14 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_14, " ");
+ _builder.append("next = ");
+ _builder.append(opScopePriv, " ");
+ _builder.append("enterHistory(");
+ String _selfPointer_11 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_11, " ");
_builder.append("next, is_handler, skip_entry);");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("setState(");
- String _selfPointer_15 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_15, " ");
+ String _selfPointer_12 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_12, " ");
_builder.append("next);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -895,10 +949,10 @@ public class GenericStateMachineGenerator {
ActorCommunicationType _commType_2 = _actorClass_2.getCommType();
boolean dataDriven = Objects.equal(_commType_2, ActorCommunicationType.DATA_DRIVEN);
StringConcatenation _builder = new StringConcatenation();
- _builder.append("switch (");
- String _memberAccess = this.langExt.memberAccess();
- _builder.append(_memberAccess, "");
- _builder.append("state) {");
+ _builder.append("switch (getState(");
+ String _selfPointer = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer, "");
+ _builder.append(")) {");
_builder.newLineIfNotEmpty();
{
StateGraph _stateMachine = xpac.getStateMachine();
@@ -1183,6 +1237,11 @@ public class GenericStateMachineGenerator {
return _builder;
}
+ public CharSequence genExtraDecl(final ExpandedActorClass xpac) {
+ StringConcatenation _builder = new StringConcatenation();
+ return _builder;
+ }
+
private CharSequence _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac) {
CharSequence _xblockexpression = null;
{
@@ -1227,7 +1286,10 @@ public class GenericStateMachineGenerator {
if (_hasDoCode) {
String _doCodeOperationName = CodegenHelpers.getDoCodeOperationName(state);
_builder.append(_doCodeOperationName, "");
- _builder.append("(self);");
+ _builder.append("(");
+ String _selfPointer = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer, "");
+ _builder.append(");");
_builder.newLineIfNotEmpty();
}
}
@@ -1246,11 +1308,27 @@ public class GenericStateMachineGenerator {
}
private CharSequence genActionCodeMethods(final ExpandedActorClass xpac, final State state) {
+ CharSequence _genActionCodeMethods = this.genActionCodeMethods(xpac, state, true);
+ return _genActionCodeMethods;
+ }
+
+ private CharSequence genActionCodeMethods(final ExpandedActorClass xpac, final State state, final boolean generateImplementation) {
CharSequence _xblockexpression = null;
{
+ final ActorClass ac = xpac.getActorClass();
ActorClass _actorClass = xpac.getActorClass();
String _name = _actorClass.getName();
final String selfPtr = this.langExt.selfPointer(_name, false);
+ String _name_1 = ac.getName();
+ final String opScope = this.langExt.operationScope(_name_1, false);
+ String _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ _xifexpression = opScope;
+ } else {
+ _xifexpression = "";
+ }
+ final String opScopePriv = _xifexpression;
final String entryOp = CodegenHelpers.getEntryCodeOperationName(state);
final String exitOp = CodegenHelpers.getExitCodeOperationName(state);
final String doOp = CodegenHelpers.getDoCodeOperationName(state);
@@ -1274,8 +1352,8 @@ public class GenericStateMachineGenerator {
AbstractGenerator _instance_5 = AbstractGenerator.getInstance();
DetailCode _inheritedDo = rs.getInheritedDo();
final String inhDo = _instance_5.getTranslatedCode(_inheritedDo);
- boolean _usesInheritance = this.langExt.usesInheritance();
- if (_usesInheritance) {
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ if (_usesInheritance_1) {
ActorClass _actorClass_1 = xpac.getActorClass();
ActorClass _base = _actorClass_1.getBase();
final String baseName = _base.getName();
@@ -1317,57 +1395,99 @@ public class GenericStateMachineGenerator {
boolean _isEmpty = entry.isEmpty();
boolean _not_3 = (!_isEmpty);
if (_not_3) {
- String _accessLevelProtected = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected, "");
- _builder.append("void ");
- _builder.append(entryOp, "");
- _builder.append("(");
- _builder.append(selfPtr, "");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(entry, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
+ {
+ if (generateImplementation) {
+ String _accessLevelProtected = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected, "");
+ _builder.append("void ");
+ _builder.append(opScopePriv, "");
+ _builder.append(entryOp, "");
+ _builder.append("(");
+ _builder.append(selfPtr, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(entry, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ String _accessLevelProtected_1 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_1, "");
+ _builder.append("void ");
+ _builder.append(entryOp, "");
+ _builder.append("(");
+ _builder.append(selfPtr, "");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
}
}
{
boolean _isEmpty_1 = exit.isEmpty();
boolean _not_4 = (!_isEmpty_1);
if (_not_4) {
- String _accessLevelProtected_1 = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected_1, "");
- _builder.append("void ");
- _builder.append(exitOp, "");
- _builder.append("(");
- _builder.append(selfPtr, "");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(exit, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
+ {
+ if (generateImplementation) {
+ String _accessLevelProtected_2 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_2, "");
+ _builder.append("void ");
+ _builder.append(opScopePriv, "");
+ _builder.append(exitOp, "");
+ _builder.append("(");
+ _builder.append(selfPtr, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(exit, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ String _accessLevelProtected_3 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_3, "");
+ _builder.append("void ");
+ _builder.append(exitOp, "");
+ _builder.append("(");
+ _builder.append(selfPtr, "");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
}
}
{
boolean _isEmpty_2 = docode.isEmpty();
boolean _not_5 = (!_isEmpty_2);
if (_not_5) {
- String _accessLevelProtected_2 = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected_2, "");
- _builder.append(" void ");
- _builder.append(doOp, "");
- _builder.append("(");
- _builder.append(selfPtr, "");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(docode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
+ {
+ if (generateImplementation) {
+ String _accessLevelProtected_4 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_4, "");
+ _builder.append(" void ");
+ _builder.append(opScopePriv, "");
+ _builder.append(doOp, "");
+ _builder.append("(");
+ _builder.append(selfPtr, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(docode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ String _accessLevelProtected_5 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_5, "");
+ _builder.append("void ");
+ _builder.append(doOp, "");
+ _builder.append("(");
+ _builder.append(selfPtr, "");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
}
}
_xblockexpression = (_builder);
@@ -1375,6 +1495,279 @@ public class GenericStateMachineGenerator {
return _xblockexpression;
}
+ public String constPointer(final String classname) {
+ return classname;
+ }
+
+ public String boolType() {
+ return "boolean";
+ }
+
+ public CharSequence genStateMachineMethodDeclarations(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ ActorCommunicationType _commType = ac.getCommType();
+ final boolean async = Objects.equal(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ ActorCommunicationType _commType_1 = ac.getCommType();
+ final boolean eventDriven = Objects.equal(_commType_1, ActorCommunicationType.EVENT_DRIVEN);
+ boolean _or = false;
+ if (async) {
+ _or = true;
+ } else {
+ _or = (async || eventDriven);
+ }
+ final boolean handleEvents = _or;
+ String _name = ac.getName();
+ final String self = this.langExt.selfPointer(_name, true);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* state IDs */");
+ _builder.newLine();
+ String _genStateIdConstants = this.genStateIdConstants(xpac);
+ _builder.append(_genStateIdConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* transition chains */");
+ _builder.newLine();
+ String _genTransitionChainConstants = this.genTransitionChainConstants(xpac);
+ _builder.append(_genTransitionChainConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* triggers */");
+ _builder.newLine();
+ String _genTriggerConstants = this.genTriggerConstants(xpac);
+ _builder.append(_genTriggerConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ CharSequence _genExtraDecl = this.genExtraDecl(xpac);
+ _builder.append(_genExtraDecl, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* Entry and Exit Codes */");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ List<State> _stateList = this._roomExtensions.getStateList(_stateMachine);
+ for(final State state : _stateList) {
+ {
+ boolean _or_1 = false;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ boolean _not = (!_usesInheritance);
+ if (_not) {
+ _or_1 = true;
+ } else {
+ boolean _isOwnObject = xpac.isOwnObject(state);
+ _or_1 = (_not || _isOwnObject);
+ }
+ if (_or_1) {
+ CharSequence _genActionCodeMethods = this.genActionCodeMethods(xpac, state, false);
+ _builder.append(_genActionCodeMethods, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* Action Codes */");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ List<Transition> _transitionList = this._roomExtensions.getTransitionList(_stateMachine_1);
+ for(final Transition tr : _transitionList) {
+ {
+ boolean _and = false;
+ boolean _or_2 = false;
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ boolean _not_1 = (!_usesInheritance_1);
+ if (_not_1) {
+ _or_2 = true;
+ } else {
+ boolean _isOwnObject_1 = xpac.isOwnObject(tr);
+ _or_2 = (_not_1 || _isOwnObject_1);
+ }
+ if (!_or_2) {
+ _and = false;
+ } else {
+ boolean _hasActionCode = this._roomExtensions.hasActionCode(tr);
+ _and = (_or_2 && _hasActionCode);
+ }
+ if (_and) {
+ TransitionChain _chain = xpac.getChain(tr);
+ Transition start = _chain.getTransition();
+ _builder.newLineIfNotEmpty();
+ boolean _and_1 = false;
+ if (!(start instanceof NonInitialTransition)) {
+ _and_1 = false;
+ } else {
+ boolean _not_2 = (!(start instanceof GuardedTransition));
+ _and_1 = ((start instanceof NonInitialTransition) && _not_2);
+ }
+ boolean hasArgs = _and_1;
+ _builder.newLineIfNotEmpty();
+ String _accessLevelProtected = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected, "");
+ _builder.append("void ");
+ String _actionCodeOperationName = CodegenHelpers.getActionCodeOperationName(tr);
+ _builder.append(_actionCodeOperationName, "");
+ _builder.append("(");
+ String _name_1 = ac.getName();
+ String _selfPointer = this.langExt.selfPointer(_name_1, hasArgs);
+ _builder.append(_selfPointer, "");
+ {
+ if (hasArgs) {
+ String _constPointer = this.constPointer("etRuntime::InterfaceItemBase");
+ _builder.append(_constPointer, "");
+ _builder.append(" ifitem");
+ String _generateArgumentList = this.transitionChainGenerator.generateArgumentList(xpac, tr);
+ _builder.append(_generateArgumentList, "");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("private:");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* calls exit codes while exiting from the current state to one of its");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* parent states while remembering the history");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @param current - the current state");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @param to - the final parent state");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("void exitTo(");
+ _builder.append(self, " ");
+ _builder.append("int current, int to, ");
+ String _boolType = this.boolType();
+ _builder.append(_boolType, " ");
+ _builder.append(" handler);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* matching the trigger of this chain. The ID of the final state is returned");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @param chain - the chain ID");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @param generic_data - the generic data pointer");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @return the ID of the final state");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int executeTransitionChain(");
+ _builder.append(self, " ");
+ _builder.append("int chain");
+ {
+ if (handleEvents) {
+ _builder.append(", ");
+ String _constPointer_1 = this.constPointer("etRuntime::InterfaceItemBase");
+ _builder.append(_constPointer_1, " ");
+ _builder.append(" ifitem, ");
+ String _voidPointer = this.langExt.voidPointer();
+ _builder.append(_voidPointer, " ");
+ _builder.append(" generic_data");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* calls entry codes while entering a state\'s history. The ID of the final leaf state is returned");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @param state - the state which is entered");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @param handler - entry code is executed if not handler");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @return - the ID of the final leaf state");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int enterHistory(");
+ _builder.append(self, " ");
+ _builder.append("int state, ");
+ String _boolType_1 = this.boolType();
+ _builder.append(_boolType_1, " ");
+ _builder.append(" handler, ");
+ String _boolType_2 = this.boolType();
+ _builder.append(_boolType_2, " ");
+ _builder.append(" skip_entry);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("void executeInitTransition(");
+ String _name_2 = ac.getName();
+ String _selfPointer_1 = this.langExt.selfPointer(_name_2, false);
+ _builder.append(_selfPointer_1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* receiveEvent contains the main implementation of the FSM */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("void receiveEvent(");
+ String _name_3 = ac.getName();
+ String _selfPointer_2 = this.langExt.selfPointer(_name_3, handleEvents);
+ _builder.append(_selfPointer_2, " ");
+ {
+ if (handleEvents) {
+ _builder.append("etRuntime::InterfaceItemBase* ifitem, int evt, ");
+ String _voidPointer_1 = this.langExt.voidPointer();
+ _builder.append(_voidPointer_1, " ");
+ _builder.append(" generic_data");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
private CharSequence guard(final Transition tt, final String trigger, final ExpandedActorClass ac) {
if (tt instanceof TriggeredTransition) {
return _guard((TriggeredTransition)tt, trigger, ac);
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/PortMessageSelectionDialog.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/PortMessageSelectionDialog.java
index d0c9ab3a0..f5aed3df2 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/PortMessageSelectionDialog.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/PortMessageSelectionDialog.java
@@ -103,7 +103,7 @@ public class PortMessageSelectionDialog extends FormDialog {
List<InterfaceItem> items = RoomHelpers.getAllInterfaceItems(ac);
for (InterfaceItem item : items) {
ArrayList<MethodItemPair> pairs = new ArrayList<MethodItemPair>();
- List<Message> out = RoomHelpers.getMessageList(item, true);
+ List<Message> out = RoomHelpers.getMessageListDeep(item, true);
if (!recvOnly) {
for (Message msg : out) {
if (!msg.isPriv())
@@ -111,7 +111,7 @@ public class PortMessageSelectionDialog extends FormDialog {
}
}
if (RoomHelpers.getProtocol(item).getCommType()==CommunicationType.DATA_DRIVEN) {
- List<Message> in = RoomHelpers.getMessageList(item, false);
+ List<Message> in = RoomHelpers.getMessageListDeep(item, false);
for (Message msg : in) {
if (!msg.isPriv())
pairs.add(new MsgItemPair(item, msg, false));
@@ -158,11 +158,11 @@ public class PortMessageSelectionDialog extends FormDialog {
public boolean hasChildren(Object element) {
if (element instanceof InterfaceItem) {
InterfaceItem item = (InterfaceItem)element;
- if (!RoomHelpers.getMessageList(item, true).isEmpty())
+ if (!RoomHelpers.getMessageListDeep(item, true).isEmpty())
return true;
if (RoomHelpers.getProtocol(item).getCommType()==CommunicationType.DATA_DRIVEN)
- if (!RoomHelpers.getMessageList(item, false).isEmpty())
+ if (!RoomHelpers.getMessageListDeep(item, false).isEmpty())
return true;
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java
index f48c176c7..9dca3a3bc 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java
@@ -323,7 +323,7 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
return false;
for (InterfaceItem item : interfaceItems) {
- if (!RoomHelpers.getMessageList(item, false).isEmpty())
+ if (!RoomHelpers.getMessageListDeep(item, false).isEmpty())
return true;
}
return false;
@@ -619,7 +619,7 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
for (int i = 0; i < items.length; i++) {
if (items[i].equals(mif.getFrom().getName())) {
interfaceCombo.select(i);
- currentMsgs = RoomHelpers.getMessageList(mif.getFrom(), false);
+ currentMsgs = RoomHelpers.getMessageListDeep(mif.getFrom(), false);
int pos = 0;
int idx = -1;
for (Message message : currentMsgs) {
@@ -659,7 +659,7 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
private MessageFromIf createDefaultMif() {
MessageFromIf mif = RoomFactory.eINSTANCE.createMessageFromIf();
for (InterfaceItem item : interfaceItems) {
- List<Message> msgs = RoomHelpers.getMessageList(item, false);
+ List<Message> msgs = RoomHelpers.getMessageListDeep(item, false);
if (!msgs.isEmpty()) {
mif.setFrom(item);
mif.setMessage(msgs.get(0));
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
index dc8ce439d..75d9a918c 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip
new file mode 100644
index 000000000..0c559f156
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
index 34e225d81..01810b460 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
index 0af04eb40..5065c43d2 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip
new file mode 100644
index 000000000..d2f4b57c9
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
index 33d336ca7..9dbaf2422 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
index 0d5c3f9ab..680b4592f 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/create_contents.xml b/plugins/org.eclipse.etrice.ui.runtime/create_contents.xml
index 3380d7de2..325f8ae1a 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/create_contents.xml
+++ b/plugins/org.eclipse.etrice.ui.runtime/create_contents.xml
@@ -26,6 +26,8 @@
<zip_project source="../../runtime" name="org.eclipse.etrice.modellib.c" />
<zip_project source="../../examples" name="org.eclipse.etrice.tutorials.java" />
<zip_project source="../../examples" name="org.eclipse.etrice.tutorials.c" />
+ <zip_project source="../../runtime" name="org.eclipse.etrice.runtime.cpp" />
+ <zip_project source="../../runtime" name="org.eclipse.etrice.modellib.cpp" />
</target>
</project>
diff --git a/plugins/org.eclipse.etrice.ui.runtime/plugin.xml b/plugins/org.eclipse.etrice.ui.runtime/plugin.xml
index d19a6f571..c9a8652cf 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/plugin.xml
+++ b/plugins/org.eclipse.etrice.ui.runtime/plugin.xml
@@ -36,6 +36,40 @@
</example>
</extension>
+ <!-- ========= org.eclipse.etrice.runtime.cpp ========= -->
+ <extension point="org.eclipse.ui.newWizards">
+ <wizard id="org.eclipse.etrice.ui.runtime.NewCPPRuntimeWizard"
+ name="eTrice C++ Runtime"
+ class="org.eclipse.emf.common.ui.wizard.ExampleInstallerWizard"
+ category="org.eclipse.etrice.core.ui.wizardCategory"
+ icon="icons/genproject.gif"
+ project="true">
+ <description>The C++ Runtime required by eTrice C++ projects</description>
+ </wizard>
+ </extension>
+ <extension point="org.eclipse.emf.common.ui.examples">
+ <example wizardID="org.eclipse.etrice.ui.runtime.NewCPPRuntimeWizard" pageImage="icons/genproject.gif">
+ <projectDescriptor name="org.eclipse.etrice.runtime.cpp" contentURI="contents/org.eclipse.etrice.runtime.cpp.zip" description="eTrice Runtime for C++"/>
+ </example>
+ </extension>
+
+ <!-- ========= org.eclipse.etrice.modellib.cpp ========= -->
+ <extension point="org.eclipse.ui.newWizards">
+ <wizard id="org.eclipse.etrice.ui.runtime.NewCPPModelLibWizard"
+ name="eTrice C++ ModelLib"
+ class="org.eclipse.emf.common.ui.wizard.ExampleInstallerWizard"
+ category="org.eclipse.etrice.core.ui.wizardCategory"
+ icon="icons/genproject.gif"
+ project="true">
+ <description>A ROOM Model Library for C++ with useful services</description>
+ </wizard>
+ </extension>
+ <extension point="org.eclipse.emf.common.ui.examples">
+ <example wizardID="org.eclipse.etrice.ui.runtime.NewCPPModelLibWizard" pageImage="icons/genproject.gif">
+ <projectDescriptor name="org.eclipse.etrice.modellib.cpp" contentURI="contents/org.eclipse.etrice.modellib.cpp.zip" description="eTrice ModelLib for C++"/>
+ </example>
+ </extension>
+
<!-- ========= org.eclipse.etrice.runtime.java ========= -->
<extension point="org.eclipse.ui.newWizards">
<wizard id="org.eclipse.etrice.ui.runtime.NewJavaRuntimeWizard"
diff --git a/runtime/org.eclipse.etrice.modellib.c/buckminster.cspec b/runtime/org.eclipse.etrice.modellib.c/buckminster.cspec
index b01751425..f396d6d95 100644
--- a/runtime/org.eclipse.etrice.modellib.c/buckminster.cspec
+++ b/runtime/org.eclipse.etrice.modellib.c/buckminster.cspec
@@ -1,2 +1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.modellib.c" componentType="buckminster" version="1.0.0"/>
+<?xml version="1.0" encoding="UTF-8"?><cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.modellib.c" componentType="buckminster" version="0.3.0.qualifier"/>
diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c
index b401b16e5..421fed88d 100644
--- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c
+++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c
@@ -24,7 +24,6 @@ enum interface_items {
IFITEM_timer = 1
};
-
/* state IDs */
enum state_ids {
NO_STATE = 0,
@@ -214,7 +213,7 @@ static void receiveEvent(ATimingService* self, InterfaceItemBase ifitem, int evt
boolean skip_entry = FALSE;
if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (self->state) {
+ switch (getState()) {
case STATE_Operational:
switch(trigger) {
case POLLING:
@@ -243,7 +242,7 @@ static void receiveEvent(ATimingService* self, InterfaceItemBase ifitem, int evt
}
}
if (chain != NOT_CAUGHT) {
- exitTo(self, self->state, catching_state, is_handler);
+ exitTo(getState(), catching_state, is_handler);
int next = executeTransitionChain(self, chain, ifitem, generic_data);
next = enterHistory(self, next, is_handler, skip_entry);
setState(self, next);
diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h
index 60822f469..339c69740 100644
--- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h
+++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h
@@ -57,7 +57,6 @@ struct ATimingService {
etTimerControlBlock tcbs[10];
etTimerControlBlock* usedTcbsRoot;
etTimerControlBlock* freeTcbsRoot;
-
/* state machine variables */
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/.cproject b/runtime/org.eclipse.etrice.modellib.cpp/.cproject
new file mode 100644
index 000000000..0191c0b6e
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/.cproject
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.config.gnu.mingw.lib.debug.44153035">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.lib.debug.44153035" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/org.eclipse.etrice.modellib.cpp"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/org.eclipse.etrice.modellib.cpp/Debug"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="etriceModellibCpp" srcPrefixMapping="" srcRootPath=""/>
+ </externalSetting>
+ </externalSettings>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactExtension="a" artifactName="etriceModellibCpp" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.lib.debug.44153035" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.lib.debug">
+ <folderInfo id="cdt.managedbuild.config.gnu.mingw.lib.debug.44153035." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.lib.debug.528335783" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.lib.debug">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.lib.debug.1299569783" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.lib.debug"/>
+ <builder buildPath="${workspace_loc:/org.eclipse.etrice.modellib.cpp/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.2013445161" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.lib.debug.724387525" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.lib.debug">
+ <option id="gnu.both.asm.option.include.paths.1757143474" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="/org.eclipse.etrice.runtime.cpp/src/platform/generic"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1284881452" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.lib.debug.1766943569" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.lib.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug.118960948" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug">
+ <option id="gnu.cpp.compiler.mingw.lib.debug.option.optimization.level.1721757225" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.lib.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.mingw.lib.debug.option.debugging.level.1204207148" name="Debug Level" superClass="gnu.cpp.compiler.mingw.lib.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.1001723439" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/platforms/generic}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.402201359" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.485632379" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.lib.debug.option.optimization.level.386071444" name="Optimization Level" superClass="gnu.c.compiler.mingw.lib.debug.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.mingw.lib.debug.option.debugging.level.2121576926" name="Debug Level" superClass="gnu.c.compiler.mingw.lib.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.c.compiler.option.include.paths.1424766451" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/platforms/generic}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2050037191" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.1525761784" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.386321355" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="cdt.managedbuild.config.gnu.mingw.lib.release.369390927">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.lib.release.369390927" moduleId="org.eclipse.cdt.core.settings" name="Release">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/org.eclipse.etrice.modellib.cpp"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/org.eclipse.etrice.modellib.cpp/Release"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="org.eclipse.etrice.modellib.cpp" srcPrefixMapping="" srcRootPath=""/>
+ </externalSetting>
+ </externalSettings>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.lib.release.369390927" name="Release" parent="cdt.managedbuild.config.gnu.mingw.lib.release">
+ <folderInfo id="cdt.managedbuild.config.gnu.mingw.lib.release.369390927." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.lib.release.863050384" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.lib.release">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.lib.release.1531613870" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.lib.release"/>
+ <builder buildPath="${workspace_loc:/org.eclipse.etrice.modellib.cpp/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.658172533" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.lib.release.1090371584" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.lib.release">
+ <option id="gnu.both.asm.option.include.paths.2079893992" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="/org.eclipse.etrice.runtime.cpp/src/platform/generic"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1692202427" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.lib.release.859095155" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.lib.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.release.756312591" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.release">
+ <option id="gnu.cpp.compiler.mingw.lib.release.option.optimization.level.2147476314" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.lib.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.mingw.lib.release.option.debugging.level.1387780898" name="Debug Level" superClass="gnu.cpp.compiler.mingw.lib.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.528505037" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/platforms/generic}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1763050360" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.release.129970568" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.release">
+ <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.lib.release.option.optimization.level.1329568783" name="Optimization Level" superClass="gnu.c.compiler.mingw.lib.release.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.mingw.lib.release.option.debugging.level.1807223219" name="Debug Level" superClass="gnu.c.compiler.mingw.lib.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+ <option id="gnu.c.compiler.option.include.paths.316043543" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/platforms/generic}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.760635415" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.1854320864" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.1472356875" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="org.eclipse.etrice.modellib.cpp.cdt.managedbuild.target.gnu.mingw.lib.704211053" name="Static Library" projectType="cdt.managedbuild.target.gnu.mingw.lib"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.debug.44153035;cdt.managedbuild.config.gnu.mingw.lib.debug.44153035.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug.118960948;cdt.managedbuild.tool.gnu.cpp.compiler.input.402201359">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.release.369390927;cdt.managedbuild.config.gnu.mingw.lib.release.369390927.;cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.release.129970568;cdt.managedbuild.tool.gnu.c.compiler.input.760635415">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.debug.44153035;cdt.managedbuild.config.gnu.mingw.lib.debug.44153035.;cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.485632379;cdt.managedbuild.tool.gnu.c.compiler.input.2050037191">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.release.369390927;cdt.managedbuild.config.gnu.mingw.lib.release.369390927.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.release.756312591;cdt.managedbuild.tool.gnu.cpp.compiler.input.1763050360">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope"/>
+</cproject>
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/.gitignore b/runtime/org.eclipse.etrice.modellib.cpp/.gitignore
new file mode 100644
index 000000000..76b025ad1
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/.gitignore
@@ -0,0 +1,2 @@
+Debug
+Release
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/.project b/runtime/org.eclipse.etrice.modellib.cpp/.project
new file mode 100644
index 000000000..25fbf253e
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.modellib.cpp</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/runtime/org.eclipse.etrice.modellib.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs
new file mode 100644
index 000000000..5f6b7ee39
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs
@@ -0,0 +1,9 @@
+eclipse.preferences.version=1
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.44153035/CPATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.44153035/CPATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.44153035/CPLUS_INCLUDE_PATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.44153035/CPLUS_INCLUDE_PATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.44153035/C_INCLUDE_PATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.44153035/C_INCLUDE_PATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.44153035/append=true
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.44153035/appendContributed=true
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/buckminster.cspec b/runtime/org.eclipse.etrice.modellib.cpp/buckminster.cspec
new file mode 100644
index 000000000..2e9e500ca
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/buckminster.cspec
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.modellib.cpp" componentType="buckminster" version="0.3.0.qualifier"/>
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/cpp_gen_modellib.launch b/runtime/org.eclipse.etrice.modellib.cpp/cpp_gen_modellib.launch
new file mode 100644
index 000000000..ca1f76ceb
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/cpp_gen_modellib.launch
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.etrice.generator.launch.cpp.launchConfigurationType">
+<booleanAttribute key="GenInstanceDiagram" value="false"/>
+<stringAttribute key="GenModelPath" value=""/>
+<booleanAttribute key="Lib" value="true"/>
+<listAttribute key="ModelFiles">
+<listEntry value="${workspace_loc:/org.eclipse.etrice.modellib.cpp/model/Language.room}"/>
+<listEntry value="${workspace_loc:/org.eclipse.etrice.modellib.cpp/model/TimingService.room}"/>
+<listEntry value="${workspace_loc:/org.eclipse.etrice.modellib.cpp/model/Types.room}"/>
+</listAttribute>
+<booleanAttribute key="SaveGenModel" value="false"/>
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;resources&gt;&#13;&#10;&lt;item path=&quot;/org.eclipse.etrice.modellib.cpp/src-gen&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/resources&gt;}"/>
+</launchConfiguration>
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/model/Language.room b/runtime/org.eclipse.etrice.modellib.cpp/model/Language.room
new file mode 100644
index 000000000..04e441aad
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/model/Language.room
@@ -0,0 +1,3 @@
+RoomModel room.basic.language {
+ PrimitiveType languageIndicator: ptInteger -> int8 default "2"
+} \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room b/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room
new file mode 100644
index 000000000..1c13eb3ef
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room
@@ -0,0 +1,301 @@
+RoomModel room.basic.service.timing {
+
+ import room.basic.types.* from "Types.room"
+
+ async ActorClass ATimingService {
+ Interface {
+ SPP timer: PTimer
+ }
+ Structure {
+ usercode1 {
+ "
+ #include \"common/platform/etTimer.h\"
+ #define ET_NB_OF_TCBS 10
+ typedef struct etTCB etTimerControlBlock;
+ struct etTCB {
+ etTargetTime_t expTime;
+ etTargetTime_t pTime;
+ int32 portIdx;
+ etTimerControlBlock* next;
+ };
+ "
+ }
+ usercode2 {
+ "//uc2"
+ }
+ usercode3{
+ "//etTimerControlBlock tcbs[ET_NB_OF_TCBS];"
+ }
+ ServiceImplementation of timer
+ Attribute tcbs[10]:tcb
+ Attribute usedTcbsRoot : tcb ref
+ Attribute freeTcbsRoot : tcb ref
+ }
+ Behavior {
+ Operation getTcb():tcb ref{"
+ etTimerControlBlock* temp = freeTcbsRoot;
+
+ if(freeTcbsRoot!=0) {
+ freeTcbsRoot=freeTcbsRoot->next;
+ temp->next=0;
+ }
+ return temp;
+ "}
+ Operation returnTcb(block:tcb ref){"
+ block->next=freeTcbsRoot;
+ freeTcbsRoot=block;
+ "}
+ Operation removeTcbFromUsedList(idx:int32){"
+ etTimerControlBlock* temp=usedTcbsRoot;
+ etTimerControlBlock* temp2=usedTcbsRoot;
+
+ if (temp==0) return;
+
+ if (usedTcbsRoot->portIdx == idx){
+ // element found, the first one
+ usedTcbsRoot = usedTcbsRoot->next;
+ returnTcb(temp);
+ return;
+ }
+
+ temp=temp->next;
+ while(temp!=0){
+ if(temp->portIdx==idx){
+ temp2->next=temp->next;
+ returnTcb(temp);
+ return;
+ }else{
+ // try next
+ temp2=temp;
+ temp=temp->next;
+ }
+ }
+ "}
+ Operation putTcbToUsedList(block:tcb ref){"
+ etTimerControlBlock* temp=usedTcbsRoot;
+ etTimerControlBlock* temp2=usedTcbsRoot;
+
+ if (temp==0){
+ // list empty put new block to root
+ block->next=0;
+ usedTcbsRoot=block;
+ return;
+ }
+
+ while(1){
+ if (temp != 0){
+ if (isTimeGreater(&block->expTime,&temp->expTime)){
+ //try next position
+ temp2=temp;
+ temp=temp->next;
+ }else{
+ // right position found
+ block->next=temp;
+ if(temp==usedTcbsRoot){
+ usedTcbsRoot=block;
+ }else{
+ temp2->next=block;
+ }
+ return;
+ }
+ }else{
+ // end of list reached
+ block->next=0;
+ temp2->next=block;
+ return;
+ }
+ }
+ "}
+ Operation isTimeGreater(t1:targetTime ref, t2 :targetTime ref):boolean{"
+ if (t1->sec > t2->sec) return TRUE;
+ if (t1->sec < t2->sec) return FALSE;
+ if (t1->nSec > t2->nSec) return TRUE;
+ return FALSE;
+ "}
+
+ Operation addTime(t1:targetTime ref, t2:targetTime ref){"
+ t1->sec += t2->sec;
+ t1->nSec += t2->nSec;
+ while(t1->nSec >= 1000000000L){
+ t1->sec++;
+ t1->nSec-=1000000000L;
+ }
+ "}
+
+ Operation printList(){"
+ etTimerControlBlock* temp=usedTcbsRoot;
+ printf(\"list: \");
+ while (temp!=0){
+ printf(\"(%ld,%ld),\",temp->expTime.sec,temp->expTime.nSec);
+ temp=temp->next;
+ }
+ printf(\"\\n\");
+ "}
+ StateMachine {
+ Transition tr0: initial -> Operational {
+ action {
+ "int i;"
+ "usedTcbsRoot=0;"
+ "freeTcbsRoot=&tcbs[0];"
+ "tcbs[ET_NB_OF_TCBS-1].next=0;"
+ "for (i=0;i<ET_NB_OF_TCBS-1;i++){"
+ "\ttcbs[i].next=&tcbs[i+1];"
+ "\t}"
+ }
+ }
+ Transition tr1: Operational -> Operational {
+ triggers {
+ <startTimeout: timer>
+ }
+ action {
+ "etTimerControlBlock* timer = getTcb();"
+ "etTargetTime_t t;"
+ "if (timer!= 0){"
+ "\tt.sec=time/1000;"
+ "\tt.nSec=(time%1000)*1000000L;"
+ "\ttimer->pTime.sec = 0;"
+ "\ttimer->pTime.nSec = 0;"
+ "\ttimer->portIdx=ifitem->getIdx();"
+ "\tgetTimeFromTarget(&(timer->expTime));"
+ "\taddTime(&(timer->expTime),&t);"
+ "\tputTcbToUsedList(timer);"
+ "\t}"
+ }
+ }
+ Transition tr3: Operational -> Operational {
+ triggers {
+ <startTimer: timer>
+ }
+ action {
+ "etTimerControlBlock* timer = getTcb();"
+ "etTargetTime_t t;"
+ "if (timer!= 0){"
+ "\tt.sec=time/1000;"
+ "\tt.nSec=(time%1000)*1000000L;"
+ "\ttimer->pTime = t;"
+ "\ttimer->portIdx=ifitem->getIdx();"
+ "\tgetTimeFromTarget(&(timer->expTime));"
+ "\taddTime(&(timer->expTime),&t);"
+ "\tputTcbToUsedList(timer);"
+ "\t}"
+ }
+ }
+ Transition tr4: Operational -> Operational {
+ triggers {
+ <kill: timer>
+ }
+ action {
+ "removeTcbFromUsedList(ifitem->getIdx());"
+ }
+ }
+ State Operational {
+ entry {
+ "// prepare"
+ } do {
+ "// maintain timers"
+ "etTimerControlBlock* temp;"
+ "etTargetTime_t t;"
+ ""
+ "getTimeFromTarget(&t);"
+ "while (usedTcbsRoot !=0 ){"
+ "\tif (isTimeGreater(&t,&(usedTcbsRoot->expTime))){"
+ "\t\ttimer[usedTcbsRoot->portIdx].timeout();"
+ "\t\ttemp=usedTcbsRoot;"
+ "\t\tusedTcbsRoot=usedTcbsRoot->next;"
+ "\t\tif((temp->pTime.sec==0)&&(temp->pTime.nSec==0)){"
+ "\t\t\t// single shot timer"
+ "\t\t\treturnTcb(temp);"
+ "\t\t}else{"
+ "\t\t\t// periodic timer"
+ "\t\t\taddTime(&temp->expTime,&temp->pTime);"
+ "\t\t\tputTcbToUsedList(temp);"
+ "\t\t\t}"
+ "\t\t}else{"
+ "\t\t\tbreak;"
+ "\t\t\t}"
+ "\t}"
+ }
+ }
+ }
+ }
+ }
+
+
+ ProtocolClass PTimer {
+ usercode1 {"
+ #define ET_TIMER_RUNNING 0x01
+ #define ET_TIMER_PERIODIC 0x02
+ "
+ }
+ usercode2 {
+ "//uc2 "
+ }
+ incoming {
+ Message startTimer(time: uint32)
+ Message startTimeout(time: uint32)
+ Message kill()
+ }
+ outgoing {
+ Message timeout()
+ }
+ conjugate PortClass
+ {
+ handle incoming startTimer{
+ "
+ if (status==0){
+ status=ET_TIMER_RUNNING | ET_TIMER_PERIODIC;
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ PTimer::getMessageString(PTimer::IN_startTimer));
+ if (getPeerAddress().isValid()){
+ getPeerMsgReceiver()->receive(new Message(getPeerAddress(),PTimer::IN_startTimer,
+ reinterpret_cast<void*>(time),
+ sizeof(uint32)));
+ }
+ }
+ "
+ }
+ handle incoming startTimeout{
+ "
+ if (status==0){
+ status = ET_TIMER_RUNNING;
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ PTimer::getMessageString(PTimer::IN_startTimeout));
+ if (getPeerAddress().isValid()){
+ getPeerMsgReceiver()->receive(new Message(getPeerAddress(),PTimer::IN_startTimeout,
+ reinterpret_cast<void*>(time),
+ sizeof(uint32)));
+ }
+ }
+ "
+ }
+ handle outgoing timeout{
+ "
+ //TODO: clear active bit in case of single shot timer
+ if (status!=0){
+ if (status==ET_TIMER_RUNNING){
+ // single shot timer
+ status=0;
+ }
+ // msg to fsm
+ getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ }
+ "
+ }
+ handle incoming kill {
+ "
+ if (status!=0){
+ status=0;
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ PTimer::getMessageString(PTimer::IN_kill));
+ if (getPeerAddress().isValid()){
+ getPeerMsgReceiver()->receive(new Message(getPeerAddress(),PTimer::IN_kill, 0, 0));
+ }
+ }
+ "
+ }
+ Attribute status:int8="0"
+ }
+ }
+ ExternalType tcb -> etTimerControlBlock
+ ExternalType targetTime -> etTargetTime_t
+} \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/model/Types.room b/runtime/org.eclipse.etrice.modellib.cpp/model/Types.room
new file mode 100644
index 000000000..b9f15df1e
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/model/Types.room
@@ -0,0 +1,21 @@
+RoomModel room.basic.types {
+
+ PrimitiveType boolean: ptBoolean -> bool default "false"
+ PrimitiveType char: ptCharacter -> char default "0"
+ PrimitiveType int8: ptInteger -> int8 default "0"
+ PrimitiveType int16: ptInteger -> int16 default "0"
+ PrimitiveType int32: ptInteger -> int32 default "0"
+ PrimitiveType int64: ptInteger -> int64 default "0"
+
+ PrimitiveType uint8: ptInteger -> uint8 default "0"
+ PrimitiveType uint16: ptInteger -> uint16 default "0"
+ PrimitiveType uint32: ptInteger -> uint32 default "0"
+ PrimitiveType uint64: ptInteger -> uint64 default "0"
+
+ PrimitiveType float32:ptReal -> float32 default "0"
+ PrimitiveType float64:ptReal -> float64 default "0"
+
+ // TODO: define strings for C
+ PrimitiveType charPtr:ptCharacter -> charPtr default "0"
+ PrimitiveType string:ptCharacter -> charPtr default "0"
+} \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/model/diagrams/room.basic.service.timing.ATimingService.behavior b/runtime/org.eclipse.etrice.modellib.cpp/model/diagrams/room.basic.service.timing.ATimingService.behavior
new file mode 100644
index 000000000..dae159c62
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/model/diagrams/room.basic.service.timing.ATimingService.behavior
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="room.behavior" name="Behavior of ATimingService" pictogramLinks="//@link //@children.0/@link //@children.0/@children.1/@link //@children.0/@children.2/@link //@connections.0/@link //@connections.1/@link //@connections.2/@link //@connections.3/@link" verticalGridUnit="10" version="0.9.0">
+ <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/>
+ <link>
+ <businessObjects href="../TimingService.room#ActorClass:ATimingService"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="sg"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="858" height="381" x="37" y="33">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" transparency="0.5" width="778" height="301" x="40" y="40" cornerHeight="20" cornerWidth="20"/>
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" foreground="//@colors.2" lineWidth="4" filled="false" transparency="0.0" width="778" height="301" x="40" y="40" cornerHeight="20" cornerWidth="20"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../TimingService.room#StateGraph:ATimingService$sg"/>
+ </link>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="778" height="80" y="40" font="//@fonts.1" horizontalAlignment="ALIGNMENT_RIGHT" verticalAlignment="ALIGNMENT_TOP" value="/"/>
+ </children>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="trp"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="40" height="40" x="100" y="100">
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="20" height="20" x="10" y="10"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../TimingService.room#StateGraph:ATimingService$sg"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.0" referencedGraphicsAlgorithm="//@children.0/@children.1/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="40" height="20" y="10" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="I"/>
+ </children>
+ </children>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="state"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="435" height="216" x="237" y="52">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="375" height="156" x="30" y="30" cornerHeight="20" cornerWidth="20">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="15" height="8" x="350" y="3" cornerHeight="5" cornerWidth="5"/>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="187" y="150">
+ <points x="-3" y="-3"/>
+ <points x="-3" y="3"/>
+ <points x="-11" y="3"/>
+ </graphicsAlgorithmChildren>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" x="187" y="150">
+ <points x="3" y="-3"/>
+ <points x="3" y="3"/>
+ <points x="11" y="3"/>
+ </graphicsAlgorithmChildren>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="187" y="150">
+ <points x="-2" y="-3"/>
+ <points x="-2" y="3"/>
+ <points x="2" y="3"/>
+ <points x="2" y="-3"/>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../TimingService.room#SimpleState:ATimingService$Operational"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.1 //@connections.2 //@connections.3" incomingConnections="//@connections.0 //@connections.1 //@connections.2 //@connections.3" referencedGraphicsAlgorithm="//@children.0/@children.2/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="375" height="156" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="Operational"/>
+ </children>
+ </children>
+ </children>
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.1/@anchors.0" end="//@children.0/@children.2/@anchors.0">
+ <properties key="obj-type" value="trans"/>
+ <graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
+ <link>
+ <businessObjects href="../TimingService.room#InitialTransition:ATimingService$initial"/>
+ </link>
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
+ <graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
+ <points x="-15" y="5"/>
+ <points/>
+ <points x="-15" y="-5"/>
+ </graphicsAlgorithm>
+ </connectionDecorators>
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
+ <graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="10" font="//@fonts.0" value="init"/>
+ </connectionDecorators>
+ </connections>
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.2/@anchors.0" end="//@children.0/@children.2/@anchors.0">
+ <properties key="obj-type" value="trans"/>
+ <graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
+ <link>
+ <businessObjects href="../TimingService.room#TriggeredTransition:ATimingService$tr1"/>
+ </link>
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
+ <graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
+ <points x="-15" y="5"/>
+ <points/>
+ <points x="-15" y="-5"/>
+ </graphicsAlgorithm>
+ </connectionDecorators>
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
+ <graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="10" font="//@fonts.0" value="tr1: &lt;startTimeout:t..."/>
+ </connectionDecorators>
+ <bendpoints x="679" y="253"/>
+ <bendpoints x="707" y="253"/>
+ <bendpoints x="707" y="206"/>
+ </connections>
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.2/@anchors.0" end="//@children.0/@children.2/@anchors.0">
+ <properties key="obj-type" value="trans"/>
+ <graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
+ <link>
+ <businessObjects href="../TimingService.room#TriggeredTransition:ATimingService$tr3"/>
+ </link>
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
+ <graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
+ <points x="-15" y="5"/>
+ <points/>
+ <points x="-15" y="-5"/>
+ </graphicsAlgorithm>
+ </connectionDecorators>
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
+ <graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="-36" y="13" font="//@fonts.0" value="tr3: &lt;startTimer:tim..."/>
+ </connectionDecorators>
+ <bendpoints x="490" y="305"/>
+ <bendpoints x="591" y="305"/>
+ </connections>
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.2/@anchors.0" end="//@children.0/@children.2/@anchors.0">
+ <properties key="obj-type" value="trans"/>
+ <graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
+ <link>
+ <businessObjects href="../TimingService.room#TriggeredTransition:ATimingService$tr4"/>
+ </link>
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
+ <graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
+ <points x="-15" y="5"/>
+ <points/>
+ <points x="-15" y="-5"/>
+ </graphicsAlgorithm>
+ </connectionDecorators>
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
+ <graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="10" y="12" font="//@fonts.0" value="tr4: &lt;kill:timer>"/>
+ </connectionDecorators>
+ <bendpoints x="321" y="271"/>
+ <bendpoints x="321" y="300"/>
+ <bendpoints x="392" y="300"/>
+ </connections>
+ <colors red="227" green="238" blue="249"/>
+ <colors red="255" green="255" blue="255"/>
+ <colors/>
+ <colors red="200" green="200" blue="200"/>
+ <fonts name="Arial" size="8"/>
+ <fonts name="Arial" size="9" bold="true"/>
+</pi:Diagram>
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/model/diagrams/room.basic.service.timing.ATimingService.structure b/runtime/org.eclipse.etrice.modellib.cpp/model/diagrams/room.basic.service.timing.ATimingService.structure
new file mode 100644
index 000000000..0874065e7
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/model/diagrams/room.basic.service.timing.ATimingService.structure
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="room.structure" name="Structure of ATimingService" pictogramLinks="//@children.0/@link //@link //@children.0/@children.0/@link" verticalGridUnit="10" version="0.9.0">
+ <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/>
+ <link>
+ <businessObjects href="../TimingService.room#ActorClass:ATimingService"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="cls"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="571" height="294" x="40" y="40">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" transparency="0.5" width="491" height="214" x="40" y="40"/>
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="4" filled="false" transparency="0.0" width="491" height="214" x="40" y="40"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../TimingService.room#ActorClass:ATimingService"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="port"/>
+ <properties key="item-kind" value=""/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="80" height="80" x="245">
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.2" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="40" height="40" x="20" y="20"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../TimingService.room#SPPRef:ATimingService$timer"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.0/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="80" height="20" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="timer"/>
+ </children>
+ </children>
+ </children>
+ <colors red="227" green="238" blue="249"/>
+ <colors red="255" green="255" blue="255"/>
+ <colors/>
+ <fonts name="Arial" size="8"/>
+</pi:Diagram>
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/readme.txt b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/readme.txt
new file mode 100644
index 000000000..c3b99d458
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/readme.txt
@@ -0,0 +1,4 @@
+This directory is an eTrice code generation target.
+It will be erased every time the generator is executed.
+
+DO NOT PLACE OTHER FILES HERE!
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp
new file mode 100644
index 000000000..e8efe9edf
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp
@@ -0,0 +1,259 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of ActorClass ATimingService
+ *
+ */
+
+#include "ATimingService.h"
+#include "common/debugging/DebuggingService.h"
+#include <iostream>
+
+using namespace etRuntime;
+
+
+ATimingService::ATimingService(etRuntime::IRTObject* parent, std::string name, const std::vector<std::vector<etRuntime::Address> >& port_addr,
+ const std::vector<std::vector<etRuntime::Address> >& peer_addr)
+: ActorClassBase( parent, name, port_addr[0][0], peer_addr[0][0]),
+timer(*this, this, "timer", IFITEM_timer, port_addr[IFITEM_timer], peer_addr[IFITEM_timer]),
+tcbs(),
+usedTcbsRoot(0),
+freeTcbsRoot(0)
+{
+ setClassName("ATimingService");
+ // initialize attributes
+ for (int i=0;i<10;i++){
+ tcbs[i] = etTimerControlBlock();
+ }
+
+ getMsgsvc()->addAsyncActor(*this);
+}
+
+void ATimingService::init(){
+ initUser();
+}
+
+void ATimingService::start(){
+ startUser();
+}
+
+void ATimingService::stop(){
+ stopUser();
+}
+
+void ATimingService::destroy(){
+}
+
+
+std::string ATimingService::s_stateStrings[] = {"<no state>","<top>","Operational"
+};
+
+
+void ATimingService::setState(int new_state) {
+ DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state]);
+ if (s_stateStrings[new_state]!="Idle") {
+ std::cout << getInstancePath() << " -> " << s_stateStrings[new_state] << std::endl;
+ }
+ m_state = new_state;
+}
+
+/* Entry and Exit Codes */
+void ATimingService::entry_Operational() {
+ // prepare
+}
+ void ATimingService::do_Operational() {
+ // maintain timers
+ etTimerControlBlock* temp;
+ etTargetTime_t t;
+
+ getTimeFromTarget(&t);
+ while (usedTcbsRoot !=0 ){
+ if (isTimeGreater(&t,&(usedTcbsRoot->expTime))){
+ timer.get(usedTcbsRoot->portIdx).timeout();
+ temp=usedTcbsRoot;
+ usedTcbsRoot=usedTcbsRoot->next;
+ if((temp->pTime.sec==0)&&(temp->pTime.nSec==0)){
+ // single shot timer
+ returnTcb(temp);
+ }else{
+ // periodic timer
+ addTime(&temp->expTime,&temp->pTime);
+ putTcbToUsedList(temp);
+ }
+ }else{
+ break;
+ }
+ }
+}
+
+/* Action Codes */
+void ATimingService::action_TRANS_INITIAL_TO__Operational() {
+ int i;
+ usedTcbsRoot=0;
+ freeTcbsRoot=&tcbs[0];
+ tcbs[ET_NB_OF_TCBS-1].next=0;
+ for (i=0;i<ET_NB_OF_TCBS-1;i++){
+ tcbs[i].next=&tcbs[i+1];
+ }
+}
+void ATimingService::action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(const InterfaceItemBase* ifitem, uint32 time) {
+ etTimerControlBlock* timer = getTcb();
+ etTargetTime_t t;
+ if (timer!= 0){
+ t.sec=time/1000;
+ t.nSec=(time%1000)*1000000L;
+ timer->pTime.sec = 0;
+ timer->pTime.nSec = 0;
+ timer->portIdx=ifitem->getIdx();
+ getTimeFromTarget(&(timer->expTime));
+ addTime(&(timer->expTime),&t);
+ putTcbToUsedList(timer);
+ }
+}
+void ATimingService::action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(const InterfaceItemBase* ifitem, uint32 time) {
+ etTimerControlBlock* timer = getTcb();
+ etTargetTime_t t;
+ if (timer!= 0){
+ t.sec=time/1000;
+ t.nSec=(time%1000)*1000000L;
+ timer->pTime = t;
+ timer->portIdx=ifitem->getIdx();
+ getTimeFromTarget(&(timer->expTime));
+ addTime(&(timer->expTime),&t);
+ putTcbToUsedList(timer);
+ }
+}
+void ATimingService::action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(const InterfaceItemBase* ifitem) {
+ removeTcbFromUsedList(ifitem->getIdx());
+}
+
+/**
+ * calls exit codes while exiting from the current state to one of its
+ * parent states while remembering the history
+ * @param current - the current state
+ * @param to - the final parent state
+ * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
+ */
+void ATimingService::exitTo(int current, int to, bool handler) {
+ while (current!=to) {
+ switch (current) {
+ case STATE_Operational:
+ this->history[STATE_TOP] = STATE_Operational;
+ current = STATE_TOP;
+ break;
+ }
+ }
+}
+
+/**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @param chain - the chain ID
+ * @param generic_data - the generic data pointer
+ * @return the ID of the final state
+ */
+int ATimingService::executeTransitionChain(int chain, const InterfaceItemBase* ifitem, void* generic_data) {
+ switch (chain) {
+ case CHAIN_TRANS_INITIAL_TO__Operational:
+ {
+ action_TRANS_INITIAL_TO__Operational();
+ return STATE_Operational;
+ }
+ case CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1:
+ {
+ uint32 time = ((uint32) generic_data);
+ action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(ifitem, time);
+ return STATE_Operational;
+ }
+ case CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3:
+ {
+ uint32 time = ((uint32) generic_data);
+ action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(ifitem, time);
+ return STATE_Operational;
+ }
+ case CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4:
+ {
+ action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(ifitem);
+ return STATE_Operational;
+ }
+ }
+ return NO_STATE;
+}
+
+/**
+ * calls entry codes while entering a state's history. The ID of the final leaf state is returned
+ * @param state - the state which is entered
+ * @param handler - entry code is executed if not handler
+ * @return - the ID of the final leaf state
+ */
+int ATimingService::enterHistory(int state, bool handler, bool skip_entry) {
+ while (true) {
+ switch (state) {
+ case STATE_Operational:
+ if (!(skip_entry || handler)) entry_Operational();
+ // in leaf state: return state id
+ return STATE_Operational;
+ case STATE_TOP:
+ state = this->history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+}
+
+void ATimingService::executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__Operational;
+ int next = executeTransitionChain(chain, 0, 0);
+ next = enterHistory(next, false, false);
+ setState(next);
+}
+
+/* receiveEvent contains the main implementation of the FSM */
+void ATimingService::receiveEvent(InterfaceItemBase* ifitem, int evt, void* generic_data) {
+ int trigger = (ifitem==0)? POLLING : ifitem->getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ bool is_handler = false;
+ bool skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (getState()) {
+ case STATE_Operational:
+ switch(trigger) {
+ case POLLING:
+ do_Operational();
+ break;
+ case TRIG_timer__startTimeout:
+ {
+ chain = CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_timer__startTimer:
+ {
+ chain = CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_timer__kill:
+ {
+ chain = CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(getState(), catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+}
+
+//******************************************
+// END of generated code for FSM
+//******************************************
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h
new file mode 100644
index 000000000..de34e5728
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h
@@ -0,0 +1,263 @@
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of ActorClass ATimingService
+ *
+ */
+
+ #ifndef _ATIMINGSERVICE_H_
+ #define _ATIMINGSERVICE_H_
+
+ #include "platforms/generic/etDatatypes.h"
+ #include "common/messaging/IRTObject.h"
+ #include "common/modelbase/PortBase.h"
+ #include "common/modelbase/InterfaceItemBase.h"
+ #include "common/modelbase/ActorClassBase.h"
+ #include "common/modelbase/SubSystemClassBase.h"
+ #include "common/messaging/Address.h"
+ #include "common/messaging/IMessageReceiver.h"
+ #include "common/debugging/DebuggingService.h"
+ #include <string>
+ #include <vector>
+
+
+ #include "room/basic/service/timing/PTimer.h"
+
+
+ /*--------------------- begin user code ---------------------*/
+
+ #include "common/platform/etTimer.h"
+ #define ET_NB_OF_TCBS 10
+ typedef struct etTCB etTimerControlBlock;
+ struct etTCB {
+ etTargetTime_t expTime;
+ etTargetTime_t pTime;
+ int32 portIdx;
+ etTimerControlBlock* next;
+ };
+
+ /*--------------------- end user code ---------------------*/
+
+
+ class ATimingService : public etRuntime::ActorClassBase {
+
+
+ protected:
+ //--------------------- ports
+ //--------------------- saps
+ //--------------------- services
+ PTimerReplPort timer;
+
+ //--------------------- interface item IDs
+ typedef enum {
+ IFITEM_timer = 1,
+ } interface_items;
+
+ /*--------------------- attributes ---------------------*/
+ etTimerControlBlock tcbs[10];
+ etTimerControlBlock* usedTcbsRoot;
+ etTimerControlBlock* freeTcbsRoot;
+
+ /*--------------------- operations ---------------------*/
+ etTimerControlBlock* getTcb() {
+
+ etTimerControlBlock* temp = freeTcbsRoot;
+
+ if(freeTcbsRoot!=0) {
+ freeTcbsRoot=freeTcbsRoot->next;
+ temp->next=0;
+ }
+ return temp;
+ }
+ void returnTcb(etTimerControlBlock* block) {
+
+ block->next=freeTcbsRoot;
+ freeTcbsRoot=block;
+ }
+ void removeTcbFromUsedList(int32 idx) {
+
+ etTimerControlBlock* temp=usedTcbsRoot;
+ etTimerControlBlock* temp2=usedTcbsRoot;
+
+ if (temp==0) return;
+
+ if (usedTcbsRoot->portIdx == idx){
+ // element found, the first one
+ usedTcbsRoot = usedTcbsRoot->next;
+ returnTcb(temp);
+ return;
+ }
+
+ temp=temp->next;
+ while(temp!=0){
+ if(temp->portIdx==idx){
+ temp2->next=temp->next;
+ returnTcb(temp);
+ return;
+ }else{
+ // try next
+ temp2=temp;
+ temp=temp->next;
+ }
+ }
+ }
+ void putTcbToUsedList(etTimerControlBlock* block) {
+
+ etTimerControlBlock* temp=usedTcbsRoot;
+ etTimerControlBlock* temp2=usedTcbsRoot;
+
+ if (temp==0){
+ // list empty put new block to root
+ block->next=0;
+ usedTcbsRoot=block;
+ return;
+ }
+
+ while(1){
+ if (temp != 0){
+ if (isTimeGreater(&block->expTime,&temp->expTime)){
+ //try next position
+ temp2=temp;
+ temp=temp->next;
+ }else{
+ // right position found
+ block->next=temp;
+ if(temp==usedTcbsRoot){
+ usedTcbsRoot=block;
+ }else{
+ temp2->next=block;
+ }
+ return;
+ }
+ }else{
+ // end of list reached
+ block->next=0;
+ temp2->next=block;
+ return;
+ }
+ }
+ }
+ bool isTimeGreater(etTargetTime_t* t1, etTargetTime_t* t2) {
+
+ if (t1->sec > t2->sec) return TRUE;
+ if (t1->sec < t2->sec) return FALSE;
+ if (t1->nSec > t2->nSec) return TRUE;
+ return FALSE;
+ }
+ void addTime(etTargetTime_t* t1, etTargetTime_t* t2) {
+
+ t1->sec += t2->sec;
+ t1->nSec += t2->nSec;
+ while(t1->nSec >= 1000000000L){
+ t1->sec++;
+ t1->nSec-=1000000000L;
+ }
+ }
+ void printList() {
+
+ etTimerControlBlock* temp=usedTcbsRoot;
+ printf("list: ");
+ while (temp!=0){
+ printf("(%ld,%ld),",temp->expTime.sec,temp->expTime.nSec);
+ temp=temp->next;
+ }
+ printf("\n");
+ }
+
+ public:
+ //--------------------- construction
+ ATimingService(etRuntime::IRTObject* parent, std::string name, const std::vector<std::vector<etRuntime::Address> >& port_addr,
+ const std::vector<std::vector<etRuntime::Address> >& peer_addr);
+
+ //--------------------- port getters
+ PTimerReplPort getTimer (){
+ return this->timer;
+ }
+
+ //--------------------- lifecycle functions
+ virtual void init();
+ virtual void start();
+ virtual void stop();
+ virtual void destroy();
+
+ /* state IDs */
+ typedef enum {
+ STATE_Operational = 2,
+ } state_ids;
+
+ /* transition chains */
+ typedef enum {
+ CHAIN_TRANS_INITIAL_TO__Operational = 1,
+ CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1 = 2,
+ CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3 = 3,
+ CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4 = 4,
+ } chain_ids;
+
+ /* triggers */
+ typedef enum {
+ POLLING = 0,
+ TRIG_timer__kill = IFITEM_timer + EVT_SHIFT*PTimer::IN_kill,
+ TRIG_timer__startTimeout = IFITEM_timer + EVT_SHIFT*PTimer::IN_startTimeout,
+ TRIG_timer__startTimer = IFITEM_timer + EVT_SHIFT*PTimer::IN_startTimer,
+ } triggers;
+
+ protected:
+ static std::string s_stateStrings[];
+
+ int history[];
+
+ private:
+ void setState(int new_state);
+
+ /* Entry and Exit Codes */
+ void entry_Operational();
+ void do_Operational();
+
+ /* Action Codes */
+ void action_TRANS_INITIAL_TO__Operational();
+ void action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(const etRuntime::InterfaceItemBase* ifitem, uint32 time);
+ void action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(const etRuntime::InterfaceItemBase* ifitem, uint32 time);
+ void action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(const etRuntime::InterfaceItemBase* ifitem);
+
+ private:
+ /**
+ * calls exit codes while exiting from the current state to one of its
+ * parent states while remembering the history
+ * @param current - the current state
+ * @param to - the final parent state
+ * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
+ */
+ void exitTo(int current, int to, bool handler);
+
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @param chain - the chain ID
+ * @param generic_data - the generic data pointer
+ * @return the ID of the final state
+ */
+ int executeTransitionChain(int chain, const etRuntime::InterfaceItemBase* ifitem, void* generic_data);
+
+ /**
+ * calls entry codes while entering a state's history. The ID of the final leaf state is returned
+ * @param state - the state which is entered
+ * @param handler - entry code is executed if not handler
+ * @return - the ID of the final leaf state
+ */
+ int enterHistory(int state, bool handler, bool skip_entry);
+
+ public:
+
+ void executeInitTransition();
+
+ /* receiveEvent contains the main implementation of the FSM */
+ void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* generic_data);
+
+ /*--------------------- begin user code ---------------------*/
+ //uc2
+ /*--------------------- end user code ---------------------*/
+
+ };
+
+
+ #endif /* _ATIMINGSERVICE_H_ */
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp
new file mode 100644
index 000000000..9b4aa2678
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp
@@ -0,0 +1,242 @@
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass PTimer
+ *
+ */
+
+ #include "PTimer.h"
+ #include "common/debugging/DebuggingService.h"
+ #include <iostream>
+
+ using namespace etRuntime;
+
+
+ /*--------------------- begin user code ---------------------*/
+ //uc2
+ /*--------------------- end user code ---------------------*/
+
+ //------------------------------------------------------------------------------------------------------------
+ // port class
+ //------------------------------------------------------------------------------------------------------------
+
+ PTimerPort::PTimerPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, Address addr, Address peerAddress, bool doRegistration)
+ : PortBase(actor, parent, name, localId, 0, addr, peerAddress)
+ {
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+ }
+
+ PTimerPort::PTimerPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, Address addr, Address peerAddress, bool doRegistration)
+ : PortBase(actor, parent, name, localId, idx, addr, peerAddress)
+ {
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+ }
+
+ void PTimerPort::receive(Message* msg) {
+ if (! PTimer::isValidIncomingEvtID(msg->getEvtId())) {
+ std::cout << "unknown" << std::endl;
+ }
+ else {
+ if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), PTimer::getMessageString(msg->getEvtId()));
+ }
+
+ getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ }
+ };
+
+
+ // sent messages
+ void PTimerPort::timeout() {
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ PTimer::getMessageString(PTimer::OUT_timeout));
+ if (getPeerAddress().isValid()){
+ getPeerMsgReceiver()->receive(new Message(getPeerAddress(), PTimer::OUT_timeout));
+ }
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ // replicated port class
+ //------------------------------------------------------------------------------------------------------------
+ PTimerReplPort::PTimerReplPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<Address> addr, std::vector<Address> peerAddress)
+ : m_replication(addr.size()),
+ m_ports()
+ {
+ char numstr[10]; // enough to hold all numbers up to 32-bits
+
+ m_ports = reinterpret_cast<PTimerPort*> (new char[sizeof(PTimerPort) * addr.size()]);
+ for (int i = 0; i < m_replication; ++i) {
+ snprintf(numstr, sizeof(numstr), "%d", i);
+ //placement new to avoid copy construction, therefore no vector is used
+ new (&m_ports[i]) PTimerPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);
+ }
+ };
+
+
+ // outgoing messages
+ void PTimerReplPort::timeout(){
+ for (int i=0; i<m_replication; ++i) {
+ m_ports[i].timeout();
+ }
+ }
+ //------------------------------------------------------------------------------------------------------------
+ // conjugated port class
+ //------------------------------------------------------------------------------------------------------------
+
+ PTimerConjPort::PTimerConjPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, Address addr, Address peerAddress, bool doRegistration)
+ : PortBase(actor, parent, name, localId, 0, addr, peerAddress),
+ status(0)
+ {
+ // initialize attributes
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+ }
+
+ PTimerConjPort::PTimerConjPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, Address addr, Address peerAddress, bool doRegistration)
+ : PortBase(actor, parent, name, localId, idx, addr, peerAddress),
+ status(0)
+ {
+ // initialize attributes
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+ }
+
+ void PTimerConjPort::receive(Message* msg) {
+ if (! PTimer::isValidOutgoingEvtID(msg->getEvtId())) {
+ std::cout << "unknown" << std::endl;
+ }
+ else {
+ if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), PTimer::getMessageString(msg->getEvtId()));
+ }
+
+ switch (msg->getEvtId()) {
+ case PTimer::OUT_timeout:
+ {
+
+ //TODO: clear active bit in case of single shot timer
+ if (status!=0){
+ if (status==ET_TIMER_RUNNING){
+ // single shot timer
+ status=0;
+ }
+ // msg to fsm
+ getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ }
+ }
+ break;
+ default:
+ getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ break;
+ }
+ }
+ };
+
+ /*--------------------- operations ---------------------*/
+
+ // sent messages
+ void PTimerConjPort::startTimer(uint32 time) {
+
+ if (status==0){
+ status=ET_TIMER_RUNNING | ET_TIMER_PERIODIC;
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ PTimer::getMessageString(PTimer::IN_startTimer));
+ if (getPeerAddress().isValid()){
+ getPeerMsgReceiver()->receive(new Message(getPeerAddress(),PTimer::IN_startTimer,
+ reinterpret_cast<void*>(time),
+ sizeof(uint32)));
+ }
+ }
+ }
+
+ void PTimerConjPort::startTimeout(uint32 time) {
+
+ if (status==0){
+ status = ET_TIMER_RUNNING;
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ PTimer::getMessageString(PTimer::IN_startTimeout));
+ if (getPeerAddress().isValid()){
+ getPeerMsgReceiver()->receive(new Message(getPeerAddress(),PTimer::IN_startTimeout,
+ reinterpret_cast<void*>(time),
+ sizeof(uint32)));
+ }
+ }
+ }
+
+ void PTimerConjPort::kill() {
+
+ if (status!=0){
+ status=0;
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ PTimer::getMessageString(PTimer::IN_kill));
+ if (getPeerAddress().isValid()){
+ getPeerMsgReceiver()->receive(new Message(getPeerAddress(),PTimer::IN_kill, 0, 0));
+ }
+ }
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ // conjugated replicated port class
+ //------------------------------------------------------------------------------------------------------------
+ PTimerConjReplPort::PTimerConjReplPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<Address> addr, std::vector<Address> peerAddress)
+ : m_replication(addr.size()),
+ m_ports()
+ {
+ char numstr[10]; // enough to hold all numbers up to 32-bits
+
+ m_ports = reinterpret_cast<PTimerConjPort*> (new char[sizeof(PTimerConjPort) * addr.size()]);
+ for (int i = 0; i < m_replication; ++i) {
+ snprintf(numstr, sizeof(numstr), "%d", i);
+ //placement new to avoid copy construction, therefore no vector is used
+ new (&m_ports[i]) PTimerConjPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);
+ }
+ };
+
+
+ // outgoing messages
+ void PTimerConjReplPort::startTimer(uint32 time){
+ for (int i=0; i<m_replication; ++i) {
+ m_ports[i].startTimer( time);
+ }
+ }
+ void PTimerConjReplPort::startTimeout(uint32 time){
+ for (int i=0; i<m_replication; ++i) {
+ m_ports[i].startTimeout( time);
+ }
+ }
+ void PTimerConjReplPort::kill(){
+ for (int i=0; i<m_replication; ++i) {
+ m_ports[i].kill();
+ }
+ }
+
+ /*--------------------- debug helpers */
+
+ /* message names as strings for debugging (generate MSC) */
+ std::string PTimer::s_messageStrings[]
+ = {"MIN",
+ "timeout",
+ "startTimer",
+ "startTimeout",
+ "kill",
+ "MAX"};
+
+ std::string PTimer::getMessageString(int msg_id) {
+ if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {
+ return s_messageStrings[msg_id];
+ } else {
+ // id out of range
+ return "Message ID out of range";
+ }
+ }
+
+
+
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.h b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.h
new file mode 100644
index 000000000..0ee3d1208
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.h
@@ -0,0 +1,139 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of ProtocolClass PTimer
+ *
+ */
+
+#ifndef _PTIMER_H_
+#define _PTIMER_H_
+
+#include "platforms/generic/etDatatypes.h"
+#include "common/messaging/IRTObject.h"
+#include "common/modelbase/PortBase.h"
+#include "common/modelbase/InterfaceItemBase.h"
+#include "common/messaging/Address.h"
+#include "common/messaging/Message.h"
+#include <vector>
+#include <string>
+
+namespace etRuntime {
+ class IEventReceiver;
+
+}
+
+/*--------------------- begin user code ---------------------*/
+
+ #define ET_TIMER_RUNNING 0x01
+ #define ET_TIMER_PERIODIC 0x02
+
+/*--------------------- end user code ---------------------*/
+
+
+class PTimer {
+ public:
+ /* message IDs */
+ typedef enum {
+ MSG_MIN = 0,
+ OUT_timeout = 1,
+ IN_startTimer = 2,
+ IN_startTimeout = 3,
+ IN_kill = 4,
+ MSG_MAX = 5,
+ } msg_ids;
+ static bool isValidEvtID(int evtId) {
+ return ((MSG_MIN < evtId) && (evtId < MSG_MAX));
+ };
+ static bool isValidOutgoingEvtID(int evtId) {
+ return ((MSG_MIN < evtId) && (evtId < IN_startTimer));
+ };
+ static bool isValidIncomingEvtID(int evtId) {
+ return ((IN_startTimer <= evtId) && (evtId < MSG_MAX));
+ };
+ static std::string getMessageString(int msg_id);
+
+ private:
+ static std::string s_messageStrings[];
+ /*--------------------- begin user code ---------------------*/
+ //uc2
+ /*--------------------- end user code ---------------------*/
+};
+
+//------------------------------------------------------------------------------------------------------------
+// port class
+//------------------------------------------------------------------------------------------------------------
+class PTimerPort : public etRuntime::PortBase {
+ public:
+ // constructors
+ PTimerPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true);
+ PTimerPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true);
+
+ virtual void receive(etRuntime::Message* m);
+
+ // outgoing messages
+ public: void timeout();
+};
+
+//------------------------------------------------------------------------------------------------------------
+// replicated port class
+//------------------------------------------------------------------------------------------------------------
+class PTimerReplPort {
+ private:
+ int m_replication;
+ PTimerPort* m_ports; //dynamic array used instead of vector to avoid copy construction
+
+ public:
+ PTimerReplPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<etRuntime::Address> addr, std::vector<etRuntime::Address> peerAddress);
+ virtual ~PTimerReplPort() {};
+
+ int getReplication() { return m_replication; }
+ int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx(); }
+ PTimerPort get(int i) {return m_ports[i];}
+
+ // outgoing messages
+ public: void timeout();
+
+};
+//------------------------------------------------------------------------------------------------------------
+// conjugated port class
+//------------------------------------------------------------------------------------------------------------
+class PTimerConjPort : public etRuntime::PortBase {
+ public:
+ // constructors
+ PTimerConjPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true);
+ PTimerConjPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true);
+
+ virtual void receive(etRuntime::Message* m);
+ /*--------------------- attributes ---------------------*/
+ int8 status;
+ /*--------------------- operations ---------------------*/
+
+ // outgoing messages
+ public: void startTimer(uint32 time);
+ public: void startTimeout(uint32 time);
+ public: void kill();
+};
+
+//------------------------------------------------------------------------------------------------------------
+// conjugated replicated port class
+//------------------------------------------------------------------------------------------------------------
+class PTimerConjReplPort {
+ private:
+ int m_replication;
+ PTimerConjPort* m_ports; //dynamic array used instead of vector to avoid copy construction
+
+ public:
+ PTimerConjReplPort(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<etRuntime::Address> addr, std::vector<etRuntime::Address> peerAddress);
+ virtual ~PTimerConjReplPort() {};
+
+ int getReplication() { return m_replication; }
+ int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx(); }
+ PTimerConjPort get(int i) {return m_ports[i];}
+
+ // outgoing messages
+ public: void startTimer(uint32 time);
+ public: void startTimeout(uint32 time);
+ public: void kill();
+
+};
+#endif /* _PTIMER_H_ */
diff --git a/runtime/org.eclipse.etrice.modellib.java/buckminster.cspec b/runtime/org.eclipse.etrice.modellib.java/buckminster.cspec
index 8f341b430..0380bfe86 100644
--- a/runtime/org.eclipse.etrice.modellib.java/buckminster.cspec
+++ b/runtime/org.eclipse.etrice.modellib.java/buckminster.cspec
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
-<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.modellib.java" componentType="buckminster" version="1.0.0"/>
+<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.modellib.java" componentType="buckminster" version="0.3.0.qualifier"/>
diff --git a/runtime/org.eclipse.etrice.runtime.c/about.html b/runtime/org.eclipse.etrice.runtime.c/about.html
new file mode 100644
index 000000000..82d49bf5f
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/runtime/org.eclipse.etrice.runtime.c/buckminster.cspec b/runtime/org.eclipse.etrice.runtime.c/buckminster.cspec
index 3982c48d6..0c80825e2 100644
--- a/runtime/org.eclipse.etrice.runtime.c/buckminster.cspec
+++ b/runtime/org.eclipse.etrice.runtime.c/buckminster.cspec
@@ -1,2 +1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.runtime.c" componentType="buckminster" version="0.0.2"/>
+<?xml version="1.0" encoding="UTF-8"?><cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.runtime.c" componentType="buckminster" version="0.3.0.qualifier"/>
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c
index 4596292a7..fa0fc43e1 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c
@@ -41,17 +41,25 @@ char* etMSCLogger_getObjectName(void){
}
void etMSCLogger_syncCall(char* sourceName, char* messageName, char* targetName){
- etLogger_fprintf(etMSCLogger_fileHandle, "%s ==> %s %s\n", sourceName, targetName, messageName);
+ if (etMSCLogger_fileHandle != NULL) {
+ etLogger_fprintf(etMSCLogger_fileHandle, "%s ==> %s %s\n", sourceName, targetName, messageName);
+ }
}
void etMSCLogger_syncReturn(char* sourceName, char* targetName){
- etLogger_fprintf(etMSCLogger_fileHandle, "%s <== %s\n", sourceName, targetName);
+ if (etMSCLogger_fileHandle != NULL) {
+ etLogger_fprintf(etMSCLogger_fileHandle, "%s <== %s\n", sourceName, targetName);
+ }
}
void etMSCLogger_asyncOut(char* sourceName, char* messageName, char* targetName){
- etLogger_fprintf(etMSCLogger_fileHandle, "%s >-- %s %s\n", sourceName, targetName, messageName);
+ if (etMSCLogger_fileHandle != NULL) {
+ etLogger_fprintf(etMSCLogger_fileHandle, "%s >-- %s %s\n", sourceName, targetName, messageName);
+ }
}
void etMSCLogger_asyncIn(char* sourceName, char* messageName, char* targetName){
- etLogger_fprintf(etMSCLogger_fileHandle, "%s --> %s %s\n", sourceName, targetName, messageName);
+ if (etMSCLogger_fileHandle != NULL) {
+ etLogger_fprintf(etMSCLogger_fileHandle, "%s --> %s %s\n", sourceName, targetName, messageName);
+ }
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.c b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.c
index b7ae57028..5783e905d 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.c
@@ -12,7 +12,7 @@
#include "modelbase/etActor.h"
-etBool handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data) {
+etBool handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data) {
/* TODO */
return FALSE;
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h
index 182a2f912..4791fa991 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h
@@ -19,6 +19,6 @@
#define NOT_CAUGHT 0
#define EVT_SHIFT 100
-etBool handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data);
+etBool handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data);
#endif /* _ETACTOR_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h
index f6fe71c2d..dbeeaa7e0 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h
@@ -50,7 +50,7 @@ typedef struct {
const etReplSubPort* ports;
} etReplPort;
-typedef etPort* InterfaceItemBase;
+typedef etPort InterfaceItemBase;
//void etPort_receive(const etPort* self, const etMessage* msg);
void etPort_sendMessage(const etPort* self, etInt16 evtId, int size, void* data);
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/.cproject b/runtime/org.eclipse.etrice.runtime.cpp/.cproject
new file mode 100644
index 000000000..9ae0da066
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/.cproject
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/org.eclipse.etrice.runtime.cpp"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/org.eclipse.etrice.runtime.cpp/Debug"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="org.eclipse.etrice.runtime.cpp" srcPrefixMapping="" srcRootPath=""/>
+ </externalSetting>
+ </externalSettings>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.lib.debug">
+ <folderInfo id="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.lib.debug.1964804313" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.lib.debug">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.lib.debug.1363258846" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.lib.debug"/>
+ <builder buildPath="${workspace_loc:/org.eclipse.etrice.runtime.cpp/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.765054146" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.lib.debug.778368249" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.lib.debug">
+ <option id="gnu.both.asm.option.include.paths.479529629" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/platforms/generic}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1431383431" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.lib.debug.2067321690" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.lib.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug.1516705340" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug">
+ <option id="gnu.cpp.compiler.mingw.lib.debug.option.optimization.level.143629884" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.lib.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.mingw.lib.debug.option.debugging.level.1636571561" name="Debug Level" superClass="gnu.cpp.compiler.mingw.lib.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.371088988" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/platforms/generic}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.834970834" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.787652226" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.lib.debug.option.optimization.level.1338147333" name="Optimization Level" superClass="gnu.c.compiler.mingw.lib.debug.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.mingw.lib.debug.option.debugging.level.1088652134" name="Debug Level" superClass="gnu.c.compiler.mingw.lib.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.c.compiler.option.include.paths.181765143" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/platforms/generic}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1322245631" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.833683108" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.1619419934" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536" moduleId="org.eclipse.cdt.core.settings" name="Release">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/org.eclipse.etrice.runtime.cpp"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/org.eclipse.etrice.runtime.cpp/Release"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="org.eclipse.etrice.runtime.cpp" srcPrefixMapping="" srcRootPath=""/>
+ </externalSetting>
+ </externalSettings>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536" name="Release" parent="cdt.managedbuild.config.gnu.mingw.lib.release">
+ <folderInfo id="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.lib.release.341416755" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.lib.release">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.lib.release.2033657787" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.lib.release"/>
+ <builder buildPath="${workspace_loc:/org.eclipse.etrice.runtime.cpp/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.629737011" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.lib.release.1791075014" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.lib.release">
+ <option id="gnu.both.asm.option.include.paths.227502240" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths"/>
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1768068662" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.lib.release.633341399" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.lib.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.release.567360588" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.release">
+ <option id="gnu.cpp.compiler.mingw.lib.release.option.optimization.level.584961348" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.lib.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.mingw.lib.release.option.debugging.level.1368123052" name="Debug Level" superClass="gnu.cpp.compiler.mingw.lib.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.763277987" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/platforms/generic}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1712453980" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.release.2143016498" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.release">
+ <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.lib.release.option.optimization.level.180068255" name="Optimization Level" superClass="gnu.c.compiler.mingw.lib.release.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.mingw.lib.release.option.debugging.level.1290753638" name="Debug Level" superClass="gnu.c.compiler.mingw.lib.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+ <option id="gnu.c.compiler.option.include.paths.1098867338" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/platforms/generic}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1857566126" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.536323295" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.2051974509" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="org.eclipse.etrice.runtime.cpp.cdt.managedbuild.target.gnu.mingw.lib.335663705" name="Static Library" projectType="cdt.managedbuild.target.gnu.mingw.lib"/>
+ </storageModule>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Release">
+ <resource resourceType="PROJECT" workspacePath="/org.eclipse.etrice.runtime.cpp"/>
+ </configuration>
+ <configuration configurationName="Debug">
+ <resource resourceType="PROJECT" workspacePath="/org.eclipse.etrice.runtime.cpp"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176;cdt.managedbuild.config.gnu.mingw.lib.debug.878140176.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug.1516705340;cdt.managedbuild.tool.gnu.cpp.compiler.input.834970834">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536;cdt.managedbuild.config.gnu.mingw.lib.release.1265017536.;cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.release.2143016498;cdt.managedbuild.tool.gnu.c.compiler.input.1857566126">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176;cdt.managedbuild.config.gnu.mingw.lib.debug.878140176.;cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.787652226;cdt.managedbuild.tool.gnu.c.compiler.input.1322245631">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536;cdt.managedbuild.config.gnu.mingw.lib.release.1265017536.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.release.567360588;cdt.managedbuild.tool.gnu.cpp.compiler.input.1712453980">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+</cproject>
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/.gitignore b/runtime/org.eclipse.etrice.runtime.cpp/.gitignore
new file mode 100644
index 000000000..5dde7aeef
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/.gitignore
@@ -0,0 +1,2 @@
+bin
+Debug
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/.project b/runtime/org.eclipse.etrice.runtime.cpp/.project
new file mode 100644
index 000000000..fa5e9dbfd
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/.project
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.runtime.cpp</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildLocation</key>
+ <value>${workspace_loc:/org.eclipse.etrice.runtime.cpp/Debug}</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>false</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+</projectDescription>
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.codan.core.prefs b/runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.codan.core.prefs
new file mode 100644
index 000000000..3ab3be8eb
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.codan.core.prefs
@@ -0,0 +1,67 @@
+eclipse.preferences.version=1
+org.eclipse.cdt.codan.checkers.errnoreturn=Warning
+org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
+org.eclipse.cdt.codan.checkers.errreturnvalue=Error
+org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.checkers.noreturn=Error
+org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
+org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
+org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
+org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
+org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false}
+org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
+org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()}
+org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
+org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
+org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true}
+org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
+org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
+org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
+org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
+org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
+org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
+org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
+org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
+org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
+org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
+org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()}
+org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false}
+org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false}
+org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
+org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
+org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")}
+org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs
new file mode 100644
index 000000000..8be085b41
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs
@@ -0,0 +1,9 @@
+eclipse.preferences.version=1
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/CPATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/CPATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/CPLUS_INCLUDE_PATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/CPLUS_INCLUDE_PATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/C_INCLUDE_PATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/C_INCLUDE_PATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/append=true
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/appendContributed=true
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/about.html b/runtime/org.eclipse.etrice.runtime.cpp/about.html
new file mode 100644
index 000000000..82d49bf5f
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/buckminster.cspec b/runtime/org.eclipse.etrice.runtime.cpp/buckminster.cspec
new file mode 100644
index 000000000..7ba0fbcf8
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/buckminster.cspec
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.runtime.cpp" componentType="buckminster" version="0.3.0.qualifier"/>
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
new file mode 100644
index 000000000..17593038c
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
@@ -0,0 +1,70 @@
+/*
+ * DebuggingService.cpp
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#include "DebuggingService.h"
+#include "common/modelbase/ActorClassBase.h"
+#include <iostream>
+
+namespace etRuntime {
+
+DebuggingService* DebuggingService::s_instance = 0;
+
+DebuggingService::DebuggingService()
+: asyncLogger() ,
+ syncLogger(),
+ portInstances()
+{
+}
+
+DebuggingService::~DebuggingService() {
+}
+
+
+void DebuggingService::addMessageAsyncOut(Address source, Address target,
+ std::string msg) {
+ asyncLogger.addMessageAsyncOut(portInstances.at(source)->getActorRTObject().getInstancePath(),
+ portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
+}
+
+void DebuggingService::addMessageAsyncIn(Address source, Address target,
+ std::string msg) {
+ asyncLogger.addMessageAsyncIn(portInstances.at(source)->getActorRTObject().getInstancePath(),
+ portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
+}
+
+void DebuggingService::addMessageSyncCall(Address source, Address target,
+ std::string msg) {
+ asyncLogger.addMessageSyncCall(portInstances.at(source)->getActorRTObject().getInstancePath(),
+ portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
+}
+
+void DebuggingService::addMessageSyncReturn(Address source, Address target,
+ std::string msg) {
+ asyncLogger.addMessageSyncReturn(portInstances.at(source)->getActorRTObject().getInstancePath(),
+ portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
+}
+
+void DebuggingService::addActorState(const ActorClassBase& actor,
+ std::string state) {
+ asyncLogger.addActorState(actor.getInstancePath(), state);
+}
+
+void DebuggingService::addPortInstance(PortBase& port) {
+ portInstances[port.getAddress()] = &port;
+ std::cout << "adding " << port.getAddress().toID() << " " << &port << " " << port.getParent()->getInstancePathName()<< std::endl;
+}
+
+MSCLogger& DebuggingService::getSyncLogger() {
+ return syncLogger;
+}
+
+MSCLogger& DebuggingService::getAsyncLogger() {
+ return asyncLogger;
+}
+
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h
new file mode 100644
index 000000000..ebfeb0f8a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h
@@ -0,0 +1,62 @@
+/*
+ * DebuggingService.h
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef DEBUGGINGSERVICE_H_
+#define DEBUGGINGSERVICE_H_
+
+#include "common/messaging/Address.h"
+#include "common/debugging/MSCLogger.h"
+#include "common/modelbase/PortBase.h"
+#include <string>
+#include <map>
+
+namespace etRuntime {
+
+class ActorClassBase;
+
+class DebuggingService {
+private:
+ static DebuggingService* s_instance;
+
+public:
+ virtual ~DebuggingService();
+
+ static DebuggingService& getInstance() {
+ if (s_instance == 0) {
+ s_instance = new DebuggingService();
+ }
+ return *s_instance;
+ }
+
+ void addMessageAsyncOut(Address source, Address target, std::string msg);
+ void addMessageAsyncIn(Address source, Address target, std::string msg);
+ void addMessageSyncCall(Address source, Address target, std::string msg);
+ void addMessageSyncReturn(Address source, Address target, std::string msg);
+ void addActorState(const ActorClassBase& actor, std::string state);
+ void addPortInstance(PortBase& port);
+ MSCLogger& getSyncLogger();
+ MSCLogger& getAsyncLogger();
+
+private:
+
+ MSCLogger asyncLogger;
+ MSCLogger syncLogger;
+ std::map<Address, PortBase*> portInstances;
+
+ DebuggingService();
+ DebuggingService(const DebuggingService& right);
+ DebuggingService& operator=(const DebuggingService& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* DEBUGGINGSERVICE_H_ */
+
+
+
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.cpp
new file mode 100644
index 000000000..b50cc8e3d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.cpp
@@ -0,0 +1,43 @@
+/*
+ * MSCFilter.cpp
+ *
+ * Created on: 16.08.2012
+ * Author: karlitsc
+ */
+
+#include "MSCFilter.h"
+
+namespace etRuntime {
+
+MSCFilter::MSCFilter() :
+ filterList() {
+}
+MSCFilter::~MSCFilter() {
+}
+
+void MSCFilter::addFilter(FilterItem filter) {
+ filterList.push_back(filter);
+}
+
+bool MSCFilter::applyTo(std::string text) {
+ if (filterList.empty())
+ return true; // no filters -> all messages will be logged
+ std::list<FilterItem>::iterator it = filterList.begin();
+ for ( ; it != filterList.end(); ++it) {
+ if (text.compare((*it).filter) == 0)
+ return !(*it).exclude;
+ }
+ return false;
+}
+
+std::string MSCFilter::reduceString(std::string string) {
+ if (filterList.size() == 1)
+ //TODO: filtering with regular expression
+ // return string.replaceFirst(filterList.front().filter, "");
+ return string;
+ else
+ return string;
+}
+
+} /* namespace etRuntime */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.h
new file mode 100644
index 000000000..c1e34c44b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.h
@@ -0,0 +1,43 @@
+/*
+ * MSCFilter.h
+ *
+ * Created on: 16.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef MSCFILTER_H_
+#define MSCFILTER_H_
+
+#include <list>
+#include <string>
+
+namespace etRuntime {
+
+class MSCFilter {
+public:
+ class FilterItem{
+ public:
+ FilterItem(std::string filter_, bool exclude_)
+ : exclude(exclude_),
+ filter(filter_)
+ {};
+ bool exclude;
+ std::string filter;
+ private:
+ FilterItem();
+ };
+
+ MSCFilter();
+ virtual ~MSCFilter();
+
+ void addFilter(FilterItem filter);
+ bool applyTo(std::string text);
+ std::string reduceString(std::string string);
+
+private:
+ std::list<FilterItem> filterList;
+
+};
+
+} /* namespace etRuntime */
+#endif /* MSCFILTER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.cpp
new file mode 100644
index 000000000..42099f812
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.cpp
@@ -0,0 +1,99 @@
+/*
+ * MSCLogger.cpp
+ *
+ * Created on: 16.08.2012
+ * Author: karlitsc
+ */
+
+#include "MSCLogger.h"
+
+namespace etRuntime {
+
+MSCLogger::MSCLogger()
+: commandList(),
+ filter(0),
+ path(),
+ msc_name(),
+is_open(false)
+{
+}
+
+MSCLogger::~MSCLogger() {
+ delete filter;
+ filter = 0;
+}
+
+void MSCLogger::setMSC(std::string msc_name_, std::string path_) {
+ msc_name = msc_name_;
+ path = path_;
+ delete filter;
+ filter = new MSCFilter();
+}
+
+void MSCLogger::addMessageAsyncOut(std::string source, std::string target,
+ std::string message) {
+ createLine(source, " >-- ", target, message);
+}
+
+void MSCLogger::addMessageAsyncIn(std::string source, std::string target,
+ std::string message) {
+ createLine(source, " --> ", target, message);
+}
+
+void MSCLogger::addMessageSyncCall(std::string source, std::string target,
+ std::string message) {
+ createLine(source, " ==> ", target, message);
+}
+
+void MSCLogger::addMessageSyncReturn(std::string source, std::string target,
+ std::string message) {
+ createLine(source, " <== ", target, message);
+}
+
+void MSCLogger::addActorState(std::string actor, std::string state) {
+ if (filter->applyTo(actor))
+ commandList.push_back("\t" + filter->reduceString(actor) + " >>> " + state);
+}
+
+void MSCLogger::createLine(std::string source, std::string mid, std::string target, std::string message) {
+ if (filter->applyTo(source) && filter->applyTo(target)) {
+ commandList.push_back( "\t"+filter->reduceString(source)+mid+filter->reduceString(target)+ " " + message);
+ }
+}
+
+void MSCLogger::close() {
+ if (is_open) {
+// try {
+ //TODO: error handling
+ // Create file
+ std::ofstream myfile;
+ //TODO: where to create the file
+ // std::string dir = "tmp/log"; doesn't work on windows
+ std::string dir = "";
+ myfile.open (std::string(dir + path + msc_name + ".seq").c_str(), std::ios::out);
+ if (myfile.is_open()) { /* ok, proceed with output */
+ saveMSCforTrace2UML(myfile);
+ myfile.close();
+ }
+// };
+ }
+ is_open = false;
+}
+
+void MSCLogger::saveMSCforTrace2UML(std::ofstream& out) {
+ //try {
+ //TODO: errorhandling
+ out << "#generated MSC for Trace2UML";
+ out << std::endl ;
+ std::list<std::string>::iterator it = commandList.begin();
+ for ( ; it != commandList.end(); ++it) {
+ out << (*it) << std::endl;
+ }
+// } catch (IOException e) {
+// System.err.println("Error: " + e.getMessage());
+// }
+
+}
+
+
+}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.h
new file mode 100644
index 000000000..51827d906
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.h
@@ -0,0 +1,63 @@
+/*
+ * MSCLogger.h
+ *
+ * Created on: 16.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef MSCLOGGER_H_
+#define MSCLOGGER_H_
+
+#include <string>
+#include <list>
+#include <iostream>
+#include <fstream>
+#include "MSCFilter.h"
+
+namespace etRuntime {
+
+class MSCLogger {
+public:
+ MSCLogger();
+ virtual ~MSCLogger();
+
+ void setMSC(std::string msc_name_, std::string path_);
+
+ //TODO synchronized
+ void open() {is_open = true; };
+ //TODO synchronized
+ void addMessageAsyncOut(std::string source, std::string target, std::string message);
+ //TODO synchronized
+ void addMessageAsyncIn(std::string source, std::string target, std::string message);
+ //TODO synchronized
+ void addMessageSyncCall(std::string source, std::string target, std::string message);
+ //TODO synchronized
+ void addMessageSyncReturn(std::string source, std::string target, std::string message);
+ //TODO synchronized
+ void addActorState(std::string actor, std::string state);
+ //TODO synchronized
+ void close();
+
+ const std::list<std::string>& getCommandList() { return commandList; };
+ MSCFilter* getMSCFilter(){ return filter; };
+
+private:
+ void createLine(std::string source, std::string mid, std::string target, std::string message);
+ void saveMSCforTrace2UML(std::ofstream& out);
+
+ std::list<std::string> commandList;
+ MSCFilter* filter;
+
+ std::string path;
+ std::string msc_name ;
+ bool is_open;
+
+ MSCLogger(const MSCLogger& right);
+ MSCLogger& operator=(const MSCLogger& right);
+
+
+};
+
+
+} /* namespace etRuntime */
+#endif /* MSCLOGGER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h
new file mode 100644
index 000000000..e48f55223
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h
@@ -0,0 +1,43 @@
+/*
+ * AbstractMessageReceiver.h
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef ABSTRACTMESSAGERECEIVER_H_
+#define ABSTRACTMESSAGERECEIVER_H_
+
+#include "common/messaging/Address.h"
+#include "common/messaging/IMessageReceiver.h"
+#include "common/messaging/RTObject.h"
+#include <string>
+
+namespace etRuntime {
+
+class AbstractMessageReceiver: public RTObject, public virtual IMessageReceiver {
+
+public:
+ Address getAddress() const {
+ return m_address;
+ }
+ virtual ~AbstractMessageReceiver() {};
+
+protected:
+ AbstractMessageReceiver(IRTObject* parent, Address address, std::string name)
+ : IMessageReceiver(),
+ RTObject(parent, name),
+ m_address(address)
+ {
+
+ }
+
+private:
+ Address m_address;
+
+ AbstractMessageReceiver();
+};
+
+
+}
+#endif /* ABSTRACTMESSAGERECEIVER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp
new file mode 100644
index 000000000..aa1c49e22
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp
@@ -0,0 +1,82 @@
+/*
+ * Address.cpp
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#include "Address.h"
+#include <sstream>
+#include <iostream>
+
+namespace etRuntime {
+
+Address::Address(int nodeID, int threadID, int objectID) :
+ m_nodeID(nodeID),
+ m_threadID(threadID),
+ m_objectID(objectID) {
+};
+
+Address::Address(const Address & right) :
+ m_nodeID(right.m_nodeID),
+ m_threadID(right.m_threadID),
+ m_objectID(right.m_objectID) {
+};
+
+Address & Address::operator = (const Address& right) {
+ if (this != &right) {
+ m_nodeID = right.m_nodeID;
+ m_threadID = right.m_threadID;
+ m_objectID = right.m_objectID;
+ }
+ return *this;
+}
+
+bool Address::operator< (const Address& right) const {
+ if (m_nodeID == right.m_nodeID) {
+ if (m_threadID == right.m_threadID) {
+ return (m_objectID < right.m_objectID);
+ }
+ else {
+ return (m_threadID < right.m_threadID);
+ }
+ }
+ else {
+ return (m_nodeID < right.m_nodeID);
+ }
+}
+
+Address::~Address() {
+}
+
+std::string Address::toString() const{
+ std::stringstream strm;
+ strm << "Address(nodeID=" << m_nodeID
+ << ",threadID=" << m_threadID << ",objectID=" << m_objectID+")";
+ return strm.str();
+}
+std::string Address::toID() const{
+ std::stringstream strm;
+ strm << m_nodeID << "_" << m_threadID << "_" << m_objectID;
+ return strm.str();
+}
+
+Address Address::createInc(int i) {
+ return Address(m_nodeID, m_threadID, m_objectID+i);
+}
+
+void Address::printAddrVector(const std::vector<std::vector<etRuntime::Address> >& addresses){
+ std::vector<std::vector<etRuntime::Address> >::const_iterator outerIt = addresses.begin();
+ std::cout << "{" ;
+ for (int i=0; outerIt!= addresses.end(); ++outerIt,++i) {
+ std::cout << "{" ;
+ std::vector<etRuntime::Address>::const_iterator it = (*outerIt).begin();
+ for (int j=0; it!=(*outerIt).end(); ++it,++j) {
+ std::cout << (*it).toID() << ":" << addresses[i][j].toID() << ",";
+ }
+ std::cout << "}" << std::endl;
+ }
+ std::cout << "}" << std::endl;
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h
new file mode 100644
index 000000000..66a164b16
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h
@@ -0,0 +1,46 @@
+/*
+ * Address.h
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef ADDRESS_H_
+#define ADDRESS_H_
+
+#include <string>
+#include <vector>
+
+namespace etRuntime {
+
+class Address {
+public:
+ explicit Address(int nodeID=0, int threadID=0, int objectID=0);
+ Address(const Address & right);
+ Address & operator = (const Address& right);
+ bool operator< (const Address& right) const;
+ ~Address();
+
+ std::string toString() const;
+ std::string toID()const;
+
+ Address createInc(int i);
+ bool isValid() const {
+ return (m_nodeID != 0) || (m_threadID != 0) || (m_objectID != 0);
+ };
+
+ int m_nodeID;
+ int m_threadID;
+ int m_objectID;
+
+ //debug helper function
+ static void printAddrVector(const std::vector<std::vector<etRuntime::Address> >& addresses);
+
+
+private:
+};
+
+} /* namespace etRuntime */
+#endif /* ADDRESS_H_ */
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.cpp
new file mode 100644
index 000000000..10b3e128c
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.cpp
@@ -0,0 +1,18 @@
+/*
+ * IMessageReceiver.cpp
+ *
+ * Created on: 08.06.2012
+ * Author: karlitsc
+ */
+
+#include "IMessageReceiver.h"
+
+namespace etRuntime {
+
+IMessageReceiver::IMessageReceiver() {
+}
+
+IMessageReceiver::~IMessageReceiver() {
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.h
new file mode 100644
index 000000000..50dff0fc2
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.h
@@ -0,0 +1,29 @@
+/*
+ * IMessageReceiver.h
+ *
+ * Created on: 08.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef IMESSAGERECEIVER_H_
+#define IMESSAGERECEIVER_H_
+
+#include "common/messaging/Address.h"
+#include "common/messaging/Message.h"
+#include "common/messaging/IRTObject.h"
+
+namespace etRuntime {
+
+class IMessageReceiver{
+public:
+ IMessageReceiver();
+ virtual ~IMessageReceiver();
+
+ virtual void receive(Message* msg) = 0;
+ virtual Address getAddress() const = 0;
+ virtual bool isMsgService() const { return false;};
+
+};
+
+} /* namespace etRuntime */
+#endif /* IMESSAGERECEIVER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp
new file mode 100644
index 000000000..158cb2ae2
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp
@@ -0,0 +1,16 @@
+/*
+ * IRTObject.cpp
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+
+#include "IRTObject.h"
+
+namespace etRuntime {
+
+const std::string IRTObject::NO_NAME = "<no name>";
+
+}
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h
new file mode 100644
index 000000000..e7168c948
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h
@@ -0,0 +1,30 @@
+/*
+ * IRTObject.h
+ *
+ * Created on: 16.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef IRTOBJECT_H_
+#define IRTOBJECT_H_
+
+#include <string>
+
+namespace etRuntime {
+
+class IRTObject {
+
+public:
+ virtual ~IRTObject() {};
+
+ static const char PATH_DELIM = '/';
+ static const char PATHNAME_DELIM = '_';
+ static const std::string NO_NAME;
+
+ virtual std::string getInstancePath() const = 0;
+ virtual std::string getInstancePathName() const = 0;
+};
+
+}
+
+#endif /* IRTOBJECT_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
new file mode 100644
index 000000000..aebf4d1a5
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
@@ -0,0 +1,28 @@
+/*
+ * Message.cpp
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#include "Message.h"
+
+#include <sstream>
+
+namespace etRuntime {
+
+
+Message::~Message() {
+ m_next = 0;
+}
+
+std::string Message::toString(){
+ std::stringstream strm;
+ strm << "EventMessage(" << m_address.toString() << ", evt=" << m_evtId << ")";
+ if (m_data) {
+ strm << std::showbase << std::hex << m_data;
+ }
+ return strm.str();
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
new file mode 100644
index 000000000..414858c2c
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
@@ -0,0 +1,54 @@
+/*
+ * Message.h
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef MESSAGE_H_
+#define MESSAGE_H_
+
+#include "common/messaging/Address.h"
+#include "etDatatypes.h"
+#include <string>
+
+namespace etRuntime {
+
+class Message {
+public:
+ Message(Address addr, int evtId, void* data, size_t dataSize) :
+ m_address(addr), m_evtId(evtId), m_next(0),
+ m_dataSize(dataSize), m_data(data), m_logFlag(true)
+ {}
+ Message(Address addr, int evtId) :
+ m_address(addr), m_evtId(evtId), m_next(0),
+ m_dataSize(0), m_data(0), m_logFlag(true)
+ {}
+ virtual ~Message();
+
+ void setNext(Message* msg){m_next = msg;}
+ Message* getNext() const {return m_next;}
+
+ void setAddress(Address address){m_address = address; }
+ Address getAddress() const { return m_address; };
+
+ int getEvtId() const { return m_evtId; }
+ void* getData() const { return m_data; }
+ bool hasDebugFlagSet() const { return m_logFlag; };
+
+ std::string toString();
+
+private:
+ Address m_address;
+ int m_evtId;
+
+ Message* m_next;
+ size_t m_dataSize;
+ void* m_data;
+ bool m_logFlag;
+
+ Message();
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
new file mode 100644
index 000000000..f709d47b6
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
@@ -0,0 +1,73 @@
+/*
+ * MessageDispatcher.cpp
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#include "MessageDispatcher.h"
+
+namespace etRuntime {
+
+
+MessageDispatcher::~MessageDispatcher() {
+}
+
+MessageDispatcher::MessageDispatcher(IRTObject* parent, Address addr, std::string name)
+: RTObject(parent, name) ,
+ IMessageReceiver(),
+ m_local_map(),
+ m_thread_map(),
+ m_node_map(),
+ m_address(addr)
+{};
+
+void MessageDispatcher::addMessageReceiver(IMessageReceiver& receiver){
+if (! receiver.getAddress().isValid() )
+ return;
+
+// TODO: does only work same thread (else)
+if (receiver.getAddress().m_nodeID != m_address.m_nodeID){
+ m_node_map[receiver.getAddress().m_objectID] = &receiver;
+}
+else if(receiver.getAddress().m_threadID != m_address.m_threadID){
+ m_thread_map[receiver.getAddress().m_threadID] = &receiver;
+}
+else {
+ m_local_map[receiver.getAddress().m_objectID] = &receiver;
+}
+};
+
+void MessageDispatcher::receive(Message* msg) {
+// TODO: does only work same thread (else)
+ //TODO: assert msg != 0
+IMessageReceiver* receiver = 0;
+std::map<int, IMessageReceiver*>::iterator it;
+if (msg->getAddress().m_nodeID != m_address.m_nodeID){
+ it = m_node_map.find(msg->getAddress().m_objectID);
+ if (it != m_node_map.end() ) {
+ receiver = (*it).second;
+ }
+}
+else if(msg->getAddress().m_threadID != m_address.m_threadID){
+ it = m_thread_map.find(msg->getAddress().m_objectID);
+ if (it != m_thread_map.end() ) {
+ receiver = (*it).second;
+ }
+}
+else {
+ // Same node, same thread -> local call Dispatch Map
+ it = m_local_map.find(msg->getAddress().m_objectID);
+ if (it != m_local_map.end() ) {
+ receiver = (*it).second;
+ }
+}
+if (receiver!=0)
+{
+ receiver->receive(msg);
+ // TODO: error handling for not found addresses
+}
+}
+
+} /* namespace etRuntime */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h
new file mode 100644
index 000000000..1a246e959
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h
@@ -0,0 +1,42 @@
+/*
+ * MessageDispatcher.h
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef MESSAGEDISPATCHER_H_
+#define MESSAGEDISPATCHER_H_
+
+#include "common/messaging/IMessageReceiver.h"
+#include "common/messaging/IRTObject.h"
+#include "common/messaging/RTObject.h"
+#include <map>
+#include <string>
+
+namespace etRuntime {
+
+class MessageDispatcher : public RTObject, public IMessageReceiver {
+public:
+ virtual ~MessageDispatcher();
+ MessageDispatcher(IRTObject* parent, Address addr, std::string name);
+ void addMessageReceiver(IMessageReceiver& receiver);
+ void receive(Message* msg);
+
+ Address getAddress() const { return m_address; };
+
+private:
+ std::map<int, IMessageReceiver*> m_local_map;
+ std::map<int, IMessageReceiver*> m_thread_map;
+ std::map<int, IMessageReceiver*> m_node_map;
+ Address m_address;
+
+ MessageDispatcher();
+ MessageDispatcher(const MessageDispatcher& right);
+ MessageDispatcher& operator=(const MessageDispatcher& right);
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGEDISPATCHER_H_ */
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp
new file mode 100644
index 000000000..632464f96
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp
@@ -0,0 +1,59 @@
+/*
+ * MessageSeQueue.cpp
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#include "MessageSeQueue.h"
+
+namespace etRuntime {
+
+
+MessageSeQueue::~MessageSeQueue() {
+ m_first = 0;
+ m_last = 0;
+}
+
+MessageSeQueue::MessageSeQueue(IRTObject* parent, std::string name)
+ : RTObject(parent, name),
+ m_first(0),
+ m_last(0),
+ m_highWaterMark(0),
+ m_size(0)
+{
+}
+
+void MessageSeQueue::push(Message* msg) {
+ // TODO: optimize queue for concurrent push / pop
+ if (m_first == 0) {
+ m_first = m_last = msg;
+ } else {
+ m_last->setNext(msg);
+ m_last = msg;
+ }
+ if (++m_size > m_highWaterMark)
+ m_highWaterMark++;
+
+}
+
+Message* MessageSeQueue::pop() {
+ // TODO: optimize queue for concurrent push / pop
+ Message* pop_msg = m_first;
+ if (m_first == 0) {
+ return m_first;
+ }
+ if (m_first->getNext() == 0) {
+ m_first = m_last = 0;
+ } else {
+ m_first = m_first->getNext();
+ }
+
+ pop_msg->setNext(0);
+ m_size--;
+
+ return pop_msg;
+}
+
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h
new file mode 100644
index 000000000..d7c5351d5
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h
@@ -0,0 +1,44 @@
+/*
+ * MessageSeQueue.h
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef MESSAGESEQUEUE_H_
+#define MESSAGESEQUEUE_H_
+
+#include "common/messaging/RTObject.h"
+#include <string>
+#include "common/messaging/Message.h"
+
+namespace etRuntime {
+
+class MessageSeQueue: public RTObject {
+public:
+ MessageSeQueue(IRTObject* parent, std::string name);
+ virtual ~MessageSeQueue();
+
+ void push(Message* msg);
+ Message* pop();
+
+ long getSize() const {return m_size; }
+ Message* getFirst() const {return m_first; }
+ Message* getLast() const { return m_last; }
+ bool isNotEmpty() const { return m_last != 0; }
+ long getHightWaterMark() const { return m_highWaterMark; }
+
+private:
+ Message* m_first;
+ Message* m_last;
+ long m_highWaterMark;
+ long m_size;
+
+ MessageSeQueue();
+ MessageSeQueue(const MessageSeQueue& right);
+ MessageSeQueue& operator=(const MessageSeQueue& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGESEQUEUE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
new file mode 100644
index 000000000..264b4fbce
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
@@ -0,0 +1,119 @@
+/*
+ * MessageService.cpp
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#include "MessageService.h"
+
+namespace etRuntime {
+
+MessageService::MessageService(IRTObject* parent, Address addr, std::string name, int priority)
+ : // super("MessageService "+name),
+ IMessageReceiver(),
+ IRTObject(),
+ m_parent(parent),
+ m_name(name),
+ m_running(false),
+ m_messageQueue(this, "Queue"),
+ m_messageDispatcher( this,
+ Address(addr.m_nodeID, addr.m_threadID, addr.m_objectID + 1),
+ "Dispatcher"),
+ m_address(addr),
+ m_lastMessageTimestamp(0),
+ m_asyncActors()
+{
+
+ // check and set priority
+// assert priority >= Thread.MIN_PRIORITY : ("priority smaller than Thread.MIN_PRIORITY (1)");
+// assert priority <= Thread.MAX_PRIORITY : ("priority bigger than Thread.MAX_PRIORITY (10)");
+// this.setPriority(priority);
+
+}
+
+MessageService::~MessageService() {
+ m_parent = 0;
+}
+
+void MessageService::run() {
+ m_running = true;
+ while (m_running) {
+ pollOneMessage();
+ }
+}
+
+void MessageService::runOnce() {
+ pollAsyncActors();
+ while (m_messageQueue.isNotEmpty()){
+ pollOneMessage();
+ }
+}
+
+//TODO: synchronized
+void MessageService::receive(Message* msg) {
+ if (msg != 0) {
+ m_messageQueue.push(msg);
+ //TODO
+ //notifyAll(); // wake up thread to compute message
+ }
+}
+
+std::string MessageService::getInstancePath() const {
+ std::string path = PATH_DELIM + m_name;
+
+ if (m_parent != 0)
+ path = m_parent->getInstancePath() + path;
+
+ return path;
+}
+
+std::string MessageService::getInstancePathName() const {
+ std::string path = PATHNAME_DELIM + m_name;
+
+ if (m_parent != 0)
+ path = m_parent->getInstancePathName() + path;
+
+ return path;
+}
+
+// TODO: synchronized
+void MessageService::terminate() {
+ if (m_running) {
+ m_running = false;
+ //TODO:
+ // notifyAll();
+ }
+}
+//TODO: synchronized
+void MessageService::pollOneMessage() {
+ Message* msg = m_messageQueue.pop(); // get next Message from Queue
+ if (msg == 0) {
+ //TODO:
+ // no message in queue -> wait till Thread is notified
+// try {
+// wait();
+// } catch (InterruptedException e) {
+// }
+ } else {
+ //TODO: set timestamp
+ // m_lastMessageTimestamp = System.currentTimeMillis();
+ m_messageDispatcher.receive(msg);
+ }
+
+}
+
+void MessageService::addAsyncActor(IEventReceiver& evtReceiver) {
+ m_asyncActors.push_back(&evtReceiver);
+}
+
+void MessageService::pollAsyncActors() {
+ std::vector<IEventReceiver*>::iterator it = m_asyncActors.begin();
+ for ( ; it != m_asyncActors.end(); ++it) {
+ // polling event
+ (*it)->receiveEvent(0,0,0);
+ }
+}
+
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
new file mode 100644
index 000000000..a9d25cb62
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
@@ -0,0 +1,77 @@
+/*
+ * MessageService.h
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef MESSAGESERVICE_H_
+#define MESSAGESERVICE_H_
+
+#include <string>
+#include <vector>
+#include "common/messaging/MessageDispatcher.h"
+#include "common/messaging/Address.h"
+#include "common/modelbase/IEventReceiver.h"
+#include "MessageSeQueue.h"
+
+namespace etRuntime {
+
+//TODO: implementation missing yet for threads
+
+class MessageService: public IMessageReceiver, public IRTObject {
+public:
+ MessageService(IRTObject* parent, Address addr, std::string name, int priority = 0);
+ virtual ~MessageService();
+
+ Address getAddress() const { return m_address; } ;
+
+ void run();
+ //TODO: for single threaded configuration only
+ void runOnce();
+
+ //TODO: synchronized
+ void terminate();
+ //TODO: synchronized
+ void receive(Message* msg);
+ //TODO: synchronized
+ virtual MessageDispatcher& getMessageDispatcher() { return m_messageDispatcher; }
+ virtual std::string getInstancePath() const ;
+ virtual std::string getInstancePathName() const ;
+ virtual bool isMsgService() const { return true;};
+
+ void addAsyncActor(IEventReceiver& evtReceiver);
+ void pollAsyncActors();
+
+
+ // protected methods for sole use by test cases
+protected:
+ MessageSeQueue& getMessageQueue() { return m_messageQueue; }
+ //TODO: synchronized
+ long getLastMessageTimestamp() const { return m_lastMessageTimestamp; }
+
+private:
+ //TODO: synchronized
+ void pollOneMessage();
+
+ IRTObject* m_parent;
+ std::string m_name;
+ bool m_running;
+
+ // TODO: add internal message queue for less locks (faster thread internal
+ // messaging)
+ MessageSeQueue m_messageQueue;
+ MessageDispatcher m_messageDispatcher;
+ Address m_address;
+ long m_lastMessageTimestamp;
+
+ std::vector<IEventReceiver*> m_asyncActors;
+
+ MessageService();
+ MessageService(const MessageService& right);
+ MessageService& operator=(const MessageService& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGESERVICE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
new file mode 100644
index 000000000..e095ed02b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
@@ -0,0 +1,120 @@
+/*
+ * MessageServiceController.cpp
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#include "MessageServiceController.h"
+
+namespace etRuntime {
+
+
+MessageServiceController::~MessageServiceController() {
+ // TODO Auto-generated destructor stub
+}
+
+MessageServiceController::MessageServiceController(/*IRTObject parent*/)
+ : m_messageServiceList(),
+ m_running(false) {
+ // TODO: Who is parent of MessageServices and Controller?
+ // this.parent = parent;
+}
+
+void MessageServiceController::addMsgSvc(MessageService& msgSvc) {
+ // TODOTS: Who is parent of MessageServices ?
+ //TODO assert
+ //assert(msgSvc.getAddress().m_threadID == m_messageServiceList.size());
+ m_messageServiceList.push_back(&msgSvc);
+}
+
+MessageService* MessageServiceController::getMsgSvc(int threadID) {
+ return m_messageServiceList.at(threadID);
+}
+
+void MessageServiceController::connectAll() {
+ for (size_t i = 0; i < m_messageServiceList.size(); i++) {
+ MessageDispatcher& dispatcher = getMsgSvc(i)->getMessageDispatcher();
+ for (size_t j = 0; j < m_messageServiceList.size(); j++) {
+ if (i != j) {
+ dispatcher.addMessageReceiver(*RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(j));
+ }
+ }
+ }
+}
+
+void MessageServiceController::start() {
+ // start all message services
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ //TODO start thread
+ //msgSvc.start();
+ // TODOTS: start in order of priorities
+ }
+ m_running = true;
+}
+
+void MessageServiceController::stop() {
+ //dumpThreads("org.eclipse.etrice.runtime.java.messaging.MessageServiceController.stop()");
+ terminate();
+ waitTerminate();
+}
+
+void MessageServiceController::waitTerminate() {
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ //try {
+ //TODO thread join
+ //msgSvc.join();
+ //} catch (InterruptedException e1) {
+ //}
+ }
+}
+
+void MessageServiceController::dumpThreads(std::string msg) {
+ std::cout << "<<< begin dump threads <<<" << std::endl;
+ std::cout << "=== " << msg << std::endl;
+ //TODO dump stack traces
+// Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
+// for (Thread thread : traces.keySet()) {
+// std::cout << "thread " << thread.getName() << std::endl;
+// StackTraceElement[] elements = traces.get(thread);
+// int n = 2;
+// if (elements.length < n)
+// n = elements.length;
+// for (int i = 0; i < n; i++) {
+// std::cout << " " << elements[i].toString() << std::endl;
+// }
+// }
+ std::cout <<(">>> end dump threads >>>");
+}
+
+void MessageServiceController::terminate() {
+ if (!m_running) {
+ return;
+ }
+ m_running = false;
+
+ // terminate all message services
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ //TODO: terminate thread
+ //msgSvc.terminate();
+ // TODOTS: stop in order of priorities
+ }
+}
+
+void MessageServiceController::runOnce() {
+ if (!m_running) {
+ return;
+ }
+ //m_running = false;
+
+ // terminate all message services
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ (*it)->runOnce();
+ }
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
new file mode 100644
index 000000000..a0668838c
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
@@ -0,0 +1,65 @@
+/*
+ * MessageServiceController.h
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef MESSAGESERVICECONTROLLER_H_
+#define MESSAGESERVICECONTROLLER_H_
+
+#include "common/messaging/MessageService.h"
+#include "common/messaging/RTServices.h"
+#include <vector>
+#include <string>
+#include <iostream>
+#include <algorithm>
+
+namespace etRuntime {
+
+class MessageServiceController {
+public:
+ MessageServiceController(/*IRTObject parent*/);
+ virtual ~MessageServiceController();
+
+ void addMsgSvc(MessageService& msgSvc);
+ //raises an exception if the service does not exist for this threadID
+ MessageService* getMsgSvc(int threadID);
+
+ void addAsyncActor(IEventReceiver& evtReceiver);
+ void pollAsyncActors();
+
+ //the connectAll method connects all messageServices
+ //it is included for test purposes
+ //currently it is not called
+ void connectAll();
+ void start();
+ void stop();
+
+ //TODO: this is only for single threaded configurations
+ void runOnce();
+
+ /**
+ * waitTerminate waits blocking for all MessageServices to terminate
+ * ! not threadsafe !
+ */
+ void waitTerminate();
+
+protected:
+ void dumpThreads(std::string msg);
+
+private:
+ void terminate();
+
+ MessageServiceController(const MessageServiceController& right);
+ MessageServiceController& operator=(const MessageServiceController& right);
+
+
+ std::vector<MessageService*> m_messageServiceList;
+ // IRTObject parent = null;
+ bool m_running;
+
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGESERVICECONTROLLER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp
new file mode 100644
index 000000000..490d5ae6d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp
@@ -0,0 +1,54 @@
+/*
+ * RTObject.cpp
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#include "RTObject.h"
+
+namespace etRuntime {
+
+RTObject::RTObject() :
+ IRTObject(), m_parent(0), m_name(NO_NAME) {
+}
+;
+
+RTObject::RTObject(IRTObject* parent, std::string name) :
+ IRTObject(), m_parent(parent), m_name(name) {
+}
+
+RTObject::RTObject(const RTObject & right) :
+ m_parent(right.m_parent),
+ m_name(right.m_name)
+{
+};
+
+RTObject & RTObject::operator = (RTObject right) {
+ std::swap(right, *this);
+ return *this;
+}
+
+RTObject::~RTObject() {
+ m_parent = 0;
+}
+
+std::string RTObject::getInstancePath() const{
+ std::string path = PATH_DELIM + m_name;
+
+ if (m_parent != 0)
+ path = m_parent->getInstancePath() + path;
+
+ return path;
+}
+
+std::string RTObject::getInstancePathName() const{
+ std::string path = PATHNAME_DELIM + m_name;
+
+ if (m_parent != 0)
+ path = m_parent->getInstancePathName() + path;
+
+ return path;
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h
new file mode 100644
index 000000000..530fb662b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h
@@ -0,0 +1,36 @@
+/*
+ * RTObject.h
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef RTOBJECT_H_
+#define RTOBJECT_H_
+
+#include <string>
+#include "common/messaging/IRTObject.h"
+
+namespace etRuntime {
+
+class RTObject : public virtual IRTObject{
+public:
+ RTObject();
+ RTObject(IRTObject* parent, std::string name);
+ RTObject(const RTObject & right);
+ RTObject & operator = (RTObject right);
+
+ virtual ~RTObject();
+
+ virtual IRTObject* getParent() const { return m_parent; };
+ virtual std::string getInstancePath() const;
+ virtual std::string getInstancePathName() const;
+
+private:
+ IRTObject* m_parent;
+ std::string m_name;
+
+};
+
+} /* namespace etRuntime */
+#endif /* RTOBJECT_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.cpp
new file mode 100644
index 000000000..09e966b2d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.cpp
@@ -0,0 +1,39 @@
+/*
+ * RTServices.cpp
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#include "RTServices.h"
+
+namespace etRuntime {
+
+RTServices* RTServices::s_instance = 0;
+
+RTServices::RTServices()
+ : m_subSystem(0),
+ m_messageServiceController( new MessageServiceController())
+{
+}
+
+RTServices::~RTServices() {
+ // TODO Auto-generated destructor stub
+}
+
+void RTServices::destroy() {
+ // TODO: also clean up all sub elements
+ m_subSystem = 0;
+ m_messageServiceController = 0;
+ //TODO is delete necessary here??
+ //delete s_instance;
+ s_instance = 0;
+}
+
+MessageServiceController& RTServices::getMsgSvcCtrl() {
+ //TODO
+ //assert(m_messageServiceController != 0);
+ return *m_messageServiceController;
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.h
new file mode 100644
index 000000000..05348de11
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.h
@@ -0,0 +1,45 @@
+/*
+ * RTServices.h
+ *
+ * Created on: 22.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef RTSERVICES_H_
+#define RTSERVICES_H_
+#include "common/messaging/MessageServiceController.h"
+
+namespace etRuntime {
+
+class SubSystemClassBase;
+class MessageServiceController;
+
+
+class RTServices {
+public:
+ virtual ~RTServices();
+
+ static RTServices& getInstance() {
+ if (s_instance == 0) {
+ s_instance = new RTServices();
+ }
+ return *s_instance;
+ }
+
+ void destroy();
+ MessageServiceController& getMsgSvcCtrl();
+ SubSystemClassBase* getSubSystem() { return m_subSystem; };
+ void setSubSystem(SubSystemClassBase* subSystem) { m_subSystem = subSystem; };
+
+private:
+ static RTServices* s_instance;
+
+ SubSystemClassBase* m_subSystem;
+ MessageServiceController* m_messageServiceController;
+
+ RTServices();
+
+};
+
+} /* namespace etRuntime */
+#endif /* RTSERVICES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
new file mode 100644
index 000000000..5b2bc9f74
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
@@ -0,0 +1,215 @@
+/*
+ * RTSystemServicesProtocol.cpp
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#include "RTSystemServicesProtocol.h"
+#include "common/debugging/DebuggingService.h"
+
+namespace etRuntime {
+
+std::string RTSystemServicesProtocol::s_messageStrings[] =
+ { "MIN",
+ "dummy",
+ "executeInitialTransition",
+ "startDebugging",
+ "stopDebugging",
+ "MAX"};
+
+std::string RTSystemServicesProtocol::getMessageString(int msg_id) {
+ if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {
+ return s_messageStrings[msg_id];
+ } else {
+ // id out of range
+ return "Message ID out of range";
+ }
+}
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocol: surrounding class
+//------------------------------------------------------------------
+
+
+RTSystemServicesProtocol::RTSystemServicesProtocol() {
+}
+
+RTSystemServicesProtocol::~RTSystemServicesProtocol() {
+}
+
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolPort
+//------------------------------------------------------------------
+
+RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, Address addr, Address peerAddress, bool doRegistration)
+:PortBase(actor, parent, name, localId, 0, addr, peerAddress)
+{
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+};
+
+RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, int idx, Address addr, Address peerAddress, bool doRegistration)
+: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
+{
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+};
+
+void RTSystemServicesProtocolPort::receive(Message* msg) {
+ if (! RTSystemServicesProtocol::isValidIncomingEvtID(msg->getEvtId())) {
+ std::cout << "unknown" << std::endl;
+ }
+ else {
+ if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
+ }
+ getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ }
+};
+
+// sent messages
+
+void RTSystemServicesProtocolPort::dummy() {
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::OUT_dummy));
+ PortBase::send(RTSystemServicesProtocol::OUT_dummy);
+};
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolPortRepl
+//------------------------------------------------------------------
+
+
+RTSystemServicesProtocolPortRepl::
+RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId, const std::vector<Address>& addr, const std::vector<Address> peerAddress)
+: m_replication(addr.size()),
+ m_ports()
+{
+ char numstr[10]; // enough to hold all numbers up to 32-bits
+
+ //m_ports.reserve(m_replication);
+ m_ports = reinterpret_cast<RTSystemServicesProtocolPort*> (new char[sizeof(RTSystemServicesProtocolPort) * addr.size()]);
+
+ for (int i = 0; i < m_replication; ++i) {
+ snprintf(numstr, sizeof(numstr), "%d", i);
+ new (&m_ports[i]) RTSystemServicesProtocolPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);
+
+ //m_ports.push_back(std::auto_ptr_ref<RTSystemServicesProtocolPort>(new RTSystemServicesProtocolPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i], false)));
+ //m_ports[i] = std::auto_ptr<RTSystemServicesProtocolPort>(new RTSystemServicesProtocolPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]));
+ }
+// for (int i = 0; i < m_replication; ++i) {
+// DebuggingService::getInstance().addPortInstance(m_ports.at(i));
+// }
+
+};
+
+// outgoing messages
+
+void RTSystemServicesProtocolPortRepl::dummy() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports[i].dummy();
+ }
+};
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolConjPort
+//------------------------------------------------------------------
+
+RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, Address addr, Address peerAddress, bool doRegistration)
+ : PortBase(actor, parent, name, localId, 0, addr, peerAddress)
+{
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+}
+RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, int idx, Address addr,
+ Address peerAddress, bool doRegistration)
+: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
+{
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+}
+
+void RTSystemServicesProtocolConjPort::receive(Message* msg) {
+ if (! RTSystemServicesProtocol::isValidOutgoingEvtID(msg->getEvtId())) { //conjugated port receives out-messages
+ std::cout << "unknown" << std::endl;
+ }
+ else {
+ if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
+ }
+ getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ }
+}
+
+// sent messages
+
+void RTSystemServicesProtocolConjPort::executeInitialTransition() {
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_executeInitialTransition));
+ PortBase::send(RTSystemServicesProtocol::IN_executeInitialTransition);
+}
+
+void RTSystemServicesProtocolConjPort::startDebugging() {
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_startDebugging));
+ PortBase::send(RTSystemServicesProtocol::IN_startDebugging);
+}
+
+void RTSystemServicesProtocolConjPort::stopDebugging() {
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_stopDebugging));
+ PortBase::send(RTSystemServicesProtocol::IN_stopDebugging);
+}
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolConjPortRepl
+//------------------------------------------------------------------
+
+//TODO: data type of addr and peerAddress
+RTSystemServicesProtocolConjPortRepl::
+RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId, const std::vector<Address>& addr, const std::vector<Address>& peerAddress)
+: m_replication(addr.size()),
+ m_ports()
+{
+ char numstr[10]; // enough to hold all numbers up to 32-bits
+ m_ports = reinterpret_cast<RTSystemServicesProtocolConjPort*> (new char[sizeof(RTSystemServicesProtocolConjPort) * addr.size()]);
+ for (int i = 0; i < m_replication; ++i) {
+ snprintf(numstr, sizeof(numstr), "%d", i);
+ //placement new to avoid copy construction, therefore no vector is used
+ new (&m_ports[i]) RTSystemServicesProtocolConjPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);
+ }
+
+};
+
+// sent messages
+
+void RTSystemServicesProtocolConjPortRepl::executeInitialTransition() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports[i].executeInitialTransition();
+ }
+}
+
+void RTSystemServicesProtocolConjPortRepl::startDebugging() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports[i].startDebugging();
+ }
+}
+
+void RTSystemServicesProtocolConjPortRepl::stopDebugging() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports[i].stopDebugging();
+ }
+}
+
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h
new file mode 100644
index 000000000..f8852c5ca
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h
@@ -0,0 +1,145 @@
+/*
+ * RTSystemServicesProtocol.h
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef RTSYSTEMSERVICESPROTOCOL_H_
+#define RTSYSTEMSERVICESPROTOCOL_H_
+
+#include "common/modelbase/PortBase.h"
+#include "common/modelbase/IEventReceiver.h"
+#include "common/messaging/Address.h"
+#include <vector>
+#include <string>
+#include <memory>
+
+namespace etRuntime {
+
+//---------------------------------------------------
+// interface for port class
+//---------------------------------------------------
+class IRTSystemServicesProtocolPort {
+public:
+ virtual ~IRTSystemServicesProtocolPort() {};
+ virtual void dummy() = 0;
+};
+
+//---------------------------------------------------
+// interface for conjugated port class
+//---------------------------------------------------
+class IRTSystemServicesProtocolConjPort {
+public:
+ virtual ~IRTSystemServicesProtocolConjPort() {};
+ virtual void executeInitialTransition() = 0;
+ virtual void startDebugging() = 0;
+ virtual void stopDebugging() = 0;
+};
+
+
+class RTSystemServicesProtocol {
+public:
+ enum eventIDs {
+ MSG_MIN = 0,
+ OUT_dummy = 1,
+ MSG_SEP = 2,
+ IN_executeInitialTransition = 2,
+ IN_startDebugging = 3,
+ IN_stopDebugging = 4,
+ MSG_MAX = 5
+ };
+ static bool isValidEvtID(int evtId) {
+ return ((MSG_MIN < evtId) && (evtId < MSG_MAX));
+ };
+ static bool isValidOutgoingEvtID(int evtId) {
+ return ((MSG_MIN < evtId) && (evtId < MSG_SEP));
+ };
+ static bool isValidIncomingEvtID(int evtId) {
+ return ((MSG_SEP <= evtId) && (evtId < MSG_MAX));
+ };
+ static std::string getMessageString(int msg_id);
+
+ private:
+ static std::string s_messageStrings[];
+
+ RTSystemServicesProtocol();
+ virtual ~RTSystemServicesProtocol();
+};
+
+ //---------------------------------------------------
+ // port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolPort : public PortBase , public IRTSystemServicesProtocolPort {
+ public:
+ RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, Address addr, Address peerAddress, bool doRegistration = true);
+
+ RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, int idx, Address addr, Address peerAddress, bool doRegistration = true);
+
+ virtual void receive(Message* m);
+ // sent messages
+ void dummy();
+ };
+
+ //---------------------------------------------------
+ // replicated port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolPortRepl: public IRTSystemServicesProtocolPort {
+ private:
+ int m_replication;
+ RTSystemServicesProtocolPort* m_ports;
+
+ public:
+ //TODO: data type of addr and peerAddress?
+ RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId,
+ const std::vector<Address>& addr, const std::vector<Address> peerAddress);
+
+ int getReplication() const { return m_replication; } ;
+ RTSystemServicesProtocolPort& get(int i) { return m_ports[i]; };
+ // outgoing messages
+ void dummy();
+ };
+
+
+ //---------------------------------------------------
+ // conjugated port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolConjPort : public PortBase, public IRTSystemServicesProtocolConjPort{
+ public:
+ RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, Address addr, Address peerAddress, bool doRegistration = true);
+ RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, int idx, Address addr,
+ Address peerAddress, bool doRegistration = true);
+
+ virtual void receive(Message* m);
+ void executeInitialTransition();
+ void startDebugging();
+ void stopDebugging();
+ };
+
+ //---------------------------------------------------
+ // replicated conjugated port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolConjPortRepl : public IRTSystemServicesProtocolConjPort{
+ private:
+ int m_replication;
+ RTSystemServicesProtocolConjPort* m_ports; //dynamic array used instead of vector to avoid copy construction
+
+ public:
+ //TODO: data type of addr and peerAddress
+ RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId,
+ const std::vector<Address>& addr, const std::vector<Address>& peerAddress);
+
+ int getReplication() const { return m_replication; } ;
+ RTSystemServicesProtocolConjPort& get(int i) { return m_ports[i]; };
+
+ void executeInitialTransition();
+ void startDebugging();
+ void stopDebugging();
+ };
+
+} /* namespace etRuntime */
+#endif /* RTSYSTEMSERVICESPROTOCOL_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
new file mode 100644
index 000000000..1a7879f3a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
@@ -0,0 +1,54 @@
+/*
+ * ActorClassBase.cpp
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#include "ActorClassBase.h"
+
+namespace etRuntime {
+
+ActorClassBase::ActorClassBase(IRTObject* parent, std::string name, Address ownAddr, Address systemPortPeerAddr)
+ : EventReceiver(parent, name),
+ IMessageReceiver(),
+ m_state(0),
+ m_RTSystemPort(0),
+ m_className("noname"),
+ m_ownAddr(ownAddr),
+ m_ownMsgsvc(RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(ownAddr.m_threadID)) {
+
+ // own ports
+ m_RTSystemPort = new RTSystemServicesProtocolPort(*this, this, "RTSystemPort", 0, 0, ownAddr,
+ systemPortPeerAddr);
+}
+
+ActorClassBase::~ActorClassBase() {
+ delete m_RTSystemPort;
+ m_RTSystemPort = 0;
+}
+
+bool ActorClassBase::handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data) {
+ if ((ifitem != 0) && (ifitem->getLocalId() != 0)) {
+ return false;
+ }
+
+ switch (evt) {
+ case RTSystemServicesProtocol::IN_executeInitialTransition:
+ executeInitTransition();
+ break;
+ case RTSystemServicesProtocol::IN_startDebugging:
+ break;
+ case RTSystemServicesProtocol::IN_stopDebugging:
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+std::string ActorClassBase::toString() {
+ return "ActorClass(className=" + m_className + ", instancePath=" + getInstancePath() + ")";
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
new file mode 100644
index 000000000..85cc8f136
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
@@ -0,0 +1,73 @@
+/*
+ * ActorClassBase.h
+ *
+ * The base class for model actor classes.
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef ACTORCLASSBASE_H_
+#define ACTORCLASSBASE_H_
+
+#include "common/modelbase/EventReceiver.h"
+#include "common/messaging/IMessageReceiver.h"
+#include "common/messaging/RTServices.h"
+#include "common/messaging/RTSystemServicesProtocol.h"
+
+namespace etRuntime {
+
+class ActorClassBase: public EventReceiver, public IMessageReceiver {
+public:
+ ActorClassBase(IRTObject* parent, std::string name, Address ownAddr, Address systemPortPeerAddr);
+ virtual ~ActorClassBase();
+
+ std::string toString();
+ std::string getClassName() const { return m_className; }
+ void setClassName(std::string className) { m_className = className; }
+ virtual Address getAddress() const {
+ // TODO: Actor should have its own address for services and debugging
+ return Address(0,0,0);
+ }
+
+ //--------------------- lifecycle functions
+ // automatically generated lifecycle functions
+ virtual void init() = 0;
+ virtual void start() = 0;
+ virtual void stop() = 0;
+ virtual void destroy() = 0;
+ virtual void executeInitTransition() = 0;
+
+ // not automatically generated lifecycle functions
+ // are called, but with empty implementation -> can be overridden by user
+ void initUser() { }
+ void startUser() { }
+ void stopUser() { }
+ void destroyUser() { }
+ virtual void receive(Message* msg) { }
+
+ int getState() const { return m_state; }
+ MessageService* getMsgsvc() const { return m_ownMsgsvc; }
+
+protected:
+ static const int EVT_SHIFT = 1000; // TODOHRR: use 256 or shift operation later
+ static const int NO_STATE = 0;
+ static const int STATE_TOP = 1;
+ static const int NOT_CAUGHT = 0;
+
+ /**
+ * the current state
+ */
+ int m_state;
+ RTSystemServicesProtocolPort* m_RTSystemPort;
+
+ virtual bool handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data);
+private:
+ std::string m_className;
+ Address m_ownAddr;
+ MessageService* m_ownMsgsvc;
+
+};
+
+} /* namespace etRuntime */
+#endif /* ACTORCLASSBASE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp
new file mode 100644
index 000000000..64026d8cc
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp
@@ -0,0 +1,16 @@
+/*
+ * EventReceiver.cpp
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#include "EventReceiver.h"
+
+namespace etRuntime {
+
+
+EventReceiver::~EventReceiver() {
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h
new file mode 100644
index 000000000..05cad0c8d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h
@@ -0,0 +1,34 @@
+/*
+ * EventReceiver.h
+ *
+ * The abstract base class for event receivers.
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef EVENTRECEIVER_H_
+#define EVENTRECEIVER_H_
+
+#include "common/messaging/RTObject.h"
+#include "common/modelbase/IEventReceiver.h"
+#include <string>
+
+namespace etRuntime {
+
+class EventReceiver : public RTObject, public IEventReceiver{
+public:
+ EventReceiver(IRTObject* parent, std::string name)
+ : RTObject(parent, name),
+ IEventReceiver()
+ {};
+ virtual ~EventReceiver();
+
+private:
+ EventReceiver(const EventReceiver& right);
+ EventReceiver& operator=(const EventReceiver& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* EVENTRECEIVER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.cpp
new file mode 100644
index 000000000..976cda3ab
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.cpp
@@ -0,0 +1,18 @@
+/*
+ * IEventReceiver.cpp
+ *
+ * Created on: 08.06.2012
+ * Author: karlitsc
+ */
+
+#include "IEventReceiver.h"
+
+namespace etRuntime {
+
+IEventReceiver::IEventReceiver() {
+}
+
+IEventReceiver::~IEventReceiver() {
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.h
new file mode 100644
index 000000000..c6966c38b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.h
@@ -0,0 +1,26 @@
+/*
+ * IEventReceiver.h
+ *
+ * Created on: 08.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef IEVENTRECEIVER_H_
+#define IEVENTRECEIVER_H_
+
+#include "common/messaging/IRTObject.h"
+
+namespace etRuntime {
+class InterfaceItemBase;
+
+class IEventReceiver {
+public:
+ IEventReceiver();
+ virtual ~IEventReceiver();
+
+ virtual void receiveEvent(InterfaceItemBase* ifitem, int evt, void* data) = 0;
+
+};
+
+} /* namespace etRuntime */
+#endif /* IEVENTRECEIVER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
new file mode 100644
index 000000000..c5c2bc6f4
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
@@ -0,0 +1,35 @@
+/*
+ * InterfaceItemBaase.cpp
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#include "InterfaceItemBase.h"
+#include "common/messaging/AbstractMessageReceiver.h"
+#include "common/messaging/RTServices.h"
+
+namespace etRuntime {
+
+InterfaceItemBase::InterfaceItemBase (IEventReceiver& actor, IRTObject* parent, std::string name, int localId, int idx, Address ownAddress, Address peerAddress)
+: AbstractMessageReceiver(parent, ownAddress, name),
+ m_idx(idx),
+ m_localId(localId),
+ m_peerAddress(peerAddress),
+ m_ownMsgReceiver(RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(ownAddress.m_threadID)),
+ m_peerMsgReceiver(peerAddress.isValid()? RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(peerAddress.m_threadID): 0),
+ m_actor(&actor)
+{
+ if (getAddress().isValid() && m_ownMsgReceiver->isMsgService()) {
+ MessageService* ms = static_cast<MessageService*>(m_ownMsgReceiver);
+ // register at the own dispatcher to receive messages
+ ms->getMessageDispatcher().addMessageReceiver(*this);
+ }
+}
+
+
+InterfaceItemBase::~InterfaceItemBase() {
+ // TODO Auto-generated destructor stub
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
new file mode 100644
index 000000000..7f144dc13
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
@@ -0,0 +1,53 @@
+/*
+ * InterfaceItemBaase.h
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef INTERFACEITEMBASE_H_
+#define INTERFACEITEMBASE_H_
+
+#include "common/messaging/Address.h"
+#include "common/messaging/IMessageReceiver.h"
+#include "common/modelbase/IEventReceiver.h"
+#include "common/messaging/AbstractMessageReceiver.h"
+#include <string>
+
+namespace etRuntime {
+class IEventReceiver;
+
+
+class InterfaceItemBase : public AbstractMessageReceiver{
+public:
+ InterfaceItemBase (IEventReceiver& actor, IRTObject* parent, std::string name, int localId, int idx, Address ownAddress, Address peerAddress);
+ virtual ~InterfaceItemBase();
+
+ int getIdx() const { return m_idx; } ;
+ IEventReceiver& getActor() { return *m_actor; };
+ IRTObject& getActorRTObject() { return *this; };
+ int getLocalId() const {return m_localId; };
+
+ void setMsgReceiver(IMessageReceiver& msgReceiver) { m_ownMsgReceiver = &msgReceiver; };
+
+protected:
+ IMessageReceiver* getMsgReceiver() const{ return m_ownMsgReceiver; };
+ IMessageReceiver* getPeerMsgReceiver() const { return m_peerMsgReceiver; };
+ Address getPeerAddress() const { return m_peerAddress; };
+
+private:
+
+ int m_idx;
+ int m_localId;
+
+ Address m_peerAddress;
+ IMessageReceiver* m_ownMsgReceiver;
+ IMessageReceiver* m_peerMsgReceiver;
+ IEventReceiver* m_actor;
+
+ InterfaceItemBase();
+
+};
+
+} /* namespace etRuntime */
+#endif /* INTERFACEITEMBASE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.cpp
new file mode 100644
index 000000000..8e5170e65
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.cpp
@@ -0,0 +1,27 @@
+/*
+ * PortBase.cpp
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#include "PortBase.h"
+
+namespace etRuntime {
+
+
+PortBase::~PortBase() {
+}
+
+void PortBase::send(int evtID) {
+
+ //TODO: how to avoid logging timerTicks
+ //if (s_messageStrings[IRTSystemServicesProtocolPort::OUT_dummy] != "timerTick") {
+ // TODOTS: model switch for activation
+ if (getPeerAddress().isValid())
+ getPeerMsgReceiver()->receive(
+ new Message(getPeerAddress(), evtID)); //TODO: placement new mit message pool verwenden
+
+};
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h
new file mode 100644
index 000000000..f7ffb66f5
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h
@@ -0,0 +1,33 @@
+/*
+ * PortBase.h
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef PORTBASE_H_
+#define PORTBASE_H_
+
+#include "common/modelbase/InterfaceItemBase.h"
+#include "common/messaging/Address.h"
+#include <string>
+
+namespace etRuntime {
+class IEventReceiver;
+
+class PortBase : public InterfaceItemBase{
+public:
+ PortBase (IEventReceiver& actor, IRTObject* parent, std::string name, int localId, int idx, Address address, Address peerAddress)
+ : InterfaceItemBase(actor, parent, name, localId, idx, address, peerAddress){};
+ virtual ~PortBase();
+
+ virtual void send(int evtID);
+
+
+private:
+ PortBase();
+
+};
+
+} /* namespace etRuntime */
+#endif /* PORTBASE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
new file mode 100644
index 000000000..c94b81408
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
@@ -0,0 +1,153 @@
+/*
+ * SubSystemClassBase.cpp
+ *
+ * Created on: 31.08.2012
+ * Author: karlitsc
+ */
+
+#include "SubSystemClassBase.h"
+#include "common/messaging/MessageService.h"
+#include "common/messaging/RTServices.h"
+#include "ActorClassBase.h"
+#include "common/debugging/DebuggingService.h"
+
+namespace etRuntime {
+
+
+SubSystemClassBase::~SubSystemClassBase() {
+ // TODO Auto-generated destructor stub
+}
+
+SubSystemClassBase::SubSystemClassBase(IRTObject* parent, std::string name)
+ : RTObject(parent, name),
+ IEventReceiver(),
+ m_RTSystemPort(0),
+ m_instances(),
+ m_testSem(0),
+ m_testErrorCode(0)
+{
+ DebuggingService::getInstance().getAsyncLogger().setMSC(name + "_Async", "");
+ DebuggingService::getInstance().getAsyncLogger().open();
+ DebuggingService::getInstance().getSyncLogger().setMSC(name + "_Sync", "");
+ DebuggingService::getInstance().getSyncLogger().open();
+
+ RTServices::getInstance().setSubSystem(this);
+}
+
+void SubSystemClassBase::init() {
+
+ std::cout << "*** MainComponent " << getInstancePath() << "::init ***" << std::endl;
+
+ // MessageService
+ instantiateMessageServices();
+
+ // this is the place to connect the message services if necessary
+ // normaly the ports will address the correct target message service directly
+ // it is just for test purposes
+ // RTServices::getInstance().getMsgSvcCtrl().connectAll();
+
+ instantiateActors();
+
+ // initialize all actor m_instances
+ for (unsigned int i = 0; i < m_instances.size(); i++) {
+ m_instances[i]->init();
+ }
+}
+
+void SubSystemClassBase::start() {
+ // start all actors instances
+ m_RTSystemPort->executeInitialTransition();
+
+ // start all message services
+ RTServices::getInstance().getMsgSvcCtrl().start();
+
+}
+
+void SubSystemClassBase::stop() {
+ std::cout << "*** MainComponent " << this->getInstancePath() << "::stop ***" << std::endl;
+
+ RTServices::getInstance().getMsgSvcCtrl().stop();
+ std::cout << "=== done stop MsgSvcCtrl" << std::endl;
+
+ // stop all actor instances
+ for (unsigned int i = 0; i < m_instances.size(); i++) {
+ m_instances[i]->stop();
+ }
+ std::cout << "=== done stop actor instances" << std::endl;
+}
+
+void SubSystemClassBase::runOnce() {
+ // run all message services one time
+ RTServices::getInstance().getMsgSvcCtrl().runOnce();
+
+}
+
+void SubSystemClassBase::destroy() {
+ std::cout << "*** MainComponent " << this->getInstancePath() << "::destroy ***" << std::endl;
+ for (unsigned int i = 0; i < m_instances.size(); i++) {
+ m_instances[i]->destroy();
+ }
+ std::cout << "=== done destroy actor instances" << std::endl;
+
+ DebuggingService::getInstance().getAsyncLogger().close();
+ DebuggingService::getInstance().getSyncLogger().close();
+ std::cout << "=== done close loggers" << std::endl;
+
+ RTServices::getInstance().destroy();
+ std::cout << "=== done destroy RTServices\n\n\n" << std::endl;
+}
+
+MessageService* SubSystemClassBase::getMsgService(int idx) const {
+ return RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(idx);
+}
+
+ActorClassBase* SubSystemClassBase::getInstance(unsigned int i) {
+ if (i < 0 || i >= m_instances.size())
+ return 0;
+
+ return m_instances[i];
+}
+
+ActorClassBase* SubSystemClassBase::getInstance(std::string path) {
+ for (unsigned int i = 0; i < m_instances.size(); i++) {
+ if (m_instances[i]->getInstancePath() == path)
+ return m_instances[i];
+ }
+
+ return 0;
+}
+
+// this is to run integration tests
+// TODO synchronized
+void SubSystemClassBase::setTestSemaphore(TestSemaphore* sem) {
+ m_testErrorCode = -1;
+ m_testSem = sem;
+}
+
+//TODO synchronized
+int SubSystemClassBase::getTestErrorCode() const {
+ return m_testErrorCode;
+}
+
+void SubSystemClassBase::testFinished(int errorCode) {
+ if (m_testSem != 0) {
+ std::cout
+ << "org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase.testFinished(int): before releasing semaphore"
+ << std::endl;
+ //m_testSem.printWaitingThreads();
+ //TODO synchronized (this) {
+ m_testErrorCode = errorCode;
+ m_testSem->release(1);
+ //}
+ std::cout
+ << "org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase.testFinished(int): semaphore released"
+ << std::endl;
+ //m_testSem.printWaitingThreads();
+ //TODO
+ //Thread.yield();
+ }
+}
+
+
+} /* namespace etRuntime */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
new file mode 100644
index 000000000..f537bd335
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
@@ -0,0 +1,71 @@
+/*
+ * SubSystemClassBase.h
+ *
+ * The base class for all SubSystems.
+ * It and its derived classes take care of the instantiation, binding (connection) and complete lifecycle of all Actor Classes of a SubSystem
+ *
+ * Created on: 31.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef SUBSYSTEMCLASSBASE_H_
+#define SUBSYSTEMCLASSBASE_H_
+
+#include "common/messaging/RTSystemServicesProtocol.h"
+#include "common/messaging/IRTObject.h"
+#include "common/debugging/MSCLogger.h"
+#include "common/modelbase/TestSemaphore.h"
+#include <string>
+#include <vector>
+#include <iostream>
+
+namespace etRuntime {
+
+class MessageService;
+class ActorClassBase;
+
+class SubSystemClassBase: public RTObject, public IEventReceiver {
+public:
+ SubSystemClassBase(IRTObject* parent, std::string name);
+ virtual ~SubSystemClassBase();
+
+ void init();
+ virtual void instantiateMessageServices() = 0;
+ virtual void instantiateActors() = 0;
+
+ void start();
+ void stop();
+ void runOnce();
+
+ void destroy();
+
+ MessageService* getMsgService(int idx) const;
+
+ ActorClassBase* getInstance(unsigned int i);
+ ActorClassBase* getInstance(std::string path);
+
+ //---------------------------------------------
+ // this is to run integration tests
+ //---------------------------------------------
+ // TODO synchronized
+ void setTestSemaphore(TestSemaphore* sem);
+ //TODO synchronized
+ int getTestErrorCode() const;
+ void testFinished(int errorCode);
+
+protected:
+ RTSystemServicesProtocolConjPortRepl* m_RTSystemPort;
+ //--------------------- interface item IDs
+ static const int IFITEM_RTSystemPort = 0;
+ std::vector<ActorClassBase*> m_instances;
+private:
+ TestSemaphore* m_testSem;
+ int m_testErrorCode;
+
+ SubSystemClassBase();
+ SubSystemClassBase(const SubSystemClassBase& right);
+ SubSystemClassBase& operator=(const SubSystemClassBase& right);
+};
+
+} /* namespace etRuntime */
+#endif /* SUBSYSTEMCLASSBASE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
new file mode 100644
index 000000000..f3e91ad77
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
@@ -0,0 +1,65 @@
+/*
+ * SubSystemRunnerBase.cpp
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#include "SubSystemRunnerBase.h"
+#include "SubSystemClassBase.h"
+#include "common/platform/etTimer.h"
+
+namespace etRuntime {
+
+SubSystemRunnerBase::SubSystemRunnerBase() {
+}
+
+SubSystemRunnerBase::~SubSystemRunnerBase() {
+}
+
+
+void SubSystemRunnerBase::waitMultiThreaded() {
+ // waiting for command line input
+ std::string token = "";
+ std::cout << "type 'quit' to exit" << std::endl;
+ while (token != "quit") {
+ std::getline(std::cin, token);
+ std::cout << "echo: " << token << std::endl;
+ }
+}
+
+void SubSystemRunnerBase::waitAndPollSingleThreaded(SubSystemClassBase& mainComponent) {
+ for (int i=0; i< 100; ++i) {
+ if (etTimer_executeNeeded()) {
+ mainComponent.runOnce();
+ }
+ Sleep(100);
+ }
+
+ std::string token = "";
+ std::cout << "type 'quit' to exit" << std::endl;
+ #ifndef WIN32
+ pollfd cinfd[1];
+ // Theoretically this should always be 0, but one fileno call isn't going to hurt, and if
+ // we try to run somewhere that stdin isn't fd 0 then it will still just work
+ cinfd[0].fd = fileno(stdin);
+ cinfd[0].events = POLLIN;
+ #else
+ HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
+ #endif
+ while (token != "quit")
+ {
+ #ifndef WIN32
+ if (poll(cinfd, 1, 1000))
+ #else
+ // doesn't work as expected:
+ if (WaitForSingleObject(h, 100) == WAIT_OBJECT_0)
+ #endif
+ {
+ std::getline(std::cin, token);
+ std::cout << "echo: " << token << std::endl;
+ }
+ mainComponent.runOnce();
+ }
+}
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h
new file mode 100644
index 000000000..d44131a40
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h
@@ -0,0 +1,41 @@
+/*
+ * SubSystemRunnerBase.h
+ *
+ * The base class for running components.
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef SUBSYSTEMRUNNERBASE_H_
+#define SUBSYSTEMRUNNERBASE_H_
+
+#include <iostream>
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+namespace etRuntime {
+
+class SubSystemClassBase;
+
+class SubSystemRunnerBase {
+public:
+ SubSystemRunnerBase();
+ ~SubSystemRunnerBase();
+
+ /**
+ * blocks until the String "quit" is entered on the console
+ */
+protected:
+ static void waitForQuit(SubSystemClassBase& mainComponent) {
+ waitAndPollSingleThreaded(mainComponent);
+ }
+
+private:
+ static void waitMultiThreaded();
+ static void waitAndPollSingleThreaded(SubSystemClassBase& mainComponent);
+};
+
+} /* namespace etRuntime */
+#endif /* SUBSYSTEMRUNNERBASE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp
new file mode 100644
index 000000000..e5138166b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp
@@ -0,0 +1,16 @@
+/*
+ * TestSemaphore.cpp
+ *
+ * Created on: 31.08.2012
+ * Author: karlitsc
+ */
+
+#include "TestSemaphore.h"
+
+namespace etRuntime {
+
+
+TestSemaphore::~TestSemaphore() {
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h
new file mode 100644
index 000000000..e10b04d45
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h
@@ -0,0 +1,43 @@
+/*
+ * TestSemaphore.h
+ *
+ * Created on: 31.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef TESTSEMAPHORE_H_
+#define TESTSEMAPHORE_H_
+
+#include <iostream>
+
+namespace etRuntime {
+
+class TestSemaphore { //extends Semaphore
+public:
+ virtual ~TestSemaphore();
+
+ TestSemaphore(int permits) {
+ }
+ void release(int count) {};
+
+ void printWaitingThreads() {
+ std::cout << ">>> begin semaphore info >>>" << std::endl;
+// std::cout << "current thread is " + Thread.currentThread().getName() << std::endl;
+// Collection < Thread > threads = getQueuedThreads();
+// if (threads.isEmpty())
+// std::cout << " no waiting threads" << std::endl;
+// else
+// for (Thread thread : threads) {
+// std::cout << " blocked: " << thread.getName() << std::endl;
+// }
+ std::cout << "<<< end semaphore info <<<" << std::endl;
+ }
+private:
+ TestSemaphore();
+ TestSemaphore(const TestSemaphore& right);
+ TestSemaphore& operator=(const TestSemaphore& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* TESTSEMAPHORE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/platform/etTimer.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/platform/etTimer.h
new file mode 100644
index 000000000..4f2c25bb9
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/platform/etTimer.h
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Thomas Jung (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _ETTIMER_H_
+#define _ETTIMER_H_
+
+#include "etDatatypes.h"
+
+typedef struct etTargetTime {
+ unsigned long nSec;
+ unsigned long sec;
+} etTargetTime_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+void etTimer_init(void);
+
+uint32 getNSecFromTarget(void);
+uint32 getSecFromTarget(void);
+
+void getTimeFromTarget(etTargetTime_t *t);
+
+int isTimeGreaterThanActualTime(const etTargetTime_t *t);
+
+etBool etTimer_executeNeeded(void);
+
+uint32 getTimeBaseNS(void);
+
+uint32 getTimeBaseUS(void);
+
+uint32 getTimeBaseMS(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ETTIMER_H__ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/config/etRuntimeConfig.h b/runtime/org.eclipse.etrice.runtime.cpp/src/config/etRuntimeConfig.h
new file mode 100644
index 000000000..b1759ab47
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/config/etRuntimeConfig.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef ETGLOBALFLAGS_H_
+#define ETGLOBALFLAGS_H_
+
+/* flags for debugging */
+#define ET_MSC_LOGGER_ACTIVATE /* needs ET_LOGGER_ACTIVATE */
+#define ET_LOGGER_ACTIVATE
+
+
+#define STRUCT_ALIGN 8
+
+/* timing and scheduling */
+#define FREQUENCY 10L
+#define ET_RUNTIME_MAXLOOP 100
+//#define ET_RUNTIME_ENDLESS
+
+/* pool and block size */
+#define MESSAGE_POOL_MAX 50
+#define MESSAGE_BLOCK_SIZE 64
+
+
+#endif /* ETGLOBALFLAGS_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etDatatypes.h
new file mode 100644
index 000000000..dfae6df6c
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etDatatypes.h
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _ETDATATYPES_H_
+#define _ETDATATYPES_H_
+
+/*
+ * typedefs for platform specific datatypes
+ * generic Version for most bigger 32 and 64 bit platforms like Linux an Windows
+ *
+ * */
+
+#include <stdio.h>
+
+/* unsigned integer datatypes */
+typedef unsigned char uint8;
+typedef unsigned short int uint16;
+typedef unsigned long uint32;
+typedef unsigned long long uint64;
+
+/* signed integer datatypes */
+typedef char int8;
+typedef short int int16;
+typedef long int32;
+typedef long long int64;
+
+
+/* float datatypes */
+typedef float float32;
+typedef double float64;
+
+/* boolean datatypes and values */
+
+#ifndef __cplusplus
+typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/
+#endif /* __cplusplus */
+
+//typedef bool boolean;
+#ifndef TRUE
+ #define TRUE 1
+#endif
+#ifndef FALSE
+ #define FALSE 0
+#endif
+
+/*
+ * typedefs for eTrice Runtime and Testing
+ *
+ * */
+
+typedef int8 etInt8;
+typedef int16 etInt16;
+typedef int32 etInt32;
+
+typedef uint8 etUInt8;
+typedef uint16 etUInt16;
+typedef uint32 etUInt32;
+
+typedef bool etBool;
+
+typedef float32 etFloat32;
+typedef float64 etFloat64;
+
+typedef FILE* etFileHandle;
+
+typedef int8 etAddressId;
+
+#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.java/buckminster.cspec b/runtime/org.eclipse.etrice.runtime.java/buckminster.cspec
index e1e2a39b2..e4f347f4f 100644
--- a/runtime/org.eclipse.etrice.runtime.java/buckminster.cspec
+++ b/runtime/org.eclipse.etrice.runtime.java/buckminster.cspec
@@ -1,2 +1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.runtime.java" componentType="buckminster" version="0.0.2"/>
+<?xml version="1.0" encoding="UTF-8"?><cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.runtime.java" componentType="buckminster" version="0.3.0.qualifier"/>
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/IRTObject.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/IRTObject.java
index 30366d326..5377dafe4 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/IRTObject.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/IRTObject.java
@@ -23,6 +23,7 @@ public interface IRTObject {
static final char PATHNAME_DELIM = '_';
static final String NO_NAME = "<no name>";
+ String getInstancePath(char delim);
String getInstancePath();
String getInstancePathName();
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageDispatcher.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageDispatcher.java
index 5ba4115cf..22eb1368c 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageDispatcher.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageDispatcher.java
@@ -8,6 +8,7 @@
package org.eclipse.etrice.runtime.java.messaging;
+import java.util.ArrayList;
import java.util.HashMap;
/**
@@ -21,14 +22,28 @@ public class MessageDispatcher extends RTObject implements IMessageReceiver {
private HashMap<Number, IMessageReceiver> local_map = new HashMap<Number, IMessageReceiver>();
private HashMap<Number, IMessageReceiver> thread_map = new HashMap<Number, IMessageReceiver>();
private HashMap<Number, IMessageReceiver> node_map = new HashMap<Number, IMessageReceiver>();
+ private ArrayList<Address> freeAdresses = new ArrayList<Address>();
private Address address = null;
+ private int nextFreeObjId = 1;
public MessageDispatcher(IRTObject parent, Address addr, String name){
super(parent, name);
address = addr;
}
+ public Address getFreeAddress() {
+ if (freeAdresses.isEmpty()) {
+ return new Address(getAddress().nodeID, getAddress().threadID, nextFreeObjId++);
+ }
+ else
+ return freeAdresses.remove(0);
+ }
+
+ public void freeAddress(Address addr) {
+ freeAdresses.add(addr);
+ }
+
public void addMessageReceiver(IMessageReceiver receiver){
if (receiver.getAddress()==null)
return;
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
index 73e4f181f..d2a6bac4d 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
@@ -93,6 +93,14 @@ public class MessageService extends Thread implements IMessageReceiver,
}
+ public Address getFreeAddress() {
+ return messageDispatcher.getFreeAddress();
+ }
+
+ public void freeAddress(Address addr) {
+ messageDispatcher.freeAddress(addr);
+ }
+
// protected methods for sole use by test cases
protected MessageSeQueue getMessageQueue() {
return messageQueue;
@@ -107,23 +115,23 @@ public class MessageService extends Thread implements IMessageReceiver,
}
@Override
- public String getInstancePath() {
- String path = PATH_DELIM + name;
+ public String getInstancePath(char delim) {
+ String path = delim + name;
if (parent!=null)
path = parent.getInstancePath()+path;
return path;
}
+
+ @Override
+ public String getInstancePath() {
+ return getInstancePath(PATH_DELIM);
+ }
@Override
public String getInstancePathName() {
- String path = PATHNAME_DELIM + name;
-
- if (parent!=null)
- path = parent.getInstancePathName()+path;
-
- return path;
+ return getInstancePath(PATHNAME_DELIM);
}
public synchronized void terminate() {
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTObject.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTObject.java
index 6884b3489..304200783 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTObject.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTObject.java
@@ -8,6 +8,8 @@
package org.eclipse.etrice.runtime.java.messaging;
+import java.util.ArrayList;
+
/**
* An implementation of the IRTObject interface using a hierarchical structure
* to assemble paths.
@@ -17,33 +19,47 @@ package org.eclipse.etrice.runtime.java.messaging;
*/
public class RTObject implements IRTObject {
- private IRTObject parent = null;
private String name = NO_NAME;
+ private IRTObject parent = null;
+ ArrayList<IRTObject> children = new ArrayList<IRTObject>();
- public RTObject(IRTObject parent, String name){
+ protected RTObject(IRTObject parent, String name){
this.parent = parent;
this.name = name;
+ if (parent instanceof RTObject)
+ ((RTObject) parent).children.add(this);
}
+ protected void destroy() {
+ for (IRTObject child : children) {
+ if (child instanceof RTObject)
+ ((RTObject) child).destroy();
+ }
+
+ if (parent instanceof RTObject)
+ ((RTObject) parent).children.remove(this);
+
+ parent = null;
+ }
+
public IRTObject getParent() {
return parent;
}
- public String getInstancePath() {
- String path = PATH_DELIM + name;
+ public String getInstancePath(char delim) {
+ String path = delim + name;
if (parent!=null)
- path = parent.getInstancePath()+path;
+ path = parent.getInstancePath(delim)+path;
return path;
}
+
+ public String getInstancePath() {
+ return getInstancePath(PATH_DELIM);
+ }
public String getInstancePathName() {
- String path = PATHNAME_DELIM + name;
-
- if (parent!=null)
- path = parent.getInstancePathName()+path;
-
- return path;
+ return getInstancePath(PATHNAME_DELIM);
}
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
index deb3222e2..b39756816 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
@@ -9,6 +9,7 @@
package org.eclipse.etrice.runtime.java.modelbase;
import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+import org.eclipse.etrice.runtime.java.messaging.Address;
import org.eclipse.etrice.runtime.java.messaging.MessageService;
import org.eclipse.etrice.runtime.java.messaging.RTObject;
import org.eclipse.etrice.runtime.java.messaging.RTServices;
@@ -113,6 +114,10 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
return RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(idx);
}
+ public Address getFreeAddress(int msgSvcId) {
+ return getMsgService(msgSvcId).getFreeAddress();
+ }
+
public ActorClassBase getInstance(int i) {
if (instances==null || i<0 || i>= instances.length)
return null;
diff --git a/tests/org.eclipse.etrice.core.room.tests/models/TestBindings.room b/tests/org.eclipse.etrice.core.room.tests/models/TestBindings.room
new file mode 100644
index 000000000..47f081898
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.room.tests/models/TestBindings.room
@@ -0,0 +1,104 @@
+RoomModel TestBindings {
+ LogicalSystem Sys {
+ SubSystemRef main: Application
+ }
+
+ SubSystemClass Application {
+ ActorRef ref1: AC1
+ ActorRef ref2: AC2
+
+ // no self connection allowed, ports are indentical
+ Binding ref1.reg and ref1.reg
+
+ // port with multiplicity 1 is already connected
+ Binding ref1.reg and ref2.conj
+ Binding ref1.reg and ref2.conj
+
+ // protocols don't match
+ Binding ref1.reg and ref2.other
+
+ // protocol extends incoming
+ Binding ref1.base and ref2.extin
+
+ // ok
+ Binding ref1.base2 and ref2.extout
+
+ // protocol extends outgoing
+ Binding ref1.base3 and ref2.extout2
+
+ // derived protocols not connectable (both directions extended)
+ Binding ref1.base4 and ref2.extinout
+
+ LogicalThread dflt_thread
+ }
+
+ ActorClass AC1 {
+ Interface {
+ Port reg: PC1
+ Port base: PCBase
+ Port base2: PCBase
+ conjugated Port base3: PCBase
+ conjugated Port base4: PCBase
+ }
+ Structure {
+ external Port reg
+ }
+ Behavior { }
+ }
+
+ ActorClass AC2 {
+ Interface {
+ conjugated Port conj: PC1
+ conjugated Port other: PC2
+ conjugated Port extout: PCExtendOut
+ conjugated Port extin: PCExtendIn
+ Port extout2: PCExtendOut
+ Port extinout: PCExtendInOut
+ }
+ Structure {
+ external Port conj
+ }
+ Behavior { }
+ }
+
+ ProtocolClass PC1 {
+ incoming {
+ Message in1()
+ }
+ }
+
+ ProtocolClass PC2 {
+ incoming {
+ Message in1()
+ }
+ }
+
+ ProtocolClass PCBase {
+ incoming {
+ Message in1()
+ }
+ }
+
+ ProtocolClass PCExtendIn extends PCBase {
+ incoming {
+ Message in2()
+ }
+ }
+
+ ProtocolClass PCExtendOut extends PCBase {
+ outgoing {
+ Message out1()
+ }
+ }
+
+ ProtocolClass PCExtendInOut extends PCBase {
+ incoming {
+ Message in2()
+ }
+ outgoing {
+ // a derived protocol should add either incoming or outgoing messages, not both
+ Message out1()
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.core.room.tests/src/org/eclipse/etrice/core/TestBindings.java b/tests/org.eclipse.etrice.core.room.tests/src/org/eclipse/etrice/core/TestBindings.java
new file mode 100644
index 000000000..d370d16b5
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.room.tests/src/org/eclipse/etrice/core/TestBindings.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core;
+
+import static org.junit.Assert.*;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.room.Binding;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class TestBindings extends TestBase {
+ private Resource resource;
+
+ @Before
+ public void setUp() {
+ prepare();
+
+ resource = getResource("TestBindings.room");
+ }
+
+ @Test
+ public void testBindingValidation() {
+ RoomModel mdl = (RoomModel) resource.getContents().get(0);
+ SubSystemClass ssc = mdl.getSubSystemClasses().get(0);
+ Binding bind = ssc.getBindings().get(0);
+ Diagnostic diag = getDiag(bind).getChildren().get(0);
+ assertEquals("expect error message", "no self connection allowed, ports are indentical", diag.getMessage());
+
+ bind = ssc.getBindings().get(1);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("expect error message", "port with multiplicity 1 is already connected", diag.getMessage());
+
+ bind = ssc.getBindings().get(2);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("expect error message", "port with multiplicity 1 is already connected", diag.getMessage());
+
+ bind = ssc.getBindings().get(3);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("protocols don't match", diag.getMessage());
+
+ bind = ssc.getBindings().get(4);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("protocol extends incoming", diag.getMessage());
+
+ bind = ssc.getBindings().get(6);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("protocol extends outgoing", diag.getMessage());
+
+ bind = ssc.getBindings().get(7);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("derived protocols not connectable (both directions extended)", diag.getMessage());
+ }
+
+ @Test
+ public void testProtocolValidation() {
+ RoomModel mdl = (RoomModel) resource.getContents().get(0);
+ for (GeneralProtocolClass pc : mdl.getProtocolClasses()) {
+ if (pc.getName().equals("PCExtendInOut")) {
+ Diagnostic diag = getDiag(pc).getChildren().get(0);
+ assertEquals("a derived protocol should add either incoming or outgoing messages, not both", diag.getMessage());
+ }
+ }
+ }
+}
diff --git a/tests/org.eclipse.etrice.generator.c.tests/buckminster.cspec b/tests/org.eclipse.etrice.generator.c.tests/buckminster.cspec
index a4ef60acf..562d565a3 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/buckminster.cspec
+++ b/tests/org.eclipse.etrice.generator.c.tests/buckminster.cspec
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.generator.c.tests" componentType="buckminster" version="0.0.2">
+<?xml version="1.0" encoding="UTF-8"?><cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.generator.c.tests" componentType="buckminster" version="0.3.0.qualifier">
<cs:actions>
<cs:public name="run_tests" actor="ant">
<cs:actorProperties>
diff --git a/tests/org.eclipse.etrice.generator.common.tests/buckminster.cspec b/tests/org.eclipse.etrice.generator.common.tests/buckminster.cspec
index 8eca211cd..7025f5870 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/buckminster.cspec
+++ b/tests/org.eclipse.etrice.generator.common.tests/buckminster.cspec
@@ -1,2 +1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.generator.common.tests" componentType="buckminster" version="0.0.2"/>
+<?xml version="1.0" encoding="UTF-8"?><cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="org.eclipse.etrice.generator.common.tests" componentType="buckminster" version="0.3.0.qualifier"/>
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/.classpath b/tests/org.eclipse.etrice.generator.cpp.tests/.classpath
new file mode 100644
index 000000000..bb2b15cfe
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.cpp.tests/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.etrice.modellib.java"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.etrice.runtime.java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/.gitignore b/tests/org.eclipse.etrice.generator.cpp.tests/.gitignore
new file mode 100644
index 000000000..04907272d
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.cpp.tests/.gitignore
@@ -0,0 +1,6 @@
+/bin
+/models
+/output
+/results
+/src-gen
+/tmp
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/.project b/tests/org.eclipse.etrice.generator.cpp.tests/.project
new file mode 100644
index 000000000..2d5f8a80c
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.cpp.tests/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.generator.cpp.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.etrice.generator.cpp.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..54e493c07
--- /dev/null
+++ b/