use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource in project osate2 by osate.
the class EMV2Util method getErrorModelElement.
/**
* Get the error model element pointed to by the EMV2Path.
* An error model element can be ErrorSource, ErrorSink, ErrorPath, ErrorPropagaiton, ErrorState,
* ErrorBehaviorEvent (ErrorEvent, RecoverEvent, RepairEvent), ErrorBehaviorTransition
* This works for condition elements (ConditionElement, SConditionElement)
* @param epath EMV2Path
* @return NamedElement
*/
public static NamedElement getErrorModelElement(EMV2Path epath) {
if (epath == null) {
return null;
}
EMV2PathElement target = getLast(epath.getEmv2Target());
if (target.getNamedElement() instanceof ErrorTypes) {
EObject prev = target.eContainer();
if (prev instanceof EMV2PathElement) {
target = (EMV2PathElement) prev;
} else {
return null;
}
}
NamedElement prop = target.getNamedElement();
if (prop != null) {
return prop;
}
String kind = target.getEmv2PropagationKind();
Classifier cxtcl = EMV2Util.getAssociatedClassifier(epath);
if (target.eContainer() instanceof EMV2PathElement) {
// should be a subcomponent reference
NamedElement cxt = ((EMV2PathElement) target.eContainer()).getNamedElement();
if (cxt instanceof Subcomponent) {
cxtcl = ((Subcomponent) cxt).getAllClassifier();
}
} else {
if (epath.getContainmentPath() != null) {
ContainmentPathElement last = getLast(epath.getContainmentPath());
if (last.getNamedElement() instanceof Subcomponent) {
cxtcl = ((Subcomponent) last.getNamedElement()).getAllClassifier();
}
}
}
ErrorPropagation ep = findErrorPropagation(cxtcl, kind, DirectionType.IN);
if (ep == null) {
ep = findErrorPropagation(cxtcl, kind, DirectionType.OUT);
}
return ep;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource in project osate2 by osate.
the class EMV2Util method getAllConnectionErrorSources.
/**
* return list of ConnectionErrorSource including those inherited from classifiers being extended
* @param cl Classifier
* @return Collection<ConnectionErrorSource> list of ConnectionErrorSource excluding duplicates
*/
public static Collection<ErrorSource> getAllConnectionErrorSources(Classifier cl) {
HashMap<String, ErrorSource> result = new LinkedHashMap<>();
EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
for (ErrorModelSubclause errorModelSubclause : emslist) {
EList<ErrorSource> eflist = errorModelSubclause.getConnectionErrorSources();
for (ErrorSource errorProp : eflist) {
String epname = EMV2Util.getPrintName(errorProp);
if (!result.containsKey(epname)) {
result.put(epname, errorProp);
}
}
}
return result.values();
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource in project osate2 by osate.
the class ErrorModelValidator method checkFlowDirection.
private void checkFlowDirection(ErrorSource errorSource) {
NamedElement ne = errorSource.getSourceModelElement();
if (ne instanceof ErrorPropagation) {
if (!Aadl2Util.isNull(ne) && ne instanceof ErrorPropagation) {
ErrorPropagation ep = (ErrorPropagation) ne;
DirectionType epd = ep.getDirection();
if (!(epd.equals(DirectionType.OUT))) {
error(errorSource, EMV2Util.getPrintName(ep) + " of error source is not an outgoing propagation point.");
}
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource in project osate2 by osate.
the class EMV2Util method getAllErrorSinks.
/**
* return list of error sinks including those inherited from classifiers being extended
* @param cl Classifier
* @return Collection<ErrorSource> list of error sinks declared in the flow section
*/
public static Collection<ErrorSink> getAllErrorSinks(Classifier cl) {
HashMap<String, ErrorSink> result = new LinkedHashMap<>();
EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
for (ErrorModelSubclause errorModelSubclause : emslist) {
EList<ErrorFlow> eflist = errorModelSubclause.getFlows();
for (ErrorFlow errorFlow : eflist) {
if (errorFlow instanceof ErrorSink) {
if (!result.containsKey(errorFlow.getName())) {
result.put(errorFlow.getName(), (ErrorSink) errorFlow);
}
}
}
}
return result.values();
}
Aggregations