Search in sources :

Example 1 with CyberRelInputLogic

use of com.ge.research.osate.verdict.dsl.verdict.CyberRelInputLogic in project VERDICT by ge-high-assurance.

the class WzrdTableLoader method getTableRow.

// Store existing cyber-relation into a data-structure
private WzrdTableRow getTableRow(Statement stmt) {
    WzrdTableRow tableRow = new WzrdTableRow();
    tableRow.setFormulaID(stmt.getId());
    tableRow.setNewRow(false);
    tableRow.setComment(((CyberRelImpl) stmt).getComment());
    tableRow.setDescription(((CyberRelImpl) stmt).getDescription());
    // tableRow.setExternal(((CyberRelImpl) stmt).getExternal());
    // tableRow.setPhase(((CyberRelImpl) stmt).getPhases());
    List<EObject> objList = stmt.eContents();
    for (int j = 0; j < objList.size(); j++) {
        EObject objInst = objList.get(j);
        if (objInst instanceof CyberRelOutputLogic) {
            CyberRelOutputLogic rhs = (CyberRelOutputLogic) objInst;
            LPort lp = rhs.getValue();
            tableRow.setFirstElement(drpdn.findIndex(drpdn.outPorts, lp.getPort()));
            tableRow.setSecondElement(drpdn.findIndex(drpdn.CIA_ABBREV, lp.getCia().getLiteral()));
        } else if (objInst instanceof CyberRelInputLogic) {
            ISerializer serializer = VerdictActivator.getInstance().getInjector(VerdictUiModule.INJECTOR_NAME).getInstance(VerdictSerializer.class);
            tableRow.setThirdElement(serializer.serialize(objInst));
        }
    }
    if (tableRow.getThirdElement() == null) {
        tableRow.setThirdElement("TRUE");
    }
    return tableRow;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) CyberRelOutputLogic(com.ge.research.osate.verdict.dsl.verdict.CyberRelOutputLogic) LPort(com.ge.research.osate.verdict.dsl.verdict.LPort) CyberRelInputLogic(com.ge.research.osate.verdict.dsl.verdict.CyberRelInputLogic) ISerializer(org.eclipse.xtext.serializer.ISerializer) VerdictSerializer(com.ge.research.osate.verdict.dsl.serializer.VerdictSerializer)

Example 2 with CyberRelInputLogic

use of com.ge.research.osate.verdict.dsl.verdict.CyberRelInputLogic 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)

Aggregations

CyberRelInputLogic (com.ge.research.osate.verdict.dsl.verdict.CyberRelInputLogic)2 CyberRelOutputLogic (com.ge.research.osate.verdict.dsl.verdict.CyberRelOutputLogic)2 EObject (org.eclipse.emf.ecore.EObject)2 VerdictSerializer (com.ge.research.osate.verdict.dsl.serializer.VerdictSerializer)1 CyberRel (com.ge.research.osate.verdict.dsl.verdict.CyberRel)1 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)1 CyberReqConditionLogic (com.ge.research.osate.verdict.dsl.verdict.CyberReqConditionLogic)1 Event (com.ge.research.osate.verdict.dsl.verdict.Event)1 LPort (com.ge.research.osate.verdict.dsl.verdict.LPort)1 SafetyRel (com.ge.research.osate.verdict.dsl.verdict.SafetyRel)1 SafetyRelInputLogic (com.ge.research.osate.verdict.dsl.verdict.SafetyRelInputLogic)1 SafetyRelOutputLogic (com.ge.research.osate.verdict.dsl.verdict.SafetyRelOutputLogic)1 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)1 SafetyReqConditionLogic (com.ge.research.osate.verdict.dsl.verdict.SafetyReqConditionLogic)1 ArrayList (java.util.ArrayList)1 ISerializer (org.eclipse.xtext.serializer.ISerializer)1 DataPort (org.osate.aadl2.DataPort)1 DirectionType (org.osate.aadl2.DirectionType)1 EventDataPort (org.osate.aadl2.EventDataPort)1 PublicPackageSection (org.osate.aadl2.PublicPackageSection)1