Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-12-12 15:04:49 +0000
committerJuergen Haug2012-12-12 15:04:49 +0000
commit72802f3f5250f6632ed0a4e6dc3bedcb9c5ffee4 (patch)
tree82752da439d361c9701506d895362c4110b523d9 /plugins/org.eclipse.etrice.generator.java
parent13e48a31dba2985660abdbf3120ef2ca93557f69 (diff)
downloadorg.eclipse.etrice-72802f3f5250f6632ed0a4e6dc3bedcb9c5ffee4.tar.gz
org.eclipse.etrice-72802f3f5250f6632ed0a4e6dc3bedcb9c5ffee4.tar.xz
org.eclipse.etrice-72802f3f5250f6632ed0a4e6dc3bedcb9c5ffee4.zip
[config, generator, tests] static and dynamic config test + fixes
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.java')
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend70
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend41
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend61
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend38
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend22
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java242
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java243
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java161
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java155
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java32
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java53
11 files changed, 610 insertions, 508 deletions
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 ed83450d1..73db99e0d 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
@@ -34,6 +34,7 @@ class ConfigGenAddon {
@Inject extension ProcedureHelpers helpers
@Inject IDataConfiguration dataConfigExt
@Inject extension RoomExtensions
+ @Inject Initialization initGen
// For SubSystemClassGen
@@ -55,27 +56,19 @@ class ConfigGenAddon {
def private applyInstanceConfig(InstanceBase instance, String invokes, List<Attribute> path){
var a = path.last
var aType = a.refType.type
- if(aType.primitive){
- var value = typeHelpers.getAttrInstanceConfigValue(path, instance)
- 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).allAttributes»
- «applyInstanceConfig(instance, invokes+"."+a.name.invokeGetter(null), path.union(e))»
- «ENDFOR»
- '''
+ switch aType {
+ PrimitiveType: {
+ var value = typeHelpers.getAttrInstanceConfigValue(path, instance)
+ if(value != null)
+ initGen.genAttributeInitializer(a, toValueLiteral(aType, value), invokes)
+ }
+ DataClass:
+ '''
+ «FOR e : (aType as DataClass).allAttributes»
+ «applyInstanceConfig(instance, invokes+"."+a.name.invokeGetter(null), path.union(e))»
+ «ENDFOR»
+ '''
+ }
}
// For ActorClassGen
@@ -122,24 +115,25 @@ class ConfigGenAddon {
}
def private genMinMaxConstantsRec(ActorClass ac, String varNamePath, List<Attribute> path){
- var temp = null as String
var aType = path.last.refType.type
- if(aType.dataClass)
- '''
- «FOR e : (aType as DataClass).allAttributes»
- «genMinMaxConstantsRec(ac, varNamePath+"_"+e.name, path.union(e))»
- «ENDFOR»
- '''
- else if(aType instanceof PrimitiveType){
- var pType = aType as PrimitiveType
- '''
- «IF (temp = dataConfigExt.getAttrClassConfigMinValue(ac, path)) != null»
- public static «pType.minMaxType» MIN_«varNamePath» = «pType.toValueLiteral(temp)»;
- «ENDIF»
- «IF (temp = dataConfigExt.getAttrClassConfigMaxValue(ac, path)) != null»
- public static «pType.minMaxType» MAX_«varNamePath» = «pType.toValueLiteral(temp)»;
- «ENDIF»
- '''
+ switch aType {
+ DataClass:
+ '''
+ «FOR e : (aType as DataClass).allAttributes»
+ «genMinMaxConstantsRec(ac, varNamePath+"_"+e.name, path.union(e))»
+ «ENDFOR»
+ '''
+ PrimitiveType:{
+ var temp = null as String
+ '''
+ «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»
+ '''
+ }
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
index 32a9a7971..75c5e0bf0 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
@@ -22,7 +22,6 @@ import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.core.room.DataClass
import org.eclipse.etrice.core.room.PortClass
import org.eclipse.etrice.core.room.PrimitiveType
-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
@@ -32,7 +31,7 @@ class Initialization {
@Inject extension TypeHelpers typeHelpers
@Inject extension RoomExtensions
- @Inject extension ILanguageExtension languageExt
+ @Inject extension JavaExtensions languageExt
@Inject extension ProcedureHelpers procedureHelpers
def attributeInitialization(List<Attribute> attribs, EObject roomClass, boolean useClassDefaultsOnly) {
@@ -50,7 +49,7 @@ class Initialization {
if(a.refType.ref){
if(a.defaultValueLiteral != null)
attributeInit(a, a.defaultValueLiteral)
- else if(!(useClassDefaultsOnly && aType.primitive))
+ else if(languageExt.needsInitialization(a))
attributeInit(a, languageExt.nullPointer)
}
else{
@@ -58,7 +57,7 @@ class Initialization {
var value = getDataConfigValue(new ArrayList<Attribute>.union(a), roomClass)
if(value == null) value = a.defaultValueLiteral
if(value != null) attributeInit(a, languageExt.toValueLiteral(aType as PrimitiveType, value))
- else if(!useClassDefaultsOnly) attributeInit(a, languageExt.defaultValue(aType))
+ else if(!useClassDefaultsOnly || languageExt.needsInitialization(a)) attributeInit(a, languageExt.defaultValue(aType))
} else
attributeInit(a, languageExt.defaultValue(aType))
}
@@ -85,22 +84,28 @@ class Initialization {
}
def private attributeInit(List<Attribute> path, String value){
- var a = path.last
+ var getter = if(path.size == 1) "this" else procedureHelpers.invokeGetters(path.take(path.size-1), null).toString
+ return genAttributeInitializer(path.last, value, getter)
+ }
+
+ def genAttributeInitializer(Attribute a, String value, String invokes){
var aType = a.refType.type
- var getter = if(path.size > 1)procedureHelpers.invokeGetters(path.take(path.size-1), null)+"." else ""
- return '''
- «IF a.size == 0 || aType.characterType»
- «getter»«procedureHelpers.invokeSetter(a.name, null, value)»;
- «ELSEIF !value.trim.startsWith('{')»
- {
- «aType.typeName»[] «a.name» = new «aType.typeName»[«a.size»];
- for (int i=0;i<«a.size»;i++){
- «a.name»[i] = «value»;
- }
- «getter»«procedureHelpers.invokeSetter(a.name, null, a.name)»;
- }
+ // be careful of: char array with single character ('x')
+ '''
+ «IF a.size == 0 || (a.size > 0 && "char".equals(aType.typeName) && !value.matches("'.'|\\(char\\).*"))»
+ «invokes».«procedureHelpers.invokeSetter(a.name, null, value)»;
+ «ELSEIF !value.trim.startsWith('{') || "char".equals(aType.typeName)»
+ {
+ «aType.typeName»[] array = new «aType.typeName»[«a.size»];
+ «IF !(a.refType.ref && aType.primitive)»
+ for (int i=0;i<«a.size»;i++){
+ array[i] = «value»;
+ }
+ «ENDIF»
+ «invokes».«procedureHelpers.invokeSetter(a.name, null, "array")»;
+ }
«ELSE»
- «getter»«procedureHelpers.invokeSetter(a.name,null, '''new «aType.typeName»[] «value»''')»;
+ «invokes».«procedureHelpers.invokeSetter(a.name,null, '''new «aType.typeName»[] «value»''')»;
«ENDIF»
'''
}
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 1e4a27d9e..2055f5b32 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
@@ -17,8 +17,10 @@
package org.eclipse.etrice.generator.java.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.DataType
import org.eclipse.etrice.core.room.ExternalType
import org.eclipse.etrice.core.room.Message
@@ -26,10 +28,8 @@ 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.generator.generic.ILanguageExtension
-import org.eclipse.xtext.util.Pair
-import org.eclipse.etrice.core.room.RefableType
import org.eclipse.etrice.generator.generic.TypeHelpers
-import com.google.inject.Inject
+import org.eclipse.xtext.util.Pair
@Singleton
class JavaExtensions implements ILanguageExtension {
@@ -50,6 +50,10 @@ class JavaExtensions implements ILanguageExtension {
}
}
+ def boolean needsInitialization(Attribute a){
+ a.size > 0 || !typeHelpers.isPrimitive(a.refType.type)|| typeHelpers.typeName(a.refType.type)?.equals("String")
+ }
+
override String accessLevelPrivate() {"private "}
override String accessLevelProtected() {"protected "}
override String accessLevelPublic() {"public "}
@@ -112,11 +116,7 @@ class JavaExtensions implements ILanguageExtension {
override toValueLiteral(PrimitiveType type, String value) {
switch(type.targetName){
- case "char":
- castValue(type, value)
- case "string":
- castValue(type, value)
- case value.contains(','):{
+ case !typeHelpers.isCharacterType(type) && value.contains(','): {
var singleValues = value.replace('{', '').replace('}', '').trim.split(',')
'''{ «FOR v: singleValues SEPARATOR ', '»«castValue(type, v.trim)»«ENDFOR» }'''.toString
}
@@ -128,41 +128,42 @@ class JavaExtensions implements ILanguageExtension {
def private castValue(PrimitiveType type, String value){
switch(type.targetName){
case "boolean":
- return value.toLowerCase
+ value.toLowerCase
case "byte":
- return "(byte)"+value
+ "(byte)"+value
case "short":
- return "(short)"+value
+ "(short)"+value
case "int":
- return value
+ value
case "long":
- return value+"L"
+ value+"L"
case "float":
- return value+"f"
+ value+"f"
case "double":
- return value+"d"
- case "char":{
- if(value.length == 1)
- return "'"+value+"'"
+ value+"d"
+ case "char":
+ if(value.empty)
+ "(char) 0"
+ else if(value.length==1)
+ "'"+value.charAt(0)+"'"
else
- return "\""+value.replace("\\", "\\\\").replace("\"", "\\\"")+"\".toCharArray()"
- }
+ "\""+value.replace("\\", "\\\\").replace("\"", "\\\"")+"\".toCharArray()"
case "String":
- return "\""+value.replace("\\", "\\\\").replace("\"", "\\\"")+"\""
+ "\""+value.replace("\\", "\\\\").replace("\"", "\\\"")+"\""
+ default:
+ throw new UnsupportedOperationException(type.targetName)
}
-
- throw new UnsupportedOperationException(type.targetName)
}
override defaultValue(DataType dt) {
- if (dt instanceof PrimitiveType) {
- var pType = dt as PrimitiveType
- return toValueLiteral(pType, pType.defaultValueLiteral)
+ switch dt {
+ PrimitiveType:
+ toValueLiteral(dt, dt.defaultValueLiteral)
+ ExternalType:
+ "new "+(dt as ExternalType).targetName+"()"
+ default:
+ "new "+dt.name+"()"
}
- else if (dt instanceof ExternalType)
- return "new "+(dt as ExternalType).targetName+"()"
- else
- return "new "+dt.name+"()"
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
index c4dbabbf2..340e08bfc 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
@@ -23,6 +23,7 @@ import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import static extension org.eclipse.etrice.generator.base.Indexed.*
import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.core.room.LogicalThread
@Singleton
class SubSystemClassGen {
@@ -44,7 +45,7 @@ class SubSystemClassGen {
logger.logInfo("generating SubSystemClass implementation: '"+file+"' in '"+path+"'")
fileAccess.setOutputPath(path)
fileAccess.generateFile(file, root.generate(ssi))
- if(dataConfigExt.hasVariableService(ssi.subSystemClass))
+ if(dataConfigExt.hasVariableService(ssi))
varService.doGenerate(root, ssi);
}
}
@@ -54,7 +55,7 @@ class SubSystemClassGen {
'''
package «cc.getPackage()»;
- «IF dataConfigExt.hasVariableService(cc)»import org.eclipse.etrice.runtime.java.config.VariableService;«ENDIF»
+ «IF dataConfigExt.hasVariableService(comp)»import org.eclipse.etrice.runtime.java.config.VariableService;«ENDIF»
import org.eclipse.etrice.runtime.java.messaging.MessageService;
import org.eclipse.etrice.runtime.java.messaging.RTServices;
import org.eclipse.etrice.runtime.java.messaging.Address;
@@ -70,6 +71,10 @@ class SubSystemClassGen {
«cc.userCode(1)»
public class «cc.name» extends SubSystemClassBase {
+ public final int THREAD__DEFAULT = 0;
+ «FOR thread : cc.threads.indexed»
+ public final int «thread.value.threadId» = «thread.index1»;
+ «ENDFOR»
«cc.userCode(2)»
@@ -84,9 +89,9 @@ class SubSystemClassGen {
@Override
public void instantiateMessageServices(){
- RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),"MessageService_Main"));
+ RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(THREAD__DEFAULT, 0, 0),"MessageService_Main"));
«FOR thread : cc.threads»
- RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, «cc.threads.indexOf(thread)+1», 0),"MessageService_«thread.name»" /*, thread_prio */));
+ RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, «thread.threadId», 0),"MessageService_«thread.name»" /*, thread_prio */));
«ENDFOR»
}
@@ -95,23 +100,24 @@ class SubSystemClassGen {
// all addresses
// Addresses for the Subsystem Systemport
- «FOR ai : comp.allContainedInstances.indexed(comp.maxObjId)»
- Address addr_item_SystemPort_«comp.allContainedInstances.indexOf(ai.value)» = new Address(0,0,«ai.index1»);
+ «FOR ai : comp.allContainedInstances»
+ Address addr_item_SystemPort_«comp.allContainedInstances.indexOf(ai)» = getFreeAddress(THREAD__DEFAULT);
«ENDFOR»
«FOR ai : comp.allContainedInstances»
+ «val threadId = if (ai.threadId==0) "THREAD__DEFAULT" else cc.threads.get(ai.threadId-1).threadId»
// 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()» = new Address(0,«ai.threadId»,«ai.objId»);
+ Address addr_item_«ai.path.getPathName()» = getFreeAddress(«threadId»);
// 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» = new Address(0,«ai.threadId»,«pi.objId+i»);
+ Address addr_item_«pi.path.getPathName()»_«i» = getFreeAddress(«threadId»);
«ENDFOR»
«ELSE»
- Address addr_item_«pi.path.getPathName()» = new Address(0,«ai.threadId»,«pi.objId»);
+ Address addr_item_«pi.path.getPathName()» = getFreeAddress(«threadId»);
«ENDIF»
«ENDFOR»
«ENDFOR»
@@ -168,7 +174,8 @@ class SubSystemClassGen {
«ENDIF»
«ENDFOR»
}
- «IF !dataConfigExt.getDynConfigWriteAttributes(ai.path).empty»
+ «IF !(dataConfigExt.getDynConfigReadAttributes(ai).empty &&
+ dataConfigExt.getDynConfigWriteAttributes(ai).empty)»
, variableService
«ENDIF»
);
@@ -202,17 +209,17 @@ class SubSystemClassGen {
});
}
- «IF dataConfigExt.hasVariableService(cc)»
+ «IF dataConfigExt.hasVariableService(comp)»
private VariableService variableService;
«ENDIF»
@Override
public void init(){
- «IF dataConfigExt.hasVariableService(cc)»
+ «IF dataConfigExt.hasVariableService(comp)»
variableService = new «cc.name»VariableService(this);
«ENDIF»
super.init();
- «IF dataConfigExt.hasVariableService(cc)»
+ «IF dataConfigExt.hasVariableService(comp)»
variableService.init();
«ENDIF»
}
@@ -220,7 +227,7 @@ class SubSystemClassGen {
@Override
public void stop(){
super.stop();
- «IF dataConfigExt.hasVariableService(cc)»
+ «IF dataConfigExt.hasVariableService(comp)»
variableService.stop();
«ENDIF»
}
@@ -229,4 +236,7 @@ class SubSystemClassGen {
'''
}
+ def private getThreadId(LogicalThread thread) {
+ "THREAD_"+thread.name.toUpperCase
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
index 247decb6d..718d10c19 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
@@ -54,18 +54,18 @@ class VariableServiceGen {
}
def private generate(Root root, SubSystemInstance comp) {
- val cc = comp.subSystemClass
+ var cc = comp.subSystemClass
val aisAttrMap = new HashMap<ActorInstance, List<Attribute>>
- comp.allContainedInstances.forEach(ai | if(!configExt.getDynConfigReadAttributes(ai.path).empty)aisAttrMap.put(ai, configExt.getDynConfigReadAttributes(ai.path)))
+ comp.allContainedInstances.forEach(ai | if(!configExt.getDynConfigReadAttributes(ai).empty)aisAttrMap.put(ai, configExt.getDynConfigReadAttributes(ai)))
'''
- package «cc.getPackage()»;
+ package «comp.subSystemClass.getPackage()»;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.etrice.runtime.java.config.VariableService;
- «configExt.getUserCode1(cc)»
+ «configExt.getUserCode1(comp)»
«FOR model : aisAttrMap.keySet.roomModels»
import «model.name».*;
«ENDFOR»
@@ -73,7 +73,7 @@ class VariableServiceGen {
public class «cc.name+"VariableService"» extends VariableService{
- private «cc.name» subSystem;
+ private «comp.subSystemClass.name» subSystem;
// Actor instances
«FOR ai : aisAttrMap.keySet»
@@ -81,7 +81,7 @@ class VariableServiceGen {
«ENDFOR»
public «cc.name+"VariableService"»(«cc.name» subSystem) {
- super(«configExt.getUserCode2(cc)»);
+ super(«configExt.getUserCode2(comp)»);
this.subSystem = subSystem;
}
@@ -153,27 +153,27 @@ class VariableServiceGen {
@Override
protected int getPollingTimerUser(){
- return «configExt.getPollingTimerUser(cc)»;
+ return «configExt.getPollingTimerUser(comp)»;
}
}
'''}
def private genMinMaxCheck(List<Attribute> path, ActorClass ac){
+ var a = path.last
var aVarName = path.toAbsolutePath("_")
var min = configExt.getAttrClassConfigMinValue(ac, path) != null
var max = configExt.getAttrClassConfigMaxValue(ac, path) != null
if(min || max)
'''
- checkMinMax(«aVarName», «IF min»«ac.name».MIN«aVarName»«ELSE»null«ENDIF», «IF max»«ac.name».MAX«aVarName»«ELSE»null«ENDIF»);
+ «IF a.size>0»for(«a.refType.type.typeName» e : «aVarName»)
+ «ENDIF»checkMinMax(«IF a.size>0»e«ELSE»«aVarName»«ENDIF», «IF min»«ac.name».MIN«aVarName»«ELSE»null«ENDIF», «IF max»«ac.name».MAX«aVarName»«ELSE»null«ENDIF»);
'''
- else
- ''''''
}
def private getDynConfigDataClasses(Iterable<ActorInstance> ais){
val result = new HashSet<DataClass>
- ais.forEach(ai | configExt.getDynConfigReadAttributes(ai.path).
+ ais.forEach(ai | configExt.getDynConfigReadAttributes(ai).
forEach(a | if(a.refType.type.dataClass)result.add(a.refType.type as DataClass)
))
return result
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
index bb0982961..8554d38bf 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
@@ -21,9 +21,9 @@ 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.generator.java.gen.Initialization;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
@@ -44,6 +44,9 @@ public class ConfigGenAddon {
@Inject
private RoomExtensions _roomExtensions;
+ @Inject
+ private Initialization initGen;
+
public CharSequence genActorInstanceConfig(final ActorInstance ai, final String aiVariableName) {
StringConcatenation _builder = new StringConcatenation();
{
@@ -93,126 +96,34 @@ public class ConfigGenAddon {
Attribute a = IterableExtensions.<Attribute>last(path);
RefableType _refType = a.getRefType();
DataType aType = _refType.getType();
- CharSequence _xifexpression = null;
- boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
- if (_isPrimitive) {
- CharSequence _xblockexpression_1 = null;
- {
- String value = this.typeHelpers.getAttrInstanceConfigValue(path, instance);
- CharSequence _xifexpression_1 = null;
- boolean _equals = Objects.equal(value, null);
- if (_equals) {
- StringConcatenation _builder = new StringConcatenation();
- _xifexpression_1 = _builder;
- } else {
- CharSequence _xifexpression_2 = null;
- boolean _or = false;
- int _size = a.getSize();
- boolean _equals_1 = (_size == 0);
- if (_equals_1) {
- _or = true;
- } else {
- boolean _isCharacterType = this.typeHelpers.isCharacterType(aType);
- _or = (_equals_1 || _isCharacterType);
- }
- if (_or) {
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append(invokes, "");
- _builder_1.append(".");
- String _name = a.getName();
- String _valueLiteral = this.stdExt.toValueLiteral(((PrimitiveType) aType), value);
- CharSequence _invokeSetter = this.helpers.invokeSetter(_name, null, _valueLiteral);
- _builder_1.append(_invokeSetter, "");
- _builder_1.append(";");
- _xifexpression_2 = _builder_1;
- } else {
- CharSequence _xifexpression_3 = null;
- int _size_1 = a.getSize();
- String[] _split = value.split(",");
- int _size_2 = ((List<String>)Conversions.doWrapArray(_split)).size();
- boolean _equals_2 = (_size_1 == _size_2);
- if (_equals_2) {
- CharSequence _xblockexpression_2 = null;
- {
- StringConcatenation _builder_2 = new StringConcatenation();
- _builder_2.append("{ ");
- {
- String[] _split_1 = value.split(",");
- boolean _hasElements = false;
- for(final String s : _split_1) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder_2.appendImmediate(", ", "");
- }
- String _trim = s.trim();
- String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), _trim);
- _builder_2.append(_valueLiteral_1, "");
- }
- }
- _builder_2.append(" }");
- CharSequence arrayExpr = _builder_2;
- StringConcatenation _builder_3 = new StringConcatenation();
- _builder_3.append(invokes, "");
- _builder_3.append(".");
- String _name_1 = a.getName();
- StringConcatenation _builder_4 = new StringConcatenation();
- _builder_4.append("new ");
- String _typeName = this.typeHelpers.typeName(aType);
- _builder_4.append(_typeName, "");
- _builder_4.append("[] ");
- _builder_4.append(arrayExpr, "");
- String _string = _builder_4.toString();
- CharSequence _invokeSetter_1 = this.helpers.invokeSetter(_name_1, null, _string);
- _builder_3.append(_invokeSetter_1, "");
- _builder_3.append(";");
- _xblockexpression_2 = (_builder_3);
- }
- _xifexpression_3 = _xblockexpression_2;
- } else {
- StringConcatenation _builder_2 = new StringConcatenation();
- _builder_2.append("{");
- _builder_2.newLine();
- _builder_2.append("\t");
- String _typeName = this.typeHelpers.typeName(aType);
- _builder_2.append(_typeName, " ");
- _builder_2.append("[] array = ");
- _builder_2.append(invokes, " ");
- _builder_2.append(".");
- String _name_1 = a.getName();
- CharSequence _invokeGetter = this.helpers.invokeGetter(_name_1, null);
- _builder_2.append(_invokeGetter, " ");
- _builder_2.append(";");
- _builder_2.newLineIfNotEmpty();
- _builder_2.append("\t");
- _builder_2.append("for (int i=0;i<");
- int _size_3 = a.getSize();
- _builder_2.append(_size_3, " ");
- _builder_2.append(";i++){");
- _builder_2.newLineIfNotEmpty();
- _builder_2.append("\t\t");
- _builder_2.append("array[i] = ");
- String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), value);
- _builder_2.append(_valueLiteral_1, " ");
- _builder_2.append(";");
- _builder_2.newLineIfNotEmpty();
- _builder_2.append("}");
- _xifexpression_3 = _builder_2;
- }
- _xifexpression_2 = _xifexpression_3;
+ CharSequence _switchResult = null;
+ boolean _matched = false;
+ if (!_matched) {
+ if (aType instanceof PrimitiveType) {
+ final PrimitiveType _primitiveType = (PrimitiveType)aType;
+ _matched=true;
+ CharSequence _xblockexpression_1 = null;
+ {
+ String value = this.typeHelpers.getAttrInstanceConfigValue(path, instance);
+ CharSequence _xifexpression = null;
+ boolean _notEquals = (!Objects.equal(value, null));
+ if (_notEquals) {
+ String _valueLiteral = this.stdExt.toValueLiteral(_primitiveType, value);
+ CharSequence _genAttributeInitializer = this.initGen.genAttributeInitializer(a, _valueLiteral, invokes);
+ _xifexpression = _genAttributeInitializer;
}
- _xifexpression_1 = _xifexpression_2;
+ _xblockexpression_1 = (_xifexpression);
}
- _xblockexpression_1 = (_xifexpression_1);
+ _switchResult = _xblockexpression_1;
}
- _xifexpression = _xblockexpression_1;
- } else {
- CharSequence _xifexpression_1 = null;
- boolean _isDataClass = this.typeHelpers.isDataClass(aType);
- if (_isDataClass) {
+ }
+ if (!_matched) {
+ if (aType instanceof DataClass) {
+ final DataClass _dataClass = (DataClass)aType;
+ _matched=true;
StringConcatenation _builder = new StringConcatenation();
{
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(((DataClass) aType));
+ List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(((DataClass) _dataClass));
for(final Attribute e : _allAttributes) {
String _plus = (invokes + ".");
String _name = a.getName();
@@ -224,11 +135,10 @@ public class ConfigGenAddon {
_builder.newLineIfNotEmpty();
}
}
- _xifexpression_1 = _builder;
+ _switchResult = _builder;
}
- _xifexpression = _xifexpression_1;
}
- _xblockexpression = (_xifexpression);
+ _xblockexpression = (_switchResult);
}
return _xblockexpression;
}
@@ -441,49 +351,54 @@ public class ConfigGenAddon {
private CharSequence genMinMaxConstantsRec(final ActorClass ac, final String varNamePath, final List<Attribute> path) {
CharSequence _xblockexpression = null;
{
- String temp = ((String) null);
Attribute _last = IterableExtensions.<Attribute>last(path);
RefableType _refType = _last.getRefType();
DataType aType = _refType.getType();
- CharSequence _xifexpression = null;
- boolean _isDataClass = this.typeHelpers.isDataClass(aType);
- if (_isDataClass) {
- StringConcatenation _builder = new StringConcatenation();
- {
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(((DataClass) aType));
- for(final Attribute e : _allAttributes) {
- String _plus = (varNamePath + "_");
- String _name = e.getName();
- String _plus_1 = (_plus + _name);
- List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
- CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _plus_1, _union);
- _builder.append(_genMinMaxConstantsRec, "");
- _builder.newLineIfNotEmpty();
+ CharSequence _switchResult = null;
+ boolean _matched = false;
+ if (!_matched) {
+ if (aType instanceof DataClass) {
+ final DataClass _dataClass = (DataClass)aType;
+ _matched=true;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(((DataClass) _dataClass));
+ for(final Attribute e : _allAttributes) {
+ String _plus = (varNamePath + "_");
+ String _name = e.getName();
+ String _plus_1 = (_plus + _name);
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
+ CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _plus_1, _union);
+ _builder.append(_genMinMaxConstantsRec, "");
+ _builder.newLineIfNotEmpty();
+ }
}
+ _switchResult = _builder;
}
- _xifexpression = _builder;
- } else {
- CharSequence _xifexpression_1 = null;
- if ((aType instanceof PrimitiveType)) {
+ }
+ if (!_matched) {
+ if (aType instanceof PrimitiveType) {
+ final PrimitiveType _primitiveType = (PrimitiveType)aType;
+ _matched=true;
CharSequence _xblockexpression_1 = null;
{
- PrimitiveType pType = ((PrimitiveType) aType);
- StringConcatenation _builder_1 = new StringConcatenation();
+ String temp = ((String) null);
+ StringConcatenation _builder = new StringConcatenation();
{
String _attrClassConfigMinValue = this.dataConfigExt.getAttrClassConfigMinValue(ac, path);
String _temp = temp = _attrClassConfigMinValue;
boolean _notEquals = (!Objects.equal(_temp, null));
if (_notEquals) {
- _builder_1.append("public static ");
- String _minMaxType = this.getMinMaxType(pType);
- _builder_1.append(_minMaxType, "");
- _builder_1.append(" MIN_");
- _builder_1.append(varNamePath, "");
- _builder_1.append(" = ");
- String _valueLiteral = this.stdExt.toValueLiteral(pType, temp);
- _builder_1.append(_valueLiteral, "");
- _builder_1.append(";");
- _builder_1.newLineIfNotEmpty();
+ _builder.append("public static ");
+ String _minMaxType = this.getMinMaxType(_primitiveType);
+ _builder.append(_minMaxType, "");
+ _builder.append(" MIN_");
+ _builder.append(varNamePath, "");
+ _builder.append(" = ");
+ String _valueLiteral = this.stdExt.toValueLiteral(_primitiveType, temp);
+ _builder.append(_valueLiteral, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
}
}
{
@@ -491,25 +406,24 @@ public class ConfigGenAddon {
String _temp_1 = temp = _attrClassConfigMaxValue;
boolean _notEquals_1 = (!Objects.equal(_temp_1, null));
if (_notEquals_1) {
- _builder_1.append("public static ");
- String _minMaxType_1 = this.getMinMaxType(pType);
- _builder_1.append(_minMaxType_1, "");
- _builder_1.append(" MAX_");
- _builder_1.append(varNamePath, "");
- _builder_1.append(" = ");
- String _valueLiteral_1 = this.stdExt.toValueLiteral(pType, temp);
- _builder_1.append(_valueLiteral_1, "");
- _builder_1.append(";");
- _builder_1.newLineIfNotEmpty();
+ _builder.append("public static ");
+ String _minMaxType_1 = this.getMinMaxType(_primitiveType);
+ _builder.append(_minMaxType_1, "");
+ _builder.append(" MAX_");
+ _builder.append(varNamePath, "");
+ _builder.append(" = ");
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(_primitiveType, temp);
+ _builder.append(_valueLiteral_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
}
}
- _xblockexpression_1 = (_builder_1);
+ _xblockexpression_1 = (_builder);
}
- _xifexpression_1 = _xblockexpression_1;
+ _switchResult = _xblockexpression_1;
}
- _xifexpression = _xifexpression_1;
}
- _xblockexpression = (_xifexpression);
+ _xblockexpression = (_switchResult);
}
return _xblockexpression;
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
index cd9a4520c..1e5c9d2b0 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
@@ -13,10 +13,10 @@ import org.eclipse.etrice.core.room.DataType;
import org.eclipse.etrice.core.room.PortClass;
import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.RefableType;
-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;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
@@ -30,7 +30,7 @@ public class Initialization {
private RoomExtensions _roomExtensions;
@Inject
- private ILanguageExtension languageExt;
+ private JavaExtensions languageExt;
@Inject
private ProcedureHelpers procedureHelpers;
@@ -79,15 +79,8 @@ public class Initialization {
_xifexpression_1 = _attributeInit;
} else {
CharSequence _xifexpression_2 = null;
- boolean _and = false;
- if (!useClassDefaultsOnly) {
- _and = false;
- } else {
- boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
- _and = (useClassDefaultsOnly && _isPrimitive);
- }
- boolean _not = (!_and);
- if (_not) {
+ boolean _needsInitialization = this.languageExt.needsInitialization(a);
+ if (_needsInitialization) {
String _nullPointer = this.languageExt.nullPointer();
CharSequence _attributeInit_1 = this.attributeInit(a, _nullPointer);
_xifexpression_2 = _attributeInit_1;
@@ -97,8 +90,8 @@ public class Initialization {
_xifexpression = _xifexpression_1;
} else {
CharSequence _xifexpression_3 = null;
- boolean _isPrimitive_1 = this.typeHelpers.isPrimitive(aType);
- if (_isPrimitive_1) {
+ boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
+ if (_isPrimitive) {
CharSequence _xblockexpression_1 = null;
{
ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
@@ -117,8 +110,15 @@ public class Initialization {
_xifexpression_4 = _attributeInit_2;
} else {
CharSequence _xifexpression_5 = null;
- boolean _not_1 = (!useClassDefaultsOnly);
- if (_not_1) {
+ boolean _or = false;
+ boolean _not = (!useClassDefaultsOnly);
+ if (_not) {
+ _or = true;
+ } else {
+ boolean _needsInitialization_1 = this.languageExt.needsInitialization(a);
+ _or = (_not || _needsInitialization_1);
+ }
+ if (_or) {
String _defaultValue = this.languageExt.defaultValue(aType);
CharSequence _attributeInit_3 = this.attributeInit(a, _defaultValue);
_xifexpression_5 = _attributeInit_3;
@@ -182,105 +182,150 @@ public class Initialization {
}
private CharSequence attributeInit(final List<Attribute> path, final String value) {
- Attribute a = IterableExtensions.<Attribute>last(path);
- RefableType _refType = a.getRefType();
- DataType aType = _refType.getType();
String _xifexpression = null;
int _size = path.size();
- boolean _greaterThan = (_size > 1);
- if (_greaterThan) {
+ boolean _equals = (_size == 1);
+ if (_equals) {
+ _xifexpression = "this";
+ } else {
int _size_1 = path.size();
int _minus = (_size_1 - 1);
Iterable<Attribute> _take = IterableExtensions.<Attribute>take(path, _minus);
CharSequence _invokeGetters = this.procedureHelpers.invokeGetters(_take, null);
- String _plus = (_invokeGetters + ".");
- _xifexpression = _plus;
- } else {
- _xifexpression = "";
+ String _string = _invokeGetters.toString();
+ _xifexpression = _string;
}
String getter = _xifexpression;
- StringConcatenation _builder = new StringConcatenation();
+ Attribute _last = IterableExtensions.<Attribute>last(path);
+ return this.genAttributeInitializer(_last, value, getter);
+ }
+
+ public CharSequence genAttributeInitializer(final Attribute a, final String value, final String invokes) {
+ CharSequence _xblockexpression = null;
{
- boolean _or = false;
- int _size_2 = a.getSize();
- boolean _equals = (_size_2 == 0);
- if (_equals) {
- _or = true;
- } else {
- boolean _isCharacterType = this.typeHelpers.isCharacterType(aType);
- _or = (_equals || _isCharacterType);
- }
- if (_or) {
- _builder.append(getter, "");
- String _name = a.getName();
- CharSequence _invokeSetter = this.procedureHelpers.invokeSetter(_name, null, value);
- _builder.append(_invokeSetter, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- String _trim = value.trim();
- boolean _startsWith = _trim.startsWith("{");
- boolean _not = (!_startsWith);
- if (_not) {
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- String _typeName = this.typeHelpers.typeName(aType);
- _builder.append(_typeName, " ");
- _builder.append("[] ");
- String _name_1 = a.getName();
- _builder.append(_name_1, " ");
- _builder.append(" = new ");
- String _typeName_1 = this.typeHelpers.typeName(aType);
- _builder.append(_typeName_1, " ");
- _builder.append("[");
- int _size_3 = a.getSize();
- _builder.append(_size_3, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (int i=0;i<");
- int _size_4 = a.getSize();
- _builder.append(_size_4, " ");
- _builder.append(";i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- String _name_2 = a.getName();
- _builder.append(_name_2, " ");
- _builder.append("[i] = ");
- _builder.append(value, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append(getter, " ");
- String _name_3 = a.getName();
- String _name_4 = a.getName();
- CharSequence _invokeSetter_1 = this.procedureHelpers.invokeSetter(_name_3, null, _name_4);
- _builder.append(_invokeSetter_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
+ RefableType _refType = a.getRefType();
+ DataType aType = _refType.getType();
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _or = false;
+ int _size = a.getSize();
+ boolean _equals = (_size == 0);
+ if (_equals) {
+ _or = true;
} else {
- _builder.append(getter, "");
- String _name_5 = a.getName();
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append("new ");
- String _typeName_2 = this.typeHelpers.typeName(aType);
- _builder_1.append(_typeName_2, "");
- _builder_1.append("[] ");
- _builder_1.append(value, "");
- CharSequence _invokeSetter_2 = this.procedureHelpers.invokeSetter(_name_5, null, _builder_1.toString());
- _builder.append(_invokeSetter_2, "");
+ boolean _and = false;
+ boolean _and_1 = false;
+ int _size_1 = a.getSize();
+ boolean _greaterThan = (_size_1 > 0);
+ if (!_greaterThan) {
+ _and_1 = false;
+ } else {
+ String _typeName = this.typeHelpers.typeName(aType);
+ boolean _equals_1 = "char".equals(_typeName);
+ _and_1 = (_greaterThan && _equals_1);
+ }
+ if (!_and_1) {
+ _and = false;
+ } else {
+ boolean _matches = value.matches("\'.\'|\\(char\\).*");
+ boolean _not = (!_matches);
+ _and = (_and_1 && _not);
+ }
+ _or = (_equals || _and);
+ }
+ if (_or) {
+ _builder.append(invokes, "");
+ _builder.append(".");
+ String _name = a.getName();
+ CharSequence _invokeSetter = this.procedureHelpers.invokeSetter(_name, null, value);
+ _builder.append(_invokeSetter, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
+ } else {
+ boolean _or_1 = false;
+ String _trim = value.trim();
+ boolean _startsWith = _trim.startsWith("{");
+ boolean _not_1 = (!_startsWith);
+ if (_not_1) {
+ _or_1 = true;
+ } else {
+ String _typeName_1 = this.typeHelpers.typeName(aType);
+ boolean _equals_2 = "char".equals(_typeName_1);
+ _or_1 = (_not_1 || _equals_2);
+ }
+ if (_or_1) {
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ String _typeName_2 = this.typeHelpers.typeName(aType);
+ _builder.append(_typeName_2, " ");
+ _builder.append("[] array = new ");
+ String _typeName_3 = this.typeHelpers.typeName(aType);
+ _builder.append(_typeName_3, " ");
+ _builder.append("[");
+ int _size_2 = a.getSize();
+ _builder.append(_size_2, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _and_2 = false;
+ RefableType _refType_1 = a.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (!_isRef) {
+ _and_2 = false;
+ } else {
+ boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
+ _and_2 = (_isRef && _isPrimitive);
+ }
+ boolean _not_2 = (!_and_2);
+ if (_not_2) {
+ _builder.append("\t");
+ _builder.append("for (int i=0;i<");
+ int _size_3 = a.getSize();
+ _builder.append(_size_3, " ");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("array[i] = ");
+ _builder.append(value, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append(invokes, " ");
+ _builder.append(".");
+ String _name_1 = a.getName();
+ CharSequence _invokeSetter_1 = this.procedureHelpers.invokeSetter(_name_1, null, "array");
+ _builder.append(_invokeSetter_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append(invokes, "");
+ _builder.append(".");
+ String _name_2 = a.getName();
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("new ");
+ String _typeName_4 = this.typeHelpers.typeName(aType);
+ _builder_1.append(_typeName_4, "");
+ _builder_1.append("[] ");
+ _builder_1.append(value, "");
+ CharSequence _invokeSetter_2 = this.procedureHelpers.invokeSetter(_name_2, null, _builder_1.toString());
+ _builder.append(_invokeSetter_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
}
}
+ _xblockexpression = (_builder);
}
- return _builder;
+ return _xblockexpression;
}
private String getDataConfigValue(final List<Attribute> path, final EObject roomClass) {
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 500a6b14d..0b820434e 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
@@ -4,6 +4,7 @@ import com.google.common.base.Objects;
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.DataType;
import org.eclipse.etrice.core.room.ExternalType;
import org.eclipse.etrice.core.room.Message;
@@ -60,6 +61,32 @@ public class JavaExtensions implements ILanguageExtension {
return _switchResult;
}
+ public boolean needsInitialization(final Attribute a) {
+ boolean _or = false;
+ boolean _or_1 = false;
+ int _size = a.getSize();
+ boolean _greaterThan = (_size > 0);
+ if (_greaterThan) {
+ _or_1 = true;
+ } else {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this.typeHelpers.isPrimitive(_type);
+ boolean _not = (!_isPrimitive);
+ _or_1 = (_greaterThan || _not);
+ }
+ if (_or_1) {
+ _or = true;
+ } else {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName = this.typeHelpers.typeName(_type_1);
+ boolean _equals = _typeName==null?false:_typeName.equals("String");
+ _or = (_or_1 || _equals);
+ }
+ return _or;
+ }
+
public String accessLevelPrivate() {
return "private ";
}
@@ -174,22 +201,16 @@ public class JavaExtensions implements ILanguageExtension {
final String _switchValue = _targetName;
boolean _matched = false;
if (!_matched) {
- if (Objects.equal(_switchValue,"char")) {
- _matched=true;
- String _castValue = this.castValue(type, value);
- _switchResult = _castValue;
- }
- }
- if (!_matched) {
- if (Objects.equal(_switchValue,"string")) {
- _matched=true;
- String _castValue_1 = this.castValue(type, value);
- _switchResult = _castValue_1;
+ boolean _and = false;
+ boolean _isCharacterType = this.typeHelpers.isCharacterType(type);
+ boolean _not = (!_isCharacterType);
+ if (!_not) {
+ _and = false;
+ } else {
+ boolean _contains = value.contains(",");
+ _and = (_not && _contains);
}
- }
- if (!_matched) {
- boolean _contains = value.contains(",");
- if (_contains) {
+ if (_and) {
_matched=true;
String _xblockexpression = null;
{
@@ -208,8 +229,8 @@ public class JavaExtensions implements ILanguageExtension {
_builder.appendImmediate(", ", "");
}
String _trim_1 = v.trim();
- String _castValue_2 = this.castValue(type, _trim_1);
- _builder.append(_castValue_2, "");
+ String _castValue = this.castValue(type, _trim_1);
+ _builder.append(_castValue, "");
}
}
_builder.append(" }");
@@ -220,72 +241,91 @@ public class JavaExtensions implements ILanguageExtension {
}
}
if (!_matched) {
- String _castValue_2 = this.castValue(type, value);
- _switchResult = _castValue_2;
+ String _castValue = this.castValue(type, value);
+ _switchResult = _castValue;
}
return _switchResult;
}
private String castValue(final PrimitiveType type, final String value) {
+ String _switchResult = null;
String _targetName = type.getTargetName();
final String _switchValue = _targetName;
boolean _matched = false;
if (!_matched) {
if (Objects.equal(_switchValue,"boolean")) {
_matched=true;
- return value.toLowerCase();
+ String _lowerCase = value.toLowerCase();
+ _switchResult = _lowerCase;
}
}
if (!_matched) {
if (Objects.equal(_switchValue,"byte")) {
_matched=true;
- return ("(byte)" + value);
+ String _plus = ("(byte)" + value);
+ _switchResult = _plus;
}
}
if (!_matched) {
if (Objects.equal(_switchValue,"short")) {
_matched=true;
- return ("(short)" + value);
+ String _plus_1 = ("(short)" + value);
+ _switchResult = _plus_1;
}
}
if (!_matched) {
if (Objects.equal(_switchValue,"int")) {
_matched=true;
- return value;
+ _switchResult = value;
}
}
if (!_matched) {
if (Objects.equal(_switchValue,"long")) {
_matched=true;
- return (value + "L");
+ String _plus_2 = (value + "L");
+ _switchResult = _plus_2;
}
}
if (!_matched) {
if (Objects.equal(_switchValue,"float")) {
_matched=true;
- return (value + "f");
+ String _plus_3 = (value + "f");
+ _switchResult = _plus_3;
}
}
if (!_matched) {
if (Objects.equal(_switchValue,"double")) {
_matched=true;
- return (value + "d");
+ String _plus_4 = (value + "d");
+ _switchResult = _plus_4;
}
}
if (!_matched) {
if (Objects.equal(_switchValue,"char")) {
_matched=true;
- int _length = value.length();
- boolean _equals = (_length == 1);
- if (_equals) {
- String _plus = ("\'" + value);
- return (_plus + "\'");
+ String _xifexpression = null;
+ boolean _isEmpty = value.isEmpty();
+ if (_isEmpty) {
+ _xifexpression = "(char) 0";
} else {
- String _replace = value.replace("\\", "\\\\");
- String _replace_1 = _replace.replace("\"", "\\\"");
- String _plus_1 = ("\"" + _replace_1);
- return (_plus_1 + "\".toCharArray()");
+ String _xifexpression_1 = null;
+ int _length = value.length();
+ boolean _equals = (_length == 1);
+ if (_equals) {
+ char _charAt = value.charAt(0);
+ String _plus_5 = ("\'" + Character.valueOf(_charAt));
+ String _plus_6 = (_plus_5 + "\'");
+ _xifexpression_1 = _plus_6;
+ } else {
+ String _replace = value.replace("\\", "\\\\");
+ String _replace_1 = _replace.replace("\"", "\\\"");
+ String _plus_7 = ("\"" + _replace_1);
+ String _plus_8 = (_plus_7 + "\".toCharArray()");
+ _xifexpression_1 = _plus_8;
+ }
+ _xifexpression = _xifexpression_1;
}
+ _switchResult = _xifexpression;
}
}
if (!_matched) {
@@ -293,31 +333,48 @@ public class JavaExtensions implements ILanguageExtension {
_matched=true;
String _replace_2 = value.replace("\\", "\\\\");
String _replace_3 = _replace_2.replace("\"", "\\\"");
- String _plus_2 = ("\"" + _replace_3);
- return (_plus_2 + "\"");
+ String _plus_9 = ("\"" + _replace_3);
+ String _plus_10 = (_plus_9 + "\"");
+ _switchResult = _plus_10;
}
}
- String _targetName_1 = type.getTargetName();
- UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException(_targetName_1);
- throw _unsupportedOperationException;
+ if (!_matched) {
+ String _targetName_1 = type.getTargetName();
+ UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException(_targetName_1);
+ throw _unsupportedOperationException;
+ }
+ return _switchResult;
}
public String defaultValue(final DataType dt) {
- if ((dt instanceof PrimitiveType)) {
- PrimitiveType pType = ((PrimitiveType) dt);
- String _defaultValueLiteral = pType.getDefaultValueLiteral();
- return this.toValueLiteral(pType, _defaultValueLiteral);
- } else {
- if ((dt instanceof ExternalType)) {
- String _targetName = ((ExternalType) dt).getTargetName();
+ String _switchResult = null;
+ boolean _matched = false;
+ if (!_matched) {
+ if (dt instanceof PrimitiveType) {
+ final PrimitiveType _primitiveType = (PrimitiveType)dt;
+ _matched=true;
+ String _defaultValueLiteral = _primitiveType.getDefaultValueLiteral();
+ String _valueLiteral = this.toValueLiteral(_primitiveType, _defaultValueLiteral);
+ _switchResult = _valueLiteral;
+ }
+ }
+ if (!_matched) {
+ if (dt instanceof ExternalType) {
+ final ExternalType _externalType = (ExternalType)dt;
+ _matched=true;
+ String _targetName = ((ExternalType) _externalType).getTargetName();
String _plus = ("new " + _targetName);
- return (_plus + "()");
- } else {
- String _name = dt.getName();
- String _plus_1 = ("new " + _name);
- return (_plus_1 + "()");
+ String _plus_1 = (_plus + "()");
+ _switchResult = _plus_1;
}
}
+ if (!_matched) {
+ String _name = dt.getName();
+ String _plus = ("new " + _name);
+ String _plus_1 = (_plus + "()");
+ _switchResult = _plus_1;
+ }
+ return _switchResult;
}
public String initializationWithDefaultValues(final DataType dt, final int size) {
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
index 2e6666ded..237b9c335 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
@@ -71,8 +71,7 @@ public class SubSystemClassGen {
this.fileAccess.setOutputPath(path);
CharSequence _generate = this.generate(root, ssi);
this.fileAccess.generateFile(file, _generate);
- SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
- boolean _hasVariableService = this.dataConfigExt.hasVariableService(_subSystemClass_3);
+ boolean _hasVariableService = this.dataConfigExt.hasVariableService(ssi);
if (_hasVariableService) {
this.varService.doGenerate(root, ssi);
}
@@ -92,7 +91,7 @@ public class SubSystemClassGen {
_builder.newLineIfNotEmpty();
_builder.newLine();
{
- boolean _hasVariableService = this.dataConfigExt.hasVariableService(cc);
+ boolean _hasVariableService = this.dataConfigExt.hasVariableService(comp);
if (_hasVariableService) {
_builder.append("import org.eclipse.etrice.runtime.java.config.VariableService;");
}
@@ -135,6 +134,25 @@ public class SubSystemClassGen {
_builder.append(_name_1, "");
_builder.append(" extends SubSystemClassBase {");
_builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("public final int THREAD__DEFAULT = 0;");
+ _builder.newLine();
+ {
+ EList<LogicalThread> _threads = cc.getThreads();
+ Iterable<Indexed<LogicalThread>> _indexed = Indexed.<LogicalThread>indexed(_threads);
+ for(final Indexed<LogicalThread> thread : _indexed) {
+ _builder.append("\t");
+ _builder.append("public final int ");
+ LogicalThread _value = thread.getValue();
+ String _threadId = this.getThreadId(_value);
+ _builder.append(_threadId, " ");
+ _builder.append(" = ");
+ int _index1 = thread.getIndex1();
+ _builder.append(_index1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.newLine();
_builder.append("\t");
CharSequence _userCode_1 = this._procedureHelpers.userCode(cc, 2);
@@ -176,19 +194,17 @@ public class SubSystemClassGen {
_builder.append("\t");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),\"MessageService_Main\"));");
+ _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(THREAD__DEFAULT, 0, 0),\"MessageService_Main\"));");
_builder.newLine();
{
- EList<LogicalThread> _threads = cc.getThreads();
- for(final LogicalThread thread : _threads) {
+ EList<LogicalThread> _threads_1 = cc.getThreads();
+ for(final LogicalThread thread_1 : _threads_1) {
_builder.append("\t\t");
_builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, ");
- EList<LogicalThread> _threads_1 = cc.getThreads();
- int _indexOf = _threads_1.indexOf(thread);
- int _plus = (_indexOf + 1);
- _builder.append(_plus, " ");
+ String _threadId_1 = this.getThreadId(thread_1);
+ _builder.append(_threadId_1, " ");
_builder.append(", 0),\"MessageService_");
- String _name_3 = thread.getName();
+ String _name_3 = thread_1.getName();
_builder.append(_name_3, " ");
_builder.append("\" /*, thread_prio */));");
_builder.newLineIfNotEmpty();
@@ -214,19 +230,13 @@ public class SubSystemClassGen {
_builder.newLine();
{
EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
- int _maxObjId = comp.getMaxObjId();
- Iterable<Indexed<ActorInstance>> _indexed = Indexed.<ActorInstance>indexed(_allContainedInstances, _maxObjId);
- for(final Indexed<ActorInstance> ai : _indexed) {
+ for(final ActorInstance ai : _allContainedInstances) {
_builder.append("\t\t");
_builder.append("Address addr_item_SystemPort_");
EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances();
- ActorInstance _value = ai.getValue();
- int _indexOf_1 = _allContainedInstances_1.indexOf(_value);
- _builder.append(_indexOf_1, " ");
- _builder.append(" = new Address(0,0,");
- int _index1 = ai.getIndex1();
- _builder.append(_index1, " ");
- _builder.append(");");
+ int _indexOf = _allContainedInstances_1.indexOf(ai);
+ _builder.append(_indexOf, " ");
+ _builder.append(" = getFreeAddress(THREAD__DEFAULT);");
_builder.newLineIfNotEmpty();
}
}
@@ -236,6 +246,22 @@ public class SubSystemClassGen {
EList<ActorInstance> _allContainedInstances_2 = comp.getAllContainedInstances();
for(final ActorInstance ai_1 : _allContainedInstances_2) {
_builder.append("\t\t");
+ String _xifexpression = null;
+ int _threadId_2 = ai_1.getThreadId();
+ boolean _equals = (_threadId_2 == 0);
+ if (_equals) {
+ _xifexpression = "THREAD__DEFAULT";
+ } else {
+ EList<LogicalThread> _threads_2 = cc.getThreads();
+ int _threadId_3 = ai_1.getThreadId();
+ int _minus = (_threadId_3 - 1);
+ LogicalThread _get = _threads_2.get(_minus);
+ String _threadId_4 = this.getThreadId(_get);
+ _xifexpression = _threadId_4;
+ }
+ final String threadId = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
_builder.append("// actor instance ");
String _path = ai_1.getPath();
_builder.append(_path, " ");
@@ -246,12 +272,8 @@ public class SubSystemClassGen {
String _path_1 = ai_1.getPath();
String _pathName = this._roomExtensions.getPathName(_path_1);
_builder.append(_pathName, " ");
- _builder.append(" = new Address(0,");
- int _threadId = ai_1.getThreadId();
- _builder.append(_threadId, " ");
- _builder.append(",");
- int _objId = ai_1.getObjId();
- _builder.append(_objId, " ");
+ _builder.append(" = getFreeAddress(");
+ _builder.append(threadId, " ");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
@@ -279,13 +301,8 @@ public class SubSystemClassGen {
_builder.append(_pathName_1, " ");
_builder.append("_");
_builder.append(i, " ");
- _builder.append(" = new Address(0,");
- int _threadId_1 = ai_1.getThreadId();
- _builder.append(_threadId_1, " ");
- _builder.append(",");
- int _objId_1 = pi.getObjId();
- int _plus_1 = (_objId_1 + i);
- _builder.append(_plus_1, " ");
+ _builder.append(" = getFreeAddress(");
+ _builder.append(threadId, " ");
_builder.append(");");
_builder.newLineIfNotEmpty();
}
@@ -296,12 +313,8 @@ public class SubSystemClassGen {
String _path_4 = pi.getPath();
String _pathName_2 = this._roomExtensions.getPathName(_path_4);
_builder.append(_pathName_2, " ");
- _builder.append(" = new Address(0,");
- int _threadId_2 = ai_1.getThreadId();
- _builder.append(_threadId_2, " ");
- _builder.append(",");
- int _objId_2 = pi.getObjId();
- _builder.append(_objId_2, " ");
+ _builder.append(" = getFreeAddress(");
+ _builder.append(threadId, " ");
_builder.append(");");
_builder.newLineIfNotEmpty();
}
@@ -327,8 +340,8 @@ public class SubSystemClassGen {
_builder.append("\t\t");
_builder.append("instances[");
EList<ActorInstance> _allContainedInstances_5 = comp.getAllContainedInstances();
- int _indexOf_2 = _allContainedInstances_5.indexOf(ai_2);
- _builder.append(_indexOf_2, " ");
+ int _indexOf_1 = _allContainedInstances_5.indexOf(ai_2);
+ _builder.append(_indexOf_1, " ");
_builder.append("] = new ");
ActorClass _actorClass = ai_2.getActorClass();
String _name_4 = _actorClass.getName();
@@ -348,8 +361,8 @@ public class SubSystemClassGen {
_builder.append("instances[");
EList<ActorInstance> _allContainedInstances_6 = comp.getAllContainedInstances();
EObject _eContainer_1 = ai_2.eContainer();
- int _indexOf_3 = _allContainedInstances_6.indexOf(_eContainer_1);
- _builder.append(_indexOf_3, " ");
+ int _indexOf_2 = _allContainedInstances_6.indexOf(_eContainer_1);
+ _builder.append(_indexOf_2, " ");
_builder.append("],");
_builder.newLineIfNotEmpty();
}
@@ -424,8 +437,8 @@ public class SubSystemClassGen {
_builder.append(_pathName_4, " ");
_builder.append("_");
EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
- int _indexOf_4 = _peers_4.indexOf(peer_1);
- _builder.append(_indexOf_4, " ");
+ int _indexOf_3 = _peers_4.indexOf(peer_1);
+ _builder.append(_indexOf_3, " ");
_builder.newLineIfNotEmpty();
}
}
@@ -468,8 +481,8 @@ public class SubSystemClassGen {
_builder.append("\t");
_builder.append("new Address[][] {{addr_item_SystemPort_");
EList<ActorInstance> _allContainedInstances_7 = comp.getAllContainedInstances();
- int _indexOf_5 = _allContainedInstances_7.indexOf(ai_2);
- _builder.append(_indexOf_5, " ");
+ int _indexOf_4 = _allContainedInstances_7.indexOf(ai_2);
+ _builder.append(_indexOf_4, " ");
_builder.append("}");
{
EList<InterfaceItemInstance> _orderedIfItemInstances_3 = ai_2.getOrderedIfItemInstances();
@@ -540,8 +553,8 @@ public class SubSystemClassGen {
_builder.append(_pathName_6, " ");
_builder.append("_");
EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
- int _indexOf_6 = _peers_8.indexOf(pi_2);
- _builder.append(_indexOf_6, " ");
+ int _indexOf_5 = _peers_8.indexOf(pi_2);
+ _builder.append(_indexOf_5, " ");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t\t");
@@ -571,10 +584,17 @@ public class SubSystemClassGen {
_builder.append("}");
_builder.newLine();
{
- String _path_10 = ai_2.getPath();
- List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(_path_10);
- boolean _isEmpty_5 = _dynConfigWriteAttributes.isEmpty();
- boolean _not_2 = (!_isEmpty_5);
+ boolean _and_1 = false;
+ List<Attribute> _dynConfigReadAttributes = this.dataConfigExt.getDynConfigReadAttributes(ai_2);
+ boolean _isEmpty_5 = _dynConfigReadAttributes.isEmpty();
+ if (!_isEmpty_5) {
+ _and_1 = false;
+ } else {
+ List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(ai_2);
+ boolean _isEmpty_6 = _dynConfigWriteAttributes.isEmpty();
+ _and_1 = (_isEmpty_5 && _isEmpty_6);
+ }
+ boolean _not_2 = (!_and_1);
if (_not_2) {
_builder.append("\t\t");
_builder.append("\t");
@@ -616,8 +636,8 @@ public class SubSystemClassGen {
_builder.append(_name_7, " ");
_builder.append(") instances[");
EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
- int _indexOf_7 = _allContainedInstances_9.indexOf(ai_3);
- _builder.append(_indexOf_7, " ");
+ int _indexOf_6 = _allContainedInstances_9.indexOf(ai_3);
+ _builder.append(_indexOf_6, " ");
_builder.append("];");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
@@ -659,8 +679,8 @@ public class SubSystemClassGen {
_builder.append("\t\t\t\t\t");
_builder.append("addr_item_SystemPort_");
EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
- int _indexOf_8 = _allContainedInstances_11.indexOf(ai_4);
- _builder.append(_indexOf_8, " ");
+ int _indexOf_7 = _allContainedInstances_11.indexOf(ai_4);
+ _builder.append(_indexOf_7, " ");
_builder.newLineIfNotEmpty();
}
}
@@ -684,8 +704,8 @@ public class SubSystemClassGen {
}
_builder.append("\t\t\t\t\t");
_builder.append("addr_item_");
- String _path_11 = ai_5.getPath();
- String _pathName_8 = this._roomExtensions.getPathName(_path_11);
+ String _path_10 = ai_5.getPath();
+ String _pathName_8 = this._roomExtensions.getPathName(_path_10);
_builder.append(_pathName_8, " ");
_builder.newLineIfNotEmpty();
}
@@ -699,7 +719,7 @@ public class SubSystemClassGen {
_builder.append("\t");
_builder.newLine();
{
- boolean _hasVariableService_1 = this.dataConfigExt.hasVariableService(cc);
+ boolean _hasVariableService_1 = this.dataConfigExt.hasVariableService(comp);
if (_hasVariableService_1) {
_builder.append("\t\t");
_builder.append("private VariableService variableService;");
@@ -715,7 +735,7 @@ public class SubSystemClassGen {
_builder.append("public void init(){");
_builder.newLine();
{
- boolean _hasVariableService_2 = this.dataConfigExt.hasVariableService(cc);
+ boolean _hasVariableService_2 = this.dataConfigExt.hasVariableService(comp);
if (_hasVariableService_2) {
_builder.append("\t\t\t");
_builder.append("variableService = new ");
@@ -729,7 +749,7 @@ public class SubSystemClassGen {
_builder.append("super.init();");
_builder.newLine();
{
- boolean _hasVariableService_3 = this.dataConfigExt.hasVariableService(cc);
+ boolean _hasVariableService_3 = this.dataConfigExt.hasVariableService(comp);
if (_hasVariableService_3) {
_builder.append("\t\t\t");
_builder.append("variableService.init();");
@@ -751,7 +771,7 @@ public class SubSystemClassGen {
_builder.append("super.stop();");
_builder.newLine();
{
- boolean _hasVariableService_4 = this.dataConfigExt.hasVariableService(cc);
+ boolean _hasVariableService_4 = this.dataConfigExt.hasVariableService(comp);
if (_hasVariableService_4) {
_builder.append("\t\t\t");
_builder.append("variableService.stop();");
@@ -769,4 +789,11 @@ public class SubSystemClassGen {
}
return _xblockexpression;
}
+
+ private String getThreadId(final LogicalThread thread) {
+ String _name = thread.getName();
+ String _upperCase = _name.toUpperCase();
+ String _plus = ("THREAD_" + _upperCase);
+ return _plus;
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
index 9c4c6e936..318db8f07 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
@@ -3,8 +3,10 @@ package org.eclipse.etrice.generator.java.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.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.SystemInstance;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
@@ -107,8 +109,8 @@ public class SubSystemRunnerGen {
String _name_4 = cc.getName();
_builder.append(_name_4, " ");
_builder.append("(\"");
- String _name_5 = ssc.getName();
- _builder.append(_name_5, " ");
+ String _runtimeName = this.getRuntimeName(ssc);
+ _builder.append(_runtimeName, " ");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
@@ -125,4 +127,30 @@ public class SubSystemRunnerGen {
}
return _xblockexpression;
}
+
+ private String getRuntimeName(final SubSystemInstance ssc) {
+ String _xblockexpression = null;
+ {
+ EObject parent = ssc.eContainer();
+ String _switchResult = null;
+ boolean _matched = false;
+ if (!_matched) {
+ if (parent instanceof SystemInstance) {
+ final SystemInstance _systemInstance = (SystemInstance)parent;
+ _matched=true;
+ String _name = _systemInstance.getName();
+ String _plus = (_name + "/");
+ String _name_1 = ssc.getName();
+ String _plus_1 = (_plus + _name_1);
+ _switchResult = _plus_1;
+ }
+ }
+ if (!_matched) {
+ String _name = ssc.getName();
+ _switchResult = _name;
+ }
+ _xblockexpression = (_switchResult);
+ }
+ return _xblockexpression;
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
index e90dfdb89..46e68228b 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
@@ -82,19 +82,17 @@ public class VariableServiceGen {
private CharSequence generate(final Root root, final SubSystemInstance comp) {
CharSequence _xblockexpression = null;
{
- final SubSystemClass cc = comp.getSubSystemClass();
+ SubSystemClass cc = comp.getSubSystemClass();
HashMap<ActorInstance,List<Attribute>> _hashMap = new HashMap<ActorInstance,List<Attribute>>();
final HashMap<ActorInstance,List<Attribute>> aisAttrMap = _hashMap;
EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
final Procedure1<ActorInstance> _function = new Procedure1<ActorInstance>() {
public void apply(final ActorInstance ai) {
- String _path = ai.getPath();
- List<Attribute> _dynConfigReadAttributes = VariableServiceGen.this.configExt.getDynConfigReadAttributes(_path);
+ List<Attribute> _dynConfigReadAttributes = VariableServiceGen.this.configExt.getDynConfigReadAttributes(ai);
boolean _isEmpty = _dynConfigReadAttributes.isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
- String _path_1 = ai.getPath();
- List<Attribute> _dynConfigReadAttributes_1 = VariableServiceGen.this.configExt.getDynConfigReadAttributes(_path_1);
+ List<Attribute> _dynConfigReadAttributes_1 = VariableServiceGen.this.configExt.getDynConfigReadAttributes(ai);
aisAttrMap.put(ai, _dynConfigReadAttributes_1);
}
}
@@ -103,7 +101,8 @@ public class VariableServiceGen {
StringConcatenation _builder = new StringConcatenation();
_builder.newLine();
_builder.append("package ");
- String _package = this.roomExt.getPackage(cc);
+ SubSystemClass _subSystemClass = comp.getSubSystemClass();
+ String _package = this.roomExt.getPackage(_subSystemClass);
_builder.append(_package, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
@@ -116,7 +115,7 @@ public class VariableServiceGen {
_builder.newLine();
_builder.append("import org.eclipse.etrice.runtime.java.config.VariableService;");
_builder.newLine();
- String _userCode1 = this.configExt.getUserCode1(cc);
+ String _userCode1 = this.configExt.getUserCode1(comp);
_builder.append(_userCode1, "");
_builder.newLineIfNotEmpty();
{
@@ -142,7 +141,8 @@ public class VariableServiceGen {
_builder.newLine();
_builder.append("\t");
_builder.append("private ");
- String _name_2 = cc.getName();
+ SubSystemClass _subSystemClass_1 = comp.getSubSystemClass();
+ String _name_2 = _subSystemClass_1.getName();
_builder.append(_name_2, " ");
_builder.append(" subSystem;");
_builder.newLineIfNotEmpty();
@@ -180,7 +180,7 @@ public class VariableServiceGen {
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("super(");
- String _userCode2 = this.configExt.getUserCode2(cc);
+ String _userCode2 = this.configExt.getUserCode2(comp);
_builder.append(_userCode2, " ");
_builder.append(");");
_builder.newLineIfNotEmpty();
@@ -463,7 +463,7 @@ public class VariableServiceGen {
_builder.newLine();
_builder.append("\t\t");
_builder.append("return ");
- int _pollingTimerUser = this.configExt.getPollingTimerUser(cc);
+ int _pollingTimerUser = this.configExt.getPollingTimerUser(comp);
_builder.append(_pollingTimerUser, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
@@ -482,6 +482,7 @@ public class VariableServiceGen {
private CharSequence genMinMaxCheck(final List<Attribute> path, final ActorClass ac) {
CharSequence _xblockexpression = null;
{
+ Attribute a = IterableExtensions.<Attribute>last(path);
String aVarName = this.toAbsolutePath(path, "_");
String _attrClassConfigMinValue = this.configExt.getAttrClassConfigMinValue(ac, path);
boolean min = (!Objects.equal(_attrClassConfigMinValue, null));
@@ -496,8 +497,32 @@ public class VariableServiceGen {
}
if (_or) {
StringConcatenation _builder = new StringConcatenation();
+ {
+ int _size = a.getSize();
+ boolean _greaterThan = (_size > 0);
+ if (_greaterThan) {
+ _builder.append("for(");
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ _builder.append(" e : ");
+ _builder.append(aVarName, "");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ }
+ }
_builder.append("checkMinMax(");
- _builder.append(aVarName, "");
+ {
+ int _size_1 = a.getSize();
+ boolean _greaterThan_1 = (_size_1 > 0);
+ if (_greaterThan_1) {
+ _builder.append("e");
+ } else {
+ _builder.append(aVarName, "");
+ }
+ }
_builder.append(", ");
{
if (min) {
@@ -523,9 +548,6 @@ public class VariableServiceGen {
_builder.append(");");
_builder.newLineIfNotEmpty();
_xifexpression = _builder;
- } else {
- StringConcatenation _builder_1 = new StringConcatenation();
- _xifexpression = _builder_1;
}
_xblockexpression = (_xifexpression);
}
@@ -537,8 +559,7 @@ public class VariableServiceGen {
final HashSet<DataClass> result = _hashSet;
final Procedure1<ActorInstance> _function = new Procedure1<ActorInstance>() {
public void apply(final ActorInstance ai) {
- String _path = ai.getPath();
- List<Attribute> _dynConfigReadAttributes = VariableServiceGen.this.configExt.getDynConfigReadAttributes(_path);
+ List<Attribute> _dynConfigReadAttributes = VariableServiceGen.this.configExt.getDynConfigReadAttributes(ai);
final Procedure1<Attribute> _function = new Procedure1<Attribute>() {
public void apply(final Attribute a) {
RefableType _refType = a.getRefType();

Back to the top