Search in sources :

Example 11 with PropertyAcc

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);
    }
}
Also used : FeatureClassifier(org.osate.aadl2.FeatureClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) Feature(org.osate.aadl2.Feature)

Example 12 with PropertyAcc

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);
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) InvalidModelException(org.osate.aadl2.properties.InvalidModelException) EndToEndFlow(org.osate.aadl2.EndToEndFlow)

Example 13 with PropertyAcc

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();
    }
}
Also used : PropertyDoesNotApplyToHolderException(org.osate.aadl2.properties.PropertyDoesNotApplyToHolderException) PropertyAcc(org.osate.aadl2.properties.PropertyAcc) Property(org.osate.aadl2.Property)

Example 14 with PropertyAcc

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;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) PropertyExpression(org.osate.aadl2.PropertyExpression)

Example 15 with PropertyAcc

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;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) Context(org.osate.aadl2.Context) ArrayList(java.util.ArrayList) PortConnection(org.osate.aadl2.PortConnection) Connection(org.osate.aadl2.Connection) DataAccess(org.osate.aadl2.DataAccess) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) DataSubcomponent(org.osate.aadl2.DataSubcomponent) PropertyAcc(org.osate.aadl2.properties.PropertyAcc) ConnectionEnd(org.osate.aadl2.ConnectionEnd) PropertyExpression(org.osate.aadl2.PropertyExpression) EventDataPort(org.osate.aadl2.EventDataPort) Property(org.osate.aadl2.Property) AccessType(org.osate.aadl2.AccessType)

Aggregations

PropertyAcc (org.osate.aadl2.properties.PropertyAcc)11 ComponentImplementation (org.osate.aadl2.ComponentImplementation)8 Property (org.osate.aadl2.Property)7 PropertyAssociation (org.osate.aadl2.PropertyAssociation)7 PropertyExpression (org.osate.aadl2.PropertyExpression)7 Classifier (org.osate.aadl2.Classifier)5 ComponentClassifier (org.osate.aadl2.ComponentClassifier)5 Subcomponent (org.osate.aadl2.Subcomponent)5 Connection (org.osate.aadl2.Connection)3 DataSubcomponent (org.osate.aadl2.DataSubcomponent)3 Feature (org.osate.aadl2.Feature)3 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)3 InstanceObject (org.osate.aadl2.instance.InstanceObject)3 InvalidModelException (org.osate.aadl2.properties.InvalidModelException)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 AbstractSubcomponent (org.osate.aadl2.AbstractSubcomponent)2 AccessType (org.osate.aadl2.AccessType)2 BasicProperty (org.osate.aadl2.BasicProperty)2 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)2