use of org.osate.aadl2.properties.PropertyAcc in project VERDICT by ge-high-assurance.
the class Aadl2CsvTranslator method getStrRepofPropVal.
public String getStrRepofPropVal(PropertyAcc propAcc) {
String value = "";
if (propAcc != null) {
List<PropertyAssociation> propAssocs = propAcc.getAssociations();
if (!propAssocs.isEmpty() && propAssocs.size() == 1) {
PropertyAssociation propAssoc = propAssocs.get(0);
// We assume that each property only has only 1 non-list value for now
if (propAssoc.getOwnedValues().size() == 1) {
ModalPropertyValue propVal = propAssoc.getOwnedValues().get(0);
PropertyExpression exp = propVal.getOwnedValue();
value = getStrRepofExpr(exp)[0];
} else {
throw new RuntimeException("Unexpected: property is a list of values with size = : " + propAssoc.getOwnedValues().size());
}
} else {
// throw new RuntimeException("Unexpected property association size: " + propAssocs.size());
}
}
return value;
}
use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class FlowLatencyAnalysisSwitch method isAssignedPropertyValue.
private static boolean isAssignedPropertyValue(NamedElement element, Property pn) {
try {
final PropertyAcc propertyAccumulator = element.getPropertyValue(pn);
PropertyAssociation firstAssociation = propertyAccumulator.first();
return firstAssociation != null;
} catch (org.osate.aadl2.properties.PropertyDoesNotApplyToHolderException exception) {
return false;
}
}
use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class ComponentTypeImpl method getPropertyValueInternal.
public final void getPropertyValueInternal(final Property property, final PropertyAcc paa, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
/*
* First see if the property is defined in component's properties
* subclause (could merge this with the loop below, but I want to make
* the steps more explicit.)
*/
if (paa.addLocal(this)) {
if (!all) {
return;
}
}
// Next walk the component type hierarchy
// Avoid loops by stopping if we extend ourself
final Set<ComponentType> seen = new HashSet<ComponentType>();
ComponentType currentType = getExtended();
while (currentType != null && !seen.contains(currentType)) {
if (paa.addLocal(currentType)) {
if (!all) {
return;
}
}
seen.add(currentType);
currentType = currentType.getExtended();
}
}
use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class ComponentImplementationImpl method getPropertyValueInternal.
public void getPropertyValueInternal(Property property, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
// this implementation's properties subclause
if (pas.addLocal(this)) {
if (!all) {
return;
}
}
// extended implementations
// avoid loops
final Set<ComponentImplementation> seen = new HashSet<ComponentImplementation>();
ComponentImplementation currentImpl = getExtended();
while (currentImpl != null && !seen.contains(currentImpl)) {
if (pas.addLocal(currentImpl)) {
if (!all) {
return;
}
}
seen.add(currentImpl);
currentImpl = currentImpl.getExtended();
}
// the type
if (getType() != null) {
getType().getPropertyValueInternal(property, pas, fromInstanceSlaveCall, all);
} else {
// XXX we have an unresolved implementation or alias throw new InvalidModelException(this,
// "Component implementation is missing its component type reference.");
}
}
use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class FlowSpecificationImpl method getPropertyValueInternal.
// FIXME-LW: instantiation
// /**
// * get in feature of a flow source, sink, or path spec.
// * In case of a refined flowspec get it from the flowspec being refined
// * @return Feature or null
// */
// // XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
// public Feature getAllInFeature() {
// FlowSpecification fs = this;
// while (fs.getInFeature() == null && fs.getRefined() != null)
// fs = fs.getRefined();
// return fs.getInFeature();
// }
//
// /**
// * get in flow context of a flow source, sink, or path spec.
// * In case of a refined flowspec get it from the flowspec being refined
// * @return Context or null
// */
// // XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
// public Context getAllInContext() {
// FlowSpecification fs = this;
// while (fs.getInContext() == null && fs.getRefined() != null)
// fs = fs.getRefined();
// return fs.getInContext();
// }
//
// /**
// * get out feature of a flow source, sink, or path spec.
// * In case of a refined flowspec get it from the flowspec being refined
// * @return Feature or null
// */
// // XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
// public Feature getAllOutFeature() {
// FlowSpecification fs = this;
// while (fs.getOutFeature() == null && fs.getRefined() != null)
// fs = fs.getRefined();
// return fs.getOutFeature();
// }
//
// /**
// * get out flow context of flow source, sink, or path spec.
// * In case of a refined flowspec get it from the flowspec being refined
// * @return Context or null
// */
// // XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
// public Context getAllOutContext() {
// FlowSpecification fs = this;
// while (fs.getOutContext() == null && fs.getRefined() != null)
// fs = fs.getRefined();
// return fs.getOutContext();
// }
public final void getPropertyValueInternal(final Property prop, final PropertyAcc paa, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
final Classifier owner = getContainingClassifier();
if (!fromInstanceSlaveCall && paa.addLocalContained(this, owner)) {
if (!all) {
return;
}
}
if (paa.addLocal(this)) {
if (!all) {
return;
}
}
// values from refined flow specifications
FlowSpecification refined = getRefined();
while (refined != null) {
if (!fromInstanceSlaveCall && paa.addLocalContained(refined, refined.getContainingClassifier())) {
if (!all) {
return;
}
}
if (paa.addLocal(refined)) {
if (!all) {
return;
}
}
refined = refined.getRefined();
}
// TYPE, not an implementation.
if (!fromInstanceSlaveCall && prop.isInherit()) {
if (owner != null) {
owner.getPropertyValueInternal(prop, paa, fromInstanceSlaveCall, all);
} else {
throw new InvalidModelException(this, "Flow specification is not part of a component");
}
}
}
Aggregations