Search in sources :

Example 6 with ConditionElement

use of org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement in project osate2 by osate.

the class CreateTransitionPaletteCommand method buildCreateOperation.

private Operation buildCreateOperation(final BusinessObjectContext srcBoc, final ErrorBehaviorState targetStateReadonly) {
    final Object srcBo = srcBoc.getBusinessObject();
    final URI targetStateUri = EcoreUtil.getURI(targetStateReadonly);
    if (srcBo instanceof ErrorBehaviorState) {
        final ErrorBehaviorState srcStateReadonly = (ErrorBehaviorState) srcBo;
        final URI srcStateUri = EcoreUtil.getURI(srcStateReadonly);
        return Operation.createWithBuilder(createOp -> createOp.supply(() -> StepResult.forValue(getStateMachine(srcStateReadonly))).modifyPreviousResult(stateMachine -> {
            final ErrorBehaviorState targetState = (ErrorBehaviorState) stateMachine.eResource().getResourceSet().getEObject(targetStateUri, true);
            final ErrorBehaviorState srcState = (ErrorBehaviorState) stateMachine.eResource().getResourceSet().getEObject(srcStateUri, true);
            final NamedElementCollectionSingleSelectorModel<ErrorBehaviorEvent> model = new NamedElementCollectionSingleSelectorModel<>(stateMachine.getEvents());
            if (!FilteringSelectorDialog.open(Display.getCurrent().getActiveShell(), "Select Event", new LabelFilteringListSelectorModel<>(model))) {
                return null;
            }
            final ErrorBehaviorEvent event = model.getSelectedElement();
            // Create the transition
            final ErrorBehaviorTransition newTransition = ErrorModelFactory.eINSTANCE.createErrorBehaviorTransition();
            newTransition.setSource(srcState);
            // Set the target
            if (srcState == targetState) {
                newTransition.setSteadyState(true);
            } else {
                newTransition.setTarget(targetState);
            }
            newTransition.setName(ErrorModelNamingUtil.buildUniqueIdentifier(stateMachine, "new_transition"));
            final ConditionElement conditionElement = ErrorModelFactory.eINSTANCE.createConditionElement();
            newTransition.setCondition(conditionElement);
            final EMV2PathElement conditionPathElement = ErrorModelFactory.eINSTANCE.createEMV2PathElement();
            conditionPathElement.setNamedElement(event);
            final QualifiedErrorEventOrPropagation errorEventOrPropogation = ErrorModelFactory.eINSTANCE.createQualifiedErrorEventOrPropagation();
            errorEventOrPropogation.setEmv2Target(conditionPathElement);
            conditionElement.setQualifiedErrorPropagationReference(errorEventOrPropogation);
            stateMachine.getTransitions().add(newTransition);
            return StepResultBuilder.create().showNewBusinessObject(srcBoc.getParent(), newTransition).build();
        }));
    } else if (srcBo instanceof ErrorBehaviorTransition || srcBo instanceof BehaviorTransitionTrunk || srcBo instanceof TransitionBranch) {
        // Get the transition to modify
        final ErrorBehaviorTransition transitionReadonly;
        if (srcBo instanceof ErrorBehaviorTransition) {
            transitionReadonly = (ErrorBehaviorTransition) srcBo;
        } else if (srcBo instanceof BehaviorTransitionTrunk) {
            transitionReadonly = ((BehaviorTransitionTrunk) srcBo).getTransition();
        } else if (srcBo instanceof TransitionBranch) {
            transitionReadonly = (ErrorBehaviorTransition) ((TransitionBranch) srcBo).eContainer();
        } else {
            throw new AadlGraphicalEditorException("Unexpected case: " + srcBo);
        }
        return Operation.createWithBuilder(createOp -> createOp.supply(() -> StepResult.forValue(transitionReadonly)).modifyPreviousResult(transition -> {
            final ErrorBehaviorState targetState = (ErrorBehaviorState) transition.eResource().getResourceSet().getEObject(targetStateUri, true);
            // Convert from using steady state and target field to using branches.
            if (transition.getDestinationBranches().isEmpty()) {
                final TransitionBranch firstBranch = ErrorModelFactory.eINSTANCE.createTransitionBranch();
                final BranchValue firstBranchValue = ErrorModelFactory.eINSTANCE.createBranchValue();
                firstBranchValue.setRealvalue("1.0");
                if (transition.isSteadyState()) {
                    firstBranch.setSteadyState(true);
                } else {
                    firstBranch.setTarget(transition.getTarget());
                }
                firstBranch.setValue(firstBranchValue);
                transition.getDestinationBranches().add(firstBranch);
                transition.eUnset(ErrorModelPackage.eINSTANCE.getErrorBehaviorTransition_Target());
                transition.eUnset(ErrorModelPackage.eINSTANCE.getErrorBehaviorTransition_TargetToken());
                transition.eUnset(ErrorModelPackage.eINSTANCE.getErrorBehaviorTransition_SteadyState());
            }
            // Create the new branch
            final TransitionBranch newBranch = ErrorModelFactory.eINSTANCE.createTransitionBranch();
            final BranchValue newBranchValue = ErrorModelFactory.eINSTANCE.createBranchValue();
            newBranchValue.setRealvalue("1.0");
            // Set the target
            if (transition.getSource() == targetState) {
                newBranch.setSteadyState(true);
            } else {
                newBranch.setTarget(targetState);
            }
            newBranch.setValue(newBranchValue);
            transition.getDestinationBranches().add(newBranch);
            return StepResultBuilder.create().build();
        }));
    } else {
        throw new AadlGraphicalEditorException("Unsupported case: " + srcBo);
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) NamedElementCollectionSingleSelectorModel(org.osate.ge.aadl2.ui.NamedElementCollectionSingleSelectorModel) URI(org.eclipse.emf.common.util.URI) StepResult(org.osate.ge.operations.StepResult) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) BehaviorTransitionTrunk(org.osate.ge.errormodel.model.BehaviorTransitionTrunk) GetCreateConnectionOperationContext(org.osate.ge.palette.GetCreateConnectionOperationContext) EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) BusinessObjectContext(org.osate.ge.BusinessObjectContext) BasePaletteCommand(org.osate.ge.palette.BasePaletteCommand) CanStartConnectionContext(org.osate.ge.palette.CanStartConnectionContext) CreateConnectionPaletteCommand(org.osate.ge.palette.CreateConnectionPaletteCommand) BranchValue(org.osate.xtext.aadl2.errormodel.errorModel.BranchValue) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) TransitionBranch(org.osate.xtext.aadl2.errormodel.errorModel.TransitionBranch) Operation(org.osate.ge.operations.Operation) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) EObject(org.eclipse.emf.ecore.EObject) Display(org.eclipse.swt.widgets.Display) ErrorModelNamingUtil(org.osate.ge.errormodel.util.ErrorModelNamingUtil) FilteringSelectorDialog(org.osate.ge.swt.selectors.FilteringSelectorDialog) ErrorModelFactory(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelFactory) ErrorBehaviorStateMachine(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine) LabelFilteringListSelectorModel(org.osate.ge.swt.selectors.LabelFilteringListSelectorModel) StepResultBuilder(org.osate.ge.operations.StepResultBuilder) ErrorBehaviorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorEvent) Optional(java.util.Optional) ErrorModelPackage(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelPackage) QualifiedErrorEventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorEventOrPropagation) EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) QualifiedErrorEventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorEventOrPropagation) TransitionBranch(org.osate.xtext.aadl2.errormodel.errorModel.TransitionBranch) NamedElementCollectionSingleSelectorModel(org.osate.ge.aadl2.ui.NamedElementCollectionSingleSelectorModel) BranchValue(org.osate.xtext.aadl2.errormodel.errorModel.BranchValue) URI(org.eclipse.emf.common.util.URI) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) ErrorBehaviorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorEvent) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) EObject(org.eclipse.emf.ecore.EObject) BehaviorTransitionTrunk(org.osate.ge.errormodel.model.BehaviorTransitionTrunk)

