Search in sources :

Example 66 with InstanceObject

use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.

the class BusLoadAnalysis method analysisBody.

public void analysisBody(final IProgressMonitor monitor, final Element obj) {
    if (obj instanceof InstanceObject) {
        SystemInstance root = ((InstanceObject) obj).getSystemInstance();
        monitor.beginTask(actionName, IProgressMonitor.UNKNOWN);
        final SOMIterator soms = new SOMIterator(root);
        while (soms.hasNext()) {
            final SystemOperationMode som = soms.nextSOM();
            checkBusLoads(root, som);
        }
        monitor.done();
    } else {
        Dialog.showError("Bound Bus Bandwidth Analysis Error", "Can only check system instances");
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) SystemInstance(org.osate.aadl2.instance.SystemInstance) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode)

Example 67 with InstanceObject

use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.

the class NotBoundResourceAnalysisHandler method doAaxlAction.

@Override
public void doAaxlAction(IProgressMonitor monitor, Element obj) {
    // Get the system instance (if any)
    final SystemInstance si = (obj instanceof InstanceObject) ? ((InstanceObject) obj).getSystemInstance() : null;
    if (si != null) {
        monitor.beginTask(getActionName(), IProgressMonitor.UNKNOWN);
        NotBoundResourceAnalysis logic = null;
        logic = new NotBoundResourceAnalysis(this);
        final SOMIterator soms = new SOMIterator(si);
        while (soms.hasNext()) {
            logic.analyzeResourceBudget(si, soms.next());
        }
        monitor.done();
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) SystemInstance(org.osate.aadl2.instance.SystemInstance) NotBoundResourceAnalysis(org.osate.analysis.resource.budgets.logic.NotBoundResourceAnalysis)

Example 68 with InstanceObject

use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.

the class ResoluteInterface method executeResoluteFunctionOnce.

/**
 * invokes Resolute claim function on targetComponent or targetElement if not null.
 * instanceroot is used to initialize the Resolute evaluation context.
 * targetComponent is the evaluation context
 * targetElement is the model element within the component instance or null.
 * parameterObjects is a list of additional parameters of types RealLiteral, IntegerLiteral, StringLiteral, BooleanLiteral
 * parameterObjects can be null or an empty list.
 * The return value is an Issue object with subissues for the list of issues returned in the Resolute ClaimResult.
 * If the proof fails then the top Issue is set to FAIL, if successful it is set to SUCCESS
 */
public EObject executeResoluteFunctionOnce(EObject fundef, final ComponentInstance targetComponent, final InstanceObject targetElement, List<PropertyExpression> parameterObjects) {
    FunctionDefinition fd = (FunctionDefinition) fundef;
    initializeResoluteContext(targetComponent.getSystemInstance());
    EvaluationContext context = new EvaluationContext(targetComponent, sets, featToConnsMap);
    // check for claim function
    FnCallExpr fcncall = createWrapperFunctionCall(fd, targetElement, parameterObjects);
    if (fcncall != null) {
        // if (fcncall.getFn().getBody() instanceof ClaimBody) {
        // using com.rockwellcollins.atc.resolute.analysis.results.ClaimResult
        ResoluteProver prover = new ResoluteProver(context) {

            @Override
            protected ResoluteEvaluator createResoluteEvaluator() {
                return new ResoluteEvaluator(context, varStack.peek()) {

                    @Override
                    public ResoluteValue caseThisExpr(ThisExpr object) {
                        // We prepare a thisexpr with either the component instance as context object or a single reference to a model element
                        // See createWrapperFunctionCall
                        NamedElement curr = context.getThisInstance();
                        if (object.getSub() != null) {
                            curr = object.getSub().getBase();
                        }
                        return new NamedElementValue(curr);
                    }
                };
            }
        };
        try {
            ResoluteResult res = prover.doSwitch(fcncall);
            return doResoluteResults(res);
        } catch (ResoluteFailException e) {
            return ResultUtil.createFailureResult(e.getMessage(), targetElement);
        }
    // } else {
    // // computational function
    // ResoluteEvaluator engine = new ResoluteEvaluator(context, null) {
    // @Override
    // public ResoluteValue caseThisExpr(ThisExpr object) {
    // // We prepare a thisexpr with either the component instance as context object or a single reference to a model element
    // // See createWrapperFunctionCall
    // NamedElement curr = context.getThisInstance();
    // if (object.getSub() != null) {
    // curr = object.getSub().getBase();
    // }
    // return new NamedElementValue(curr);
    // }
    // };
    // Object res = engine.doSwitch(fcncall);
    // return null;
    // }
    } else {
        return ResultUtil.createErrorDiagnostic("Could not find Resolute Function " + fd.getName(), fd);
    }
}
Also used : ResoluteEvaluator(com.rockwellcollins.atc.resolute.analysis.execution.ResoluteEvaluator) ResoluteResult(com.rockwellcollins.atc.resolute.analysis.results.ResoluteResult) NamedElementValue(com.rockwellcollins.atc.resolute.analysis.values.NamedElementValue) FunctionDefinition(com.rockwellcollins.atc.resolute.resolute.FunctionDefinition) ResoluteFailException(com.rockwellcollins.atc.resolute.analysis.execution.ResoluteFailException) EvaluationContext(com.rockwellcollins.atc.resolute.analysis.execution.EvaluationContext) FnCallExpr(com.rockwellcollins.atc.resolute.resolute.FnCallExpr) NamedElement(org.osate.aadl2.NamedElement) ResoluteProver(com.rockwellcollins.atc.resolute.analysis.execution.ResoluteProver) ThisExpr(com.rockwellcollins.atc.resolute.resolute.ThisExpr)

Example 69 with InstanceObject

use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.

the class CheckBindingConstraints method runAnalysis.

public static List<Issue> runAnalysis(IProgressMonitor monitor, SystemInstance si) {
    List<Issue> issuesList = new ArrayList<>();
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
    System.out.println(si.getSystemOperationModes().size());
    SubMonitor loopMonitor = subMonitor.split(100).setWorkRemaining(si.getSystemOperationModes().size());
    for (SOMIterator somIter = new SOMIterator(si); somIter.hasNext(); ) {
        SystemOperationMode som = somIter.next();
        SubMonitor iterationMonitor = loopMonitor.split(1);
        iterationMonitor.setWorkRemaining(8);
        // Processor binding
        SubMonitor processorChild = iterationMonitor.split(2);
        subMonitor.setTaskName("Getting Processor Binding Components");
        processorChild.split(1);
        List<ComponentInstance> processorBindingComponents = getComponents(monitor, si, ComponentCategory.THREAD, ComponentCategory.VIRTUAL_PROCESSOR, ComponentCategory.DEVICE).collect(Collectors.toList());
        processorChild.setTaskName("Checking Processor Bindings");
        processorChild.split(1);
        issuesList.addAll(checkBindingConstraints(processorBindingComponents.stream(), "processor", GetProperties::getActualProcessorBinding, GetProperties::getAllowedProcessorBinding, GetProperties::getAllowedProcessorBindingClass, som));
        // Dispatch Protocol
        subMonitor.setTaskName("Checking Dispacth Protocols");
        SubMonitor dispatchChild = iterationMonitor.split(1);
        issuesList.addAll(checkDispatchProtocol(processorBindingComponents.stream(), som));
        // Memory binding
        subMonitor.setTaskName("Getting Memory Components");
        SubMonitor memrChild = iterationMonitor.split(2);
        memrChild.split(1);
        Stream<ComponentInstance> memoryBindingComponents = getComponents(monitor, si, ComponentCategory.THREAD, ComponentCategory.DEVICE, ComponentCategory.DATA, ComponentCategory.SUBPROGRAM, ComponentCategory.PROCESSOR, ComponentCategory.VIRTUAL_PROCESSOR);
        subMonitor.setTaskName("Checking Memory Bindings");
        memrChild.split(1);
        Stream<FeatureInstance> memoryBindingFeatures = getFeatures(monitor, si, FeatureCategory.DATA_PORT, FeatureCategory.EVENT_DATA_PORT);
        Stream<InstanceObject> memoryBindingElements = Stream.concat(memoryBindingComponents, memoryBindingFeatures);
        issuesList.addAll(checkBindingConstraints(memoryBindingElements, "memory", GetProperties::getActualMemoryBinding, GetProperties::getAllowedMemoryBinding, GetProperties::getAllowedMemoryBindingClass, som));
        // Connection binding (only handles connection and virtual bus)
        subMonitor.setTaskName("Checking Connection Bindings");
        SubMonitor conenctionChild = iterationMonitor.split(1);
        Stream<ComponentInstance> connectionBindingComponents = getComponents(monitor, si, ComponentCategory.VIRTUAL_BUS);
        Stream<ConnectionInstance> connectionBindingConnections = getConnections(monitor, si);
        List<InstanceObject> connectionBindingElements = Stream.concat(connectionBindingComponents, connectionBindingConnections).collect(Collectors.toList());
        issuesList.addAll(checkBindingConstraints(connectionBindingElements.stream(), "connection", GetProperties::getActualConnectionBinding, GetProperties::getAllowedConnectionBinding, GetProperties::getAllowedConnectionBindingClass, som));
        // Connection Quality of Service
        subMonitor.setTaskName("Checking Connection Quality of Services");
        SubMonitor qualityChild = iterationMonitor.split(1);
        issuesList.addAll(checkRequiredAndProvided(connectionBindingElements.stream(), GetProperties::getRequiredConnectionQualityOfService, "Required_Connection_Quality_Of_Service", GetProperties::getProvidedConnectionQualityOfService, qos -> qos.getName(), som));
        // Virtual Bus Class
        subMonitor.setTaskName("Checking Virtual Bus Bindings");
        SubMonitor busChild = iterationMonitor.split(1);
        Function<ComponentInstance, Collection<ComponentClassifier>> getProvidedVBClass = boundElement -> {
            Stream<ComponentClassifier> providedProperty = GetProperties.getProvidedVirtualBusClass(boundElement).stream();
            Stream<ComponentClassifier> providedBySubcomponent = boundElement.getComponentInstances().stream().map(subcomponent -> subcomponent.getClassifier());
            return Stream.concat(providedProperty, providedBySubcomponent).collect(Collectors.toSet());
        };
        issuesList.addAll(checkRequiredAndProvided(connectionBindingElements.stream(), GetProperties::getRequiredVirtualBusClass, "Required_Virtual_Bus_Class", getProvidedVBClass, vbClass -> vbClass.getName(), som));
        busChild.setWorkRemaining(0);
    }
    subMonitor.setWorkRemaining(0);
    return issuesList;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Arrays(java.util.Arrays) Element(org.osate.aadl2.Element) Spliterators(java.util.Spliterators) SubMonitor(org.eclipse.core.runtime.SubMonitor) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) DeploymentProperties(org.osate.aadl2.contrib.deployment.DeploymentProperties) StreamSupport(java.util.stream.StreamSupport) GetProperties(org.osate.xtext.aadl2.properties.util.GetProperties) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) EnumSet(java.util.EnumSet) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) FeatureCategory(org.osate.aadl2.instance.FeatureCategory) SystemInstance(org.osate.aadl2.instance.SystemInstance) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) Iterator(java.util.Iterator) Aadl2Util(org.osate.aadl2.util.Aadl2Util) Collection(java.util.Collection) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) Collectors(java.util.stream.Collectors) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Consumer(java.util.function.Consumer) List(java.util.List) Stream(java.util.stream.Stream) ComponentCategory(org.osate.aadl2.ComponentCategory) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Optional(java.util.Optional) AaxlReadOnlyHandlerAsJob(org.osate.ui.handlers.AaxlReadOnlyHandlerAsJob) StringExtensions(org.eclipse.xtext.xbase.lib.StringExtensions) NamedElement(org.osate.aadl2.NamedElement) Collections(java.util.Collections) Spliterator(java.util.Spliterator) Dialog(org.osate.ui.dialogs.Dialog) InstanceObject(org.osate.aadl2.instance.InstanceObject) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ArrayList(java.util.ArrayList) SubMonitor(org.eclipse.core.runtime.SubMonitor) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) InstanceObject(org.osate.aadl2.instance.InstanceObject) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Collection(java.util.Collection) Stream(java.util.stream.Stream)

Example 70 with InstanceObject

use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.

the class DeploymentProperties method getAllowedPhysicalAccess.

public static Optional<List<InstanceObject>> getAllowedPhysicalAccess(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getAllowedPhysicalAccess_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return ((InstanceReferenceValue) resolved1).getReferencedInstanceObject();
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Property(org.osate.aadl2.Property)

Aggregations

InstanceObject (org.osate.aadl2.instance.InstanceObject)77 PropertyExpression (org.osate.aadl2.PropertyExpression)38 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)36 Property (org.osate.aadl2.Property)35 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)31 SystemInstance (org.osate.aadl2.instance.SystemInstance)27 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)24 ArrayList (java.util.ArrayList)19 ListValue (org.osate.aadl2.ListValue)17 NamedElement (org.osate.aadl2.NamedElement)17 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)15 Element (org.osate.aadl2.Element)14 Classifier (org.osate.aadl2.Classifier)13 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)12 List (java.util.List)11 EObject (org.eclipse.emf.ecore.EObject)11 Resource (org.eclipse.emf.ecore.resource.Resource)10 ComponentClassifier (org.osate.aadl2.ComponentClassifier)10 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)10 URI (org.eclipse.emf.common.util.URI)9