X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2FManualSwitch.java;fp=era.mi%2Fsrc%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2FManualSwitch.java;h=0000000000000000000000000000000000000000;hb=0009789a8df6b8d4562b6e1cbfa75102a7516ea8;hp=5012761e311fec377a9bf40839dd09ada585adb6;hpb=a28f7aa0dab4248e99159c5a647676170cb17a4e;p=Mograsim.git diff --git a/era.mi/src/mograsim/logic/core/components/ManualSwitch.java b/era.mi/src/mograsim/logic/core/components/ManualSwitch.java deleted file mode 100644 index 5012761e..00000000 --- a/era.mi/src/mograsim/logic/core/components/ManualSwitch.java +++ /dev/null @@ -1,74 +0,0 @@ -package mograsim.logic.core.components; - -import java.util.List; - -import mograsim.logic.core.timeline.Timeline; -import mograsim.logic.core.types.Bit; -import mograsim.logic.core.wires.Wire.ReadEnd; -import mograsim.logic.core.wires.Wire.ReadWriteEnd; - -/** - * This class models a simple on/off (ONE/ZERO) switch for user interaction. - * - * @author Christian Femers - * - */ -public class ManualSwitch extends Component -{ - private ReadWriteEnd output; - private boolean isOn; - - public ManualSwitch(Timeline timeline, ReadWriteEnd output) - { - super(timeline); - if (output.length() != 1) - throw new IllegalArgumentException("Switch output can be only a single wire"); - this.output = output; - } - - public void switchOn() - { - setState(true); - } - - public void switchOff() - { - setState(false); - } - - public void toggle() - { - setState(!isOn); - } - - public void setState(boolean isOn) - { - if (this.isOn == isOn) - return; - this.isOn = isOn; - output.feedSignals(getValue()); - } - - public boolean isOn() - { - return isOn; - } - - public Bit getValue() - { - return isOn ? Bit.ONE : Bit.ZERO; - } - - @Override - public List getAllInputs() - { - return List.of(); - } - - @Override - public List getAllOutputs() - { - return List.of(output); - } - -}