use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource in project osate2 by osate.
the class EMV2Util method getAllErrorPaths.
/**
* return list of error paths including those inherited from classifiers being extended
* @param cl Classifier
* @return Collection<ErrorSource> list of error paths declared in the flow section
*/
public static Collection<ErrorPath> getAllErrorPaths(Classifier cl) {
HashMap<String, ErrorPath> result = new LinkedHashMap<>();
EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
for (ErrorModelSubclause errorModelSubclause : emslist) {
EList<ErrorFlow> eflist = errorModelSubclause.getFlows();
for (ErrorFlow errorFlow : eflist) {
if (errorFlow instanceof ErrorPath) {
if (!result.containsKey(errorFlow.getName())) {
result.put(errorFlow.getName(), (ErrorPath) errorFlow);
}
}
}
}
return result.values();
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource in project osate2 by osate.
the class EMV2Util method findConnectionErrorSourceForConnection.
/**
* Find ConnectionErrorSource with given classifier by looking through all connection error sources
* @param conni the connection instance whose connection declarations we're using
* @return the connection error source or null
*/
public static ErrorSource findConnectionErrorSourceForConnection(ConnectionInstance conni) {
for (ConnectionReference connref : conni.getConnectionReferences()) {
Connection conn = connref.getConnection();
Classifier cl = getAssociatedClassifier(conn);
if (cl != null) {
Collection<ErrorSource> ceslist = getAllConnectionErrorSources(cl);
for (ErrorSource ces : ceslist) {
if (ces.isAll() || ces.getSourceModelElement().getName().equalsIgnoreCase(conn.getName())) {
return ces;
}
}
}
}
return null;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource in project osate2 by osate.
the class PropagateErrorSources method startConnectionSourceFlows.
/**
* Start with the source of a connection instance
* @param ci component instance
*/
public void startConnectionSourceFlows(ComponentInstance root) {
Collection<ErrorSource> ceslist = EMV2Util.getAllConnectionErrorSources(root.getComponentClassifier());
if (ceslist.isEmpty()) {
return;
}
for (ErrorSource ces : ceslist) {
if (!Util.conditionHolds(ces, root)) {
continue;
}
EMSUtil.unsetAll(root.getSystemInstance());
// find connection instances that this connection is part of
String connName = ces.getSourceModelElement().getName();
ConnectionInstance conni = InstanceUtil.findConnectionInstance(root, (Connection) ces.getSourceModelElement());
EList<PropagationPathEnd> ends = Util.getAllPropagationDestinationEnds(faultModel, conni);
if (ends.size() == 0) {
return;
}
PropagationPathEnd ppe = ends.get(0);
ErrorPropagation destEP = ppe.getErrorPropagation();
ComponentInstance destci = ppe.getComponentInstance();
TypeSet fmType = ces.getFailureModeType();
String failuremodeDesc = ces.getFailureModeDescription();
TypeSet tsep = ces.getTypeTokenConstraint();
EList<TypeToken> result = tsep.getTypeTokens();
// XXX use this if we want all leaf types: EM2TypeSetUtil.generateAllLeafTypeTokens(tsep,EMV2Util.getContainingTypeUseContext(errorSource));
for (TypeToken typeToken : result) {
String failuremodeText;
if (failuremodeDesc == null) {
failuremodeText = generateOriginalFailureModeText(fmType != null ? fmType : typeToken);
} else {
failuremodeText = failuremodeDesc;
}
String effectText = generateOriginalFailureModeText(typeToken);
String connText = generateComponentPropagationPointText(destci, destEP);
traceErrorFlows(destci, destEP, typeToken, 0, "Connection " + connName + "," + failuremodeText + "," + effectText + " -> " + connText);
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource in project osate2 by osate.
the class PropagateErrorSources method startExternalFlows.
/**
* Start with an external incoming error propagation as source
* @param ci component instance
*/
public void startExternalFlows(ComponentInstance root) {
Collection<ErrorPropagation> eplist = EMV2Util.getAllIncomingErrorPropagations(root.getComponentClassifier());
String componentText = generateComponentInstanceText(root);
if (eplist.isEmpty()) {
return;
}
reportExternalImpactHeading();
reportExternalTableHeading();
for (ErrorPropagation ep : eplist) {
EMSUtil.unsetAll(root);
TypeSet tsep = ep.getTypeSet();
if (tsep != null) {
EList<TypeToken> result = tsep.getTypeTokens();
// XXX use this if we want all leaf types: EM2TypeSetUtil.generateAllLeafTypeTokens(tsep,EMV2Util.getContainingTypeUseContext(errorSource));
for (TypeToken typeToken : result) {
String failuremodeText = generateErrorPropTypeTokenText(ep, typeToken);
traceErrorPaths(root, ep, typeToken, 2, componentText + ", " + failuremodeText);
}
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource in project osate2 by osate.
the class FHAReport method processHazards.
protected void processHazards(ComponentInstance ci, WriteToFile report) {
for (ErrorBehaviorTransition trans : EMV2Util.getAllErrorBehaviorTransitions(ci.getComponentClassifier())) {
ConditionExpression cond = trans.getCondition();
if (cond instanceof ConditionElement) {
ConditionElement condElement = (ConditionElement) trans.getCondition();
EventOrPropagation eop = EMV2Util.getErrorEventOrPropagation(condElement);
if (eop instanceof ErrorEvent) {
ErrorEvent errorEvent = (ErrorEvent) eop;
List<EMV2PropertyAssociation> PA = getHazardsPropertyInCurrentFormat(ci, errorEvent, errorEvent.getTypeSet());
List<EMV2PropertyAssociation> Sev = EMV2Properties.getSeverityProperty(ci, errorEvent, errorEvent.getTypeSet());
List<EMV2PropertyAssociation> Like = EMV2Properties.getLikelihoodProperty(ci, errorEvent, errorEvent.getTypeSet());
reportHazardProperty(ci, PA, Sev, Like, errorEvent, errorEvent.getTypeSet(), errorEvent, report);
}
// condElement.getIncoming()
}
}
for (ErrorBehaviorState state : EMV2Util.getAllErrorBehaviorStates(ci)) {
List<EMV2PropertyAssociation> PA = getHazardsPropertyInCurrentFormat(ci, state, state.getTypeSet());
List<EMV2PropertyAssociation> Sev = EMV2Properties.getSeverityProperty(ci, state, state.getTypeSet());
List<EMV2PropertyAssociation> Like = EMV2Properties.getLikelihoodProperty(ci, state, state.getTypeSet());
reportHazardProperty(ci, PA, Sev, Like, state, state.getTypeSet(), state, report);
}
// report all error sources as hazards if they have the property
Collection<ErrorSource> eslist = EMV2Util.getAllErrorSources(ci.getComponentClassifier());
Collection<ErrorPropagation> oeplist = EMV2Util.getAllOutgoingErrorPropagations(ci.getComponentClassifier());
for (ErrorSource errorSource : eslist) {
NamedElement ne = errorSource.getSourceModelElement();
ErrorBehaviorState failureMode = errorSource.getFailureModeReference();
List<EMV2PropertyAssociation> HazardPA = Collections.emptyList();
List<EMV2PropertyAssociation> Sev = Collections.emptyList();
List<EMV2PropertyAssociation> Like = Collections.emptyList();
TypeSet ts = null;
NamedElement target = null;
Element localContext = null;
// not dealing with type set as failure mode
if (failureMode != null) {
// state is originating hazard, possibly with a type set
ts = failureMode.getTypeSet();
// error source a local context
HazardPA = getHazardsPropertyInCurrentFormat(ci, failureMode, ts);
Sev = EMV2Properties.getSeverityProperty(ci, failureMode, ts);
Like = EMV2Properties.getLikelihoodProperty(ci, failureMode, ts);
target = failureMode;
localContext = errorSource;
}
if (HazardPA.isEmpty()) {
// error source is originating hazard
ts = errorSource.getTypeTokenConstraint();
if (ts == null && ne instanceof ErrorPropagation) {
ts = ((ErrorPropagation) ne).getTypeSet();
}
HazardPA = getHazardsPropertyInCurrentFormat(ci, errorSource, ts);
Sev = EMV2Properties.getSeverityProperty(ci, errorSource, ts);
Like = EMV2Properties.getLikelihoodProperty(ci, errorSource, ts);
target = errorSource;
localContext = null;
if (HazardPA.isEmpty() && errorSource.getFailureModeType() != null) {
ts = errorSource.getFailureModeType();
HazardPA = getHazardsPropertyInCurrentFormat(ci, errorSource, ts);
Sev = EMV2Properties.getSeverityProperty(ci, errorSource, ts);
Like = EMV2Properties.getLikelihoodProperty(ci, errorSource, ts);
}
}
if (!HazardPA.isEmpty()) {
reportHazardProperty(ci, HazardPA, Sev, Like, target, ts, localContext, report);
}
}
for (ErrorPropagation ep : oeplist) {
TypeSet ts = null;
NamedElement target = null;
Element localContext = null;
// error propagation is originating hazard
ts = ep.getTypeSet();
List<EMV2PropertyAssociation> HazardPA = getHazardsPropertyInCurrentFormat(ci, ep, ts);
List<EMV2PropertyAssociation> Sev = EMV2Properties.getSeverityProperty(ci, ep, ts);
List<EMV2PropertyAssociation> Like = EMV2Properties.getLikelihoodProperty(ci, ep, ts);
target = ep;
localContext = null;
// XXX we may have more than one matching hazard
if (!HazardPA.isEmpty()) {
reportHazardProperty(ci, HazardPA, Sev, Like, target, ts, localContext, report);
}
}
}
Aggregations