Example 7 with ConditionElement

use of org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement in project osate2 by osate.

the class PropagationGraphBackwardTraversal method processCondition.

/**
 * create the appropriate FTA events according to the expression.
 * When calculating the probability apply the specified scale to each probability..
 * Used to perform scaling according to the transition branch probability.
 * @param component
 * @param condition
 * @param type
 * @param scale
 * @param stateOnly do not trace via transitions
 * @return an EObject related to the condition (can be null)
 */
public EObject processCondition(ComponentInstance component, ConditionExpression condition, TypeToken type, BigDecimal scale, boolean stateOnly) {
    // Mapping of AND expression
    if (condition instanceof AndExpression) {
        preProcessAnd(component, condition, type, scale);
        AndExpression expression = (AndExpression) condition;
        List<EObject> subResults = new LinkedList<EObject>();
        for (ConditionExpression ce : expression.getOperands()) {
            EObject res = processCondition(component, ce, type, scale, stateOnly);
            if (res != null) {
                addSubresult(subResults, res);
            }
        }
        return postProcessAnd(component, condition, type, subResults, scale);
    }
    // Mapping of All expression
    if (condition instanceof AllExpression) {
        List<EObject> subResults = new LinkedList<EObject>();
        AllExpression allCondition = (AllExpression) condition;
        if (allCondition.getCount() == 0) {
            preProcessAnd(component, condition, type, scale);
            for (ConditionExpression ce : allCondition.getOperands()) {
                EObject res = processCondition(component, ce, type, scale, stateOnly);
                if (res != null) {
                    addSubresult(subResults, res);
                }
            }
        }
        return postProcessAnd(component, condition, type, subResults, scale);
    }
    // Mapping of OR expression
    if (condition instanceof OrExpression) {
        // XXX preProcessOr ?
        preProcessXor(component, condition, type, scale);
        OrExpression expression = (OrExpression) condition;
        List<EObject> subResults = new LinkedList<EObject>();
        for (ConditionExpression ce : expression.getOperands()) {
            EObject res = processCondition(component, ce, type, scale, stateOnly);
            if (res != null) {
                addSubresult(subResults, res);
            }
        }
        return postProcessXor(component, condition, type, scale, subResults);
    }
    // Mapping of ORMORE expression
    if (condition instanceof OrmoreExpression) {
        OrmoreExpression omCondition = (OrmoreExpression) condition;
        List<EObject> subResults = new LinkedList<EObject>();
        if (omCondition.getCount() == 1) {
            /* 1 ormore is mapped to a OR gate */
            preProcessOr(component, condition, type, scale);
            for (ConditionExpression ce : omCondition.getOperands()) {
                EObject res = processCondition(component, ce, type, scale, stateOnly);
                if (res != null) {
                    addSubresult(subResults, res);
                }
            }
            return postProcessOr(component, condition, type, subResults, scale);
        } else {
            /* x ormore with x > 1 is mapped to a ORMORE gate */
            preProcessOrMore(component, condition, type, scale);
            for (ConditionExpression ce : omCondition.getOperands()) {
                EObject res = processCondition(component, ce, type, scale, stateOnly);
                if (res != null) {
                    addSubresult(subResults, res);
                }
            }
            return postProcessOrMore(component, condition, type, subResults, scale);
        }
    }
    // Mapping of single condition element
    if (condition instanceof ConditionElement) {
        ConditionElement conditionElement = (ConditionElement) condition;
        if (condition instanceof SConditionElement) {
            SConditionElement sconditionElement = (SConditionElement) condition;
            if (sconditionElement.getQualifiedState() != null) {
                /**
                 * In the following, it seems that we reference another
                 * component. This is typically the case when the condition is
                 * within an composite error behavior.
                 *
                 * So, we find the referenced component in the component
                 * hierarchy and add all its contributors to the returned
                 * events.
                 */
                QualifiedErrorBehaviorState qs = sconditionElement.getQualifiedState();
                ComponentInstance referencedInstance = EMV2Util.getLastComponentInstance(qs, component);
                ErrorBehaviorState state = EMV2Util.getState(sconditionElement);
                // either original type or mapped to constraint in condition or type set on state declaration
                TypeSet referencedErrorType = (sconditionElement.getConstraint() != null) ? sconditionElement.getConstraint() : state.getTypeSet();
                if (referencedInstance != null) {
                    List<EObject> subResults = new LinkedList<EObject>();
                    if (referencedErrorType == null) {
                        EObject newEvent = traverseCompositeErrorState(referencedInstance, state, null, stateOnly, scale);
                        if (newEvent != null) {
                            addSubresult(subResults, newEvent);
                        }
                    } else {
                        // handle type set on states
                        // get incoming type from propagation
                        EList<TypeToken> leaftypes = EMV2TypeSetUtil.flattenTypesetElements(referencedErrorType);
                        for (TypeToken typeToken : leaftypes) {
                            EObject newEvent = traverseCompositeErrorState(referencedInstance, state, typeToken, stateOnly, scale);
                            if (newEvent != null) {
                                addSubresult(subResults, newEvent);
                            }
                        }
                    }
                    if (subResults.isEmpty()) {
                        return processErrorBehaviorState(referencedInstance, EMV2Util.getState(sconditionElement), type, scale);
                    } else if (subResults.size() == 1) {
                        return subResults.get(0);
                    } else {
                        return postProcessXor(component, sconditionElement, type, scale, subResults);
                    }
                }
                return processErrorBehaviorState(referencedInstance, EMV2Util.getState(sconditionElement), type, scale);
            } else if (sconditionElement.getQualifiedErrorPropagationReference() != null) {
                EMV2Path path = sconditionElement.getQualifiedErrorPropagationReference();
                ComponentInstance referencedInstance = EMV2Util.getLastComponentInstance(path, component);
                ErrorPropagation ep = EMV2Util.getErrorPropagation(path);
                // either original type or mapped to constraint in condition or type set on state declaration
                TypeSet referencedErrorType = (sconditionElement.getConstraint() != null) ? sconditionElement.getConstraint() : ep.getTypeSet();
                if (referencedInstance != null) {
                    // handle type set on states
                    // get incoming type from propagation
                    EList<TypeToken> leaftypes = EMV2TypeSetUtil.flattenTypesetElements(referencedErrorType);
                    List<EObject> subResults = new LinkedList<EObject>();
                    for (TypeToken typeToken : leaftypes) {
                        // XXX ErrorType newtype = mapTargetType(typeToken, type);
                        EObject newEvent = traverseIncomingErrorPropagation(referencedInstance, ep, typeToken, scale);
                        if (newEvent != null) {
                            addSubresult(subResults, newEvent);
                        }
                    }
                    if (subResults.isEmpty()) {
                        return processIncomingErrorPropagation(referencedInstance, ep, type, scale);
                    } else if (subResults.size() == 1) {
                        return subResults.get(0);
                    } else {
                        return postProcessXor(component, sconditionElement, type, scale, subResults);
                    }
                }
                return processErrorBehaviorState(referencedInstance, EMV2Util.getState(sconditionElement), type, scale);
            }
            // should not reach this
            return processErrorBehaviorState(component, EMV2Util.getState(sconditionElement), null, scale);
        }
        if (conditionElement.getConstraint() != null) {
            if (isNoError(conditionElement.getConstraint())) {
                // this is a recovery transition since an incoming propagation constraint is NoError
                return null;
            }
        }
        if (conditionElement.getQualifiedErrorPropagationReference() != null) {
            EMV2Path path = conditionElement.getQualifiedErrorPropagationReference();
            ComponentInstance relatedComponent = EMV2Util.getLastComponentInstance(path, component);
            NamedElement errorModelElement = EMV2Util.getErrorModelElement(path);
            /**
             * Here, we have an error event. Likely, this is something we
             * can get when we are analyzing error component behavior.
             */
            if (errorModelElement instanceof ErrorEvent) {
                if (Util.conditionHolds((ErrorEvent) errorModelElement, component)) {
                    Collection<TypeToken> referencedErrorTypes = conditionElement.getConstraint() != null ? mapTokenThroughConstraint(conditionElement.getConstraint(), type) : mapTokenThroughConstraint(((ErrorEvent) errorModelElement).getTypeSet(), type);
                    if (referencedErrorTypes.isEmpty()) {
                        if (type == null) {
                            return processErrorEvent(component, (ErrorEvent) errorModelElement, null, scale);
                        } else {
                            return null;
                        }
                    } else {
                        List<EObject> subResults = new LinkedList<EObject>();
                        if (type == null) {
                            for (TypeToken et : referencedErrorTypes) {
                                EObject newEvent = processErrorEvent(component, (ErrorEvent) errorModelElement, et, scale);
                                if (newEvent != null) {
                                    addSubresult(subResults, newEvent);
                                }
                            }
                        } else {
                            if (EMV2TypeSetUtil.contains(referencedErrorTypes, type)) {
                                return processErrorEvent(component, (ErrorEvent) errorModelElement, type, scale);
                            } else {
                                return null;
                            }
                        }
                        if (subResults.isEmpty()) {
                            return null;
                        } else if (subResults.size() == 1) {
                            return subResults.get(0);
                        } else {
                            return postProcessXor(component, conditionElement, type, scale, subResults);
                        }
                    }
                }
            }
            /**
             * Here, we have an error propagation. This is notified with the
             * in propagation within a composite error model.
             */
            if (errorModelElement instanceof ErrorPropagation) {
                ErrorPropagation errorPropagation = (ErrorPropagation) errorModelElement;
                // Collection<TypeToken> referencedErrorTypes = conditionElement.getConstraint() != null
                // ? filterFromIncomingPropagation(conditionElement.getConstraint(), type)
                // : filterFromIncomingPropagation(errorPropagation.getTypeSet(), type);
                Collection<TypeToken> referencedErrorTypes = conditionElement.getConstraint() != null ? EMV2TypeSetUtil.flattenTypesetElements(conditionElement.getConstraint()) : EMV2TypeSetUtil.flattenTypesetElements(errorPropagation.getTypeSet());
                List<EObject> subResults = new LinkedList<EObject>();
                for (TypeToken et : referencedErrorTypes) {
                    if (isNoError(et)) {
                        // this is a recovery transition since an incoming propagation became error free
                        continue;
                    }
                    if (errorPropagation.getDirection() == DirectionType.IN) {
                        EObject newEvent = traverseIncomingErrorPropagation(relatedComponent, errorPropagation, et, scale);
                        if (newEvent != null) {
                            addSubresult(subResults, newEvent);
                        }
                    } else {
                        EObject newEvent = traverseOutgoingErrorPropagation(relatedComponent, errorPropagation, et, scale);
                        if (newEvent != null) {
                            addSubresult(subResults, newEvent);
                        }
                    }
                }
                if (subResults.isEmpty()) {
                    return null;
                } else if (subResults.size() == 1) {
                    return subResults.get(0);
                } else {
                    return postProcessXor(component, conditionElement, type, scale, subResults);
                }
            }
        }
    }
    return null;
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) QualifiedErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState) AllExpression(org.osate.xtext.aadl2.errormodel.errorModel.AllExpression) OrmoreExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression) OrExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrExpression) LinkedList(java.util.LinkedList) SConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) SConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement) EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) AndExpression(org.osate.xtext.aadl2.errormodel.errorModel.AndExpression) EList(org.eclipse.emf.common.util.EList) ConditionExpression(org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) EObject(org.eclipse.emf.ecore.EObject) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) QualifiedErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) List(java.util.List) LinkedList(java.util.LinkedList) EList(org.eclipse.emf.common.util.EList) NamedElement(org.osate.aadl2.NamedElement)

