use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class FlowLatencyUtil method getContributorType.
public static String getContributorType(EObject relatedElement) {
if (relatedElement instanceof ComponentInstance) {
ComponentInstance relatedComponentInstance = (ComponentInstance) relatedElement;
if (relatedComponentInstance.getCategory() == ComponentCategory.VIRTUAL_BUS) {
return "protocol";
}
if (relatedComponentInstance.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) {
return "partition";
}
return relatedComponentInstance.getCategory().getName();
}
if (relatedElement instanceof VirtualBus) {
return "protocol";
}
if (relatedElement instanceof ComponentClassifier) {
ComponentType relatedComponentType = (ComponentType) relatedElement;
return relatedComponentType.getCategory().getName();
}
if (relatedElement instanceof ConnectionInstance) {
final ConnectionKind connectionKind = ((ConnectionInstance) relatedElement).getKind();
Timing connectionType;
try {
connectionType = connectionKind == ConnectionKind.PORT_CONNECTION ? CommunicationProperties.getTiming((ConnectionInstance) relatedElement).orElse(Timing.SAMPLED) : Timing.SAMPLED;
} catch (final PropertyLookupException e) {
// Property association semantics for FEATURE connections are missing
connectionType = Timing.SAMPLED;
}
if (connectionType == Timing.DELAYED) {
return "delayed connection";
}
if (connectionType == Timing.IMMEDIATE) {
return "immediate connection";
}
if (connectionType == Timing.SAMPLED) {
return "connection";
}
return "connection";
}
return "component";
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class LatencyContributorComponent method getContributorType.
@Override
protected String getContributorType() {
ComponentInstance relatedComponentInstance;
ComponentType relatedComponentType;
if (relatedElement instanceof ComponentInstance) {
relatedComponentInstance = (ComponentInstance) relatedElement;
if (relatedComponentInstance.getCategory() == ComponentCategory.VIRTUAL_BUS) {
return "protocol";
}
if (relatedComponentInstance.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) {
return "partition";
}
return relatedComponentInstance.getCategory().getName();
}
if (relatedElement instanceof VirtualBus) {
return "protocol";
}
if (relatedElement instanceof ComponentClassifier) {
relatedComponentType = (ComponentType) relatedElement;
return relatedComponentType.getCategory().getName();
}
return "component";
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class AadlBaUtils method getDataClassifier.
/**
* Returns the DataClassifier of the element binded to the given
* Value object. A target instance can be given to this method as
* Target instance can be cast into ValueVariable reference.
* <BR><BR>
* Notes: <BR><BR>
* <BR>_ ValueVariable : {@link #getClassifier(Element, Classifier)}
* to see the restrictions.
* <BR>_ ValueConstant : Property constant and property reference are not supported:
* returns {@code null}.
* <BR><BR>
*
* @param v the given Value object
* @param parentContainer only for AADLBA declarative objects which have no
* parent set, yet
* @return the binded component's DataClassifier object or {@code null} for
* the ValueConstant objects and for the Abstract components objects.
* @exception UnsupportedOperationException for unsupported binded
* object types.
*/
public static DataClassifier getDataClassifier(Value v, ComponentClassifier parentContainer) {
Classifier result = null;
if (v instanceof ValueVariable) {
// Either ElementHolder or DataComponentReference object.
Element el = null;
if (v instanceof ElementHolder) {
el = ((ElementHolder) v).getElement();
} else // DataComponentReference case.
{
DataComponentReference dcr = (DataComponentReference) v;
DataHolder lastElement = dcr.getData().get(dcr.getData().size() - 1);
el = lastElement.getElement();
}
if (parentContainer == null) {
parentContainer = (ComponentClassifier) v.getContainingClassifier();
}
result = getClassifier(el, parentContainer);
} else // Property constant and property reference are not supported.
{
result = null;
}
if (result instanceof DataClassifier) {
return (DataClassifier) result;
} else // Abstract components case.
{
return null;
}
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class AadlBaUtils method getDataRepresentation.
/**
* Returns the data representation of the given ValueVariable object
* or DataRepresentation.UNKNOWN if Data_Model::Data_Representation
* property is not set or if the ValueVariable object represents a data
* structure.
*
* @param v the given ValueVariable object
* @return the data representation or DataRepresentation.UNKNOWN
*/
public static DataRepresentation getDataRepresentation(ValueVariable v) {
if (v instanceof PortCountValue) {
return DataRepresentation.INTEGER;
} else if (v instanceof PortFreshValue) {
return DataRepresentation.BOOLEAN;
} else {
// Either ElementHolder or DataComponentReference object.
Element el = null;
if (v instanceof ElementHolder) {
if (v instanceof PrototypeHolder) {
PrototypeHolder ph = (PrototypeHolder) v;
if (ph.getPrototypeBinding() != null) {
el = ph.getPrototypeBinding();
} else {
el = ph.getPrototype();
}
} else {
el = ((ElementHolder) v).getElement();
}
} else // DataComponentReference case.
{
DataComponentReference dcr = (DataComponentReference) v;
DataHolder lastElement = dcr.getData().get(dcr.getData().size() - 1);
el = lastElement.getElement();
}
if (el instanceof Abstract) {
return DataRepresentation.UNKNOWN;
} else if (el instanceof Feature) {
Classifier c = ((Feature) el).getClassifier();
if (c instanceof DataClassifier) {
return getDataRepresentation((DataClassifier) c);
} else {
return DataRepresentation.UNKNOWN;
}
} else if (el instanceof DataSubcomponent) {
final DataSubcomponent subcompo = (DataSubcomponent) el;
final Classifier classifier = subcompo.getClassifier();
// fixes 2401: Avoid crashing the editor when subcomponent is not resolved
if (classifier == null || classifier.eIsProxy()) {
return DataRepresentation.UNKNOWN;
}
return getDataRepresentation((DataClassifier) ((DataSubcomponent) el).getClassifier());
} else if (el instanceof BehaviorVariable) {
// Behavior case.
return getDataRepresentation((BehaviorVariable) el);
} else {
// Prototype cases.
Classifier klass;
ComponentClassifier baParentComponent = (ComponentClassifier) v.getContainingClassifier();
klass = AadlBaUtils.getClassifier(el, baParentComponent);
return getDataRepresentation((DataClassifier) klass);
}
}
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class InstanceValidation method checkForReferenceProcessor.
protected void checkForReferenceProcessor(Element obj) {
if (obj instanceof ComponentInstance) {
ComponentInstance ci = (ComponentInstance) obj;
double et = GetProperties.getMaximumComputeExecutionTimeinSec(ci);
if (et != 0) {
ComponentClassifier refproc = GetProperties.getReferenceProcessor(ci);
if (refproc == null) {
isOK = false;
handler.error(ci, "Thread instance " + ci.getComponentInstancePath() + " has execution time, but no Reference_Processor. Please this property.");
}
}
}
}
Aggregations