Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.app4mc.multicore.execution.logic/src/org/eclipse/app4mc/multicore/execution/logic/executionmodel/ExecutionModel.java')
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.app4mc.multicore.execution.logic/src/org/eclipse/app4mc/multicore/execution/logic/executionmodel/ExecutionModel.java283
1 files changed, 146 insertions, 137 deletions
diff --git a/plugins/org.eclipse.app4mc.multicore.execution.logic/src/org/eclipse/app4mc/multicore/execution/logic/executionmodel/ExecutionModel.java b/plugins/org.eclipse.app4mc.multicore.execution.logic/src/org/eclipse/app4mc/multicore/execution/logic/executionmodel/ExecutionModel.java
index 8868056a4..989cd9fd7 100755..100644
--- a/plugins/org.eclipse.app4mc.multicore.execution.logic/src/org/eclipse/app4mc/multicore/execution/logic/executionmodel/ExecutionModel.java
+++ b/plugins/org.eclipse.app4mc.multicore.execution.logic/src/org/eclipse/app4mc/multicore/execution/logic/executionmodel/ExecutionModel.java
@@ -1,137 +1,146 @@
-/**
- ********************************************************************************
- * Copyright (c) 2017 Dortmund University of Applied Sciences and Arts and others.
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Dortmund University of Applied Sciences and Arts - initial API and implementation
- ********************************************************************************
- */
-
-package org.eclipse.app4mc.multicore.execution.logic.executionmodel;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.function.BiConsumer;
-import java.util.function.Consumer;
-
-import org.eclipse.app4mc.multicore.execution.logic.executionmodel.misc.EMTimeType;
-import org.eclipse.app4mc.multicore.execution.logic.executionmodel.types.EMCore;
-import org.eclipse.app4mc.multicore.execution.logic.executionmodel.types.EMTask;
-import org.eclipse.app4mc.multicore.execution.logic.executionmodel.types.EMTaskHistState;
-import org.eclipse.app4mc.multicore.execution.logic.executionmodel.types.EMTask.DeadlineEntry;
-
-public class ExecutionModel{
-
- private final Map<String,EMCore> cores = new HashMap<>();
-
- private final List<Consumer<EMCore>> coreAddedListener = new LinkedList<>();
-
- private final Map<String,EMTask> tasks = new HashMap<>();
-
- private final List<Consumer<EMTask>> taskAddedListener = new LinkedList<>();
-
- private List<BiConsumer<EMTask, EMTaskHistState>> histEntryListener = new LinkedList<>();
-
- private List<BiConsumer<EMTask, DeadlineEntry>> deadlineListener=new LinkedList<>();
-
- private EMTimeType timeScale=EMTimeType.NONE;
-
- public Map<String, EMCore> getCores() {
- return cores;
- }
-
- /**
- * Tasks in of after execution.
- * @see EMTask
- * @return
- */
- public Map<String, EMTask> getTasks() {
- return tasks;
- }
-
- public void setTimeScale(EMTimeType t){
- this.timeScale=t;
- }
-
- public EMTimeType getTimeScale(){
- return timeScale;
- }
-
- public void addTaskDeadlineMissedEntry(String taskName,String core,Long time){
- final EMTask t =tasks.get(taskName);
- DeadlineEntry d= new DeadlineEntry(time, cores.get(core));
- t.getMissedDeadlines().add(d);
- notifyTaskDeadlineMissed(t, d);
- }
-
- /**
- * Add a history entry to a task (e.g state running from time point 1000 to 1223).
- * By adding the entry with this method observer will be notified about completed task hist entries.
- * @param taskName
- * @param e
- */
- public void addTaskHistEntry(String taskName,EMTaskHistState e){
- final EMTask t =tasks.get(taskName);
- t.getStateHistory().add(e);
- notifyTaskHistEntryListener(t,e);
- }
-
- /**
- * Add a task to the model. Only this method will notify observers about added tasks.
- * @param t
- */
- public synchronized void addTask(EMTask t){
- tasks.put(t.getName(), t);
- notifyTaskAddedListener(t);
- }
-
- /**
- * Add a core to the model. Only this method will notify observers about added cores.
- * @param c
- */
- public void addCore(EMCore c){
- cores.put(c.getName(), c);
- notifyAllCoreAddedObserver(c);
- }
-
- private void notifyAllCoreAddedObserver(EMCore c) {
- coreAddedListener.forEach(x->x.accept(c));
- }
-
- private void notifyTaskAddedListener(EMTask t){
- taskAddedListener.forEach(x->x.accept(t));
- }
-
- private void notifyTaskHistEntryListener(EMTask t, EMTaskHistState e){
- histEntryListener.forEach(x->x.accept(t, e));
- }
-
- public void addTaskHistEntryAddedListener(BiConsumer<EMTask, EMTaskHistState> e ){
- histEntryListener.add(e);
- }
-
- public void addTaskAddedListener(Consumer<EMTask> t){
- taskAddedListener.add(t);
- }
-
- public void addCoreAddedListener(Consumer<EMCore> c){
- coreAddedListener.add(c);
- }
-
- public void addTaskDeadlineListener(BiConsumer<EMTask, DeadlineEntry> e) {
- deadlineListener.add(e);
- }
-
- private void notifyTaskDeadlineMissed(EMTask t, DeadlineEntry e){
- deadlineListener.forEach(x->x.accept(t, e));
- }
-
-}
+/**
+ ********************************************************************************
+ * Copyright (c) 2019 Dortmund University of Applied Sciences and Arts and others.
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Dortmund University of Applied Sciences and Arts - initial API and implementation
+ ********************************************************************************
+ */
+
+package org.eclipse.app4mc.multicore.execution.logic.executionmodel;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+
+import org.eclipse.app4mc.multicore.execution.logic.executionmodel.misc.EMTimeType;
+import org.eclipse.app4mc.multicore.execution.logic.executionmodel.types.EMCore;
+import org.eclipse.app4mc.multicore.execution.logic.executionmodel.types.EMTask;
+import org.eclipse.app4mc.multicore.execution.logic.executionmodel.types.EMTaskHistState;
+import org.eclipse.app4mc.multicore.execution.logic.executionmodel.types.EMTask.DeadlineEntry;
+
+public class ExecutionModel{
+
+ private final Map<String,EMCore> cores = new HashMap<>();
+
+ private final List<Consumer<EMCore>> coreAddedListener = new LinkedList<>();
+
+ private final Map<String,EMTask> tasks = new HashMap<>();
+
+ private final List<Consumer<EMTask>> taskAddedListener = new LinkedList<>();
+
+ private List<BiConsumer<EMTask, EMTaskHistState>> histEntryListener = new LinkedList<>();
+
+ private List<BiConsumer<EMTask, DeadlineEntry>> deadlineListener=new LinkedList<>();
+
+ private EMTimeType timeScale=EMTimeType.NONE;
+
+ private String path="";
+
+ public Map<String, EMCore> getCores() {
+ return cores;
+ }
+
+ /**
+ * Tasks in of after execution.
+ * @see EMTask
+ * @return
+ */
+ public Map<String, EMTask> getTasks() {
+ return tasks;
+ }
+
+ public void setTimeScale(EMTimeType t){
+ this.timeScale=t;
+ }
+
+ public EMTimeType getTimeScale(){
+ return timeScale;
+ }
+
+ public void addTaskDeadlineMissedEntry(String taskName,String core,Long time){
+ final EMTask t =tasks.get(taskName);
+ DeadlineEntry d= new DeadlineEntry(time, cores.get(core));
+ t.getMissedDeadlines().add(d);
+ notifyTaskDeadlineMissed(t, d);
+ }
+
+ /**
+ * Add a history entry to a task (e.g state running from time point 1000 to 1223).
+ * By adding the entry with this method observer will be notified about completed task hist entries.
+ * @param taskName
+ * @param e
+ */
+ public void addTaskHistEntry(String taskName,EMTaskHistState e){
+ final EMTask t =tasks.get(taskName);
+ t.getStateHistory().add(e);
+ notifyTaskHistEntryListener(t,e);
+ }
+
+ /**
+ * Add a task to the model. Only this method will notify observers about added tasks.
+ * @param t
+ */
+ public synchronized void addTask(EMTask t){
+ tasks.put(t.getName(), t);
+ notifyTaskAddedListener(t);
+ }
+
+ /**
+ * Add a core to the model. Only this method will notify observers about added cores.
+ * @param c
+ */
+ public void addCore(EMCore c){
+ cores.put(c.getName(), c);
+ notifyAllCoreAddedObserver(c);
+ }
+
+ private void notifyAllCoreAddedObserver(EMCore c) {
+ coreAddedListener.forEach(x->x.accept(c));
+ }
+
+ private void notifyTaskAddedListener(EMTask t){
+ taskAddedListener.forEach(x->x.accept(t));
+ }
+
+ private void notifyTaskHistEntryListener(EMTask t, EMTaskHistState e){
+ histEntryListener.forEach(x->x.accept(t, e));
+ }
+
+ public void addTaskHistEntryAddedListener(BiConsumer<EMTask, EMTaskHistState> e ){
+ histEntryListener.add(e);
+ }
+
+ public void addTaskAddedListener(Consumer<EMTask> t){
+ taskAddedListener.add(t);
+ }
+
+ public void addCoreAddedListener(Consumer<EMCore> c){
+ coreAddedListener.add(c);
+ }
+
+ public void addTaskDeadlineListener(BiConsumer<EMTask, DeadlineEntry> e) {
+ deadlineListener.add(e);
+ }
+
+ private void notifyTaskDeadlineMissed(EMTask t, DeadlineEntry e){
+ deadlineListener.forEach(x->x.accept(t, e));
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+}

Back to the top