use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class FTAGenerator method transformSubgates.
/**
* find common events in subgates and move them to an enclosing gate
* Currently does it if all of the gates of a given type have something in common.
* It also does it for various subsets of events with the matching gate type.
* Distributive Law 3a and 3b (see NRC Fault Tree Handbook page 80).
* @param topevent
* @param gt
* @return Event
*/
private Event transformSubgates(Event topevent, LogicOperation gt, LogicOperation topgt) {
List<Event> subEvents = topevent.getSubEvents();
if (subEvents.isEmpty()) {
return topevent;
}
if (subEvents.size() == 1) {
// (Event) subEvents.get(0);
return topevent;
}
Set<Event> intersection = null;
List<Event> todo = new LinkedList<Event>();
while (true) {
todo.clear();
for (Event se : subEvents) {
if (!se.getSubEvents().isEmpty() && (se.getSubEventLogic() == gt)) {
if (intersection == null) {
intersection = new HashSet<Event>(se.getSubEvents());
todo.add(se);
} else {
if (intersects(intersection, se.getSubEvents())) {
intersection.retainAll(se.getSubEvents());
todo.add(se);
}
}
}
}
if (todo.size() > 1 && intersection != null && !intersection.isEmpty()) {
if (subEvents.size() == todo.size()) {
// all subgates are involved
// remove from lower OR and create an OR above top gate
Event newtopevent = FaultTreeUtils.createUniqueIntermediateEvent(ftaModel, (ComponentInstance) topevent.getRelatedInstanceObject(), topevent.getRelatedEMV2Object(), (TypeToken) topevent.getRelatedErrorType());
newtopevent.setSubEventLogic(gt);
newtopevent.getSubEvents().add(topevent);
for (Event event : intersection) {
newtopevent.getSubEvents().add(event);
}
for (Event se : todo) {
EList<Event> rem = se.getSubEvents();
rem.removeAll(intersection);
}
flattenSubgates(topevent);
removeZeroOneEventSubGates(topevent);
flattenSubgates(newtopevent);
removeZeroOneEventSubGates(newtopevent);
return newtopevent;
} else {
// transformed subtree to top gate replacing subset of events involved in transformation
Event newtopevent = FaultTreeUtils.createIntermediateEvent(ftaModel, (ComponentInstance) topevent.getRelatedInstanceObject(), topevent.getRelatedEMV2Object(), (TypeToken) topevent.getRelatedErrorType());
newtopevent.setSubEventLogic(gt);
topevent.getSubEvents().add(newtopevent);
// remove intersection fro subset of gates
for (Event event : intersection) {
newtopevent.getSubEvents().add(event);
}
for (Event se : todo) {
EList<Event> rem = se.getSubEvents();
rem.removeAll(intersection);
}
topevent.getSubEvents().removeAll(todo);
flattenSubgates(newtopevent);
removeZeroOneEventSubGates(newtopevent);
flattenSubgates(topevent);
removeZeroOneEventSubGates(topevent);
return topevent;
}
} else {
flattenSubgates(topevent);
removeZeroOneEventSubGates(topevent);
return topevent;
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class FTAGenerator method preProcessIncomingErrorPropagation.
@Override
protected EObject preProcessIncomingErrorPropagation(ComponentInstance component, ErrorPropagation errorPropagation, TypeToken targetType, BigDecimal scale) {
String name = FaultTreeUtils.buildName(component, errorPropagation, targetType);
Event result = FaultTreeUtils.findEvent(ftaModel, name);
return result;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class FTAGenerator method processErrorEvent.
@Override
protected EObject processErrorEvent(ComponentInstance component, ErrorEvent errorEvent, TypeToken type, BigDecimal scale) {
Event ftaEvent = FaultTreeUtils.createBasicEvent(ftaModel, component, errorEvent, type);
ftaEvent.setScale(scale);
return ftaEvent;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class CreateFTAModel method createModel.
public static FaultTree createModel(ComponentInstance selection, final String startingPoint, FaultTreeType faultTreeType) {
NamedElement errorStateOrPropagation = null;
TypeToken errorType = null;
if (startingPoint.startsWith(prefixState)) {
String toProcess = startingPoint.replace(prefixState, "");
for (ErrorBehaviorState ebs : EMV2Util.getAllErrorBehaviorStates(selection)) {
if (ebs.getName().equalsIgnoreCase(toProcess)) {
errorStateOrPropagation = ebs;
}
}
}
if (startingPoint.startsWith(prefixOutgoingPropagation)) {
String toProcess = startingPoint.replace(prefixOutgoingPropagation, "");
for (ErrorPropagation opc : EMV2Util.getAllOutgoingErrorPropagations(selection.getComponentClassifier())) {
EList<TypeToken> result = EMV2TypeSetUtil.flattenTypesetElements(opc.getTypeSet());
for (TypeToken tt : result) {
String longName = EMV2Util.getPrintName(opc) + EMV2Util.getPrintName(tt);
if (longName.equalsIgnoreCase(toProcess) && !tt.getType().isEmpty()) {
errorStateOrPropagation = opc;
errorType = tt;
}
}
}
}
if (errorStateOrPropagation == null) {
return null;
}
PropagationGraph currentPropagationGraph = Util.generatePropagationGraph(selection.getSystemInstance(), false);
FTAGenerator generator = new FTAGenerator(currentPropagationGraph);
FaultTree ftamodel = generator.getftaModel(selection, errorStateOrPropagation, errorType, faultTreeType);
String rootname = ftamodel.getName() + (faultTreeType.equals(FaultTreeType.MINIMAL_CUT_SET) ? "_cutset" : (faultTreeType.equals(FaultTreeType.FAULT_TRACE) ? "_trace" : (faultTreeType.equals(FaultTreeType.COMPOSITE_PARTS) ? "_parts" : "_tree")));
ftamodel.setName(rootname);
return ftamodel;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class ErrorStateToModeMappingImpl method basicSetTypeToken.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTypeToken(TypeSet newTypeToken, NotificationChain msgs) {
TypeSet oldTypeToken = typeToken;
typeToken = newTypeToken;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ErrorModelPackage.ERROR_STATE_TO_MODE_MAPPING__TYPE_TOKEN, oldTypeToken, newTypeToken);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
Aggregations