Example 8 with ConditionElement

use of org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement in project osate2 by osate.

the class PropagationGraphBackwardTraversal method handleOutgoingErrorPropagationCondition.

/**
 * Process all OutgoingPropagationConditions that match the propagation and type of interest
 * It is an OR of the OutgoingPropagationConditions that match.
 * Fore each it is an AND of the source state (if it involves an error event or propagation).
 * @param component ComponentInstance
 * @param propagation (outgoing) ErrorPropagation
 * @param type TypeToken
 * @return Event (can be null)
 */
private EObject handleOutgoingErrorPropagationCondition(ComponentInstance component, OutgoingPropagationCondition opc, TypeToken type, HashMultimap<ErrorPropagation, String> handledEOPs, BigDecimal scale) {
    EObject conditionResult = null;
    EObject stateResult = null;
    if (opc.getCondition() != null) {
        conditionResult = processCondition(component, opc.getCondition(), opc.getCondition() == null ? type : null, FaultTreeUtils.BigOne, false);
    }
    ErrorBehaviorState state = opc.getState();
    if (state != null) {
        // use constraint as we have mapping
        TypeSet newtypeset = null;
        if (opc.getTypeTokenConstraint() != null) {
            newtypeset = opc.getTypeTokenConstraint();
        } else if (state.getTypeSet() != null) {
            newtypeset = state.getTypeSet();
        }
        List<EObject> subResults = new LinkedList<EObject>();
        if (newtypeset != null) {
            EList<TypeToken> types = flattenTypesetElements(newtypeset);
            for (TypeToken typeToken : types) {
                EObject res = traverseErrorBehaviorState(component, state, typeToken, scale);
                if (res != null) {
                    addSubresult(subResults, res);
                }
            }
            if (subResults.isEmpty()) {
                stateResult = processErrorBehaviorState(component, state, type, scale);
            } else if (subResults.size() == 1) {
                stateResult = subResults.get(0);
            } else {
                stateResult = postProcessXor(component, state, type, BigOne, subResults);
            }
        } else {
            stateResult = traverseErrorBehaviorState(component, state, null, scale);
        }
    }
    if (conditionResult == null && stateResult != null) {
        for (ErrorBehaviorTransition trans : EMV2Util.getAllErrorBehaviorTransitions(component)) {
            if (state == trans.getTarget()) {
                Collection<ConditionElement> conde = EMV2Util.getAllConditionElementsFromConditionExpression(trans.getCondition());
                for (ConditionElement conditionElement : conde) {
                    EventOrPropagation eop = EMV2Util.getErrorEventOrPropagation(conditionElement);
                    if (eop instanceof ErrorPropagation) {
                        handledEOPs.put((ErrorPropagation) eop, EMV2Util.getPrintName(type));
                    }
                }
            }
        }
    } else {
        // error paths
        Collection<ConditionElement> conde = EMV2Util.getAllConditionElementsFromConditionExpression(opc.getCondition());
        for (ConditionElement conditionElement : conde) {
            EventOrPropagation eop = EMV2Util.getErrorEventOrPropagation(conditionElement);
            if (eop instanceof ErrorPropagation) {
                handledEOPs.put((ErrorPropagation) eop, EMV2Util.getPrintName(type));
            }
        }
    }
    return processOutgoingErrorPropagationCondition(component, opc, type, conditionResult, stateResult, scale);
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) QualifiedErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState) SConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) EObject(org.eclipse.emf.ecore.EObject) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) LinkedList(java.util.LinkedList)

