Search in sources :

Example 6 with BoolTable

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);
}
Also used : BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 7 with BoolTable

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()));
    }
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) ArrayList(java.util.ArrayList) ExpressionException(de.neemann.digital.analyse.expression.ExpressionException) BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) TruthTable(de.neemann.digital.analyse.TruthTable) TruthTableTableModel(de.neemann.digital.analyse.TruthTableTableModel)

Aggregations

BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)7 TruthTable (de.neemann.digital.analyse.TruthTable)3 Variable (de.neemann.digital.analyse.expression.Variable)3 BoolTableByteArray (de.neemann.digital.analyse.quinemc.BoolTableByteArray)2 TableReducer (de.neemann.digital.analyse.quinemc.TableReducer)2 Model (de.neemann.digital.core.Model)2 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)2 ModelAnalyser (de.neemann.digital.analyse.ModelAnalyser)1 TruthTableTableModel (de.neemann.digital.analyse.TruthTableTableModel)1 ExpressionException (de.neemann.digital.analyse.expression.ExpressionException)1 Signal (de.neemann.digital.core.Signal)1 ArrayList (java.util.ArrayList)1