blob: 4274d1a7c1046bb67c26a363b19943e9b98d385b [file] [log] [blame]
/**
* *******************************************************************************
* Copyright (c) 2017 Timing-Architects Embedded Systems GmbH and others.
* 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:
* Timing-Architects Embedded Systems GmbH - initial API and implementation
*
* *******************************************************************************
*/
package org.eclipse.app4mc.amalthea.generator.ui;
import java.util.Arrays;
import org.eclipse.app4mc.amalthea.generator.configuration.DoubleDistribution;
import org.eclipse.app4mc.amalthea.generator.configuration.Generation;
import org.eclipse.app4mc.amalthea.generator.configuration.IntegerDistribution;
import org.eclipse.app4mc.amalthea.generator.configuration.PercentageDistribution;
import org.eclipse.app4mc.amalthea.generator.configuration.PriorityDeterminationAlgorithm;
import org.eclipse.app4mc.amalthea.generator.configuration.ProcessMappingAlgorithms;
import org.eclipse.app4mc.amalthea.generator.configuration.RTMGC;
import org.eclipse.app4mc.amalthea.generator.configuration.RTMGCFactory;
import org.eclipse.app4mc.amalthea.generator.configuration.TaskProperties;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
public class TasksConfigurationHelper implements IConfigurationHelper {
private IntegerDistributionGroup count;
private PercentageDistributionGroup load;
private IntegerDistributionGroup group;
private IntegerDistributionGroup mta;
private DoubleDistributionGroup deadline;
private IntegerDistributionGroup schedule;
private Combo mappingCombo;
private Combo priorityCombo;
public void addTabItem(TabFolder parent) {
TabItem tab = new TabItem(parent, SWT.NONE);
tab.setText("Tasks");
ScrolledComposite sc = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL);
Composite container = new Composite(sc, SWT.NONE);
GridLayout gridLayout = new GridLayout();
container.setLayout(gridLayout);
gridLayout.numColumns = 2;
sc.setExpandVertical(true);
sc.setExpandHorizontal(true);
// distributions
this.count = new IntegerDistributionGroup(container, "Number of Tasks to be generated", 9, 15, 22);
this.load = new PercentageDistributionGroup(container, "Load in Percentage for each Task", 1, 20);
this.group = new IntegerDistributionGroup(container, "Number of Tasks per Task Group", 1);
this.mta = new IntegerDistributionGroup(container, "Number of Concurrent Task Activations", 1, 5);
this.deadline = new DoubleDistributionGroup(container, "Factor of the Deadline Relative to the Recurrence of the Task", 1);
this.schedule = new IntegerDistributionGroup(container, "Number of Call Sequences between Schedule Points that are added", 1);
// call graphs
// mapping determination
Label label = new Label(container, SWT.NONE);
label.setText("Mapping Determination Algorithm");
label.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
mappingCombo = new Combo(container, SWT.READ_ONLY);
mappingCombo.setItems(Arrays.stream(ProcessMappingAlgorithms.values()).map(Enum::name).toArray(String[]::new));
mappingCombo.select(0);
// priority determination
label = new Label(container, SWT.NONE);
label.setText("Priority Determination Algorithm");
label.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
priorityCombo = new Combo(container, SWT.READ_ONLY);
priorityCombo.setItems(Arrays.stream(PriorityDeterminationAlgorithm.values()).map(Enum::name).toArray(String[]::new));
priorityCombo.select(0);
sc.setContent(container);
sc.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT));
tab.setControl(sc);
}
@Override
public void loadConfiguration(RTMGC rtmgc) {
if(null != rtmgc) {
Generation generation = rtmgc.getGeneration();
if(null != generation) {
TaskProperties tasks = generation.getTasks();
if(null != tasks) {
IntegerDistribution count = tasks.getCount();
this.count.set(count);
PercentageDistribution load = tasks.getLoad();
this.load.set(load);
IntegerDistribution group = tasks.getPerTaskGroup();
this.group.set(group);
IntegerDistribution mta = tasks.getMta();
this.mta.set(mta);
DoubleDistribution deadline = tasks.getDeadlineFactor();
this.deadline.set(deadline);
IntegerDistribution schedule = tasks.getCallSequencesBetweenSchedulePoints();
this.schedule.set(schedule);
this.mappingCombo.select(tasks.getMappingDetermination().getValue());
this.priorityCombo.select(tasks.getPriorityDetermination().getValue());
}
}
}
}
@Override
public void updateConfiguration(RTMGC rtmgc) {
if(null != rtmgc) {
Generation generation = rtmgc.getGeneration();
if(null == generation) {
generation = RTMGCFactory.eINSTANCE.createGeneration();
rtmgc.setGeneration(generation);
}
TaskProperties tasks = generation.getTasks();
if(null == tasks) {
tasks = RTMGCFactory.eINSTANCE.createTaskProperties();
generation.setTasks(tasks);
}
IntegerDistribution count = this.count.get();
tasks.setCount(count);
PercentageDistribution load = this.load.get();
tasks.setLoad(load);
IntegerDistribution group = this.group.get();
tasks.setPerTaskGroup(group);
IntegerDistribution mta = this.mta.get();
tasks.setMta(mta);
DoubleDistribution deadline = this.deadline.get();
tasks.setDeadlineFactor(deadline);
IntegerDistribution schedule = this.schedule.get();
tasks.setCallSequencesBetweenSchedulePoints(schedule);
tasks.setMappingDetermination(ProcessMappingAlgorithms.get(this.mappingCombo.getSelectionIndex()));
tasks.setPriorityDetermination(PriorityDeterminationAlgorithm.get(this.priorityCombo.getSelectionIndex()));
}
}
@Override
public boolean isValid() {
return true;
}
}