Search in sources :

Example 11 with DoubleDotRef

use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AMASE by loonwerks.

the class SafetyValidator method checkFaultSpecStmt.

/**
 * Checks description string, warning if empty, and checks that the
 * fault node name is valid.
 * @param specStmt
 */
@Check(CheckType.FAST)
public void checkFaultSpecStmt(FaultStatement specStmt) {
    DoubleDotRef nodeName = specStmt.getFaultDefName();
    // Check on fault description
    if (specStmt.getStr().isEmpty()) {
        warning(specStmt, "Fault description is optional, but should " + "not be an empty string.");
    }
    // Check that the NamedElement (fault node name) is a valid node definition
    NamedElement finalNodeName = nodeName.getElm();
    if (!(finalNodeName instanceof NodeDef)) {
        error(nodeName, "The fault name must be a valid node definition.");
    }
}
Also used : NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Example 12 with DoubleDotRef

use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AMASE by loonwerks.

the class SafetyValidator method checkInput.

/**
 * Checks fault def name is valid,
 * expressions passed into node match parameter types,
 * and correct number of arguments passed in.
 *
 * @param inputs
 */
@Check(CheckType.FAST)
public void checkInput(InputStatement inputs) {
    EObject container = inputs.eContainer();
    NamedElement defNameSub;
    List<Expr> exprList = inputs.getNom_conn();
    List<String> inputList = inputs.getFault_in();
    ArrayList<String> argNames = new ArrayList<String>();
    if (container instanceof FaultStatement) {
        FaultStatement faultStatement = (FaultStatement) container;
        DoubleDotRef defName = faultStatement.getFaultDefName();
        defNameSub = defName.getElm();
        // Make sure we have a NodeDefExpr
        if (defNameSub instanceof NodeDef) {
            List<Arg> nodeArgs = ((NodeDef) defNameSub).getArgs();
            for (Arg arg : nodeArgs) {
                argNames.add(arg.getFullName());
                if (arg.getType() instanceof DoubleDotRefImpl) {
                    if ((((DoubleDotRefImpl) arg.getType()).getElm() instanceof PropertyImpl) || (((DoubleDotRefImpl) arg.getType()).getElm() instanceof DataTypeImpl)) {
                        error(inputs, "Fault node parameters are not recognized: a possible issue is that the keyword 'float' is used instead of 'real.'");
                    }
                }
            }
            // If the sizes are accurate, make sure names match
            if (nodeArgs.size() - 1 == (inputList.size())) {
                // Go through input list and make sure each name is in the arg list
                for (String inputName : inputList) {
                    if (!argNames.contains(inputName)) {
                        error(inputs, "Input names must match fault node definition names. " + "The input name " + inputName + " is not an input in the node definition. " + "All possible input names are: " + argNames.toString());
                    }
                }
            } else {
                argNames.remove("trigger");
                error(inputs, "With this fault definition, you must have " + (argNames.size() - 1) + " inputs." + " These are called: " + argNames.toString());
            }
            if (inputListHasRepeats(inputList)) {
                error(inputs, "There is a repeated name in the input list: " + inputList.toString());
            }
            if (!checkInputTypes(exprList, nodeArgs)) {
                error(inputs, "Types of inputs do not match types of node parameters");
            }
        } else {
            // Not a node def expr
            error(defName, "Fault definition: " + defNameSub.getFullName() + " must be a valid agree node definition name.");
        }
    } else {
        error(inputs, "Fault inputs must be defined within a fault statement.");
    }
}
Also used : NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) ArrayList(java.util.ArrayList) FaultStatement(edu.umn.cs.crisys.safety.safety.FaultStatement) HWFaultStatement(edu.umn.cs.crisys.safety.safety.HWFaultStatement) PropertyImpl(org.osate.aadl2.impl.PropertyImpl) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) DataTypeImpl(org.osate.aadl2.impl.DataTypeImpl) EObject(org.eclipse.emf.ecore.EObject) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) Arg(com.rockwellcollins.atc.agree.agree.Arg) DoubleDotRefImpl(com.rockwellcollins.atc.agree.agree.impl.DoubleDotRefImpl) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Example 13 with DoubleDotRef

use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AMASE by loonwerks.

the class FaultStatementImpl method basicSetFaultDefName.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetFaultDefName(DoubleDotRef newFaultDefName, NotificationChain msgs) {
    DoubleDotRef oldFaultDefName = faultDefName;
    faultDefName = newFaultDefName;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SafetyPackage.FAULT_STATEMENT__FAULT_DEF_NAME, oldFaultDefName, newFaultDefName);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef)

Example 14 with DoubleDotRef

use of com.rockwellcollins.atc.agree.agree.DoubleDotRef 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 15 with DoubleDotRef

use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AMASE by loonwerks.

the class SafetyAnnexContentAssist method getNestedDotIDCandidates.

private List<String> getNestedDotIDCandidates(SelectionExpr id) {
    NamedElement base = ((NamedElmExpr) id).getElm();
    NamedElement namedEl = null;
    if (base instanceof Arg) {
        Type type = ((Arg) base).getType();
        DoubleDotRef elID = ((DoubleDotRef) type);
        namedEl = elID.getElm();
    } else if (base instanceof DataPort) {
        namedEl = ((DataPort) base).getDataFeatureClassifier();
    } else if (base instanceof EventDataPort) {
        namedEl = ((EventDataPort) base).getDataFeatureClassifier();
    } else if (base instanceof AadlPackage) {
        return getNestedDotIDCandidates((AadlPackage) base);
    } else {
        return new ArrayList<>();
    }
    return getNestedDotIDCandidates(namedEl);
}
Also used : DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) Type(com.rockwellcollins.atc.agree.agree.Type) AadlPackage(org.osate.aadl2.AadlPackage) Arg(com.rockwellcollins.atc.agree.agree.Arg) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) EventDataPort(org.osate.aadl2.EventDataPort) NamedElement(org.osate.aadl2.NamedElement) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr)

Aggregations

DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)26 NamedElement (org.osate.aadl2.NamedElement)17 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)11 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)8 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)8 RealLitExpr (com.rockwellcollins.atc.agree.agree.RealLitExpr)8 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)8 Arg (com.rockwellcollins.atc.agree.agree.Arg)7 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)7 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)7 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)7 NodeBodyExpr (com.rockwellcollins.atc.agree.agree.NodeBodyExpr)7 PreExpr (com.rockwellcollins.atc.agree.agree.PreExpr)7 PrevExpr (com.rockwellcollins.atc.agree.agree.PrevExpr)7 RecordLitExpr (com.rockwellcollins.atc.agree.agree.RecordLitExpr)7 DataImplementation (org.osate.aadl2.DataImplementation)7 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)6 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)6 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)6 ExistsExpr (com.rockwellcollins.atc.agree.agree.ExistsExpr)6