diff options
author | Thomas Schuetz | 2013-07-12 08:40:15 +0000 |
---|---|---|
committer | Thomas Schuetz | 2013-07-12 08:40:15 +0000 |
commit | 12cda553738ca88662624b6f47066b5564549648 (patch) | |
tree | bfa65b6c38aa566a5f1cc98395da6546a6c6e282 /plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend | |
parent | 3447749b1a453735ac54fc09ea7680acdbb19b69 (diff) | |
parent | d65e1d1bdd43feadb43261b85aac2d8aef5e089c (diff) | |
download | org.eclipse.etrice-12cda553738ca88662624b6f47066b5564549648.tar.gz org.eclipse.etrice-12cda553738ca88662624b6f47066b5564549648.tar.xz org.eclipse.etrice-12cda553738ca88662624b6f47066b5564549648.zip |
Merge remote-tracking branch 'origin/master'
Conflicts:
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.tutorials.c.zip
plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
Change-Id: I98e2df3ab57d6e7e8f27e5b0aee7eaa189bfbc33
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend')
-rw-r--r-- | plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend | 178 |
1 files changed, 89 insertions, 89 deletions
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 index c1f7c9eab..876eafbcb 100644 --- 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 @@ -1,89 +1,89 @@ -/*******************************************************************************
- * 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)
- * Peter Karlitschek
- *
- *******************************************************************************/
-
-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
-
-import static extension org.eclipse.etrice.generator.base.CodegenHelpers.*
-
-/**
- * @author Peter Karlitschek
- *
- */
- @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[];
- static const int s_numberOfStates;
-
- 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.genStatePathName»"
- «ENDFOR»};
- const int «ac.name»::s_numberOfStates = «ac.getAllBaseStatesLeavesLast().size + 2»;
-
- 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"
- }
-
-
-
-
-}
+/******************************************************************************* + * 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) + * Peter Karlitschek + * + *******************************************************************************/ + +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 + +import static extension org.eclipse.etrice.generator.base.CodegenHelpers.* + +/** + * @author Peter Karlitschek + * + */ + @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[]; + static const int s_numberOfStates; + + 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.genStatePathName»" + «ENDFOR»}; + const int «ac.name»::s_numberOfStates = «ac.getAllBaseStatesLeavesLast().size + 2»; + + 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" + } + + + + +} |