Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2013-11-19 15:55:55 +0000
committerHenrik Rentz-Reichert2013-11-25 11:40:18 +0000
commitd9871bb6cfbd3b146f6c0da07136192291bedd24 (patch)
tree81122d4facdf5cfc027ef4d35e44f2a01c1f4196 /plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice
parent475da5253481df1a63b0ebf52071729c2bd86881 (diff)
downloadorg.eclipse.etrice-d9871bb6cfbd3b146f6c0da07136192291bedd24.tar.gz
org.eclipse.etrice-d9871bb6cfbd3b146f6c0da07136192291bedd24.tar.xz
org.eclipse.etrice-d9871bb6cfbd3b146f6c0da07136192291bedd24.zip
[core,gen] added enum room init + enum config support for java,c
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice')
-rw-r--r--plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend123
1 files changed, 63 insertions, 60 deletions
diff --git a/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
index 4fdd584b1..b5d1e0c1f 100644
--- a/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
+++ b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
@@ -9,22 +9,25 @@
* Juergen Haug
*
*******************************************************************************/
-
package org.eclipse.etrice.generator.config
import com.google.inject.Inject
import java.util.ArrayList
import java.util.List
+import org.eclipse.emf.common.EMFPlugin
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.etrice.core.ConfigStandaloneSetup
import org.eclipse.etrice.core.common.base.BooleanLiteral
-import org.eclipse.etrice.core.config.ConfigModel
import org.eclipse.etrice.core.common.base.IntLiteral
import org.eclipse.etrice.core.common.base.Literal
-import org.eclipse.etrice.core.common.base.LiteralArray
import org.eclipse.etrice.core.common.base.RealLiteral
import org.eclipse.etrice.core.common.base.StringLiteral
+import org.eclipse.etrice.core.config.ConfigModel
+import org.eclipse.etrice.core.config.ConfigValue
+import org.eclipse.etrice.core.config.ConfigValueArray
+import org.eclipse.etrice.core.config.EnumConfigValue
+import org.eclipse.etrice.core.config.LiteralConfigValue
import org.eclipse.etrice.core.genmodel.base.ILogger
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance
@@ -36,117 +39,117 @@ import org.eclipse.etrice.generator.base.IDataConfiguration
import org.eclipse.etrice.generator.base.IResourceURIAcceptor
import org.eclipse.etrice.generator.config.util.DataConfigurationHelper
import org.eclipse.xtext.scoping.impl.ImportUriResolver
-import org.eclipse.emf.common.EMFPlugin
class DataConfiguration implements IDataConfiguration {
-
+
@Inject
protected ILogger logger;
-
+
@Inject
protected ImportUriResolver uriResolver;
override doSetup() {
if (!EMFPlugin::IS_ECLIPSE_RUNNING)
ConfigStandaloneSetup::doSetup()
-
+
}
-
+
override setResources(ResourceSet resource, ILogger logger) {
DataConfigurationHelper::setConfigModels(resource, logger)
}
-
+
// static
-
override getAttrClassConfigValue(ActorClass actor, List<Attribute> path) {
actor.getAttrClassConfig(path)?.value?.toStringExpr
}
-
+
override getAttrClassConfigMaxValue(ActorClass actor, List<Attribute> path) {
actor.getAttrClassConfig(path)?.max?.toStringExpr
}
-
+
override getAttrClassConfigMinValue(ActorClass actor, List<Attribute> path) {
actor.getAttrClassConfig(path)?.min?.toStringExpr
}
-
- def private getAttrClassConfig(ActorClass actor, List<Attribute> path){
+
+ def private getAttrClassConfig(ActorClass actor, List<Attribute> path) {
var id = '''/«actor.name»/«path.toStringPath»'''.toString
DataConfigurationHelper::actorClassAttrMap.get(id)
}
-
+
override getAttrClassConfigValue(ProtocolClass pc, boolean regular, List<Attribute> path) {
var id = '''/«pc.name»/«IF regular»regular«ELSE»conjugated«ENDIF»/«path.toStringPath»'''.toString
DataConfigurationHelper::protocolClassAttrMap.get(id)?.value?.toStringExpr
}
-
- def private toStringPath(List<Attribute> path){
+
+ def private toStringPath(List<Attribute> path) {
'''«FOR a : path SEPARATOR '/'»«a.name»«ENDFOR»'''.toString
}
-
+
override getAttrInstanceConfigValue(ActorInstance ai, List<Attribute> path) {
- var id = ai.path+"/"+path.toStringPath
+ var id = ai.path + "/" + path.toStringPath
DataConfigurationHelper::actorInstanceAttrMap.get(id)?.value?.toStringExpr
}
-
+
override getAttrInstanceConfigValue(InterfaceItemInstance item, List<Attribute> path) {
- DataConfigurationHelper::actorInstanceAttrMap.get(item.path+"/"+path.toStringPath)?.value?.toStringExpr
+ DataConfigurationHelper::actorInstanceAttrMap.get(item.path + "/" + path.toStringPath)?.value?.toStringExpr
}
+
// dynamic
-
override getPollingTimerUser(SubSystemInstance subsystem) {
- val dynConf = subsystem.config?.dynConfig
- if (dynConf==null)
- 0
- else
- dynConf.polling
+ val dynConf = subsystem.config?.dynConfig
+ if (dynConf == null)
+ 0
+ else
+ dynConf.polling
}
-
+
override getUserCode1(SubSystemInstance subsystem) {
var dynConfig = subsystem.config?.dynConfig
- return
- if(dynConfig?.filePath != null)
- "import org.eclipse.etrice.runtime.java.config.ConfigSourceFile;" // TODO JH make lang independent
- else
- dynConfig?.userCode1
+ return if (dynConfig?.filePath != null)
+ "import org.eclipse.etrice.runtime.java.config.ConfigSourceFile;" // TODO JH make lang independent
+ else
+ dynConfig?.userCode1
}
-
+
override getUserCode2(SubSystemInstance subsystem) {
var dynConfig = subsystem.config?.dynConfig
- return
- if(dynConfig?.filePath != null)
- '''new ConfigSourceFile("«dynConfig.filePath»")'''
- else
- dynConfig?.userCode2
+ return if (dynConfig?.filePath != null) '''new ConfigSourceFile("«dynConfig.filePath»")''' else
+ dynConfig?.userCode2
}
-
+
override getDynConfigReadAttributes(ActorInstance ai) {
val result = new ArrayList<Attribute>
var configs = DataConfigurationHelper::dynActorInstanceAttrMap.get(ai.path)
- configs?.forEach(c | if(c.readOnly)result.add(c.attribute))
-
+ configs?.forEach(c|if(c.readOnly) result.add(c.attribute))
+
return result
}
-
+
override getDynConfigWriteAttributes(ActorInstance ai) {
val result = new ArrayList<Attribute>
var configs = DataConfigurationHelper::dynActorInstanceAttrMap.get(ai.path)
- configs?.forEach(c | if(!c.readOnly)result.add(c.attribute))
-
+ configs?.forEach(c|if(!c.readOnly) result.add(c.attribute))
+
return result
}
-
-
+
override hasVariableService(SubSystemInstance subsystem) {
subsystem.config?.dynConfig != null
}
-
- def private toStringExpr(LiteralArray literal){
- '''«FOR l : literal.literals SEPARATOR ','»«l.toStringExpr»«ENDFOR»'''.toString
+
+ def private toStringExpr(ConfigValueArray literal) {
+ '''«FOR l : literal.values SEPARATOR ','»«l.toStringExpr»«ENDFOR»'''.toString
}
-
- def private toStringExpr(Literal literal){
- switch(literal){
+
+ def private toStringExpr(ConfigValue configValue) {
+ switch (configValue) {
+ LiteralConfigValue: configValue.value.toStringExpr
+ EnumConfigValue: configValue.value.fullName
+ }
+ }
+
+ def private toStringExpr(Literal literal) {
+ switch (literal) {
BooleanLiteral: literal.isTrue.toString
IntLiteral: literal.value.toString
RealLiteral: literal.value.toString
@@ -154,24 +157,24 @@ class DataConfiguration implements IDataConfiguration {
}
}
- def private getConfig(SubSystemInstance cc){
+ def private getConfig(SubSystemInstance cc) {
DataConfigurationHelper::subSystemConfigMap.get(cc.path)
- }
+ }
override getDynConfigReadAttributes(ActorClass actor) {
val result = new ArrayList<Attribute>
var configs = DataConfigurationHelper::dynActorClassAttrMap.get(actor)
- configs?.forEach(c | if(c.readOnly)result.add(c.attribute))
+ configs?.forEach(c|if(c.readOnly) result.add(c.attribute))
return result
}
-
+
override getDynConfigWriteAttributes(ActorClass actor) {
val result = new ArrayList<Attribute>
var configs = DataConfigurationHelper::dynActorClassAttrMap.get(actor)
- configs?.forEach(c | if(!c.readOnly)result.add(c.attribute))
+ configs?.forEach(c|if(!c.readOnly) result.add(c.attribute))
return result
}
-
+
override void addReferencedModels(IResourceURIAcceptor acceptor, EObject root) {
if (root instanceof ConfigModel) {
for (imp : (root as ConfigModel).imports) {
@@ -180,5 +183,5 @@ class DataConfiguration implements IDataConfiguration {
}
}
}
-
+
}

Back to the top