more consistent string conversion of high-z values, see #511

This commit is contained in:
hneemann 2020-09-12 10:51:51 +02:00
parent 7c2d944856
commit a526c91bc9
4 changed files with 5 additions and 5 deletions

View File

@ -66,7 +66,7 @@ public enum IntFormat {
*/ */
public String formatToEdit(Value inValue) { public String formatToEdit(Value inValue) {
if (inValue.isHighZ()) if (inValue.isHighZ())
return "?"; return "Z";
switch (this) { switch (this) {
case dec: case dec:

View File

@ -49,7 +49,7 @@ public class InValue {
* @throws Bits.NumberFormatException NumberFormatException * @throws Bits.NumberFormatException NumberFormatException
*/ */
public InValue(String value) throws Bits.NumberFormatException { public InValue(String value) throws Bits.NumberFormatException {
if (value.toLowerCase().trim().equalsIgnoreCase("z")) { if (value.trim().equalsIgnoreCase("z")) {
this.highZ = true; this.highZ = true;
this.value = 0; this.value = 0;
} else { } else {

View File

@ -236,7 +236,7 @@ public final class SingleValueDialog extends JDialog implements ModelStateObserv
textField.setText("0" + Long.toOctalString(editValue)); textField.setText("0" + Long.toOctalString(editValue));
break; break;
case HIGHZ: case HIGHZ:
textField.setText("?"); textField.setText("Z");
break; break;
default: default:
} }
@ -267,7 +267,7 @@ public final class SingleValueDialog extends JDialog implements ModelStateObserv
private void setStringToDialog(String text) { private void setStringToDialog(String text) {
text = text.trim(); text = text.trim();
if (text.length() > 0) { if (text.length() > 0) {
if (text.contains("?") && supportsHighZ) { if (text.contains("Z") && supportsHighZ) {
setSelectedFormat(InMode.HIGHZ); setSelectedFormat(InMode.HIGHZ);
editValue = 0; editValue = 0;
} else if (text.charAt(0) == '\'') { } else if (text.charAt(0) == '\'') {

View File

@ -20,6 +20,6 @@ public class ValueTest extends TestCase {
public void testFromInValue() throws Bits.NumberFormatException { public void testFromInValue() throws Bits.NumberFormatException {
assertEquals("5", new Value(new InValue("5"), 4).toString()); assertEquals("5", new Value(new InValue("5"), 4).toString());
assertEquals("Z", new Value(new InValue("z"), 4).toString()); assertEquals("Z", new Value(new InValue("z"), 4).toString());
assertEquals("?", IntFormat.hex.formatToEdit(new Value(new InValue("z"), 4))); assertEquals("Z", IntFormat.hex.formatToEdit(new Value(new InValue("z"), 4)));
} }
} }