Search in sources :

Example 11 with InstanceObject

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

the class AnalysisModel method populateBindingPaths.

/**
 * populate direct bindings from the specified component to its resources
 *
 * @param ci
 */
protected void populateBindingPaths(InstanceObject obj) {
    if (obj instanceof ComponentInstance) {
        ComponentInstance ci = (ComponentInstance) obj;
        List<ComponentInstance> cpus = InstanceModelUtil.getProcessorBinding(ci);
        for (ComponentInstance cpu : cpus) {
            populateBindingPropagationPaths(ci, cpu, "processor");
        }
        if (!(ci instanceof VirtualProcessor)) {
            // do memory bindings
            List<ComponentInstance> mems = InstanceModelUtil.getMemoryBinding(ci);
            for (ComponentInstance mem : mems) {
                populateBindingPropagationPaths(ci, mem, "memory");
            }
        }
        if (ci instanceof VirtualBus) {
            // do connection bindings
            List<InstanceObject> boundresources = InstanceModelUtil.getConnectionBindings(ci);
            for (InstanceObject bres : boundresources) {
                populateBindingPropagationPaths(ci, (ComponentInstance) bres, "connection");
            }
        }
        List<ComponentInstance> systems = InstanceModelUtil.getFunctionBinding(ci);
        for (ComponentInstance system : systems) {
            populateBindingPropagationPaths(ci, system, "binding");
        }
    } else if (obj instanceof ConnectionInstance) {
        // do connection bindings
        List<? extends InstanceObject> boundresources = InstanceModelUtil.getConnectionBindings(obj);
        if (boundresources.isEmpty()) {
            boundresources = InstanceModelUtil.deriveBoundBuses((ConnectionInstance) obj);
        }
        for (InstanceObject bres : boundresources) {
            populateBindingPropagationPaths((ConnectionInstance) obj, (ComponentInstance) bres, "connection");
        }
    }
}
Also used : VirtualProcessor(org.osate.aadl2.VirtualProcessor) InstanceObject(org.osate.aadl2.instance.InstanceObject) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) VirtualBus(org.osate.aadl2.VirtualBus) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) BasicEList(org.eclipse.emf.common.util.BasicEList) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Example 12 with InstanceObject

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

the class AnalysisModel method populateUserDeclaredPropagationPaths.

/**
 * populate with user declared propagation paths declared in this component
 * instance the paths are between subcomponents
 *
 * @param ci
 *            ComponentInstance
 */
protected void populateUserDeclaredPropagationPaths(InstanceObject obj) {
    if (obj instanceof ComponentInstance) {
        ComponentInstance ci = (ComponentInstance) obj;
        Collection<PropagationPath> pplist = EMV2Util.getAllPropagationPaths(ci.getComponentClassifier());
        for (PropagationPath propagationPath : pplist) {
            addUserDeclaredPropagationPath(ci, propagationPath);
        }
    }
}
Also used : PropagationPath(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPath) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 13 with InstanceObject

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

the class EMSUtil method removeAll.

// remove error model state objects in all objects contained in root
public static void removeAll(InstanceObject root) {
    TreeIterator<Object> it = EcoreUtil.getAllContents(root, false);
    while (it.hasNext()) {
        InstanceObject io = (InstanceObject) it.next();
        Adapter st = ErrorModelStateAdapterFactory.INSTANCE.adapt(io, ErrorModelState.class);
        Notifier notifier = st.getTarget();
        notifier.eAdapters().remove(st);
        st.setTarget(null);
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) InstanceObject(org.osate.aadl2.instance.InstanceObject) Adapter(org.eclipse.emf.common.notify.Adapter) Notifier(org.eclipse.emf.common.notify.Notifier)

Example 14 with InstanceObject

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

the class CodeGenUtil method toPropertyExpression.

public static InstanceReferenceValue toPropertyExpression(InstanceObject value) {
    InstanceReferenceValue instanceReferenceValue = InstanceFactory.eINSTANCE.createInstanceReferenceValue();
    instanceReferenceValue.setReferencedInstanceObject(value);
    return instanceReferenceValue;
}
Also used : InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue)

Example 15 with InstanceObject

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

