Search in sources :

Example 21 with VisualElement

use of de.neemann.digital.draw.elements.VisualElement in project Digital by hneemann.

the class JarComponentManagerTest method testJarAvailable.

public void testJarAvailable() throws PinException, NodeException, IOException, ElementNotFoundException, TestingDataException {
    ToBreakRunner br = new ToBreakRunner("dig/jarLib/jarLibTest.dig") {

        @Override
        public void initLibrary(ElementLibrary library) {
            library.addExternalJarComponents(new File(Resources.getRoot(), "dig/jarLib/pluginExample-1.0-SNAPSHOT.jar"));
            assertNull(library.checkForException());
        }
    };
    for (VisualElement ve : br.getCircuit().getElements()) {
        if (ve.equalsDescription(TestCaseElement.TESTCASEDESCRIPTION)) {
            TestCaseDescription td = ve.getElementAttributes().get(TestCaseElement.TESTDATA);
            TestExecutor tr = new TestExecutor(td).create(br.getModel());
            assertTrue(tr.allPassed());
        }
    }
}
Also used : TestExecutor(de.neemann.digital.testing.TestExecutor) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner) VisualElement(de.neemann.digital.draw.elements.VisualElement) File(java.io.File) TestCaseDescription(de.neemann.digital.testing.TestCaseDescription)

Example 22 with VisualElement

use of de.neemann.digital.draw.elements.VisualElement in project Digital by hneemann.

the class CircuitBuilder method checkForOutputBus.

private int checkForOutputBus(int splitterXPos, Circuit circuit) {
    StringBuilder pinString = new StringBuilder();
    int y = 0;
    for (Map.Entry<String, ArrayList<String>> e : mis.getOutputBusMap().entrySet()) {
        pinString.setLength(0);
        int found = 0;
        final ArrayList<String> outputs = e.getValue();
        for (String n : outputs) {
            if (combinatorialOutputs.containsKey(n)) {
                found++;
                String p = mis.getPins().get(n);
                if (p != null) {
                    if (pinString.length() != 0)
                        pinString.append(",");
                    pinString.append(p);
                }
            }
        }
        if (found == outputs.size()) {
            circuit.add(new VisualElement(Splitter.DESCRIPTION.getName()).setAttribute(Keys.OUTPUT_SPLIT, "" + outputs.size()).setAttribute(Keys.INPUT_SPLIT, "1*" + outputs.size()).setPos(new Vector(splitterXPos, y)).setShapeFactory(shapeFactory));
            circuit.add(new VisualElement(Out.DESCRIPTION.getName()).setAttribute(Keys.LABEL, e.getKey()).setAttribute(Keys.BITS, outputs.size()).setAttribute(Keys.PINNUMBER, pinString.toString()).setPos(new Vector(splitterXPos + 3 * SIZE, y)).setShapeFactory(shapeFactory));
            circuit.add(new Wire(new Vector(splitterXPos + 3 * SIZE, y), new Vector(splitterXPos + SIZE, y)));
            for (int i = 0; i < outputs.size(); i++) {
                circuit.add(new VisualElement(Tunnel.DESCRIPTION.getName()).setAttribute(Keys.NETNAME, outputs.get(i)).setRotation(2).setPos(new Vector(splitterXPos - SIZE, y + i * SIZE)).setShapeFactory(shapeFactory));
                circuit.add(new Wire(new Vector(splitterXPos - SIZE, y + i * SIZE), new Vector(splitterXPos, y + i * SIZE)));
                FragmentVisualElement frag = combinatorialOutputs.get(outputs.get(i));
                frag.setVisualElement(new VisualElement(Tunnel.DESCRIPTION.getName()).setShapeFactory(shapeFactory).setAttribute(Keys.NETNAME, outputs.get(i)));
            }
            y += (outputs.size() + 2) * SIZE;
        }
    }
    return y;
}
Also used : VisualElement(de.neemann.digital.draw.elements.VisualElement) Wire(de.neemann.digital.draw.elements.Wire) Vector(de.neemann.digital.draw.graphics.Vector)

Example 23 with VisualElement

use of de.neemann.digital.draw.elements.VisualElement in project Digital by hneemann.

the class CircuitBuilder method addClockToFlipFlops.

