Search in sources :

Example 31 with ComponentImpl

use of verdict.vdm.vdm_model.ComponentImpl 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 32 with ComponentImpl

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

the class Vdm2Csv method execute.

/**
 * @param VDM
 * @param stem directory
 * @param soteria directory
 * @param model name i.e., project directory name
 * 1. Initialize tables with headers if they have static headers
 * 2. Build tables for STEM:
 *        ScnCompProps.csv, ScnConnections.csv, ScnBusBindings.csv
 * 3. Build tables for Soteria++:
 *        CompDep.csv, Mission.csv, CompSaf.csv,
 *        Events.csv, ScnCompProps.csv, ScnConnections.csv
 * 4. Output the csv files
 */
public void execute(Model vdm, String stemDir, String soteriaDir, String modelName) {
    Table eventsTable = new Table("QualifiedName", "SanitizedQualifiedName", "PackageName", "Comp", "Event", "Probability");
    Table compSafTable = new Table("QualifiedName", "SanitizedQualifiedName", "PackageName", "Comp", "InputPortOrEvent", "InputIAOrEvent", "OutputPort", "OutputIA");
    Table compDepTable = new Table("QualifiedName", "SanitizedQualifiedName", "PackageName", "Comp", "InputPort", "InputCIA", "OutputPort", "OutputCIA");
    Table missionTable = new Table("ModelVersion", "MissionReqId", "MissionReq", "ReqId", "Req", "MissionImpactCIA", "Effect", "Severity", "CompInstanceDependency", "CompOutputDependency", "DependentCompOutputCIA", "ReqType");
    List<ComponentImpl> compImpls = vdm.getComponentImpl();
    // map(property_name, hash_set_of_connections)
    Map<String, HashSet<String>> propToConnections = new HashMap<>();
    // create map for connection names to attributes names and attribute names to attribute value
    Map<String, HashMap<String, String>> connectionAttributesMap = new HashMap<>();
    // map(property_name, hash_set_of_components)
    Map<String, HashSet<String>> propToCompInsts = new HashMap<>();
    // create map for component names to attributes names and attribute names to attribute value
    Map<String, HashMap<String, String>> compInstAttributesMap = new HashMap<>();
    Map<String, String> compToCompImpl = new HashMap<>();
    Map<String, List<ConnectionEnd>> connectionDestToSourceMap = new HashMap<>();
    // pre-process component implementations info in the VDM and update maps propToConnections, connectionAttributesMap, compToCompImpl, compInstAttributesMap
    // these maps will be used to build tables scnConnTable and scnCompPropsTable
    preprocessCompImpls(compImpls, modelName, propToConnections, connectionAttributesMap, compToCompImpl, propToCompInsts, compInstAttributesMap, connectionDestToSourceMap);
    Table scnConnTable = updateConnectionsTable(compImpls, modelName, propToConnections, connectionAttributesMap, compToCompImpl);
    Table scnBusBindingsTable = updateBusBindingsTable(compImpls, modelName, compToCompImpl);
    Table scnCompPropsTable = updateCompInstTable(compImpls, modelName, propToCompInsts, compInstAttributesMap, compToCompImpl);
    // build events, compDep, compSaf, mission tables
    updateTablesWithDataFromVDM(vdm, modelName, eventsTable, compDepTable, compSafTable, missionTable, connectionDestToSourceMap);
    // create CSVs for STEM and Soteria++
    // For STEM
    scnCompPropsTable.toCsvFile(new File(stemDir, "ScnCompProps.csv"));
    scnConnTable.toCsvFile(new File(stemDir, "ScnConnections.csv"));
    scnBusBindingsTable.toCsvFile(new File(stemDir, "ScnBusBindings.csv"));
    // For Soteria++
    eventsTable.toCsvFile(new File(soteriaDir, "Events.csv"));
    compSafTable.toCsvFile(new File(soteriaDir, "CompSaf.csv"));
    compDepTable.toCsvFile(new File(soteriaDir, "CompDep.csv"));
    missionTable.toCsvFile(new File(soteriaDir, "Mission.csv"));
    scnCompPropsTable.toCsvFile(new File(soteriaDir, "ScnCompProps.csv"));
    scnConnTable.toCsvFile(new File(soteriaDir, "ScnConnections.csv"));
}
Also used : Table(com.ge.research.osate.verdict.aadl2csv.Table) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ComponentImpl(verdict.vdm.vdm_model.ComponentImpl) File(java.io.File) HashSet(java.util.HashSet)

Example 33 with ComponentImpl

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

the class Vdm2Csv method updateCompInstTable.

private Table updateCompInstTable(List<ComponentImpl> compImpls, String scenario, Map<String, HashSet<String>> propToCompInsts, Map<String, HashMap<String, String>> compInstAttributesMap, Map<String, String> compToCompImpl) {
    // update component instances prop table
    List<String> headers = new ArrayList<String>(Arrays.asList("Scenario", "QualifiedName", "SanitizedQualifiedName", "PackageName", "Comp", "Impl", "CompInstance"));
    headers.addAll(propToCompInsts.keySet());
    Table scnCompPropsTable = new Table(headers);
    for (ComponentImpl compImpl : compImpls) {
        if (compImpl.getBlockImpl() != null) {
            List<verdict.vdm.vdm_model.ComponentInstance> compInstances = compImpl.getBlockImpl().getSubcomponent();
            // --add rows to comp properties csv
            for (verdict.vdm.vdm_model.ComponentInstance compInst : compInstances) {
                updateCompPropsTable(compInst.getName(), compInst, scnCompPropsTable, compInstAttributesMap, scenario, compImpl, compToCompImpl, propToCompInsts);
            }
        }
    }
    return scnCompPropsTable;
}
Also used : Table(com.ge.research.osate.verdict.aadl2csv.Table) ArrayList(java.util.ArrayList) ComponentInstance(verdict.vdm.vdm_model.ComponentInstance) ComponentInstance(verdict.vdm.vdm_model.ComponentInstance) ComponentImpl(verdict.vdm.vdm_model.ComponentImpl)

Aggregations

ComponentImpl (verdict.vdm.vdm_model.ComponentImpl)33 ComponentInstance (verdict.vdm.vdm_model.ComponentInstance)25 ComponentType (verdict.vdm.vdm_model.ComponentType)24 BlockImpl (verdict.vdm.vdm_model.BlockImpl)17 HashSet (java.util.HashSet)13 GenericAttribute (verdict.vdm.vdm_data.GenericAttribute)9 CompInstancePort (verdict.vdm.vdm_model.CompInstancePort)9 Port (verdict.vdm.vdm_model.Port)9 ArrayList (java.util.ArrayList)8 ConnectionEnd (verdict.vdm.vdm_model.ConnectionEnd)7 Connection (verdict.vdm.vdm_model.Connection)6 HashMap (java.util.HashMap)5 Expression (verdict.vdm.vdm_lustre.Expression)5 Table (com.ge.research.osate.verdict.aadl2csv.Table)4 ContractItem (verdict.vdm.vdm_lustre.ContractItem)4 ContractSpec (verdict.vdm.vdm_lustre.ContractSpec)4 ConstantDeclaration (verdict.vdm.vdm_lustre.ConstantDeclaration)3 NodeBody (verdict.vdm.vdm_lustre.NodeBody)3 NodeEquation (verdict.vdm.vdm_lustre.NodeEquation)3 SymbolDefinition (verdict.vdm.vdm_lustre.SymbolDefinition)3