Search in sources :

Example 1 with InValue

use of de.neemann.digital.core.io.InValue in project Digital by hneemann.

the class CircuitTest method createCircuit.

private static Circuit createCircuit() {
    Circuit c = new Circuit();
    // add a ROM
    final DataField data = new DataField(4);
    data.setData(0, 0xffff0000ffff0000L);
    data.setData(1, 0x8fff0000ffff0000L);
    final VisualElement rom = new VisualElement(ROM.DESCRIPTION.getName()).setAttribute(Keys.DATA, data);
    c.add(rom);
    // add an input
    final VisualElement in = new VisualElement(In.DESCRIPTION.getName()).setAttribute(Keys.INPUT_DEFAULT, new InValue(0x8fff0000ffff0000L));
    c.add(in);
    return c;
}
Also used : DataField(de.neemann.digital.core.memory.DataField) InValue(de.neemann.digital.core.io.InValue)

Example 2 with InValue

use of de.neemann.digital.core.io.InValue in project Digital by hneemann.

the class CircuitComponent method actualToDefault.

/**
 * Makes actual input values to the default value
 */
public void actualToDefault() {
    if (!isLocked()) {
        Modifications.Builder builder = new Modifications.Builder(Lang.get("menu_actualToDefault"));
        for (VisualElement ve : circuit.getElements()) if (ve.equalsDescription(In.DESCRIPTION)) {
            ObservableValue ov = ((InputShape) ve.getShape()).getObservableValue();
            if (ov != null) {
                InValue newValue = new InValue(ov);
                InValue oldValue = ve.getElementAttributes().get(Keys.INPUT_DEFAULT);
                if (!newValue.equals(oldValue))
                    builder.add(new ModifyAttribute<>(ve, Keys.INPUT_DEFAULT, newValue));
            }
        }
        modify(builder.build());
    }
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) InValue(de.neemann.digital.core.io.InValue)

Aggregations

InValue (de.neemann.digital.core.io.InValue)2 ObservableValue (de.neemann.digital.core.ObservableValue)1 DataField (de.neemann.digital.core.memory.DataField)1