allows an input shape to avoid the active low state; see #177

This commit is contained in:
hneemann 2019-01-15 08:24:59 +01:00
parent aaa5050e20
commit 2af7b15180
5 changed files with 26 additions and 3 deletions

View File

@ -395,6 +395,15 @@ public final class Keys {
public static final Key<Boolean> IS_HIGH_Z public static final Key<Boolean> IS_HIGH_Z
= new Key<>("isHighZ", false).allowGroupEdit().setSecondary(); = new Key<>("isHighZ", false).allowGroupEdit().setSecondary();
/**
* flag to avoid active low at an input
*/
public static final Key<Boolean> AVOID_ACTIVE_LOW
= new Key<>("avoidActiveLow", false)
.setDependsOn(IS_HIGH_Z)
.allowGroupEdit()
.setSecondary();
/** /**
* the description of an element * the description of an element
*/ */

View File

@ -35,6 +35,7 @@ public class In implements Element {
.addAttribute(Keys.LABEL) .addAttribute(Keys.LABEL)
.addAttribute(Keys.INPUT_DEFAULT) .addAttribute(Keys.INPUT_DEFAULT)
.addAttribute(Keys.IS_HIGH_Z) .addAttribute(Keys.IS_HIGH_Z)
.addAttribute(Keys.AVOID_ACTIVE_LOW)
.addAttribute(Keys.DESCRIPTION) .addAttribute(Keys.DESCRIPTION)
.addAttribute(Keys.INT_FORMAT) .addAttribute(Keys.INT_FORMAT)
.addAttribute(Keys.PINNUMBER); .addAttribute(Keys.PINNUMBER);

View File

@ -32,11 +32,12 @@ public class InputShape implements Shape {
private final String label; private final String label;
private final PinDescriptions outputs; private final PinDescriptions outputs;
private final IntFormat format; private final IntFormat format;
private final boolean isHighZ;
private final boolean avoidLow;
private IOState ioState; private IOState ioState;
private SingleValueDialog dialog; private SingleValueDialog dialog;
private Value value; private Value value;
private Value inValue; private Value inValue;
private final boolean isHighZ;
/** /**
* Creates a new instance * Creates a new instance
@ -56,6 +57,8 @@ public class InputShape implements Shape {
format = attr.get(Keys.INT_FORMAT); format = attr.get(Keys.INT_FORMAT);
isHighZ = attr.get(Keys.INPUT_DEFAULT).isHighZ() || attr.get(Keys.IS_HIGH_Z); isHighZ = attr.get(Keys.INPUT_DEFAULT).isHighZ() || attr.get(Keys.IS_HIGH_Z);
avoidLow = isHighZ && attr.get(Keys.AVOID_ACTIVE_LOW);
} }
@Override @Override
@ -74,8 +77,12 @@ public class InputShape implements Shape {
if (value.getBits() == 1) { if (value.getBits() == 1) {
modelSync.access(() -> { modelSync.access(() -> {
if (isHighZ) { if (isHighZ) {
if (value.isHighZ()) value.setValue(0); if (value.isHighZ()) {
else if (value.getValue() == 0) value.setValue(1); if (avoidLow)
value.setValue(1);
else
value.setValue(0);
} else if (value.getValue() == 0) value.setValue(1);
else value.setToHighZ(); else value.setToHighZ();
} else } else
value.setValue(1 - value.getValue()); value.setValue(1 - value.getValue());

View File

@ -993,6 +993,9 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
<string name="key_isHighZ">Eingang kann hochohmig sein</string><!-- In, Splitter --> <string name="key_isHighZ">Eingang kann hochohmig sein</string><!-- In, Splitter -->
<string name="key_isHighZ_tt">Wenn gesetzt, ist ein hochohmiger Eingang erlaubt. Bei einem Eingangselement ist ein <string name="key_isHighZ_tt">Wenn gesetzt, ist ein hochohmiger Eingang erlaubt. Bei einem Eingangselement ist ein
hochohmiger Eingang auch erlaubt, wenn der Vorgabewert auf hochohmig ("Z") gesetzt wird.</string> hochohmiger Eingang auch erlaubt, wenn der Vorgabewert auf hochohmig ("Z") gesetzt wird.</string>
<string name="key_avoidActiveLow">Keine Ausgabe von Null.</string>
<string name="key_avoidActiveLow_tt">Vermeidet die Ausgabe von Null. Ist vor allem beim Aufbau von Relaisschaltungen
hilfreich. Kann nur aktiviert werden, wenn ein hochohmiger Ausgang erlaubt ist.</string>
<string name="key_Description">Beschreibung</string><!-- Out, In, Text --> <string name="key_Description">Beschreibung</string><!-- Out, In, Text -->
<string name="key_Description_tt">Eine kurze Beschreibung des Elementes.</string> <string name="key_Description_tt">Eine kurze Beschreibung des Elementes.</string>
<string name="key_Frequency">Frequenz/Hz</string><!-- Clock --> <string name="key_Frequency">Frequenz/Hz</string><!-- Clock -->

View File

@ -988,6 +988,9 @@
<string name="key_isHighZ">Is three-state input</string><!-- In, Splitter --> <string name="key_isHighZ">Is three-state input</string><!-- In, Splitter -->
<string name="key_isHighZ_tt">If set the input is allowed to be in high-z state. At the input component this is <string name="key_isHighZ_tt">If set the input is allowed to be in high-z state. At the input component this is
also allowed if high-z ("Z") is set as the default value.</string> also allowed if high-z ("Z") is set as the default value.</string>
<string name="key_avoidActiveLow">No zero output.</string>
<string name="key_avoidActiveLow_tt">Avoids zero output. This is especially helpful when setting up relay circuits.
Can only be activated if a high-z output is allowed.</string>
<string name="key_Description">Description</string><!-- Out, In, Text --> <string name="key_Description">Description</string><!-- Out, In, Text -->
<string name="key_Description_tt">A short description of this element and its usage.</string> <string name="key_Description_tt">A short description of this element and its usage.</string>
<string name="key_Frequency">Frequency/Hz</string><!-- Clock --> <string name="key_Frequency">Frequency/Hz</string><!-- Clock -->