| /** |
| * ******************************************************************************* |
| * 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.Generation; |
| import org.eclipse.app4mc.amalthea.generator.configuration.IntegerDistribution; |
| import org.eclipse.app4mc.amalthea.generator.configuration.PercentageDistribution; |
| import org.eclipse.app4mc.amalthea.generator.configuration.RTMGC; |
| import org.eclipse.app4mc.amalthea.generator.configuration.RTMGCFactory; |
| import org.eclipse.app4mc.amalthea.generator.configuration.RunnableProperties; |
| import org.eclipse.app4mc.amalthea.generator.configuration.RuntimeType; |
| 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 RunnablesConfigurationHelper implements IConfigurationHelper { |
| |
| private Combo typeCombo; |
| private IntegerDistributionGroup instructionsGroup; |
| private IntegerDistributionGroup callSequenceGroup; |
| private IntegerDistributionGroup swcGroup; |
| private PercentageDistributionGroup min; |
| private PercentageDistributionGroup max; |
| |
| public void addTabItem(TabFolder parent) { |
| TabItem tab = new TabItem(parent, SWT.NONE); |
| tab.setText("Runnables"); |
| |
| ScrolledComposite sc = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL); |
| |
| Composite container = new Composite(sc, SWT.NONE); |
| container.setLayout(new GridLayout()); |
| GridLayout gridLayout = new GridLayout(); |
| container.setLayout(gridLayout); |
| gridLayout.numColumns = 2; |
| |
| sc.setExpandVertical(true); |
| sc.setExpandHorizontal(true); |
| |
| // runtime type |
| Label label = new Label(container, SWT.NONE); |
| label.setText("Distribution Type"); |
| label.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); |
| typeCombo = new Combo(container, SWT.READ_ONLY); |
| typeCombo.setItems(Arrays.stream(RuntimeType.values()).map(Enum::name).toArray(String[]::new)); |
| typeCombo.select(0); |
| |
| this.instructionsGroup = new IntegerDistributionGroup(container, "Number of Instructions per Runnable", 30000, 50000, 100000); |
| this.callSequenceGroup = new IntegerDistributionGroup(container, "Number of Runnables per Call Sequence", 6, 13); |
| this.swcGroup = new IntegerDistributionGroup(container, "Number of Instructions per SWC", 3, 5); |
| this.min = new PercentageDistributionGroup(container, "Minimum Distance for Statistics", 33, 66, 99); |
| this.max = new PercentageDistributionGroup(container, "Maximum Distance for Statistics", 110, 150, 200); |
| |
| 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) { |
| RunnableProperties runnables = generation.getRunnables(); |
| if(null != runnables) { |
| RuntimeType type = runnables.getRuntimeType(); |
| this.typeCombo.select(type.getValue()); |
| IntegerDistribution instructionsPerRunnable = runnables.getInstructionsPerRunnables(); |
| this.instructionsGroup.set(instructionsPerRunnable); |
| IntegerDistribution runnablesPerCallSequence = runnables.getRunnablesPerCallSequence(); |
| this.callSequenceGroup.set(runnablesPerCallSequence); |
| IntegerDistribution runnablesPerSWC = runnables.getRunnablesPerSWC(); |
| this.swcGroup.set(runnablesPerSWC); |
| PercentageDistribution min = runnables.getMinStatisticsDistance(); |
| this.min.set(min); |
| PercentageDistribution max = runnables.getMaxStatisticsDistance(); |
| this.max.set(max); |
| } |
| } |
| } |
| } |
| |
| @Override |
| public void updateConfiguration(RTMGC rtmgc) { |
| if(null != rtmgc) { |
| Generation generation = rtmgc.getGeneration(); |
| if(null == generation) { |
| generation = RTMGCFactory.eINSTANCE.createGeneration(); |
| rtmgc.setGeneration(generation); |
| } |
| RunnableProperties runnables = generation.getRunnables(); |
| if(null == runnables) { |
| runnables = RTMGCFactory.eINSTANCE.createRunnableProperties(); |
| generation.setRunnables(runnables); |
| } |
| int type = this.typeCombo.getSelectionIndex(); |
| runnables.setRuntimeType(RuntimeType.get(type)); |
| IntegerDistribution instructionsPerRunnable = this.instructionsGroup.get(); |
| runnables.setInstructionsPerRunnables(instructionsPerRunnable); |
| IntegerDistribution runnablesPerCallSequence = this.callSequenceGroup.get(); |
| runnables.setRunnablesPerCallSequence(runnablesPerCallSequence); |
| IntegerDistribution runnablesPerSWC = this.swcGroup.get(); |
| runnables.setRunnablesPerSWC(runnablesPerSWC); |
| PercentageDistribution min = this.min.get(); |
| runnables.setMinStatisticsDistance(min); |
| PercentageDistribution max = this.max.get(); |
| runnables.setMaxStatisticsDistance(max); |
| } |
| } |
| |
| @Override |
| public boolean isValid() { |
| return true; |
| } |
| } |