Search in sources :

Example 51 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class PropagationGraphBackwardTraversal method traverseErrorBehaviorState.

/**
 * process error state. Recursively deal with source states of transitions (an PRIORITY AND gate).
 * We only process error events (not recover or repair) and error propagations referenced by the expression.
 * @param component ComponentInstance
 * @param state ErrorBehaviorState
 * @param type ErrorTypes
 * @return EObject (can be null)
 */
public EObject traverseErrorBehaviorState(ComponentInstance component, ErrorBehaviorState state, TypeToken type, BigDecimal inscale) {
    if (state == null) {
        return null;
    }
    List<EObject> subResults = new LinkedList<EObject>();
    Collection<ErrorBehaviorTransition> transitions = EMV2Util.getAllErrorBehaviorTransitions(component);
    BigDecimal combinedscale = inscale;
    for (ErrorBehaviorTransition ebt : transitions) {
        ConditionExpression conditionExpression = null;
        BigDecimal branchscale = BigOne;
        boolean sameState = false;
        Collection<TypeToken> newtypes = new LinkedList<TypeToken>();
        if (ebt.getTarget() != null && EMV2Util.isSame(state, ebt.getTarget())) {
            if (ebt.getTargetToken() != null) {
                Collection<TypeToken> filteredtypes = filterTokenThroughConstraint(ebt.getTargetToken(), type);
                for (TypeToken filteredtype : filteredtypes) {
                    if (contains(ebt.getTargetToken(), filteredtype)) {
                        conditionExpression = ebt.getCondition();
                        if (ebt.getSource() != null && EMV2Util.isSame(state, ebt.getSource()) && isSame(type, ebt.getTypeTokenConstraint())) {
                            sameState = true;
                            newtypes.add(filteredtype);
                        }
                    }
                }
            } else {
                conditionExpression = ebt.getCondition();
                if (ebt.getSource() != null && EMV2Util.isSame(state, ebt.getSource()) && isSame(type, ebt.getTypeTokenConstraint())) {
                    sameState = true;
                    newtypes.add(type);
                }
            }
        } else if (!ebt.getDestinationBranches().isEmpty()) {
            // deal with transition branches
            EList<TransitionBranch> tbs = ebt.getDestinationBranches();
            for (TransitionBranch transitionBranch : tbs) {
                if (ebt.getSource() != null && EMV2Util.isSame(ebt.getSource(), transitionBranch.getTarget()) && ebt.getSource().getTypeSet() == null && transitionBranch.getTarget().getTypeSet() == null) {
                    sameState = true;
                }
                if (transitionBranch.getTarget() != null) {
                    if (EMV2Util.isSame(transitionBranch.getTarget(), state)) {
                        if (ebt.getTargetToken() != null) {
                            Collection<TypeToken> filteredtypes = filterTokenThroughConstraint(ebt.getTargetToken(), type);
                            for (TypeToken filteredtype : filteredtypes) {
                                if (contains(transitionBranch.getTargetToken(), filteredtype)) {
                                    conditionExpression = ebt.getCondition();
                                    if (EMV2Util.isSame(ebt.getSource(), state) && isSame(type, ebt.getTypeTokenConstraint())) {
                                        sameState = true;
                                        newtypes.add(filteredtype);
                                    }
                                }
                            }
                        } else {
                            conditionExpression = ebt.getCondition();
                        }
                    }
                } else if (transitionBranch.isSteadyState()) {
                    // same state
                    if (ebt.getSource() != null && EMV2Util.isSame(state, ebt.getSource()) && isSame(type, ebt.getTypeTokenConstraint())) {
                        conditionExpression = ebt.getCondition();
                        sameState = true;
                        newtypes.add(type);
                    }
                }
                if (conditionExpression != null) {
                    // get branch prob value
                    BranchValue val = transitionBranch.getValue();
                    if (val.getRealvalue() != null) {
                        branchscale = new BigDecimal(EMV2Util.stripUnderScore(val.getRealvalue()));
                    } else if (val.getSymboliclabel() != null) {
                        Classifier cl = EMV2Util.getAssociatedClassifier(ebt);
                        List<EMV2PropertyAssociation> pa = EMV2Properties.getProperty(val.getSymboliclabel().getQualifiedName(), cl, ebt, null);
                        for (EMV2PropertyAssociation emv2PropertyAssociation : pa) {
                            branchscale = BigDecimal.valueOf(EMV2Properties.getRealValue(emv2PropertyAssociation));
                        }
                    } else if (val.isOthers()) {
                        branchscale = BigOne;
                        for (TransitionBranch tb : tbs) {
                            BranchValue valcount = tb.getValue();
                            if (valcount.getRealvalue() != null) {
                                branchscale = branchscale.subtract(new BigDecimal(EMV2Util.stripUnderScore(valcount.getRealvalue())));
                            } else if (valcount.getSymboliclabel() != null) {
                                Classifier cl = EMV2Util.getAssociatedClassifier(ebt);
                                List<EMV2PropertyAssociation> pa = EMV2Properties.getProperty(valcount.getSymboliclabel().getQualifiedName(), cl, ebt, null);
                                for (EMV2PropertyAssociation emv2PropertyAssociation : pa) {
                                    branchscale = branchscale.subtract(new BigDecimal(EMV2Properties.getRealValue(emv2PropertyAssociation)));
                                }
                            }
                        }
                    }
                    // XXX why break?
                    break;
                }
            }
        } else if (ebt.isSteadyState()) {
            // same state
            if (ebt.getSource() != null && EMV2Util.isSame(state, ebt.getSource()) && isSame(type, ebt.getTypeTokenConstraint())) {
                conditionExpression = ebt.getCondition();
                sameState = true;
                newtypes.add(type);
            }
        }
        combinedscale = inscale.multiply(branchscale);
        if (!sameState && conditionExpression != null) {
            // don't include transition staying in same state
            EObject conditionResult = processCondition(component, conditionExpression, newtypes == null ? type : null, combinedscale, false);
            // we also do not traverse back if left is allstates.
            if (conditionResult != null) {
                EObject stateResult = null;
                if (!(sameState || ebt.isAllStates())) {
                    if (newtypes.isEmpty()) {
                        stateResult = traverseErrorBehaviorState(component, ebt.getSource(), null, combinedscale);
                    } else {
                        List<EObject> subsubResults = new LinkedList<EObject>();
                        for (TypeToken typeToken : newtypes) {
                            EObject newEvent = traverseErrorBehaviorState(component, state, typeToken, combinedscale);
                            if (newEvent != null) {
                                addSubresult(subsubResults, newEvent);
                            }
                        }
                        if (subsubResults.isEmpty()) {
                            stateResult = processErrorBehaviorState(component, state, type, inscale);
                        } else if (subsubResults.size() == 1) {
                            stateResult = subsubResults.get(0);
                        } else {
                            stateResult = processTypesetElements(component, state, type, subsubResults, combinedscale);
                        }
                    }
                }
                if (stateResult != null) {
                    EObject tmpresult = processTransitionCondition(component, ebt.getSource(), type, conditionResult, stateResult, combinedscale);
                    if (tmpresult != null) {
                        addSubresult(subResults, tmpresult);
                    }
                } else if (stateResult == null) {
                    addSubresult(subResults, conditionResult);
                }
            }
        }
    }
    if (!subResults.isEmpty()) {
        return postProcessErrorBehaviorState(component, state, type, subResults, combinedscale);
    }
    // or if no transitions specified for state machine
    if (transitions.isEmpty()) {
        // processErrorBehaviorState(component, state, type);
        return traverseCompositeErrorStateOnly(component, state, type, inscale);
    } else {
        // Do not include
        return null;
    }
}
Also used : TransitionBranch(org.osate.xtext.aadl2.errormodel.errorModel.TransitionBranch) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) BranchValue(org.osate.xtext.aadl2.errormodel.errorModel.BranchValue) Classifier(org.osate.aadl2.Classifier) LinkedList(java.util.LinkedList) BigDecimal(java.math.BigDecimal) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) 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) Collection(java.util.Collection)

