use of org.osate.aadl2.impl.DataPortImpl in project AMASE by loonwerks.
the class FaultASTBuilder method populateMapSenderToReceiver.
/**
* Collect all connections from sender to receivers and add to map.
*
* @param senderOutput The DataPortImpl associated with the output from sender.
* @return Return a list of all the connection instance ends.
*/
protected List<ConnectionInstanceEnd> populateMapSenderToReceiver(DataPortImpl senderOutput) {
// Get list of connections from parent component that senderOutput is connected to.
String searchFor = senderOutput.getFullName();
// Will be key for mapSenderToReceiver
String tempSend = this.agreeNode.compInst.getName() + "." + searchFor;
String compName = "";
List<ConnectionInstanceEnd> senderConnections = new ArrayList<>();
List<String> tempReceive = new ArrayList<String>();
// Name of sender component (the one with the fanned output)
compName = this.agreeNode.compInst.getName();
// Find the connections of this component (need to access parent comp to get conns)
if (this.agreeNode.compInst.eContainer() instanceof SystemInstanceImpl) {
SystemInstanceImpl parentContainer = (SystemInstanceImpl) this.agreeNode.compInst.eContainer();
// Go through all connections and find the ones from sender to receiver.
for (ConnectionInstance ci : parentContainer.allConnectionInstances()) {
if (ci.getSource().eContainer() instanceof ComponentInstanceImpl) {
ComponentInstanceImpl thisComp = (ComponentInstanceImpl) ci.getSource().eContainer();
if (thisComp.getName().equals(compName)) {
// to create the communication nodes.
if (ci.getSource().getName().equals(senderOutput.getName())) {
senderConnections.add(ci.getDestination());
if (ci.getDestination().eContainer() instanceof SystemInstanceImpl) {
SystemInstanceImpl sysReceiver = (SystemInstanceImpl) ci.getDestination().eContainer();
tempReceive.add(sysReceiver.getName() + "." + ci.getDestination().getName());
} else if (ci.getDestination().eContainer() instanceof ComponentInstanceImpl) {
ComponentInstanceImpl sysReceiver = (ComponentInstanceImpl) ci.getDestination().eContainer();
tempReceive.add(sysReceiver.getName() + "." + ci.getDestination().getName());
} else {
new SafetyException("Asymmetric fault linked to output " + senderOutput.getName() + ") must be linked to a system instance component.");
}
} else {
continue;
}
}
}
// Map sender to receiver names
mapSenderToReceiver.put(tempSend, tempReceive);
}
}
return senderConnections;
}
use of org.osate.aadl2.impl.DataPortImpl 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