| 1 | package de.uka.ipd.sdq.pcmsolver.runconfig; |
| 2 | |
| 3 | import org.eclipse.core.runtime.CoreException; |
| 4 | import org.eclipse.debug.core.ILaunchConfiguration; |
| 5 | |
| 6 | import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedRunConfiguration; |
| 7 | import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowConfigurationBuilder; |
| 8 | import de.uka.ipd.sdq.workflow.launchconfig.tabs.DebugEnabledCommonTab; |
| 9 | |
| 10 | /** |
| 11 | * This class can build PCM solver specific configuration objects out of a given |
| 12 | * Eclipse Launch Configuration. |
| 13 | * |
| 14 | * @author brosch |
| 15 | * |
| 16 | */ |
| 17 | public class PCMSolverConfigurationBasedConfigBuilder extends |
| 18 | AbstractWorkflowConfigurationBuilder { |
| 19 | |
| 20 | /** |
| 21 | * Configuration details constant. |
| 22 | */ |
| 23 | private static final int DOMAINSIZEDEFAULT = 32; |
| 24 | |
| 25 | /** |
| 26 | * Configuration details constant. |
| 27 | */ |
| 28 | private static final double DISTANCEDEFAULT = 1.0; |
| 29 | |
| 30 | /** |
| 31 | * The constructor takes an Eclipse Launch Configuration object. |
| 32 | * |
| 33 | * @param configuration |
| 34 | * the Eclipse Launch Configuration object |
| 35 | * @param mode |
| 36 | * distinguishes between debug mode and normal mode |
| 37 | * @throws CoreException |
| 38 | * the access of attributes of the Eclipse Launch Configuration |
| 39 | * object might lead to a CoreException |
| 40 | */ |
| 41 | public PCMSolverConfigurationBasedConfigBuilder( |
| 42 | final ILaunchConfiguration configuration, final String mode) |
| 43 | throws CoreException { |
| 44 | super(configuration, mode); |
| 45 | } |
| 46 | |
| 47 | /* |
| 48 | * (non-Javadoc) |
| 49 | * |
| 50 | * @see |
| 51 | * de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowConfigurationBuilder |
| 52 | * #fillConfiguration(de.uka.ipd.sdq.workflow.launchconfig. |
| 53 | * AbstractWorkflowBasedRunConfiguration) |
| 54 | */ |
| 55 | @Override |
| 56 | public void fillConfiguration( |
| 57 | final AbstractWorkflowBasedRunConfiguration configuration) |
| 58 | throws CoreException { |
| 59 | |
| 60 | // We assume that we got a PCMSolverWorkflowRunConfiguration object: |
| 61 | PCMSolverWorkflowRunConfiguration config = (PCMSolverWorkflowRunConfiguration) configuration; |
| 62 | |
| 63 | // Per default, we assume that this is not a reliability analysis: |
| 64 | config.setReliabilityAnalysis(false); |
| 65 | |
| 66 | // We also assume that we are in interactive mode (so that dialogs in |
| 67 | // case of model validation errors or exceptions during analysis are NOT |
| 68 | // suppressed): |
| 69 | config.setInteractive(true); |
| 70 | |
| 71 | // Set some general properties from the Eclipse Launch Configuration: |
| 72 | config.setDomainSize(hasAttribute(MessageStrings.MAX_DOMAIN) ? getIntegerAttribute(MessageStrings.MAX_DOMAIN) |
| 73 | : DOMAINSIZEDEFAULT); |
| 74 | config.setDistance(hasAttribute(MessageStrings.SAMPLING_DIST) ? getDoubleAttribute(MessageStrings.SAMPLING_DIST) |
| 75 | : DISTANCEDEFAULT); |
| 76 | config.setSolver(hasAttribute(MessageStrings.SOLVER) ? getStringAttribute(MessageStrings.SOLVER) |
| 77 | : MessageStrings.SRE_SOLVER); |
| 78 | |
| 79 | // Set further properties which are specific for the LQN Solver: |
| 80 | config.setLqnsOutput(hasAttribute(MessageStrings.LQNS_OUTPUT) ? getStringAttribute(MessageStrings.LQNS_OUTPUT) |
| 81 | : MessageStrings.LQN_OUTPUT_HUMAN); |
| 82 | config.setLqnsOutputDir(hasAttribute(MessageStrings.LQNS_OUTPUT_DIR) ? getStringAttribute(MessageStrings.LQNS_OUTPUT_DIR) |
| 83 | : System.getProperty("user.dir")); |
| 84 | config.setLqsimOutput(hasAttribute(MessageStrings.LQSIM_OUTPUT) ? getStringAttribute(MessageStrings.LQSIM_OUTPUT) |
| 85 | : MessageStrings.LQN_OUTPUT_HUMAN); |
| 86 | config.setLqsimOutputDir(hasAttribute(MessageStrings.LQSIM_OUTPUT_DIR) ? getStringAttribute(MessageStrings.LQSIM_OUTPUT_DIR) |
| 87 | : System.getProperty("user.dir")); |
| 88 | |
| 89 | config.setSREOutputFile(hasAttribute(MessageStrings.SRE_OUTPUT_FILE) ? getStringAttribute(MessageStrings.SRE_OUTPUT_FILE) |
| 90 | : System.getProperty("user.dir")); |
| 91 | |
| 92 | config.setIsUseSREInputModel(hasAttribute(MessageStrings.SRE_IS_USE_INPUT_MODEL) ? getBooleanAttribute(MessageStrings.SRE_IS_USE_INPUT_MODEL) |
| 93 | : false); |
| 94 | |
| 95 | config.setDebugLevel(hasAttribute(DebugEnabledCommonTab.WORKFLOW_ENGINE_DEBUG_LEVEL) ? getIntegerAttribute(DebugEnabledCommonTab.WORKFLOW_ENGINE_DEBUG_LEVEL) |
| 96 | : 0); |
| 97 | config.setPsQuantum(hasAttribute(MessageStrings.PS_QUANTUM) ? getStringAttribute(MessageStrings.PS_QUANTUM) |
| 98 | : "0.001"); |
| 99 | |
| 100 | config.setPragmas(hasAttribute(MessageStrings.PRAGMAS) ? getStringAttribute(MessageStrings.PRAGMAS) |
| 101 | : ""); |
| 102 | |
| 103 | config.setLQSimRuntime(hasAttribute(MessageStrings.RUN_TIME) ? getStringAttribute(MessageStrings.RUN_TIME) |
| 104 | : ""); |
| 105 | |
| 106 | config.setLQSimBlocks(hasAttribute(MessageStrings.BLOCKS) ? getStringAttribute(MessageStrings.BLOCKS) |
| 107 | : ""); |
| 108 | |
| 109 | config.setConvValue(hasAttribute(MessageStrings.CONV_VALUE) ? getStringAttribute(MessageStrings.CONV_VALUE) |
| 110 | : "0.001"); |
| 111 | config.setItLimit(hasAttribute(MessageStrings.IT_LIMIT) ? getStringAttribute(MessageStrings.IT_LIMIT) |
| 112 | : "50"); |
| 113 | config.setPrintInt(hasAttribute(MessageStrings.PRINT_INT) ? getStringAttribute(MessageStrings.PRINT_INT) |
| 114 | : "10"); |
| 115 | config.setUnderCoeff(hasAttribute(MessageStrings.UNDER_COEFF) ? getStringAttribute(MessageStrings.UNDER_COEFF) |
| 116 | : "0.5"); |
| 117 | |
| 118 | config.setStopOnMessageLossLQNS(hasAttribute(MessageStrings.STOP_ON_MESSAGE_LOSS_LQNS) |
| 119 | ? getBooleanAttribute(MessageStrings.STOP_ON_MESSAGE_LOSS_LQNS) |
| 120 | : true); |
| 121 | config.setStopOnMessageLossLQSim(hasAttribute(MessageStrings.STOP_ON_MESSAGE_LOSS_LQSIM) |
| 122 | ? getBooleanAttribute(MessageStrings.STOP_ON_MESSAGE_LOSS_LQSIM) |
| 123 | : true); |
| 124 | |
| 125 | config.setInfiniteTaskMultiplicity(hasAttribute(MessageStrings.INFINITE_TASK_MULTIPLICITY) |
| 126 | ? getBooleanAttribute(MessageStrings.INFINITE_TASK_MULTIPLICITY) |
| 127 | : true); |
| 128 | } |
| 129 | } |