use of edu.umn.cs.crisys.safety.safety.TemporalConstraint in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method constrainFaultActive.
/**
* Method constrains hardware faults to be permanent.
*
* @param hwf HardwareFault to be constrained.
* @param nameBase Name of fault.
* @param builder AgreeNodeBuilder will have assertions added.
*/
public void constrainFaultActive(HWFault hwf, String nameBase, AgreeNodeBuilder builder) {
IdExpr independentlyActiveExpr = new IdExpr(this.createFaultIndependentActiveId(nameBase));
IdExpr dependentlyActiveExpr = new IdExpr(this.createFaultDependentActiveId(nameBase));
IdExpr independentEventExpr = new IdExpr(this.createFaultEventId(nameBase));
List<Expr> faultExprs = new ArrayList<>();
// collect the list of source faults in the propagations
// whose target fault is the current fault
// the names of those source faults are created through
// createFaultIndependentActiveId
getSrcFaultExprList(hwf, faultExprs);
// create a disjunction of the source faults as the triggering event
// for the dependent fault
Expr dependentEventExpr = buildFaultDisjunctionExpr(faultExprs, 0);
Expr assertIndependentExpr;
Expr assertDependentExpr;
TemporalConstraint tc = hwf.duration.getTc();
if (tc instanceof PermanentConstraint) {
assertIndependentExpr = createPermanentExpr(independentlyActiveExpr, independentEventExpr);
assertDependentExpr = createPermanentExpr(dependentlyActiveExpr, dependentEventExpr);
} else if (tc instanceof TransientConstraint) {
System.out.println("WARNING: ignoring duration on transient faults");
assertIndependentExpr = createTransientExpr(independentlyActiveExpr, independentEventExpr);
assertDependentExpr = createTransientExpr(dependentlyActiveExpr, dependentEventExpr);
} else {
throw new SafetyException("Unknown constraint type during translation of fault " + hwf.id + ". Constraint must be 'permanent'.");
}
builder.addAssertion(new AgreeStatement("", assertIndependentExpr, hwf.hwFaultStatement));
builder.addAssertion(new AgreeStatement("", assertDependentExpr, hwf.hwFaultStatement));
}
use of edu.umn.cs.crisys.safety.safety.TemporalConstraint in project AMASE by loonwerks.
the class DurationStatementImpl method basicSetTc.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTc(TemporalConstraint newTc, NotificationChain msgs) {
TemporalConstraint oldTc = tc;
tc = newTc;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SafetyPackage.DURATION_STATEMENT__TC, oldTc, newTc);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of edu.umn.cs.crisys.safety.safety.TemporalConstraint in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method constrainFaultActive.
/**
* Constrains fault activity to permanent expression. If user attempts to create
* transient, exception is thrown.
*
* @param f Fault
* @param nameBase Lustre name of fault
* @param builder The node builder that will have these assertions added.
*/
public void constrainFaultActive(Fault f, String nameBase, AgreeNodeBuilder builder) {
IdExpr independentlyActiveExpr = new IdExpr(this.createFaultIndependentActiveId(nameBase));
IdExpr dependentlyActiveExpr = new IdExpr(this.createFaultDependentActiveId(nameBase));
IdExpr independentEventExpr = new IdExpr(this.createFaultEventId(nameBase));
List<Expr> faultExprs = new ArrayList<>();
// collect the list of source faults in the propagations
// whose target fault is the current fault
// the names of those source faults are created through
// createFaultIndependentActiveId
getSrcFaultExprList(f, faultExprs);
// create a disjunction of the source faults as the triggering event
// for the dependent fault
Expr dependentEventExpr = buildFaultDisjunctionExpr(faultExprs, 0);
Expr assertIndependentExpr;
Expr assertDependentExpr;
TemporalConstraint tc = f.duration.getTc();
if (tc instanceof PermanentConstraint) {
assertIndependentExpr = createPermanentExpr(independentlyActiveExpr, independentEventExpr);
assertDependentExpr = createPermanentExpr(dependentlyActiveExpr, dependentEventExpr);
} else if (tc instanceof TransientConstraint) {
System.out.println("WARNING: ignoring duration on transient faults");
assertIndependentExpr = createTransientExpr(independentlyActiveExpr, independentEventExpr);
assertDependentExpr = createTransientExpr(dependentlyActiveExpr, dependentEventExpr);
} else {
throw new SafetyException("Unknown constraint type during translation of fault " + f.id + ". Constraint must be 'permanent'.");
}
builder.addAssertion(new AgreeStatement("", assertIndependentExpr, f.faultStatement));
builder.addAssertion(new AgreeStatement("", assertDependentExpr, f.faultStatement));
}
Aggregations