use of org.osate.aadl2.instance.impl.FeatureInstanceImpl in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method changeAsymConnections.
/**
* Method will remove the previous connections in the main lustre node from
* sender to receivers and add in the new connections from sender to commNode
* and from commNode to receiver. Ex: What used to be: Sender_out = reciever1.in
* Sender_out = reciever2.in Sender_out = reciever3.in Is now: Sender_out =
* asym0.in Sender_out = asym1.in Sender_out = asym2.in asym0.out = reciever1.in
* asym1.out = reciever2.in asym2.out = reciever3.in
*
* @param nb NodeBuilder for the main lustre node.
*/
private void changeAsymConnections(AgreeNodeBuilder nb) {
// Insert connections sender_output = commNode_input
for (String output : mapAsymCompOutputToCommNodeIn.keySet()) {
for (String nodeName : mapAsymCompOutputToCommNodeIn.get(output)) {
Expr eq = new BinaryExpr(new IdExpr(output), BinaryOp.EQUAL, new IdExpr(nodeName));
nb.addAssertion(new AgreeStatement("", eq, this.topNode.reference));
}
}
// Insert connections commNode_output = receiver_input.
for (String output : mapCommNodeOutputToConnections.keySet()) {
String featureName = "";
String componentName = "";
// First access name of receiving component and its input
if (mapCommNodeOutputToConnections.get(output).eContainer() instanceof SystemInstanceImpl) {
FeatureInstanceImpl fi = (FeatureInstanceImpl) mapCommNodeOutputToConnections.get(output);
componentName = "";
featureName = fi.getName();
} else if (mapCommNodeOutputToConnections.get(output) instanceof FeatureInstanceImpl) {
FeatureInstanceImpl fi = (FeatureInstanceImpl) mapCommNodeOutputToConnections.get(output);
featureName = fi.getName();
if (fi.eContainer() instanceof ComponentInstanceImpl) {
ComponentInstanceImpl ci = (ComponentInstanceImpl) fi.eContainer();
componentName = ci.getName() + "__";
} else {
new SafetyException("Asymmetric fault must be connected to a component instance.");
}
} else {
new SafetyException("Asymmetric fault must have an allowable connection.");
}
// Create lustre connection name, add to builder.
IdExpr connectionName = new IdExpr(componentName + featureName);
Expr eq = new BinaryExpr(new IdExpr(output), BinaryOp.EQUAL, connectionName);
nb.addAssertion(new AgreeStatement("", eq, this.topNode.reference));
}
}
Aggregations