Search in sources :

Example 1 with IOState

use of de.neemann.digital.draw.elements.IOState in project Digital by hneemann.

the class InputShape method applyStateMonitor.

@Override
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
    this.ioState = ioState;
    ioState.getOutput(0).addObserverToValue(guiObserver);
    return new Interactor() {

        @Override
        public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, Sync modelSync) {
            ObservableValue value = ioState.getOutput(0);
            if (value.getBits() == 1) {
                modelSync.access(() -> {
                    if (isHighZ) {
                        if (value.isHighZ())
                            value.setValue(0);
                        else if (value.getValue() == 0)
                            value.setValue(1);
                        else
                            value.setToHighZ();
                    } else
                        value.setValue(1 - value.getValue());
                });
                return true;
            } else {
                if (dialog == null || !dialog.isVisible()) {
                    Model model = ((In) element).getModel();
                    dialog = new SingleValueDialog(model.getWindowPosManager().getMainFrame(), pos, label, value, isHighZ, cc, model, modelSync);
                    dialog.setVisible(true);
                } else
                    dialog.requestFocus();
                return false;
            }
        }
    };
}
Also used : CircuitComponent(de.neemann.digital.gui.components.CircuitComponent) In(de.neemann.digital.core.io.In) IOState(de.neemann.digital.draw.elements.IOState) Element(de.neemann.digital.core.element.Element) ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) Sync(de.neemann.digital.gui.sync.Sync) SingleValueDialog(de.neemann.digital.gui.components.SingleValueDialog)

Example 2 with IOState

use of de.neemann.digital.draw.elements.IOState in project Digital by hneemann.

the class RAMShape method applyStateMonitor.

@Override
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
    return new Interactor() {

        @Override
        public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, Sync modelSync) {
            if (element instanceof RAMInterface) {
                DataField dataField = ((RAMInterface) element).getMemory();
                DataEditor dataEditor = new DataEditor(cc, dataField, size, dataBits, addrBits, true, modelSync);
                dataEditor.showDialog(dialogTitle, model);
            }
            return false;
        }
    };
}
Also used : DataEditor(de.neemann.digital.gui.components.DataEditor) DataField(de.neemann.digital.core.memory.DataField) CircuitComponent(de.neemann.digital.gui.components.CircuitComponent) IOState(de.neemann.digital.draw.elements.IOState) Sync(de.neemann.digital.gui.sync.Sync) RAMInterface(de.neemann.digital.core.memory.RAMInterface)

Example 3 with IOState

use of de.neemann.digital.draw.elements.IOState in project Digital by hneemann.

the class DipSwitchShape method applyStateMonitor.

@Override
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
    this.ioState = ioState;
    ioState.getOutput(0).addObserverToValue(guiObserver);
    return new Interactor() {

        @Override
        public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, Sync modelSync) {
            ObservableValue value = ioState.getOutput(0);
            modelSync.access(() -> value.setValue(1 - value.getValue()));
            return true;
        }
    };
}
Also used : CircuitComponent(de.neemann.digital.gui.components.CircuitComponent) IOState(de.neemann.digital.draw.elements.IOState) Element(de.neemann.digital.core.element.Element) ObservableValue(de.neemann.digital.core.ObservableValue) Sync(de.neemann.digital.gui.sync.Sync)

Aggregations

IOState (de.neemann.digital.draw.elements.IOState)3 CircuitComponent (de.neemann.digital.gui.components.CircuitComponent)3 Sync (de.neemann.digital.gui.sync.Sync)3 ObservableValue (de.neemann.digital.core.ObservableValue)2 Element (de.neemann.digital.core.element.Element)2 Model (de.neemann.digital.core.Model)1 In (de.neemann.digital.core.io.In)1 DataField (de.neemann.digital.core.memory.DataField)1 RAMInterface (de.neemann.digital.core.memory.RAMInterface)1 DataEditor (de.neemann.digital.gui.components.DataEditor)1 SingleValueDialog (de.neemann.digital.gui.components.SingleValueDialog)1