Search in sources :

Example 16 with SystemType

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());
    }
}
Also used : SystemType(net.opengis.sensorML.x101.SystemType) ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SensorML(org.n52.shetland.ogc.sensorML.SensorML) Member(net.opengis.sensorML.x101.ContactListDocument.ContactList.Member) System(org.n52.shetland.ogc.sensorML.System) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Test(org.junit.jupiter.api.Test)

Example 17 with SystemType

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();
}
Also used : SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) XmlObject(org.apache.xmlbeans.XmlObject) SystemType(net.opengis.sensorML.x101.SystemType)

Example 18 with SystemType

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();
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ComponentType(org.osate.aadl2.ComponentType) Program(jkind.lustre.Program) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) EphemeralImplementationUtil(com.rockwellcollins.atc.agree.analysis.EphemeralImplementationUtil) AnalysisResult(jkind.api.results.AnalysisResult) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult) IHandlerService(org.eclipse.ui.handlers.IHandlerService) AgreeASTBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeASTBuilder) SystemInstance(org.osate.aadl2.instance.SystemInstance) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) NamedElement(org.osate.aadl2.NamedElement) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 19 with SystemType

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;
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) AadlPackage(org.osate.aadl2.AadlPackage) TextSelection(org.eclipse.jface.text.TextSelection) Element(org.osate.aadl2.Element) ArrayList(java.util.ArrayList) SystemType(org.osate.aadl2.SystemType) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) SystemImplementation(org.osate.aadl2.SystemImplementation) EObject(org.eclipse.emf.ecore.EObject) ISelection(org.eclipse.jface.viewers.ISelection) EObject(org.eclipse.emf.ecore.EObject)

Example 20 with SystemType

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;
}
Also used : AbstractProcessType(net.opengis.sensorML.x101.AbstractProcessType) AbstractComponentType(net.opengis.sensorML.x101.AbstractComponentType) AbstractDerivableComponentType(net.opengis.sensorML.x101.AbstractDerivableComponentType) ComponentType(net.opengis.sensorML.x101.ComponentType) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SensorML(org.n52.shetland.ogc.sensorML.SensorML) AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

SystemType (net.opengis.sensorML.x101.SystemType)24 Test (org.junit.jupiter.api.Test)18 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)15 SystemType (org.osate.aadl2.SystemType)15 ArrayList (java.util.ArrayList)13 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)13 System (org.n52.shetland.ogc.sensorML.System)11 EObject (org.eclipse.emf.ecore.EObject)10 SensorML (org.n52.shetland.ogc.sensorML.SensorML)9 AnnexSubclause (org.osate.aadl2.AnnexSubclause)9 SystemImplementation (org.osate.aadl2.SystemImplementation)8 IdentifierList (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)6 PublicPackageSection (org.osate.aadl2.PublicPackageSection)6 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)5 HashSet (java.util.HashSet)5 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)4 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)4 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)4 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)4 SmlPerson (org.n52.shetland.ogc.sensorML.SmlPerson)4