|
@@ -10,6 +10,7 @@
|
|
|
*/
|
|
|
package org.yakindu.sct.runtime.java.test_hierarchy;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
import java.util.EnumSet;
|
|
|
import java.util.HashSet;
|
|
@@ -17,9 +18,7 @@ import java.util.Set;
|
|
|
import org.yakindu.sct.runtime.java.Event;
|
|
|
import org.yakindu.sct.runtime.java.IStatemachine;
|
|
|
|
|
|
-public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
- implements
|
|
|
- IStatemachine {
|
|
|
+public class Test_HierarchyCycleBasedStatemachine implements IStatemachine {
|
|
|
|
|
|
public enum State {
|
|
|
State1, State9, State10, State2, State3, State4, State5, State6, State7, State8,
|
|
@@ -29,14 +28,13 @@ public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
|
|
|
private final Set<State> activeStates = EnumSet.noneOf(State.class);
|
|
|
|
|
|
- private final Collection<Event> occuredEvents;
|
|
|
+ private final ArrayList<Event> occuredEvents;
|
|
|
|
|
|
private final Collection<Event> outEvents;
|
|
|
|
|
|
- public Test_HierarchyAbstractBaseStatemachine(
|
|
|
- Collection<Event> occuredEvents) {
|
|
|
- this.occuredEvents = occuredEvents;
|
|
|
- this.outEvents = new HashSet<Event>();
|
|
|
+ public Test_HierarchyCycleBasedStatemachine() {
|
|
|
+ occuredEvents = new ArrayList<Event>();
|
|
|
+ outEvents = new HashSet<Event>();
|
|
|
interfaceDefault = new InterfaceDefaultImpl(this);
|
|
|
}
|
|
|
|
|
@@ -49,7 +47,7 @@ public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
}
|
|
|
|
|
|
protected boolean eventOccured() {
|
|
|
- return !getOccuredEvents().isEmpty();
|
|
|
+ return !occuredEvents.isEmpty();
|
|
|
}
|
|
|
|
|
|
public void init() {
|
|
@@ -68,53 +66,53 @@ public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
enterSequenceState1();
|
|
|
}
|
|
|
|
|
|
- private boolean conditionState1Tr0(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent1());
|
|
|
+ private boolean conditionState1Tr0() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent1());
|
|
|
}
|
|
|
- private boolean conditionState9Tr0(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent9());
|
|
|
+ private boolean conditionState9Tr0() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent9());
|
|
|
}
|
|
|
- private boolean conditionState10Tr0(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent10());
|
|
|
+ private boolean conditionState10Tr0() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent10());
|
|
|
}
|
|
|
- private boolean conditionState2Tr0(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent6());
|
|
|
+ private boolean conditionState2Tr0() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent6());
|
|
|
}
|
|
|
- private boolean conditionState3Tr0(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent2());
|
|
|
+ private boolean conditionState3Tr0() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent2());
|
|
|
}
|
|
|
- private boolean conditionState3Tr1(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent11());
|
|
|
+ private boolean conditionState3Tr1() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent11());
|
|
|
}
|
|
|
- private boolean conditionState3Tr2(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent14());
|
|
|
+ private boolean conditionState3Tr2() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent14());
|
|
|
}
|
|
|
- private boolean conditionState4Tr0(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent7());
|
|
|
+ private boolean conditionState4Tr0() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent7());
|
|
|
}
|
|
|
- private boolean conditionState5Tr0(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent3());
|
|
|
+ private boolean conditionState5Tr0() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent3());
|
|
|
}
|
|
|
- private boolean conditionState5Tr1(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent12());
|
|
|
+ private boolean conditionState5Tr1() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent12());
|
|
|
}
|
|
|
- private boolean conditionState5Tr2(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent15());
|
|
|
+ private boolean conditionState5Tr2() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent15());
|
|
|
}
|
|
|
- private boolean conditionState6Tr0(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent8());
|
|
|
+ private boolean conditionState6Tr0() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent8());
|
|
|
}
|
|
|
- private boolean conditionState7Tr0(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent4());
|
|
|
+ private boolean conditionState7Tr0() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent4());
|
|
|
}
|
|
|
- private boolean conditionState8Tr0(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent5());
|
|
|
+ private boolean conditionState8Tr0() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent5());
|
|
|
}
|
|
|
- private boolean conditionState8Tr1(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent13());
|
|
|
+ private boolean conditionState8Tr1() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent13());
|
|
|
}
|
|
|
- private boolean conditionState8Tr2(Collection<?> events) {
|
|
|
- return getOccuredEvents().contains(interfaceDefault.getEventEvent16());
|
|
|
+ private boolean conditionState8Tr2() {
|
|
|
+ return occuredEvents.contains(interfaceDefault.getEventEvent16());
|
|
|
}
|
|
|
private void actionsState1Tr0() {
|
|
|
exitSequenceState1();
|
|
@@ -363,8 +361,19 @@ public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
if (activeStates.contains(State.State3)) {
|
|
|
exitSequenceState3();
|
|
|
|
|
|
- } else if (activeStates.contains(State.State4)) {
|
|
|
- exitSequenceState4();
|
|
|
+ } else if (activeStates.contains(State.State5)) {
|
|
|
+ exitSequenceState5();
|
|
|
+ exitActionState4();
|
|
|
+
|
|
|
+ } else if (activeStates.contains(State.State7)) {
|
|
|
+ exitSequenceState7();
|
|
|
+ exitActionState6();
|
|
|
+ exitActionState4();
|
|
|
+
|
|
|
+ } else if (activeStates.contains(State.State8)) {
|
|
|
+ exitSequenceState8();
|
|
|
+ exitActionState6();
|
|
|
+ exitActionState4();
|
|
|
|
|
|
}
|
|
|
exitActionState2();
|
|
@@ -377,8 +386,13 @@ public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
if (activeStates.contains(State.State5)) {
|
|
|
exitSequenceState5();
|
|
|
|
|
|
- } else if (activeStates.contains(State.State6)) {
|
|
|
- exitSequenceState6();
|
|
|
+ } else if (activeStates.contains(State.State7)) {
|
|
|
+ exitSequenceState7();
|
|
|
+ exitActionState6();
|
|
|
+
|
|
|
+ } else if (activeStates.contains(State.State8)) {
|
|
|
+ exitSequenceState8();
|
|
|
+ exitActionState6();
|
|
|
|
|
|
}
|
|
|
exitActionState4();
|
|
@@ -405,41 +419,41 @@ public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
activeStates.remove(State.State8);
|
|
|
exitActionState8();
|
|
|
}
|
|
|
- private void cycleState1(Collection<?> events) {
|
|
|
+ private void reactState1() {
|
|
|
}
|
|
|
- private void cycleState9(Collection<?> events) {
|
|
|
- if (conditionState1Tr0(events)) {
|
|
|
+ private void reactState9() {
|
|
|
+ if (conditionState1Tr0()) {
|
|
|
actionsState1Tr0();
|
|
|
} else {
|
|
|
- if (conditionState9Tr0(events)) {
|
|
|
+ if (conditionState9Tr0()) {
|
|
|
actionsState9Tr0();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- private void cycleState10(Collection<?> events) {
|
|
|
- if (conditionState1Tr0(events)) {
|
|
|
+ private void reactState10() {
|
|
|
+ if (conditionState1Tr0()) {
|
|
|
actionsState1Tr0();
|
|
|
} else {
|
|
|
- if (conditionState10Tr0(events)) {
|
|
|
+ if (conditionState10Tr0()) {
|
|
|
actionsState10Tr0();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- private void cycleState2(Collection<?> events) {
|
|
|
+ private void reactState2() {
|
|
|
}
|
|
|
- private void cycleState3(Collection<?> events) {
|
|
|
- if (conditionState2Tr0(events)) {
|
|
|
+ private void reactState3() {
|
|
|
+ if (conditionState2Tr0()) {
|
|
|
actionsState2Tr0();
|
|
|
} else {
|
|
|
- if (conditionState3Tr0(events)) {
|
|
|
+ if (conditionState3Tr0()) {
|
|
|
actionsState3Tr0();
|
|
|
} else {
|
|
|
- if (conditionState3Tr1(events)) {
|
|
|
+ if (conditionState3Tr1()) {
|
|
|
actionsState3Tr1();
|
|
|
} else {
|
|
|
- if (conditionState3Tr2(events)) {
|
|
|
+ if (conditionState3Tr2()) {
|
|
|
actionsState3Tr2();
|
|
|
}
|
|
|
}
|
|
@@ -447,22 +461,22 @@ public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- private void cycleState4(Collection<?> events) {
|
|
|
+ private void reactState4() {
|
|
|
}
|
|
|
- private void cycleState5(Collection<?> events) {
|
|
|
- if (conditionState2Tr0(events)) {
|
|
|
+ private void reactState5() {
|
|
|
+ if (conditionState2Tr0()) {
|
|
|
actionsState2Tr0();
|
|
|
} else {
|
|
|
- if (conditionState4Tr0(events)) {
|
|
|
+ if (conditionState4Tr0()) {
|
|
|
actionsState4Tr0();
|
|
|
} else {
|
|
|
- if (conditionState5Tr0(events)) {
|
|
|
+ if (conditionState5Tr0()) {
|
|
|
actionsState5Tr0();
|
|
|
} else {
|
|
|
- if (conditionState5Tr1(events)) {
|
|
|
+ if (conditionState5Tr1()) {
|
|
|
actionsState5Tr1();
|
|
|
} else {
|
|
|
- if (conditionState5Tr2(events)) {
|
|
|
+ if (conditionState5Tr2()) {
|
|
|
actionsState5Tr2();
|
|
|
}
|
|
|
}
|
|
@@ -472,19 +486,19 @@ public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- private void cycleState6(Collection<?> events) {
|
|
|
+ private void reactState6() {
|
|
|
}
|
|
|
- private void cycleState7(Collection<?> events) {
|
|
|
- if (conditionState2Tr0(events)) {
|
|
|
+ private void reactState7() {
|
|
|
+ if (conditionState2Tr0()) {
|
|
|
actionsState2Tr0();
|
|
|
} else {
|
|
|
- if (conditionState4Tr0(events)) {
|
|
|
+ if (conditionState4Tr0()) {
|
|
|
actionsState4Tr0();
|
|
|
} else {
|
|
|
- if (conditionState6Tr0(events)) {
|
|
|
+ if (conditionState6Tr0()) {
|
|
|
actionsState6Tr0();
|
|
|
} else {
|
|
|
- if (conditionState7Tr0(events)) {
|
|
|
+ if (conditionState7Tr0()) {
|
|
|
actionsState7Tr0();
|
|
|
}
|
|
|
|
|
@@ -494,23 +508,23 @@ public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- private void cycleState8(Collection<?> events) {
|
|
|
- if (conditionState2Tr0(events)) {
|
|
|
+ private void reactState8() {
|
|
|
+ if (conditionState2Tr0()) {
|
|
|
actionsState2Tr0();
|
|
|
} else {
|
|
|
- if (conditionState4Tr0(events)) {
|
|
|
+ if (conditionState4Tr0()) {
|
|
|
actionsState4Tr0();
|
|
|
} else {
|
|
|
- if (conditionState6Tr0(events)) {
|
|
|
+ if (conditionState6Tr0()) {
|
|
|
actionsState6Tr0();
|
|
|
} else {
|
|
|
- if (conditionState8Tr0(events)) {
|
|
|
+ if (conditionState8Tr0()) {
|
|
|
actionsState8Tr0();
|
|
|
} else {
|
|
|
- if (conditionState8Tr1(events)) {
|
|
|
+ if (conditionState8Tr1()) {
|
|
|
actionsState8Tr1();
|
|
|
} else {
|
|
|
- if (conditionState8Tr2(events)) {
|
|
|
+ if (conditionState8Tr2()) {
|
|
|
actionsState8Tr2();
|
|
|
}
|
|
|
}
|
|
@@ -522,43 +536,44 @@ public abstract class Test_HierarchyAbstractBaseStatemachine
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- protected void runCycle(Collection<?> events) {
|
|
|
- getOutEvents().clear();
|
|
|
+ public void runCycle() {
|
|
|
+ outEvents.clear();
|
|
|
for (State state : activeStates) {
|
|
|
switch (state) {
|
|
|
case State1 :
|
|
|
- cycleState1(events);
|
|
|
+ reactState1();
|
|
|
break;
|
|
|
case State9 :
|
|
|
- cycleState9(events);
|
|
|
+ reactState9();
|
|
|
break;
|
|
|
case State10 :
|
|
|
- cycleState10(events);
|
|
|
+ reactState10();
|
|
|
break;
|
|
|
case State2 :
|
|
|
- cycleState2(events);
|
|
|
+ reactState2();
|
|
|
break;
|
|
|
case State3 :
|
|
|
- cycleState3(events);
|
|
|
+ reactState3();
|
|
|
break;
|
|
|
case State4 :
|
|
|
- cycleState4(events);
|
|
|
+ reactState4();
|
|
|
break;
|
|
|
case State5 :
|
|
|
- cycleState5(events);
|
|
|
+ reactState5();
|
|
|
break;
|
|
|
case State6 :
|
|
|
- cycleState6(events);
|
|
|
+ reactState6();
|
|
|
break;
|
|
|
case State7 :
|
|
|
- cycleState7(events);
|
|
|
+ reactState7();
|
|
|
break;
|
|
|
case State8 :
|
|
|
- cycleState8(events);
|
|
|
+ reactState8();
|
|
|
break;
|
|
|
default :
|
|
|
// no state found
|
|
|
}
|
|
|
}
|
|
|
+ occuredEvents.clear();
|
|
|
}
|
|
|
}
|