Search in sources :

Example 6 with CompInstancePort

use of verdict.vdm.vdm_model.CompInstancePort in project VERDICT by ge-high-assurance.

the class Instrumentor method get_ports.

private HashSet<String> get_ports(Connection link) {
    HashSet<String> ports = new HashSet<String>();
    ConnectionEnd con_end = link.getSource();
    Port dest_port = con_end.getComponentPort();
    if (dest_port == null) {
        CompInstancePort instance_port = con_end.getSubcomponentPort();
        dest_port = instance_port.getPort();
    }
    ports.add(dest_port.getName());
    con_end = link.getDestination();
    dest_port = con_end.getComponentPort();
    if (dest_port == null) {
        CompInstancePort instance_port = con_end.getSubcomponentPort();
        dest_port = instance_port.getPort();
    }
    ports.add(dest_port.getName());
    return ports;
}
Also used : CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) Port(verdict.vdm.vdm_model.Port) ConnectionEnd(verdict.vdm.vdm_model.ConnectionEnd) HashSet(java.util.HashSet)

Example 7 with CompInstancePort

use of verdict.vdm.vdm_model.CompInstancePort in project VERDICT by ge-high-assurance.

the class VDMInstrumentor method retrieve_links.

protected boolean retrieve_links(ComponentType component, Connection connection, Port instrumented_port) {
    // Default Block Implementation
    ComponentImpl compImpl = retrieve_cmp_impl(component);
    // R.H.S
    ConnectionEnd src = connection.getSource();
    ComponentInstance src_componentInstance = new ComponentInstance();
    // Source Connection
    Port src_port = src.getComponentPort();
    if (src_port != null) {
        String identifier = compImpl.getId();
        // identifier = identifier.replace(".I", "_I");
        identifier = identifier.replace(".", "_dot_");
        identifier = identifier.replace("::", "_double_colon_");
        src_componentInstance.setId(identifier);
        src_componentInstance.setName(identifier);
        src_componentInstance.setImplementation(compImpl);
    }
    // if (src_port == instrumented_port) {
    CompInstancePort compInstancePort = src.getSubcomponentPort();
    if (compInstancePort != null) {
        src_componentInstance = compInstancePort.getSubcomponent();
        src_port = compInstancePort.getPort();
    }
    if (instrumented_port == src_port) {
        return true;
    }
    return false;
}
Also used : CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) Port(verdict.vdm.vdm_model.Port) ComponentInstance(verdict.vdm.vdm_model.ComponentInstance) ConnectionEnd(verdict.vdm.vdm_model.ConnectionEnd) ComponentImpl(verdict.vdm.vdm_model.ComponentImpl)

Example 8 with CompInstancePort

use of verdict.vdm.vdm_model.CompInstancePort in project VERDICT by ge-high-assurance.

the class VDMInstrumentor method ignoreMarkedLink.

// Ignore Connection or Marked Ports.
private boolean ignoreMarkedLink(Connection con) {
    ConnectionEnd srcConnection = con.getSource();
    ComponentType srcType = null;
    ConnectionEnd destConnection = con.getDestination();
    ComponentType destType = null;
    Port srcPort = srcConnection.getComponentPort();
    if (srcPort == null) {
        CompInstancePort compPort = srcConnection.getSubcomponentPort();
        srcPort = compPort.getPort();
        ComponentInstance srcCompInstance = compPort.getSubcomponent();
        srcType = srcCompInstance.getSpecification();
        if (srcType == null) {
            ComponentImpl compImpl = srcCompInstance.getImplementation();
            srcType = compImpl.getType();
        }
    }
    Port destPort = destConnection.getComponentPort();
    if (destPort == null) {
        CompInstancePort compPort = destConnection.getSubcomponentPort();
        destPort = compPort.getPort();
        ComponentInstance destCompInstance = compPort.getSubcomponent();
        destType = destCompInstance.getSpecification();
        if (destType == null) {
            ComponentImpl compImpl = destCompInstance.getImplementation();
            destType = compImpl.getType();
        }
    }
    if (this.marked_ports.contains(srcPort) || this.marked_ports.contains(destPort)) {
        System.out.println("Ignore Port Connection:" + con.getName());
        return true;
    }
    if (this.marked_types.contains(srcType) || this.marked_types.contains(destType)) {
        System.out.println("Ignore Instance Connection:" + con.getName());
        return true;
    }
    return false;
}
Also used : ComponentType(verdict.vdm.vdm_model.ComponentType) CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) Port(verdict.vdm.vdm_model.Port) ComponentInstance(verdict.vdm.vdm_model.ComponentInstance) ConnectionEnd(verdict.vdm.vdm_model.ConnectionEnd) ComponentImpl(verdict.vdm.vdm_model.ComponentImpl)

Example 9 with CompInstancePort

use of verdict.vdm.vdm_model.CompInstancePort in project VERDICT by ge-high-assurance.

the class VDM2Lustre method ignoreConnection.

