Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend')
-rw-r--r--plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend154
1 files changed, 154 insertions, 0 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
new file mode 100644
index 000000000..ea7ebfb66
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * 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.config
+
+import java.util.ArrayList
+import java.util.List
+import org.eclipse.emf.ecore.resource.ResourceSet
+import org.eclipse.etrice.core.ConfigStandaloneSetup
+import org.eclipse.etrice.core.genmodel.base.ILogger
+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.ProtocolClass
+import org.eclipse.etrice.core.room.SubSystemClass
+import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.generator.config.util.DataConfigurationHelper
+import org.eclipse.etrice.core.config.BooleanLiteral
+import org.eclipse.etrice.core.config.IntLiteral
+import org.eclipse.etrice.core.config.RealLiteral
+import org.eclipse.etrice.core.config.StringLiteral
+import org.eclipse.etrice.core.config.LiteralArray
+import org.eclipse.etrice.core.config.Literal
+
+class DataConfiguration implements IDataConfiguration {
+
+
+ override doSetup() {
+ 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)?.min?.toStringExpr
+ }
+
+ override getAttrClassConfigMinValue(ActorClass actor, List<Attribute> path) {
+ actor.getAttrClassConfig(path)?.max?.toStringExpr
+ }
+
+ 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){
+ '''«FOR a : path SEPARATOR '/'»«a.name»«ENDFOR»'''.toString
+ }
+
+ override getAttrInstanceConfigValue(ActorInstance ai, List<Attribute> path) {
+ var id = ai.path+"/"+path.toStringPath
+ DataConfigurationHelper::actorInstanceAttrMap.get(id)?.value?.toStringExpr
+ }
+
+ // dynamic
+
+ override getPollingTimerUser(SubSystemClass subsystem) {
+ subsystem.config?.dynConfig?.polling
+ }
+
+ override getUserCode1(SubSystemClass 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
+ }
+
+ override getUserCode2(SubSystemClass subsystem) {
+ var dynConfig = subsystem.config?.dynConfig
+ return
+ if(dynConfig?.filePath != null)
+ '''new ConfigSourceFile("«dynConfig.filePath»")'''
+ else
+ dynConfig?.userCode2
+ }
+
+ override getDynConfigReadAttributes(String actorInstance) {
+ val result = new ArrayList<Attribute>
+ var configs = DataConfigurationHelper::dynActorInstanceAttrMap.get(actorInstance)
+ configs?.forEach(c | if(c.readOnly)result.add(c.attribute))
+
+ return result
+ }
+
+ override getDynConfigWriteAttributes(String actorInstance) {
+ val result = new ArrayList<Attribute>
+ var configs = DataConfigurationHelper::dynActorInstanceAttrMap.get(actorInstance)
+ configs?.forEach(c | if(!c.readOnly)result.add(c.attribute))
+
+ return result
+ }
+
+
+ override hasVariableService(SubSystemClass subsystem) {
+ subsystem.config?.dynConfig != null
+ }
+
+ def private toStringExpr(LiteralArray literal){
+ '''«FOR l : literal.literals SEPARATOR ','»«l.toStringExpr»«ENDFOR»'''.toString
+ }
+
+ def private toStringExpr(Literal literal){
+ switch(literal){
+ BooleanLiteral: literal.isTrue.toString
+ IntLiteral: literal.value.toString
+ RealLiteral: literal.value.toString
+ StringLiteral: literal.value.toString
+ }
+ }
+
+ def private getConfig(SubSystemClass cc){
+ DataConfigurationHelper::subSystemConfigMap.get(cc)
+ }
+
+ 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))
+ 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))
+ return result
+ }
+
+} \ No newline at end of file

Back to the top