use of edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl 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.impl.FaultStatementImpl in project AMASE by loonwerks.
the class IvcToFTGenerator method getMCSInfo.
/**
* Gathers details about MCS element and returns descriptive string
* including component name, fault/contract name and description.
* @param mcsElem String of mcs element
* @param renaming AgreeRenaming map
* @param compName component name where this fault/contract can be found
* @return descriptive string for hierarchical ft textual representation
*/
private String getMCSInfo(String mcsElem, AgreeRenaming renaming) {
String refStr = renaming.getSupportRefString(mcsElem);
if (mcsElem.startsWith("__fault")) {
FaultStatementImpl faultStmtImpl = (FaultStatementImpl) renaming.getRefMap().get(refStr);
String faultUserName = faultStmtImpl.getName();
String faultUserExplanation = faultStmtImpl.getStr();
return "Contributing fault found in component " + stripOutInstanceName(mcsElem) + ": " + faultUserName + ": " + faultUserExplanation + " (" + mcsElem + ")";
} else {
String name = mcsElem.substring(0, mcsElem.indexOf("."));
return "Supporting contract in component " + name + ": " + refStr;
}
}
use of edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl 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);
}
}
}
}
use of edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl in project AMASE by loonwerks.
the class FaultDisableHandler method makeMap.
/**
* Checks classifiers in AadlPackage for any ComponentTypeImpl
* and then collects safety annex spec statements to gather
* fault names specific to that component.
*
* @param classifiers Classifiers in this AadlPackage
*/
private void makeMap(List<Classifier> classifiers) {
for (Classifier cl : classifiers) {
if (cl instanceof ComponentTypeImpl) {
String compName = cl.getName();
List<String> faultNameList = new ArrayList<String>();
List<AnnexSubclause> asList = cl.getOwnedAnnexSubclauses();
for (AnnexSubclause as : asList) {
if (as.getName().equalsIgnoreCase("safety")) {
if (as instanceof DefaultAnnexSubclauseImpl) {
DefaultAnnexSubclauseImpl defaultAnnex = (DefaultAnnexSubclauseImpl) as;
SafetyContractSubclauseImpl safetyAnnex = (SafetyContractSubclauseImpl) defaultAnnex.getParsedAnnexSubclause();
List<SpecStatement> specs = ((SafetyContract) safetyAnnex.getContract()).getSpecs();
for (SpecStatement spec : specs) {
if (spec instanceof FaultStatementImpl) {
FaultStatementImpl fs = (FaultStatementImpl) spec;
faultNameList.add(fs.getName());
}
}
}
}
}
// If list nonempty, add to map for this component
if (!faultNameList.isEmpty()) {
mapCompNameToFaults.put(compName, faultNameList);
}
}
}
}
Aggregations