Search in sources :

Example 36 with SystemType

use of org.geotoolkit.sml.xml.v100.SystemType in project VERDICT by ge-high-assurance.

the class Agree2Vdm method populateVDMFromAadlAgreeObjects.

/**
 *  @param objects a List of AADL objects,
 * 	@param model an empty VDM model to populate
 *  @return a populated VDM model
 *  This method is invoked after preprocessAadlFiles and populateVDMFromAadlObjects,
 *  i.e., the aadl files are first parsed, translated into objects in preprocessAadlFiles(),
 *  then VDM is populated with objects corresponding to AADL constructs in populateVDMFromAadlObjects(),
 *  then this method is invoked to populate the agree constructs in the vdm model
 */
public Model populateVDMFromAadlAgreeObjects(List<EObject> objects, Model model) {
    HashSet<String> dataTypeDecl = getTypeDeclarationsAsHashSet(model);
    HashSet<String> nodeDecl = new HashSet<String>();
    // variables for extracting data from the AADL object
    List<SystemType> systemTypes = new ArrayList<>();
    List<SystemImplementation> systemImplementations = new ArrayList<>();
    // extracting data from the AADLObject
    for (EObject obj : objects) {
        if (obj instanceof SystemType) {
            // obtaining system Types
            systemTypes.add((SystemType) obj);
        } else if (obj instanceof SystemImplementation) {
            systemImplementations.add((SystemImplementation) obj);
        }
    }
    // end of extracting data from the AADLObjec
    /* Translating agree annex in System Types */
    model = translateAgreeAnnex(systemTypes, systemImplementations, model, dataTypeDecl, nodeDecl);
    // return the final model
    return model;
}
Also used : SystemImplementation(org.osate.aadl2.SystemImplementation) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) SystemType(org.osate.aadl2.SystemType) HashSet(java.util.HashSet)

Example 37 with SystemType

use of org.geotoolkit.sml.xml.v100.SystemType in project VERDICT by ge-high-assurance.

the class VerdictUtil method getEvents.

/**
 * Get the (linked) set of all cyber requirements in the AADL AST of which obj is part.
 *
 * @param obj
 * @return
 */
public static Set<String> getEvents(EObject obj) {
    Set<String> cyberReqs = new LinkedHashSet<>();
    // Find public package section
    EObject container = obj;
    while (container != null && !(container instanceof PublicPackageSection)) {
        container = container.eContainer();
    }
    PublicPackageSection pack = (PublicPackageSection) container;
    if (pack != null && pack.getOwnedClassifiers() != null) {
        // Find all systems
        for (Classifier cls : pack.getOwnedClassifiers()) {
            if (cls instanceof SystemType) {
                SystemType system = (SystemType) cls;
                // Get all verdict annexes for this system
                for (AnnexSubclause annex : system.getOwnedAnnexSubclauses()) {
                    if ("verdict".equals(annex.getName())) {
                        Verdict subclause = VerdictUtil.getVerdict(annex);
                        // Get all cyber req IDs
                        for (Statement statement : subclause.getElements()) {
                            if (statement instanceof CyberReq) {
                                cyberReqs.add(statement.getId());
                            }
                        }
                    }
                }
            }
        }
    }
    return cyberReqs;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PublicPackageSection(org.osate.aadl2.PublicPackageSection) CyberReq(com.ge.research.osate.verdict.dsl.verdict.CyberReq) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) EObject(org.eclipse.emf.ecore.EObject) SystemType(org.osate.aadl2.SystemType) Classifier(org.osate.aadl2.Classifier) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) AnnexSubclause(org.osate.aadl2.AnnexSubclause) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict)

Example 38 with SystemType

use of org.geotoolkit.sml.xml.v100.SystemType in project VERDICT by ge-high-assurance.

the class VerdictUtil method getAllReqs.

/**
 * Get the (linked) set of all cyber requirements in the AADL AST of which obj is part.
 *
 * @param obj
 * @return
 */
