WireArray(Input) is now Wire(End); all in-/outputs are now WireEnds
[Mograsim.git] / era.mi / src / era / mi / logic / components / ManualSwitch.java
index 93018dd..19ece81 100644 (file)
@@ -3,8 +3,7 @@ package era.mi.logic.components;
 import java.util.List;
 
 import era.mi.logic.Bit;
-import era.mi.logic.wires.WireArray;
-import era.mi.logic.wires.WireArray.WireArrayInput;
+import era.mi.logic.wires.Wire.WireEnd;
 
 /**
  * This class models a simple on/off (ONE/ZERO) switch for user interaction.
@@ -12,60 +11,60 @@ import era.mi.logic.wires.WireArray.WireArrayInput;
  * @author Christian Femers
  *
  */
-public class ManualSwitch implements Component 
+public class ManualSwitch implements Component
 {
-       private WireArray output;
-       private WireArrayInput outputI;
+       private WireEnd output;
        private boolean isOn;
-       
-       public ManualSwitch(WireArray output) 
+
+       public ManualSwitch(WireEnd output)
        {
-               if(output.length != 1)
+               if (output.length() != 1)
                        throw new IllegalArgumentException("Switch output can be only a single wire");
                this.output = output;
-               this.outputI = output.createInput();
        }
-       
+
        public void switchOn()
        {
                setState(true);
        }
-       
+
        public void switchOff()
        {
                setState(false);
        }
-       
+
        public void toggle()
        {
                setState(!isOn);
        }
-       
+
        public void setState(boolean isOn)
        {
-               if(this.isOn == isOn)
+               if (this.isOn == isOn)
                        return;
                this.isOn = isOn;
-               outputI.feedSignals(getValue());
+               output.feedSignals(getValue());
        }
-       
+
        public boolean isOn()
        {
                return isOn;
        }
-       
+
        public Bit getValue()
        {
                return isOn ? Bit.ONE : Bit.ZERO;
        }
 
        @Override
-       public List<WireArray> getAllInputs() {
+       public List<WireEnd> getAllInputs()
+       {
                return List.of();
        }
 
        @Override
-       public List<WireArray> getAllOutputs() {
+       public List<WireEnd> getAllOutputs()
+       {
                return List.of(output);
        }