use of com.ge.research.osate.verdict.dsl.verdict.FExpr in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method handleEventHappens.
/**
* to create a EventHappens object for a SafetyRelExpr object
* @param portExpr
* @param allPortNames
* @param allPortCIAs
* @return
*/
verdict.vdm.vdm_model.EventHappens handleEventHappens(SLExpr eventExpr, List<String> allPortNames, List<String> allPortCIAs) {
String eventName = ((FExpr) eventExpr).getEventName();
Object happens = ((FExpr) eventExpr).getFault();
// to pack this Port
verdict.vdm.vdm_model.EventHappens event = createVdmEventHappens(eventName, happens);
// for testing --- delete later
allPortNames.add(eventName);
allPortCIAs.add(happens.toString());
return event;
}
use of com.ge.research.osate.verdict.dsl.verdict.FExpr in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method handleOrSafetyRelExpr.
/**
* to handle LOr expressions while creating a SafetyRelExpr object
* @param orExpr
* @param allPortNames
* @param allPortCIAs
* @return
*/
verdict.vdm.vdm_model.SafetyRelExpr handleOrSafetyRelExpr(SLExpr orExpr, List<String> allPortNames, List<String> allPortCIAs) {
// to pack this SafetyRelExpr
verdict.vdm.vdm_model.SafetyRelExpr packSafetyRelExpr = new verdict.vdm.vdm_model.SafetyRelExpr();
if (orExpr instanceof SLPort) {
verdict.vdm.vdm_model.IAPort port = handleIAPort(orExpr, allPortNames, allPortCIAs);
// setting "port" field of packSafetyRelExpr
packSafetyRelExpr.setPort(port);
} else if (orExpr instanceof SLNot) {
verdict.vdm.vdm_model.SafetyRelExprKind kind = verdict.vdm.vdm_model.SafetyRelExprKind.fromValue("Not");
// setting "kind" of expression
packSafetyRelExpr.setKind(kind);
// to pack the SafetyRelExpr for the Not
verdict.vdm.vdm_model.SafetyRelExpr packNotCyberExpr = handleNotSafetyRelExpr((SLNot) orExpr, allPortNames, allPortCIAs);
// set the "not" of packSafetyRelExpr
packSafetyRelExpr.setNot(packNotCyberExpr);
} else if (orExpr instanceof FExpr) {
verdict.vdm.vdm_model.EventHappens fault = handleEventHappens(orExpr, allPortNames, allPortCIAs);
// setting "port" field of packSafetyRelExpr
packSafetyRelExpr.setFault(fault);
} else if (((SLOr) orExpr).getExprs().size() == 1) {
// Is a solo disjunct
/**
* If it is a single disjunct, just send it to handleAndCyberExpr
* and return the same package returned by handleAndCyberExpr
*/
SLAnd soloAndExpr = ((SLOr) orExpr).getExprs().get(0);
packSafetyRelExpr = handleAndSafetyRelExpr(soloAndExpr, allPortNames, allPortCIAs);
} else if (((SLOr) orExpr).getExprs().size() > 1) {
verdict.vdm.vdm_model.SafetyRelExprKind kind = verdict.vdm.vdm_model.SafetyRelExprKind.fromValue("Or");
// setting "kind" of expression
packSafetyRelExpr.setKind(kind);
// to pack all disjunct subexpressions in a single list
verdict.vdm.vdm_model.SafetyRelExprList packAndList = new verdict.vdm.vdm_model.SafetyRelExprList();
for (SLAnd andExpr : ((SLOr) orExpr).getExprs()) {
// for each disjunct (each disjunct is a LAnd)
// to pack the SafetyRelExprfor this disjunct
verdict.vdm.vdm_model.SafetyRelExpr packDisjunctSafetyRelExpr = handleAndSafetyRelExpr(andExpr, allPortNames, allPortCIAs);
// adding to the list of disjuncts
packAndList.getExpr().add(packDisjunctSafetyRelExpr);
}
// setting the "and" field of packSafetyRelExpr
packSafetyRelExpr.setOr(packAndList);
}
return packSafetyRelExpr;
}
use of com.ge.research.osate.verdict.dsl.verdict.FExpr in project VERDICT by ge-high-assurance.
the class Aadl2CsvTranslator method extractPortsAndEventsFromAndExpr.
void extractPortsAndEventsFromAndExpr(SLAnd andExpr, List<String> allPortsEventsNames, List<String> allPortsIAEventsHappens) {
StringBuilder portEventNames = new StringBuilder();
StringBuilder iasHappens = new StringBuilder();
for (int i = 0; i < andExpr.getExprs().size(); ++i) {
SLExpr subAndExpr = andExpr.getExprs().get(i);
if (subAndExpr instanceof FExpr) {
portEventNames.append(((FExpr) subAndExpr).getEventName());
iasHappens.append("happens");
} else if (subAndExpr instanceof SLPort) {
portEventNames.append(((SLPort) subAndExpr).getPort());
iasHappens.append(convertAbbreviation(((SLPort) subAndExpr).getIa().getLiteral()));
// We probably need to change this to support nested conjunction expressions
} else {
throw new RuntimeException("MBAA does not support parsing nested safety relation expression: " + subAndExpr);
}
if (i < andExpr.getExprs().size() - 1) {
portEventNames.append(";");
iasHappens.append(";");
}
}
allPortsEventsNames.add(portEventNames.toString());
allPortsIAEventsHappens.add(iasHappens.toString());
}
use of com.ge.research.osate.verdict.dsl.verdict.FExpr in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method handleAndSafetyRelExpr.
/**
* to handle LAnd expressions while creating a SafetyRelExpr object
* @param andExpr
* @param allPortNames
* @param allPortCIAs
* @return
*/
verdict.vdm.vdm_model.SafetyRelExpr handleAndSafetyRelExpr(SLAnd andExpr, List<String> allPortNames, List<String> allPortCIAs) {
// to pack this SafetyRelExpr
verdict.vdm.vdm_model.SafetyRelExpr packSafetyRelExpr = new verdict.vdm.vdm_model.SafetyRelExpr();
if (andExpr.getExprs().size() == 1) {
// Is a Port or a Not or a Happens or a Not
SLExpr subAndExpr = andExpr.getExprs().get(0);
if (subAndExpr instanceof SLPort) {
verdict.vdm.vdm_model.IAPort port = handleIAPort(subAndExpr, allPortNames, allPortCIAs);
// setting "port" field of packSafetyRelExpr
packSafetyRelExpr.setPort(port);
} else if (subAndExpr instanceof SLNot) {
verdict.vdm.vdm_model.SafetyRelExprKind kind = verdict.vdm.vdm_model.SafetyRelExprKind.fromValue("Not");
// setting "kind" of expression
packSafetyRelExpr.setKind(kind);
// to pack the SafetyRelExpr for the Not
verdict.vdm.vdm_model.SafetyRelExpr packNotSafetyRelExpr = handleNotSafetyRelExpr((SLNot) subAndExpr, allPortNames, allPortCIAs);
// set the "not" of packSafetyRelExpr
packSafetyRelExpr.setNot(packNotSafetyRelExpr);
} else if (subAndExpr instanceof FExpr) {
verdict.vdm.vdm_model.EventHappens fault = handleEventHappens(subAndExpr, allPortNames, allPortCIAs);
// setting "port" field of packSafetyRelExpr
packSafetyRelExpr.setFault(fault);
} else if (subAndExpr instanceof SLOr) {
/**
* If it is a single conjunct, just send it to handleOrCyberExpr
* and return the same package returned by handleAndCyberExpr
*/
packSafetyRelExpr = handleOrSafetyRelExpr(subAndExpr, allPortNames, allPortCIAs);
}
} else if (andExpr.getExprs().size() > 1) {
// collection of conjuncts
verdict.vdm.vdm_model.SafetyRelExprKind kind = verdict.vdm.vdm_model.SafetyRelExprKind.fromValue("And");
// setting "kind" of expression
packSafetyRelExpr.setKind(kind);
// to pack all conjunct subexpressions in a single list
verdict.vdm.vdm_model.SafetyRelExprList packOrList = new verdict.vdm.vdm_model.SafetyRelExprList();
for (SLExpr expr : andExpr.getExprs()) {
// for each conjunct (each disjunct is a LExpr)
// to pack the SafetyRelExpr for this conjunct
verdict.vdm.vdm_model.SafetyRelExpr packConjunctSafetyRelExpr = handleOrSafetyRelExpr(expr, allPortNames, allPortCIAs);
// adding to the list of conjuncts
packOrList.getExpr().add(packConjunctSafetyRelExpr);
}
// setting the "or" field of packSafetyRelExpr
packSafetyRelExpr.setAnd(packOrList);
}
return packSafetyRelExpr;
}
Aggregations