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");
}
}
}
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);
}
}
}
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);
}
}
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;
}
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;
}
Aggregations