public static Set<String> getAllReqs(EObject obj) {
    Set<String> reqs = new LinkedHashSet<>();
    // Find public package section
    EObject container = obj;
    while (container != null && !(container instanceof PublicPackageSection)) {
        container = container.eContainer();
    }
    PublicPackageSection pack = (PublicPackageSection) container;
    if (pack != null && pack.getOwnedClassifiers() != null) {
        // Find all systems
        for (Classifier cls : pack.getOwnedClassifiers()) {
            if (cls instanceof SystemType) {
                SystemType system = (SystemType) cls;
                // Get all verdict annexes for this system
                for (AnnexSubclause annex : system.getOwnedAnnexSubclauses()) {
                    if ("verdict".equals(annex.getName())) {
                        Verdict subclause = VerdictUtil.getVerdict(annex);
                        // Get all cyber req IDs
                        for (Statement statement : subclause.getElements()) {
                            if (statement instanceof CyberReq) {
                                reqs.add(statement.getId());
                            } else if (statement instanceof SafetyReq) {
                                reqs.add(statement.getId());
                            }
                        }
                    }
                }
            }
        }
    }
    return reqs;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PublicPackageSection(org.osate.aadl2.PublicPackageSection) CyberReq(com.ge.research.osate.verdict.dsl.verdict.CyberReq) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) EObject(org.eclipse.emf.ecore.EObject) SystemType(org.osate.aadl2.SystemType) Classifier(org.osate.aadl2.Classifier) SafetyReq(com.ge.research.osate.verdict.dsl.verdict.SafetyReq) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) AnnexSubclause(org.osate.aadl2.AnnexSubclause) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict)

Example 39 with SystemType

use of org.geotoolkit.sml.xml.v100.SystemType in project VERDICT by ge-high-assurance.

the class VerdictUtil method getAvailablePorts.

/**
 * Finds all input/output ports for the system enclosing an LPort.
 *
 * Automatically detects if the ports should be input or output based
 * on the context (if possible).
 *
 * Requires: port must be an LPort or inside a CyberRel/CyberReq
 *
 * @param port the AST object from which to search up the tree
 * @param allowSkipInput used in the proposal provider because model
 *        is not necessarily where we expect it to be
 * @return the ports info (see AvailablePortsInfo)
 */
