Search in sources :

Example 56 with PropertyAssociation

use of org.osate.aadl2.PropertyAssociation in project AMASE by loonwerks.

the class SafetyScopeProvider method scope_GetPropertyExpr_prop.

protected IScope scope_GetPropertyExpr_prop(GetPropertyExpr ctx, EReference ref) {
    IScope prevScope = prevScope(ctx, ref);
    ComponentRef cr = ctx.getComponentRef();
    if (cr instanceof ThisRef) {
        List<Property> ps = new ArrayList<>();
        EObject container = ctx.getContainingClassifier();
        while (container != null) {
            if (container instanceof Classifier) {
                List<PropertyAssociation> pas = ((Classifier) container).getAllPropertyAssociations();
                for (PropertyAssociation pa : pas) {
                    ps.add(pa.getProperty());
                }
                container = ((Classifier) container).eContainer();
            } else if (container instanceof AadlPackage) {
                for (PropertySet propSet : EcoreUtil2.getAllContentsOfType(container, PropertySet.class)) {
                    for (Property p : propSet.getOwnedProperties()) {
                        ps.add(p);
                    }
                // =======
                // EList<EObject> refs  = null;
                // 
                // if (container instanceof NestedDotID) {
                // NestedDotID parent = (NestedDotID) container;
                // refs = parent.eCrossReferences();
                // 
                // if (refs.size() != 1) {
                // return new HashSet<>(); // this will throw a parsing error
                // }
                // container = refs.get(0); // figure out what this type this portion
                // 
                // // of the nest id is so we can figure out
                // // what we could possibly link to
                // 
                // if (container instanceof ThreadSubcomponent) {
                // container = ((ThreadSubcomponent) container).getComponentType();
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof Subcomponent) {
                // container = ((Subcomponent) container).getComponentImplementation();
                // if (container == null) { // no implementation is provided
                // container = refs.get(0);
                // container = ((Subcomponent) container).getClassifier();
                // }
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof DataPort) {
                // container = ((DataPort) container).getDataFeatureClassifier();
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof EventDataPort) {
                // container = ((EventDataPort) container).getDataFeatureClassifier();
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof AadlPackage) {
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof FeatureGroupImpl) {
                // container = ((FeatureGroupImpl) container).getAllFeatureGroupType();
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof Arg || container instanceof ConstStatement) {
                // Type type;
                // 
                // if (container instanceof Arg) {
                // type = ((Arg) container).getType();
                // } else {
                // type = ((ConstStatement) container).getType();
                // }
                // 
                // if (type instanceof RecordType) {
                // DoubleDotRef elID = ((RecordType) type).getRecord();
                // NamedElement namedEl = elID.getElm();
                // 
                // if (namedEl instanceof ComponentImplementation) {
                // ComponentImplementation componentImplementation = (ComponentImplementation) namedEl;
                // EList<Subcomponent> subs = componentImplementation.getAllSubcomponents();
                // result.addAll(subs);
                // } else if (namedEl instanceof RecordDefExpr) {
                // result.addAll(((RecordDefExpr) namedEl).getArgs());
                // >>>>>>> origin/develop
                }
                container = null;
            } else {
                container = container.eContainer();
            }
        }
        return Scopes.scopeFor(ps, prevScope);
    } else if (cr instanceof DoubleDotRef) {
        NamedElement ne = ((DoubleDotRef) cr).getElm();
        if (ne instanceof Subcomponent) {
            List<PropertyAssociation> pas = ((Subcomponent) ne).getOwnedPropertyAssociations();
            List<Property> ps = new ArrayList<>();
            for (PropertyAssociation pa : pas) {
                ps.add(pa.getProperty());
            }
            return Scopes.scopeFor(ps, prevScope);
        }
    }
    return IScope.NULLSCOPE;
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) PropertyAssociation(org.osate.aadl2.PropertyAssociation) ArrayList(java.util.ArrayList) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ThisRef(com.rockwellcollins.atc.agree.agree.ThisRef) EObject(org.eclipse.emf.ecore.EObject) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) FaultSubcomponent(edu.umn.cs.crisys.safety.safety.FaultSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) IScope(org.eclipse.xtext.scoping.IScope) PropertySet(org.osate.aadl2.PropertySet) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) EList(org.eclipse.emf.common.util.EList) ComponentRef(com.rockwellcollins.atc.agree.agree.ComponentRef) Property(org.osate.aadl2.Property) NamedElement(org.osate.aadl2.NamedElement)

Example 57 with PropertyAssociation

use of org.osate.aadl2.PropertyAssociation in project VERDICT by ge-high-assurance.

the class SynthesisAadlWriter method applyChangesToElem.

