Search in sources :

Example 11 with PublicPackageSection

use of org.osate.aadl2.PublicPackageSection 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 12 with PublicPackageSection

use of org.osate.aadl2.PublicPackageSection 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 13 with PublicPackageSection

use of org.osate.aadl2.PublicPackageSection in project osate2 by osate.

the class AadlPackageImpl method basicSetOwnedPublicSection.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetOwnedPublicSection(PublicPackageSection newOwnedPublicSection, NotificationChain msgs) {
    PublicPackageSection oldOwnedPublicSection = ownedPublicSection;
    ownedPublicSection = newOwnedPublicSection;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Aadl2Package.AADL_PACKAGE__OWNED_PUBLIC_SECTION, oldOwnedPublicSection, newOwnedPublicSection);
        if (msgs == null) {
            msgs = notification;
        } else {
            msgs.add(notification);
        }
    }
    Resource.Internal eInternalResource = eInternalResource();
    if (eInternalResource == null || !eInternalResource.isLoading()) {
        if (newOwnedPublicSection != null) {
            if (newOwnedPublicSection != publicSection) {
                setPublicSection(newOwnedPublicSection);
            }
        }
    }
    return msgs;
}
Also used : PublicPackageSection(org.osate.aadl2.PublicPackageSection) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Resource(org.eclipse.emf.ecore.resource.Resource)

Example 14 with PublicPackageSection

use of org.osate.aadl2.PublicPackageSection in project osate2 by osate.

the class AadlPackageImpl method setPublicSection.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public void setPublicSection(PublicPackageSection newPublicSection) {
    PublicPackageSection oldPublicSection = publicSection;
    publicSection = newPublicSection;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, Aadl2Package.AADL_PACKAGE__PUBLIC_SECTION, oldPublicSection, publicSection));
    }
}
Also used : PublicPackageSection(org.osate.aadl2.PublicPackageSection) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 15 with PublicPackageSection

use of org.osate.aadl2.PublicPackageSection in project osate2 by osate.

the class AadlPackageImpl method createOwnedPublicSection.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public PublicPackageSection createOwnedPublicSection() {
    PublicPackageSection newOwnedPublicSection = (PublicPackageSection) create(Aadl2Package.eINSTANCE.getPublicPackageSection());
    setOwnedPublicSection(newOwnedPublicSection);
    return newOwnedPublicSection;
}
Also used : PublicPackageSection(org.osate.aadl2.PublicPackageSection)

Aggregations

PublicPackageSection (org.osate.aadl2.PublicPackageSection)15 SystemType (org.osate.aadl2.SystemType)8 AadlPackage (org.osate.aadl2.AadlPackage)7 Classifier (org.osate.aadl2.Classifier)7 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)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 EObject (org.eclipse.emf.ecore.EObject)4 AnnexSubclause (org.osate.aadl2.AnnexSubclause)4 CyberRel (com.ge.research.osate.verdict.dsl.verdict.CyberRel)3 Event (com.ge.research.osate.verdict.dsl.verdict.Event)3 SafetyRel (com.ge.research.osate.verdict.dsl.verdict.SafetyRel)3 HashMap (java.util.HashMap)3 AnnexLibrary (org.osate.aadl2.AnnexLibrary)3 CyberMission (com.ge.research.osate.verdict.dsl.verdict.CyberMission)2 ThreatStatement (com.ge.research.osate.verdict.dsl.verdict.ThreatStatement)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2