Search in sources :

Example 16 with InstanceObject

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

the class FTAHandler method getTarget.

private InstanceObject getTarget(ISelection currentSelection) {
    if (currentSelection instanceof IStructuredSelection) {
        IStructuredSelection iss = (IStructuredSelection) currentSelection;
        if (iss.size() == 1) {
            Object obj = iss.getFirstElement();
            if (obj instanceof InstanceObject) {
                return (InstanceObject) obj;
            }
            if (obj instanceof EObjectURIWrapper) {
                EObject eObject = new ResourceSetImpl().getEObject(((EObjectURIWrapper) obj).getUri(), true);
                if (eObject instanceof InstanceObject) {
                    return (InstanceObject) eObject;
                }
            }
            if (obj instanceof IFile) {
                URI uri = OsateResourceUtil.toResourceURI((IFile) obj);
                Resource res = new ResourceSetImpl().getResource(uri, true);
                EList<EObject> rl = res.getContents();
                if (!rl.isEmpty()) {
                    return (InstanceObject) rl.get(0);
                }
            }
        }
    }
    return null;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) IFile(org.eclipse.core.resources.IFile) EObjectURIWrapper(org.osate.aadl2.modelsupport.EObjectURIWrapper) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) EObject(org.eclipse.emf.ecore.EObject) InstanceObject(org.osate.aadl2.instance.InstanceObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) URI(org.eclipse.emf.common.util.URI)

Example 17 with InstanceObject

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

the class FaultTreeUtils method getHazardDescriptionAndProbability.

public static String getHazardDescriptionAndProbability(EObject context) {
    if (context instanceof Event) {
        Event ev = (Event) context;
        FaultTree ft = (FaultTree) ev.eContainer();
        String hazardDescription = EMV2Properties.getHazardDescription((InstanceObject) ev.getRelatedInstanceObject(), (NamedElement) ev.getRelatedEMV2Object(), (ErrorTypes) ev.getRelatedErrorType());
        String labeltext = FaultTreeUtils.getDescription(ev);
        if (labeltext == null || labeltext.isEmpty()) {
            labeltext = ((Event) context).getName();
        }
        String msg = ev.getMessage() != null ? "\nMessage: " + ev.getMessage() : "";
        String problabel = "";
        if (isASharedEvent(ev)) {
            labeltext = "Dependent event: " + labeltext;
        } else if (ev == ft.getRoot()) {
            // mark probability with star if shared events are involved
            if (FaultTreeUtils.hasSharedEvents(ft)) {
                problabel = " (incl. dependent event probabilities)";
            }
        }
        if (hazardDescription == null) {
            return String.format("%1$s%4$s\nOccurrence probability %2$s%3$s", labeltext, getProbability(ev), problabel, msg);
        } else {
            return String.format("%1$s\n%3$s%5$s\nOccurrence probability %2$s%4$s", labeltext, getProbability(ev), "Hazard: " + hazardDescription, problabel, msg);
        }
    }
    return "";
}
Also used : FaultTree(org.osate.aadl2.errormodel.FaultTree.FaultTree) Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)

Example 18 with InstanceObject

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

the class UnhandledFaultsHandler method doAaxlAction.

@Override
public void doAaxlAction(IProgressMonitor monitor, Element obj) {
    monitor.beginTask("UnhandledFaults", IProgressMonitor.UNKNOWN);
    // Get the system instance (if any)
    SystemInstance si;
    if (obj instanceof InstanceObject) {
        si = ((InstanceObject) obj).getSystemInstance();
    } else {
        return;
    }
    setCSVLog("UnhandledFaults", si);
    PropagationGraph currentPropagationGraph = Util.generatePropagationGraph(si, false);
    Collection<PropagationGraphPath> pathlist = currentPropagationGraph.getPropagationGraphPaths();
    for (PropagationGraphPath path : pathlist) {
        checkPropagationPathErrorTypes(path);
    }
    monitor.done();
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) PropagationGraph(org.osate.aadl2.errormodel.PropagationGraph.PropagationGraph) SystemInstance(org.osate.aadl2.instance.SystemInstance) PropagationGraphPath(org.osate.aadl2.errormodel.PropagationGraph.PropagationGraphPath)

Example 19 with InstanceObject

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

the class GetProperties method getAllowedMemoryBindingClass.

public static List<Classifier> getAllowedMemoryBindingClass(final InstanceObject io) {
    Property allowedMemoryBindingClass = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.ALLOWED_MEMORY_BINDING_CLASS);
    ArrayList<Classifier> components = new ArrayList<>();
    List<? extends PropertyExpression> propertyValues;
    try {
        propertyValues = io.getPropertyValueList(allowedMemoryBindingClass);
    } catch (Exception e) {
        return components;
    }
    for (PropertyExpression propertyExpression : propertyValues) {
        components.add(((ClassifierValue) propertyExpression).getClassifier());
    }
    return components;
}
Also used : ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException)

Example 20 with InstanceObject

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

the class GetProperties method getAllowedConnectionBinding.

public static List<ComponentInstance> getAllowedConnectionBinding(final InstanceObject io) {
    ArrayList<ComponentInstance> components = new ArrayList<ComponentInstance>();
    Property allowedConnectionBinding = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.ALLOWED_CONNECTION_BINDING);
    List<? extends PropertyExpression> propertyValues;
    try {
        propertyValues = io.getPropertyValueList(allowedConnectionBinding);
    } catch (Exception e) {
        return components;
    }
    for (PropertyExpression propertyExpression : propertyValues) {
        components.add((ComponentInstance) ((InstanceReferenceValue) propertyExpression).getReferencedInstanceObject());
    }
    return components;
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException)

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