use of org.osate.aadl2.SystemType in project arctic-sea by 52North.
the class SensorMLEncoderV101Test method should_encode_multiple_contacts_in_contactList.
@Test
public void should_encode_multiple_contacts_in_contactList() throws EncodingException {
final SensorML sensorML = new SensorML();
final System system = new System();
sensorML.addMember(system);
final SmlPerson contact1 = createPerson("1");
final SmlPerson contact2 = createPerson("2");
system.addContact(contact1);
system.addContact(contact2);
final SystemType xbSystem = encodeSystem(sensorML);
assertThat(xbSystem.sizeOfContactArray(), is(1));
assertThat(xbSystem.getContactArray(0).isSetContactList(), is(true));
final ContactList xbContactList = xbSystem.getContactArray(0).getContactList();
assertThat(xbContactList.sizeOfMemberArray(), is(2));
final Member member = xbContactList.getMemberArray(0);
final Member member2 = xbContactList.getMemberArray(1);
assertThat(member.isSetPerson(), is(true));
assertThat(member2.isSetPerson(), is(true));
if (member.getPerson().getName().equals(contact1.getName())) {
checkPerson(contact1, member.getPerson());
checkPerson(contact2, member2.getPerson());
} else {
checkPerson(contact1, member2.getPerson());
checkPerson(contact2, member.getPerson());
}
}
use of org.osate.aadl2.SystemType in project arctic-sea by 52North.
the class SensorMLEncoderV101Test method encodeSystem.
private SystemType encodeSystem(final SensorML sensorMl) throws EncodingException {
final XmlObject encodedSml = sensorMLEncoderv101.encode(sensorMl);
assertThat(encodedSml, instanceOf(SensorMLDocument.class));
final net.opengis.sensorML.x101.SensorMLDocument.SensorML xbSml = ((SensorMLDocument) encodedSml).getSensorML();
assertThat(xbSml.getMemberArray().length, is(1));
assertThat(xbSml.getMemberArray()[0].getProcess(), instanceOf(SystemType.class));
return (SystemType) xbSml.getMemberArray()[0].getProcess();
}
use of org.osate.aadl2.SystemType in project AMASE by loonwerks.
the class GenMCSHandler method runJob.
@Override
protected IStatus runJob(Element root, IProgressMonitor monitor) {
EphemeralImplementationUtil implUtil = new EphemeralImplementationUtil(monitor);
// this flag is set by the rerun handler to prevent clearing the advice map
if (!calledFromRerun) {
rerunAdviceMap.clear();
}
calledFromRerun = false;
disableRerunHandler();
handlerService = getWindow().getService(IHandlerService.class);
try {
// Make sure the user selected a component implementation
ComponentImplementation ci = getComponentImplementation(root, implUtil);
SystemInstance si = getSysInstance(ci, implUtil);
AnalysisResult result;
CompositeAnalysisResult wrapper = new CompositeAnalysisResult("");
// SystemType sysType = si.getSystemImplementation().getType();
ComponentType sysType = AgreeUtils.getInstanceType(si);
EList<AnnexSubclause> annexSubClauses = AnnexUtil.getAllAnnexSubclauses(sysType, AgreePackage.eINSTANCE.getAgreeContractSubclause());
if (annexSubClauses.size() == 0) {
throw new AgreeException("There is not an AGREE annex in the '" + sysType.getName() + "' system type.");
}
if (isRecursive()) {
if (AgreeUtils.usingKind2()) {
throw new AgreeException("Kind2 only supports monolithic verification");
}
result = buildAnalysisResult(((NamedElement) root).getName(), si);
wrapper.addChild(result);
result = wrapper;
} else if (isRealizability()) {
AgreeProgram agreeProgram = new AgreeASTBuilder().getAgreeProgram(si, false);
Program program = LustreAstBuilder.getRealizabilityLustreProgram(agreeProgram);
wrapper.addChild(createVerification("Realizability Check", si, program, agreeProgram, AnalysisType.Realizability));
result = wrapper;
} else {
wrapVerificationResult(si, wrapper);
result = wrapper;
}
showView(result, linker);
return doAnalysis(root, monitor, result, linker);
} catch (Throwable e) {
String messages = getNestedMessages(e);
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, messages, e);
} finally {
implUtil.cleanup();
}
}
use of org.osate.aadl2.SystemType in project osate-plugin by sireum.
the class AbstractSireumHandler method getElement.
private Element getElement(ExecutionEvent e) {
Element root = AadlUtil.getElement(getCurrentSelection(e));
if (root == null) {
root = SelectionHelper.getSelectedSystemImplementation();
}
if (root == null) {
ISelection selection = SelectionHelper.getSelection();
if (selection instanceof TreeSelection) {
TreeSelection ts = (TreeSelection) selection;
List<SystemImplementation> candidates = new ArrayList<>();
for (Object o : ts.toList()) {
if (o instanceof EObjectNode) {
EObjectNode eon = (EObjectNode) o;
EObject eo = SelectionHelper.getXtextEditor().getDocument().readOnly(resource -> {
return eon.getEObject(resource);
});
if (eo instanceof SystemImplementation) {
candidates.add((SystemImplementation) eo);
}
}
}
if (candidates.size() == 1) {
// selected items in outline view only include a single system implementation
// so use that
root = candidates.get(0);
}
} else if (selection instanceof TextSelection) {
TextSelection ts = (TextSelection) selection;
EObject selectedObject = SelectionHelper.getEObjectFromSelection(selection);
if (selectedObject instanceof SystemType) {
// cursor is probably in the xx part of 'system implementation xx.yy ...'
SystemType st = (SystemType) selectedObject;
// find all system implementations of st and see if the cursor
// is in one of them
AadlPackage ap = AadlUtil.getContainingPackage(st);
for (SystemImplementation si : EcoreUtil2.getAllContentsOfType(ap, SystemImplementation.class)) {
if (si.getType().equals(st)) {
INode node = NodeModelUtils.findActualNodeFor(si);
if (//
node != null && (//
node.getStartLine() <= ts.getStartLine() + 1 && ts.getEndLine() + 1 <= node.getEndLine())) {
root = si;
}
}
}
}
}
}
return root;
}
use of org.osate.aadl2.SystemType in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseSensorML.
@SuppressFBWarnings("BC_VACUOUS_INSTANCEOF")
private SensorML parseSensorML(final SensorMLDocument xbSensorML) throws DecodingException {
final SensorML sensorML = new SensorML();
// get member process
for (final Member xbMember : xbSensorML.getSensorML().getMemberArray()) {
if (xbMember.getProcess() != null) {
if (xbMember.getProcess() instanceof AbstractProcessType) {
final AbstractProcessType xbAbstractProcess = xbMember.getProcess();
AbstractProcess abstractProcess = null;
if (xbAbstractProcess.schemaType() == SystemType.type) {
abstractProcess = parseSystem((SystemType) xbAbstractProcess);
} else if (xbAbstractProcess.schemaType() == ProcessModelType.type) {
abstractProcess = parseProcessModel((ProcessModelType) xbAbstractProcess);
} else if (xbAbstractProcess.schemaType() == ComponentType.type) {
abstractProcess = parseComponent((ComponentType) xbAbstractProcess);
} else {
throw unsupportedMemberProcess(xbMember);
}
sensorML.addMember(abstractProcess);
} else {
throw unsupportedMemberProcess(xbMember);
}
} else {
throw new DecodingException(XmlHelper.getLocalName(xbMember), "The process of a member of the SensorML Document is null (%s)!", xbMember.getProcess());
}
}
sensorML.setXml(xbSensorML.xmlText(getXmlOptions()));
return sensorML;
}
Aggregations