1 package era.mi.logic.components;
5 import era.mi.logic.Bit;
6 import era.mi.logic.wires.WireArray;
7 import era.mi.logic.wires.WireArray.WireArrayInput;
10 * This class models a simple on/off (ONE/ZERO) switch for user interaction.
12 * @author Christian Femers
15 public final class ManualSwitch implements Component
17 private WireArray output;
18 private WireArrayInput outputI;
21 public ManualSwitch(WireArray output)
23 if(output.length != 1)
24 throw new IllegalArgumentException("Switch output can be only a single wire");
26 this.outputI = output.createInput();
29 public void switchOn()
34 public void switchOff()
44 public void setState(boolean isOn)
49 outputI.feedSignals(getValue());
59 return isOn ? Bit.ONE : Bit.ZERO;
63 public List<WireArray> getAllInputs() {
68 public List<WireArray> getAllOutputs() {
69 return List.of(output);