Search in sources :

Example 21 with Port

use of verdict.vdm.vdm_model.Port 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 22 with Port

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

the class VDMInstrumentor method identifyEmptyOutputComponents.

protected void identifyEmptyOutputComponents() {
    for (ComponentType componentType : this.vdm_model.getComponentType()) {
        Port mPort = markPort(componentType);
        if (mPort != null) {
            // System.out.println("Ignoring Node:" + componentType.getName());
            System.out.println("Ignoring Port Instrumentation:" + mPort.getName());
            this.marked_types.add(componentType);
            this.marked_ports.add(mPort);
        }
    }
}
Also used : ComponentType(verdict.vdm.vdm_model.ComponentType) CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) Port(verdict.vdm.vdm_model.Port)

Example 23 with Port

use of verdict.vdm.vdm_model.Port 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 24 with Port

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

the class VDM2Lustre method visit.

public void visit(Model vdm_model, LustreProgram program) {
    // A) Copying Type Declaration + amend name '_Impl
    for (TypeDeclaration typeDec : vdm_model.getTypeDeclaration()) {
        visit(typeDec, program);
    }
    // Copying over Constant Declarations
    for (ConstantDeclaration constDec : program.getConstantDeclaration()) {
        String constName = constDec.getName();
        constName = constName.replace(".", "_dot_");
        constName = constName.replace("::", "_double_colon_");
        constDec.setName(constName);
        visit(constDec);
    }
    // Event Ports
    for (ComponentType componentType : vdm_model.getComponentType()) {
        // Collect Node with no output
        Port mPort = markPort(componentType);
        if (mPort == null) {
            // Event Ports to Data Ports;
            for (Port port : componentType.getPort()) {
                // Update event_ports
                visit(port, program);
            }
        } else {
            System.out.println("Ignoring Node:" + componentType.getName());
            System.out.println("Ignoring Port:" + mPort.getName());
            this.marked_types.add(componentType);
            this.marked_ports.add(mPort);
        }
    }
    // B) Component Type
    Node cmp_node = null;
    Node impl_node = null;
    String inst_cmp = "(.+)_Inst_.*";
    Pattern inst_pattern = Pattern.compile(inst_cmp);
    for (ComponentType componentType : vdm_model.getComponentType()) {
        boolean is_declared = false;
        if (!this.marked_types.contains(componentType)) {
            for (ComponentImpl componentImpl : vdm_model.getComponentImpl()) {
                if (componentType == componentImpl.getType()) {
                    impl_node = visit(componentType, true);
                    visit(componentImpl, impl_node);
                    is_declared = true;
                    break;
                }
            }
            if (is_declared) {
                cmp_node = visit(componentType, false);
                Matcher m = inst_pattern.matcher(cmp_node.getName());
                if (m.matches() == false) {
                    program.getNodeDeclaration().add(cmp_node);
                }
                program.getNodeDeclaration().add(impl_node);
            } else {
                cmp_node = visit(componentType, false);
                program.getNodeDeclaration().add(cmp_node);
            }
        }
    }
    // Copying over Node Declarations.
    for (Node node_dec : program.getNodeDeclaration()) {
        visit(node_dec, program);
    }
    // Copy over Contract Spec.
    for (Contract contract : program.getContractDeclaration()) {
        visit(contract, program);
    }
}
Also used : Pattern(java.util.regex.Pattern) ComponentType(verdict.vdm.vdm_model.ComponentType) Matcher(java.util.regex.Matcher) CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) Port(verdict.vdm.vdm_model.Port) Node(verdict.vdm.vdm_lustre.Node) ConstantDeclaration(verdict.vdm.vdm_lustre.ConstantDeclaration) TypeDeclaration(verdict.vdm.vdm_data.TypeDeclaration) ComponentImpl(verdict.vdm.vdm_model.ComponentImpl) Contract(verdict.vdm.vdm_lustre.Contract)

Example 25 with Port

use of verdict.vdm.vdm_model.Port 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)

Aggregations

Port (verdict.vdm.vdm_model.Port)36 EventDataPort (org.osate.aadl2.EventDataPort)20 EventPort (org.osate.aadl2.EventPort)20 DataPort (org.osate.aadl2.DataPort)19 CompInstancePort (verdict.vdm.vdm_model.CompInstancePort)16 ArrayList (java.util.ArrayList)12 CyberMission (com.ge.research.osate.verdict.dsl.verdict.CyberMission)11 CyberRel (com.ge.research.osate.verdict.dsl.verdict.CyberRel)11 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)11 Event (com.ge.research.osate.verdict.dsl.verdict.Event)11 SafetyRel (com.ge.research.osate.verdict.dsl.verdict.SafetyRel)11 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)11 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)11 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)11 AnnexSubclause (org.osate.aadl2.AnnexSubclause)11 LPort (com.ge.research.osate.verdict.dsl.verdict.LPort)9 SLPort (com.ge.research.osate.verdict.dsl.verdict.SLPort)9 ComponentImpl (verdict.vdm.vdm_model.ComponentImpl)9 ComponentType (verdict.vdm.vdm_model.ComponentType)9 BusAccess (org.osate.aadl2.BusAccess)8