Example 9 with ConditionElement

use of org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement in project osate2 by osate.

the class AbstractErrorModelSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == Aadl2Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Aadl2Package.ARRAY_RANGE:
                sequence_ArrayRange(context, (ArrayRange) semanticObject);
                return;
            case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
                sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
                return;
            case Aadl2Package.BOOLEAN_LITERAL:
                sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
                return;
            case Aadl2Package.CLASSIFIER_VALUE:
                sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
                return;
            case Aadl2Package.COMPUTED_VALUE:
                sequence_ComputedTerm(context, (ComputedValue) semanticObject);
                return;
            case Aadl2Package.CONTAINED_NAMED_ELEMENT:
                sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
                return;
            case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
                sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
                return;
            case Aadl2Package.INTEGER_LITERAL:
                sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
                return;
            case Aadl2Package.LIST_VALUE:
                sequence_ListTerm(context, (ListValue) semanticObject);
                return;
            case Aadl2Package.MODAL_PROPERTY_VALUE:
                if (rule == grammarAccess.getModalPropertyValueRule()) {
                    sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
                    sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyValueRule()) {
                    sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.NAMED_VALUE:
                if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
                    sequence_ConstantValue(context, (NamedValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
                    sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.OPERATION:
                sequence_SignedConstant(context, (Operation) semanticObject);
                return;
            case Aadl2Package.PROPERTY_ASSOCIATION:
                if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
                    sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
                    sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyAssociationRule()) {
                    sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.RANGE_VALUE:
                sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
                return;
            case Aadl2Package.REAL_LITERAL:
                sequence_RealTerm(context, (RealLiteral) semanticObject);
                return;
            case Aadl2Package.RECORD_VALUE:
                if (rule == grammarAccess.getOldRecordTermRule()) {
                    sequence_OldRecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
                    sequence_RecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.REFERENCE_VALUE:
                sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
                return;
            case Aadl2Package.STRING_LITERAL:
                sequence_StringTerm(context, (StringLiteral) semanticObject);
                return;
        }
    else if (epackage == ErrorModelPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case ErrorModelPackage.ALL_EXPRESSION:
                if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getConditionExpressionRule() || action == grammarAccess.getConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getAndExpressionRule() || action == grammarAccess.getAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getAllExpressionRule() || rule == grammarAccess.getConditionTermRule()) {
                    sequence_AllExpression(context, (AllExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getSConditionExpressionRule() || action == grammarAccess.getSConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getSAndExpressionRule() || action == grammarAccess.getSAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getSAllExpressionRule() || rule == grammarAccess.getSConditionTermRule()) {
                    sequence_SAllExpression(context, (AllExpression) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.AND_EXPRESSION:
                if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getConditionExpressionRule() || action == grammarAccess.getConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getAndExpressionRule() || action == grammarAccess.getAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getConditionTermRule()) {
                    sequence_AndExpression(context, (AndExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getSConditionExpressionRule() || action == grammarAccess.getSConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getSAndExpressionRule() || action == grammarAccess.getSAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getSConditionTermRule()) {
                    sequence_SAndExpression(context, (AndExpression) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.BRANCH_VALUE:
                sequence_BranchValue(context, (BranchValue) semanticObject);
                return;
            case ErrorModelPackage.COMPOSITE_STATE:
                sequence_CompositeState(context, (CompositeState) semanticObject);
                return;
            case ErrorModelPackage.CONDITION_ELEMENT:
                sequence_ConditionElement(context, (ConditionElement) semanticObject);
                return;
            case ErrorModelPackage.EMV2_PATH:
                if (rule == grammarAccess.getBasicEMV2PathRule()) {
                    sequence_BasicEMV2Path(context, (EMV2Path) semanticObject);
                    return;
                } else if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getEMV2PathRule()) {
                    sequence_EMV2Path(context, (EMV2Path) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.EMV2_PATH_ELEMENT:
                if (rule == grammarAccess.getEMV2ErrorPropagationPathRule()) {
                    sequence_EMV2ErrorPropagationPath(context, (EMV2PathElement) semanticObject);
                    return;
                } else if (rule == grammarAccess.getEMV2PathElementOrKindRule()) {
                    sequence_EMV2PathElementOrKind(context, (EMV2PathElement) semanticObject);
                    return;
                } else if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getEMV2PathElementRule()) {
                    sequence_EMV2PathElement(context, (EMV2PathElement) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.EMV2_PROPERTY_ASSOCIATION:
                if (rule == grammarAccess.getBasicEMV2PropertyAssociationRule()) {
                    sequence_BasicEMV2PropertyAssociation(context, (EMV2PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getEMV2PropertyAssociationRule()) {
                    sequence_EMV2PropertyAssociation(context, (EMV2PropertyAssociation) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.EMV2_ROOT:
                sequence_EMV2Root(context, (EMV2Root) semanticObject);
                return;
            case ErrorModelPackage.ERROR_BEHAVIOR_STATE:
                sequence_ErrorBehaviorState(context, (ErrorBehaviorState) semanticObject);
                return;
            case ErrorModelPackage.ERROR_BEHAVIOR_STATE_MACHINE:
                sequence_ErrorBehaviorStateMachine(context, (ErrorBehaviorStateMachine) semanticObject);
                return;
            case ErrorModelPackage.ERROR_BEHAVIOR_TRANSITION:
                sequence_ErrorBehaviorTransition(context, (ErrorBehaviorTransition) semanticObject);
                return;
            case ErrorModelPackage.ERROR_CODE_VALUE:
                sequence_ErrorCodeValue(context, (ErrorCodeValue) semanticObject);
                return;
            case ErrorModelPackage.ERROR_DETECTION:
                sequence_ErrorDetection(context, (ErrorDetection) semanticObject);
                return;
            case ErrorModelPackage.ERROR_EVENT:
                sequence_ErrorEvent(context, (ErrorEvent) semanticObject);
                return;
            case ErrorModelPackage.ERROR_MODEL_LIBRARY:
                if (rule == grammarAccess.getEMV2LibraryRule()) {
                    sequence_EMV2Library(context, (ErrorModelLibrary) semanticObject);
                    return;
                } else if (rule == grammarAccess.getAnnexLibraryRule() || rule == grammarAccess.getNamedElementRule() || rule == grammarAccess.getErrorModelLibraryRule()) {
                    sequence_ErrorModelLibrary(context, (ErrorModelLibrary) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.ERROR_MODEL_SUBCLAUSE:
                if (rule == grammarAccess.getEMV2SubclauseRule()) {
                    sequence_EMV2Subclause(context, (ErrorModelSubclause) semanticObject);
                    return;
                } else if (rule == grammarAccess.getAnnexSubclauseRule() || rule == grammarAccess.getModalElementRule() || rule == grammarAccess.getErrorModelSubclauseRule()) {
                    sequence_ErrorModelSubclause(context, (ErrorModelSubclause) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.ERROR_PATH:
                sequence_ErrorPath(context, (ErrorPath) semanticObject);
                return;
            case ErrorModelPackage.ERROR_PROPAGATION:
                sequence_ErrorPropagation(context, (ErrorPropagation) semanticObject);
                return;
            case ErrorModelPackage.ERROR_SINK:
                sequence_ErrorSink(context, (ErrorSink) semanticObject);
                return;
            case ErrorModelPackage.ERROR_SOURCE:
                sequence_ErrorSource(context, (ErrorSource) semanticObject);
                return;
            case ErrorModelPackage.ERROR_STATE_TO_MODE_MAPPING:
                sequence_ErrorStateToModeMapping(context, (ErrorStateToModeMapping) semanticObject);
                return;
            case ErrorModelPackage.ERROR_TYPE:
                sequence_TypeDefinition(context, (ErrorType) semanticObject);
                return;
            case ErrorModelPackage.FEATUREOR_PP_REFERENCE:
                sequence_FeatureorPPReference(context, (FeatureorPPReference) semanticObject);
                return;
            case ErrorModelPackage.IF_CONDITION:
                sequence_IfCondition(context, (IfCondition) semanticObject);
                return;
            case ErrorModelPackage.OR_EXPRESSION:
                if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getConditionExpressionRule() || action == grammarAccess.getConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getAndExpressionRule() || action == grammarAccess.getAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getConditionTermRule()) {
                    sequence_ConditionExpression(context, (OrExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getSConditionExpressionRule() || action == grammarAccess.getSConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getSAndExpressionRule() || action == grammarAccess.getSAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getSConditionTermRule()) {
                    sequence_SConditionExpression(context, (OrExpression) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.ORLESS_EXPRESSION:
                if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getConditionExpressionRule() || action == grammarAccess.getConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getAndExpressionRule() || action == grammarAccess.getAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getOrlessExpressionRule() || rule == grammarAccess.getConditionTermRule()) {
                    sequence_OrlessExpression(context, (OrlessExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getSConditionExpressionRule() || action == grammarAccess.getSConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getSAndExpressionRule() || action == grammarAccess.getSAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getSOrlessExpressionRule() || rule == grammarAccess.getSConditionTermRule()) {
                    sequence_SOrlessExpression(context, (OrlessExpression) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.ORMORE_EXPRESSION:
                if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getConditionExpressionRule() || action == grammarAccess.getConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getAndExpressionRule() || action == grammarAccess.getAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getOrmoreExpressionRule() || rule == grammarAccess.getConditionTermRule()) {
                    sequence_OrmoreExpression(context, (OrmoreExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getSConditionExpressionRule() || action == grammarAccess.getSConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getSAndExpressionRule() || action == grammarAccess.getSAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getSOrmoreExpressionRule() || rule == grammarAccess.getSConditionTermRule()) {
                    sequence_SOrmoreExpression(context, (OrmoreExpression) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.OUTGOING_PROPAGATION_CONDITION:
                sequence_OutgoingPropagationCondition(context, (OutgoingPropagationCondition) semanticObject);
                return;
            case ErrorModelPackage.PROPAGATION_PATH:
                sequence_PropagationPath(context, (PropagationPath) semanticObject);
                return;
            case ErrorModelPackage.PROPAGATION_POINT:
                sequence_PropagationPoint(context, (PropagationPoint) semanticObject);
                return;
            case ErrorModelPackage.QUALIFIED_ERROR_BEHAVIOR_STATE:
                sequence_QualifiedErrorBehaviorState(context, (QualifiedErrorBehaviorState) semanticObject);
                return;
            case ErrorModelPackage.QUALIFIED_ERROR_EVENT_OR_PROPAGATION:
                sequence_QualifiedErrorEventOrPropagation(context, (QualifiedErrorEventOrPropagation) semanticObject);
                return;
            case ErrorModelPackage.QUALIFIED_ERROR_PROPAGATION:
                sequence_QualifiedErrorPropagation(context, (QualifiedErrorPropagation) semanticObject);
                return;
            case ErrorModelPackage.QUALIFIED_PROPAGATION_POINT:
                sequence_QualifiedPropagationPoint(context, (QualifiedPropagationPoint) semanticObject);
                return;
            case ErrorModelPackage.RECOVER_EVENT:
                sequence_RecoverEvent(context, (RecoverEvent) semanticObject);
                return;
            case ErrorModelPackage.REPAIR_EVENT:
                sequence_RepairEvent(context, (RepairEvent) semanticObject);
                return;
            case ErrorModelPackage.REPORTING_PORT_REFERENCE:
                sequence_ReportingPortReference(context, (ReportingPortReference) semanticObject);
                return;
            case ErrorModelPackage.SCONDITION_ELEMENT:
                sequence_SConditionElement(context, (SConditionElement) semanticObject);
                return;
            case ErrorModelPackage.SUBCOMPONENT_ELEMENT:
                sequence_SubcomponentElement(context, (SubcomponentElement) semanticObject);
                return;
            case ErrorModelPackage.TRANSITION_BRANCH:
                sequence_TransitionBranch(context, (TransitionBranch) semanticObject);
                return;
            case ErrorModelPackage.TYPE_MAPPING:
                sequence_TypeMapping(context, (TypeMapping) semanticObject);
                return;
            case ErrorModelPackage.TYPE_MAPPING_SET:
                sequence_TypeMappingSet(context, (TypeMappingSet) semanticObject);
                return;
            case ErrorModelPackage.TYPE_SET:
                if (rule == grammarAccess.getNoErrorTypeSetRule()) {
                    sequence_NoErrorTypeSet(context, (TypeSet) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeTokenOrNoErrorRule() || rule == grammarAccess.getTypeTokenConstraintNoErrorRule()) {
                    sequence_NoErrorTypeSet_TypeSetConstructor(context, (TypeSet) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeSetConstructorRule() || rule == grammarAccess.getTypeSetReferenceRule() || rule == grammarAccess.getTypeTokenRule() || rule == grammarAccess.getTypeTokenConstraintRule()) {
                    sequence_TypeSetConstructor(context, (TypeSet) semanticObject);
                    return;
                } else if (rule == grammarAccess.getNamedElementRule() || rule == grammarAccess.getErrorTypesRule() || rule == grammarAccess.getTypeSetDefinitionRule()) {
                    sequence_TypeSetDefinition(context, (TypeSet) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.TYPE_TOKEN:
                if (rule == grammarAccess.getNoErrorTypeTokenRule()) {
                    sequence_NoErrorTypeToken(context, (TypeToken) semanticObject);
                    return;
                } else if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getTypeSetElementRule()) {
                    sequence_TypeSetElement(context, (TypeToken) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.TYPE_TRANSFORMATION:
                sequence_TypeTransformation(context, (TypeTransformation) semanticObject);
                return;
            case ErrorModelPackage.TYPE_TRANSFORMATION_SET:
                sequence_TypeTransformationSet(context, (TypeTransformationSet) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) ParserRule(org.eclipse.xtext.ParserRule) ComputedValue(org.osate.aadl2.ComputedValue) Action(org.eclipse.xtext.Action) ClassifierValue(org.osate.aadl2.ClassifierValue) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) ErrorModelLibrary(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary) BooleanLiteral(org.osate.aadl2.BooleanLiteral) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ReferenceValue(org.osate.aadl2.ReferenceValue) AllExpression(org.osate.xtext.aadl2.errormodel.errorModel.AllExpression) OrlessExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrlessExpression) ArrayRange(org.osate.aadl2.ArrayRange) NamedValue(org.osate.aadl2.NamedValue) Operation(org.osate.aadl2.Operation) OrmoreExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression) OrExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrExpression) RangeValue(org.osate.aadl2.RangeValue) EPackage(org.eclipse.emf.ecore.EPackage) RealLiteral(org.osate.aadl2.RealLiteral) EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) AndExpression(org.osate.xtext.aadl2.errormodel.errorModel.AndExpression) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) IntegerLiteral(org.osate.aadl2.IntegerLiteral) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ListValue(org.osate.aadl2.ListValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) RecordValue(org.osate.aadl2.RecordValue) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) StringLiteral(org.osate.aadl2.StringLiteral) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) Parameter(org.eclipse.xtext.Parameter) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement)

Example 10 with ConditionElement

use of org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement in project osate2 by osate.

the class PropagateErrorSources method startErrorFlows.

/**
 * traverse error flow if the component instance is an error source
 * @param ci component instance
 */
public void startErrorFlows(ComponentInstance ci) {
    Collection<ErrorSource> eslist = EMV2Util.getAllErrorSources(ci.getComponentClassifier());
    String componentText = ci.getComponentInstancePath();
    HashMultimap<ErrorPropagation, String> handledPropagations = HashMultimap.create();
    for (ErrorBehaviorEvent event : EMV2Util.getAllErrorBehaviorEvents(ci)) {
        if (!(event instanceof ErrorEvent) || !Util.conditionHolds((ErrorEvent) event, ci)) {
            continue;
        }
        TypeSet sourcetype = ((ErrorEvent) event).getTypeSet();
        if (sourcetype == null) {
            // no type on event
            for (ErrorBehaviorTransition trans : EMV2Util.getAllErrorBehaviorTransitions(ci)) {
                if (trans.getCondition() instanceof ConditionElement) {
                    ConditionElement conditionElement = (ConditionElement) trans.getCondition();
                    processTransition(ci, event, null, trans, conditionElement, componentText, handledPropagations);
                } else if (trans.getCondition() instanceof OrmoreExpression) {
                    EList<ConditionExpression> elems = ((OrmoreExpression) trans.getCondition()).getOperands();
                    for (ConditionExpression conditionExpression : elems) {
                        if (conditionExpression instanceof ConditionElement) {
                            ConditionElement conditionElement = (ConditionElement) conditionExpression;
                            processTransition(ci, event, null, trans, conditionElement, componentText, handledPropagations);
                        }
                    }
                } else if (trans.getCondition() instanceof OrExpression) {
                    EList<ConditionExpression> elems = ((OrExpression) trans.getCondition()).getOperands();
                    for (ConditionExpression conditionExpression : elems) {
                        if (conditionExpression instanceof ConditionElement) {
                            ConditionElement conditionElement = (ConditionElement) conditionExpression;
                            processTransition(ci, event, null, trans, conditionElement, componentText, handledPropagations);
                        }
                    }
                }
            }
        } else {
            EList<TypeToken> tokens = EMV2TypeSetUtil.generateAllLeafTypeTokens(((ErrorEvent) event).getTypeSet(), EMV2Util.getUseTypes(event));
            for (TypeToken typeToken : tokens) {
                for (ErrorBehaviorTransition trans : EMV2Util.getAllErrorBehaviorTransitions(ci)) {
                    // the only one that makes sense is an or of error events
                    if (trans.getCondition() instanceof ConditionElement) {
                        ConditionElement conditionElement = (ConditionElement) trans.getCondition();
                        processTransition(ci, event, typeToken, trans, conditionElement, componentText, handledPropagations);
                    } else if (trans.getCondition() instanceof OrmoreExpression) {
                        EList<ConditionExpression> elems = ((OrmoreExpression) trans.getCondition()).getOperands();
                        for (ConditionExpression conditionExpression : elems) {
                            if (conditionExpression instanceof ConditionElement) {
                                ConditionElement conditionElement = (ConditionElement) conditionExpression;
                                processTransition(ci, event, typeToken, trans, conditionElement, componentText, handledPropagations);
                            }
                        }
                    } else if (trans.getCondition() instanceof OrExpression) {
                        EList<ConditionExpression> elems = ((OrExpression) trans.getCondition()).getOperands();
                        for (ConditionExpression conditionExpression : elems) {
                            if (conditionExpression instanceof ConditionElement) {
                                ConditionElement conditionElement = (ConditionElement) conditionExpression;
                                processTransition(ci, event, typeToken, trans, conditionElement, componentText, handledPropagations);
                            }
                        }
                    }
                }
            }
        }
    }
    for (ErrorSource errorSource : eslist) {
        if (!Util.conditionHolds(errorSource, ci)) {
            continue;
        }
        EMSUtil.unsetAll(ci.getSystemInstance());
        Collection<ErrorPropagation> eplist = EMV2Util.getOutgoingPropagationOrAll(errorSource);
        TypeSet ts = errorSource.getTypeTokenConstraint();
        ErrorBehaviorState failureMode = errorSource.getFailureModeReference();
        TypeSet failureTypeSet = null;
        if (failureMode != null) {
            failureTypeSet = failureMode.getTypeSet();
        } else {
            // reference to named type set
            // or type set constructor
            failureTypeSet = errorSource.getFailureModeType();
        }
        String failuremodeDesc = errorSource.getFailureModeDescription();
        for (ErrorPropagation ep : eplist) {
            TypeSet tsep = ep.getTypeSet();
            if (ts != null || tsep != null) {
                EList<TypeToken> result = ts != null ? ts.getTypeTokens() : tsep.getTypeTokens();
                for (TypeToken typeToken : result) {
                    String failuremodeText;
                    if (handledPropagations.containsEntry(ep, EMV2Util.getPrintName(typeToken))) {
                        continue;
                    }
                    if (failuremodeDesc == null) {
                        failuremodeText = generateOriginalFailureModeText(failureMode != null ? failureMode : (failureTypeSet != null ? failureTypeSet : typeToken));
                    } else {
                        failuremodeText = failuremodeDesc;
                    }
                    traceErrorPaths(ci, ep, typeToken, 2, componentText + "," + failuremodeText);
                }
            }
        }
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) OrmoreExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression) OrExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrExpression) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ErrorBehaviorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorEvent) BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) ConditionExpression(org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Aggregations

ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)10 ConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement)9 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)9 ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)8 SConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement)6 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)6 EObject (org.eclipse.emf.ecore.EObject)5 ConditionExpression (org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression)5 ErrorEvent (org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)5 EventOrPropagation (org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation)5 NamedElement (org.osate.aadl2.NamedElement)4 AndExpression (org.osate.xtext.aadl2.errormodel.errorModel.AndExpression)4 ErrorBehaviorTransition (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition)4 OrExpression (org.osate.xtext.aadl2.errormodel.errorModel.OrExpression)4 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)3 AllExpression (org.osate.xtext.aadl2.errormodel.errorModel.AllExpression)3 EMV2PathElement (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement)3 OrmoreExpression (org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression)3 QualifiedErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState)3 LinkedList (java.util.LinkedList)2