added data view in circuit area.

made shapes and ShapeFactory more consistent.
This commit is contained in:
hneemann 2016-04-09 11:11:41 +02:00
parent 50d6b62fcc
commit 688db05fc1
36 changed files with 1089 additions and 84 deletions

View File

@ -0,0 +1,351 @@
<?xml version="1.0" encoding="utf-8"?>
<circuit>
<version>1</version>
<visualElements>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>rotation</string>
<rotation rotation="3"/>
</entry>
</elementAttributes>
<pos x="320" y="340"/>
<rotate>3</rotate>
</visualElement>
<visualElement>
<elementName>JK_FF</elementName>
<elementAttributes>
<entry>
<string>valueIsProbe</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Q_0</string>
</entry>
</elementAttributes>
<pos x="240" y="280"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>JK_FF</elementName>
<elementAttributes>
<entry>
<string>valueIsProbe</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Q_1</string>
</entry>
<entry>
<string>Default</string>
<int>1</int>
</entry>
</elementAttributes>
<pos x="440" y="280"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>JK_FF</elementName>
<elementAttributes>
<entry>
<string>valueIsProbe</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Q_2</string>
</entry>
<entry>
<string>Default</string>
<int>1</int>
</entry>
</elementAttributes>
<pos x="660" y="280"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>JK_FF</elementName>
<elementAttributes>
<entry>
<string>valueIsProbe</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Q_3</string>
</entry>
<entry>
<string>Default</string>
<int>1</int>
</entry>
</elementAttributes>
<pos x="880" y="280"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>And</elementName>
<elementAttributes/>
<pos x="540" y="240"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>And</elementName>
<elementAttributes/>
<pos x="760" y="240"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>Const</elementName>
<elementAttributes/>
<pos x="180" y="320"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>Clock</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>C</string>
</entry>
</elementAttributes>
<pos x="160" y="200"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>rotation</string>
<rotation reference="../../../../visualElement/elementAttributes/entry/rotation"/>
</entry>
</elementAttributes>
<pos x="520" y="340"/>
<rotate>3</rotate>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>rotation</string>
<rotation reference="../../../../visualElement/elementAttributes/entry/rotation"/>
</entry>
</elementAttributes>
<pos x="740" y="340"/>
<rotate>3</rotate>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>rotation</string>
<rotation reference="../../../../visualElement/elementAttributes/entry/rotation"/>
</entry>
</elementAttributes>
<pos x="960" y="340"/>
<rotate>3</rotate>
</visualElement>
<visualElement>
<elementName>Data</elementName>
<elementAttributes>
<entry>
<string>microStep</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Data</string>
</entry>
</elementAttributes>
<pos x="120" y="-60"/>
<rotate>0</rotate>
</visualElement>
</visualElements>
<wires>
<wire>
<p1 x="420" y="320"/>
<p2 x="440" y="320"/>
</wire>
<wire>
<p1 x="640" y="320"/>
<p2 x="660" y="320"/>
</wire>
<wire>
<p1 x="860" y="320"/>
<p2 x="880" y="320"/>
</wire>
<wire>
<p1 x="180" y="320"/>
<p2 x="220" y="320"/>
</wire>
<wire>
<p1 x="220" y="320"/>
<p2 x="240" y="320"/>
</wire>
<wire>
<p1 x="640" y="240"/>
<p2 x="760" y="240"/>
</wire>
<wire>
<p1 x="420" y="240"/>
<p2 x="540" y="240"/>
</wire>
<wire>
<p1 x="600" y="260"/>
<p2 x="640" y="260"/>
</wire>
<wire>
<p1 x="820" y="260"/>
<p2 x="860" y="260"/>
</wire>
<wire>
<p1 x="160" y="200"/>
<p2 x="200" y="200"/>
</wire>
<wire>
<p1 x="200" y="200"/>
<p2 x="400" y="200"/>
</wire>
<wire>
<p1 x="400" y="200"/>
<p2 x="620" y="200"/>
</wire>
<wire>
<p1 x="620" y="200"/>
<p2 x="840" y="200"/>
</wire>
<wire>
<p1 x="300" y="280"/>
<p2 x="320" y="280"/>
</wire>
<wire>
<p1 x="500" y="280"/>
<p2 x="520" y="280"/>
</wire>
<wire>
<p1 x="640" y="280"/>
<p2 x="660" y="280"/>
</wire>
<wire>
<p1 x="720" y="280"/>
<p2 x="740" y="280"/>
</wire>
<wire>
<p1 x="940" y="280"/>
<p2 x="960" y="280"/>
</wire>
<wire>
<p1 x="860" y="280"/>
<p2 x="880" y="280"/>
</wire>
<wire>
<p1 x="220" y="280"/>
<p2 x="240" y="280"/>
</wire>
<wire>
<p1 x="520" y="280"/>
<p2 x="540" y="280"/>
</wire>
<wire>
<p1 x="740" y="280"/>
<p2 x="760" y="280"/>
</wire>
<wire>
<p1 x="320" y="280"/>
<p2 x="420" y="280"/>
</wire>
<wire>
<p1 x="420" y="280"/>
<p2 x="440" y="280"/>
</wire>
<wire>
<p1 x="840" y="300"/>
<p2 x="880" y="300"/>
</wire>
<wire>
<p1 x="620" y="300"/>
<p2 x="660" y="300"/>
</wire>
<wire>
<p1 x="400" y="300"/>
<p2 x="440" y="300"/>
</wire>
<wire>
<p1 x="200" y="300"/>
<p2 x="240" y="300"/>
</wire>
<wire>
<p1 x="320" y="280"/>
<p2 x="320" y="340"/>
</wire>
<wire>
<p1 x="640" y="240"/>
<p2 x="640" y="260"/>
</wire>
<wire>
<p1 x="640" y="260"/>
<p2 x="640" y="280"/>
</wire>
<wire>
<p1 x="640" y="280"/>
<p2 x="640" y="320"/>
</wire>
<wire>
<p1 x="400" y="200"/>
<p2 x="400" y="300"/>
</wire>
<wire>
<p1 x="960" y="280"/>
<p2 x="960" y="340"/>
</wire>
<wire>
<p1 x="420" y="240"/>
<p2 x="420" y="280"/>
</wire>
<wire>
<p1 x="420" y="280"/>
<p2 x="420" y="320"/>
</wire>
<wire>
<p1 x="740" y="280"/>
<p2 x="740" y="340"/>
</wire>
<wire>
<p1 x="840" y="200"/>
<p2 x="840" y="300"/>
</wire>
<wire>
<p1 x="200" y="200"/>
<p2 x="200" y="300"/>
</wire>
<wire>
<p1 x="520" y="280"/>
<p2 x="520" y="340"/>
</wire>
<wire>
<p1 x="620" y="200"/>
<p2 x="620" y="300"/>
</wire>
<wire>
<p1 x="860" y="260"/>
<p2 x="860" y="280"/>
</wire>
<wire>
<p1 x="860" y="280"/>
<p2 x="860" y="320"/>
</wire>
<wire>
<p1 x="220" y="280"/>
<p2 x="220" y="320"/>
</wire>
</wires>
<measurementOrdering>
<string>C</string>
<string>Q_0</string>
<string>Q_1</string>
<string>Q_2</string>
<string>Q_3</string>
</measurementOrdering>
</circuit>

