2020-04-13 09:14:15 +00:00
|
|
|
public class DigitalInput {
|
|
|
|
private boolean value = false;
|
|
|
|
|
2020-04-13 12:36:06 +00:00
|
|
|
public DigitalInput(final boolean value) {
|
2020-04-13 10:56:58 +00:00
|
|
|
setValue(value);
|
|
|
|
}
|
|
|
|
|
2020-04-14 09:29:26 +00:00
|
|
|
public DigitalInput(final LogicGate gate) {
|
2020-04-13 10:56:58 +00:00
|
|
|
setValue(gate);
|
|
|
|
}
|
|
|
|
|
2020-04-13 12:36:06 +00:00
|
|
|
public DigitalInput(final int value) {
|
2020-04-13 10:56:58 +00:00
|
|
|
setValue(value);
|
|
|
|
}
|
|
|
|
|
2020-04-13 12:36:06 +00:00
|
|
|
public DigitalInput(final char value) {
|
2020-04-13 10:56:58 +00:00
|
|
|
setValue(value);
|
2020-04-13 09:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* default value is false!
|
|
|
|
*/
|
|
|
|
public DigitalInput() {
|
|
|
|
}
|
|
|
|
|
2020-04-13 10:56:58 +00:00
|
|
|
public boolean getValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2020-04-13 09:14:15 +00:00
|
|
|
public void setValue(boolean value) {
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setValue(LogicGate gate) {
|
|
|
|
this.value = gate.getOutput(); // todo validation stuff
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setValue(int value) {
|
2020-04-13 10:48:15 +00:00
|
|
|
this.value = value > 0;
|
2020-04-13 09:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setValue(char value) {
|
2020-04-13 10:48:15 +00:00
|
|
|
this.value = value == 'H';
|
2020-04-13 09:14:15 +00:00
|
|
|
}
|
|
|
|
}
|