makes also the switches countable

This commit is contained in:
hneemann 2019-07-06 14:49:25 +02:00
parent 383b15dc06
commit b17bc3b5ea
5 changed files with 55 additions and 4 deletions

View File

@ -114,4 +114,11 @@ public final class PlainSwitchDT implements NodeInterface {
void addOutputsTo(ObservableValues.Builder ov) {
ov.add(outputA, outputB, outputC);
}
/**
* @return the number of bits switched
*/
public int getBits() {
return bits;
}
}

View File

@ -10,13 +10,14 @@ import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.stats.Countable;
import static de.neemann.digital.core.element.PinInfo.input;
/**
* A simple relay.
*/
public class Relay extends Node implements Element {
public class Relay extends Node implements Element, Countable {
/**
* The relays description
@ -79,4 +80,14 @@ public class Relay extends Node implements Element {
public boolean isClosed() {
return s.isClosed();
}
@Override
public int getDataBits() {
return s.getDataBits();
}
@Override
public int getInputsCount() {
return s.getInputsCount();
}
}

View File

@ -10,13 +10,14 @@ import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.stats.Countable;
import static de.neemann.digital.core.element.PinInfo.input;
/**
* A simple relay.
*/
public class RelayDT extends Node implements Element {
public class RelayDT extends Node implements Element, Countable {
/**
* The relays description
@ -76,4 +77,14 @@ public class RelayDT extends Node implements Element {
public boolean isClosed() {
return s.isClosed();
}
@Override
public int getDataBits() {
return s.getDataBits();
}
@Override
public int getInputsCount() {
return s.getInputsCount();
}
}

View File

@ -10,11 +10,12 @@ import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.stats.Countable;
/**
* A simple manually controlled switch
*/
public class Switch implements Element, NodeInterface {
public class Switch implements Element, NodeInterface, Countable {
/**
* The switch description
@ -103,4 +104,14 @@ public class Switch implements Element, NodeInterface {
public boolean isClosed() {
return closed;
}
@Override
public int getDataBits() {
return poles[0].getBits();
}
@Override
public int getInputsCount() {
return poles.length;
}
}

View File

@ -10,11 +10,12 @@ import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.stats.Countable;
/**
* A simple double throw switch
*/
public class SwitchDT implements Element, NodeInterface {
public class SwitchDT implements Element, NodeInterface, Countable {
/**
* The switch description
@ -91,4 +92,14 @@ public class SwitchDT implements Element, NodeInterface {
public boolean isClosed() {
return closed;
}
@Override
public int getDataBits() {
return poles[0].getBits();
}
@Override
public int getInputsCount() {
return poles.length;
}
}