private static void applyChangesToElem(NamedElement elem, Map<String, Property> props, Map<String, List<ResultsInstance.Item>> elemChanges) {
    if (elemChanges.containsKey(elem.getFullName())) {
        for (ResultsInstance.Item item : elemChanges.get(elem.getFullName())) {
            Property prop = props.get(item.defenseProperty);
            // TODO perhaps figure out how to remove a defense if the DAL goes to 0?
            boolean existing = false;
            // try modifying existing prop if it exists
            for (PropertyAssociation assoc : elem.getOwnedPropertyAssociations()) {
                if (prop.equals(assoc.getProperty())) {
                    if (assoc.getOwnedValues().size() != 1) {
                        throw new RuntimeException("defense property has a list value, component: " + item.component + ", defense property: " + item.defenseProperty);
                    }
                    ModalPropertyValue propVal = assoc.getOwnedValues().get(0);
                    IntegerLiteral val = (IntegerLiteral) propVal.createOwnedValue(Aadl2Package.eINSTANCE.getIntegerLiteral());
                    val.setValue(item.outputDal);
                    existing = true;
                    break;
                }
            }
            // add the prop if it doesn't exist
            if (!existing && item.outputDal > 0) {
                PropertyAssociation assoc = elem.createOwnedPropertyAssociation();
                assoc.setProperty(prop);
                ModalPropertyValue propVal = assoc.createOwnedValue();
                IntegerLiteral val = (IntegerLiteral) propVal.createOwnedValue(Aadl2Package.eINSTANCE.getIntegerLiteral());
                val.setValue(item.outputDal);
            }
        }
    }
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) ResultsInstance(com.ge.verdict.vdm.synthesis.ResultsInstance) Property(org.osate.aadl2.Property) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Example 58 with PropertyAssociation

use of org.osate.aadl2.PropertyAssociation 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 59 with PropertyAssociation

use of org.osate.aadl2.PropertyAssociation in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method createVdmPort.

/**
 * @author Vidhya Tekken Valapil
 * Creates a new Vdm Port object and returns
 * Populates "name", "mode" and "type"
 * @param dataport
 * @return vdm port
 */
private Port createVdmPort(DataPort dataPort, Model model, HashSet<String> dataTypeDecl) {
    String modeString = "in";
    if (dataPort.isIn()) {
        modeString = "in";
    } else if (dataPort.isOut()) {
        modeString = "out";
    }
    // fetching data type information
    DataSubcomponentType dSubCompType = dataPort.getDataFeatureClassifier();
    verdict.vdm.vdm_data.DataType dtype = new verdict.vdm.vdm_data.DataType();
    if (dSubCompType instanceof DataTypeImpl) {
        org.osate.aadl2.DataType aadlDType = (org.osate.aadl2.DataType) dSubCompType;
        dtype = resolveAADLDataType(aadlDType, model, dataTypeDecl);
    } else if (dSubCompType instanceof DataImplementationImpl) {
        org.osate.aadl2.DataImplementation aadlDImpl = (org.osate.aadl2.DataImplementation) dSubCompType;
        dtype = resolveAADLDataImplementationType(aadlDImpl, model, dataTypeDecl);
    } else {
        System.out.println("Unresolved/unexpected Named Element.");
    }
    verdict.vdm.vdm_model.Port newPort = new verdict.vdm.vdm_model.Port();
    newPort.setProbe(false);
    if (dataPort.getOwnedPropertyAssociations().size() != 0) {
        EList<PropertyAssociation> propertyAssocs = dataPort.getOwnedPropertyAssociations();
        for (PropertyAssociation propertyAssoc : propertyAssocs) {
            if (propertyAssoc.getProperty().getName().equalsIgnoreCase("probe")) {
                EList<ModalPropertyValue> propVals = propertyAssoc.getOwnedValues();
                if (propVals.size() == 0 || propVals.size() > 1) {
                    throw new RuntimeException("Unexpected number for values for probe property of port.");
                }
                if (propVals.get(0).getOwnedValue() instanceof BooleanLiteral) {
                    BooleanLiteral probeVal = (BooleanLiteral) propVals.get(0).getOwnedValue();
                    newPort.setProbe(probeVal.getValue());
                } else {
                    throw new RuntimeException("Unexpected type of value for probe property of port.");
                }
            }
        }
    }
    newPort.setId(dataPort.getQualifiedName());
    newPort.setName(dataPort.getName());
    newPort.setMode(convertToVdmPortMode(modeString));
    newPort.setType(dtype);
    return newPort;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) DataImplementationImpl(org.osate.aadl2.impl.DataImplementationImpl) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BooleanLiteral(org.osate.aadl2.BooleanLiteral) SLPort(com.ge.research.osate.verdict.dsl.verdict.SLPort) LPort(com.ge.research.osate.verdict.dsl.verdict.LPort) EventPort(org.osate.aadl2.EventPort) DataPort(org.osate.aadl2.DataPort) Port(verdict.vdm.vdm_model.Port) EventDataPort(org.osate.aadl2.EventDataPort) DataImplementation(org.osate.aadl2.DataImplementation) Port(verdict.vdm.vdm_model.Port) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) DataTypeImpl(org.osate.aadl2.impl.DataTypeImpl) DataType(org.osate.aadl2.DataType) DataType(org.osate.aadl2.DataType)

Example 60 with PropertyAssociation

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

Aggregations

PropertyAssociation (org.osate.aadl2.PropertyAssociation)90 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)51 Property (org.osate.aadl2.Property)49 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)45 PropertyExpression (org.osate.aadl2.PropertyExpression)41 BasicProperty (org.osate.aadl2.BasicProperty)28 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)28 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)27 NamedElement (org.osate.aadl2.NamedElement)24 ListValue (org.osate.aadl2.ListValue)21 ArrayList (java.util.ArrayList)19 NamedValue (org.osate.aadl2.NamedValue)18 Element (org.osate.aadl2.Element)15 ArraySizeProperty (org.osate.aadl2.ArraySizeProperty)13 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)13 ReferenceValue (org.osate.aadl2.ReferenceValue)13 EObject (org.eclipse.emf.ecore.EObject)12 Mode (org.osate.aadl2.Mode)12 Classifier (org.osate.aadl2.Classifier)11 IntegerLiteral (org.osate.aadl2.IntegerLiteral)11