View File

@ -0,0 +1,214 @@
<?xml version="1.0" encoding="utf-8"?>
<circuit>
<version>1</version>
<visualElements>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>rotation</string>
<rotation rotation="3"/>
</entry>
</elementAttributes>
<pos x="400" y="460"/>
<rotate>3</rotate>
</visualElement>
<visualElement>
<elementName>Clock</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>C</string>
</entry>
<entry>
<string>Frequency</string>
<int>2</int>
</entry>
</elementAttributes>
<pos x="280" y="360"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>rotation</string>
<rotation reference="../../../../visualElement/elementAttributes/entry/rotation"/>
</entry>
</elementAttributes>
<pos x="560" y="460"/>
<rotate>3</rotate>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>rotation</string>
<rotation reference="../../../../visualElement/elementAttributes/entry/rotation"/>
</entry>
</elementAttributes>
<pos x="720" y="460"/>
<rotate>3</rotate>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>rotation</string>
<rotation reference="../../../../visualElement/elementAttributes/entry/rotation"/>
</entry>
</elementAttributes>
<pos x="880" y="460"/>
<rotate>3</rotate>
</visualElement>
<visualElement>
<elementName>T_FF</elementName>
<elementAttributes>
<entry>
<string>valueIsProbe</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Q_0</string>
</entry>
</elementAttributes>
<pos x="320" y="360"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>T_FF</elementName>
<elementAttributes>
<entry>
<string>valueIsProbe</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Q_1</string>
</entry>
</elementAttributes>
<pos x="480" y="360"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>T_FF</elementName>
<elementAttributes>
<entry>
<string>valueIsProbe</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Q_2</string>
</entry>
</elementAttributes>
<pos x="640" y="360"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>T_FF</elementName>
<elementAttributes>
<entry>
<string>valueIsProbe</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Q_3</string>
</entry>
</elementAttributes>
<pos x="800" y="360"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>Data</elementName>
<elementAttributes>
<entry>
<string>microStep</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Data</string>
</entry>
</elementAttributes>
<pos x="220" y="100"/>
<rotate>0</rotate>
</visualElement>
</visualElements>
<wires>
<wire>
<p1 x="540" y="360"/>
<p2 x="560" y="360"/>
</wire>
<wire>
<p1 x="600" y="360"/>
<p2 x="640" y="360"/>
</wire>
<wire>
<p1 x="380" y="360"/>
<p2 x="400" y="360"/>
</wire>
<wire>
<p1 x="280" y="360"/>
<p2 x="320" y="360"/>
</wire>
<wire>
<p1 x="440" y="360"/>
<p2 x="480" y="360"/>
</wire>
<wire>
<p1 x="700" y="360"/>
<p2 x="720" y="360"/>
</wire>
<wire>
<p1 x="760" y="360"/>
<p2 x="800" y="360"/>
</wire>
<wire>
<p1 x="860" y="360"/>
<p2 x="880" y="360"/>
</wire>
<wire>
<p1 x="540" y="380"/>
<p2 x="600" y="380"/>
</wire>
<wire>
<p1 x="380" y="380"/>
<p2 x="440" y="380"/>
</wire>
<wire>
<p1 x="700" y="380"/>
<p2 x="760" y="380"/>
</wire>
<wire>
<p1 x="560" y="360"/>
<p2 x="560" y="460"/>
</wire>
<wire>
<p1 x="880" y="360"/>
<p2 x="880" y="460"/>
</wire>
<wire>
<p1 x="400" y="360"/>
<p2 x="400" y="460"/>
</wire>
<wire>
<p1 x="720" y="360"/>
<p2 x="720" y="460"/>
</wire>
<wire>
<p1 x="440" y="360"/>
<p2 x="440" y="380"/>
</wire>
<wire>
<p1 x="760" y="360"/>
<p2 x="760" y="380"/>
</wire>
<wire>
<p1 x="600" y="360"/>
<p2 x="600" y="380"/>
</wire>
</wires>
</circuit>

