diff --git a/src/main/java/de/neemann/digital/core/element/ElementTypeDescription.java b/src/main/java/de/neemann/digital/core/element/ElementTypeDescription.java
index 930d2300a..f2a8353af 100644
--- a/src/main/java/de/neemann/digital/core/element/ElementTypeDescription.java
+++ b/src/main/java/de/neemann/digital/core/element/ElementTypeDescription.java
@@ -7,7 +7,6 @@ package de.neemann.digital.core.element;
import de.neemann.digital.core.NodeException;
import de.neemann.digital.draw.elements.PinException;
-import de.neemann.digital.gui.Main;
import de.neemann.digital.lang.Lang;
import java.lang.reflect.Constructor;
@@ -71,8 +70,6 @@ public class ElementTypeDescription {
if (p.getDirection() != PinDescription.Direction.input)
throw new RuntimeException("pin direction error");
attributeList = new ArrayList<>();
- if (Main.isExperimentalMode())
- attributeList.add(Keys.GENERIC);
}
/**
diff --git a/src/main/java/de/neemann/digital/core/element/Keys.java b/src/main/java/de/neemann/digital/core/element/Keys.java
index 5659a5779..90ec2fead 100644
--- a/src/main/java/de/neemann/digital/core/element/Keys.java
+++ b/src/main/java/de/neemann/digital/core/element/Keys.java
@@ -790,4 +790,10 @@ public final class Keys {
public static final Key GENERIC =
new Key.LongString("generic").allowGroupEdit();
+ /**
+ * Circuit is generic
+ */
+ public static final Key IS_GENERIC =
+ new Key("isGeneric", false).setSecondary();
+
}
diff --git a/src/main/java/de/neemann/digital/gui/components/CircuitComponent.java b/src/main/java/de/neemann/digital/gui/components/CircuitComponent.java
index abd33f3f6..9c38f3079 100644
--- a/src/main/java/de/neemann/digital/gui/components/CircuitComponent.java
+++ b/src/main/java/de/neemann/digital/gui/components/CircuitComponent.java
@@ -79,6 +79,8 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
ATTR_LIST.add(Keys.PRELOAD_PROGRAM);
ATTR_LIST.add(Keys.PROGRAM_TO_PRELOAD);
ATTR_LIST.add(Keys.TRANSISTORS);
+ if (Main.isExperimentalMode())
+ ATTR_LIST.add(Keys.IS_GENERIC);
}
/**
@@ -1021,14 +1023,13 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
}
private void editAttributes(VisualElement element, MouseEvent e) {
- String name = element.getElementName();
try {
- ElementTypeDescription elementType = library.getElementType(name);
- ArrayList list = elementType.getAttributeList();
+ ArrayList list = getAttributeList(element);
if (list.size() > 0) {
Point p = new Point(e.getX(), e.getY());
SwingUtilities.convertPointToScreen(p, CircuitComponent.this);
AttributeDialog attributeDialog = new AttributeDialog(parent, p, list, element.getElementAttributes()).setVisualElement(element);
+ ElementTypeDescription elementType = library.getElementType(element.getElementName());
if (elementType instanceof ElementLibrary.ElementTypeDescriptionCustom) {
attributeDialog.addButton(Lang.get("attr_openCircuitLabel"), new ToolTipAction(Lang.get("attr_openCircuit")) {
@Override
@@ -1179,7 +1180,7 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
for (VisualElement ve : getCircuit().getElements())
if (ve.matches(min, max)) {
elementList.add(ve);
- for (Key k : library.getElementType(ve.getElementName()).getAttributeList()) {
+ for (Key k : getAttributeList(ve)) {
if (k.isGroupEditAllowed()) {
if (keyList.contains(k)) {
if (!ve.getElementAttributes().get(k).equals(attr.get(k))) {
@@ -1207,7 +1208,7 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
if (ad.getCheckBoxes().get(key).isSelected()) {
Object newVal = mod.get(key);
for (VisualElement ve : elementList) {
- if (library.getElementType(ve.getElementName()).getAttributeList().contains(key)) {
+ if (getAttributeList(ve).contains(key)) {
if (!ve.getElementAttributes().get(key).equals(newVal))
modBuilder.add(new ModifyAttribute<>(ve, key, newVal));
}
@@ -1218,10 +1219,19 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
}
} catch (ElementNotFoundException e) {
- // Do nothing if an element is not in library
+ // Do nothing if an element is not in the library
}
}
+ private ArrayList getAttributeList(VisualElement ve) throws ElementNotFoundException {
+ ArrayList list = library.getElementType(ve.getElementName()).getAttributeList();
+ if (getCircuit().getAttributes().get(Keys.IS_GENERIC)) {
+ list = new ArrayList<>(list);
+ list.add(Keys.GENERIC);
+ }
+ return list;
+ }
+
/**
* @return true if circuit is modified
*/
diff --git a/src/main/resources/analyser/Counter.dig b/src/main/resources/analyser/Counter.dig
index 3ccd5fe9b..7a9c7a31c 100644
--- a/src/main/resources/analyser/Counter.dig
+++ b/src/main/resources/analyser/Counter.dig
@@ -1,7 +1,12 @@
1
-
+
+
+ isGeneric
+ true
+
+
In
diff --git a/src/main/resources/analyser/CounterPreset.dig b/src/main/resources/analyser/CounterPreset.dig
index 45e41e2fe..b83e4d9ca 100644
--- a/src/main/resources/analyser/CounterPreset.dig
+++ b/src/main/resources/analyser/CounterPreset.dig
@@ -1,7 +1,12 @@
1
-
+
+
+ isGeneric
+ true
+
+
In
@@ -11,7 +16,7 @@
en
-
+
Clock
@@ -33,7 +38,7 @@
2
-
+
In
@@ -43,7 +48,7 @@
dir
-
+
Out
@@ -61,7 +66,7 @@
this.Bits=orig.Bits;
-
+
Out
@@ -71,7 +76,7 @@
ovf
-
+
D_FF
@@ -89,7 +94,7 @@
this.Bits=orig.Bits;
-
+
Multiplexer
@@ -103,7 +108,7 @@
this.Bits=orig.Bits;
-
+
Multiplexer
@@ -131,12 +136,12 @@
this.Bits=orig.Bits;
-
+
Ground
-
+
Const
@@ -150,12 +155,12 @@
this.Bits=orig.Bits;
-
+
And
-
+
Multiplexer
@@ -169,7 +174,7 @@
this.Bits=orig.Bits;
-
+
Const
@@ -187,7 +192,7 @@
this.Bits=orig.Bits;
-
+
In
@@ -223,7 +228,7 @@
this.Bits=orig.Bits;
-
+
Const
@@ -246,7 +251,7 @@ if (orig.maxValue=0) {
}
-
+
Or
@@ -300,7 +305,7 @@ if (orig.maxValue=0) {
-
+
Multiplexer
@@ -314,7 +319,7 @@ if (orig.maxValue=0) {
this.Bits=orig.Bits;
-
+
In
@@ -338,7 +343,7 @@ if (orig.maxValue=0) {
clr
-
+
Multiplexer
@@ -356,7 +361,7 @@ if (orig.maxValue=0) {
this.Bits=orig.Bits;
-
+
Const
@@ -374,12 +379,12 @@ if (orig.maxValue=0) {
this.Bits=orig.Bits;
-
+
XOr
-
+
Const
@@ -395,12 +400,12 @@ if (orig.maxValue=0) {
}
-
+
XOr
-
+
Const
@@ -416,12 +421,12 @@ if (orig.maxValue=0) {
}
-
+
XOr
-
+
Const
@@ -437,7 +442,7 @@ if (orig.maxValue=0) {
}
-
+
XOr
@@ -507,107 +512,99 @@ if (orig.inverterConfig.in) {
-
-
+
+
-
-
+
+
-
-
-
-
-
+
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
+
+
-
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -615,96 +612,104 @@ if (orig.inverterConfig.in) {
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -716,43 +721,35 @@ if (orig.inverterConfig.in) {
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
+
-
+
@@ -760,7 +757,23 @@ if (orig.inverterConfig.in) {
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -768,7 +781,7 @@ if (orig.inverterConfig.in) {
-
+
diff --git a/src/main/resources/analyser/JK_FF.dig b/src/main/resources/analyser/JK_FF.dig
index 6d7c380a2..501696d43 100644
--- a/src/main/resources/analyser/JK_FF.dig
+++ b/src/main/resources/analyser/JK_FF.dig
@@ -1,7 +1,12 @@
1
-
+
+
+ isGeneric
+ true
+
+
D_FF
diff --git a/src/main/resources/analyser/T_FF_EN.dig b/src/main/resources/analyser/T_FF_EN.dig
index 8d3d878f8..213cdf465 100644
--- a/src/main/resources/analyser/T_FF_EN.dig
+++ b/src/main/resources/analyser/T_FF_EN.dig
@@ -1,7 +1,12 @@
1
-
+
+
+ isGeneric
+ true
+
+
D_FF
diff --git a/src/main/resources/lang/lang_de.xml b/src/main/resources/lang/lang_de.xml
index 398a978f7..7f394ebe0 100644
--- a/src/main/resources/lang/lang_de.xml
+++ b/src/main/resources/lang/lang_de.xml
@@ -1343,6 +1343,9 @@ Sind evtl. die Namen der Variablen nicht eindeutig?
Generisch
Anweisung um eine generische Schaltung anzupassen.
+ Schaltung ist generisch
+ Erlaubt die Erzeugung von generischen Schaltungen.
+
Leitung eingefügt.
Aus Zwischenablage eingefügt.
Wert ''{0}'' in Element ''{1}'' verändert.
diff --git a/src/main/resources/lang/lang_en.xml b/src/main/resources/lang/lang_en.xml
index 586e439a6..52e0dbd57 100644
--- a/src/main/resources/lang/lang_en.xml
+++ b/src/main/resources/lang/lang_en.xml
@@ -1313,8 +1313,8 @@
MIDI instrument
The MIDI instrument to use.
Allow program change
- Adds a new input PC. If this input is set to high,
- the value at input N is used to change te program (instrument).
+ Adds a new input PC. If this input is set to high,
+ the value at input N is used to change the program (instrument).
Transistors
Number of transistors required. Used for circuit statistics.
@@ -1331,6 +1331,9 @@
Generic
Statements used to generify a circuit.
+ Circuit is generic
+ Allows to create a generic circuit.
+
Inserted wire.
Insert from clipboard.
Value ''{0}'' in component ''{1}'' modified.
diff --git a/src/main/resources/lang/lang_es_ref.xml b/src/main/resources/lang/lang_es_ref.xml
index d3dddb618..75f3d02b5 100644
--- a/src/main/resources/lang/lang_es_ref.xml
+++ b/src/main/resources/lang/lang_es_ref.xml
@@ -1175,8 +1175,8 @@
MIDI instrument
The MIDI instrument to use.
Allow program change
- Adds a new input PC. If this input is set to high,
- the value at input N is used to change te program (instrument).
+ Adds a new input PC. If this input is set to high,
+ the value at input N is used to change the program (instrument).
Inserted wire.
Insert from clipboard.
Value ''{0}'' in component ''{1}'' modified.
diff --git a/src/main/resources/lang/lang_pt_ref.xml b/src/main/resources/lang/lang_pt_ref.xml
index b14bde294..88702e011 100644
--- a/src/main/resources/lang/lang_pt_ref.xml
+++ b/src/main/resources/lang/lang_pt_ref.xml
@@ -1304,8 +1304,8 @@
MIDI instrument
The MIDI instrument to use.
Allow program change
- Adds a new input PC. If this input is set to high,
- the value at input N is used to change te program (instrument).
+ Adds a new input PC. If this input is set to high,
+ the value at input N is used to change the program (instrument).
Inserted wire.
Insert from clipboard.