use of com.ge.research.osate.verdict.dsl.verdict.SLExpr in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method handleAndSafetyReqExpr.
/**
* to handle LAnd expressions while creating a SafetyReqExpr object
* @param andExpr
* @param allPortNames
* @param allPortCIAs
* @return
*/
verdict.vdm.vdm_model.SafetyReqExpr handleAndSafetyReqExpr(SLAnd andExpr, List<String> allPortNames, List<String> allPortCIAs) {
// to pack this SafetyReqExpr
verdict.vdm.vdm_model.SafetyReqExpr packSafetyReqExpr = new verdict.vdm.vdm_model.SafetyReqExpr();
if (andExpr.getExprs().size() == 1) {
// Is a Port 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 packSafetyReq
packSafetyReqExpr.setPort(port);
} else if (subAndExpr instanceof SLNot) {
verdict.vdm.vdm_model.SafetyReqExprKind kind = verdict.vdm.vdm_model.SafetyReqExprKind.fromValue("Not");
// setting "kind" of expression
packSafetyReqExpr.setKind(kind);
// to pack the SafetyReqExpr for the Not
verdict.vdm.vdm_model.SafetyReqExpr packNotSafetyReqExpr = handleNotSafetyReqExpr((SLNot) subAndExpr, allPortNames, allPortCIAs);
// set the "not" of packSafetyReqExpr
packSafetyReqExpr.setNot(packNotSafetyReqExpr);
} else if (subAndExpr instanceof SLOr) {
/**
* If it is a single conjunct, just send it to handleOrCyberExpr
* and return the same package returned by handleAndCyberExpr
*/
packSafetyReqExpr = handleOrSafetyReqExpr(subAndExpr, allPortNames, allPortCIAs);
}
} else if (andExpr.getExprs().size() > 1) {
// collection of conjuncts
verdict.vdm.vdm_model.SafetyReqExprKind kind = verdict.vdm.vdm_model.SafetyReqExprKind.fromValue("And");
// setting "kind" of expression
packSafetyReqExpr.setKind(kind);
// to pack all conjunct subexpressions in a single list
verdict.vdm.vdm_model.SafetyReqExprList packOrList = new verdict.vdm.vdm_model.SafetyReqExprList();
for (SLExpr expr : andExpr.getExprs()) {
// for each conjunct (each disjunct is a LExpr)
// to pack the SafetyReqExpr for this conjunct
verdict.vdm.vdm_model.SafetyReqExpr packConjunctSafetyReqExpr = handleOrSafetyReqExpr(expr, allPortNames, allPortCIAs);
// adding to the list of conjuncts
packOrList.getExpr().add(packConjunctSafetyReqExpr);
}
// setting the "or" field of packSafetyReqExpr
packSafetyReqExpr.setAnd(packOrList);
}
return packSafetyReqExpr;
}
use of com.ge.research.osate.verdict.dsl.verdict.SLExpr 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.SLExpr 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;
}