private void addClockToFlipFlops(Circuit circuit) {
    int x = Integer.MAX_VALUE;
    int yMin = Integer.MAX_VALUE;
    int yMax = Integer.MIN_VALUE;
    for (FragmentVisualElement ff : flipflops) {
        Vector p = ff.getVisualElement().getPos();
        if (p.x < x)
            x = p.x;
        if (p.y < yMin)
            yMin = p.y;
        if (p.y > yMax)
            yMax = p.y;
    }
    x -= SIZE;
    if (useJKff)
        x -= SIZE;
    int yPos = yMin - SIZE * 3;
    if (useJKff)
        yPos = -SIZE;
    circuit.add(new Wire(new Vector(x, yPos), new Vector(x, yMax + SIZE)));
    for (FragmentVisualElement ff : flipflops) {
        Vector p = ff.getVisualElement().getPos();
        circuit.add(new Wire(new Vector(x, p.y + SIZE), new Vector(p.x, p.y + SIZE)));
    }
    VisualElement clock = new VisualElement(Clock.DESCRIPTION.getName()).setShapeFactory(shapeFactory).setPos(new Vector(x, yPos));
    clock.getElementAttributes().set(Keys.LABEL, "C").set(Keys.ROTATE, new Rotation(3)).set(Keys.FREQUENCY, 2).set(Keys.RUN_AT_REAL_TIME, true);
    circuit.add(clock);
}
Also used : VisualElement(de.neemann.digital.draw.elements.VisualElement) Wire(de.neemann.digital.draw.elements.Wire) Vector(de.neemann.digital.draw.graphics.Vector) Rotation(de.neemann.digital.core.element.Rotation)

Example 24 with VisualElement

use of de.neemann.digital.draw.elements.VisualElement in project Digital by hneemann.

the class CircuitBuilder method addNetConnections.

private void addNetConnections(Circuit circuit, int xPos, int y) {
    for (Variable name : sequentialVars) {
        String oName = name.getIdentifier();
        if (oName.endsWith("n")) {
            oName = oName.substring(0, oName.length() - 1);
            if (oName.endsWith("_") || oName.endsWith("^"))
                oName = oName.substring(0, oName.length() - 1);
        }
        if (!combinatorialOutputs.containsKey(oName)) {
            VisualElement t = new VisualElement(Tunnel.DESCRIPTION.getName()).setShapeFactory(shapeFactory);
            t.getElementAttributes().set(Keys.NETNAME, name.getIdentifier());
            t.setPos(new Vector(xPos, y));
            t.setRotation(2);
            circuit.add(t);
            VisualElement o = new VisualElement(Out.DESCRIPTION.getName()).setShapeFactory(shapeFactory);
            o.getElementAttributes().set(Keys.LABEL, oName);
            o.setPos(new Vector(xPos + SIZE, y));
            checkPinNumber(o);
            circuit.add(o);
            circuit.add(new Wire(new Vector(xPos, y), new Vector(xPos + SIZE, y)));
            y += SIZE * 2;
        }
    }
}
Also used : VisualElement(de.neemann.digital.draw.elements.VisualElement) Wire(de.neemann.digital.draw.elements.Wire) Vector(de.neemann.digital.draw.graphics.Vector)

Example 25 with VisualElement

use of de.neemann.digital.draw.elements.VisualElement in project Digital by hneemann.

the class TestCaseDescriptionEditor method getComponent.

@Override
protected JComponent getComponent(ElementAttributes elementAttributes) {
    JPanel panel = new JPanel(new FlowLayout());
    panel.add(new ToolTipAction(Lang.get("btn_edit")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new TestCaseDescriptionDialog(SwingUtilities.getWindowAncestor(panel), data, null).setVisible(true);
        }
    }.createJButton());
    panel.add(new ToolTipAction(Lang.get("btn_editDetached")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                getAttributeDialog().fireOk();
                VisualElement visualElement = TestCaseDescriptionEditor.this.getAttributeDialog().getVisualElement();
                Main main = getAttributeDialog().getMain();
                if (main != null) {
                    TestCaseDescriptionDialog dialog = new TestCaseDescriptionDialog(main, data, visualElement);
                    main.getWindowPosManager().register("testdata", dialog);
                    dialog.setVisible(true);
                }
            } catch (EditorParseException e1) {
                e1.printStackTrace();
            }
        }
    }.setToolTip(Lang.get("btn_editDetached_tt")).createJButton());
    return panel;
}
Also used : ToolTipAction(de.neemann.gui.ToolTipAction) ActionEvent(java.awt.event.ActionEvent) VisualElement(de.neemann.digital.draw.elements.VisualElement) Main(de.neemann.digital.gui.Main)

Aggregations

VisualElement (de.neemann.digital.draw.elements.VisualElement)25 Vector (de.neemann.digital.draw.graphics.Vector)11 Wire (de.neemann.digital.draw.elements.Wire)8 Circuit (de.neemann.digital.draw.elements.Circuit)7 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)5 ElementTypeDescription (de.neemann.digital.core.element.ElementTypeDescription)4 TestCaseDescription (de.neemann.digital.testing.TestCaseDescription)4 File (java.io.File)4 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)3 Main (de.neemann.digital.gui.Main)3 ExpressionListenerStore (de.neemann.digital.gui.components.table.ExpressionListenerStore)3 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)3 ErrorMessage (de.neemann.gui.ErrorMessage)3 IOException (java.io.IOException)3 Expression (de.neemann.digital.analyse.expression.Expression)2 Signal (de.neemann.digital.core.Signal)2 And (de.neemann.digital.core.basic.And)2 Keys (de.neemann.digital.core.element.Keys)2 External (de.neemann.digital.core.extern.External)2 In (de.neemann.digital.core.io.In)2