public static AvailablePortsInfo getAvailablePorts(EObject port, boolean allowSkipInput, DirectionType specifiedDir) {
    List<String> ports = new ArrayList<>();
    SystemType system = null;
    DirectionType dir = null;
    // Determine direction
    EObject container = port;
    while (!(container instanceof CyberRelInputLogic || container instanceof CyberRelOutputLogic || container instanceof CyberReqConditionLogic || container instanceof CyberRel || container instanceof CyberReq || container instanceof SafetyRelInputLogic || container instanceof SafetyRelOutputLogic || container instanceof SafetyReqConditionLogic || container instanceof SafetyRel || container instanceof SafetyReq || container instanceof SystemType || container instanceof PublicPackageSection)) {
        if (container == null) {
            break;
        }
        container = container.eContainer();
    }
    if (container instanceof CyberRelInputLogic) {
        dir = DirectionType.IN;
    } else if (container instanceof CyberRelOutputLogic) {
        dir = DirectionType.OUT;
    } else if (container instanceof CyberReqConditionLogic) {
        dir = DirectionType.OUT;
    } else if (container instanceof SafetyRelInputLogic) {
        dir = DirectionType.IN;
    } else if (container instanceof SafetyRelOutputLogic) {
        dir = DirectionType.OUT;
    } else if (container instanceof SafetyReqConditionLogic) {
        dir = DirectionType.OUT;
    } else {
        // If allowSkipInput is true, then we will simply collect both input and output
        if (!allowSkipInput) {
            throw new RuntimeException();
        }
    }
    while (!(container instanceof CyberRel || container instanceof CyberReq || container instanceof SafetyReq || container instanceof SafetyRel || container instanceof Event || container instanceof SystemType || container instanceof PublicPackageSection)) {
        if (container == null) {
            break;
        }
        container = container.eContainer();
    }
    boolean isCyberReq;
    if (container instanceof CyberReq) {
        isCyberReq = true;
    } else if (container instanceof CyberRel) {
        isCyberReq = false;
    } else if (container instanceof SafetyReq) {
        isCyberReq = false;
    } else if (container instanceof SafetyRel) {
        isCyberReq = false;
    } else if (container instanceof Event) {
        isCyberReq = false;
    } else {
        if (specifiedDir == null) {
            throw new RuntimeException();
        } else {
            dir = specifiedDir;
            isCyberReq = false;
        }
    }
    while (!(container instanceof SystemType || container instanceof PublicPackageSection)) {
        if (container == null) {
            break;
        }
        container = container.eContainer();
    }
    if (container instanceof SystemType) {
        system = (SystemType) container;
        while (!(container instanceof SystemType || container instanceof PublicPackageSection)) {
            container = container.eContainer();
        }
        if (container instanceof SystemType) {
            // Find all data(event data) ports
            for (DataPort dataPort : ((SystemType) container).getOwnedDataPorts()) {
                if ((dir != null && dataPort.getDirection().equals(dir)) || (dir == null && (dataPort.getDirection().equals(DirectionType.IN) || dataPort.getDirection().equals(DirectionType.OUT)))) {
                    ports.add(dataPort.getName());
                }
            }
            for (EventDataPort eventDataPort : ((SystemType) container).getOwnedEventDataPorts()) {
                if ((dir != null && eventDataPort.getDirection().equals(dir)) || (dir == null && (eventDataPort.getDirection().equals(DirectionType.IN) || eventDataPort.getDirection().equals(DirectionType.OUT)))) {
                    ports.add(eventDataPort.getName());
                }
            }
        }
    }
    return new AvailablePortsInfo(ports, system, dir == null || dir.equals(DirectionType.IN), isCyberReq);
}
Also used : CyberRel(com.ge.research.osate.verdict.dsl.verdict.CyberRel) CyberReq(com.ge.research.osate.verdict.dsl.verdict.CyberReq) CyberReqConditionLogic(com.ge.research.osate.verdict.dsl.verdict.CyberReqConditionLogic) CyberRelOutputLogic(com.ge.research.osate.verdict.dsl.verdict.CyberRelOutputLogic) ArrayList(java.util.ArrayList) SafetyRelOutputLogic(com.ge.research.osate.verdict.dsl.verdict.SafetyRelOutputLogic) SystemType(org.osate.aadl2.SystemType) CyberRelInputLogic(com.ge.research.osate.verdict.dsl.verdict.CyberRelInputLogic) SafetyRelInputLogic(com.ge.research.osate.verdict.dsl.verdict.SafetyRelInputLogic) DirectionType(org.osate.aadl2.DirectionType) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) PublicPackageSection(org.osate.aadl2.PublicPackageSection) SafetyRel(com.ge.research.osate.verdict.dsl.verdict.SafetyRel) EObject(org.eclipse.emf.ecore.EObject) Event(com.ge.research.osate.verdict.dsl.verdict.Event) EventDataPort(org.osate.aadl2.EventDataPort) SafetyReqConditionLogic(com.ge.research.osate.verdict.dsl.verdict.SafetyReqConditionLogic) SafetyReq(com.ge.research.osate.verdict.dsl.verdict.SafetyReq)

Example 40 with SystemType

use of org.geotoolkit.sml.xml.v100.SystemType in project AGREE by loonwerks.

the class EphemeralImplementationUtil method createComponentImplementationInternal.

/**
 * Internal method to actually create the ephemeral component implementation and containing resource.
 * <p>
 * This method is intended to by invoked only from the command stack so that editing permissions are managed
 * through the transactional editing domain.
 *
 * @param ct The {@link ComponentType} for which to create an ephemeral implementation.
 * @param aadlResource The {@link Resource} in which to place the ephemeral implementation and it containing
 *     {@link AadlPackage}.
 * @return A {@link ComponentImplementation} matching the given component type.
 * @throws InterruptedException
 */
