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.");
}
}
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.");
}
}
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;
}
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);
}
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;
}
Aggregations