Search in sources :

Example 6 with PCMRandomVariable

use of org.palladiosimulator.pcm.core.PCMRandomVariable in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddHDDProcessingResourceSpecification method getReadProcessingRate.

private PCMRandomVariable getReadProcessingRate() {
    final PCMRandomVariable pcmRandomVariable = CoreFactory.eINSTANCE.createPCMRandomVariable();
    pcmRandomVariable.setSpecification("");
    final StochasticExpressionEditDialog dialog = new StochasticExpressionEditDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), TypeEnum.DOUBLE, pcmRandomVariable);
    dialog.setDisplayTitle(SET_READ_PROCESSING_RATE);
    dialog.open();
    if (dialog.getResult() == null) {
        return null;
    }
    pcmRandomVariable.setSpecification(dialog.getResultText());
    return pcmRandomVariable;
}
Also used : StochasticExpressionEditDialog(org.palladiosimulator.editors.commons.dialogs.stoex.StochasticExpressionEditDialog) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable)

Example 7 with PCMRandomVariable

use of org.palladiosimulator.pcm.core.PCMRandomVariable in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddHDDProcessingResourceSpecification method execute.

@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final Object parameter = parameters.get(NEW_HDD_PROCESSING_RESOURCE_SPECIFICATION);
    if (parameter == null || !(parameter instanceof HDDProcessingResourceSpecification)) {
        return;
    }
    final HDDProcessingResourceSpecification hddProcessingResourceSpecification = (HDDProcessingResourceSpecification) parameter;
    // 1. dialog
    final ProcessingResourceType prt = getResourceType(hddProcessingResourceSpecification);
    if (prt != null) {
        hddProcessingResourceSpecification.setActiveResourceType_ActiveResourceSpecification(prt);
    } else {
        return;
    }
    // set processing rate always to 1
    final PCMRandomVariable processingRate = CoreFactory.eINSTANCE.createPCMRandomVariable();
    processingRate.setSpecification("1");
    hddProcessingResourceSpecification.setProcessingRate_ProcessingResourceSpecification(processingRate);
    // 2. dialog
    final PCMRandomVariable readProcessingRate = getReadProcessingRate();
    if (readProcessingRate != null) {
        hddProcessingResourceSpecification.setReadProcessingRate(readProcessingRate);
    } else {
        return;
    }
    // 3. dialog
    final PCMRandomVariable writeProcessingRate = getWriteProcessingRate();
    if (writeProcessingRate != null) {
        hddProcessingResourceSpecification.setWriteProcessingRate(writeProcessingRate);
    } else {
        return;
    }
    // 4. dialog
    final SchedulingPolicy sp = getSchedulingPolicy(hddProcessingResourceSpecification);
    if (sp != null) {
        hddProcessingResourceSpecification.setSchedulingPolicy(sp);
    } else {
        return;
    }
}
Also used : HDDProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.HDDProcessingResourceSpecification) EObject(org.eclipse.emf.ecore.EObject) ProcessingResourceType(org.palladiosimulator.pcm.resourcetype.ProcessingResourceType) SchedulingPolicy(org.palladiosimulator.pcm.resourcetype.SchedulingPolicy) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable)

Example 8 with PCMRandomVariable

use of org.palladiosimulator.pcm.core.PCMRandomVariable in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddLinkingResourceAction method getRandomVariableFromStoExDialog.

/**
 * Opens a StoxEx dialog and returns the resulting {@link PCMRandomVariable}.
 *
 * @param displayTitle
 *            Title of the StoEx dialog
 * @return PCMRandomVariable if user entered valid data and confirmed. Will return null if user
 *         canceled dialog
 */
private PCMRandomVariable getRandomVariableFromStoExDialog(final String displayTitle) {
    final PCMRandomVariable randomVariable = CoreFactory.eINSTANCE.createPCMRandomVariable();
    randomVariable.setSpecification("");
    final StochasticExpressionEditDialog dialog = new StochasticExpressionEditDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), TypeEnum.DOUBLE, randomVariable);
    dialog.setDisplayTitle(displayTitle);
    dialog.open();
    if (dialog.getReturnCode() == Dialog.CANCEL) {
        return null;
    }
    randomVariable.setSpecification(dialog.getResultText());
    return randomVariable;
}
Also used : StochasticExpressionEditDialog(org.palladiosimulator.editors.commons.dialogs.stoex.StochasticExpressionEditDialog) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable)

