Search in sources :

Example 21 with Context

use of org.osate.aadl2.Context in project osate2 by osate.

the class EMV2Properties method isErrorModelElementProperty.

/**
 * return the containment path if the stack combined with the target and optionally the type set match the containment path of a property association.
 * It is sufficient for one of the paths in the PA to match.
 * ciStack represents the path from the context of the PA to the component instance whose property we want to retrieve
 * The desired type set ts must be contained in the type set named in the containment path
 * @param propertyAssociation PropertyAssociation that is the candidate
 * @param ciStack (can be null or empty) ComponentInstance in instance model hierarchy with the error model element, whose property we are retrieving (or null)
 * @param target Element the target object in the error model whose property we retrieve
 * @param ts type set that must contain the last element if it is a type
 * @return ContainedNamedElement the containment path that matches
 */
public static EMV2PropertyAssociation isErrorModelElementProperty(EMV2PropertyAssociation propertyAssociation, NamedElement target, Stack<NamedElement> ciStack, ErrorTypes ts) {
    boolean matchStack = false;
    EList<EMV2Path> applies = propertyAssociation.getEmv2Path();
    for (EMV2Path emv2Path : applies) {
        ContainmentPathElement cp = emv2Path.getContainmentPath();
        if (cp != null) {
            matchStack = matchCIStack(ciStack, cp);
        } else {
            matchStack = matchCIStack(ciStack, emv2Path.getEmv2Target());
        }
        if (matchStack) {
            // we are past the component portion of the path
            String targetName = EMV2Util.getPrintName(target);
            NamedElement pathTargetEME = EMV2Util.getErrorModelElement(emv2Path);
            String pathName = EMV2Util.getPrintName(pathTargetEME);
            if (targetName.equalsIgnoreCase(pathName)) {
                ErrorTypes typeelement = EMV2Util.getErrorType(emv2Path);
                if (typeelement != null && ts != null) {
                    // check to see if the desired ts is contained in the PA containment path
                    if (EMV2TypeSetUtil.contains(ts, typeelement) || EMV2TypeSetUtil.contains(typeelement, ts)) {
                        return propertyAssociation;
                    }
                } else {
                    return propertyAssociation;
                }
            }
        }
    }
    return null;
}
Also used : EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) NamedElement(org.osate.aadl2.NamedElement) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)

Example 22 with Context

use of org.osate.aadl2.Context in project osate2 by osate.

the class ToolUtil method getAllReferencedPackageDiagnostics.

/**
 * Get the errors and warnings for the AADL packages whose contents are in the same tree as the specified business object context
 * @param boc the business object context whose tree will be used.
 * @return the errors and warnings.
 */
public static Set<Diagnostic> getAllReferencedPackageDiagnostics(final BusinessObjectContext boc) {
    // Find root to get all referenced package diagnostics
    final BusinessObjectContext root = findRoot(boc).orElseThrow(() -> new RuntimeException("Cannot find root"));
    // Get referenced packages of root boc
    final Set<AadlPackage> packages = getReferencedPackages(root);
    // Collect errors and warnings for referenced AADL packages
    final List<DiagnosticBuilder> diagnosticBuilders = new ArrayList<>();
    for (final AadlPackage pkg : packages) {
        ProjectUtil.getProjectForBo(pkg).ifPresent(project -> {
            final ResourceSet resourceSet = AadlModelAccessUtil.getLiveResourceSet(project);
            final DiagnosticBuilder diagnosticBuilder = new DiagnosticBuilder(pkg);
            // Model error and warning diagnostics
            populateDiagnostics(diagnosticBuilder, pkg, resourceSet);
            diagnosticBuilders.add(diagnosticBuilder);
        });
    }
    return diagnosticBuilders.stream().flatMap(DiagnosticBuilder::getDiagnostics).collect(toDiagnosticTreeSet());
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) ArrayList(java.util.ArrayList) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 23 with Context

use of org.osate.aadl2.Context in project osate2 by osate.

the class ConnectionReferenceImpl method setContext.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setContext(ComponentInstance newContext) {
    ComponentInstance oldContext = context;
    context = newContext;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, InstancePackage.CONNECTION_REFERENCE__CONTEXT, oldContext, context));
    }
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 24 with Context

use of org.osate.aadl2.Context in project osate2 by osate.

the class Aadl2Validator method checkFeatureGroupConnectionDirection.

/**
 * Check category of source and destination Section 9.5 Legality rules L5-8
 */
