use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath in project osate2 by osate.
the class EMV2Util method findReverseErrorFlowFrom.
/**
* find the error flow whose outgoing error propagation point is flowSource
* @param eps List of error propagations
* @param flowSource ErrorPropagation
* @return ErrorFlow list
*/
public static EList<ErrorFlow> findReverseErrorFlowFrom(Collection<ErrorFlow> efs, ErrorPropagation flowSource) {
EList<ErrorFlow> result = new BasicEList<ErrorFlow>();
for (ErrorFlow ef : efs) {
ErrorPropagation eprop = null;
boolean isall = false;
if (ef instanceof ErrorPath) {
ErrorPath ep = (ErrorPath) ef;
eprop = ep.getOutgoing();
isall = ep.isAllOutgoing();
} else if (ef instanceof ErrorSource && ((ErrorSource) ef).getSourceModelElement() instanceof ErrorPropagation) {
ErrorSource es = (ErrorSource) ef;
eprop = (ErrorPropagation) es.getSourceModelElement();
isall = es.isAll();
}
if ((eprop != null && eprop == flowSource) || isall) {
result.add(ef);
}
}
return result;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath 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.ErrorPath in project osate2 by osate.
the class EMV2Util method findErrorFlowFromComponentInstance.
public static EList<ErrorFlow> findErrorFlowFromComponentInstance(ComponentInstance component, ErrorPropagation flowSource) {
EList<ErrorFlow> result = new BasicEList<ErrorFlow>();
Collection<ErrorFlow> efs = EMV2Util.getAllErrorFlows(component.getComponentClassifier());
ErrorFlow toAdd;
for (ErrorFlow ef : efs) {
ErrorPropagation eprop = null;
toAdd = ef;
boolean isall = false;
if (ef instanceof ErrorPath) {
ErrorPath ep = (ErrorPath) ef;
eprop = ep.getIncoming();
isall = ep.isAllIncoming();
} else if (ef instanceof ErrorSink) {
ErrorSink es = (ErrorSink) ef;
eprop = es.getIncoming();
isall = es.isAllIncoming();
}
if ((eprop != null && eprop == flowSource) || isall) {
result.add(toAdd);
}
}
return result;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath in project osate2 by osate.
the class ErrorModelValidator method checkErrorPathTypes.
private void checkErrorPathTypes(ErrorPath ef) {
ErrorPropagation epin = ef.getIncoming();
ErrorPropagation epout = ef.getOutgoing();
if (ef.getTypeTokenConstraint() != null) {
// in prop
if (epin != null) {
if (!EMV2TypeSetUtil.contains(epin.getTypeSet(), ef.getTypeTokenConstraint())) {
error(ef, "Type token constraint is not contained in type set of incoming propagation " + EMV2Util.getPrintName(epin));
}
} else {
// check containment for all of the incoming propagation points
Classifier cl = ef.getContainingClassifier();
Collection<ErrorPropagation> eps = EMV2Util.getAllIncomingErrorPropagations(cl);
for (ErrorPropagation errorPropagation : eps) {
if (!EMV2TypeSetUtil.contains(errorPropagation.getTypeSet(), ef.getTypeTokenConstraint())) {
error(ef, "Type token constraint is not contained in type set of incoming propagation " + EMV2Util.getPrintName(errorPropagation));
}
}
}
}
if (ef.getTargetToken() != null) {
// check that outoging flow type token is contained in that of prop
if (epout != null) {
if (!EMV2TypeSetUtil.contains(epout.getTypeSet(), ef.getTargetToken())) {
error(ef, "Target token is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(epout));
}
} else {
// check containment for all of the outgoing propagation points
Classifier cl = ef.getContainingClassifier();
Collection<ErrorPropagation> eps = EMV2Util.getAllOutgoingErrorPropagations(cl);
for (ErrorPropagation errorPropagation : eps) {
if (!EMV2TypeSetUtil.contains(errorPropagation.getTypeSet(), ef.getTargetToken())) {
error(ef, "Target token is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(errorPropagation));
}
}
}
// ensures only one error type is associated with the target error type
TypeSet ts = ef.getTargetToken();
if (ts.getTypeTokens().size() > 1) {
error(ef, "Outgoing propagation may only have a single error type");
}
TypeToken tt = ts.getTypeTokens().get(0);
if (tt != null && tt.getType() != null && !(tt.getType().get(0) instanceof ErrorType)) {
error(ef, "Outgoing propagation may only have a single error type");
}
} else {
// no outgoing path type token
if (ef.getTypeTokenConstraint() != null) {
// match the incoming path constraint
if (epout != null) {
// need to handle use mappings
if (!EMV2TypeSetUtil.contains(epout.getTypeSet(), ef.getTypeTokenConstraint())) {
error(ef, "Incoming path type constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(epout));
}
} else {
// check containment for all of the outgoing propagation
// points
Classifier cl = ef.getContainingClassifier();
Collection<ErrorPropagation> eps = EMV2Util.getAllOutgoingErrorPropagations(cl);
for (ErrorPropagation errorPropagation : eps) {
if (!EMV2TypeSetUtil.contains(errorPropagation.getTypeSet(), ef.getTypeTokenConstraint())) {
error(ef, "Incoming path type constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(errorPropagation));
}
}
}
} else {
// check in to out type set of propagations for the flow
if (epout != null && epin != null) {
if (!EMV2TypeSetUtil.contains(epout.getTypeSet(), epin.getTypeSet())) {
error(ef, "Incoming error propagation " + EMV2Util.getPrintName(epin) + " constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(epout));
}
} else if (epout == null && epin != null) {
// check containment for all of the outgoing propagation
// points against one incoming
Classifier cl = ef.getContainingClassifier();
Collection<ErrorPropagation> eps = EMV2Util.getAllOutgoingErrorPropagations(cl);
for (ErrorPropagation allepout : eps) {
if (!EMV2TypeSetUtil.contains(allepout.getTypeSet(), epin.getTypeSet())) {
error(ef, "Incoming error propagation " + EMV2Util.getPrintName(epin) + " constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(allepout));
}
}
} else if (epout != null && epin == null) {
// check containment for all of the outgoing propagation
// points against one incoming
Classifier cl = ef.getContainingClassifier();
Collection<ErrorPropagation> eps = EMV2Util.getAllIncomingErrorPropagations(cl);
for (ErrorPropagation errorPropagation : eps) {
if (!EMV2TypeSetUtil.contains(epout.getTypeSet(), errorPropagation.getTypeSet())) {
error(ef, "Incoming error propagation " + EMV2Util.getPrintName(errorPropagation) + " constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(epout));
}
}
} else if (epout == null && epin == null) {
// check containment for all of the outgoing propagation
// points against one incoming
Classifier cl = ef.getContainingClassifier();
Collection<ErrorPropagation> epsin = EMV2Util.getAllIncomingErrorPropagations(cl);
Collection<ErrorPropagation> epsout = EMV2Util.getAllOutgoingErrorPropagations(cl);
for (ErrorPropagation allepout : epsout) {
for (ErrorPropagation allepin : epsin) {
if (!EMV2TypeSetUtil.contains(allepout.getTypeSet(), allepin.getTypeSet())) {
error(ef, "Incoming error propagation " + EMV2Util.getPrintName(allepin) + " constraint is not contained in type set of outgoing propagation " + EMV2Util.getPrintName(allepout));
}
}
}
}
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath in project osate2 by osate.
the class ErrorModelValidator method checkFlowDirection.
private void checkFlowDirection(ErrorPath errorPath) {
ErrorPropagation ep = errorPath.getIncoming();
if (!Aadl2Util.isNull(ep)) {
DirectionType epd = ep.getDirection();
if (!(epd.equals(DirectionType.IN))) {
error(errorPath, "Source " + EMV2Util.getPrintName(ep) + " of error path is not an incoming propagation point.");
}
}
ep = errorPath.getOutgoing();
if (!Aadl2Util.isNull(ep)) {
DirectionType epd = ep.getDirection();
if (!(epd.equals(DirectionType.OUT))) {
error(errorPath, "Target " + EMV2Util.getPrintName(ep) + " of error path is not an outgoing propagation point.");
}
}
}
Aggregations