Example 9 with PCMRandomVariable

use of org.palladiosimulator.pcm.core.PCMRandomVariable in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddProcessingResourceSpecification method execute.

@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final Object parameter = parameters.get(NEW_PROCESSING_RESOURCE_SPECIFICATION);
    if (parameter == null || !(parameter instanceof ProcessingResourceSpecification)) {
        return;
    }
    final ProcessingResourceSpecification processingResourceSpecification = (ProcessingResourceSpecification) parameter;
    // 1. dialog
    final ProcessingResourceType prt = getResourceType(processingResourceSpecification);
    if (prt != null)
        processingResourceSpecification.setActiveResourceType_ActiveResourceSpecification(prt);
    else
        return;
    // 2. dialog
    final PCMRandomVariable pcmrv = getProcessingRate();
    if (pcmrv != null)
        processingResourceSpecification.setProcessingRate_ProcessingResourceSpecification(pcmrv);
    else
        return;
    // 3. dialog
    final SchedulingPolicy sp = getSchedulingPolicy(processingResourceSpecification);
    if (sp != null)
        processingResourceSpecification.setSchedulingPolicy(sp);
    else
        return;
}
Also used : ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification) EObject(org.eclipse.emf.ecore.EObject) ProcessingResourceType(org.palladiosimulator.pcm.resourcetype.ProcessingResourceType) SchedulingPolicy(org.palladiosimulator.pcm.resourcetype.SchedulingPolicy) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable)

Example 10 with PCMRandomVariable

use of org.palladiosimulator.pcm.core.PCMRandomVariable in project Palladio-Editors-Sirius by PalladioSimulator.

the class PCMServices method editPCMRandomVariable.

/**
 * Sets the given string as a specification on the {@link PCMRandomVariable} . For this it first
 * parses it to prevent any errors.
 *
 * @param pcmRandomVariable
 *            the random variable
 * @param expression
 *            the expression
 * @return the random variable
 */
public EObject editPCMRandomVariable(final EObject pcmRandomVariable, final String expressionString) {
    if (!(pcmRandomVariable instanceof PCMRandomVariable)) {
        return null;
    }
    if (!validExpression(expressionString)) {
        final ErrorDialog errorDialog = new ErrorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), PARSER_ERROR_TITLE, null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, PARSER_ERROR_MESSAGE), IStatus.ERROR);
        errorDialog.open();
        return null;
    }
    ((PCMRandomVariable) pcmRandomVariable).setSpecification(expressionString);
    return pcmRandomVariable;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable)

Aggregations

PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)10 StochasticExpressionEditDialog (org.palladiosimulator.editors.commons.dialogs.stoex.StochasticExpressionEditDialog)5 EObject (org.eclipse.emf.ecore.EObject)3 ProcessingResourceType (org.palladiosimulator.pcm.resourcetype.ProcessingResourceType)2 SchedulingPolicy (org.palladiosimulator.pcm.resourcetype.SchedulingPolicy)2 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 URI (org.eclipse.emf.common.util.URI)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ICommand (org.eclipse.gmf.runtime.common.core.command.ICommand)1 SetValueCommand (org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand)1 SetRequest (org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest)1 ErrorDialog (org.eclipse.jface.dialogs.ErrorDialog)1 Session (org.eclipse.sirius.business.api.session.Session)1 CommunicationLinkResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification)1 HDDProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.HDDProcessingResourceSpecification)1 ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)1 CommunicationLinkResourceType (org.palladiosimulator.pcm.resourcetype.CommunicationLinkResourceType)1 ResourceRepository (org.palladiosimulator.pcm.resourcetype.ResourceRepository)1 ClosedWorkload (org.palladiosimulator.pcm.usagemodel.ClosedWorkload)1