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.WireArrayEnd;
10 * This class models a simple on/off (ONE/ZERO) switch for user interaction.
12 * @author Christian Femers
15 public class ManualSwitch implements Component
17 private WireArray output;
18 private WireArrayEnd 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)
46 if (this.isOn == isOn)
49 outputI.feedSignals(getValue());
59 return isOn ? Bit.ONE : Bit.ZERO;
63 public List<WireArray> getAllInputs()
69 public List<WireArray> getAllOutputs()
71 return List.of(output);