use of edu.umn.cs.crisys.safety.safety.FaultSubcomponent in project AMASE by loonwerks.
the class FaultASTBuilder method createCommNode.
/**
* Create Lustre node for asymmetric fault connection nodes.
*
* @param node AgreeNode corresponds to the "sender" node that has the fan out connections.
* This is needed to access the type of connection for input/output of this node.
* @param fstmt FaultStatement associated with the sender component output.
* @param fault Fault built from fault statement.
* @param nodeName Name of asymmetric node.
* @param connNumber How many connections from sender to receivers (used in naming).
* @return Node : lustre node of this communication node.
*/
private Node createCommNode(AgreeNode node, FaultStatement fstmt, Fault fault, String nodeName, int connNumber) {
// 1. Create unique node name
NodeBuilder newNode = new NodeBuilder(nodeName);
// 2. Get the output/input type from the node and the fstmt
List<AgreeVar> nodeOutputs = node.outputs;
AgreeVar outputOfInterest = null;
// Assume asymmetric fault first in list.
// Will have to display this to user somewhere.
List<NamedElement> nomFaultConn = new ArrayList<NamedElement>();
// Get the nominal connection
for (FaultSubcomponent fs : fstmt.getFaultDefinitions()) {
if (fs instanceof OutputStatement) {
nomFaultConn = ((OutputStatement) fs).getNom_conn();
}
}
// Get the agree node output that this fault is connected to
for (AgreeVar agreeVar : nodeOutputs) {
String temp = agreeVar.id;
if (temp.contentEquals(nomFaultConn.get(0).getName())) {
// This agreeVar is the sender var we want to save for the
// later mapping to the receiver var.
outputOfInterest = agreeVar;
}
}
// Now the same type on the AgreeNode outputOfInterest
// is the same as what we will create for the type of
// both input and output of commNode.
Type type = outputOfInterest.type;
newNode = createInputForCommNode(newNode, fault, outputOfInterest.type, nodeName);
newNode = createOutputForCommNode(newNode);
newNode = createLocalsForCommNode(newNode, fault);
newNode = createEquationsForCommNode(newNode, fault, type, nodeName);
return newNode.build();
}
use of edu.umn.cs.crisys.safety.safety.FaultSubcomponent in project AMASE by loonwerks.
the class SafetyScopeProvider method getNamedElementsFromSafetySpecs.
private Set<NamedElement> getNamedElementsFromSafetySpecs(EList<edu.umn.cs.crisys.safety.safety.SpecStatement> safetySpecs) {
Set<NamedElement> nelms = new HashSet<>();
EList<FaultSubcomponent> faultDefs = null;
for (SpecStatement spec : safetySpecs) {
if (spec instanceof FaultStatement) {
FaultStatement fs = (FaultStatement) spec;
faultDefs = fs.getFaultDefinitions();
for (FaultSubcomponent fsub : faultDefs) {
if (fsub instanceof SafetyEqStatement) {
SafetyEqStatement seq = (SafetyEqStatement) fsub;
if (seq instanceof EqValue) {
EqValue eqVal = (EqValue) seq;
nelms.addAll(eqVal.getLhs());
} else if (seq instanceof IntervalEq) {
IntervalEq eqVal = (IntervalEq) seq;
nelms.add(eqVal.getLhs_int());
}
}
}
// nelms.add((NamedElement) spec);
}
}
return nelms;
}
Aggregations