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;
}
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;
}
}
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;
}
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;
}
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;
}
Aggregations