private void checkFeatureGroupConnectionDirection(Connection connection) {
    if (connection.isAllBidirectional()) {
        // this is checked separately
        return;
    }
    final ClassifierMatchingRule classifierMatchingRuleValue = org.osate.aadl2.contrib.modeling.ModelingProperties.getClassifierMatchingRule(connection).orElse(ClassifierMatchingRule.CLASSIFIER_MATCH);
    if (classifierMatchingRuleValue == ClassifierMatchingRule.SUBSET) {
        // in case of subset if the connection is directional we do not have to match
        return;
    }
    ConnectionEnd source = connection.getAllLastSource();
    ConnectionEnd destination = connection.getAllLastDestination();
    if (source instanceof FeatureGroupConnectionEnd && destination instanceof FeatureGroupConnectionEnd) {
        Context srccxt = connection.getAllSourceContext();
        Context dstcxt = connection.getAllDestinationContext();
        DirectionType sourceDirection = ((FeatureGroup) source).getDirection();
        List<NamedElement> sourceChain = getConnectionChain(connection.getRootConnection().getSource());
        if (isInvertNeeded(sourceChain.subList(0, sourceChain.size() - 1))) {
            sourceDirection = sourceDirection.getInverseDirection();
        }
        DirectionType destinationDirection = ((FeatureGroup) destination).getDirection();
        List<NamedElement> destinationChain = getConnectionChain(connection.getRootConnection().getDestination());
        if (isInvertNeeded(destinationChain.subList(0, destinationChain.size() - 1))) {
            destinationDirection = destinationDirection.getInverseDirection();
        }
        checkThroughConnection(connection);
        if (srccxt instanceof Subcomponent && dstcxt instanceof Subcomponent) {
            // sibling to sibling
            if (sourceDirection.equals(DirectionType.IN)) {
                error("The direction of the source " + source.getName() + " of a directional feature group connection must not be in", connection, Aadl2Package.eINSTANCE.getConnection_Source(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (sourceDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(sourceChain, DirectionType.IN, connection, Aadl2Package.eINSTANCE.getConnection_Source());
            }
            if (destinationDirection.equals(DirectionType.OUT)) {
                error("The direction of the destination " + destination.getName() + " of a directional feature group connection must not be out", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (destinationDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(destinationChain, DirectionType.OUT, connection, Aadl2Package.eINSTANCE.getConnection_Destination());
            }
        } else if (!(srccxt instanceof Subcomponent)) {
            // going down
            if (sourceDirection.equals(DirectionType.OUT)) {
                error("The direction of the source " + source.getName() + " of this incoming directional feature group connection must not be out", connection, Aadl2Package.eINSTANCE.getConnection_Source(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (sourceDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(sourceChain, DirectionType.OUT, connection, Aadl2Package.eINSTANCE.getConnection_Source());
            }
            if (destinationDirection.equals(DirectionType.OUT)) {
                error("The direction of the destination " + destination.getName() + " of this incoming directional feature group connection must not be out", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (destinationDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(destinationChain, DirectionType.OUT, connection, Aadl2Package.eINSTANCE.getConnection_Destination());
            }
        } else if (!(dstcxt instanceof Subcomponent)) {
            // going up
            if (sourceDirection.equals(DirectionType.IN)) {
                error("The direction of the source " + source.getName() + " of this outgoing directional feature group connection must not be in", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (sourceDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(sourceChain, DirectionType.IN, connection, Aadl2Package.eINSTANCE.getConnection_Source());
            }
            if (destinationDirection.equals(DirectionType.IN)) {
                error("The direction of the destination " + destination.getName() + " of this outgoing directional feature group connection must not be in", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (destinationDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(destinationChain, DirectionType.IN, connection, Aadl2Package.eINSTANCE.getConnection_Destination());
            }
        }
    }
}
Also used : ClassifierMatchingRule(org.osate.aadl2.contrib.modeling.ClassifierMatchingRule)

Example 25 with Context

use of org.osate.aadl2.Context in project osate2 by osate.

the class FaultTreeUtils method getAssignedProbability.

/**
 * return spec probability, i.e., probability assigned by property
 * @param context
 * @return
 */
public static String getAssignedProbability(EObject context) {
    Event ev = (Event) context;
    if (ev.getAssignedProbability() == null || ev.getAssignedProbability().compareTo(BigZero) == 0) {
        return "";
    }
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(context.eResource().getURI().segment(1));
    String specProb = String.format("%1$." + FaultTreeModel.getPrecision(project) + "e", ev.getAssignedProbability());
    return specProb + getScale(context);
}
Also used : Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) IProject(org.eclipse.core.resources.IProject)

Aggregations

Context (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context)58 Context (com.microsoft.z3.Context)39 CoreException (org.eclipse.core.runtime.CoreException)36 NamedElement (org.osate.aadl2.NamedElement)32 Context (org.osate.aadl2.Context)31 ArrayList (java.util.ArrayList)28 Subcomponent (org.osate.aadl2.Subcomponent)26 BoolExpr (com.microsoft.z3.BoolExpr)25 List (java.util.List)24 Feature (org.osate.aadl2.Feature)24 EObject (org.eclipse.emf.ecore.EObject)22 HashMap (java.util.HashMap)19 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)19 ServerInstance (org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)17 Classifier (org.osate.aadl2.Classifier)17 Map (java.util.Map)16 Test (org.junit.Test)16 ComponentClassifier (org.osate.aadl2.ComponentClassifier)16 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)15 Property (org.osate.aadl2.Property)15