View File

@ -0,0 +1,227 @@
<?xml version="1.0" encoding="utf-8"?>
<circuit>
<version>1</version>
<visualElements>
<visualElement>
<elementName>And</elementName>
<elementAttributes/>
<pos x="600" y="240"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>Not</elementName>
<elementAttributes/>
<pos x="480" y="240"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>And</elementName>
<elementAttributes/>
<pos x="700" y="160"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>And</elementName>
<elementAttributes/>
<pos x="700" y="320"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>NOr</elementName>
<elementAttributes/>
<pos x="800" y="180"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>NOr</elementName>
<elementAttributes/>
<pos x="800" y="300"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>Q</string>
</entry>
</elementAttributes>
<pos x="940" y="200"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>~Q</string>
</entry>
</elementAttributes>
<pos x="940" y="320"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>Delay</elementName>
<elementAttributes/>
<pos x="540" y="240"/>
<rotate>0</rotate>
</visualElement>
<visualElement>
<elementName>In</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>C</string>
</entry>
</elementAttributes>
<pos x="440" y="260"/>
<rotate>0</rotate>
</visualElement>
</visualElements>
<wires>
<wire>
<p1 x="780" y="240"/>
<p2 x="900" y="280"/>
</wire>
<wire>
<p1 x="780" y="280"/>
<p2 x="900" y="240"/>
</wire>
<wire>
<p1 x="880" y="320"/>
<p2 x="900" y="320"/>
</wire>
<wire>
<p1 x="680" y="320"/>
<p2 x="700" y="320"/>
</wire>
<wire>
<p1 x="900" y="320"/>
<p2 x="940" y="320"/>
</wire>
<wire>
<p1 x="680" y="160"/>
<p2 x="700" y="160"/>
</wire>
<wire>
<p1 x="440" y="260"/>
<p2 x="460" y="260"/>
</wire>
<wire>
<p1 x="660" y="260"/>
<p2 x="680" y="260"/>
</wire>
<wire>
<p1 x="880" y="200"/>
<p2 x="900" y="200"/>
</wire>
<wire>
<p1 x="680" y="200"/>
<p2 x="700" y="200"/>
</wire>
<wire>
<p1 x="900" y="200"/>
<p2 x="940" y="200"/>
</wire>
<wire>
<p1 x="680" y="360"/>
<p2 x="700" y="360"/>
</wire>
<wire>
<p1 x="680" y="140"/>
<p2 x="900" y="140"/>
</wire>
<wire>
<p1 x="780" y="300"/>
<p2 x="800" y="300"/>
</wire>
<wire>
<p1 x="460" y="240"/>
<p2 x="480" y="240"/>
</wire>
<wire>
<p1 x="520" y="240"/>
<p2 x="540" y="240"/>
</wire>
<wire>
<p1 x="580" y="240"/>
<p2 x="600" y="240"/>
</wire>
<wire>
<p1 x="760" y="340"/>
<p2 x="800" y="340"/>
</wire>
<wire>
<p1 x="760" y="180"/>
<p2 x="800" y="180"/>
</wire>
<wire>
<p1 x="460" y="280"/>
<p2 x="600" y="280"/>
</wire>
<wire>
<p1 x="780" y="220"/>
<p2 x="800" y="220"/>
</wire>
<wire>
<p1 x="680" y="380"/>
<p2 x="900" y="380"/>
</wire>
<wire>
<p1 x="900" y="280"/>
<p2 x="900" y="320"/>
</wire>
<wire>
<p1 x="900" y="140"/>
<p2 x="900" y="200"/>
</wire>
<wire>
<p1 x="900" y="200"/>
<p2 x="900" y="240"/>
</wire>
<wire>
<p1 x="900" y="320"/>
<p2 x="900" y="380"/>
</wire>
<wire>
<p1 x="680" y="200"/>
<p2 x="680" y="260"/>
</wire>
<wire>
<p1 x="680" y="140"/>
<p2 x="680" y="160"/>
</wire>
<wire>
<p1 x="680" y="360"/>
<p2 x="680" y="380"/>
</wire>
<wire>
<p1 x="680" y="260"/>
<p2 x="680" y="320"/>
</wire>
<wire>
<p1 x="460" y="240"/>
<p2 x="460" y="260"/>
</wire>
<wire>
<p1 x="460" y="260"/>
<p2 x="460" y="280"/>
</wire>
<wire>
<p1 x="780" y="280"/>
<p2 x="780" y="300"/>
</wire>
<wire>
<p1 x="780" y="220"/>
<p2 x="780" y="240"/>
</wire>
</wires>
<measurementOrdering>
<string>C</string>
<string>J</string>
<string>K</string>
<string>Dif</string>
<string>Q</string>
<string>~Q</string>
</measurementOrdering>
</circuit>

