Search in sources :

Example 1 with SoteriaFormula

use of edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormula in project AMASE by loonwerks.

the class SoteriaPrettyPrintVisitor method visit.

@Override
public Void visit(SoteriaComp comp) {
    write("{");
    writeln("name = \"" + comp.componentName + "\";");
    writeln("faults = [\"" + comp.faultString + "\"];");
    write("input_flows = [");
    // write each input
    boolean multipleElem = false;
    for (String input : comp.inputFlows) {
        if (multipleElem) {
            writeln(";");
        }
        write("\"" + input + "\"");
        multipleElem = true;
    }
    writeln("];");
    write("basic_events = [");
    multipleElem = false;
    // write each basic event name
    for (SoteriaFault fault : comp.basicEvents.values()) {
        if (multipleElem) {
            writeln(";");
        }
        write("\"" + fault.faultName + "\"");
        multipleElem = true;
    }
    writeln("];");
    write("event_info = [");
    multipleElem = false;
    // write each basic event failure rate and exposure time
    for (SoteriaFault fault : comp.basicEvents.values()) {
        if (multipleElem) {
            writeln(";");
        }
        write("(" + fault.failureRate + ", " + fault.exposureTime + ")");
        multipleElem = true;
    }
    writeln("];");
    write("output_flows = [");
    // write each output
    multipleElem = false;
    for (String output : comp.outputFlows) {
        if (multipleElem) {
            writeln(";");
        }
        write("\"" + output + "\"");
        multipleElem = true;
    }
    writeln("];");
    writeln("formulas = [");
    // write each formula
    multipleElem = false;
    for (Map.Entry<String, SoteriaFormula> entry : comp.formulas.entrySet()) {
        if (multipleElem) {
            writeln(";");
        }
        SoteriaFormula formula = entry.getValue();
        formula.accept(this);
        multipleElem = true;
    }
    writeln("]");
    write("}");
    return null;
}
Also used : SoteriaFormula(edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormula) Map(java.util.Map) SoteriaFault(edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFault)

Example 2 with SoteriaFormula

use of edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormula in project AMASE by loonwerks.

the class IvcToSoteriaGenerator method extractPropertyResult.

private void extractPropertyResult(SoteriaComp comp, AgreeRenaming renaming, PropertyResult propertyResult) {
    // get original property name
    String origPropertyName = propertyResult.getName();
    String lustreName = renaming.getLustreNameFromAgreeVar(origPropertyName);
    String propertyName = updateElemName(comp.componentName + "_" + lustreName);
    // if it is a guarantee
    if (lustreName.startsWith("__GUARANTEE")) {
        // if it's a valid guarantee
        if (propertyResult.getStatus().equals(jkind.api.results.Status.VALID)) {
            // add property as an output to the soteria map
            comp.addOutput(propertyName);
            // add property violation as a top level fault to the model
            if (!isLowerLevel) {
                CompContractViolation contractViolation = new CompContractViolation(comp.componentName, propertyName);
                model.addTopLevelFault(contractViolation);
            }
            ValidProperty property = (ValidProperty) propertyResult.getProperty();
            SoteriaFormula formula = new SoteriaFormula(propertyName);
            // handle multiple ivc sets
            for (List<String> ivcSet : property.getIvcSets()) {
                SoteriaFormulaSubgroup formulaSubgroup = new SoteriaFormulaSubgroup(propertyName);
                extractIvcSets(comp, renaming, formulaSubgroup, ivcSet);
                if (!formulaSubgroup.elmeList.isEmpty()) {
                    formula.addFormulaSubgroup(formulaSubgroup);
                }
            }
            if (!formula.formulaBody.isEmpty()) {
                comp.addFormula(propertyName, formula);
            }
        } else if (propertyResult.getStatus().equals(jkind.api.results.Status.CANCELED)) {
            throw new SafetyException("One of the properties was canceled in the process of model checking." + " Rerun this analysis to proceed.");
        } else if (propertyResult.getStatus().equals(jkind.api.results.Status.INVALID)) {
            throw new SafetyException("One of the properties is invalid. The model must be valid using AGREE Verify All Layers.");
        }
    }
}
Also used : CompContractViolation(edu.umn.cs.crisys.safety.analysis.soteria.CompContractViolation) ValidProperty(jkind.results.ValidProperty) SoteriaFormulaSubgroup(edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormulaSubgroup) SoteriaFormula(edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormula) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException)

Aggregations

SoteriaFormula (edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormula)2 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)1 CompContractViolation (edu.umn.cs.crisys.safety.analysis.soteria.CompContractViolation)1 SoteriaFault (edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFault)1 SoteriaFormulaSubgroup (edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormulaSubgroup)1 Map (java.util.Map)1 ValidProperty (jkind.results.ValidProperty)1