projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New Timeline events notify the simulation thread now
[Mograsim.git]
/
era.mi
/
src
/
era
/
mi
/
logic
/
components
/
ManualSwitch.java
diff --git
a/era.mi/src/era/mi/logic/components/ManualSwitch.java
b/era.mi/src/era/mi/logic/components/ManualSwitch.java
index
34c603c
..
0ad4a76
100644
(file)
--- a/
era.mi/src/era/mi/logic/components/ManualSwitch.java
+++ b/
era.mi/src/era/mi/logic/components/ManualSwitch.java
@@
-2,9
+2,8
@@
package era.mi.logic.components;
import java.util.List;
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.types.Bit;
+import era.mi.logic.wires.Wire.WireEnd;
/**
* This class models a simple on/off (ONE/ZERO) switch for user interaction.
/**
* This class models a simple on/off (ONE/ZERO) switch for user interaction.
@@
-12,52
+11,60
@@
import era.mi.logic.wires.WireArray.WireArrayInput;
* @author Christian Femers
*
*/
* @author Christian Femers
*
*/
-public class ManualSwitch implements Component
{
- private WireArray output;
- private Wire
ArrayInput outputI
;
+public class ManualSwitch implements Component
+{
+ private Wire
End output
;
private boolean isOn;
private boolean isOn;
- public ManualSwitch(WireArray output) {
- if (output.length != 1)
+ public ManualSwitch(WireEnd output)
+ {
+ if (output.length() != 1)
throw new IllegalArgumentException("Switch output can be only a single wire");
this.output = output;
throw new IllegalArgumentException("Switch output can be only a single wire");
this.output = output;
- this.outputI = output.createInput();
}
}
- public void switchOn() {
+ public void switchOn()
+ {
setState(true);
}
setState(true);
}
- public void switchOff() {
+ public void switchOff()
+ {
setState(false);
}
setState(false);
}
- public void toggle() {
+ public void toggle()
+ {
setState(!isOn);
}
setState(!isOn);
}
- public void setState(boolean isOn) {
+ public void setState(boolean isOn)
+ {
if (this.isOn == isOn)
return;
this.isOn = isOn;
if (this.isOn == isOn)
return;
this.isOn = isOn;
- output
I
.feedSignals(getValue());
+ output.feedSignals(getValue());
}
}
- public boolean isOn() {
+ public boolean isOn()
+ {
return isOn;
}
return isOn;
}
- public Bit getValue() {
+ public Bit getValue()
+ {
return isOn ? Bit.ONE : Bit.ZERO;
}
@Override
return isOn ? Bit.ONE : Bit.ZERO;
}
@Override
- public List<WireArray> getAllInputs() {
+ public List<WireEnd> getAllInputs()
+ {
return List.of();
}
@Override
return List.of();
}
@Override
- public List<WireArray> getAllOutputs() {
+ public List<WireEnd> getAllOutputs()
+ {
return List.of(output);
}
return List.of(output);
}