View File

@ -406,7 +406,7 @@ public class Model {
* @param name the name of the Signal
* @param value the signals value
*/
private Signal(String name, ObservableValue value) {
public Signal(String name, ObservableValue value) {
this.name = name;
this.value = value;
}

View File

@ -33,6 +33,7 @@ public class AttributeKey<VALUE> {
public static final AttributeKey<Boolean> ShowDataTable = new AttributeKey<>("showDataTable", Lang.get("key_showDataTable"), false);
public static final AttributeKey<Boolean> ShowDataGraph = new AttributeKey<>("showDataGraph", Lang.get("key_showDataGraph"), false);
public static final AttributeKey<Boolean> StartTimer = new AttributeKey<>("startTimer", Lang.get("key_startClock"), false);
public static final AttributeKey<Boolean> MicroStep = new AttributeKey<>("microStep", Lang.get("key_microStep"), false);
private final String key;
private final VALUE def;

View File

@ -40,7 +40,7 @@ public interface Element {
/**
* Is called after registerNodes is called on all Elements.
*/
default void init() {
default void init(Model model) {
}
}

View File

@ -84,6 +84,10 @@ public class ElementAttributes {
return get(AttributeKey.Bits);
}
public String getLabel() {
return get(AttributeKey.Label);
}
public ElementAttributes setBits(int bits) {
set(AttributeKey.Bits, bits);
return this;
@ -116,4 +120,5 @@ public class ElementAttributes {
attributes = new HashMap<>();
attributes.put(fileKey, file.getPath());
}
}

View File

@ -152,7 +152,7 @@ public class Splitter implements Element {
}
@Override
public void init() {
public void init(Model m) {
for (ObservableValue v : inputs)
v.hasChanged();
}

View File

@ -16,6 +16,7 @@ import de.neemann.digital.core.io.Out;
import de.neemann.digital.core.io.Probe;
import de.neemann.digital.core.memory.*;
import de.neemann.digital.core.wiring.*;
import de.neemann.digital.gui.components.data.DummyElement;
import de.neemann.digital.gui.components.terminal.Terminal;
import de.neemann.digital.lang.Lang;
@ -54,6 +55,7 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
add(Out.SEVENDESCRIPTION, menu);
add(Out.SEVENHEXDESCRIPTION, menu);
add(Terminal.DESCRIPTION, menu);
add(DummyElement.DATADESCRIPTION, menu);
menu = Lang.get("lib_mux");
add(Multiplexer.DESCRIPTION, menu);

View File

@ -24,10 +24,10 @@ import java.util.*;
*/
public class ModelDescription implements Iterable<ModelEntry> {
private final Circuit circuit;
private final NetList netList;
private final ArrayList<ModelEntry> entries;
private final HashMap<String, Pin> ioMap;
private HashMap<Node, ModelEntry> map;
/**
* Creates the ModelDescription.
@ -69,6 +69,7 @@ public class ModelDescription implements Iterable<ModelEntry> {
* @throws NodeException NodeException
*/
public ModelDescription(Circuit circuit, ElementLibrary library, boolean readAsCustom, String fileName, NetList netList) throws PinException, NodeException {
this.circuit = circuit;
this.netList = netList;
entries = new ArrayList<>();
if (readAsCustom)
@ -176,8 +177,10 @@ public class ModelDescription implements Iterable<ModelEntry> {
for (ModelEntry e : entries)
e.getElement().registerNodes(m);
for (ModelEntry e : entries)
e.getElement().init();
for (ModelEntry e : entries) {
e.getElement().init(m);
e.getVisualElement().getShape().registerModel(this, m, e);
}
return m;
}
@ -231,4 +234,7 @@ public class ModelDescription implements Iterable<ModelEntry> {
return entr;
}
public Circuit getCircuit() {
return circuit;
}
}

View File

@ -1,6 +1,7 @@
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -20,8 +21,8 @@ public class BreakShape implements Shape {
private static final Vector D2 = new Vector(SIZEQ, SIZEQ);
private final String label;
public BreakShape(String label) {
this.label = label;
public BreakShape(ElementAttributes attr) {
this.label = attr.getLabel();
}
@Override

View File

@ -3,6 +3,7 @@ package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -21,8 +22,8 @@ public class ClockShape implements Shape {
private final String label;
public ClockShape(String label) {
this.label = label;
public ClockShape(ElementAttributes attr) {
this.label = attr.getLabel();
}
@Override

View File

@ -2,6 +2,8 @@ package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.AttributeKey;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -17,8 +19,8 @@ public class ConstShape implements Shape {
private String value;
public ConstShape(long value) {
this.value = ObservableValue.getHexString(value);
public ConstShape(ElementAttributes attr) {
this.value = ObservableValue.getHexString(attr.get(AttributeKey.Value));
}
@Override

View File

@ -0,0 +1,69 @@
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.Model;
import de.neemann.digital.core.ModelEvent;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.AttributeKey;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pins;
import de.neemann.digital.draw.graphics.Graphic;
import de.neemann.digital.draw.model.ModelDescription;
import de.neemann.digital.draw.model.ModelEntry;
import de.neemann.digital.gui.components.OrderMerger;
import de.neemann.digital.gui.components.data.DataSet;
import de.neemann.digital.gui.components.data.DataSetObserver;
import java.util.ArrayList;
/**
* Shape which shows the data graph inside the models circuit area.
*
* @author hneemann
*/
public class DataShape implements Shape {
private final ModelEvent.Event type;
private DataSet dataSet;
public DataShape(ElementAttributes attr) {
if (attr.get(AttributeKey.MicroStep))
type = ModelEvent.Event.MICROSTEP;
else
type = ModelEvent.Event.STEP;
}
@Override
public Pins getPins() {
return new Pins();
}
@Override
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
return null;
}
@Override
public void drawTo(Graphic graphic, boolean heighLight) {
if (dataSet == null) {
dataSet = new DataSet();
}
dataSet.drawTo(graphic, false);
}
@Override
public void registerModel(ModelDescription modelDescription, Model model, ModelEntry element) {
ArrayList<Model.Signal> signals = model.getSignalsCopy();
new OrderMerger<String, Model.Signal>(modelDescription.getCircuit().getMeasurementOrdering()) {
@Override
public boolean equals(Model.Signal a, String b) {
return a.getName().equals(b);
}
}.order(signals);
dataSet = new DataSet(signals);
DataSetObserver dataSetObserver = new DataSetObserver(type, dataSet);
model.addObserver(dataSetObserver);
}
}

View File

@ -1,6 +1,8 @@
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.AttributeKey;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -18,10 +20,10 @@ public class DemuxerShape implements Shape {
private final int height;
private Pins pins;
public DemuxerShape(int selectorBits, boolean hasInput, boolean flip) {
public DemuxerShape(ElementAttributes attr, boolean hasInput) {
this.hasInput = hasInput;
this.flip = flip;
outputCount = 1 << selectorBits;
this.flip = attr.get(AttributeKey.FlipSelPositon);
outputCount = 1 << attr.get(AttributeKey.SelectorBits);
height = hasInput || (outputCount <= 2) ? outputCount * SIZE : (outputCount - 1) * SIZE;
}

View File

@ -1,6 +1,8 @@
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.AttributeKey;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -19,8 +21,8 @@ public class DriverShape implements Shape {
private final boolean bottom;
private Pins pins;
public DriverShape(boolean bottom) {
this.bottom = bottom;
public DriverShape(ElementAttributes attr) {
this.bottom = attr.get(AttributeKey.FlipSelPositon);
}
@Override

View File

@ -3,6 +3,7 @@ package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -24,8 +25,8 @@ public class InputShape implements Shape {
private final String label;
private IOState ioState;
public InputShape(String label) {
this.label = label;
public InputShape(ElementAttributes attr) {
this.label = attr.getLabel();
}
@Override

View File

@ -2,6 +2,8 @@ package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.AttributeKey;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -10,8 +12,6 @@ import de.neemann.digital.draw.graphics.Orientation;
import de.neemann.digital.draw.graphics.Style;
import de.neemann.digital.draw.graphics.Vector;
import java.awt.*;
import static de.neemann.digital.draw.shapes.OutputShape.SIZE;
/**
@ -24,9 +24,9 @@ public class LEDShape implements Shape {
private Style onStyle;
private IOState ioState;
public LEDShape(String label, Color color) {
this.label = label;
onStyle = new Style(1, true, color);
public LEDShape(ElementAttributes attr) {
this.label = attr.getLabel();
onStyle = new Style(1, true, attr.get(AttributeKey.Color));
}
@Override

View File

@ -1,6 +1,8 @@
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.AttributeKey;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -16,9 +18,9 @@ public class MuxerShape implements Shape {
private final boolean flip;
private Pins pins;
public MuxerShape(int selectorBits, boolean flip) {
this.flip = flip;
this.inputCount = 1 << selectorBits;
public MuxerShape(ElementAttributes attr) {
this.flip = attr.get(AttributeKey.FlipSelPositon);
this.inputCount = 1 << attr.get(AttributeKey.SelectorBits);
}
@Override

View File

@ -2,6 +2,7 @@ package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -20,8 +21,8 @@ public class OutputShape implements Shape {
private final String label;
private IOState ioState;
public OutputShape(String label) {
this.label = label;
public OutputShape(ElementAttributes attr) {
this.label = attr.getLabel();
}
@Override

View File

@ -1,6 +1,7 @@
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -18,8 +19,8 @@ public class ProbeShape implements Shape {
private IOState ioState;
private int bits;
public ProbeShape(String label) {
this.label = label;
public ProbeShape(ElementAttributes attr) {
this.label = attr.getLabel();
}
@Override

View File

@ -1,6 +1,7 @@
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
@ -15,8 +16,8 @@ public class ResetShape implements Shape {
private final String label;
public ResetShape(String label) {
this.label = label;
public ResetShape(ElementAttributes attr) {
this.label = attr.getLabel();
}
@Override

View File

@ -2,26 +2,25 @@ package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
import de.neemann.digital.draw.graphics.Style;
import de.neemann.digital.draw.graphics.Vector;
import java.awt.*;
import static de.neemann.digital.draw.shapes.GenericShape.SIZE;
/**
* @author hneemann
*/
public class SevenSegHexShape extends SevenShape {
private static final int[] table = new int[]{0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71};
private static final int[] TABLE = new int[]{0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71};
private Pins pins;
private ObservableValue input;
public SevenSegHexShape(String label, Color color) {
super(label, color);
public SevenSegHexShape(ElementAttributes attr) {
super(attr);
}
@Override
@ -30,7 +29,7 @@ public class SevenSegHexShape extends SevenShape {
return onStyle;
int v = (int) input.getValueIgnoreBurn() & 0xf;
v = table[v];
v = TABLE[v];
if ((v & (1 << i)) != 0)
return onStyle;
else

View File

@ -2,14 +2,13 @@ package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
import de.neemann.digital.draw.graphics.Style;
import de.neemann.digital.draw.graphics.Vector;
import java.awt.*;
import static de.neemann.digital.draw.shapes.GenericShape.SIZE;
/**
@ -19,8 +18,8 @@ public class SevenSegShape extends SevenShape {
private ObservableValue[] inputs;
private Pins pins;
public SevenSegShape(String label, Color color) {
super(label, color);
public SevenSegShape(ElementAttributes attr) {
super(attr);
}
@Override

View File

@ -1,5 +1,7 @@
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.element.AttributeKey;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.graphics.Graphic;
import de.neemann.digital.draw.graphics.Polygon;
import de.neemann.digital.draw.graphics.Style;
@ -23,9 +25,9 @@ public abstract class SevenShape implements Shape {
protected final Style onStyle;
protected final Style offStyle;
public SevenShape(String label, Color color) {
this.label = label;
onStyle = new Style(8, true, color);
public SevenShape(ElementAttributes attr) {
this.label = attr.getLabel();
onStyle = new Style(8, true, attr.get(AttributeKey.Color));
offStyle = new Style(8, true, new Color(230, 230, 230));
}

View File

@ -1,8 +1,11 @@
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.Model;
import de.neemann.digital.core.Observer;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pins;
import de.neemann.digital.draw.model.ModelDescription;
import de.neemann.digital.draw.model.ModelEntry;
/**
* @author hneemann
@ -23,7 +26,7 @@ public interface Shape extends Drawable {
* shape can register the guiObserver to one of the the input or output ObservableValues.
* To access the actual state while drawing, the Shape needs to store the IOState in a member
* variable.
*
* <p>
* If the shape returns an interactor, this interactors clicked method is called if the
* shape is clicked in the running mode.
*
@ -33,4 +36,14 @@ public interface Shape extends Drawable {
*/
Interactor applyStateMonitor(IOState ioState, Observer guiObserver);
/**
* Allows the shape to make its drawing dependent of the model.
* It is used by {@link DataShape} to create and show the data graph.
*
* @param modelDescription the models description
* @param model the model itself
* @param element the ModelElement this shape belongs to
*/
default void registerModel(ModelDescription modelDescription, Model model, ModelEntry element) {
}
}

View File

@ -15,6 +15,7 @@ import de.neemann.digital.core.memory.RAMSinglePort;
import de.neemann.digital.core.wiring.*;
import de.neemann.digital.draw.library.ElementLibrary;
import de.neemann.digital.gui.LibrarySelector;
import de.neemann.digital.gui.components.data.DummyElement;
import de.neemann.digital.lang.Lang;
import java.util.HashMap;
@ -42,24 +43,25 @@ public final class ShapeFactory {
map.put(RAMDualPort.DESCRIPTION.getName(), attr -> new RAMShape("RAM", RAMDualPort.DESCRIPTION.getInputNames(attr), outputInfos(RAMDualPort.DESCRIPTION, attr), attr.get(AttributeKey.Label)));
map.put(RAMSinglePort.DESCRIPTION.getName(), attr -> new RAMShape("RAM", RAMSinglePort.DESCRIPTION.getInputNames(attr), outputInfos(RAMSinglePort.DESCRIPTION, attr), attr.get(AttributeKey.Label)));
map.put(In.DESCRIPTION.getName(), attr -> new InputShape(attr.get(AttributeKey.Label)));
map.put(Reset.DESCRIPTION.getName(), attr -> new ResetShape(attr.get(AttributeKey.Label)));
map.put(Const.DESCRIPTION.getName(), attr -> new ConstShape(attr.get(AttributeKey.Value)));
map.put(Out.DESCRIPTION.getName(), attr -> new OutputShape(attr.get(AttributeKey.Label)));
map.put(Out.LEDDESCRIPTION.getName(), attr -> new LEDShape(attr.get(AttributeKey.Label), attr.get(AttributeKey.Color)));
map.put(Probe.DESCRIPTION.getName(), attr -> new ProbeShape(attr.get(AttributeKey.Label)));
map.put(Clock.DESCRIPTION.getName(), attr -> new ClockShape(attr.get(AttributeKey.Label)));
map.put(Out.SEVENDESCRIPTION.getName(), attr -> new SevenSegShape(attr.get(AttributeKey.Label), attr.get(AttributeKey.Color)));
map.put(Out.SEVENHEXDESCRIPTION.getName(), attr -> new SevenSegHexShape(attr.get(AttributeKey.Label), attr.get(AttributeKey.Color)));
map.put(In.DESCRIPTION.getName(), InputShape::new);
map.put(Reset.DESCRIPTION.getName(), ResetShape::new);
map.put(Const.DESCRIPTION.getName(), ConstShape::new);
map.put(Out.DESCRIPTION.getName(), OutputShape::new);
map.put(Out.LEDDESCRIPTION.getName(), LEDShape::new);
map.put(Probe.DESCRIPTION.getName(), ProbeShape::new);
map.put(Clock.DESCRIPTION.getName(), ClockShape::new);
map.put(Out.SEVENDESCRIPTION.getName(), SevenSegShape::new);
map.put(Out.SEVENHEXDESCRIPTION.getName(), SevenSegHexShape::new);
map.put(DummyElement.DATADESCRIPTION.getName(), DataShape::new);
map.put(Break.DESCRIPTION.getName(), attributes -> new BreakShape(attributes.get(AttributeKey.Label)));
map.put(Break.DESCRIPTION.getName(), BreakShape::new);
map.put(Multiplexer.DESCRIPTION.getName(), attr -> new MuxerShape(attr.get(AttributeKey.SelectorBits), attr.get(AttributeKey.FlipSelPositon)));
map.put(Demultiplexer.DESCRIPTION.getName(), attr -> new DemuxerShape(attr.get(AttributeKey.SelectorBits), true, attr.get(AttributeKey.FlipSelPositon)));
map.put(Decoder.DESCRIPTION.getName(), attr -> new DemuxerShape(attr.get(AttributeKey.SelectorBits), false, attr.get(AttributeKey.FlipSelPositon)));
map.put(Multiplexer.DESCRIPTION.getName(), MuxerShape::new);
map.put(Demultiplexer.DESCRIPTION.getName(), attr -> new DemuxerShape(attr, true));
map.put(Decoder.DESCRIPTION.getName(), attr -> new DemuxerShape(attr, false));
map.put(Splitter.DESCRIPTION.getName(), attr -> new SplitterShape(attr.get(AttributeKey.InputSplit), attr.get(AttributeKey.OutputSplit)));
map.put(Driver.DESCRIPTION.getName(), attr -> new DriverShape(attr.get(AttributeKey.FlipSelPositon)));
map.put(Splitter.DESCRIPTION.getName(), SplitterShape::new);
map.put(Driver.DESCRIPTION.getName(), DriverShape::new);
}
private OutputPinInfo[] outputInfos(ElementTypeDescription description, ElementAttributes attributes) {

View File

@ -2,6 +2,8 @@ package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.BitsException;
import de.neemann.digital.core.Observer;
import de.neemann.digital.core.element.AttributeKey;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.wiring.Splitter;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
@ -20,7 +22,9 @@ public class SplitterShape implements Shape {
private final int length;
private Pins pins;
public SplitterShape(String inputDef, String outputDef) throws BitsException {
public SplitterShape(ElementAttributes attr) throws BitsException {
String inputDef = attr.get(AttributeKey.InputSplit);
String outputDef = attr.get(AttributeKey.OutputSplit);
inputs = new Splitter.Ports(inputDef).getNames();
outputs = new Splitter.Ports(outputDef).getNames();
length = (Math.max(inputs.length, outputs.length) - 1) * SIZE + 2;

View File

@ -550,6 +550,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
@Override
public void hasChanged() {
try {
model.fireManualChangeEvent();
model.doStep();
circuitComponent.repaint();
} catch (NodeException | RuntimeException e) {

View File

@ -56,9 +56,11 @@ public class DataSample {
*
* @param i the index of the value
* @param value the value
* @return this for chained calls
*/
public void setValue(int i, long value) {
public DataSample setValue(int i, long value) {
values[i] = value;
return this;
}
/**

View File

@ -24,6 +24,23 @@ public class DataSet implements Iterable<DataSample>, Drawable {
private DataSample min;
private DataSample max;
/**
* Creates a simple dummy DataSet used for creating the DataShape
*/
public DataSet() {
this(createDummy());
add(new DataSample(0, signalSize()));
add(new DataSample(1, signalSize()).setValue(1, 1));
}
private static ArrayList<Model.Signal> createDummy() {
ArrayList<Model.Signal> list = new ArrayList<>();
list.add(new Model.Signal("A", null));
list.add(new Model.Signal("B", null));
list.add(new Model.Signal("C", null));
return list;
}
/**
* Creates a new instance
*
@ -173,4 +190,8 @@ public class DataSet implements Iterable<DataSample>, Drawable {
public int getGraphicHeight() {
return signalSize() * (SIZE + SEP) + 2 * BORDER;
}
public ArrayList<Model.Signal> getSignals() {
return signals;
}
}

View File

@ -19,12 +19,10 @@ import java.util.List;
* @author hneemann
*/
public class DataSetDialog extends JDialog implements ModelStateObserver {
private final ModelEvent.Event type;
private final ArrayList<Model.Signal> signals;
private final DataSetComponent dsc;
private DataSample manualSample;
private int maintime;
private DataSet dataSet;
private DataSetObserver dataSetObserver;
/**
* Creates a new instance
@ -38,7 +36,6 @@ public class DataSetDialog extends JDialog implements ModelStateObserver {
super(owner, Lang.get("win_measures"), false);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setAlwaysOnTop(true);
this.type = type;
signals = model.getSignalsCopy();
new OrderMerger<String, Model.Signal>(ordering) {
@ -50,6 +47,8 @@ public class DataSetDialog extends JDialog implements ModelStateObserver {
dataSet = new DataSet(signals);
dataSetObserver = new DataSetObserver(type, dataSet);
dsc = new DataSetComponent(dataSet);
JScrollPane scrollPane = new JScrollPane(dsc);
getContentPane().add(scrollPane);
@ -75,21 +74,7 @@ public class DataSetDialog extends JDialog implements ModelStateObserver {
@Override
public void handleEvent(ModelEvent event) {
if (event.getType() == ModelEvent.Event.MANUALCHANGE) {
if (manualSample == null)
manualSample = new DataSample(maintime, signals.size());
manualSample.fillWith(signals);
}
if (event.getType() == type) {
if (manualSample != null) {
dataSet.add(manualSample);
manualSample = null;
maintime++;
}
dataSet.add(new DataSample(maintime, signals.size()).fillWith(signals));
maintime++;
}
dataSetObserver.handleEvent(event);
dsc.revalidate();
dsc.repaint();
}

View File

@ -0,0 +1,41 @@
package de.neemann.digital.gui.components.data;
import de.neemann.digital.core.ModelEvent;
import de.neemann.digital.core.ModelStateObserver;
/**
* @author hneemann
*/
public class DataSetObserver implements ModelStateObserver {
private final DataSet dataSet;
private final ModelEvent.Event type;
private DataSample manualSample;
private int maintime;
public DataSetObserver(ModelEvent.Event type, DataSet dataSet) {
this.type = type;
this.dataSet = dataSet;
}
@Override
public void handleEvent(ModelEvent event) {
if (event.getType() == ModelEvent.Event.MANUALCHANGE) {
if (manualSample == null)
manualSample = new DataSample(maintime, dataSet.signalSize());
manualSample.fillWith(dataSet.getSignals());
}
if (event.getType() == type) {
if (manualSample != null) {
dataSet.add(manualSample);
manualSample = null;
maintime++;
}
dataSet.add(new DataSample(maintime, dataSet.signalSize()).fillWith(dataSet.getSignals()));
maintime++;
}
}
}

View File

@ -0,0 +1,46 @@
package de.neemann.digital.gui.components.data;
import de.neemann.digital.core.Model;
import de.neemann.digital.core.NodeException;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.element.AttributeKey;
import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
/**
* Only a placeholder.
* Has no connections to the model!
*
* @author hneemann
*/
public class DummyElement implements Element {
/**
* The DataElement description
*/
public static final ElementTypeDescription DATADESCRIPTION = new ElementTypeDescription("Data", DummyElement.class)
.addAttribute(AttributeKey.MicroStep);
/**
* Creates a new dummy element
*
* @param attr the attributes
*/
public DummyElement(ElementAttributes attr) {
}
@Override
public void setInputs(ObservableValue... inputs) throws NodeException {
}
@Override
public ObservableValue[] getOutputs() {
return new ObservableValue[0];
}
@Override
public void registerNodes(Model model) {
}
}

View File

@ -36,7 +36,7 @@ key_showListing=Zeige Listing an, wenn verf\u00FCgbar
key_showDataTable=Zeige Messwertetabelle
key_showDataGraph=Zeige Messwertegraph
key_startClock=Starte den Takt
key_microStep=Zeige Mikroschritte
rot_0=0\u00B0
rot_90=90\u00B0

View File

@ -36,6 +36,7 @@ key_showListing=Show list file if available
key_showDataTable=Show measurement values
key_showDataGraph=Show measurement graph
key_startClock=Start timer
key_microStep=Show micro steps
rot_0=0\u00B0
rot_90=90\u00B0