use of de.neemann.digital.analyse.quinemc.BoolTable in project Digital by hneemann.
the class ModelAnalyserTest method testAnalyzerBacktrack.
public void testAnalyzerBacktrack() throws Exception {
Model model = new ToBreakRunner("dig/analyze/analyzeBacktrack.dig", false).getModel();
TruthTable tt = new ModelAnalyser(model).analyse();
final BoolTable Y1 = tt.getResult("1Y");
checkRemaining(Y1, "1A", "1B");
checkTable(getInner(Y1), zero, one, one, zero);
final BoolTable Y2 = tt.getResult("2Y");
checkRemaining(Y2, "2A", "2B");
checkTable(getInner(Y2), one, zero, zero, one);
final BoolTable Y3 = tt.getResult("3Y");
checkRemaining(Y3, "3A", "3B");
checkTable(getInner(Y3), zero, one, one, one);
final BoolTable Y4 = tt.getResult("4Y");
checkRemaining(Y4, "4A", "4B", "4C");
checkTable(getInner(Y4), zero, zero, zero, zero, zero, zero, zero, one);
}
use of de.neemann.digital.analyse.quinemc.BoolTable in project Digital by hneemann.
the class TableReorderManager method checkReorder.
private void checkReorder(TruthTableTableModel model) {
ArrayList<Variable> varList = model.getTable().getVars();
ArrayList<String> vars = new ArrayList<>();
ArrayList<String> results = new ArrayList<>();
boolean wasChange = false;
for (int i = 0; i < model.getColumnCount(); i++) {
String name = table.getTableHeader().getColumnModel().getColumn(i).getHeaderValue().toString();
if (!name.equals(table.getModel().getColumnName(i)))
wasChange = true;
BoolTable r = model.getTable().getResult(name);
if (r != null && varList.contains(new Variable(name)))
return;
if (r != null)
results.add(name);
else
vars.add(name);
}
if (wasChange) {
if (isVarChange(varList, vars)) {
try {
TruthTable tt = new ReorderInputs(model.getTable(), vars).reorder();
tableDialog.setModel(new TruthTableTableModel(tt));
} catch (ExpressionException e) {
// can't happen because no columns are removed
e.printStackTrace();
}
} else if (isResultChange(model.getTable(), results)) {
try {
TruthTable tt = new ReorderOutputs(model.getTable(), results).reorder();
tableDialog.setModel(new TruthTableTableModel(tt));
} catch (ExpressionException e) {
// can't happen because no columns are removed
e.printStackTrace();
}
} else
tableDialog.setModel(new TruthTableTableModel(model.getTable()));
}
}
Aggregations