| 1 | package de.uka.ipd.sdq.codegen.simucontroller.runconfig; |
| 2 | |
| 3 | import org.eclipse.core.runtime.CoreException; |
| 4 | import org.eclipse.debug.core.ILaunchConfiguration; |
| 5 | |
| 6 | import de.uka.ipd.sdq.simucomframework.SimuComConfig; |
| 7 | import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedRunConfiguration; |
| 8 | import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowConfigurationBuilder; |
| 9 | import de.uka.ipd.sdq.workflow.pcm.ConstantsContainer; |
| 10 | import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractCodeGenerationWorkflowRunConfiguration.CodeGenerationAdvice; |
| 11 | import de.uka.ipd.sdq.workflow.pcm.runconfig.SensitivityAnalysisConfiguration; |
| 12 | |
| 13 | public abstract class AbstractSimulationLaunchConfigurationBasedConfigBuilder |
| 14 | extends AbstractWorkflowConfigurationBuilder { |
| 15 | |
| 16 | public AbstractSimulationLaunchConfigurationBasedConfigBuilder( |
| 17 | ILaunchConfiguration configuration, String mode) throws CoreException { |
| 18 | super(configuration,mode); |
| 19 | } |
| 20 | |
| 21 | @Override |
| 22 | public void fillConfiguration(AbstractWorkflowBasedRunConfiguration configuration) throws CoreException { |
| 23 | AbstractSimulationWorkflowConfiguration config = (AbstractSimulationWorkflowConfiguration) configuration; |
| 24 | |
| 25 | config.setCodeGenerationAdvicesFile(CodeGenerationAdvice.SIMULATION); |
| 26 | |
| 27 | config.setDebug(this.isDebug); |
| 28 | if (hasAttribute(SimuComConfig.SHOULD_THROW_EXCEPTION)) |
| 29 | config.setInteractive(getBooleanAttribute(SimuComConfig.SHOULD_THROW_EXCEPTION)); |
| 30 | else |
| 31 | config.setInteractive(true); |
| 32 | |
| 33 | config.setSimulateLinkingResources(getBooleanAttribute(ConstantsContainer.SIMULATE_LINKING_RESOURCES)); |
| 34 | |
| 35 | //This loads the feature config for Steffen's Connector Completions |
| 36 | //TODO: Integrate this in CIP process. |
| 37 | config.setFeatureConfigFile( getStringAttribute(ConstantsContainer.FEATURE_CONFIG) ); |
| 38 | |
| 39 | config.setSensitivityAnalysisEnabled( |
| 40 | hasValidSensitvityVariableAttribute(ConstantsContainer.VARIABLE_TEXT)); |
| 41 | if (config.isSensitivityAnalysisEnabled()) { |
| 42 | SensitivityAnalysisConfiguration sensitivityConfig = |
| 43 | new SensitivityAnalysisConfiguration( |
| 44 | "", |
| 45 | //TODO: getStringAttribute(ConstantsContainer.VARIABLE_SHORT_NAME), |
| 46 | getStringAttribute(ConstantsContainer.VARIABLE_TEXT), |
| 47 | getDoubleAttribute(ConstantsContainer.MINIMUM_TEXT), |
| 48 | getDoubleAttribute(ConstantsContainer.MAXIMUM_TEXT), |
| 49 | getDoubleAttribute(ConstantsContainer.STEP_WIDTH_TEXT)); |
| 50 | config.setSensitivityAnalysisConfiguration(sensitivityConfig); |
| 51 | } |
| 52 | |
| 53 | config.setCompletionConfiguration(new PCMCompletionRunConfiguration(config, properties)); |
| 54 | } |
| 55 | |
| 56 | private boolean hasValidSensitvityVariableAttribute(String attribute) throws CoreException { |
| 57 | if (!configuration.hasAttribute(attribute)) |
| 58 | return false; |
| 59 | Object value = getStringAttribute(attribute); |
| 60 | //Anne: I sometimes get a "NO ELEMENT SELECTED" result from the LaunchConfig even if I deleted the string from the field |
| 61 | //I have no idea how to fix it directly, so I need to catch it here. |
| 62 | //It seems to only appear in the Design Space Exploration tab. |
| 63 | return value instanceof String && !value.equals("") && !value.equals("NO ELEMENT SELECTED"); |
| 64 | } |
| 65 | |
| 66 | } |