diff --git a/src/main/fsm/SevenSegCounter.fsm b/src/main/fsm/SevenSegCounter.fsm
index 93021ad1a..0f7d32431 100644
--- a/src/main/fsm/SevenSegCounter.fsm
+++ b/src/main/fsm/SevenSegCounter.fsm
@@ -2,209 +2,209 @@
+ S=0111111
0
0
90
- S=0111111
+ S=0000110
1
1
90
- S=0000110
+ S=1011011
2
2
90
- S=1011011
+ S=1001111
3
3
90
- S=1001111
+ S=1100110
4
4
90
- S=1100110
+ S=1101101
5
5
90
- S=1101101
+ S=1111101
6
6
90
- S=1111101
+ S=0000111
7
7
90
- S=0000111
+ S=1111111
8
8
90
- S=1111111
+ S=1101111
9
9
90
- S=1101111
-
+
+
en=1 & clr=0
-
-
+
+
en=1 & clr=0
-
+
en=1 & clr=0
-
-
+
+
en=1 & clr=0
-
-
+
+
en=1 & clr=0
-
-
+
+
en=1 & clr=0
-
-
+
+
en=1 & clr=0
-
+
en=1 & clr=0
-
+
en=1 & clr=0
-
-
+ ov=1
+
en=1 & clr=0
- ov=1
-
+
+
clr=1
-
-
+
+
clr=1
-
-
+
+
clr=1
-
-
+
+
clr=1
-
-
+
+
clr=1
-
-
+
+
clr=1
-
-
+
+
clr=1
-
-
+
+
clr=1
-
-
+
+
clr=1
-
\ No newline at end of file
diff --git a/src/main/java/de/neemann/digital/fsm/Movable.java b/src/main/java/de/neemann/digital/fsm/Movable.java
index 6ab9fc09a..d853f9b7b 100644
--- a/src/main/java/de/neemann/digital/fsm/Movable.java
+++ b/src/main/java/de/neemann/digital/fsm/Movable.java
@@ -9,8 +9,11 @@ import de.neemann.digital.draw.graphics.VectorFloat;
/**
* A movable element.
+ *
+ * @param the type of the implementing class
*/
-public abstract class Movable {
+public class Movable {
+ private String values = "";
private VectorFloat position;
private transient VectorFloat speed;
private transient VectorFloat force;
@@ -47,7 +50,7 @@ public abstract class Movable {
*
* @param df the force to add
*/
- public void addToForce(VectorFloat df) {
+ void addToForce(VectorFloat df) {
if (force == null)
force = df;
else
@@ -60,7 +63,7 @@ public abstract class Movable {
* @param pos the position of the causer of the force
* @param reach the reach of the force
*/
- public void addRepulsive(VectorFloat pos, float reach) {
+ void addRepulsive(VectorFloat pos, float reach) {
final VectorFloat dif = position.sub(pos);
float dist = dif.len();
if (dist == 0) {
@@ -96,14 +99,14 @@ public abstract class Movable {
* @param target the targe
* @param scale a scaling factor
*/
- public void addAttractiveTo(VectorFloat target, float scale) {
+ void addAttractiveTo(VectorFloat target, float scale) {
addToForce(target.sub(position).mul(scale));
}
/**
* @return the force
*/
- public VectorFloat getForce() {
+ VectorFloat getForce() {
if (force == null)
resetForce();
return force;
@@ -112,7 +115,7 @@ public abstract class Movable {
/**
* Sets the force to zero
*/
- public void resetForce() {
+ void resetForce() {
this.force = new VectorFloat(0, 0);
}
@@ -146,7 +149,23 @@ public abstract class Movable {
}
/**
- * @return the output values of this moveable
+ * Sets the values to define as a comma separated string with assignments: 'A=0,B=1'
+ *
+ * @param values the assignments
+ * @return this for chained calls
*/
- abstract public String getValues();
+ public A setValues(String values) {
+ if (!this.values.equals(values)) {
+ this.values = values;
+ wasModified();
+ }
+ return (A) this;
+ }
+
+ /**
+ * @return the state value map
+ */
+ public String getValues() {
+ return values;
+ }
}
diff --git a/src/main/java/de/neemann/digital/fsm/State.java b/src/main/java/de/neemann/digital/fsm/State.java
index c01bf495b..a1086902b 100644
--- a/src/main/java/de/neemann/digital/fsm/State.java
+++ b/src/main/java/de/neemann/digital/fsm/State.java
@@ -12,7 +12,7 @@ import java.util.List;
/**
* Represents a state
*/
-public class State extends Movable {
+public class State extends Movable {
/**
* The default state radius
*/
@@ -25,7 +25,6 @@ public class State extends Movable {
private int number = -1;
private String name;
private int radius;
- private String values = "";
/**
* Creates a new state
@@ -38,27 +37,6 @@ public class State extends Movable {
this.radius = DEFAULT_RAD;
}
- /**
- * Sets the values to define as a comma separated string with assignments: 'A=0,B=1'
- *
- * @param values the assignments
- * @return this for chained calls
- */
- public State setValues(String values) {
- if (!this.values.equals(values)) {
- this.values = values;
- wasModified();
- }
- return this;
- }
-
- /**
- * @return the state value map
- */
- public String getValues() {
- return values;
- }
-
/**
* @return the name of the state
*/
@@ -126,9 +104,9 @@ public class State extends Movable {
pos = pos.add(delta);
gr.drawText(pos, pos.add(new Vector(1, 0)), name, Orientation.CENTERCENTER, Style.NORMAL);
- if (values != null) {
+ if (getValues() != null && getValues().length() > 0) {
pos = pos.add(delta);
- gr.drawText(pos, pos.add(new Vector(1, 0)), values, Orientation.CENTERCENTER, Style.NORMAL);
+ gr.drawText(pos, pos.add(new Vector(1, 0)), getValues(), Orientation.CENTERCENTER, Style.NORMAL);
}
}
}
diff --git a/src/main/java/de/neemann/digital/fsm/Transition.java b/src/main/java/de/neemann/digital/fsm/Transition.java
index ec60df539..0c2ee5f9d 100644
--- a/src/main/java/de/neemann/digital/fsm/Transition.java
+++ b/src/main/java/de/neemann/digital/fsm/Transition.java
@@ -18,13 +18,12 @@ import java.util.List;
/**
* Represents a transition
*/
-public class Transition extends Movable {
+public class Transition extends Movable {
private static final float EXPANSION_TRANS = 0.001f;
private final State fromState;
private final State toState;
private String condition;
- private String values = "";
private transient Expression conditionExpression;
@@ -142,9 +141,9 @@ public class Transition extends Movable {
if (condition != null && condition.length() > 0) {
gr.drawText(getPos(), getPos().add(new Vector(1, 0)), condition, Orientation.CENTERCENTER, Style.NORMAL);
}
- if (values != null && values.length() > 0) {
+ if (getValues() != null && getValues().length() > 0) {
VectorFloat pos = getPos().add(new VectorFloat(0, Style.NORMAL.getFontSize()));
- gr.drawText(pos, pos.add(new Vector(1, 0)), values, Orientation.CENTERCENTER, Style.NORMAL);
+ gr.drawText(pos, pos.add(new Vector(1, 0)), getValues(), Orientation.CENTERCENTER, Style.NORMAL);
}
}
@@ -206,27 +205,6 @@ public class Transition extends Movable {
return getConditionExpression() != null;
}
- /**
- * @return the transitions values
- */
- public String getValues() {
- return values;
- }
-
- /**
- * Sets the values
- *
- * @param values the values to use
- * @return this for chained calls
- */
- public Transition setValues(String values) {
- if (!this.values.equals(values)) {
- this.values = values;
- wasModified();
- }
- return this;
- }
-
/**
* @return the starting state
*/