// Ignore Connection or Marked Ports.
private boolean ignoreConnection(Connection con) {
    ConnectionEnd srcConnection = con.getSource();
    ComponentType srcType = null;
    ConnectionEnd destConnection = con.getDestination();
    ComponentType destType = null;
    Port srcPort = srcConnection.getComponentPort();
    if (srcPort == null) {
        CompInstancePort compPort = srcConnection.getSubcomponentPort();
        // System.out.println(">>>>>>>>" + con.getName());
        srcPort = compPort.getPort();
        ComponentInstance srcCompInstance = compPort.getSubcomponent();
        srcType = srcCompInstance.getSpecification();
        if (srcType == null) {
            ComponentImpl compImpl = srcCompInstance.getImplementation();
            srcType = compImpl.getType();
        }
    }
    Port destPort = destConnection.getComponentPort();
    if (destPort == null) {
        CompInstancePort compPort = destConnection.getSubcomponentPort();
        destPort = compPort.getPort();
        ComponentInstance destCompInstance = compPort.getSubcomponent();
        destType = destCompInstance.getSpecification();
        if (destType == null) {
            ComponentImpl compImpl = destCompInstance.getImplementation();
            destType = compImpl.getType();
        }
    }
    if (this.marked_ports.contains(srcPort) || this.marked_ports.contains(destPort)) {
        System.out.println("Ignore Port Connection:" + con.getName());
        return true;
    }
    if (this.marked_types.contains(srcType) || this.marked_types.contains(destType)) {
        System.out.println("Ignore Instance Connection:" + con.getName());
        return true;
    }
    return false;
}
Also used : ComponentType(verdict.vdm.vdm_model.ComponentType) CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) Port(verdict.vdm.vdm_model.Port) ComponentInstance(verdict.vdm.vdm_model.ComponentInstance) ConnectionEnd(verdict.vdm.vdm_model.ConnectionEnd) ComponentImpl(verdict.vdm.vdm_model.ComponentImpl)

Example 10 with CompInstancePort

use of verdict.vdm.vdm_model.CompInstancePort in project VERDICT by ge-high-assurance.

the class Vdm2Csv method getPortsAndIAsForMission.

private void getPortsAndIAsForMission(SafetyReqExpr inputSafetyExpr, String[] portsIAs, Map<String, List<ConnectionEnd>> connectionDestToSourceMap) {
    if (inputSafetyExpr.getKind() == null) {
        // get port's linked source instance
        if (connectionDestToSourceMap.containsKey(inputSafetyExpr.getPort().getName())) {
            List<ConnectionEnd> linkedSourcePorts = connectionDestToSourceMap.get(inputSafetyExpr.getPort().getName());
            if (linkedSourcePorts.size() > 1) {
                throw new RuntimeException("Multiple Linked Source Ports is unexpected for ports in cyber expression.");
            }
            if (linkedSourcePorts.get(0).getSubcomponentPort() != null) {
                CompInstancePort destCompPort = linkedSourcePorts.get(0).getSubcomponentPort();
                if (portsIAs[0].equalsIgnoreCase("")) {
                    portsIAs[0] = destCompPort.getSubcomponent().getName();
                    portsIAs[1] = destCompPort.getPort().getName();
                    // get IA
                    portsIAs[2] = formatToSmall(inputSafetyExpr.getPort().getIa().name());
                } else {
                    portsIAs[0] = portsIAs[0] + ";" + destCompPort.getSubcomponent().getName();
                    portsIAs[1] = portsIAs[1] + ";" + destCompPort.getPort().getName();
                    // get IA
                    portsIAs[2] = portsIAs[2] + ";" + formatToSmall(inputSafetyExpr.getPort().getIa().name());
                }
            } else {
                throw new RuntimeException("Linked Source Port has no instance information");
            }
        } else {
            throw new RuntimeException("Missing component instance dependency. " + inputSafetyExpr.getPort().getName() + " is not linked to a source port");
        }
    } else if (inputSafetyExpr.getKind().toString().equalsIgnoreCase("And")) {
        List<SafetyReqExpr> subInpSafetyList = inputSafetyExpr.getAnd().getExpr();
        for (SafetyReqExpr subInpSafetyExpr : subInpSafetyList) {
            getPortsAndIAsForMission(subInpSafetyExpr, portsIAs, connectionDestToSourceMap);
        }
    } else {
        throw new RuntimeException("VERDICT only supports DNF in safety requirements.");
    }
}
Also used : CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) SafetyReqExpr(verdict.vdm.vdm_model.SafetyReqExpr) ConnectionEnd(verdict.vdm.vdm_model.ConnectionEnd) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

CompInstancePort (verdict.vdm.vdm_model.CompInstancePort)13 ConnectionEnd (verdict.vdm.vdm_model.ConnectionEnd)12 Port (verdict.vdm.vdm_model.Port)9 ComponentImpl (verdict.vdm.vdm_model.ComponentImpl)6 ComponentInstance (verdict.vdm.vdm_model.ComponentInstance)6 ComponentType (verdict.vdm.vdm_model.ComponentType)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Expression (verdict.vdm.vdm_lustre.Expression)3 HashSet (java.util.HashSet)2 ContractItem (verdict.vdm.vdm_lustre.ContractItem)2 ContractSpec (verdict.vdm.vdm_lustre.ContractSpec)2 IfThenElse (verdict.vdm.vdm_lustre.IfThenElse)2 NodeCall (verdict.vdm.vdm_lustre.NodeCall)2 NodeEquation (verdict.vdm.vdm_lustre.NodeEquation)2 NodeEquationLHS (verdict.vdm.vdm_lustre.NodeEquationLHS)2 Connection (verdict.vdm.vdm_model.Connection)2 HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1