private ComponentImplementation createComponentImplementationInternal(ComponentType ct, Resource aadlResource) throws InterruptedException {
    // Create a package and public section to contain the created
    // component implementation
    AadlPackage aadlPackage = Aadl2Factory.eINSTANCE.createAadlPackage();
    aadlPackage.setName(aadlResource.getURI().trimFragment().trimFileExtension().lastSegment().toString());
    PublicPackageSection publicSection = aadlPackage.createOwnedPublicSection();
    // Add import for package containing ct
    AadlPackage ctPackage = (AadlPackage) AgreeUtils.getClosestContainerOfType(ct, AadlPackage.class);
    publicSection.getImportedUnits().add(ctPackage);
    // Add renames clause to make linking to ct easy
    PackageRename ctRename = publicSection.createOwnedPackageRename();
    ctRename.setName("");
    ctRename.setRenamedPackage(ctPackage);
    ctRename.setRenameAll(true);
    // Create the component implementation in the public section
    ComponentImplementation compImpl;
    if (ct instanceof ThreadType) {
        compImpl = (ComponentImplementation) publicSection.createOwnedClassifier(Aadl2Package.eINSTANCE.getThreadImplementation());
    } else if (ct instanceof ThreadGroupType) {
        compImpl = (ComponentImplementation) publicSection.createOwnedClassifier(Aadl2Package.eINSTANCE.getThreadGroupImplementation());
    } else if (ct instanceof ProcessType) {
        compImpl = (ComponentImplementation) publicSection.createOwnedClassifier(Aadl2Package.eINSTANCE.getProcessImplementation());
    } else if (ct instanceof SubprogramType) {
        compImpl = (ComponentImplementation) publicSection.createOwnedClassifier(Aadl2Package.eINSTANCE.getSubprogramImplementation());
    } else if (ct instanceof ProcessorType) {
        compImpl = (ComponentImplementation) publicSection.createOwnedClassifier(Aadl2Package.eINSTANCE.getProcessorImplementation());
    } else if (ct instanceof BusType) {
        compImpl = (ComponentImplementation) publicSection.createOwnedClassifier(Aadl2Package.eINSTANCE.getBusImplementation());
    } else if (ct instanceof DeviceType) {
        compImpl = (ComponentImplementation) publicSection.createOwnedClassifier(Aadl2Package.eINSTANCE.getDeviceImplementation());
    } else if (ct instanceof SystemType) {
        compImpl = (ComponentImplementation) publicSection.createOwnedClassifier(Aadl2Package.eINSTANCE.getSystemImplementation());
    } else {
        throw new AgreeException("Unhandled component type: " + ct.getClass().toString());
    }
    compImpl.setType(ct);
    compImpl.setName(ct.getName() + ".wrapper");
    // Add the package and its contents to the resource
    aadlResource.getContents().add(aadlPackage);
    // IResource as we build it.
    try {
        aadlResource.save(null);
    } catch (IOException e) {
        e.printStackTrace();
        setErrorMessage(e.getMessage());
        return null;
    } catch (NullPointerException npe) {
        npe.printStackTrace();
        setErrorMessage(npe.getMessage());
        npe.getMessage();
        return null;
    // } catch (InterruptedException e) {
    // throw e;
    } catch (Exception e) {
        e.printStackTrace();
        errorMessage = e.getMessage();
        e.getMessage();
        return null;
    }
    return compImpl;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ThreadGroupType(org.osate.aadl2.ThreadGroupType) AadlPackage(org.osate.aadl2.AadlPackage) BusType(org.osate.aadl2.BusType) ProcessorType(org.osate.aadl2.ProcessorType) SystemType(org.osate.aadl2.SystemType) IOException(java.io.IOException) RollbackException(org.eclipse.emf.transaction.RollbackException) IOException(java.io.IOException) DeviceType(org.osate.aadl2.DeviceType) ProcessType(org.osate.aadl2.ProcessType) PublicPackageSection(org.osate.aadl2.PublicPackageSection) ThreadType(org.osate.aadl2.ThreadType) PackageRename(org.osate.aadl2.PackageRename) SubprogramType(org.osate.aadl2.SubprogramType)

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)14 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)13 ArrayList (java.util.ArrayList)12 System (org.n52.shetland.ogc.sensorML.System)11 EObject (org.eclipse.emf.ecore.EObject)9 SensorML (org.n52.shetland.ogc.sensorML.SensorML)9 AnnexSubclause (org.osate.aadl2.AnnexSubclause)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 SystemImplementation (org.osate.aadl2.SystemImplementation)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