use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class NetListTest method testTunnel.
public void testTunnel() throws Exception {
Circuit c = new Circuit();
c.add(new Wire(new Vector(1, 1), new Vector(2, 1)));
addTunnel(c, new Vector(2, 1), "A");
c.add(new Wire(new Vector(3, 1), new Vector(4, 1)));
addTunnel(c, new Vector(3, 1), "A");
NetList ns = new NetList(c);
assertEquals(1, ns.size());
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class ElementLibrary method importElement.
/**
* Imports the given file
*
* @param file the file to load
* @return the description
* @throws IOException IOException
*/
ElementTypeDescription importElement(File file) throws IOException {
try {
LOGGER.debug("load element " + file);
Circuit circuit;
try {
circuit = Circuit.loadCircuit(file, shapeFactory);
} catch (FileNotFoundException e) {
throw new IOException(Lang.get("err_couldNotFindIncludedFile_N0", file));
}
ElementTypeDescriptionCustom description = new ElementTypeDescriptionCustom(file, attributes -> new CustomElement(circuit, ElementLibrary.this), circuit);
description.setShortName(createShortName(file));
String descriptionText = circuit.getAttributes().get(Keys.DESCRIPTION);
if (descriptionText != null && descriptionText.length() > 0) {
description.setDescription(descriptionText);
}
return description;
} catch (PinException e) {
throw new IOException(Lang.get("msg_errorImportingModel_N0", file), e);
}
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class LibraryNode method getToolTipText.
/**
* @return the tool tip text
*/
public String getToolTipText() {
if (isCustom()) {
if (isUnique()) {
if (description == null) {
if (toolTipText == null) {
try {
LOGGER.debug("load tooltip from " + file);
Circuit c = Circuit.loadCircuit(file, null);
toolTipText = new LineBreaker().toHTML().breakLines(c.getAttributes().get(Keys.DESCRIPTION));
} catch (Exception e) {
toolTipText = Lang.get("msg_fileNotImportedYet");
}
}
return toolTipText;
} else
return new LineBreaker().toHTML().breakLines(description.getDescription(new ElementAttributes()));
} else
return Lang.get("msg_fileIsNotUnique");
} else
return new LineBreaker().toHTML().breakLines(Lang.getNull("elem_" + getName() + "_tt"));
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class CircuitBuilderTest method testBuilderCombinatorial.
public void testBuilderCombinatorial() throws Exception {
Variable a = new Variable("a");
Variable b = new Variable("b");
// xor
Expression y = and(or(a, b), not(and(a, b)));
ElementLibrary library = new ElementLibrary();
Circuit circuit = new CircuitBuilder(new ShapeFactory(library)).addCombinatorial("y", y).createCircuit();
ModelCreator m = new ModelCreator(circuit, library);
TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
te.check(0, 0, 0);
te.check(0, 1, 1);
te.check(1, 0, 1);
te.check(1, 1, 0);
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class CircuitBuilderTest method testBuilderSequential.
public void testBuilderSequential() throws Exception {
Variable y0 = new Variable("Y_0");
Variable y1 = new Variable("Y_1");
// counter
Expression y0s = not(y0);
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
ElementLibrary library = new ElementLibrary();
Circuit circuit = new CircuitBuilder(new ShapeFactory(library)).addSequential("Y_0", y0s).addSequential("Y_1", y1s).createCircuit();
ModelCreator m = new ModelCreator(circuit, library);
TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
te.check(0, 0);
te.checkC(1, 0);
te.checkC(0, 1);
te.checkC(1, 1);
te.checkC(0, 0);
}
Aggregations