use of edu.umn.cs.crisys.safety.safety.FaultSubcomponent in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method getOutputNameFromFaultStatement.
/**
* Given a fault statement, returns the string name of the output this fault
* stmt is connected to.
*
* @param fs FaultStatement in question
* @return String name of the output
*/
private String getOutputNameFromFaultStatement(FaultStatement fs) {
String output = "";
for (FaultSubcomponent fc : fs.getFaultDefinitions()) {
if (fc instanceof OutputStatement) {
EList<NamedElement> outputType = ((OutputStatement) fc).getNom_conn();
// TODO: Assume the output is first in list. (????)
if (outputType.size() > 0) {
NamedElement id = outputType.get(0);
// output = id.getBase().getName();
output = id.toString();
return output;
}
break;
}
}
return output;
}
use of edu.umn.cs.crisys.safety.safety.FaultSubcomponent in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method separateFaultStmts.
/**
* This method uses a list of fault statements and divides them into multiple
* asym faults on a single output and everything else.
*
* @param allFS List<FaultStatement> All fault statements in this agree
* node
* @param remainderFS List<FaultStatement> List to add all single asym faults
* on single output AND sym faults.
* @param multipleAsymFS List<FaultStatement> List to add all multiple asym
* faults on single output.
*/
private void separateFaultStmts(List<FaultStatement> allFS, List<FaultStatement> remainderFS, Map<String, List<FaultStatement>> asymMap) {
// Else append to multipleAsymFS list.
for (FaultStatement fs : allFS) {
int count = fs.getFaultDefinitions().size();
for (FaultSubcomponent fc : fs.getFaultDefinitions()) {
count--;
if (fc instanceof PropagationTypeStatement) {
if (((PropagationTypeStatement) fc).getPty() instanceof asymmetric) {
// Asym fault needs to be processed further and added to map.
String outputName = getOutputNameFromFaultStatement(fs);
if (outputName.isEmpty()) {
new SafetyException("Error processing asymmetric fault: the output name is undefined for fault statement:" + fs.getName());
} else {
List<FaultStatement> tempAsymFaults = new ArrayList<FaultStatement>();
tempAsymFaults.add(fs);
if (asymMap.containsKey(outputName)) {
asymMap.get(outputName).addAll(tempAsymFaults);
} else {
asymMap.put(outputName, tempAsymFaults);
}
break;
}
} else {
// symmetric faults added to remainderFS list
remainderFS.add(fs);
break;
}
}
// all definitions, then we have no prop type stmt. It is sym.
if (count == 0) {
remainderFS.add(fs);
}
}
}
// Add multiples to multiple list.
for (String key : asymMap.keySet()) {
if (asymMap.get(key).size() == 1) {
remainderFS.addAll(asymMap.get(key));
}
}
}
use of edu.umn.cs.crisys.safety.safety.FaultSubcomponent in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method isDisabled.
/**
* Checks fault stmt for DisableStatement. If found, returns value of disable
* statement. Else returns false.
*
* @param fs FaultStatement
* @return bool: isDisabled
*/
private Boolean isDisabled(FaultStatement fs) {
Boolean disableFound = false;
List<FaultSubcomponent> subcomps = fs.getFaultDefinitions();
for (FaultSubcomponent fsc : subcomps) {
if (fsc instanceof DisableStatement) {
disableFound = true;
DisableStatement ds = (DisableStatement) fsc;
BooleanLiteral bl = ds.getCond();
return bl.getValue();
}
}
return disableFound;
}
use of edu.umn.cs.crisys.safety.safety.FaultSubcomponent in project AMASE by loonwerks.
the class IvcToFTGenerator method extractFaultMCSElem.
private void extractFaultMCSElem(String compName, AgreeRenaming renaming, FTAndNode mcsSetNode, String faultName, String faultRefName, String originalFaultName) {
// differentiate same fault definitions activated in subcomponents of different parent components
String updatedFaultName = MHSUtils.updateElemName(compName + "_" + faultName);
// if mcsElem is not yet in leaf nodes
if (!faultTree.leafNodes.containsKey(updatedFaultName)) {
FaultStatementImpl faultStmtImpl = (FaultStatementImpl) renaming.getRefMap().get(faultRefName);
// original fault name specified by the user
String faultUserName = faultStmtImpl.getName();
// original fault explanation specified by the user
String faultUserExplanation = faultStmtImpl.getStr();
// probability string
String probStr = "";
// failure probability
float failureProb = (float) 0.0;
for (FaultSubcomponent faultSub : faultStmtImpl.getFaultDefinitions()) {
if (faultSub instanceof ProbabilityStatementImpl) {
probStr = ((ProbabilityStatementImpl) faultSub).getProbability();
failureProb = Float.parseFloat(probStr);
}
}
// TODO: need to have component specify failure rate and exposure time in the future
// currently treat exposure time and failure rate as (float) 1.0
// and set the failure probability from the fault statement as the failure rate
FTLeafNode ftLeafNode = new FTLeafNode(compName, updatedFaultName, (float) 1.0, (float) 1.0, failureProb, originalFaultName, faultUserName, faultUserExplanation);
faultTree.addLeafNode(updatedFaultName, ftLeafNode);
mcsSetNode.addChildNode(updatedFaultName, ftLeafNode);
// update intermediate node
faultTree.addIntermediateNode(mcsSetNode.nodeName, mcsSetNode);
// ftLeafNode.addParentNode(mcsSetNode);
} else {
FTLeafNode leafNode = faultTree.leafNodes.get(updatedFaultName);
mcsSetNode.addChildNode(updatedFaultName, leafNode);
faultTree.addIntermediateNode(mcsSetNode.nodeName, mcsSetNode);
// leafNode.addParentNode(mcsSetNode);
}
}
use of edu.umn.cs.crisys.safety.safety.FaultSubcomponent 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