Example 52 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class AadlImportsUtil method ensurePackageIsImportedForClassifier.

/**
 * Ensure that an element's package has the necessary imports to reference a specified object.
 * Only supports classifiers as the referenced object at this time.
 * If the referenced element is not a classifier, then the method does not perform any changes.
 * @param pkgContext is the object that needs to reference the containing object
 * @param referencedObject is the object which needs to be referenced.
 */
public static void ensurePackageIsImportedForClassifier(final Element pkgContext, final Object referencedObject) {
    final AadlPackage referencingPkg = (AadlPackage) pkgContext.getElementRoot();
    if (referencingPkg == null) {
        return;
    }
    final PackageSection referencingSection = referencingPkg.getPublicSection();
    if (referencedObject instanceof Classifier) {
        Classifier referencedClassifier = (Classifier) referencedObject;
        if (referencedClassifier.eIsProxy()) {
            referencedClassifier = (Classifier) EcoreUtil.resolve(referencedClassifier, pkgContext.eResource());
        }
        if (referencedClassifier.getNamespace() != null && referencedClassifier.getNamespace().getOwner() instanceof AadlPackage) {
            final AadlPackage referencedPkg = (AadlPackage) referencedClassifier.getNamespace().getOwner();
            addImportIfNeeded(referencingSection, referencedPkg);
        }
    }
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) PackageSection(org.osate.aadl2.PackageSection) Classifier(org.osate.aadl2.Classifier)

Example 53 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class AadlBusinessObjectProvider method getAllDefaultAnnexSubclauses.

/**
 * Returns all the default annex subclauses owned by a classifier or any extended or implemented classifiers.
 * @param topClassifier
 * @return
 */
