use of edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFault 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;
}
use of edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFault in project AMASE by loonwerks.
the class IvcToSoteriaGenerator method extractFaultIvcElem.
private void extractFaultIvcElem(SoteriaComp comp, AgreeRenaming renaming, SoteriaFormulaSubgroup formulaSubgroup, String faultName, String faultRefName) {
// get the fault name for that fault activation variable in ivcElement
CompFaultActivation faultActivation = new CompFaultActivation(comp.componentName, faultName);
formulaSubgroup.addFormulaElem(faultActivation);
// if ivcElem is not yet in basicEvents
if (!comp.basicEvents.containsKey(faultName)) {
FaultStatementImpl faultStmtImpl = (FaultStatementImpl) renaming.getRefMap().get(faultRefName);
for (FaultSubcomponent faultSub : faultStmtImpl.getFaultDefinitions()) {
if (faultSub instanceof ProbabilityStatementImpl) {
String probStr = ((ProbabilityStatementImpl) faultSub).getProbability();
float failureProb = Float.parseFloat(probStr);
// TODO: need to have component specify failure rate and exposure time in the future
// currently treat exposure time as (float) 1.0
// and treat the failure probability from the fault statement as the failure rate
SoteriaFault basicEvent = new SoteriaFault(updateElemName(faultName), failureProb, (float) 1.0);
comp.addBasicEvent(faultName, basicEvent);
}
}
}
}
Aggregations