Search in sources :

Example 1 with ElementTypeDescription

use of de.neemann.digital.core.element.ElementTypeDescription in project Digital by hneemann.

the class ExportZipAction method addFile.

private void addFile(ZipOutputStream zip, File file, Circuit circuit) throws ElementNotFoundException, IOException {
    addToZip(zip, file);
    for (VisualElement ve : circuit.getElements()) {
        String name = ve.getElementName();
        if (!elementSet.contains(name)) {
            elementSet.add(name);
            ElementTypeDescription desc = lib.getElementType(name);
            if (desc instanceof ElementLibrary.ElementTypeDescriptionCustom) {
                ElementLibrary.ElementTypeDescriptionCustom custom = (ElementLibrary.ElementTypeDescriptionCustom) desc;
                addFile(zip, custom.getFile(), custom.getCircuit());
            }
        }
    }
}
Also used : ElementTypeDescription(de.neemann.digital.core.element.ElementTypeDescription) ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) VisualElement(de.neemann.digital.draw.elements.VisualElement)

Example 2 with ElementTypeDescription

use of de.neemann.digital.core.element.ElementTypeDescription 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 3 with ElementTypeDescription

use of de.neemann.digital.core.element.ElementTypeDescription 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)

Example 4 with ElementTypeDescription

use of de.neemann.digital.core.element.ElementTypeDescription in project Digital by hneemann.

the class KeyOrderer method writeKeysXML.

private static void writeKeysXML(ArrayList<Entry> keys, PrintStream out) {
    for (Entry e : keys) {
        out.print("    <string name=\"");
        out.print(escapeXML(e.key, true));
        out.print("\">");
        out.print(escapeXML(e.value.trim(), false));
        // if (e.value.contains("\n"))
        // out.print("\n    ");
        out.print("</string>");
        if (e.elements != null) {
            out.print("<!-- ");
            boolean first = true;
            for (ElementTypeDescription d : e.elements) {
                if (first)
                    first = false;
                else
                    out.print(", ");
                out.print(d.getName());
            }
            out.print(" -->");
        }
        out.println();
    }
}
Also used : ElementTypeDescription(de.neemann.digital.core.element.ElementTypeDescription)

Aggregations

ElementTypeDescription (de.neemann.digital.core.element.ElementTypeDescription)4 VisualElement (de.neemann.digital.draw.elements.VisualElement)2 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)2 ElementNotFoundException (de.neemann.digital.draw.library.ElementNotFoundException)2 NodeException (de.neemann.digital.core.NodeException)1 Movable (de.neemann.digital.draw.elements.Movable)1 PinException (de.neemann.digital.draw.elements.PinException)1