use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class FeatureImpl method getPropertyValue.
public void getPropertyValue(Property prop, PropertyAcc pas, Classifier cl, final boolean all) {
Classifier owner = getContainingClassifier();
// local contained value
if (pas.addLocalContained(this, owner) && !all || pas.addLocal(this)) {
if (!all) {
return;
}
}
// values from refined features
Feature refined = getRefined();
while (refined != null) {
if (pas.addLocal(refined)) {
if (!all) {
return;
}
}
refined = refined.getRefined();
}
getPropertyValueHelper(prop, pas, cl, all);
// feature group TYPE, not an implementation.
if (prop.isInherit()) {
owner.getPropertyValueInternal(prop, pas, true, all);
}
}
use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class EndToEndFlowImpl method getPropertyValueInternal.
// XXX: [AADL 1 -> AADL 2] Added to make property lookup work.
public final void getPropertyValueInternal(final Property pn, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
final ComponentImplementation partOf = (ComponentImplementation) getContainingClassifier();
if (partOf == null) {
throw new InvalidModelException(this, "End to End Flow is not part of a component");
}
// First check the container's contained property associations
if (!fromInstanceSlaveCall && pas.addLocalContained(this, partOf)) {
if (!all) {
return;
}
}
// Next check the flow sequence's properties subclause
if (pas.addLocal(this)) {
if (!all) {
return;
}
}
// Next find the value by walking up the connection's refinement
// sequence
EndToEndFlow refined = getRefined();
while (refined != null) {
if (!fromInstanceSlaveCall && pas.addLocalContained(refined, refined.getContainingClassifier())) {
if (!all) {
return;
}
}
if (pas.addLocal(refined)) {
if (!all) {
return;
}
}
refined = refined.getRefined();
}
/*
* if still not set, and the property is "inherit", try the containing
* component implementation.
*/
if (!fromInstanceSlaveCall && pn.isInherit()) {
partOf.getPropertyValueInternal(pn, pas, fromInstanceSlaveCall, all);
}
}
use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class NamedElementImpl method getPropertyValue.
/**
* Returns the property value for the property specified by property
*
* @param property
* The property to lookup
* @return AadlModalPropertyValue
* @exception IllegalStateException
* Thrown if the lookup encounters a cycle of property
* reference dependencies.
*/
public PropertyAcc getPropertyValue(final Property property, final boolean all) throws IllegalStateException, InvalidModelException, PropertyDoesNotApplyToHolderException, IllegalArgumentException {
// Error if the property is not acceptable
if (property == null) {
throw new IllegalArgumentException("Property property cannot be null.");
}
if (!acceptsProperty(property)) {
throw new PropertyDoesNotApplyToHolderException(this, property, "Property " + property.getName() + " does not apply to " + getClass().getName());
}
// Check that we aren't already looking up this property
final LinkedList<Property> stack = lookupStack.get();
if (stack.contains(property)) {
throw new IllegalStateException("Encountered circular dependency on property \"" + property.getName() + "\"");
}
try {
stack.addFirst(property);
PropertyAcc pas = new PropertyAcc(property);
getPropertyValueInternal(property, pas, false, all);
return pas;
} finally {
stack.removeFirst();
}
}
use of org.osate.aadl2.properties.PropertyAcc in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method getStrRepofPropVal.
/**
* @author Paul Meng
* @param propAcc
* @return
*/
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 VERDICT by ge-high-assurance.
the class Aadl2CsvTranslator method buildScnConnectionsTable.
/**
* Build the scenario architecture table.
*
* <p>Lists the properties associated with each connection.
* @return
*/
private Table buildScnConnectionsTable() {
List<String> headers = new ArrayList<String>(Arrays.asList("Scenario", "Comp", "Impl", "ConnectionName", "SrcComp", "SrcImpl", "SrcCompInstance", "SrcCompCategory", "SrcPortName", "SrcPortType", "DestComp", "DestImpl", "DestCompInstance", "DestCompCategory", "DestPortName", "DestPortType"));
headers.addAll(connPropertyToName.values());
// for(Map.Entry<String, List<Property>> entry : propSetNameToConnProps.entrySet()) {
// for(Property prop : entry.getValue()) {
// headers.add(prop.getName());
// }
// }
Table scnConnTable = new Table(headers);
for (ComponentImplementation compImpl : compImpls) {
if (compImpl.getOwnedConnections() != null && !compImpl.getOwnedConnections().isEmpty()) {
for (Connection conn : compImpl.getOwnedConnections()) {
String srcCompInstName = "";
String destCompInstName = "";
String srcCompName = compImpl.getTypeName();
String destCompName = compImpl.getTypeName();
String srcCompImplName = compImpl.getName();
String destCompImplName = compImpl.getName();
String srcCompCatName = compImpl.getCategory().getName();
String destCompCatName = compImpl.getCategory().getName();
Context srcConnContext = conn.getAllSourceContext();
Context destConnContext = conn.getAllDestinationContext();
ConnectionEnd srcConnectionEnd = conn.getAllSource();
ConnectionEnd destConnectionEnd = conn.getAllDestination();
if (srcConnContext != null) {
String[] info = obtainConnCompInfo(srcConnContext);
srcCompInstName = srcConnContext.getName();
srcCompCatName = info[0];
srcCompName = info[1];
srcCompImplName = info[2];
}
if (destConnContext != null) {
String[] info = obtainConnCompInfo(destConnContext);
destCompInstName = destConnContext.getName();
destCompCatName = info[0];
destCompName = info[1];
destCompImplName = info[2];
}
String srcPortTypeName = null;
String destPortTypeName = null;
String srcPortName = srcConnectionEnd.getName();
String destPortName = destConnectionEnd.getName();
if (srcConnectionEnd instanceof DataPort) {
srcPortTypeName = ((DataPort) srcConnectionEnd).isIn() ? (((DataPort) srcConnectionEnd).isOut() ? "in;out" : "in") : "out";
} else if (srcConnectionEnd instanceof EventDataPort) {
srcPortTypeName = ((EventDataPort) srcConnectionEnd).isIn() ? (((EventDataPort) srcConnectionEnd).isOut() ? "in;out" : "in") : "out";
} else if (srcConnectionEnd instanceof DataAccess) {
AccessType type = ((DataAccess) srcConnectionEnd).getKind();
if (type == AccessType.PROVIDES) {
srcPortTypeName = "provides data access";
} else if (type == AccessType.REQUIRES) {
srcPortTypeName = "requires data access";
} else {
throw new RuntimeException("Unexpected access type: " + type);
}
} else if (srcConnectionEnd instanceof DataSubcomponent) {
srcPortTypeName = "data";
} else {
throw new RuntimeException("Unsupported AADL component element type: " + srcConnectionEnd);
}
if (destConnectionEnd instanceof DataPort) {
destPortTypeName = ((DataPort) destConnectionEnd).isIn() ? (((DataPort) destConnectionEnd).isOut() ? "in;out" : "in") : "out";
} else if (destConnectionEnd instanceof EventDataPort) {
destPortTypeName = ((EventDataPort) destConnectionEnd).isIn() ? (((EventDataPort) destConnectionEnd).isOut() ? "in;out" : "in") : "out";
} else if (destConnectionEnd instanceof DataAccess) {
AccessType type = ((DataAccess) destConnectionEnd).getKind();
if (type == AccessType.PROVIDES) {
destPortTypeName = "provides data access";
} else {
destPortTypeName = "requires data access";
}
} else if (destConnectionEnd instanceof DataSubcomponent) {
destPortTypeName = "data";
} else {
throw new RuntimeException("Unsupported AADL component element type: " + destConnectionEnd);
}
scnConnTable.addValue(scenario);
scnConnTable.addValue(compImpl.getTypeName());
scnConnTable.addValue(compImpl.getName());
scnConnTable.addValue(conn.getName());
scnConnTable.addValue(srcCompName);
scnConnTable.addValue(srcCompImplName);
scnConnTable.addValue(srcCompInstName);
scnConnTable.addValue(srcCompCatName);
scnConnTable.addValue(srcPortName);
scnConnTable.addValue(srcPortTypeName);
scnConnTable.addValue(destCompName);
scnConnTable.addValue(destCompImplName);
scnConnTable.addValue(destCompInstName);
scnConnTable.addValue(destCompCatName);
scnConnTable.addValue(destPortName);
scnConnTable.addValue(destPortTypeName);
for (Property prop : connPropertyToName.keySet()) {
String value = "";
PropertyAcc propAcc = conn.getPropertyValue(prop);
PropertyExpression defPropExpr = prop.getDefaultValue();
int lastColon = prop.getName().lastIndexOf(":");
String propName = lastColon != -1 ? prop.getName().substring(lastColon + 1) : prop.getName();
if (synthesis && DefenseProperties.MBAA_CONN_DEFENSE_PROPERTIES_SET.contains(propName)) {
// this fools stem
value = "9";
} else if (propAcc != null && !propAcc.getAssociations().isEmpty()) {
value = getStrRepofPropVal(propAcc);
} else if (defPropExpr != null) {
value = getStrRepofExpr(defPropExpr)[0];
}
scnConnTable.addValue(value);
}
scnConnTable.capRow();
// Fill in the reverse connection if the connection is bidirectional
if (conn.isBidirectional()) {
scnConnTable.addValue(scenario);
scnConnTable.addValue(compImpl.getTypeName());
scnConnTable.addValue(compImpl.getName());
scnConnTable.addValue(conn.getName() + "_reverse");
scnConnTable.addValue(destCompName);
scnConnTable.addValue(destCompImplName);
scnConnTable.addValue(destCompInstName);
scnConnTable.addValue(destCompCatName);
scnConnTable.addValue(destPortName);
scnConnTable.addValue(destPortTypeName);
scnConnTable.addValue(srcCompName);
scnConnTable.addValue(srcCompImplName);
scnConnTable.addValue(srcCompInstName);
scnConnTable.addValue(srcCompCatName);
scnConnTable.addValue(srcPortName);
scnConnTable.addValue(srcPortTypeName);
for (Property prop : connPropertyToName.keySet()) {
String value = "";
PropertyAcc propAcc = conn.getPropertyValue(prop);
PropertyExpression defPropExpr = prop.getDefaultValue();
int lastColon = prop.getName().lastIndexOf(":");
String propName = lastColon != -1 ? prop.getName().substring(lastColon + 1) : prop.getName();
if (synthesis && DefenseProperties.MBAA_CONN_DEFENSE_PROPERTIES_SET.contains(propName)) {
// this fools stem
value = "9";
} else if (propAcc != null && !propAcc.getAssociations().isEmpty()) {
value = getStrRepofPropVal(propAcc);
} else if (defPropExpr != null) {
value = getStrRepofExpr(defPropExpr)[0];
}
scnConnTable.addValue(value);
}
scnConnTable.capRow();
}
}
}
}
return scnConnTable;
}
Aggregations