use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.
the class Issue2722Test method testInstantiationA.
@Test
public void testInstantiationA() throws Exception {
AadlPackage pkg = testHelper.parseFile(PATH + FILE1);
Optional<Classifier> impl = pkg.getOwnedPublicSection().getOwnedClassifiers().stream().filter(c -> c.getName().equals("S.i")).findFirst();
SystemInstance instance = InstantiateModel.instantiate((ComponentImplementation) impl.get());
Assert.assertEquals("S_i_Instance", instance.getName());
ConnectionInstance conni = instance.getConnectionInstances().get(0);
Assert.assertEquals("l.ll.o -> r.rr.i", conni.getName());
EList<SystemOperationMode> soms = conni.getInSystemOperationModes();
Assert.assertEquals(1, soms.size());
Assert.assertEquals(soms.get(0), instance.getSystemOperationModes().get(0));
}
use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.
the class AadlElementContentProvider method hasChildren.
@Override
public boolean hasChildren(Object element) {
if (element instanceof IFile || element instanceof ContributedAadlStorage) {
return true;
} else {
EObjectURIWrapper wrapper = (EObjectURIWrapper) element;
EObject eObject = new ResourceSetImpl().getEObject(wrapper.getUri(), true);
if (eObject instanceof AadlPackage || eObject instanceof PropertySet || eObject instanceof ComponentInstance) {
return eObject.eContents().stream().anyMatch(member -> !(member instanceof SystemOperationMode || member instanceof PropertyAssociation));
} else if (eObject instanceof PackageSection) {
return eObject.eContents().stream().anyMatch(member -> member instanceof Classifier || member instanceof AnnexLibrary);
} else if (eObject instanceof Classifier) {
return eObject.eContents().stream().anyMatch(member -> member instanceof ClassifierFeature || member instanceof PropertyAssociation);
} else {
return false;
}
}
}
use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.
the class AbstractInstanceOrDeclarativeModelReadOnlyHandler method doAaxlAction.
@Override
public final void doAaxlAction(final IProgressMonitor monitor, final Element obj) {
final NamedElement root = ((NamedElement) obj).getElementRoot();
if (root instanceof SystemInstance) {
final SystemInstance si = (SystemInstance) root;
final int whichMode;
if (si.getSystemOperationModes().size() > 1) {
whichMode = Dialog.askQuestion("Choose Mode", "Please choose in which mode(s) the model should be analyzed.", analyzeInSingleModeOnly() ? SINGLE_MODE_CHOICE_LABELS : ALL_MODE_CHOICE_LABELS, lastDefaultModeChoice);
} else {
// A system with no modes still has at least one SOM named NORMAL_SOM_NAME aka "no modes"
whichMode = INITIAL_MODE;
}
if (whichMode != -1) {
lastDefaultModeChoice = whichMode;
SystemOperationMode chosenSOM = null;
if (!si.getSystemOperationModes().isEmpty()) {
// the SOM list should not be empty
if (whichMode == INITIAL_MODE) {
// this may also be "No Modes" aka NORMAL_SOM_NAME
chosenSOM = si.getInitialSystemOperationMode();
} else if (whichMode == CHOOSE_MODE) {
final SOMChooserDialog somDialog = new SOMChooserDialog(getShell(), si, false);
if (somDialog.openThreadSafe() == Window.OK) {
chosenSOM = somDialog.getSOM();
} else {
return;
}
}
}
if (initializeAnalysis(si)) {
final AnalysisErrorReporterManager errManager = getErrorManager();
if (chosenSOM != null) {
analyzeInstanceModelInMode(monitor, errManager, si, chosenSOM);
} else {
final SOMIterator soms = new SOMIterator(si);
while (soms.hasNext()) {
final SystemOperationMode som = soms.nextSOM();
analyzeInstanceModelInMode(monitor, errManager, si, som);
}
}
finalizeAnalysis();
}
}
} else if (obj instanceof NamedElement) {
if (canAnalyzeDeclarativeModels()) {
Dialog.showError("Error", "Please select an instance model");
} else if (initializeAnalysis((NamedElement) obj)) {
analyzeDeclarativeModel(monitor, getErrorManager(), obj);
finalizeAnalysis();
}
}
}
Aggregations