mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-10 21:38:05 -04:00
more consistent string conversion of high-z values, see #511
This commit is contained in:
parent
7c2d944856
commit
a526c91bc9
@ -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:
|
||||||
|
@ -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 {
|
||||||
|
@ -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) == '\'') {
|
||||||
|
@ -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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user