Search in sources :

Example 16 with Arg

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

the class SafetyValidator method checkOutput.

/**
 * Check return params of fault node against params listed
 * in outputs.
 * @param outputs
 */
@Check(CheckType.FAST)
public void checkOutput(OutputStatement outputs) {
    List<String> faultsOut = outputs.getFault_out();
    EObject container = outputs.eContainer();
    List<Arg> retValues = new ArrayList<Arg>();
    List<String> returnNames = new ArrayList<String>();
    if (container instanceof FaultStatement) {
        retValues = getNodeReturnArgs((FaultStatement) container);
        if (retValues == null) {
            error(outputs, "Fault node definition is not valid for these outputs.");
        }
        for (Arg arg : retValues) {
            returnNames.add(arg.getFullName());
        }
        // Check sizes
        if (retValues.size() == (faultsOut.size())) {
            // Check names
            for (String outputName : faultsOut) {
                if (!returnNames.contains(outputName)) {
                    error(outputs, "The output name: " + outputName + " is not an return value in the node definition. " + "All possible output names are: " + returnNames.toString());
                }
            }
        } else {
            error(outputs, "The number of outputs must match the number of return values in the node definition." + "No. of outputs must be " + returnNames.size() + ".");
        }
    } else {
        error(outputs, "Fault outputs must be in a fault statement.");
    }
    if (!checkOutputTypes(faultsOut, outputs.getNom_conn(), retValues)) {
        error(outputs, "The output types do not match the node return parameter types.");
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Arg(com.rockwellcollins.atc.agree.agree.Arg) ArrayList(java.util.ArrayList) FaultStatement(edu.umn.cs.crisys.safety.safety.FaultStatement) HWFaultStatement(edu.umn.cs.crisys.safety.safety.HWFaultStatement) Check(org.eclipse.xtext.validation.Check)

Example 17 with Arg

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

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

the class IntervalEqImpl method basicSetLhs_int.

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

Example 19 with Arg

use of com.rockwellcollins.atc.agree.agree.Arg 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)

Example 20 with Arg

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

the class SafetyValidator method checkOutputTypes.

/**
 * Check that output types between these lists match.
 * Assume lists are in order.
 * @param faultsOut fault node output names
 * @param nom_conn nominal output connections
 * @param retValues arguments of return values of fault node
 * @return valid
 */
private boolean checkOutputTypes(List<String> faultsOut, EList<NamedElement> nom_conn, List<Arg> retValues) {
    // TODO: If I cannot access the type (e.g., complex nested
    // type), the string remains empty. If string is empty, I let
    // the type check say "all is well." This needs to be addressed.
    String type = "";
    for (int i = 0; i < faultsOut.size(); i++) {
        if (nom_conn.get(i) instanceof DataPortImpl) {
            type = getDataPortType((DataPortImpl) nom_conn.get(i));
            String argType = getArgType(retValues.get(i));
            if (type.equals(argType) || (!type.isEmpty() || !argType.isEmpty())) {
                return true;
            } else {
                return false;
            }
        } else if (nom_conn.get(i) instanceof Arg) {
            type = getArgType((Arg) nom_conn.get(i));
            String argType = getArgType(retValues.get(i));
            if (type.equals(argType) && !type.isEmpty() && !argType.isEmpty()) {
                return true;
            } else {
                return false;
            }
        }
    }
    return true;
}
Also used : DataPortImpl(org.osate.aadl2.impl.DataPortImpl) Arg(com.rockwellcollins.atc.agree.agree.Arg) TransientConstraint(edu.umn.cs.crisys.safety.safety.TransientConstraint) TemporalConstraint(edu.umn.cs.crisys.safety.safety.TemporalConstraint)

Aggregations

Arg (com.rockwellcollins.atc.agree.agree.Arg)31 ArrayList (java.util.ArrayList)11 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)10 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)7 DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)7 NodeBodyExpr (com.rockwellcollins.atc.agree.agree.NodeBodyExpr)7 NodeDef (com.rockwellcollins.atc.agree.agree.NodeDef)7 RealLitExpr (com.rockwellcollins.atc.agree.agree.RealLitExpr)7 NamedElement (org.osate.aadl2.NamedElement)7 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)6 PrimType (com.rockwellcollins.atc.agree.agree.PrimType)6 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)5 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)5 Check (org.eclipse.xtext.validation.Check)5 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)4 EqStatement (com.rockwellcollins.atc.agree.agree.EqStatement)4 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)4 Expr (com.rockwellcollins.atc.agree.agree.Expr)4 InputStatement (com.rockwellcollins.atc.agree.agree.InputStatement)4 PreExpr (com.rockwellcollins.atc.agree.agree.PreExpr)4