1 package era.mi.logic.components;
5 import era.mi.logic.timeline.Timeline;
6 import era.mi.logic.types.Bit;
7 import era.mi.logic.wires.Wire.ReadEnd;
8 import era.mi.logic.wires.Wire.ReadWriteEnd;
11 * This class models a simple on/off (ONE/ZERO) switch for user interaction.
13 * @author Christian Femers
16 public class ManualSwitch extends Component
18 private ReadWriteEnd output;
21 public ManualSwitch(Timeline timeline, ReadWriteEnd output)
24 if (output.length() != 1)
25 throw new IllegalArgumentException("Switch output can be only a single wire");
29 public void switchOn()
34 public void switchOff()
44 public void setState(boolean isOn)
46 if (this.isOn == isOn)
49 output.feedSignals(getValue());
59 return isOn ? Bit.ONE : Bit.ZERO;
63 public List<ReadEnd> getAllInputs()
69 public List<ReadWriteEnd> getAllOutputs()
71 return List.of(output);