Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-10-29 07:38:43 -0400
committerJuergen Haug2012-10-29 07:38:43 -0400
commit3b04960843e75bcdb210663541a6117d83727f51 (patch)
treecbe60410875a30e742fe59ad2639a287535c5ae3 /plugins/org.eclipse.etrice.core.config
parent0f9be31bd213f7bb86b1e7359967997efd8f73e4 (diff)
downloadorg.eclipse.etrice-3b04960843e75bcdb210663541a6117d83727f51.tar.gz
org.eclipse.etrice-3b04960843e75bcdb210663541a6117d83727f51.tar.xz
org.eclipse.etrice-3b04960843e75bcdb210663541a6117d83727f51.zip
[CQ 6485][config, generator] refactor: draft IDataConfiguration, static
Diffstat (limited to 'plugins/org.eclipse.etrice.core.config')
-rw-r--r--plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF12
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java151
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java2
3 files changed, 159 insertions, 6 deletions
diff --git a/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
index 2044adef0..fe79b8a8f 100644
--- a/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
@@ -19,11 +19,13 @@ Require-Bundle: org.eclipse.xtext;bundle-version="2.1.1";visibility:=reexport,
org.eclipse.emf.common,
org.antlr.runtime,
org.eclipse.xtext.common.types;bundle-version="2.1.1",
- org.eclipse.etrice.core.room;bundle-version="0.2.0"
-Import-Package: org.apache.log4j,
- org.apache.commons.logging,
- org.eclipse.xtext.xbase.lib,
- org.eclipse.xtend.lib
+ org.eclipse.etrice.core.room;bundle-version="0.2.0",
+ org.eclipse.etrice.core.genmodel;bundle-version="0.2.0"
+Import-Package: org.apache.commons.logging,
+ org.apache.log4j,
+ org.eclipse.etrice.generator.base,
+ org.eclipse.xtend.lib,
+ org.eclipse.xtext.xbase.lib
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.etrice.core,
org.eclipse.etrice.core.services,
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
new file mode 100644
index 000000000..79a74fedf
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * 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.core.config;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.etrice.core.config.ActorClassConfig;
+import org.eclipse.etrice.core.config.ActorInstanceConfig;
+import org.eclipse.etrice.core.config.AttrInstanceConfig;
+import org.eclipse.etrice.core.config.ConfigModel;
+import org.eclipse.etrice.core.config.ProtocolClassConfig;
+import org.eclipse.etrice.core.config.SubSystemConfig;
+import org.eclipse.etrice.core.config.util.ConfigUtil;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.SubSystemClass;
+
+public class DataConfigurationHelper {
+
+ public static Map<ActorClass, ActorClassConfig> ac2acConfMap = new HashMap<ActorClass, ActorClassConfig>();
+ public static Map<PortClass, PortClassConfig> pc2pcConfMap = new HashMap<PortClass, PortClassConfig>();
+ public static Map<String, ActorInstanceConfig> path2aiConfMap = new HashMap<String, ActorInstanceConfig>();
+ public static Map<SubSystemClass, SubSystemConfig> ssc2ssConfMap = new HashMap<SubSystemClass, SubSystemConfig>();
+ public static Map<SubSystemClass, List<AttrInstanceConfig>> ssc2attrInstConfMap = new HashMap<SubSystemClass, List<AttrInstanceConfig>>();
+ public static Map<ActorClass, List<ActorInstanceConfig>> ac2aiConfMap = new HashMap<ActorClass, List<ActorInstanceConfig>>();
+ public static Map<ActorInstanceConfig, ActorClass> aiConf2acMap = new HashMap<ActorInstanceConfig, ActorClass>();
+
+ public static boolean setConfigModels(ResourceSet rs, ILogger logger) {
+ ac2acConfMap.clear();
+ pc2pcConfMap.clear();
+ path2aiConfMap.clear();
+ ssc2ssConfMap.clear();
+ ssc2attrInstConfMap.clear();
+ ac2aiConfMap.clear();
+ aiConf2acMap.clear();
+ boolean error = false;
+
+ List<ConfigModel> configs = new ArrayList<ConfigModel>();
+ for (Resource res : rs.getResources()) {
+ EObject object = res.getContents().get(0);
+ if (object instanceof ConfigModel)
+ configs.add((ConfigModel) object);
+ }
+
+ if (!configs.isEmpty())
+ logger.logInfo("-- loading configurations");
+
+ Set<ActorClass> actorClasses = new HashSet<ActorClass>();
+ Set<ProtocolClass> protocolClasses = new HashSet<ProtocolClass>();
+ for (ConfigModel config : configs) {
+ for (ActorClassConfig classConfig : config.getActorClassConfigs()) {
+ if (actorClasses.contains(classConfig.getActor())) {
+ logger.logError("Multiple configurations for actor class "
+ + classConfig.getActor().getName() + " found", null);
+ error = true;
+ } else {
+ actorClasses.add(classConfig.getActor());
+ ac2acConfMap.put(classConfig.getActor(), classConfig);
+ }
+ }
+ for (ProtocolClassConfig protocolConfig : config
+ .getProtocolClassConfigs()) {
+ if (protocolClasses.contains(protocolConfig.getProtocol())) {
+ logger.logError(
+ "Multiple configurations for protocol class "
+ + protocolConfig.getProtocol().getName()
+ + " found", null);
+ error = true;
+ } else {
+ protocolClasses.add(protocolConfig.getProtocol());
+ pc2pcConfMap.put(protocolConfig.getProtocol().getRegular(),
+ protocolConfig.getRegular());
+ pc2pcConfMap.put(protocolConfig.getProtocol()
+ .getConjugate(), protocolConfig.getConjugated());
+ }
+ }
+ for (ActorInstanceConfig instanceConfig : config
+ .getActorInstanceConfigs()) {
+ String path = "/" + instanceConfig.getRoot().getName()
+ + toPath(instanceConfig.getPath().getRefs(), "/");
+ if (path2aiConfMap.containsKey(path)) {
+ logger.logError(
+ "Multiple configurations for actor instance "
+ + path + " found", null);
+ } else
+ path2aiConfMap.put(path, instanceConfig);
+
+ ActorClass ac = ConfigUtil.resolve(instanceConfig.getRoot(),
+ instanceConfig.getPath());
+ if (ac2aiConfMap.get(ac) == null)
+ ac2aiConfMap.put(ac, new ArrayList<ActorInstanceConfig>());
+ ac2aiConfMap.get(ac).add(instanceConfig);
+
+ aiConf2acMap.put(instanceConfig, ac);
+ }
+ for (SubSystemConfig ssConfig : config.getSubSystemConfigs()) {
+ if (ssc2ssConfMap.containsKey(ssConfig)) {
+ logger.logError(
+ "Multiple configurations for subSystem class "
+ + ssConfig.getSubSystem().getName()
+ + " found", null);
+ error = true;
+ } else {
+ ssc2ssConfMap.put(ssConfig.getSubSystem(), ssConfig);
+ ssc2attrInstConfMap.put(ssConfig.getSubSystem(),
+ new ArrayList<AttrInstanceConfig>());
+ }
+ }
+ }
+
+ // dynConfigSubsystemMap
+ for (ActorInstanceConfig instanceConfig : path2aiConfMap.values()) {
+ List<AttrInstanceConfig> dynConfigs = new ArrayList<AttrInstanceConfig>();
+ for (AttrInstanceConfig config : instanceConfig.getAttributes())
+ if (config.isDynConfig())
+ dynConfigs.add(config);
+ if (!dynConfigs.isEmpty())
+ ssc2attrInstConfMap.get(instanceConfig.getRoot()).addAll(
+ dynConfigs);
+ }
+
+ return !error;
+ }
+
+ public static String toPath(Iterable<String> path, String pathDelim) {
+ StringBuilder b = new StringBuilder();
+ for (String p : path)
+ b.append(pathDelim + p);
+
+ return b.toString();
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java
index 50b3ba135..79732bc36 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java
@@ -182,7 +182,7 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
ConfigPackage.Literals.ATTR_CONFIG__VALUE);
if (a.getSize() > 0)
error("DataClass arrays not supported",
- ConfigPackage.Literals.ATTR_CLASS_CONFIG__ATTRIBUTES);
+ ConfigPackage.Literals.ATTR_CONFIG__ATTRIBUTE);
}
}

Back to the top