the class FTAHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ComponentInstance target;
    InstanceObject object = getTarget(HandlerUtil.getCurrentSelection(event));
    if (object == null) {
        Dialog.showInfo("Fault Tree Analysis", "Please choose an instance model");
        return IStatus.ERROR;
    }
    SystemInstance si = object.getSystemInstance();
    if (object instanceof ComponentInstance) {
        target = (ComponentInstance) object;
    } else {
        target = si;
    }
    if (!EMV2Util.hasComponentErrorBehaviorTransitions(target) && !EMV2Util.hasCompositeErrorBehavior(target) && !EMV2Util.hasOutgoingPropagations(target)) {
        Dialog.showInfo("Fault Tree Analysis", "Your system instance or selected component instance must have outgoing propagations, error state transitions, or composite error states.");
        return IStatus.ERROR;
    }
    stateNames = new ArrayList<String>();
    for (ErrorPropagation outprop : EMV2Util.getAllOutgoingErrorPropagations(target.getComponentClassifier())) {
        EList<TypeToken> result = EMV2TypeSetUtil.flattenTypesetElements(outprop.getTypeSet());
        for (TypeToken tt : result) {
            String epName = CreateFTAModel.prefixOutgoingPropagation + EMV2Util.getPrintName(outprop) + EMV2Util.getPrintName(tt);
            if (!stateNames.contains(epName)) {
                stateNames.add(epName);
            }
        }
    }
    Collection<ErrorBehaviorState> states = EMV2Util.getAllErrorBehaviorStates(target);
    if (!states.isEmpty()) {
        ErrorBehaviorState head = states.iterator().next();
        for (ErrorBehaviorState ebs : EMV2Util.getAllErrorBehaviorStates(target)) {
            if (ebs != head) {
                stateNames.add(CreateFTAModel.prefixState + EMV2Util.getPrintName(ebs));
            }
        }
        stateNames.add(CreateFTAModel.prefixState + EMV2Util.getPrintName(head));
    }
    if (stateNames.isEmpty()) {
        Dialog.showInfo("Fault Tree Analysis", "Selected system must have error states or error propagations");
        return IStatus.ERROR;
    }
    final Display d = PlatformUI.getWorkbench().getDisplay();
    d.syncExec(() -> {
        IWorkbenchWindow window;
        Shell sh;
        window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        sh = window.getShell();
        FTADialog diag = new FTADialog(sh);
        diag.setValues(stateNames);
        diag.setTarget("'" + (target instanceof SystemInstance ? target.getName() : target.getComponentInstancePath()) + "'");
        diag.open();
        ERROR_STATE_NAME = diag.getValue();
        FAULT_TREE_TYPE = diag.getFaultTreeType();
        GRAPHIC_VIEW = diag.isGraphicView();
    });
    if (ERROR_STATE_NAME != null) {
        if (FAULT_TREE_TYPE.equals(FaultTreeType.COMPOSITE_PARTS) && ERROR_STATE_NAME.startsWith(CreateFTAModel.prefixOutgoingPropagation)) {
            Dialog.showInfo("Fault Tree Analysis", "Select error state for composite parts fault tree");
            return IStatus.ERROR;
        }
        if (FAULT_TREE_TYPE.equals(FaultTreeType.COMPOSITE_PARTS) && !EMV2Util.hasCompositeErrorBehavior(target)) {
            Dialog.showInfo("Fault Tree Analysis", "Selected system must have composite error states for composite parts fault tree analysis");
            return IStatus.ERROR;
        }
        FaultTree ftmodel = CreateFTAModel.createModel(target, ERROR_STATE_NAME, FAULT_TREE_TYPE);
        if (ftmodel == null) {
            Dialog.showInfo("Fault Tree Analysis", "No fault tree generated. Selected error propagation has no out propagation condition or path from an inner component");
            return IStatus.ERROR;
        }
        saveFaultTree(ftmodel);
        if (GRAPHIC_VIEW) {
            SiriusUtil.INSTANCE.autoOpenModel(ftmodel, ResourceUtil.getFile(si.eResource()).getProject(), "viewpoint:/org.osate.aadl2.errormodel.faulttree.design/FaultTree", "IconicFaultTree", "Fault Tree");
        } else {
            if (FAULT_TREE_TYPE.equals(FaultTreeType.MINIMAL_CUT_SET)) {
                SiriusUtil.INSTANCE.autoOpenModel(ftmodel, ResourceUtil.getFile(si.eResource()).getProject(), "viewpoint:/org.osate.aadl2.errormodel.faulttree.design/FaultTree", "MinimalCutSetTable", "Minimal Cutset");
            } else {
                SiriusUtil.INSTANCE.autoOpenModel(ftmodel, ResourceUtil.getFile(si.eResource()).getProject(), "viewpoint:/org.osate.aadl2.errormodel.faulttree.design/FaultTree", "FaultTreeTable", "Fault Tree");
            }
        }
        return Status.OK_STATUS;
    }
    return IStatus.ERROR;
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) InstanceObject(org.osate.aadl2.instance.InstanceObject) Shell(org.eclipse.swt.widgets.Shell) SystemInstance(org.osate.aadl2.instance.SystemInstance) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) FaultTree(org.osate.aadl2.errormodel.FaultTree.FaultTree) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) Display(org.eclipse.swt.widgets.Display)

Aggregations

InstanceObject (org.osate.aadl2.instance.InstanceObject)71 PropertyExpression (org.osate.aadl2.PropertyExpression)38 Property (org.osate.aadl2.Property)35 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)35 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)31 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)24 SystemInstance (org.osate.aadl2.instance.SystemInstance)22 ListValue (org.osate.aadl2.ListValue)17 NamedElement (org.osate.aadl2.NamedElement)17 ArrayList (java.util.ArrayList)16 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)15 Classifier (org.osate.aadl2.Classifier)13 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)12 Element (org.osate.aadl2.Element)11 ComponentClassifier (org.osate.aadl2.ComponentClassifier)10 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)10 BasicProperty (org.osate.aadl2.BasicProperty)9 PropertyLookupException (org.osate.aadl2.properties.PropertyLookupException)9 List (java.util.List)8 Subcomponent (org.osate.aadl2.Subcomponent)8