use of de.neemann.digital.analyse.expression.ContextFiller in project Digital by hneemann.
the class ReorderInputs method reorder.
/**
* Creates a new table matching the actual state of the items
*
* @return the new table
* @throws ExpressionException ExpressionException
*/
public TruthTable reorder() throws ExpressionException {
ArrayList<Variable> newVars = new ArrayList<>();
ArrayList<Variable> deletedVars = new ArrayList<>();
deletedVars.addAll(table.getVars());
for (String name : names) {
Variable found = null;
for (Variable v : deletedVars) if (v.getIdentifier().equals(name)) {
found = v;
break;
}
if (found != null) {
newVars.add(found);
deletedVars.remove(found);
}
}
if (newVars.size() < 2)
throw new ExpressionException(Lang.get("err_tableBecomesToSmall"));
TruthTable newTable = new TruthTable(newVars);
for (int j = 0; j < table.getResultCount(); j++) newTable.addResult(table.getResultName(j));
ContextFiller fc = new ContextFiller(newTable.getVars());
for (Variable v : deletedVars) fc.set(v, false);
for (int row = 0; row < newTable.getRows(); row++) {
fc.setContextTo(row);
for (int t = 0; t < newTable.getResultCount(); t++) newTable.setByContext(t, fc, table.getByContext(t, fc));
}
return newTable;
}
use of de.neemann.digital.analyse.expression.ContextFiller in project Digital by hneemann.
the class CheckResultListener method resultFound.
@Override
public void resultFound(String name, Expression expression) throws FormatterException, ExpressionException {
listener.resultFound(name, expression);
ContextFiller cf = new ContextFiller(variables);
for (int i = 0; i < boolTable.size(); i++) check(boolTable.get(i), expression.calculate(cf.setContextTo(i)));
}
Aggregations