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);
}
}
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);
}
}
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();
}
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;
}
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);
}
}
Aggregations