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