use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation in project osate2 by osate.
the class ErrorPathImpl method setIncoming.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setIncoming(ErrorPropagation newIncoming) {
ErrorPropagation oldIncoming = incoming;
incoming = newIncoming;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ErrorModelPackage.ERROR_PATH__INCOMING, oldIncoming, incoming));
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation in project osate2 by osate.
the class ErrorModelValidator method checkConditionElementType.
private void checkConditionElementType(ConditionElement conditionElement) {
EventOrPropagation ep = EMV2Util.getErrorEventOrPropagation(conditionElement);
if (ep == null) {
return;
}
TypeSet triggerTS = null;
String triggerName = "";
if (ep instanceof ErrorPropagation) {
triggerTS = ((ErrorPropagation) ep).getTypeSet();
triggerName = "propagation " + EMV2Util.getPrintName((ErrorPropagation) ep);
} else if (ep instanceof ErrorEvent) {
triggerTS = ((ErrorEvent) ep).getTypeSet();
triggerName = "event " + ((ErrorBehaviorEvent) ep).getName();
}
TypeSet condTS = conditionElement.getConstraint();
if (condTS == null) {
return;
}
if (triggerTS == null && condTS != null) {
// it is ok for a state not to have a type set.
error(conditionElement, "Condition has type constraint but referenced " + triggerName + " does not.");
} else if (!EMV2TypeSetUtil.isNoError(condTS) && !EMV2TypeSetUtil.contains(triggerTS, condTS)) {
error(conditionElement, "Condition type constraint " + EMV2Util.getPrintName(condTS) + "is not contained in type set " + EMV2Util.getPrintName(triggerTS) + "of referenced " + triggerName);
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation in project osate2 by osate.
the class ErrorModelValidator method checkTransitionTargetTriggerTypes.
private void checkTransitionTargetTriggerTypes(ErrorBehaviorTransition ebt) {
if (ebt.isSteadyState()) {
return;
}
ErrorBehaviorState targetstate = ebt.getTarget();
if (targetstate != null) {
TypeSet targetTS = targetstate.getTypeSet();
if (targetTS == null) {
return;
}
TypeSet tt = ebt.getTargetToken();
if (tt != null) {
return;
}
// state requires a type
if (ebt.getCondition() instanceof ConditionElement) {
// either the event must be typed or the source state must be typed
EventOrPropagation ep = EMV2Util.getErrorEventOrPropagation((ConditionElement) ebt.getCondition());
if (ep instanceof ErrorEvent) {
ErrorEvent ev = (ErrorEvent) ep;
TypeSet evTS = ev.getTypeSet();
if (evTS == null) {
TypeSet srcTS = ebt.getSource().getTypeSet();
if (srcTS == null) {
error(ebt, "Target state " + targetstate.getName() + " requires type but the triggering error event " + EMV2Util.getPrintName(ev) + " or source state " + EMV2Util.getPrintName(ebt.getSource()) + " does not have a type");
} else {
// source typeset must be contained in target type set
if (!EMV2TypeSetUtil.contains(targetTS, srcTS)) {
error(ebt, "Target state " + targetstate.getName() + " does not contain types of source state " + EMV2Util.getPrintName(ebt.getSource()));
}
}
} else {
// error event has type. It must be consistent with the expected state type
if (!EMV2TypeSetUtil.contains(targetTS, evTS)) {
error(ebt, "Target state " + targetstate.getName() + " does not contain types of error event " + EMV2Util.getPrintName(ev));
}
}
} else if (ep instanceof ErrorPropagation) {
ErrorPropagation eprop = (ErrorPropagation) ep;
// we can check type compatibility
if (!EMV2TypeSetUtil.contains(targetTS, eprop.getTypeSet())) {
error(ebt, "Target state " + targetstate.getName() + " does not contain types of error propagation " + EMV2Util.getPrintName(eprop));
}
}
} else {
// full condition expression
// type transformation & events must be typed
ErrorBehaviorStateMachine ebsm = (ErrorBehaviorStateMachine) targetstate.eContainer();
if (ebsm.getUseTransformation().isEmpty()) {
error(ebt, "Target state " + targetstate.getName() + " does not include a target type but requires types. For conditions on multiple elements a target type must be assigned explicitly or a type transformation must be specified in the error behavior state machine" + EMV2Util.getPrintName(ebsm));
}
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation in project osate2 by osate.
the class ErrorModelValidator method checkAssociationAppliesTo.
private void checkAssociationAppliesTo(final EMV2PropertyAssociation pa) {
final Property pn = pa.getProperty();
final EList<EMV2Path> appliesTo = pa.getEmv2Path();
if (appliesTo == null || appliesTo.size() == 0) {
Element element = pa.getOwner();
if (element instanceof NamedElement) {
final boolean applies = ((NamedElement) element).acceptsProperty(pn);
if (!applies) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + ((NamedElement) element).getName());
// error(pa,
// "Property " + pa.getQualifiedName() +
// " does not apply to " + element.eClass().getName());
}
}
} else {
for (EMV2Path cna : appliesTo) {
EMV2PathElement path = cna.getEmv2Target();
if (path != null) {
// only the last value is interesting to us
final EMV2PathElement ph = EMV2Util.getLast(path);
NamedElement ne = ph.getNamedElement();
if (ne instanceof ErrorTypes) {
ErrorTypes et = (ErrorTypes) ne;
EObject prev = ph.eContainer();
if (prev instanceof EMV2PathElement) {
ne = ((EMV2PathElement) prev).getNamedElement();
boolean noMatch = false;
if (ne instanceof ErrorBehaviorState) {
TypeSet ts = ((ErrorBehaviorState) ne).getTypeSet();
noMatch = ts != null && !EMV2TypeSetUtil.contains(ts, et);
} else if (ne instanceof ErrorPropagation) {
String epname = EMV2Util.getPrintName((ErrorPropagation) ne);
EList<ErrorPropagation> eplist = EMV2Util.getContainingErrorModelSubclause(ne).getPropagations();
Boolean foundType = false;
for (ErrorPropagation ep : eplist) {
if (epname.equalsIgnoreCase(EMV2Util.getPrintName(ep))) {
TypeSet ts = ep.getTypeSet();
if (EMV2TypeSetUtil.contains(ts, et)) {
foundType = true;
break;
}
}
}
noMatch = !foundType;
} else if (ne instanceof ErrorEvent) {
TypeSet ts = ((ErrorEvent) ne).getTypeSet();
noMatch = ts != null && !EMV2TypeSetUtil.contains(ts, et);
}
if (noMatch) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " applies to refers to type " + EMV2Util.getPrintName(et) + " not contained in type set of error propagation " + EMV2Util.getPrintName(ne));
}
}
}
if (!Aadl2Util.isNull(ne)) {
final boolean applies = ph.getNamedElement().acceptsProperty(pn);
if (!applies) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + EMV2Util.getPrintName(cna));
}
}
}
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation in project osate2 by osate.
the class ErrorModelValidator method caseErrorModelSubclause.
@Check(CheckType.FAST)
public void caseErrorModelSubclause(ErrorModelSubclause subclause) {
if (EcoreUtil2.getContainerOfType(subclause, FeatureGroupType.class) != null) {
error("Error model subclauses are not permitted in feature group types.", EcoreUtil2.getContainerOfType(subclause, DefaultAnnexSubclause.class), Aadl2Package.eINSTANCE.getNamedElement_Name());
return;
}
checkSubclauseAssociationToClassifier(subclause);
checkDuplicateSubclause(subclause);
checkOnePropagationAndContainmentPoint(subclause);
Collection<NamedElement> names = EMV2Util.getAllNamedElements(subclause);
List<NamedElement> doubles = EMV2Util.findDoubleNamedElementsInList(names);
for (NamedElement namedElement : doubles) {
if (!(namedElement instanceof ErrorPropagation)) {
error(namedElement, "Subclause has more than one element with the name '" + namedElement.getName() + "'.");
}
}
Collection<ErrorPropagation> ins = EMV2Util.getAllIncomingErrorPropagations(subclause.getContainingClassifier());
for (ErrorPropagation errorPropagation : ins) {
checkTypePropagationAndContainment(errorPropagation);
}
Collection<ErrorPropagation> outs = EMV2Util.getAllOutgoingErrorPropagations(subclause.getContainingClassifier());
for (ErrorPropagation errorPropagation : outs) {
checkTypePropagationAndContainment(errorPropagation);
}
checkUseBehavior(subclause);
}
Aggregations