use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class PropagateErrorSources method doAllOutPropagationsOrFeatures.
protected boolean doAllOutPropagationsOrFeatures(ComponentInstance ci, EList<FeatureInstance> filist, ErrorPropagation ep, TypeToken tt, int depth, String entryText) {
boolean handled = false;
for (FeatureInstance fi : filist) {
if (fi.getFlowDirection().outgoing()) {
ErrorPropagation outp = EMV2Util.getOutgoingErrorPropagation(fi);
if (outp != null) {
TypeToken newtt = EMV2Util.mapToken(tt, null);
if (EMV2TypeSetUtil.contains(outp.getTypeSet(), newtt)) {
traceErrorPaths(ci, outp, newtt, depth + 1, entryText + "," + generateFailureModeText(ci, ep, tt) + " [All Out Props]");
handled = true;
} else {
Collection<TypeToken> intersection = EMV2TypeSetUtil.getConstrainedTypeTokens(outp.getTypeSet(), newtt);
if (intersection.isEmpty()) {
String errorText = ",\"" + generateFailureModeText(ci, outp, newtt) + " [Not in type constraint " + EMV2Util.getPrintName(outp.getTypeSet()) + " ]\"";
reportEntry(entryText + errorText, depth);
handled = true;
} else {
for (TypeToken typeToken : intersection) {
traceErrorPaths(ci, outp, typeToken, depth + 1, entryText + "," + generateFailureModeText(ci, ep, tt) + " [All Out Subtype]");
handled = true;
}
}
}
} else {
if (!fi.getFeatureInstances().isEmpty()) {
boolean res = doAllOutPropagationsOrFeatures(ci, fi.getFeatureInstances(), ep, tt, depth, entryText);
if (res) {
handled = true;
} else {
// report only for the top feature instance
if (fi.getOwner() instanceof ComponentInstance) {
String errorText = "," + generateFailureModeText(ci, outp, tt) + " [No feature with out propagation ]";
reportEntry(entryText + errorText, depth);
}
}
}
}
}
}
return handled;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class PropagateErrorSources method processTransition.
private void processTransition(ComponentInstance ci, ErrorBehaviorEvent event, TypeToken eventtype, ErrorBehaviorTransition trans, ConditionElement conditionElement, String componentText, HashMultimap<ErrorPropagation, String> handledPropagations) {
EventOrPropagation eop = EMV2Util.getErrorEventOrPropagation(conditionElement);
TypeSet constraint = conditionElement.getConstraint();
if (eop instanceof ErrorPropagation) {
return;
}
if (eop.getName().equalsIgnoreCase(event.getName())) {
// match the event
if (eventtype != null && constraint != null && !EMV2TypeSetUtil.contains(constraint, eventtype)) {
return;
}
ErrorBehaviorState targetstate = trans.getTarget();
TypeSet statetype = null;
if (targetstate.getTypeSet() != null) {
statetype = trans.getTargetToken();
}
// we have the state and possibly a type
for (OutgoingPropagationCondition opc : EMV2Util.getAllOutgoingPropagationConditions(ci)) {
if (EMV2TypeSetUtil.isNoError(opc.getTypeToken()) || opc.getCondition() != null) {
continue;
}
if (opc.isAllStates() || (opc.getState() != null && targetstate.getName().equalsIgnoreCase(opc.getState().getName()))) {
// either typeless state or type is contained in opc type constraint on state
TypeSet statetypeconstraint = opc.getTypeTokenConstraint();
if (statetypeconstraint == null || statetype == null || EMV2TypeSetUtil.contains(statetypeconstraint, statetype)) {
ErrorTypes outtype = opc.getTypeToken();
if (outtype == null) {
outtype = statetype;
}
if (opc.isAllPropagations()) {
Collection<ErrorPropagation> oeps = EMV2Util.getAllOutgoingErrorPropagations(ci.getComponentClassifier());
for (ErrorPropagation ep : oeps) {
if (outtype == null) {
if (eventtype != null) {
traceErrorPaths(ci, ep, eventtype, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
handledPropagations.put(ep, EMV2Util.getPrintName(eventtype));
}
} else {
EList<TypeToken> result = EMV2TypeSetUtil.generateAllLeafTypeTokens((TypeSet) outtype, EMV2Util.getUseTypes(opc));
for (TypeToken tt : result) {
traceErrorPaths(ci, ep, tt, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
handledPropagations.put(ep, EMV2Util.getPrintName(tt));
}
}
}
} else {
ErrorPropagation ep = opc.getOutgoing();
if (outtype == null) {
if (eventtype != null) {
traceErrorPaths(ci, ep, eventtype, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
handledPropagations.put(ep, EMV2Util.getPrintName(eventtype));
}
} else {
EList<TypeToken> result = EMV2TypeSetUtil.generateAllLeafTypeTokens((TypeSet) outtype, EMV2Util.getUseTypes(opc));
for (TypeToken tt : result) {
traceErrorPaths(ci, ep, tt, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
handledPropagations.put(ep, EMV2Util.getPrintName(tt));
}
}
}
}
}
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class FHAReport method reportHazardProperty.
protected void reportHazardProperty(InstanceObject ci, List<EMV2PropertyAssociation> PAList, List<EMV2PropertyAssociation> SevList, List<EMV2PropertyAssociation> LikeList, NamedElement target, TypeSet ts, Element localContext, WriteToFile report) {
String targetName;
if (PAList.isEmpty()) {
return;
}
if (target == null) {
targetName = "";
} else {
targetName = EMV2Util.getPrintName(target);
if (target instanceof ErrorEvent) {
targetName = "event " + targetName;
}
if (target instanceof ErrorBehaviorState) {
targetName = "state " + targetName;
}
}
for (EMV2PropertyAssociation PA : PAList) {
for (ModalPropertyValue modalPropertyValue : PA.getOwnedValues()) {
PropertyExpression peVal = modalPropertyValue.getOwnedValue();
ListValue lv = (ListValue) peVal;
for (PropertyExpression pe : lv.getOwnedListElements()) {
EList<BasicPropertyAssociation> fields = ((RecordValue) pe).getOwnedFieldValues();
if (ts != null) {
// do smaller of ts or hazard type set.
EList<EMV2Path> epathlist = PA.getEmv2Path();
for (EMV2Path ep : epathlist) {
ErrorTypes et = EMV2Util.getErrorType(ep);
ErrorTypes targettype = ts;
if (et != null && EMV2TypeSetUtil.contains(ts, et)) {
targettype = et;
}
List<EMV2PropertyAssociation> Sevs = EMV2Properties.getSeverityProperty(ci, target, et);
List<EMV2PropertyAssociation> Likes = EMV2Properties.getLikelihoodProperty(ci, target, et);
EMV2PropertyAssociation Sev = Sevs.isEmpty() ? null : Sevs.get(0);
EMV2PropertyAssociation Like = Likes.isEmpty() ? null : Likes.get(0);
PropertyExpression severityValue = EMV2Properties.getPropertyValue(Sev);
PropertyExpression likelihoodValue = EMV2Properties.getPropertyValue(Like);
if (targettype instanceof TypeSet) {
for (TypeToken token : ((TypeSet) targettype).getTypeTokens()) {
reportFHAEntry(report, fields, severityValue, likelihoodValue, ci, targetName, EMV2Util.getName(token));
}
} else {
reportFHAEntry(report, fields, severityValue, likelihoodValue, ci, targetName, EMV2Util.getName(targettype));
}
}
} else {
// did not have a type set. Let's use fmr (state of type set as failure mode.
EMV2PropertyAssociation Sev = SevList.isEmpty() ? null : SevList.get(0);
EMV2PropertyAssociation Like = LikeList.isEmpty() ? null : LikeList.get(0);
PropertyExpression severityValue = EMV2Properties.getPropertyValue(Sev);
PropertyExpression likelihoodValue = EMV2Properties.getPropertyValue(Like);
if (localContext == null) {
reportFHAEntry(report, fields, severityValue, likelihoodValue, ci, targetName, "");
} else {
reportFHAEntry(report, fields, severityValue, likelihoodValue, ci, EMV2Util.getPrintName(localContext), EMV2Util.getPrintName(target));
}
}
}
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class FTAGenerator method finalizeAsUniqueOrEvents.
private Event finalizeAsUniqueOrEvents(ComponentInstance component, Element ne, TypeToken type, List<EObject> subEvents) {
if (subEvents.size() == 0) {
return null;
}
Event combined = FaultTreeUtils.createUniqueIntermediateEvent(ftaModel, component, ne, type);
combined.setSubEventLogic(LogicOperation.OR);
for (Object seobj : subEvents) {
combined.getSubEvents().add((Event) seobj);
}
return combined;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class FTAGenerator method processIncomingErrorPropagation.
@Override
protected EObject processIncomingErrorPropagation(ComponentInstance component, ErrorPropagation incoming, TypeToken type, BigDecimal scale) {
Event res = FaultTreeUtils.createBasicEvent(ftaModel, component, incoming, type);
res.setScale(scale);
if (component instanceof SystemInstance) {
res.setType(EventType.EXTERNAL);
} else {
res.setType(EventType.UNDEVELOPED);
}
return res;
}
Aggregations