use of de.neemann.digital.analyse.ModelAnalyser in project Digital by hneemann.
the class BuilderExpressionCreatorTest method check.
private void check(Model m) throws AnalyseException, NodeException, BacktrackException, PinException {
TruthTable tt = new ModelAnalyser(m).analyse();
m.close();
assertEquals(1, tt.getResultCount());
BoolTable r = tt.getResult(0);
assertEquals(4, r.size());
assertEquals(ThreeStateValue.zero, r.get(0));
assertEquals(ThreeStateValue.one, r.get(1));
assertEquals(ThreeStateValue.one, r.get(2));
assertEquals(ThreeStateValue.zero, r.get(3));
}
use of de.neemann.digital.analyse.ModelAnalyser in project Digital by hneemann.
the class Main method createAnalyseMenu.
/**
* Creates the analyse menu
*
* @param menuBar the menu bar
*/
private void createAnalyseMenu(JMenuBar menuBar) {
JMenu analyse = new JMenu(Lang.get("menu_analyse"));
menuBar.add(analyse);
analyse.add(new ToolTipAction(Lang.get("menu_analyse")) {
@Override
public void actionPerformed(ActionEvent e) {
try {
Model model = new ModelCreator(circuitComponent.getCircuit(), library).createModel(false);
try {
if (model.isInvalidSignal())
new ErrorMessage(Lang.get("msg_invalidSignalsAnalysed")).show(Main.this);
else
new TableDialog(Main.this, new ModelAnalyser(model).analyse(), library, shapeFactory, getBaseFileName()).setVisible(true);
ensureModelIsStopped();
} finally {
model.close();
}
} catch (PinException | NodeException | AnalyseException | ElementNotFoundException | BacktrackException | RuntimeException e1) {
showErrorWithoutARunningModel(Lang.get("msg_analyseErr"), e1);
}
}
}.setToolTip(Lang.get("menu_analyse_tt")).setAccelerator("F9").createJMenuItem());
analyse.add(new ToolTipAction(Lang.get("menu_synthesise")) {
@Override
public void actionPerformed(ActionEvent e) {
TruthTable tt = new TruthTable(3).addResult();
new TableDialog(Main.this, tt, library, shapeFactory, getBaseFileName()).setVisible(true);
ensureModelIsStopped();
}
}.setToolTip(Lang.get("menu_synthesise_tt")).createJMenuItem());
analyse.add(new ToolTipAction(Lang.get("menu_expression")) {
@Override
public void actionPerformed(ActionEvent e) {
new ExpressionDialog(Main.this, library, shapeFactory, getBaseFileName()).setVisible(true);
}
}.setToolTip(Lang.get("menu_expression_tt")).createJMenuItem());
}
use of de.neemann.digital.analyse.ModelAnalyser in project Digital by hneemann.
the class CircuitBuilderTest method testBus.
public void testBus() throws Exception {
final ToBreakRunner runner = new ToBreakRunner("dig/circuitBuilder/busTest.dig", false);
// create truth table incl. ModelAnalyzerInfo
TruthTable tt = new ModelAnalyser(runner.getModel()).analyse();
assertEquals(8, tt.getVars().size());
assertEquals(8, tt.getResultCount());
// create expressions based on truth table
ExpressionListenerStore expr = new ExpressionListenerStore(null);
new ExpressionCreator(tt).create(expr);
// build a new circuit
CircuitBuilder circuitBuilder = new CircuitBuilder(runner.getLibrary().getShapeFactory(), false, tt.getVars()).setModelAnalyzerInfo(tt.getModelAnalyzerInfo());
new BuilderExpressionCreator(circuitBuilder).create(expr);
Circuit circuit = circuitBuilder.createCircuit();
// check
List<VisualElement> in = circuit.findElements(v -> v.equalsDescription(In.DESCRIPTION));
assertEquals(2, in.size());
checkPin(in.get(0), "A", "1,2,3,4");
checkPin(in.get(1), "B", "5,6,7,8");
List<VisualElement> out = circuit.findElements(v -> v.equalsDescription(Out.DESCRIPTION));
assertEquals(2, out.size());
checkPin(out.get(0), "S", "9,10,11,12");
checkPin(out.get(1), "U", "13,14,15,16");
}
Aggregations