private static EList<AnnexSubclause> getAllDefaultAnnexSubclauses(final Classifier topClassifier) {
    final EList<AnnexSubclause> result = new BasicEList<AnnexSubclause>();
    if (topClassifier == null) {
        return result;
    }
    final EList<Classifier> classifiers = topClassifier.getSelfPlusAllExtended();
    if (topClassifier instanceof ComponentImplementation) {
        ComponentType ct = ((ComponentImplementation) topClassifier).getType();
        if (ct != null) {
            // May be null in the case of an invalid model.
            final EList<Classifier> tclassifiers = ct.getSelfPlusAllExtended();
            classifiers.addAll(tclassifiers);
        }
    }
    for (Classifier classifier : classifiers) {
        result.addAll(classifier.getOwnedAnnexSubclauses());
    }
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) BasicEList(org.eclipse.emf.common.util.BasicEList) Classifier(org.osate.aadl2.Classifier) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 54 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class PackageSectionImpl method createOwnedClassifier.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Classifier createOwnedClassifier(EClass eClass) {
    Classifier newOwnedClassifier = (Classifier) create(eClass);
    getOwnedClassifiers().add(newOwnedClassifier);
    return newOwnedClassifier;
}
Also used : Classifier(org.osate.aadl2.Classifier)

Example 55 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class FlowLatencyAnalysisSwitch method processActualConnectionBindingsTransmission.

/*
	 * connOrVB - Can be a ConnectionInstance (initial call), ComponentInstance (bus or virtual bus bound to a connection or virtual bus)
	 *
	 * onBehalfOfConnection - The connection instance that is bound to this mess. When connOrVB is a connection instance then
	 * it must be that connOrVB == onBehalfOfConnection
	 */
private void processActualConnectionBindingsTransmission(final InstanceObject connOrVB, double transmissionDataSize, final LatencyContributor latencyContributor, final ConnectionInstance onBehalfOfConnection) {
    boolean willDoVirtualBuses = false;
    boolean willDoBuses = false;
    // look for actual binding if we have a connection instance or virtual bus instance
    final List<InstanceObject> bindings = DeploymentProperties.getActualConnectionBinding(connOrVB).orElse(Collections.emptyList());
    if (bindings.isEmpty()) {
        return;
    }
    for (InstanceObject componentInstance : bindings) {
        if (((ComponentInstance) componentInstance).getCategory().equals(ComponentCategory.VIRTUAL_BUS)) {
            willDoVirtualBuses = true;
        } else {
            willDoBuses = true;
        }
    }
    if (!willDoVirtualBuses) {
        /**
         * required virtual bus class indicates protocols the connection intends to use.
         * We also can have an actual connection binding to a virtual bus
         * If we have that we want to use that virtual bus overhead
         */
        List<Classifier> protocols = DeploymentProperties.getRequiredVirtualBusClass(connOrVB).orElse(Collections.emptyList());
        // XXX: [Code Coverage] protocols cannot be null.
        if ((protocols != null) && (protocols.size() > 0)) {
            // XXX: [Code Coverage] willDoBuses is always true if willDoVirtualBuses is false.
            if (willDoBuses) {
                latencyContributor.reportInfo("Adding required virtual bus contributions to bound bus");
            }
            transmissionDataSize = computeTotalDataSize(protocols, transmissionDataSize, latencyContributor, onBehalfOfConnection);
        }
    }
    for (InstanceObject componentInstance : bindings) {
        double wrappedDataSize = transmissionDataSize + AadlContribUtils.getDataSize((ComponentInstance) componentInstance, SizeUnits.BYTES);
        processTransmissionTime(componentInstance, wrappedDataSize, latencyContributor, onBehalfOfConnection);
        if (((ComponentInstance) componentInstance).getCategory().equals(ComponentCategory.VIRTUAL_BUS)) {
            processActualConnectionBindingsTransmission(componentInstance, wrappedDataSize, latencyContributor, onBehalfOfConnection);
        }
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier)

Aggregations

Classifier (org.osate.aadl2.Classifier)203 ComponentClassifier (org.osate.aadl2.ComponentClassifier)90 ComponentImplementation (org.osate.aadl2.ComponentImplementation)49 NamedElement (org.osate.aadl2.NamedElement)40 AadlPackage (org.osate.aadl2.AadlPackage)38 Subcomponent (org.osate.aadl2.Subcomponent)37 ComponentType (org.osate.aadl2.ComponentType)34 EObject (org.eclipse.emf.ecore.EObject)31 ArrayList (java.util.ArrayList)29 BasicEList (org.eclipse.emf.common.util.BasicEList)28 Feature (org.osate.aadl2.Feature)26 DataClassifier (org.osate.aadl2.DataClassifier)22 FeatureGroupType (org.osate.aadl2.FeatureGroupType)21 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)21 AnnexSubclause (org.osate.aadl2.AnnexSubclause)17 Element (org.osate.aadl2.Element)17 EList (org.eclipse.emf.common.util.EList)15 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)15 FeatureGroup (org.osate.aadl2.FeatureGroup)14 PropertyExpression (org.osate.aadl2.PropertyExpression)14