use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.
the class GetProperties method getActualProcessorBinding.
// /**
// * this method only picks up the first element, which may not be a bus
// * @param connection Connection Instance
// * @return
// */
// public static ComponentInstance getBoundBus(final ConnectionInstance
// connection) {
// List<ComponentInstance> ret = getActualConnectionBinding(connection);
// ComponentInstance ci = ret.isEmpty() ? null : ret.get(0);
// if (ci != null) {
// return ci;
// }
// return null;
// }
public static List<ComponentInstance> getActualProcessorBinding(final ComponentInstance io) {
ArrayList<ComponentInstance> components = new ArrayList<ComponentInstance>();
Property actualProcessorBinding = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.ACTUAL_PROCESSOR_BINDING);
List<? extends PropertyExpression> propertyValues;
try {
propertyValues = io.getPropertyValueList(actualProcessorBinding);
} catch (Exception e) {
return components;
}
for (PropertyExpression propertyExpression : propertyValues) {
if (propertyExpression != null) {
InstanceObject obj = ((InstanceReferenceValue) propertyExpression).getReferencedInstanceObject();
components.add((ComponentInstance) obj);
}
}
return components;
}
use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.
the class GetProperties method getAllowedMemoryBinding.
public static List<ComponentInstance> getAllowedMemoryBinding(final InstanceObject io) {
Property allowedMemoryBinding = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.ALLOWED_MEMORY_BINDING);
ArrayList<ComponentInstance> components = new ArrayList<>();
List<? extends PropertyExpression> propertyValues;
try {
propertyValues = io.getPropertyValueList(allowedMemoryBinding);
} catch (Exception e) {
return components;
}
for (PropertyExpression propertyExpression : propertyValues) {
components.add((ComponentInstance) ((InstanceReferenceValue) propertyExpression).getReferencedInstanceObject());
}
return components;
}
use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.
the class GetProperties method getActualConnectionBinding.
public static List<ComponentInstance> getActualConnectionBinding(final InstanceObject io) {
ArrayList<ComponentInstance> components = new ArrayList<ComponentInstance>();
Property actualConnectionBinding = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.ACTUAL_CONNECTION_BINDING);
List<? extends PropertyExpression> propertyValues;
try {
propertyValues = io.getPropertyValueList(actualConnectionBinding);
} catch (Exception e) {
return components;
}
for (PropertyExpression propertyExpression : propertyValues) {
components.add((ComponentInstance) ((InstanceReferenceValue) propertyExpression).getReferencedInstanceObject());
}
return components;
}
use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.
the class GetProperties method getOutgoingMessageRatePerSecond.
/*
* Look for Message_Rate or SEI::Data_Rate first. Then pick up Output_Rate,
* whose default value is 1 per dispatch That rate is converted to persecond
* using Period. If Period is zero then the resulting data rate is zero as
* well.
*/
public static double getOutgoingMessageRatePerSecond(final NamedElement ne) {
double res = GetProperties.getMessageRatePerSecond(ne);
if (res > 0) {
return res;
}
Property outputRate = lookupPropertyDefinition(ne, CommunicationProperties._NAME, CommunicationProperties.OUTPUT_RATE);
RecordValue rec = GetProperties.getOutPutRate(ne);
if (rec != null) {
res = GetProperties.getMaxDataRate(rec);
EnumerationLiteral unit = GetProperties.getRateUnit(rec);
double period = 0;
if (unit == null || unit.getName().equalsIgnoreCase("PerDispatch")) {
if (ne instanceof InstanceObject) {
period = GetProperties.getPeriodInSeconds(((InstanceObject) ne).getContainingComponentInstance(), 0);
} else {
period = GetProperties.getPeriodInSeconds(ne.getContainingClassifier(), 0);
}
if (period == 0) {
return 0;
}
res = res / period;
}
if (res > 0) {
return res;
}
}
double period = GetProperties.getPeriodInSeconds(ne.getContainingClassifier(), 0);
if (period == 0) {
return 0;
}
res = 1 / period;
return res;
}
use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.
the class Util method populateBindingPaths.
/**
* populate direct bindings from the specified component to its resources
*
* @param ci
*/
protected static void populateBindingPaths(PropagationGraph pg, InstanceObject obj) {
if (obj instanceof ComponentInstance) {
final ComponentInstance ci = (ComponentInstance) obj;
final ComponentCategory componentCategory = ci.getCategory();
if (mayHaveActualProcessorBindings.contains(componentCategory)) {
final List<InstanceObject> cpus = InstanceModelUtil.getProcessorBindings(ci);
for (final InstanceObject cpu : cpus) {
populateBindingPropagationPaths(pg, ci, (ComponentInstance) cpu, "processor");
}
}
if (!(ci instanceof VirtualProcessor)) {
// do memory bindings
if (mayHaveActualMemoryBindings.contains(componentCategory)) {
final List<InstanceObject> mems = InstanceModelUtil.getMemoryBindings(ci);
for (final InstanceObject mem : mems) {
populateBindingPropagationPaths(pg, ci, (ComponentInstance) mem, "memory");
}
}
}
if (ci instanceof VirtualBus) {
// do connection bindings
if (mayHaveActualConnectionBindings.contains(componentCategory)) {
final List<InstanceObject> boundresources = InstanceModelUtil.getConnectionBindings(ci);
for (final InstanceObject bres : boundresources) {
populateBindingPropagationPaths(pg, ci, (ComponentInstance) bres, "connection");
}
}
}
if (mayHaveActualFunctionBinding.contains(componentCategory)) {
final List<InstanceObject> systems = InstanceModelUtil.getFunctionBindings(ci);
for (final InstanceObject system : systems) {
populateBindingPropagationPaths(pg, ci, (ComponentInstance) system, "binding");
}
}
} else if (obj instanceof ConnectionInstance) {
// do connection bindings -- nb. all connections are allowed the actual_connection_binding property
List<? extends InstanceObject> boundresources = InstanceModelUtil.getConnectionBindings(obj);
if (boundresources.isEmpty()) {
boundresources = InstanceModelUtil.deriveBoundBuses((ConnectionInstance) obj);
}
for (InstanceObject bres : boundresources) {
populateBindingPropagationPaths(pg, (ConnectionInstance) obj, (ComponentInstance) bres, "connection");
}
}
}
Aggregations