Skip to content
Snippets Groups Projects
Commit 303136f5 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

D3SE: Introduce IComponentAdapters.

parent 3e549181
No related branches found
No related tags found
No related merge requests found
Showing
with 114 additions and 19 deletions
ExplorationAlg.java df5046c20ceebc90791cbaeaf512da81a28f5ff3 YELLOW
ExplorationAlg.java 78301476900941a502ee198f6ac321e06f7b8428 YELLOW
ExplorationAlgActivator.java 7ccd8c61f3cd761be44cd5b23dc925a1f5da8fbe YELLOW
......@@ -31,6 +31,7 @@ import org.fortiss.af3.exploration.alg.module.IEvaluatorModule;
import org.fortiss.af3.exploration.alg.module.common.evaluator.mapping.MappingEvaluatorConstraint;
import org.fortiss.af3.exploration.alg.module.common.evaluator.mapping.MappingEvaluatorObjective;
import org.fortiss.af3.exploration.alg.module.common.input.AllResourceInputModule;
import org.fortiss.af3.exploration.alg.module.common.input.ComponentInputModule;
import org.fortiss.af3.exploration.alg.module.common.input.DeployableTaskModule;
import org.fortiss.af3.exploration.alg.module.common.input.ExecutionUnitTargetModule;
import org.fortiss.af3.exploration.alg.module.common.input.GatewayUnitInputModule;
......@@ -135,6 +136,7 @@ public final class ExplorationAlg implements IStartup {
private static void registerInputModules() {
IExplorationInputService iService = getService(IExplorationInputService.class);
iService.registerExplorationInput(new ExecutionUnitTargetModule());
iService.registerExplorationInput(new ComponentInputModule());
iService.registerExplorationInput(new DeployableTaskModule());
iService.registerExplorationInput(new ResourceConnectionModule());
iService.registerExplorationInput(new PlatformCommunicationGraphInputModule());
......
AF3ComponentAdapter.java 1ac45531defaa21151fd2210f2ce40d45945aaf6 RED
AF3ExecutionUnitAdapter.java 3f430bb010b8779ca44c1772d839618e98cf74c4 RED
AF3GatewayAdapter.java 5769b7b1fb706c3c78104029a433b28ae22a3fde RED
AF3MemoryUnitAdapter.java cbd6d2cacec27413b73208d116c506a84e6f22e5 RED
......@@ -7,5 +8,5 @@ AF3ResourceAdapter.java a4679a59cfe897a37e4410e6b9a48fb4d214f5eb RED
AF3ResourceConnectionAdapter.java 8741ce49893c49ac9d2ae1b8feb0fde440a71092 RED
AF3SignalAdapter.java c06b7eb4bc0b3036d3d1b8d9fd42391e33513214 RED
AF3SystemModelAdapter.java e391d3bb2c075660309944dd0149cd9ec2f314ad RED
AF3TaskAdapter.java 613f63f835b1c6c3cb12fdd4c35ade737c319f8c RED
AF3TaskAdapter.java f2ed4e139ff02d87bd080d6964105f50a127254f RED
AF3TransmissionUnitAdapter.java ddf19d48805623248a260facd4fc00baef2c62ad RED
/*-------------------------------------------------------------------------+
| Copyright 2019 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IComponentAdapter;
/**
* Internal representation of AF3 Components.
*
* @author diewald
*/
public class AF3ComponentAdapter extends AF3RequestAdapter<Component> implements IComponentAdapter {
/** Constructor. */
public AF3ComponentAdapter(Component modelElement) {
super(modelElement);
}
}
......@@ -34,6 +34,7 @@ import java.util.Set;
import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.common.util.Enumerator;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IComponentAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IMemoryUnitAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
......@@ -105,7 +106,7 @@ public class AF3TaskAdapter extends AF3RequestAdapter<Task> implements ITaskAdap
* @throws InvalidModelException
* if a required annotation cannot be found.
*/
public AF3TaskAdapter(Task af3Task, Collection<Component> af3Components,
public AF3TaskAdapter(Task af3Task, Collection<IComponentAdapter> components,
Set<IExecutionUnitAdapter> execUnits, Set<IMemoryUnitAdapter> memUnits)
throws InvalidModelException {
super(af3Task);
......@@ -154,16 +155,18 @@ public class AF3TaskAdapter extends AF3RequestAdapter<Task> implements ITaskAdap
// Properties inherited from components.
SafetyIntegrityLevel tempSIL = null;
for(Component comp : af3Components) {
if(comp.isStronglyCausal()) {
for(IComponentAdapter comp : components) {
// TODO: Move all this logic to the IComponentAdapter.
Component af3Component = comp.getObject(Component.class);
if(af3Component.isStronglyCausal()) {
stronglyCausal = true;
}
tempSIL = getAnnotationChecked(comp, SafetyIntegrityLevel.class);
tempSIL = getAnnotationChecked(af3Component, SafetyIntegrityLevel.class);
if(sil == null) {
sil = tempSIL;
} else if(sil.getValue() != tempSIL.getValue()) {
throw new InvalidModelException(comp,
throw new InvalidModelException(af3Component,
"Only components with the same SIL may be mapped to a Task.");
}
}
......
AllResourceInputModule.java c97356e064efd2e8c199b925bc5958c54889be05 YELLOW
DeployableTaskModule.java e467f7ae733c37654910e30af3ed3f598b9a480a YELLOW
ComponentInputModule.java d59a510d0122c8603222833274c0c2cfa818a6c8 YELLOW
DeployableTaskModule.java d6d20bb271a889a324ad9901dab0173ae247a2a5 YELLOW
ExecutionUnitTargetModule.java 422fc65f1d07c008302691c5cb55633a69b6d038 YELLOW
GatewayUnitInputModule.java c5cbadfdab27feebde7a910a54fa1bf99781d10c YELLOW
MemoryUnitInputModule.java d58ae0709d5162988cb3bfede155449db664fc45 YELLOW
......
/*-------------------------------------------------------------------------+
| Copyright 2019 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.alg.module.common.input;
import java.util.HashSet;
import java.util.Set;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IComponentAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3.AF3ComponentAdapter;
import org.fortiss.af3.exploration.alg.module.InputModule;
import org.fortiss.af3.exploration.alg.module.InputProvider;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import com.google.inject.Provides;
import com.google.inject.Singleton;
/**
* Input module to read components that specify behavior and the data flow.
*
* @author diewald
*/
public class ComponentInputModule extends InputModule<Set<IComponentAdapter>> {
/** Provides the {@link ITaskAdapter}s of the task architecture. */
@Provides
@InputProvider
@Singleton
public Set<IComponentAdapter> getComponents(SuperSet<Component> af3Comps) {
Set<IComponentAdapter> components = new HashSet<>();
for(Component currentComponent : af3Comps.getEntries()) {
components.add(new AF3ComponentAdapter(currentComponent));
}
return components;
}
}
......@@ -15,16 +15,15 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.alg.module.common.input;
import static org.fortiss.tooling.common.util.LambdaUtils.filter;
import static org.fortiss.tooling.common.util.LambdaUtils.getFirst;
import static java.util.stream.Collectors.toSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Optional;
import java.util.List;
import java.util.Set;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IComponentAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IMemoryUnitAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
......@@ -51,16 +50,23 @@ public class DeployableTaskModule extends InputModule<Set<ITaskAdapter>> {
@Singleton
public Set<ITaskAdapter> getTasks(SuperSet<Task> af3Tasks,
SuperSet<ComponentToTaskAllocationEntry> componentTaskAllocs,
Set<IExecutionUnitAdapter> execUnits, Set<IMemoryUnitAdapter> memUnits) {
Set<IComponentAdapter> components, Set<IExecutionUnitAdapter> execUnits,
Set<IMemoryUnitAdapter> memUnits) {
Set<ITaskAdapter> tasks = new HashSet<>();
for(Task currentTask : af3Tasks.getEntries()) {
Optional<ComponentToTaskAllocationEntry> assocComponent =
getFirst(filter(componentTaskAllocs.getEntries(),
e -> e.getTargetElement() == currentTask));
Collection<Component> af3Components = new ArrayList<>();
assocComponent.ifPresent(e -> af3Components.addAll(e.getComponents()));
// @CodeFormatterOff
Set<Component> assocAF3Components = componentTaskAllocs.getEntries().stream()
.filter(e -> e.getTargetElement() == currentTask) // Get only relevant entries
.map(e -> e.getSourceElements()) // Trace back to mapped components
.flatMap(List::stream) // Unfold the list (aggregate)
.map(Component.class::cast) // Fixup the generic IModelElement return type
.collect(toSet());
// @CodeFormatterOn
Collection<IComponentAdapter> assocComponents = components.stream()
.filter(c -> assocAF3Components.contains(c.getObject(Component.class)))
.collect(toSet());
tasks.add(new AF3TaskAdapter(currentTask, af3Components, execUnits, memUnits));
tasks.add(new AF3TaskAdapter(currentTask, assocComponents, execUnits, memUnits));
}
return tasks;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment