Search in sources :

Example 1 with ElementNotFoundException

use of de.neemann.digital.draw.library.ElementNotFoundException in project Digital by hneemann.

the class Main method startTests.

/**
 * starts the tests
 */
public void startTests() {
    try {
        ArrayList<ValueTableDialog.TestSet> tsl = new ArrayList<>();
        for (VisualElement el : circuitComponent.getCircuit().getElements()) if (el.equalsDescription(TestCaseElement.TESTCASEDESCRIPTION))
            tsl.add(new ValueTableDialog.TestSet(el.getElementAttributes().get(TestCaseElement.TESTDATA), el.getElementAttributes().getCleanLabel()));
        if (tsl.isEmpty())
            throw new TestingDataException(Lang.get("err_noTestData"));
        windowPosManager.register("testResult", new ValueTableDialog(Main.this, Lang.get("msg_testResult")).addTestResult(tsl, circuitComponent.getCircuit(), library)).setVisible(true);
        ensureModelIsStopped();
    } catch (NodeException | ElementNotFoundException | PinException | TestingDataException | RuntimeException e1) {
        showErrorWithoutARunningModel(Lang.get("msg_runningTestError"), e1);
    }
}
Also used : ValueTableDialog(de.neemann.digital.gui.components.testing.ValueTableDialog) TestingDataException(de.neemann.digital.testing.TestingDataException) ArrayList(java.util.ArrayList) ElementNotFoundException(de.neemann.digital.draw.library.ElementNotFoundException)

Example 2 with ElementNotFoundException

use of de.neemann.digital.draw.library.ElementNotFoundException in project Digital by hneemann.

the class Main method orderMeasurements.

private void orderMeasurements() {
    try {
        Model m = new ModelCreator(circuitComponent.getCircuit(), library).createModel(false);
        try {
            ensureModelIsStopped();
            ArrayList<String> names = new ArrayList<>();
            for (Signal s : m.getSignals()) names.add(s.getName());
            new OrderMerger<String, String>(circuitComponent.getCircuit().getMeasurementOrdering()).order(names);
            ElementOrderer.ListOrder<String> o = new ElementOrderer.ListOrder<>(names);
            if (new ElementOrderer<>(Main.this, Lang.get("menu_orderMeasurements"), o).addOkButton().showDialog()) {
                circuitComponent.modify(new ModifyMeasurementOrdering(names));
            }
        } finally {
            m.close();
        }
    } catch (NodeException | PinException | ElementNotFoundException | RuntimeException e) {
        showErrorWithoutARunningModel(Lang.get("msg_errorCreatingModel"), e);
    }
}
Also used : ArrayList(java.util.ArrayList) ElementNotFoundException(de.neemann.digital.draw.library.ElementNotFoundException) ModelCreator(de.neemann.digital.draw.model.ModelCreator) ModifyMeasurementOrdering(de.neemann.digital.gui.components.modification.ModifyMeasurementOrdering) LibraryTreeModel(de.neemann.digital.gui.components.tree.LibraryTreeModel)

Example 3 with ElementNotFoundException

use of de.neemann.digital.draw.library.ElementNotFoundException in project Digital by hneemann.

the class ModifySetBits method modify.

@Override
public void modify(Circuit circuit, ElementLibrary library) {
    ArrayList<Movable> list = circuit.getElementsToMove(min, max);
    for (Movable m : list) if (m instanceof VisualElement) {
        VisualElement ve = (VisualElement) m;
        try {
            ElementTypeDescription td = library.getElementType(ve.getElementName());
            if (td != null) {
                if (td.getAttributeList().contains(Keys.BITS))
                    ve.setAttribute(Keys.BITS, bits);
            }
        } catch (ElementNotFoundException e) {
            e.printStackTrace();
        }
    }
    circuit.modified();
}
Also used : ElementTypeDescription(de.neemann.digital.core.element.ElementTypeDescription) Movable(de.neemann.digital.draw.elements.Movable) VisualElement(de.neemann.digital.draw.elements.VisualElement) ElementNotFoundException(de.neemann.digital.draw.library.ElementNotFoundException)

Example 4 with ElementNotFoundException

use of de.neemann.digital.draw.library.ElementNotFoundException in project Digital by hneemann.

the class CircuitComponent method getToolTipText.

@Override
public String getToolTipText(MouseEvent event) {
    Vector pos = getPosVector(event);
    VisualElement ve = circuit.getElementAt(pos);
    if (ve != null) {
        Pin p = circuit.getPinAt(raster(pos), ve);
        if (p != null)
            return createPinToolTip(p);
        try {
            ElementTypeDescription etd = library.getElementType(ve.getElementName());
            String tt = etd.getDescription(ve.getElementAttributes());
            final String pin = ve.getElementAttributes().get(Keys.PINNUMBER);
            if (pin.length() > 0)
                tt += " (" + Lang.get("msg_pin_N", pin) + ")";
            return checkToolTip(tt);
        } catch (ElementNotFoundException e) {
            return null;
        }
    }
    Wire w = circuit.getWireAt(pos, SIZE2);
    if (w != null) {
        ObservableValue v = w.getValue();
        if (v != null)
            return v.getValueString();
    }
    return null;
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) ElementNotFoundException(de.neemann.digital.draw.library.ElementNotFoundException) Vector(de.neemann.digital.draw.graphics.Vector)

Example 5 with ElementNotFoundException

use of de.neemann.digital.draw.library.ElementNotFoundException in project Digital by hneemann.

the class HDLModel method createNode.

/**
 * Creates a isolated node
 *
 * @param v      the VisualElement of the node
 * @param parent the parrents circuit
 * @return the node
 * @throws HDLException HDLException
 */
public HDLNode createNode(VisualElement v, HDLCircuit parent) throws HDLException {
    try {
        ElementTypeDescription td = elementLibrary.getElementType(v.getElementName());
        if (td instanceof ElementLibrary.ElementTypeDescriptionCustom) {
            ElementLibrary.ElementTypeDescriptionCustom tdc = (ElementLibrary.ElementTypeDescriptionCustom) td;
            HDLCircuit c = circuitMap.get(tdc.getCircuit());
            if (c == null) {
                c = new HDLCircuit(tdc.getCircuit(), v.getElementName(), this);
                circuitMap.put(tdc.getCircuit(), c);
            }
            return addInputsOutputs(new HDLNodeCustom(v.getElementName(), v.getElementAttributes(), c), v, parent).createExpressions();
        } else if (v.equalsDescription(Const.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(new ExprConstant(node.getElementAttributes().get(Keys.VALUE), node.getOutput().getBits()));
            return node;
        } else if (v.equalsDescription(DipSwitch.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(new ExprConstant(node.getElementAttributes().get(Keys.DIP_DEFAULT) ? 1 : 0, node.getOutput().getBits()));
            return node;
        } else if (v.equalsDescription(Ground.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(new ExprConstant(0, node.getOutput().getBits()));
            return node;
        } else if (v.equalsDescription(VDD.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(new ExprConstant(-1, node.getOutput().getBits()));
            return node;
        } else if (v.equalsDescription(Not.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(new ExprNot(new ExprVar(node.getInputs().get(0).getNet())));
            return node;
        } else if (v.equalsDescription(Or.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(createOperation(node.getInputs(), ExprOperate.Operation.OR));
            return node;
        } else if (v.equalsDescription(And.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(createOperation(node.getInputs(), ExprOperate.Operation.AND));
            return node;
        } else if (v.equalsDescription(XOr.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(createOperation(node.getInputs(), ExprOperate.Operation.XOR));
            return node;
        } else if (v.equalsDescription(NOr.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(new ExprNot(createOperation(node.getInputs(), ExprOperate.Operation.OR)));
            return node;
        } else if (v.equalsDescription(NAnd.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(new ExprNot(createOperation(node.getInputs(), ExprOperate.Operation.AND)));
            return node;
        } else if (v.equalsDescription(XNOr.DESCRIPTION)) {
            final HDLNodeAssignment node = createExpression(v, parent, td);
            node.setExpression(new ExprNot(createOperation(node.getInputs(), ExprOperate.Operation.XOR)));
            return node;
        } else
            return addInputsOutputs(new HDLNodeBuildIn(v.getElementName(), v.getElementAttributes(), new ObservableValuesBitsProvider(td.createElement(v.getElementAttributes()).getOutputs())), v, parent).createExpressions();
    } catch (ElementNotFoundException | PinException | NodeException e) {
        throw new HDLException("error creating node", e);
    }
}
Also used : NodeException(de.neemann.digital.core.NodeException) ElementNotFoundException(de.neemann.digital.draw.library.ElementNotFoundException) ElementTypeDescription(de.neemann.digital.core.element.ElementTypeDescription) ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) PinException(de.neemann.digital.draw.elements.PinException)

Aggregations

ElementNotFoundException (de.neemann.digital.draw.library.ElementNotFoundException)8 ModelCreator (de.neemann.digital.draw.model.ModelCreator)3 ElementTypeDescription (de.neemann.digital.core.element.ElementTypeDescription)2 ValueTableDialog (de.neemann.digital.gui.components.testing.ValueTableDialog)2 LibraryTreeModel (de.neemann.digital.gui.components.tree.LibraryTreeModel)2 ArrayList (java.util.ArrayList)2 AnalyseException (de.neemann.digital.analyse.AnalyseException)1 ModelAnalyser (de.neemann.digital.analyse.ModelAnalyser)1 TruthTable (de.neemann.digital.analyse.TruthTable)1 NodeException (de.neemann.digital.core.NodeException)1 ObservableValue (de.neemann.digital.core.ObservableValue)1 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)1 Clock (de.neemann.digital.core.wiring.Clock)1 Circuit (de.neemann.digital.draw.elements.Circuit)1 Movable (de.neemann.digital.draw.elements.Movable)1 PinException (de.neemann.digital.draw.elements.PinException)1 VisualElement (de.neemann.digital.draw.elements.VisualElement)1 Vector (de.neemann.digital.draw.graphics.Vector)1 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)1 RealTimeClock (de.neemann.digital.draw.model.RealTimeClock)1